diff options
author | jhaas@chromium.org <jhaas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-11 18:47:34 +0000 |
---|---|---|
committer | jhaas@chromium.org <jhaas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-11 18:47:34 +0000 |
commit | dcc45d06e47c3e07f18d4fbef6909f315a4f6210 (patch) | |
tree | ff6c5868633038b72c2c5256a7f4a49307113684 /webkit | |
parent | be18d3eae2db247dc5a0e211cc97579620324641 (diff) | |
download | chromium_src-dcc45d06e47c3e07f18d4fbef6909f315a4f6210.zip chromium_src-dcc45d06e47c3e07f18d4fbef6909f315a4f6210.tar.gz chromium_src-dcc45d06e47c3e07f18d4fbef6909f315a4f6210.tar.bz2 |
Fix Chromium bug 4178
"new Image()" was aliased in the V8 bindings to document.createElement('image').
While the behavior of new Image() doesn't appear to be well-defined in spec,
all other browsers always create an HTML image element, regardless of the type of
the current document. Changed our implementation to conform.
Review URL: http://codereview.chromium.org/10268
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5186 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
3 files changed, 20 insertions, 1 deletions
diff --git a/webkit/data/layout_tests/chrome/svg/custom/new-image-is-html-element-expected.txt b/webkit/data/layout_tests/chrome/svg/custom/new-image-is-html-element-expected.txt new file mode 100644 index 0000000..0cdd613 --- /dev/null +++ b/webkit/data/layout_tests/chrome/svg/custom/new-image-is-html-element-expected.txt @@ -0,0 +1 @@ +PASS
diff --git a/webkit/data/layout_tests/chrome/svg/custom/new-image-is-html-element.svg b/webkit/data/layout_tests/chrome/svg/custom/new-image-is-html-element.svg new file mode 100644 index 0000000..cfa0890 --- /dev/null +++ b/webkit/data/layout_tests/chrome/svg/custom/new-image-is-html-element.svg @@ -0,0 +1,14 @@ +<svg xmlns="http://www.w3.org/2000/svg"> + <text id="result" y="100"/> + <script> + if (window.layoutTestController) + layoutTestController.dumpAsText(); + + // Firefox, Opera, and Safari all treat "new Image()" as creating an + // HTML image element regardless of the current doctype. Ensure that + // Chrome's behavior is the same + + var pass = "[object HTMLImageElement]" == new Image(); + document.getElementById("result").appendChild(document.createTextNode(pass ? "PASS" : "FAIL")); + </script> +</svg> diff --git a/webkit/port/bindings/v8/v8_custom.cpp b/webkit/port/bindings/v8/v8_custom.cpp index b737061..b476a91 100644 --- a/webkit/port/bindings/v8/v8_custom.cpp +++ b/webkit/port/bindings/v8/v8_custom.cpp @@ -1330,9 +1330,13 @@ NAMED_PROPERTY_GETTER(DOMWindow) { // It must return the value of property after initialization. static HashMap<String, String> kLazyInitMap; if (kLazyInitMap.isEmpty()) { + // "new Image()" does not appear to be well-defined in a spec, but Safari, + // Opera, and Firefox all consider it to always create an HTML image + // element, regardless of the current doctype. kLazyInitMap.set("Image", "function Image() { \ - return document.createElement('image'); \ + return document.createElementNS( \ + 'http://www.w3.org/1999/xhtml', 'img'); \ }; \ Image"); kLazyInitMap.set("Option", |