Bug 1593797 - Unskip browser_bug422543 in Fission mode. r=mccr8

This is a partial fix, which prevents the test from simply timing out. It
still fails, because this is a test of content session history listeners,
which don't currently work as expected for cross-process navigations.

Differential Revision: https://phabricator.services.mozilla.com/D51696

--HG--
rename : docshell/test/browser/file_bug422543_script.js => docshell/test/browser/Bug422543Child.jsm
extra : moz-landing-system : lando
This commit is contained in:
Kris Maglione 2019-11-08 20:05:02 +00:00
Родитель fe1657a564
Коммит c573d8fa3c
5 изменённых файлов: 178 добавлений и 169 удалений

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

@ -0,0 +1,99 @@
var EXPORTED_SYMBOLS = ["Bug422543Child"];
class SHistoryListener {
constructor() {
this.retval = true;
this.last = "initial";
}
OnHistoryNewEntry(aNewURI) {
this.last = "newentry";
}
OnHistoryGotoIndex() {
this.last = "gotoindex";
}
OnHistoryPurge() {
this.last = "purge";
}
OnHistoryReload() {
this.last = "reload";
return this.retval;
}
OnHistoryReplaceEntry() {}
}
SHistoryListener.prototype.QueryInterface = ChromeUtils.generateQI([
Ci.nsISHistoryListener,
Ci.nsISupportsWeakReference,
]);
let listeners;
class Bug422543Child extends JSWindowActorChild {
constructor() {
super();
}
actorCreated() {
if (listeners) {
return;
}
this.shistory = this.docShell.nsIWebNavigation.sessionHistory;
listeners = [new SHistoryListener(), new SHistoryListener()];
for (let listener of listeners) {
this.shistory.legacySHistory.addSHistoryListener(listener);
}
}
cleanup() {
for (let listener of listeners) {
this.shistory.legacySHistory.removeSHistoryListener(listener);
}
this.shistory = null;
return {};
}
getListenerStatus() {
return listeners.map(l => l.last);
}
resetListeners() {
for (let listener of listeners) {
listener.last = "initial";
}
return {};
}
notifyReload() {
let history = this.shistory.legacySHistory;
let rval = history.notifyOnHistoryReload();
return { rval };
}
setRetval({ num, val }) {
listeners[num].retval = val;
return {};
}
receiveMessage(msg) {
switch (msg.name) {
case "cleanup":
return this.cleanup();
case "getListenerStatus":
return this.getListenerStatus();
case "notifyReload":
return this.notifyReload();
case "resetListeners":
return this.resetListeners();
case "setRetval":
return this.setRetval(msg.data);
}
return null;
}
}

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

@ -0,0 +1,3 @@
var EXPORTED_SYMBOLS = ["Bug422543Parent"];
class Bug422543Parent extends JSWindowActorParent {}

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

@ -1,5 +1,7 @@
[DEFAULT]
support-files =
Bug422543Child.jsm
Bug422543Parent.jsm
dummy_page.html
favicon_bug655270.ico
file_bug234628-1-child.html
@ -28,7 +30,6 @@ support-files =
file_bug234628-9-child.html
file_bug234628-9.html
file_bug420605.html
file_bug422543_script.js
file_bug503832.html
file_bug655270.html
file_bug670318.html
@ -97,7 +98,7 @@ support-files =
[browser_bug420605.js]
skip-if = fission || verify
[browser_bug422543.js]
skip-if = fission # Crashes: @ libc-2.23.so + 0xfb74d
fail-if = fission
[browser_bug441169.js]
[browser_bug503832.js]
skip-if = verify

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

@ -1,8 +1,14 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
const ACTOR = "Bug422543";
let getActor = browser => {
return browser.browsingContext.currentWindowGlobal.getActor(ACTOR);
};
add_task(async function runTests() {
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (!Services.prefs.getBoolPref("fission.sessionHistoryInParent")) {
await setupAsync();
let browser = gBrowser.selectedBrowser;
// Now that we're set up, initialize our frame script.
@ -55,57 +61,55 @@ add_task(async function runTests() {
ok(!(await notifyReloadAsync()), "reloading has been canceled");
await checkListenersAsync("reload", "saw the reload notification");
function listenOnce(message, arg = {}) {
return new Promise(resolve => {
let mm = gBrowser.selectedBrowser.messageManager;
mm.addMessageListener(message + ":return", function listener(msg) {
mm.removeMessageListener(message + ":return", listener);
resolve(msg.data);
});
mm.sendAsyncMessage(message, arg);
});
function sendQuery(message, arg = {}) {
return getActor(gBrowser.selectedBrowser).sendQuery(message, arg);
}
function checkListenersAsync(aLast, aMessage) {
return listenOnce("bug422543:getListenerStatus").then(
listenerStatuses => {
is(listenerStatuses[0], aLast, aMessage);
is(listenerStatuses[1], aLast, aMessage);
}
);
return sendQuery("getListenerStatus").then(listenerStatuses => {
is(listenerStatuses[0], aLast, aMessage);
is(listenerStatuses[1], aLast, aMessage);
});
}
function resetListenersAsync() {
return listenOnce("bug422543:resetListeners");
return sendQuery("resetListeners");
}
function notifyReloadAsync() {
return listenOnce("bug422543:notifyReload").then(({ rval }) => {
return sendQuery("notifyReload").then(({ rval }) => {
return rval;
});
}
function setListenerRetvalAsync(num, val) {
return listenOnce("bug422543:setRetval", { num, val });
return sendQuery("setRetval", { num, val });
}
function setupAsync() {
return BrowserTestUtils.openNewForegroundTab(
async function setupAsync() {
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"http://mochi.test:8888"
).then(function(tab) {
let browser = tab.linkedBrowser;
registerCleanupFunction(async function() {
await listenOnce("bug422543:cleanup");
gBrowser.removeTab(tab);
});
);
browser.messageManager.loadFrameScript(
getRootDirectory(gTestPath) + "file_bug422543_script.js",
false
);
let base = getRootDirectory(gTestPath).slice(0, -1);
ChromeUtils.registerWindowActor(ACTOR, {
parent: {
moduleURI: `${base}/Bug422543Parent.jsm`,
},
child: {
moduleURI: `${base}/Bug422543Child.jsm`,
},
});
registerCleanupFunction(async () => {
await sendQuery("cleanup");
gBrowser.removeTab(tab);
ChromeUtils.unregisterWindowActor(ACTOR);
});
await sendQuery("init");
}
return;
}
@ -163,36 +167,35 @@ add_task(async function runTests() {
checkListeners("reload", "saw the reload notification");
});
function SHistoryListener() {}
SHistoryListener.prototype = {
retval: true,
last: "initial",
class SHistoryListener {
constructor() {
this.retval = true;
this.last = "initial";
}
OnHistoryNewEntry(aNewURI) {
this.last = "newentry";
},
}
OnHistoryGotoIndex() {
this.last = "gotoindex";
},
}
OnHistoryPurge() {
this.last = "purge";
},
}
OnHistoryReload() {
this.last = "reload";
return this.retval;
},
}
OnHistoryReplaceEntry() {},
QueryInterface: ChromeUtils.generateQI([
Ci.nsISHistoryListener,
Ci.nsISupportsWeakReference,
]),
};
OnHistoryReplaceEntry() {}
}
SHistoryListener.prototype.QueryInterface = ChromeUtils.generateQI([
Ci.nsISHistoryListener,
Ci.nsISupportsWeakReference,
]);
let listeners = [new SHistoryListener(), new SHistoryListener()];
@ -215,38 +218,37 @@ function setListenerRetval(num, val) {
listeners[num].retval = val;
}
function setup() {
return BrowserTestUtils.openNewForegroundTab(
async function setup() {
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"http://mochi.test:8888"
).then(function(tab) {
let browser = tab.linkedBrowser;
registerCleanupFunction(async function() {
for (let listener of listeners) {
browser.browsingContext.sessionHistory.removeSHistoryListener(listener);
}
gBrowser.removeTab(tab);
});
);
let browser = tab.linkedBrowser;
registerCleanupFunction(async function() {
for (let listener of listeners) {
browser.browsingContext.sessionHistory.addSHistoryListener(listener);
browser.browsingContext.sessionHistory.removeSHistoryListener(listener);
}
gBrowser.removeTab(tab);
});
for (let listener of listeners) {
browser.browsingContext.sessionHistory.addSHistoryListener(listener);
}
}
function whenPageShown(aBrowser, aNavigation) {
let listener = ContentTask.spawn(aBrowser, null, function() {
return new Promise(resolve => {
addEventListener(
"pageshow",
function onLoad() {
removeEventListener("pageshow", onLoad, true);
resolve();
},
true
);
});
let promise = new Promise(resolve => {
let unregister = BrowserTestUtils.addContentEventListener(
aBrowser,
"pageshow",
() => {
unregister();
resolve();
},
{ capture: true }
);
});
aNavigation();
return listener;
return promise;
}

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

@ -1,96 +0,0 @@
/* eslint-env mozilla/frame-script */
function SHistoryListener() {}
SHistoryListener.prototype = {
retval: true,
last: "initial",
OnHistoryNewEntry(aNewURI) {
this.last = "newentry";
},
OnHistoryGotoIndex() {
this.last = "gotoindex";
},
OnHistoryPurge() {
this.last = "purge";
},
OnHistoryReload() {
this.last = "reload";
return this.retval;
},
OnHistoryReplaceEntry() {},
QueryInterface: ChromeUtils.generateQI([
Ci.nsISHistoryListener,
Ci.nsISupportsWeakReference,
]),
};
let testAPI = {
shistory: null,
listeners: [new SHistoryListener(), new SHistoryListener()],
init() {
this.shistory = docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
for (let listener of this.listeners) {
this.shistory.legacySHistory.addSHistoryListener(listener);
}
},
cleanup() {
for (let listener of this.listeners) {
this.shistory.legacySHistory.removeSHistoryListener(listener);
}
this.shistory = null;
sendAsyncMessage("bug422543:cleanup:return", {});
},
getListenerStatus() {
sendAsyncMessage(
"bug422543:getListenerStatus:return",
this.listeners.map(l => l.last)
);
},
resetListeners() {
for (let listener of this.listeners) {
listener.last = "initial";
}
sendAsyncMessage("bug422543:resetListeners:return", {});
},
notifyReload() {
let history = this.shistory.legacySHistory;
let rval = history.notifyOnHistoryReload();
sendAsyncMessage("bug422543:notifyReload:return", { rval });
},
setRetval({ num, val }) {
this.listeners[num].retval = val;
sendAsyncMessage("bug422543:setRetval:return", {});
},
};
addMessageListener("bug422543:cleanup", () => {
testAPI.cleanup();
});
addMessageListener("bug422543:getListenerStatus", () => {
testAPI.getListenerStatus();
});
addMessageListener("bug422543:notifyReload", () => {
testAPI.notifyReload();
});
addMessageListener("bug422543:resetListeners", () => {
testAPI.resetListeners();
});
addMessageListener("bug422543:setRetval", msg => {
testAPI.setRetval(msg.data);
});
testAPI.init();