forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1261842 - Fix up some private browsing tests to account for initi…
…al browsers being remote now. r=jdm MozReview-Commit-ID: CxhKsIXnPxj --HG-- extra : rebase_source : 158631cd0b0dac610a5f89dd48b3b13e64ed0c6f extra : source : f6062f1139114f586e3ea9f6d946766f63dedb1d
- Loading branch information
1 parent
d22a16e
commit 5f1bcd6
Showing
2 changed files
with
37 additions
and
63 deletions.
There are no files selected for viewing
51 changes: 20 additions & 31 deletions
51
...onents/privatebrowsing/test/browser/browser_privatebrowsing_noSessionRestoreMenuOption.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); |
49 changes: 17 additions & 32 deletions
49
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_nonbrowser.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |