diff --git a/browser/base/content/test/general/browser_close_dependent_tabs.js b/browser/base/content/test/general/browser_close_dependent_tabs.js index 5ab93e5a56ec..0c3f00e242d2 100644 --- a/browser/base/content/test/general/browser_close_dependent_tabs.js +++ b/browser/base/content/test/general/browser_close_dependent_tabs.js @@ -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"); });