Bug 1686812 - Change test_performance_navigation.html to use BroadcastChannel, r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D101833
This commit is contained in:
Anny Gakhokidze 2021-01-14 23:56:34 +00:00
Родитель 6f86ea40b9
Коммит 6686db8685
2 изменённых файлов: 18 добавлений и 23 удалений

Просмотреть файл

@ -3,6 +3,7 @@
<script>
let pass = false;
let initialLoad = false;
var bc = new BroadcastChannel("bug145971");
function checkNavigationTypeEquals2() {
if (performance.navigation.type == 2) {
pass = true;
@ -11,8 +12,8 @@
}
function testDone() {
opener.ok(pass, "Bug 145971: Navigation type does not equal 2 when restoring document from session history.");
opener.nextTest();
bc.postMessage({result: pass});
bc.close();
window.close();
}

Просмотреть файл

@ -1,41 +1,35 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=
https://bugzilla.mozilla.org/show_bug.cgi?id=145971
-->
<head>
<title>Test for Bug </title>
<title>Test for Bug 145971</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body onload="nextTest()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<body onload="runTest()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=145971">Mozilla Bug 145971</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug **/
var testFiles =
[ "test_bug145971.html"
];
var testWindow;
function nextTest_() {
if (testFiles.length) {
let nextFile = testFiles.shift();
info("Running " + nextFile);
testWindow = window.open(nextFile, "", "width=360,height=480");
} else {
SimpleTest.finish();
var bc = new BroadcastChannel("bug145971");
bc.onmessage = function(msgEvent) {
var result = msgEvent.data.result;
if (result == undefined) {
info("Got unexpected message from BroadcastChannel");
return;
}
}
ok(result, "Bug 145971: Navigation type does not equal 2 when restoring document from session history.");
SimpleTest.finish();
};
function nextTest() {
setTimeout(nextTest_, 0);
function runTest() {
window.open("test_bug145971.html", "", "width=360,height=480,noopener");
}
</script>