fune/browser/components/sessionstore/test/browser_394759_behavior.js
Mike Conley 43834a9b9d Bug 1047603 - Fix browser_394759_behaviour.js test. r=ttaubert.
Turns out this test wasn't accustomed to newly created windows having
initially non-remote browsers, and that we need to wait for them to
redirect and restore in the content process before we can properly
serialize the window.

--HG--
extra : rebase_source : 35a9fc43b5691b024d75b00348f14d27b27f081e
2015-01-26 15:21:34 -05:00

79 lines
2.9 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function test() {
// This test takes quite some time, and timeouts frequently, so we require
// more time to run.
// See Bug 518970.
requestLongerTimeout(2);
waitForExplicitFinish();
// helper function that does the actual testing
function openWindowRec(windowsToOpen, expectedResults, recCallback) {
// do actual checking
if (!windowsToOpen.length) {
let closedWindowData = JSON.parse(ss.getClosedWindowData());
let numPopups = closedWindowData.filter(function(el, i, arr) {
return el.isPopup;
}).length;
let numNormal = ss.getClosedWindowCount() - numPopups;
// #ifdef doesn't work in browser-chrome tests, so do a simple regex on platform
let oResults = navigator.platform.match(/Mac/) ? expectedResults.mac
: expectedResults.other;
is(numPopups, oResults.popup,
"There were " + oResults.popup + " popup windows to repoen");
is(numNormal, oResults.normal,
"There were " + oResults.normal + " normal windows to repoen");
// cleanup & return
executeSoon(recCallback);
return;
}
// hack to force window to be considered a popup (toolbar=no didn't work)
let winData = windowsToOpen.shift();
let settings = "chrome,dialog=no," +
(winData.isPopup ? "all=no" : "all");
let url = "http://example.com/?window=" + windowsToOpen.length;
provideWindow(function onTestURLLoaded(win) {
let tabReady = () => {
win.close();
// Give it time to close
executeSoon(function() {
openWindowRec(windowsToOpen, expectedResults, recCallback);
});
};
if (win.gMultiProcessBrowser) {
let tab = win.gBrowser.selectedTab;
tab.addEventListener("SSTabRestored", function onTabRestored() {
tab.removeEventListener("SSTabRestored", onTabRestored);
tabReady();
});
} else {
tabReady();
}
}, url, settings);
}
let windowsToOpen = [{isPopup: false},
{isPopup: false},
{isPopup: true},
{isPopup: true},
{isPopup: true}];
let expectedResults = {mac: {popup: 3, normal: 0},
other: {popup: 3, normal: 1}};
let windowsToOpen2 = [{isPopup: false},
{isPopup: false},
{isPopup: false},
{isPopup: false},
{isPopup: false}];
let expectedResults2 = {mac: {popup: 0, normal: 3},
other: {popup: 0, normal: 3}};
openWindowRec(windowsToOpen, expectedResults, function() {
openWindowRec(windowsToOpen2, expectedResults2, finish);
});
}