chromium/third_party/blink/web_tests/fast/forms/reparented-image-as-property.html

<body>
<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>
<div id="log"></div>
<form><img id="bar"></form>
<form></form>
<div id="div"></div>
<script>
if (window.testRunner)
    testRunner.dumpAsText();

function log(msg)
{
    document.getElementById("log").innerHTML += msg + "<br>";
}
function shouldBe(a, b)
{
    var result = eval(a);
    log((result == eval(b)) ? ("PASS: '" + a + "' is '" + b + "'.") : ("FAIL: '" + a + "' should be '" + b + "', was '" + result + "'."));
}

try {
    var imgFoo = document.createElement("img");
    var imgBar = document.body.getElementsByTagName("img")[0];
    var div = document.getElementById("div");
    imgFoo.setAttribute("id", "foo");

    document.forms[0].appendChild(imgFoo);
    document.forms[0].appendChild(imgBar);

    document.forms[1].appendChild(imgFoo);
    shouldBe('document.forms[0].foo', 'undefined');
    shouldBe('document.forms[1].foo', 'imgFoo');

    document.forms[0].removeChild(imgBar);
    shouldBe('document.forms[0].bar', 'undefined');

    // Don't leave a broken image icon in test results.
    document.forms[1].removeChild(imgFoo);

    log("DONE");

} catch (ex) {
    log("FAIL: " + ex);
}
</script>