Allowing document.write in Image documents asserts the page.

Check the document type before writing into it. Add tests for checking the
assert/crash in TestRunner.

BUG=307650
R=abarth, japhet

Review URL: https://codereview.chromium.org/27148005

git-svn-id: svn://svn.chromium.org/blink/trunk@160233 bbb929c8-8fbe-4397-9dbb-9b2b20218538