In Chrome, open an image by selecting "Open image in new tab" from the context menu. Open the console in the newly opened tab and run the following code:
document.open();
document.write("foo");
document.close();
Instead of a document with only the text "foo" in it, the result is, well, nothing at all. I first noticed this when jQuery failed to load, citing the document variable being undefined as the reason. The code works as expected in all other pages.
I also tried running the same thing in Firefox (except it was "View image") and it worked as expected, which leads me to believe this is specific to Chrome.
I have also noticed that, when you open an image in Firefox, the type of the document object isn't HTMLDocument, but ImageDocument. I have tried to find whether Chrome does something similar, but to no avail.
I'm writing a Chrome extension which also needs to stop all loaded Javascript and insert <!DOCTYPE html>
when necessary, so editing document.innerHTML
isn't an option.