mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1277344 - Opened a new private window, to remove setting docshell to private. r=ehsan
MozReview-Commit-ID: 9hFEKV3Wq2J
This commit is contained in:
parent
1c9bd9748d
commit
5859f4c006
@ -14,27 +14,19 @@
|
||||
add_task(function test() {
|
||||
let prefix = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_concurrent_page.html';
|
||||
|
||||
function setUsePrivateBrowsing(browser, val) {
|
||||
return ContentTask.spawn(browser, val, function* (val) {
|
||||
docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = val;
|
||||
});
|
||||
};
|
||||
|
||||
function getElts(browser) {
|
||||
return browser.contentTitle.split('|');
|
||||
};
|
||||
|
||||
// Step 1
|
||||
gBrowser.selectedTab = gBrowser.addTab(prefix + '?action=set&name=test&value=value&initial=true');
|
||||
let non_private_browser = gBrowser.selectedBrowser;
|
||||
non_private_browser.loadURI(prefix + '?action=set&name=test&value=value&initial=true');
|
||||
yield BrowserTestUtils.browserLoaded(non_private_browser);
|
||||
|
||||
|
||||
// Step 2
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
let private_browser = gBrowser.selectedBrowser;
|
||||
yield BrowserTestUtils.browserLoaded(private_browser);
|
||||
yield setUsePrivateBrowsing(private_browser, true);
|
||||
let private_window = yield BrowserTestUtils.openNewBrowserWindow({ private : true });
|
||||
let private_browser = private_window.getBrowser().selectedBrowser;
|
||||
private_browser.loadURI(prefix + '?action=set&name=test2&value=value2');
|
||||
yield BrowserTestUtils.browserLoaded(private_browser);
|
||||
|
||||
@ -55,10 +47,13 @@ add_task(function test() {
|
||||
is(elts[1], '1', "private window should only see private items");
|
||||
|
||||
|
||||
// Make the private tab public again, which should clear the
|
||||
// Reopen the private window again, without privateBrowsing, which should clear the
|
||||
// the private storage.
|
||||
yield setUsePrivateBrowsing(private_browser, false);
|
||||
private_window.close();
|
||||
private_window = yield BrowserTestUtils.openNewBrowserWindow({ private : false });
|
||||
private_browser = null;
|
||||
yield new Promise(resolve => Cu.schedulePreciseGC(resolve));
|
||||
private_browser = private_window.getBrowser().selectedBrowser;
|
||||
|
||||
private_browser.loadURI(prefix + '?action=get&name=test2');
|
||||
yield BrowserTestUtils.browserLoaded(private_browser);
|
||||
@ -69,16 +64,19 @@ add_task(function test() {
|
||||
|
||||
// Making it private again should clear the storage and it shouldn't
|
||||
// be able to see the old private storage as well.
|
||||
yield setUsePrivateBrowsing(private_browser, true);
|
||||
private_window.close();
|
||||
private_window = yield BrowserTestUtils.openNewBrowserWindow({ private : true });
|
||||
private_browser = null;
|
||||
yield new Promise(resolve => Cu.schedulePreciseGC(resolve));
|
||||
private_browser = private_window.getBrowser().selectedBrowser;
|
||||
|
||||
private_browser.loadURI(prefix + '?action=set&name=test3&value=value3');
|
||||
BrowserTestUtils.browserLoaded(private_browser);
|
||||
yield BrowserTestUtils.browserLoaded(private_browser);
|
||||
elts = yield getElts(private_browser);
|
||||
is(elts[1], '1', "private window should only see new private items");
|
||||
|
||||
// Cleanup.
|
||||
non_private_browser.loadURI(prefix + '?final=true');
|
||||
yield BrowserTestUtils.browserLoaded(non_private_browser);
|
||||
gBrowser.removeCurrentTab();
|
||||
gBrowser.removeCurrentTab();
|
||||
private_window.close();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user