diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/html/test/test_bug277724.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/html/test/test_bug277724.html')
-rw-r--r-- | dom/html/test/test_bug277724.html | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/dom/html/test/test_bug277724.html b/dom/html/test/test_bug277724.html new file mode 100644 index 000000000..39b54cb7d --- /dev/null +++ b/dom/html/test/test_bug277724.html @@ -0,0 +1,141 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=277724 +--> +<head> + <title>Test for Bug 277724</title> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=277724">Mozilla Bug 277724</a> +<p id="display"></p> +<pre id="test"> +<script class="testbody" type="text/javascript"> + +/** Test for Bug 277724 **/ + +var childUnloaded = false; + +var nodes = [ + [ "select", HTMLSelectElement ], + [ "textarea", HTMLTextAreaElement ], + [ "text", HTMLInputElement ], + [ "password", HTMLInputElement ], + [ "checkbox", HTMLInputElement ], + [ "radio", HTMLInputElement ], + [ "image", HTMLInputElement ], + [ "submit", HTMLInputElement ], + [ "reset", HTMLInputElement ], + [ "button input", HTMLInputElement ], + [ "hidden", HTMLInputElement ], + [ "file", HTMLInputElement ], + [ "submit button", HTMLButtonElement ], + [ "reset button", HTMLButtonElement ], + [ "button", HTMLButtonElement ] +]; + +function soon(f) { + return function() { setTimeout(f, 0); } +} + +function startTest(frameid) { + is(childUnloaded, false, "Child not unloaded yet"); + + var doc = $(frameid).contentDocument; + ok(doc instanceof Document, "Check for doc", "doc should be a document"); + + for (var i = 0; i < nodes.length; ++i) { + var id = nodes[i][0]; + var node = doc.getElementById(id); + ok(node instanceof nodes[i][1], + "Check for " + id, id + " should be a " + nodes[i][1]); + is(node.disabled, false, "check for " + id + " state"); + node.disabled = true; + is(node.disabled, true, "check for " + id + " state change"); + } + + $(frameid).onload = soon(function() { continueTest(frameid) }); + + // Do this off a timeout so it's not treated like a replace load. + function loadBlank() { + $(frameid).contentWindow.location = "about:blank"; + } + setTimeout(loadBlank, 0); +} + +function continueTest(frameid) { + is(childUnloaded, true, "Unload handler should have fired"); + var doc = $(frameid).contentDocument; + ok(doc instanceof Document, "Check for doc", "doc should be a document"); + + for (var i = 0; i < nodes.length; ++i) { + var id = nodes[i][0]; + var node = doc.getElementById(id); + ok(node === null, + "Check for " + id, id + " should be null"); + } + + $(frameid).onload = soon(function() { finishTest(frameid); }); + + // Do this off a timeout too. Why, I'm not sure. Something in session + // history creates another history state if we don't. :( + function goBack() { + $(frameid).contentWindow.history.back(); + } + setTimeout(goBack, 0); +} + +// XXXbz this is a nasty hack to work around the XML content sink not being +// incremental, so that the _first_ control we test is ok but others are not. +var testIs = is; +var once = false; +function flipper(a, b, c) { + if (once) { + todo(a == b, c); + } else { + once = true; + is(a, b, c); + } +} + +function finishTest(frameid) { + var doc = $(frameid).contentDocument; + ok(doc instanceof Document, "Check for doc", "doc should be a document"); + + for (var i = 0; i < nodes.length; ++i) { + var id = nodes[i][0]; + var node = doc.getElementById(id); + ok(node instanceof nodes[i][1], + "Check for " + id, id + " should be a " + nodes[i][1]); + //testIs(node.disabled, true, "check for " + id + " state restore"); + } + + if (frameid == "frame2") { + SimpleTest.finish(); + } else { + childUnloaded = false; + + // XXXbz this is a nasty hack to deal with the content sink. See above. + testIs = flipper; + + $("frame2").onload = soon(function() { startTest("frame2"); }); + $("frame2").src = "bug277724_iframe2.xhtml"; + } +} + +SimpleTest.waitForExplicitFinish(); +</script> +</pre> + +<!-- Don't use display:none, since we don't support framestate restoration + without a frame tree --> +<div id="content" style="visibility: hidden"> + <iframe src="bug277724_iframe1.html" id="frame1" + onload="setTimeout(function() { startTest('frame1') }, 0)"></iframe> + <iframe src="" id="frame2"></iframe> +</div> +</body> +</html> + |