Bug 1132566 - Make test e10s compatible: browser_privatebrowsing_crh.js; r=mossop

--HG--
extra : rebase_source : 589646a3c98e6716c268e914616914b2a6871d25
This commit is contained in:
Steven MacLeod 2015-03-05 12:06:20 -05:00
Родитель bd3bc10806
Коммит f9facaba93
2 изменённых файлов: 27 добавлений и 45 удалений

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

@ -27,7 +27,6 @@ skip-if = e10s
[browser_privatebrowsing_cookieacceptdialog.js]
skip-if = e10s # Bug 1139953 - Accept cookie dialog shown in private window when e10s enabled
[browser_privatebrowsing_crh.js]
skip-if = e10s
[browser_privatebrowsing_downloadLastDir.js]
skip-if = e10s
[browser_privatebrowsing_downloadLastDir_c.js]

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

@ -5,55 +5,38 @@
// This test makes sure that the Clear Recent History menu item and command
// is disabled inside the private browsing mode.
function test() {
waitForExplicitFinish();
add_task(function test() {
function checkDisableOption(aPrivateMode, aWindow) {
let crhCommand = aWindow.document.getElementById("Tools:Sanitize");
ok(crhCommand, "The clear recent history command should exist");
function checkDisableOption(aPrivateMode, aWindow, aCallback) {
executeSoon(function() {
let crhCommand = aWindow.document.getElementById("Tools:Sanitize");
ok(crhCommand, "The clear recent history command should exist");
is(PrivateBrowsingUtils.isWindowPrivate(aWindow), aPrivateMode,
"PrivateBrowsingUtils should report the correct per-window private browsing status");
is(crhCommand.hasAttribute("disabled"), aPrivateMode,
"Clear Recent History command should be disabled according to the private browsing mode");
executeSoon(aCallback);
});
is(PrivateBrowsingUtils.isWindowPrivate(aWindow), aPrivateMode,
"PrivateBrowsingUtils should report the correct per-window private browsing status");
is(crhCommand.hasAttribute("disabled"), aPrivateMode,
"Clear Recent History command should be disabled according to the private browsing mode");
};
let windowsToClose = [];
let testURI = "http://mochi.test:8888/";
function testOnWindow(aIsPrivate, aCallback) {
whenNewWindowLoaded({private: aIsPrivate}, function(aWin) {
windowsToClose.push(aWin);
aWin.gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
if (aWin.content.location.href != testURI) {
aWin.gBrowser.loadURI(testURI);
return;
}
aWin.gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
executeSoon(function() aCallback(aWin));
}, true);
let privateWin = yield BrowserTestUtils.openNewBrowserWindow({private: true});
let privateBrowser = privateWin.gBrowser.selectedBrowser;
privateBrowser.loadURI(testURI);
yield BrowserTestUtils.browserLoaded(privateBrowser);
aWin.gBrowser.loadURI(testURI);
});
};
info("Test on private window");
checkDisableOption(true, privateWin);
registerCleanupFunction(function() {
windowsToClose.forEach(function(aWin) {
aWin.close();
});
});
testOnWindow(true, function(aWin) {
info("Test on private window");
checkDisableOption(true, aWin, function() {
testOnWindow(false, function(aPrivWin) {
info("Test on public window");
checkDisableOption(false, aPrivWin, finish);
});
});
});
}
let win = yield BrowserTestUtils.openNewBrowserWindow();
let browser = win.gBrowser.selectedBrowser;
browser.loadURI(testURI);
yield BrowserTestUtils.browserLoaded(browser);
info("Test on public window");
checkDisableOption(false, win);
// Cleanup
yield BrowserTestUtils.closeWindow(privateWin);
yield BrowserTestUtils.closeWindow(win);
});