Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / reparented-image-as-property.html
blob676fd33aa45ccd160a1e13412e239a306d2aaa8e
1 <body>
2 <p>Test access to images inside forms as form element propertyies. Expected results match IE, because its behavior makes much more sense than Firefox one.</p>
3 <div id="log"></div>
4 <form><img id="bar"></form>
5 <form></form>
6 <div id="div"></div>
7 <script>
8 if (window.testRunner)
9 testRunner.dumpAsText();
11 function log(msg)
13 document.getElementById("log").innerHTML += msg + "<br>";
15 function shouldBe(a, b)
17 var result = eval(a);
18 log((result == eval(b)) ? ("PASS: '" + a + "' is '" + b + "'.") : ("FAIL: '" + a + "' should be '" + b + "', was '" + result + "'."));
21 try {
22 var imgFoo = document.createElement("img");
23 var imgBar = document.body.getElementsByTagName("img")[0];
24 var div = document.getElementById("div");
25 imgFoo.setAttribute("id", "foo");
27 document.forms[0].appendChild(imgFoo);
28 document.forms[0].appendChild(imgBar);
30 document.forms[1].appendChild(imgFoo);
31 shouldBe('document.forms[0].foo', 'undefined');
32 shouldBe('document.forms[1].foo', 'imgFoo');
34 document.forms[0].removeChild(imgBar);
35 shouldBe('document.forms[0].bar', 'undefined');
37 // Don't leave a broken image icon in test results.
38 document.forms[1].removeChild(imgFoo);
40 log("DONE");
42 } catch (ex) {
43 log("FAIL: " + ex);
45 </script>