mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1132566 - Cleanup browser_privatebrowsing_concurrent.js; r=mossop
Factor some of the repeated ContentTask.spawns into their own functions and comment what's happening a bit better. A few variables are also renamed to clarify what they represent.
This commit is contained in:
parent
496df57ed0
commit
4890331124
@ -14,54 +14,71 @@
|
||||
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_tab = gBrowser.selectedBrowser;
|
||||
yield BrowserTestUtils.browserLoaded(non_private_tab);
|
||||
let non_private_browser = gBrowser.selectedBrowser;
|
||||
yield BrowserTestUtils.browserLoaded(non_private_browser);
|
||||
|
||||
|
||||
// Step 2
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
let private_tab = gBrowser.selectedBrowser;
|
||||
yield BrowserTestUtils.browserLoaded(private_tab);
|
||||
yield ContentTask.spawn(private_tab, {}, function* () {
|
||||
docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = true;
|
||||
});
|
||||
private_tab.loadURI(prefix + '?action=set&name=test2&value=value2');
|
||||
yield BrowserTestUtils.browserLoaded(private_tab);
|
||||
let private_browser = gBrowser.selectedBrowser;
|
||||
yield BrowserTestUtils.browserLoaded(private_browser);
|
||||
yield setUsePrivateBrowsing(private_browser, true);
|
||||
private_browser.loadURI(prefix + '?action=set&name=test2&value=value2');
|
||||
yield BrowserTestUtils.browserLoaded(private_browser);
|
||||
|
||||
non_private_tab.loadURI(prefix + '?action=get&name=test2');
|
||||
yield BrowserTestUtils.browserLoaded(non_private_tab);
|
||||
let elts = non_private_tab.contentTitle.split('|');
|
||||
|
||||
// Step 3
|
||||
non_private_browser.loadURI(prefix + '?action=get&name=test2');
|
||||
yield BrowserTestUtils.browserLoaded(non_private_browser);
|
||||
let elts = yield getElts(non_private_browser);
|
||||
isnot(elts[0], 'value2', "public window shouldn't see private storage");
|
||||
is(elts[1], '1', "public window should only see public items");
|
||||
|
||||
private_tab.loadURI(prefix + '?action=get&name=test');
|
||||
yield BrowserTestUtils.browserLoaded(private_tab);
|
||||
elts = private_tab.contentTitle.split('|');
|
||||
|
||||
// Step 4
|
||||
private_browser.loadURI(prefix + '?action=get&name=test');
|
||||
yield BrowserTestUtils.browserLoaded(private_browser);
|
||||
elts = yield getElts(private_browser);
|
||||
isnot(elts[0], 'value', "private window shouldn't see public storage");
|
||||
is(elts[1], '1', "private window should only see private items");
|
||||
|
||||
yield ContentTask.spawn(private_tab, {}, function* (){
|
||||
docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = false;
|
||||
});
|
||||
|
||||
// Make the private tab public again, which should clear the
|
||||
// the private storage.
|
||||
yield setUsePrivateBrowsing(private_browser, false);
|
||||
yield new Promise(resolve => Cu.schedulePreciseGC(resolve));
|
||||
|
||||
private_tab.loadURI(prefix + '?action=get&name=test2');
|
||||
yield BrowserTestUtils.browserLoaded(private_tab);
|
||||
elts = private_tab.contentTitle.split('|');
|
||||
private_browser.loadURI(prefix + '?action=get&name=test2');
|
||||
yield BrowserTestUtils.browserLoaded(private_browser);
|
||||
elts = yield getElts(private_browser);
|
||||
isnot(elts[0], 'value2', "public window shouldn't see cleared private storage");
|
||||
is(elts[1], '1', "public window should only see public items");
|
||||
|
||||
yield ContentTask.spawn(private_tab, {}, function* (){
|
||||
docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = true;
|
||||
});
|
||||
|
||||
private_tab.loadURI(prefix + '?action=set&name=test3&value=value3');
|
||||
BrowserTestUtils.browserLoaded(private_tab);
|
||||
elts = private_tab.contentTitle.split('|');
|
||||
// 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_browser.loadURI(prefix + '?action=set&name=test3&value=value3');
|
||||
BrowserTestUtils.browserLoaded(private_browser);
|
||||
elts = yield getElts(private_browser);
|
||||
is(elts[1], '1', "private window should only see new private items");
|
||||
|
||||
// Cleanup.
|
||||
non_private_tab.loadURI(prefix + '?final=true');
|
||||
yield BrowserTestUtils.browserLoaded(non_private_tab);
|
||||
non_private_browser.loadURI(prefix + '?final=true');
|
||||
yield BrowserTestUtils.browserLoaded(non_private_browser);
|
||||
gBrowser.removeCurrentTab();
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user