fune/dom/tests/mochitest/dom-level0/test_background_loading_iframes.html
Kris Maglione b459f53a11 Bug 1561061: Move SpecialPowers pref env code to parent and make sane-ish. r=aswan
Differential Revision: https://phabricator.services.mozilla.com/D35706

--HG--
extra : rebase_source : ec33af8c17048c3828d4ca4643e2e17bd2a854c0
extra : source : c2d0956f41d82e76c682f829807e818863cd802a
2019-06-24 13:47:53 -07:00

67 lines
2 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test for background loading iframes</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
var myLoadTime;
var receivedPostMessage = [];
window.addEventListener('message', function(event) {
receivedPostMessage.push(parseInt(event.data));
if (receivedPostMessage.length == 3) {
if (!myLoadTime){
ok(false, "Child iframes are loaded earlier than the parent document");
} else {
receivedPostMessage.forEach(function(iframeLoadTime, index) {
ok(iframeLoadTime, "Iframe load time should not be null");
ok(iframeLoadTime >= myLoadTime, "Parent document should be loaded earlier than child iframes");
})
}
SimpleTest.finish();
}
})
window.onload = function() {
myLoadTime = performance.now();
}
SpecialPowers.pushPrefEnv({"set":[["dom.background_loading_iframe", true]]}).then(function () {
var iframe1 = document.createElement("iframe");
var iframe2 = document.createElement("iframe");
var iframe3 = document.createElement("iframe");
iframe1.src = "http://example.org:80/tests/dom/tests/mochitest/dom-level0/file_test_background_loading_iframes.html";
iframe2.src = "http://example.org:80/tests/dom/tests/mochitest/dom-level0/file_test_background_loading_iframes.html";
iframe3.src = "http://example.org:80/tests/dom/tests/mochitest/dom-level0/file_test_background_loading_iframes.html";
iframe1.onload = function() {
iframe1.contentWindow.postMessage("test", "*");
}
iframe2.onload = function() {
iframe2.contentWindow.postMessage("test", "*");
}
iframe3.onload = function() {
iframe3.contentWindow.postMessage("test", "*");
}
document.body.append(iframe1);
document.body.append(iframe2);
document.body.append(iframe3);
});
</script>
</pre>
</body>
</html>