Backed out changeset 5414d6a71785 (bug 1315105)

--HG--
extra : rebase_source : 32ab8a0003ae643e467bcc24bd857ce58679c82f
This commit is contained in:
Carsten "Tomcat" Book 2016-12-19 15:58:54 +01:00
parent 2f85471cc3
commit 4accb2ccc4
3 changed files with 0 additions and 162 deletions

View File

@ -42,6 +42,3 @@ support-files =
support-files =
test_new_window_from_content_child.html
[browser_xhr_sandbox.js]
[browser_prerendering.js]
support-files = prerender.html
skip-if = !e10s # Prerendering requires e10s

View File

@ -1,152 +0,0 @@
const URL = "https://example.com/browser/dom/tests/browser/prerender.html";
// Wait for a process change and then fulfil the promise.
function awaitProcessChange(browser) {
return new Promise(resolve => {
browser.addEventListener("BrowserChangedProcess", function bcp(e) {
browser.removeEventListener("BrowserChangedProcess", bcp);
info("The browser changed process!");
resolve();
});
});
}
// Wait for onbeforeunload dialog, and dismiss it immediately.
function awaitAndCloseBeforeUnloadDialog() {
return new Promise(resolve => {
function onDialogShown(node) {
info("Found onbeforeunload dialog");
Services.obs.removeObserver(onDialogShown,
"tabmodal-dialog-loaded");
let dismissButton = node.ui.button0;
dismissButton.click();
resolve();
}
Services.obs.addObserver(onDialogShown, "tabmodal-dialog-loaded");
});
}
add_task(function* () {
yield SpecialPowers.pushPrefEnv({
set: [["browser.groupedhistory.enabled", true],
["dom.linkPrerender.enabled", true],
["dom.require_user_interaction_for_beforeunload", false]]
});
});
// Test 1: Creating a prerendered browser, and clicking on a link to that browser,
// will cause changes.
add_task(function* () {
let tab = gBrowser.addTab(URL);
yield new Promise(resolve => {
tab.linkedBrowser.messageManager.addMessageListener("Prerender:Request", function f() {
tab.linkedBrowser.messageManager.removeMessageListener("Prerender:Request", f);
info("Successfully received the prerender request");
resolve();
});
});
yield BrowserTestUtils.switchTab(gBrowser, tab);
// Check that visibilityState is set correctly in the prerendered tab. We
// check all of the tabs because we have no easy way to tell which one is
// which.
let result;
for (let i = 0; i < gBrowser.tabs.length; ++i) {
result = yield ContentTask.spawn(gBrowser.tabs[i].linkedBrowser, null, function* () {
let interesting = content.document.location.toString() == "data:text/html,b";
if (interesting) {
is(content.document.visibilityState, "prerender");
}
return interesting;
});
if (result) {
break;
}
}
ok(result, "The prerender tab was found!");
let dialogShown = awaitAndCloseBeforeUnloadDialog();
ContentTask.spawn(tab.linkedBrowser, null, function*() {
let anchor = content.document.querySelector("a");
anchor.click();
});
yield dialogShown;
yield awaitProcessChange(tab.linkedBrowser);
yield ContentTask.spawn(tab.linkedBrowser, null, function*() {
is(content.document.location.toString(), "data:text/html,b");
is(content.document.visibilityState, "visible",
"VisibilityState of formerly prerendered window must be visible");
});
let groupedSHistory = tab.linkedBrowser.frameLoader.groupedSessionHistory;
is(groupedSHistory.count, 2, "Check total length of grouped shistory.");
is(gBrowser.tabs.length, 3, "Check number of opened tabs.");
// We don't touch the about:blank tab opened when browser mochitest runs.
// The tabs under test are the other 2 tabs, so we're expecting 2 TabClose.
let closed = new Promise(resolve => {
let seen = 0;
gBrowser.tabContainer.addEventListener("TabClose", function f() {
if (++seen == 2) {
gBrowser.tabContainer.removeEventListener("TabClose", f);
resolve();
}
});
});
yield BrowserTestUtils.removeTab(tab);
yield closed;
is(gBrowser.tabs.length, 1);
});
// Test 2: Creating a prerendered browser, and navigating to a different url,
// succeeds, and closes the prerendered browser.
add_task(function* () {
let tab = gBrowser.addTab(URL);
yield Promise.all([
BrowserTestUtils.browserLoaded(tab.linkedBrowser),
new Promise(resolve => {
tab.linkedBrowser.messageManager.addMessageListener("Prerender:Request", function f() {
tab.linkedBrowser.messageManager.removeMessageListener("Prerender:Request", f);
info("Successfully received the prerender request");
resolve();
});
}),
BrowserTestUtils.switchTab(gBrowser, tab),
]);
let dialogShown = awaitAndCloseBeforeUnloadDialog();
ContentTask.spawn(tab.linkedBrowser, null, function*() {
let anchor = content.document.querySelector("a");
anchor.setAttribute("href", "data:text/html,something_else");
anchor.click();
});
yield dialogShown;
yield Promise.all([
BrowserTestUtils.browserLoaded(tab.linkedBrowser),
new Promise(resolve => {
let seen = false;
gBrowser.tabContainer.addEventListener("TabClose", function f() {
gBrowser.tabContainer.removeEventListener("TabClose", f);
if (!seen) {
seen = true;
info("The tab was closed");
resolve();
}
});
}),
]);
yield ContentTask.spawn(tab.linkedBrowser, null, function*() {
is(content.document.location.toString(), "data:text/html,something_else");
});
yield BrowserTestUtils.removeTab(tab);
});

View File

@ -1,7 +0,0 @@
<html>
<head><title>Prerender Test</title></head>
<body onbeforeunload="return 'stay with me';">
<link rel="prerender" href="data:text/html,b">
<a href="data:text/html,b">clicky here</a>
</body>
</html>