Backed out changeset cb1e59969729 (bug 1315105)

--HG--
extra : rebase_source : 2b71de0fbd36b44663caf37654c88e64bfe9af2c
This commit is contained in:
Carsten "Tomcat" Book 2016-12-19 15:58:55 +01:00
parent 4accb2ccc4
commit f1b50a1663

View File

@ -1,7 +1,6 @@
add_task(function* () {
yield SpecialPowers.pushPrefEnv({
set: [["browser.groupedhistory.enabled", true],
["dom.linkPrerender.enabled", true]]
set: [["browser.groupedhistory.enabled", true]]
});
// Wait for a process change and then fulfil the promise.
@ -15,53 +14,27 @@ add_task(function* () {
});
}
// Wait for given number tabs being closed.
function awaitTabClose(number) {
return new Promise(resolve => {
let seen = 0;
gBrowser.tabContainer.addEventListener("TabClose", function f() {
if (++seen == number) {
gBrowser.tabContainer.removeEventListener("TabClose", f);
resolve();
}
});
});
}
let tab2;
// Test 1: Create prerendered browser, and don't switch to it, then close the tab
let closed1 = awaitTabClose(2);
yield BrowserTestUtils.withNewTab({ gBrowser, url: "data:text/html,a" }, function* (browser1) {
// Set up the grouped SHEntry setup
let requestMade = new Promise(resolve => {
browser1.messageManager.addMessageListener("Prerender:Request", function f() {
browser1.messageManager.removeMessageListener("Prerender:Request", f);
ok(true, "Successfully received the prerender request");
resolve();
});
tab2 = gBrowser.loadOneTab("data:text/html,b", {
referrerPolicy: Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT,
allowThirdPartyFixup: true,
relatedToCurrent: true,
isPrerendered: true,
});
is(gBrowser.tabs.length, 2);
yield ContentTask.spawn(browser1, null, function() {
let link = content.document.createElement("link");
link.setAttribute("rel", "prerender");
link.setAttribute("href", "data:text/html,b");
content.document.body.appendChild(link);
});
yield requestMade;
is(gBrowser.tabs.length, 3);
});
yield closed1;
// At this point prerendered tab should be closed
is(gBrowser.tabs.length, 1, "The new tab and the prerendered 'tab' should be closed");
// At this point tab2 should be closed
todo(!tab2.linkedBrowser, "The new tab should be closed");
yield BrowserTestUtils.removeTab(tab2); // XXX: Shouldn't be needed once the todo is fixed
// Test 2: Create prerendered browser, switch to it, then close the tab
let closed2 = awaitTabClose(2);
yield BrowserTestUtils.withNewTab({ gBrowser, url: "data:text/html,a" }, function* (browser1) {
// Set up the grouped SHEntry setup
let tab2 = gBrowser.loadOneTab("data:text/html,b", {
tab2 = gBrowser.loadOneTab("data:text/html,b", {
referrerPolicy: Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT,
allowThirdPartyFixup: true,
relatedToCurrent: true,
@ -72,8 +45,7 @@ add_task(function* () {
tab2.linkedBrowser.frameLoader);
yield awaitProcessChange(browser1);
});
yield closed2;
// At this point prerendered tab should be closed
is(gBrowser.tabs.length, 1, "The new tab and the prerendered 'tab' should be closed");
// At this point tab2 should be closed
ok(!tab2.linkedBrowser, "The new tab should be closed");
});