function assertCheck(data) {
if (data.assertIs) {
for (const args of data.assertIs) {
is(args[0], args[1], args[2]);
}
}
if (data.assertOk) {
for (const args of data.assertOk) {
ok(args[0], args[1]);
}
}
if (data.assertIsNot) {
for (const args of data.assertIsNot) {
isnot(args[0], args[1], args[2]);
}
}
}
var bc1, currentCase = 0;
function test1() {
bc1 = new BroadcastChannel("bug1155730_part1");
bc1.onmessage = (msgEvent) => { var msg = msgEvent.data; varcommand = msg.command;
if (command == "pageshow") {
currentCase++; var persisted = msg.persisted;
is(persisted, false, "Shouldn't have persisted session history entry.");
bc1.postMessage({command: "test", currentCase});
} else if (command == "asserts") {
is(msg.currentCase, currentCase, "correct case");
info(`Checking asserts for case ${msg.currentCase}`);
assertCheck(msg);
if (currentCase == 3) {
// move on to the next test
bc1.close();
test2();
}
}
}
window.open("file_scrollRestoration_part1_nobfcache.html", "", "width=360,height=480,noopener");
}
var bc2, bc2navigate;
function test2() {
currentCase = 0;
bc2 = new BroadcastChannel("bug1155730_part2");
bc2.onmessage = (msgEvent) => { var msg = msgEvent.data; varcommand = msg.command;
if (command == "pageshow") {
currentCase++; var persisted = msg.persisted;
switch (currentCase) {
case 1:
is(persisted, false, "Shouldn't have persisted session history entry.");
break;
case 2:
is(persisted, true, "Should have persisted session history entry.");
}
bc2.postMessage({command: "test", currentCase});
} else if (command == "asserts") {
is(msg.currentCase, currentCase, "correct case");
info(`Checking asserts for case ${msg.currentCase}`);
assertCheck(msg);
if (currentCase == 3) {
// move on to the next test
bc2.close();
test3();
}
} else if (command == "nextCase") {
currentCase++;
}
}
// test4 opens a new page which can enter bfcache. That page then loads
// another page which can't enter bfcache. That second page then scrolls
// down. History API is then used to navigate back and forward. When the
// second page loads again, it should scroll down automatically. var bc4a, bc4b; var scrollYCounter = 0;
function test4() {
currentCase = 0;
bc4a = new BroadcastChannel("bfcached");
bc4a.onmessage = (msgEvent) => { var msg = msgEvent.data; varcommand = msg.command;
if (command == "pageshow") {
++currentCase;
if (currentCase == 1) {
ok(!msg.persisted, "The first page should not be persisted initially.");
bc4a.postMessage("loadNext");
} else if (currentCase == 3) {
ok(msg.persisted, "The first page should be persisted.");
bc4a.postMessage("forward");
bc4a.close();
}
}
}
bc4b = new BroadcastChannel("notbfcached");
bc4b.onmessage = (event) => { var msg = event.data; varcommand = msg.command;
if (command == "pageshow") {
++currentCase;
if (currentCase == 2) {
ok(!msg.persisted, "The second page should not be persisted.");
bc4b.postMessage("getScrollY");
bc4b.postMessage("scroll");
bc4b.postMessage("getScrollY");
bc4b.postMessage("back");
} else if (currentCase == 4) {
ok(!msg.persisted, "The second page should not be persisted.");
bc4b.postMessage("getScrollY");
}
} else if (msg == "closed") {
bc4b.close();
SimpleTest.finish();
} else if ("scrollY" in msg) {
++scrollYCounter;
if (scrollYCounter == 1) {
is(msg.scrollY, 0, "The page should be initially scrolled to top.");
} else if (scrollYCounter == 2) {
isnot(msg.scrollY, 0, "The page should be then scrolled down.");
} else if (scrollYCounter == 3) {
isnot(msg.scrollY, 0, "The page should be scrolled down after being restored from the session history.");
bc4b.postMessage("close");
}
}
}
window.open("file_scrollRestoration_bfcache_and_nobfcache.html", "", "width=360,height=480,noopener");
}
SimpleTest.enableLegacyUnpartitionedStorage().then(() => {
// If Fission is disabled, the pref is no-op.
SpecialPowers.pushPrefEnv({set: [["fission.bfcacheInParent", true]]}, () => {
test1();
});
});
</script>
</pre>
</body>
</html>
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.