fix($sce): do not assume $document[0] exists

this is important so that people can mock $window without having to add stuff that angular uses internally into it

Closes #9661
We will need this as ngScenario gets compiled up into a separate file with its own closure.
It just happens that our unit tests run with all the files in a single closure! (Which is bad but no one has the energy to fix it)