mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
104 lines
3.3 KiB
Plaintext
104 lines
3.3 KiB
Plaintext
|
<?xml version="1.0"?>
|
||
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||
|
<window title="Mozilla Bug 113934" onload="doTheTest()"
|
||
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||
|
|
||
|
<hbox>
|
||
|
<vbox>
|
||
|
<browser type="content" id="f1" width="300" height="200"/>
|
||
|
<browser type="content" id="f2" width="300" height="200"/>
|
||
|
</vbox>
|
||
|
<vbox>
|
||
|
<browser type="content" id="f3" width="30" height="200"/>
|
||
|
</vbox>
|
||
|
<spacer flex="1"/>
|
||
|
</hbox>
|
||
|
|
||
|
<!-- test code goes here -->
|
||
|
<script type="application/javascript"><![CDATA[
|
||
|
var imports = [ "SimpleTest", "is", "isnot", "ok", "snapshotWindow",
|
||
|
"compareSnapshots" ];
|
||
|
for each (var import in imports) {
|
||
|
window[import] = window.opener.wrappedJSObject[import];
|
||
|
}
|
||
|
|
||
|
function $(id) {
|
||
|
return document.getElementById(id);
|
||
|
}
|
||
|
|
||
|
/** Test for Bug 113934 **/
|
||
|
var doc1 =
|
||
|
"data:text/html,<html><body onbeforeunload='document.documentElement.textContent = \"\"' onunload='document.documentElement.textContent = \"\"' onpagehide='document.documentElement.textContent = \"\"'>This is a test</body></html>";
|
||
|
var doc2 = "data:text/html,<html><body>This is a second test</body></html>";
|
||
|
|
||
|
|
||
|
$("f1").setAttribute("src", doc1);
|
||
|
$("f2").setAttribute("src", doc2);
|
||
|
$("f3").setAttribute("src", doc2);
|
||
|
|
||
|
function doTheTest() {
|
||
|
var s1 = snapshotWindow($("f1").contentWindow);
|
||
|
var s2 = snapshotWindow($("f2").contentWindow);
|
||
|
var s3 = snapshotWindow($("f3").contentWindow);
|
||
|
|
||
|
ok(!compareSnapshots(s2, s3)[0],
|
||
|
"Should look different due to different sizing");
|
||
|
|
||
|
function getDOM(id) {
|
||
|
return $(id).contentDocument.documentElement.innerHTML;
|
||
|
}
|
||
|
|
||
|
var dom1 = getDOM("f1");
|
||
|
|
||
|
var dom2 = getDOM("f2");
|
||
|
$("f2").contentDocument.body.textContent = "Modified the text";
|
||
|
var dom2star = getDOM("f2");
|
||
|
isnot(dom2, dom2star, "We changed the DOM!");
|
||
|
|
||
|
$("f1").swapDocShells($("f2"));
|
||
|
// now we have doms 2*, 1, 2 in the frames
|
||
|
|
||
|
is(getDOM("f1"), dom2star, "Shouldn't have changed the DOM on swap");
|
||
|
is(getDOM("f2"), dom1, "Shouldn't have fired event handlers");
|
||
|
|
||
|
var strs = { "f1": "", "f3" : "" };
|
||
|
function attachListener(node, type) {
|
||
|
var listener = function(e) {
|
||
|
if (strs[node.id]) strs[node.id] += " ";
|
||
|
strs[node.id] += node.id + ".page" + type;
|
||
|
}
|
||
|
node.addEventListener("page" + type, listener, false);
|
||
|
|
||
|
listener.detach = function() {
|
||
|
node.removeEventListener("page" + type, listener, false);
|
||
|
}
|
||
|
return listener;
|
||
|
}
|
||
|
|
||
|
var l1 = attachListener($("f1"), "show");
|
||
|
var l2 = attachListener($("f1"), "hide");
|
||
|
var l3 = attachListener($("f3"), "show");
|
||
|
var l4 = attachListener($("f3"), "hide");
|
||
|
|
||
|
$("f1").swapDocShells($("f3"));
|
||
|
// now we have DOMs 2, 1, 2* in the frames
|
||
|
|
||
|
l1.detach();
|
||
|
l2.detach();
|
||
|
l3.detach();
|
||
|
l4.detach();
|
||
|
|
||
|
var s1_new = snapshotWindow($("f1").contentWindow);
|
||
|
var [same, first, second] = compareSnapshots(s1_new, s2);
|
||
|
ok(same, "Should reflow on swap", "Expected " + second + " but got " + first);
|
||
|
|
||
|
is(strs["f1"], "f1.pagehide f1.pageshow");
|
||
|
is(strs["f3"], "f3.pagehide f3.pageshow");
|
||
|
|
||
|
window.close();
|
||
|
SimpleTest.finish();
|
||
|
}
|
||
|
|
||
|
]]></script>
|
||
|
</window>
|