Bug 1662410 - Part 3: Fix tests that use legacySHistory. r=peterv

Differential Revision: https://phabricator.services.mozilla.com/D89901
This commit is contained in:
Andreas Farre 2020-09-16 14:51:11 +00:00
Родитель d80d98ee5d
Коммит 2c546aa7d3
15 изменённых файлов: 459 добавлений и 176 удалений

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

@ -9,7 +9,28 @@ const gExpectedHistory = {
entries: [],
};
function get_remote_history(browser) {
async function get_remote_history(browser) {
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
let sessionHistory = browser.browsingContext?.sessionHistory;
if (!sessionHistory) {
return null;
}
let result = {
index: sessionHistory.index,
entries: [],
};
for (let i = 0; i < sessionHistory.count; i++) {
let entry = sessionHistory.getEntryAtIndex(i);
result.entries.push({
uri: entry.URI.spec,
title: entry.title,
});
}
return result;
}
return SpecialPowers.spawn(browser, [], () => {
let webNav = content.docShell.QueryInterface(Ci.nsIWebNavigation);
let sessionHistory = webNav.sessionHistory;

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

@ -14,21 +14,41 @@ add_task(async function test() {
await BrowserTestUtils.withNewTab(
{ gBrowser, url: "http://example.com" },
async function(browser) {
await SpecialPowers.spawn(browser, [], async function() {
let cw = content;
let oldTitle = cw.document.title;
ok(oldTitle, "Content window should initially have a title.");
cw.history.pushState("", "", "new_page");
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
await SpecialPowers.spawn(browser, [], async function() {
let cw = content;
let oldTitle = cw.document.title;
ok(oldTitle, "Content window should initially have a title.");
cw.history.pushState("", "", "new_page");
let shistory = cw.docShell.QueryInterface(Ci.nsIWebNavigation)
.sessionHistory;
let shistory = cw.docShell.QueryInterface(Ci.nsIWebNavigation)
.sessionHistory;
is(
shistory.legacySHistory.getEntryAtIndex(shistory.index).title,
oldTitle,
"SHEntry title after pushstate."
);
is(
shistory.legacySHistory.getEntryAtIndex(shistory.index).title,
oldTitle,
"SHEntry title after pushstate."
);
});
return;
}
let bc = browser.browsingContext;
let oldTitle = browser.browsingContext.currentWindowGlobal.documentTitle;
ok(oldTitle, "Content window should initially have a title.");
SpecialPowers.spawn(browser, [], async function() {
content.history.pushState("", "", "new_page");
});
let shistory = bc.sessionHistory;
await SHListener.waitForHistory(shistory, SHListener.NewEntry);
is(
shistory.getEntryAtIndex(shistory.index).title,
oldTitle,
"SHEntry title after pushstate."
);
}
);
});

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

@ -198,3 +198,56 @@ function assertBackForwardState(canGoBack, canGoForward) {
} disabled`
);
}
class SHListener {
static NewEntry = 0;
static Reload = 1;
static GotoIndex = 2;
static Purge = 3;
static ReplaceEntry = 4;
static async waitForHistory(history, event) {
return new Promise(resolve => {
let listener = {
OnHistoryNewEntry: () => {},
OnHistoryReload: () => {
return true;
},
OnHistoryGotoIndex: () => {},
OnHistoryPurge: () => {},
OnHistoryReplaceEntry: () => {},
QueryInterface: ChromeUtils.generateQI([
"nsISHistoryListener",
"nsISupportsWeakReference",
]),
};
function finish() {
history.removeSHistoryListener(listener);
resolve();
}
switch (event) {
case this.NewEntry:
listener.OnHistoryNewEntry = finish;
break;
case this.Reload:
listener.OnHistoryReload = () => {
finish();
return true;
};
break;
case this.GotoIndex:
listener.OnHistoryGotoIndex = finish;
break;
case this.Purge:
listener.OnHistoryPurge = finish;
break;
case this.ReplaceEntry:
listener.OnHistoryReplaceEntry = finish;
break;
}
history.addSHistoryListener(listener);
});
}
}

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

@ -35,8 +35,13 @@
}
// Work around bug 467960
var history = gBrowser.webNavigation.sessionHistory;
history.legacySHistory.purgeHistory(history.count);
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
let history = gBrowser.browsingContext.sessionHistory;
history.purgeHistory(history.count);
} else {
let history = gBrowser.webNavigation.sessionHistory;
history.legacySHistory.purgeHistory(history.count);
}
window.close();
window.arguments[0].SimpleTest.finish();

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

@ -37,8 +37,13 @@
function finish() {
gBrowser.removeEventListener("pageshow", eventListener, true);
// Work around bug 467960
var history = gBrowser.webNavigation.sessionHistory;
history.legacySHistory.purgeHistory(history.count);
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
var history = gBrowser.browsingContext.sessionHistory;
history.purgeHistory(history.count);
} else {
var history = gBrowser.webNavigation.sessionHistory;
history.legacySHistory.purgeHistory(history.count);
}
window.close();
window.arguments[0].SimpleTest.finish();

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

@ -34,7 +34,7 @@
for (let eventType of LISTEN_EVENTS) {
gBrowser.removeEventListener(eventType, eventListener, true);
}
window.close();
window.arguments[0].SimpleTest.finish();
}
@ -45,7 +45,7 @@
for (let eventType of LISTEN_EVENTS) {
gBrowser.addEventListener(eventType, eventListener, true);
}
gTestsIterator = testsIterator();
nextTest();
}
@ -58,10 +58,16 @@
}
function doTest() {
var history = gBrowser.webNavigation.sessionHistory;
let history;
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
history = gBrowser.browsingContext.sessionHistory;
} else {
history = gBrowser.webNavigation.sessionHistory.legacySHistory;
}
if (history.count == gExpected.length) {
for (var i=0; i<history.count; i++) {
var shEntry = history.legacySHistory.getEntryAtIndex(i).
var shEntry = history.getEntryAtIndex(i).
QueryInterface(Ci.nsISHEntry);
is(!!shEntry.contentViewer, gExpected[i], "content viewer "+i+", test "+gTestCount);
}
@ -73,9 +79,9 @@
if (j == i)
continue;
let shentry1 = history.legacySHistory.getEntryAtIndex(i)
let shentry1 = history.getEntryAtIndex(i)
.QueryInterface(Ci.nsISHEntry);
let shentry2 = history.legacySHistory.getEntryAtIndex(j)
let shentry2 = history.getEntryAtIndex(j)
.QueryInterface(Ci.nsISHEntry);
ok(!shentry1.sharesDocumentWith(shentry2),
'Test ' + gTestCount + ': shentry[' + i + "] shouldn't " +

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

@ -14,7 +14,7 @@
<script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
<script type="application/javascript"><![CDATA[
Services.prefs.setBoolPref("browser.navigation.requireUserInteraction", false);
// Define the generator-iterator for the tests.
var tests = testIterator();
@ -26,7 +26,7 @@
}
////
// Generator function for test steps for bug 662200:
// Generator function for test steps for bug 662200:
// Description goes here.
//
function* testIterator()
@ -40,13 +40,13 @@
};
doPageNavigation(navData);
yield undefined;
// Load the second test page.
navData = {
eventsToListenFor: ["pageshow", "pagehide"],
expectedEvents: [ {type: "pagehide",
expectedEvents: [ {type: "pagehide",
title: "A"},
{type: "pageshow",
{type: "pageshow",
title: "B"} ],
onNavComplete: nextTest
}
@ -61,9 +61,9 @@
// Load the third test page.
navData = {
eventsToListenFor: ["pageshow", "pagehide"],
expectedEvents: [ {type: "pagehide",
expectedEvents: [ {type: "pagehide",
title: "B"},
{type: "pageshow",
{type: "pageshow",
title: "C"} ],
onNavComplete: nextTest
};
@ -74,14 +74,14 @@
0, 0, 0, 0, 0, false, false, false, false, 0, null);
link.dispatchEvent(event);
yield undefined;
// Go back.
navData = {
back: true,
eventsToListenFor: ["pageshow", "pagehide"],
expectedEvents: [ {type: "pagehide",
expectedEvents: [ {type: "pagehide",
title: "C"},
{type: "pageshow",
{type: "pageshow",
title: "B"} ],
onNavComplete: nextTest
};
@ -89,14 +89,19 @@
yield undefined;
var docshell = TestWindow.getWindow().docShell;
var shistory = docshell.sessionHistory.legacySHistory;
let shistory;
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
shistory = docshell.browsingContext.sessionHistory;
} else {
shistory = docshell.sessionHistory.legacySHistory;
}
// Reload.
navData = {
eventsToListenFor: ["pageshow", "pagehide"],
expectedEvents: [ {type: "pagehide",
expectedEvents: [ {type: "pagehide",
title: "B"},
{type: "pageshow",
{type: "pageshow",
title: "B"} ],
onNavComplete: nextTest
};
@ -117,7 +122,7 @@
// Tell the framework the test is finished.
finish();
}
]]></script>
<browser type="content" primary="true" flex="1" id="content" src="about:blank"/>

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

@ -35,8 +35,13 @@
}
// Work around bug 467960
var history = gBrowser.webNavigation.sessionHistory;
history.legacySHistory.purgeHistory(history.count);
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
let history = gBrowser.browsingContext.sessionHistory;
history.purgeHistory(history.count);
} else {
let history = gBrowser.webNavigation.sessionHistory;
history.legacySHistory.purgeHistory(history.count);
}
window.close();
window.arguments[0].SimpleTest.finish();

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

@ -14,9 +14,8 @@ add_task(async function() {
browser
) {
// At this point, we haven't set gHistoryMaxSize to 0, and it is still 50 (default value).
await ContentTask.spawn(browser, null, () => {
var sh = content.window.docShell.QueryInterface(Ci.nsIWebNavigation)
.sessionHistory.legacySHistory;
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
let sh = browser.browsingContext.sessionHistory;
is(
sh.count,
1,
@ -27,7 +26,22 @@ add_task(async function() {
0,
"Shistory's current index should be 0 because we haven't purged history yet"
);
});
} else {
await ContentTask.spawn(browser, null, () => {
var sh = content.window.docShell.QueryInterface(Ci.nsIWebNavigation)
.sessionHistory.legacySHistory;
is(
sh.count,
1,
"We should have entry in session history because we haven't changed gHistoryMaxSize to be 0 yet"
);
is(
sh.index,
0,
"Shistory's current index should be 0 because we haven't purged history yet"
);
});
}
var loadPromise = BrowserTestUtils.browserLoaded(browser, false, URL2);
// If we set the pref at the beginning of this page, then when we launch a child process
@ -49,12 +63,19 @@ add_task(async function() {
browser.reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE);
await promise;
await ContentTask.spawn(browser, null, () => {
var sh = content.window.docShell.QueryInterface(Ci.nsIWebNavigation)
.sessionHistory.legacySHistory;
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
let sh = browser.browsingContext.sessionHistory;
is(sh.count, 0, "We should not save any entries in session history");
is(sh.index, -1);
is(sh.requestedIndex, -1);
});
} else {
await ContentTask.spawn(browser, null, () => {
var sh = content.window.docShell.QueryInterface(Ci.nsIWebNavigation)
.sessionHistory.legacySHistory;
is(sh.count, 0, "We should not save any entries in session history");
is(sh.index, -1);
is(sh.requestedIndex, -1);
});
}
});
});

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

@ -50,7 +50,7 @@ add_task(async function() {
testDone.promise = new Promise(resolve => {
testDone.resolve = resolve;
});
let legacySHistory = browser.browsingContext.sessionHistory;
let shistory = browser.browsingContext.sessionHistory;
// 3. Register a session history listener to listen for a 'content viewer evicted' event.
let historyListener = {
OnContentViewerEvicted() {
@ -58,7 +58,7 @@ add_task(async function() {
true,
"History listener got called after a content viewer was evicted"
);
legacySHistory.removeSHistoryListener(historyListener);
shistory.removeSHistoryListener(historyListener);
delete window._testListener;
// 6. Resolve the promise when we got our 'content viewer evicted' event
testDone.resolve();
@ -68,7 +68,7 @@ add_task(async function() {
"nsISupportsWeakReference",
]),
};
legacySHistory.addSHistoryListener(historyListener);
shistory.addSHistoryListener(historyListener);
// Keep the weak shistory listener alive
window._testListener = historyListener;
}

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

@ -9,15 +9,21 @@
<script>
let Ci = SpecialPowers.Ci;
let webNav = SpecialPowers.wrap(window)
.docShell
.QueryInterface(Ci.nsIWebNavigation);
.docShell
.QueryInterface(Ci.nsIWebNavigation);
let shistory = webNav.sessionHistory;
function test() {
async function test() {
if (opener) {
opener.info("file_bug1300461_back.html");
opener.is(shistory.count, 2, "check history length");
opener.is(shistory.index, 1, "check history index");
opener.is(shistory.legacySHistory.requestedIndex, -1, "check requestedIndex");
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
opener.is(shistory.legacySHistory.requestedIndex, -1, "check requestedIndex");
} else {
let index = await opener.getSHRequestedIndex();
opener.is(index, -1, "check requestedIndex");
}
opener.ok(webNav.canGoBack, "check canGoBack");
if (opener.testCount == 1) {
opener.info("replaceState to redirect.html");

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

@ -4,17 +4,22 @@
<meta charset="utf-8">
<title>Bug 1326251</title>
<script>
SpecialPowers.Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
SpecialPowers.Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
// Evict bfcache and then go back.
async function evictCache() {
let shistory = SpecialPowers.wrap(window)
.docShell
.QueryInterface(SpecialPowers.Ci.nsIWebNavigation)
.sessionHistory;
shistory.legacySHistory.evictAllContentViewers();
history.back();
}
// Evict bfcache and then go back.
async function evictCache() {
let shistory = SpecialPowers.wrap(window)
.docShell
.QueryInterface(SpecialPowers.Ci.nsIWebNavigation)
.sessionHistory;
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
shistory.legacySHistory.evictAllContentViewers();
} else {
opener.evictAllContentViewers();
}
history.back();
}
</script>
</head>
<body onload="setTimeout(evictCache, 0);">

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

@ -10,78 +10,117 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1375833
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForExplicitFinish();
/**
* Test for Bug 1375833. It tests for 2 things in a normal reload -
* 1. Static frame history should not be dropped.
* 2. In a reload, docshell would parse the reloaded root document and
* genearate new child docshells, and then use the child offset
*/
/**
* Test for Bug 1375833. It tests for 2 things in a normal reload -
* 1. Static frame history should not be dropped.
* 2. In a reload, docshell would parse the reloaded root document and
* genearate new child docshells, and then use the child offset
*/
let testWin = window.open("file_bug1375833.html");
let count = 0;
let webNav, shistory;
let frameDocShellId;
window.addEventListener("message", e => {
switch (count++) {
case 0:
ok(e.data.endsWith("file_bug1375833-frame2.html"), "check location");
let testWin = window.open("file_bug1375833.html");
let count = 0;
let webNav, shistory;
let frameDocShellId;
let chromeScript = null;
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
chromeScript = SpecialPowers.loadChromeScript(() => {
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
webNav = SpecialPowers.wrap(testWin)
.docShell
.QueryInterface(SpecialPowers.Ci.nsIWebNavigation);
shistory = webNav.sessionHistory;
is(shistory.count, 2, "check history length");
is(shistory.index, 1, "check history index");
function doSend(message, fn) {
try {
// eslint-disable-next-line no-undef
sendAsyncMessage(message, {success: true, value: fn()});
} catch(_) {
// eslint-disable-next-line no-undef
sendAsyncMessage(message, {success: false});
}
}
frameDocShellId = String(getFrameDocShell().historyID);
ok(frameDocShellId, "sanity check for docshell ID");
testWin.location.reload();
break;
case 1:
ok(e.data.endsWith("file_bug1375833-frame2.html"), "check location");
is(shistory.count, 4, "check history length");
is(shistory.index, 3, "check history index");
let newFrameDocShellId = String(getFrameDocShell().historyID);
ok(newFrameDocShellId, "sanity check for docshell ID");
is(newFrameDocShellId, frameDocShellId, "check docshell ID remains after reload");
let entry = shistory.legacySHistory.getEntryAtIndex(shistory.index);
let frameEntry = entry.GetChildAt(0);
is(String(frameEntry.docshellID), frameDocShellId, "check newly added shentry uses the same docshell ID");
webNav.goBack();
break;
case 2:
ok(e.data.endsWith("file_bug1375833-frame1.html"), "check location");
is(shistory.count, 4, "check history length");
is(shistory.index, 2, "check history index");
webNav.goBack();
break;
case 3:
ok(e.data.endsWith("file_bug1375833-frame2.html"), "check location");
is(shistory.count, 4, "check history length");
is(shistory.index, 1, "check history index");
webNav.goBack();
break;
case 4:
ok(e.data.endsWith("file_bug1375833-frame1.html"), "check location");
is(shistory.count, 4, "check history length");
is(shistory.index, 0, "check history index");
testWin.close();
SimpleTest.finish();
// eslint-disable-next-line no-undef
addMessageListener("test1", index => {
doSend("test1", () => {
let win = Services.wm.getMostRecentWindow("navigator:browser");
let sessionHistory = win.gBrowser.selectedBrowser.browsingContext.sessionHistory;
let entry = shistory.getEntryAtIndex(sessionHistory.index);
let frameEntry = entry.GetChildAt(0);
return String(frameEntry.docshellID);
})
});
});
}
});
function getFrameDocShell() {
return SpecialPowers.wrap(testWin.window[0]).docShell;
}
window.addEventListener("message", async e => {
switch (count++) {
case 0:
ok(e.data.endsWith("file_bug1375833-frame2.html"), "check location");
webNav = SpecialPowers.wrap(testWin)
.docShell
.QueryInterface(SpecialPowers.Ci.nsIWebNavigation);
shistory = webNav.sessionHistory;
is(shistory.count, 2, "check history length");
is(shistory.index, 1, "check history index");
frameDocShellId = String(getFrameDocShell().historyID);
ok(frameDocShellId, "sanity check for docshell ID");
testWin.location.reload();
break;
case 1:
ok(e.data.endsWith("file_bug1375833-frame2.html"), "check location");
is(shistory.count, 4, "check history length");
is(shistory.index, 3, "check history index");
let newFrameDocShellId = String(getFrameDocShell().historyID);
ok(newFrameDocShellId, "sanity check for docshell ID");
is(newFrameDocShellId, frameDocShellId, "check docshell ID remains after reload");
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
let entry = shistory.legacySHistory.getEntryAtIndex(shistory.index);
let frameEntry = entry.GetChildAt(0);
is(String(frameEntry.docshellID), frameDocShellId, "check newly added shentry uses the same docshell ID");
} else {
let p = chromeScript.promiseOneMessage("test1");
chromeScript.sendAsyncMessage("test1", shistory.index);
let result = await p;
ok(result.success, "legacySHistory worked around ok");
is(result.value, frameDocShellId, "check newly added shentry uses the same docshell ID");
}
webNav.goBack();
break;
case 2:
ok(e.data.endsWith("file_bug1375833-frame1.html"), "check location");
is(shistory.count, 4, "check history length");
is(shistory.index, 2, "check history index");
webNav.goBack();
break;
case 3:
ok(e.data.endsWith("file_bug1375833-frame2.html"), "check location");
is(shistory.count, 4, "check history length");
is(shistory.index, 1, "check history index");
webNav.goBack();
break;
case 4:
ok(e.data.endsWith("file_bug1375833-frame1.html"), "check location");
is(shistory.count, 4, "check history length");
is(shistory.index, 0, "check history index");
if (chromeScript) {
chromeScript.destroy();
}
testWin.close();
SimpleTest.finish();
}
});
function getFrameDocShell() {
return SpecialPowers.wrap(testWin.window[0]).docShell;
}
</script>
</head>

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

@ -12,61 +12,114 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
<script type="application/javascript">
/** Test for Bug **/
let chromeScript = null;
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
chromeScript = SpecialPowers.loadChromeScript(() => {
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
var testFiles =
[ "file_bug462076_1.html", // Dynamic frames before onload
"file_bug462076_2.html", // Dynamic frames when handling onload
"file_bug462076_3.html", // Dynamic frames after onload
"file_bug508537_1.html", // Dynamic frames and forward-back
"file_document_write_1.html", // Session history + document.write
// "file_static_and_dynamic_1.html",// Static and dynamic frames and forward-back
"file_bug534178.html", // Session history entry clean-up.
"file_fragment_handling_during_load.html",
"file_nested_frames.html",
"file_shiftReload_and_pushState.html",
"file_scrollRestoration.html",
"file_bug1300461.html",
"file_bug1326251.html",
"file_bug1379762-1.html",
"file_bug1609475.html",
];
var testCount = 0; // Used by the test files.
function doSend(message, fn) {
try {
// eslint-disable-next-line no-undef
sendAsyncMessage(message, {success: true, value: fn()});
} catch(_) {
// eslint-disable-next-line no-undef
sendAsyncMessage(message, {success: false});
}
}
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
// eslint-disable-next-line no-undef
addMessageListener("requestedIndex", () => {
doSend("requestedIndex", () => {
let win = Services.wm.getMostRecentWindow("navigator:browser");
let shistory = win.gBrowser.selectedBrowser.browsingContext.sessionHistory;
return shistory.requestedIndex;
})
});
var testWindow;
function nextTest_() {
if (testFiles.length) {
testCount = 0;
let nextFile = testFiles.shift();
info("Running " + nextFile);
testWindow = window.open(nextFile, "", "width=360,height=480");
testWindow.onunload = function() { }; // to prevent bfcache
} else {
SimpleTest.finish();
}
}
// eslint-disable-next-line no-undef
addMessageListener("evictAllContentViewers", _ => {
doSend("evictAllContentViewers", () => {
let win = Services.wm.getMostRecentWindow("navigator:browser");
let shistory = win.gBrowser.selectedBrowser.browsingContext.sessionHistory;
return shistory.evictAllContentViewers();
})
});
});
}
async function case3WaitForBlank() {
let loaded = SimpleTest.promiseWaitForCondition(() => {
return testWindow.location.href == "about:blank";
});
await loaded;
SpecialPowers.wrap(testWindow).history.back();
}
async function getSHRequestedIndex() {
let p = chromeScript.promiseOneMessage("requestedIndex");
chromeScript.sendAsyncMessage("requestedIndex");
let result = await p;
ok(result.success, "Got requested index from parent");
return result.value;
}
function nextTest() {
setTimeout(nextTest_, 0);
}
async function evictAllContentViewers() {
let p = chromeScript.promiseOneMessage("evictAllContentViewers");
chromeScript.sendAsyncMessage("evictAllContentViewers");
let result = await p;
ok(result.success, "Called evictAllContentViewers from parent");
}
</script>
/** Test for Bug **/
var testFiles =
[ "file_bug462076_1.html", // Dynamic frames before onload
"file_bug462076_2.html", // Dynamic frames when handling onload
"file_bug462076_3.html", // Dynamic frames after onload
"file_bug508537_1.html", // Dynamic frames and forward-back
"file_document_write_1.html", // Session history + document.write
// "file_static_and_dynamic_1.html",// Static and dynamic frames and forward-back
"file_bug534178.html", // Session history entry clean-up.
"file_fragment_handling_during_load.html",
"file_nested_frames.html",
"file_shiftReload_and_pushState.html",
"file_scrollRestoration.html",
"file_bug1300461.html",
"file_bug1326251.html",
"file_bug1379762-1.html",
"file_bug1609475.html",
];
var testCount = 0; // Used by the test files.
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
var testWindow;
function nextTest_() {
if (testFiles.length) {
testCount = 0;
let nextFile = testFiles.shift();
info("Running " + nextFile);
testWindow = window.open(nextFile, "", "width=360,height=480");
testWindow.onunload = function() { }; // to prevent bfcache
} else {
if (chromeScript) {
chromeScript.destroy();
}
SimpleTest.finish();
}
}
async function case3WaitForBlank() {
let loaded = SimpleTest.promiseWaitForCondition(() => {
return testWindow.location.href == "about:blank";
});
await loaded;
SpecialPowers.wrap(testWindow).history.back();
}
function nextTest() {
setTimeout(nextTest_, 0);
}
</script>
</pre>
</body>
</html>

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

@ -28,6 +28,45 @@ var checkResult = async function(isRemote, browserKey, uri) {
"browser.permanentKey should be correct"
);
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
let sessionHistory =
gBrowser.selectedBrowser.browsingContext.sessionHistory;
let entry = sessionHistory.getEntryAtIndex(sessionHistory.count - 1);
let args = { uri, referrerInfo: deReferrerInfo, isRemote };
Assert.equal(entry.URI.spec, args.uri, "Uri should be correct");
// Main process like about:mozilla does not trigger the real network request.
// So we don't store referrerInfo in sessionHistory in that case.
// Besides, the referrerInfo stored in sessionHistory was computed, we only
// check pre-computed things.
if (args.isRemote) {
let resultReferrerInfo = entry.referrerInfo;
let expectedReferrerInfo = E10SUtils.deserializeReferrerInfo(
args.referrerInfo
);
Assert.equal(
resultReferrerInfo.originalReferrer.spec,
expectedReferrerInfo.originalReferrer.spec,
"originalReferrer should be correct"
);
Assert.equal(
resultReferrerInfo.sendReferrer,
expectedReferrerInfo.sendReferrer,
"sendReferrer should be correct"
);
Assert.equal(
resultReferrerInfo.referrerPolicy,
expectedReferrerInfo.referrerPolicy,
"referrerPolicy should be correct"
);
} else {
Assert.equal(entry.referrerInfo, null, "ReferrerInfo should be correct");
}
return;
}
await SpecialPowers.spawn(
gBrowser.selectedBrowser,
[{ uri, referrerInfo: deReferrerInfo, isRemote }],