mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1261842 - Fix up some private browsing tests to account for initial browsers being remote now. r=jdm
MozReview-Commit-ID: CxhKsIXnPxj --HG-- extra : rebase_source : 158631cd0b0dac610a5f89dd48b3b13e64ed0c6f extra : source : f6062f1139114f586e3ea9f6d946766f63dedb1d
This commit is contained in:
parent
d22a16e722
commit
5f1bcd6334
@ -1,34 +1,23 @@
|
||||
/* 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/. */
|
||||
"use strict";
|
||||
|
||||
// This test checks that the Session Restore menu option is not enabled in private mode
|
||||
/**
|
||||
* Tests that if we open a tab within a private browsing window, and then
|
||||
* close that private browsing window, that subsequent private browsing
|
||||
* windows do not allow the command for restoring the last session.
|
||||
*/
|
||||
add_task(function* test_no_session_restore_menu_option() {
|
||||
let win = yield BrowserTestUtils.openNewBrowserWindow({ private: true });
|
||||
ok(true, "The first private window got loaded");
|
||||
win.gBrowser.addTab("about:mozilla");
|
||||
yield BrowserTestUtils.closeWindow(win);
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
win = yield BrowserTestUtils.openNewBrowserWindow({ private: true });
|
||||
let srCommand = win.document.getElementById("Browser:RestoreLastSession");
|
||||
ok(srCommand, "The Session Restore command should exist");
|
||||
is(PrivateBrowsingUtils.isWindowPrivate(win), true,
|
||||
"PrivateBrowsingUtils should report the correct per-window private browsing status");
|
||||
is(srCommand.hasAttribute("disabled"), true,
|
||||
"The Session Restore command should be disabled in private browsing mode");
|
||||
|
||||
function testNoSessionRestoreMenuItem() {
|
||||
let win = OpenBrowserWindow({private: true});
|
||||
win.addEventListener("load", function onLoad() {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
ok(true, "The second private window got loaded");
|
||||
let srCommand = win.document.getElementById("Browser:RestoreLastSession");
|
||||
ok(srCommand, "The Session Restore command should exist");
|
||||
is(PrivateBrowsingUtils.isWindowPrivate(win), true,
|
||||
"PrivateBrowsingUtils should report the correct per-window private browsing status");
|
||||
is(srCommand.hasAttribute("disabled"), true,
|
||||
"The Session Restore command should be disabled in private browsing mode");
|
||||
win.close();
|
||||
finish();
|
||||
}, false);
|
||||
}
|
||||
|
||||
let win = OpenBrowserWindow({private: true});
|
||||
win.addEventListener("load", function onload() {
|
||||
win.removeEventListener("load", onload, false);
|
||||
ok(true, "The first private window got loaded");
|
||||
win.gBrowser.addTab("about:mozilla");
|
||||
win.close();
|
||||
testNoSessionRestoreMenuItem();
|
||||
}, false);
|
||||
}
|
||||
yield BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
|
@ -1,34 +1,19 @@
|
||||
/* 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/. */
|
||||
"use strict";
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
/**
|
||||
* Tests that we fire the last-pb-context-exited observer notification
|
||||
* when the last private browsing window closes, even if a chrome window
|
||||
* was opened from that private browsing window.
|
||||
*/
|
||||
add_task(function* () {
|
||||
let win = yield BrowserTestUtils.openNewBrowserWindow({private: true});
|
||||
let chromeWin = win.open("chrome://browser/content/places/places.xul", "_blank",
|
||||
"chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar");
|
||||
yield BrowserTestUtils.waitForEvent(chromeWin, "load");
|
||||
let obsPromise = TestUtils.topicObserved("last-pb-context-exited");
|
||||
yield BrowserTestUtils.closeWindow(win);
|
||||
yield obsPromise;
|
||||
Assert.ok(true, "Got the last-pb-context-exited notification");
|
||||
chromeWin.close();
|
||||
});
|
||||
|
||||
let windowsToClose = [];
|
||||
registerCleanupFunction(function() {
|
||||
windowsToClose.forEach(function(win) {
|
||||
win.close();
|
||||
});
|
||||
});
|
||||
|
||||
let win = OpenBrowserWindow({private: true});
|
||||
win.addEventListener("load", function onLoad() {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
let chromeWin = win.open("chrome://browser/content/places/places.xul",
|
||||
"_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar");
|
||||
chromeWin.addEventListener("load", function chromeWinLoad() {
|
||||
chromeWin.removeEventListener("load", chromeWinLoad, false);
|
||||
win.close();
|
||||
}, false);
|
||||
windowsToClose.push(chromeWin);
|
||||
}, false);
|
||||
|
||||
let observer = function() {
|
||||
is(true, true, "observer fired");
|
||||
Services.obs.removeObserver(observer, "last-pb-context-exited");
|
||||
executeSoon(finish);
|
||||
};
|
||||
Services.obs.addObserver(observer, "last-pb-context-exited", false);
|
||||
windowsToClose.push(win);
|
||||
}
|
Loading…
Reference in New Issue
Block a user