mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1616353 - Part 12: Remove or fix tests which try to set OriginAttributes too late, r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D67059 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
d9dd824ff3
commit
7031bc0da0
@ -8,103 +8,6 @@ add_task(function cleanup() {
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
let URL_PUBLIC = "http://example.com/public/" + Math.random();
|
||||
let URL_PRIVATE = "http://example.com/private/" + Math.random();
|
||||
let tab1, tab2;
|
||||
try {
|
||||
// Setup a public tab and a private tab
|
||||
info("Setting up public tab");
|
||||
tab1 = BrowserTestUtils.addTab(gBrowser, URL_PUBLIC);
|
||||
await promiseBrowserLoaded(tab1.linkedBrowser);
|
||||
|
||||
info("Setting up private tab");
|
||||
tab2 = BrowserTestUtils.addTab(gBrowser);
|
||||
await promiseBrowserLoaded(tab2.linkedBrowser);
|
||||
await setUsePrivateBrowsing(tab2.linkedBrowser, true);
|
||||
BrowserTestUtils.loadURI(tab2.linkedBrowser, URL_PRIVATE);
|
||||
await promiseBrowserLoaded(tab2.linkedBrowser);
|
||||
|
||||
info("Flush to make sure chrome received all data.");
|
||||
await TabStateFlusher.flush(tab1.linkedBrowser);
|
||||
await TabStateFlusher.flush(tab2.linkedBrowser);
|
||||
|
||||
info("Checking out state");
|
||||
let state = await promiseRecoveryFileContents();
|
||||
|
||||
info("State: " + state);
|
||||
// Ensure that sessionstore.js only knows about the public tab
|
||||
ok(state.includes(URL_PUBLIC), "State contains public tab");
|
||||
ok(!state.includes(URL_PRIVATE), "State does not contain private tab");
|
||||
|
||||
// Ensure that we can close and undo close the public tab but not the private tab
|
||||
gBrowser.removeTab(tab2);
|
||||
tab2 = null;
|
||||
|
||||
gBrowser.removeTab(tab1);
|
||||
tab1 = null;
|
||||
|
||||
tab1 = ss.undoCloseTab(window, 0);
|
||||
ok(true, "Public tab supports undo close");
|
||||
|
||||
is(
|
||||
ss.getClosedTabCount(window),
|
||||
0,
|
||||
"Private tab does not support undo close"
|
||||
);
|
||||
} finally {
|
||||
if (tab1) {
|
||||
gBrowser.removeTab(tab1);
|
||||
}
|
||||
if (tab2) {
|
||||
gBrowser.removeTab(tab2);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
const FRAME_SCRIPT =
|
||||
"data:," +
|
||||
"docShell.QueryInterface%28Components.interfaces.nsILoadContext%29.usePrivateBrowsing%3Dtrue";
|
||||
|
||||
// Clear the list of closed windows.
|
||||
forgetClosedWindows();
|
||||
|
||||
// Create a new window to attach our frame script to.
|
||||
let win = await promiseNewWindowLoaded();
|
||||
let mm = win.getGroupMessageManager("browsers");
|
||||
mm.loadFrameScript(FRAME_SCRIPT, true);
|
||||
|
||||
// Create a new tab in the new window that will load the frame script.
|
||||
let tab = BrowserTestUtils.addTab(win.gBrowser, "about:mozilla");
|
||||
let browser = tab.linkedBrowser;
|
||||
await promiseBrowserLoaded(browser);
|
||||
await TabStateFlusher.flush(browser);
|
||||
|
||||
// Check that we consider the tab as private.
|
||||
let state = JSON.parse(ss.getTabState(tab));
|
||||
ok(state.isPrivate, "tab considered private");
|
||||
|
||||
// Ensure we don't allow restoring closed private tabs in non-private windows.
|
||||
win.gBrowser.removeTab(tab);
|
||||
is(ss.getClosedTabCount(win), 0, "no tabs to restore");
|
||||
|
||||
// Create a new tab in the new window that will load the frame script.
|
||||
tab = BrowserTestUtils.addTab(win.gBrowser, "about:mozilla");
|
||||
browser = tab.linkedBrowser;
|
||||
await promiseBrowserLoaded(browser);
|
||||
await TabStateFlusher.flush(browser);
|
||||
|
||||
// Check that we consider the tab as private.
|
||||
state = JSON.parse(ss.getTabState(tab));
|
||||
ok(state.isPrivate, "tab considered private");
|
||||
|
||||
// Check that all private tabs are removed when the non-private
|
||||
// window is closed and we don't save windows without any tabs.
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
is(ss.getClosedWindowCount(), 0, "no windows to restore");
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
// Clear the list of closed windows.
|
||||
forgetClosedWindows();
|
||||
@ -130,7 +33,3 @@ add_task(async function() {
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
is(ss.getClosedWindowCount(), 0, "no windows to restore");
|
||||
});
|
||||
|
||||
function setUsePrivateBrowsing(browser, val) {
|
||||
return sendMessage(browser, "ss-test:setUsePrivateBrowsing", val);
|
||||
}
|
||||
|
@ -110,12 +110,6 @@ addMessageListener("ss-test:setAuthorStyleDisabled", function(msg) {
|
||||
sendSyncMessage("ss-test:setAuthorStyleDisabled");
|
||||
});
|
||||
|
||||
addMessageListener("ss-test:setUsePrivateBrowsing", function(msg) {
|
||||
let loadContext = docShell.QueryInterface(Ci.nsILoadContext);
|
||||
loadContext.usePrivateBrowsing = msg.data;
|
||||
sendAsyncMessage("ss-test:setUsePrivateBrowsing");
|
||||
});
|
||||
|
||||
addMessageListener("ss-test:getScrollPosition", function(msg) {
|
||||
let frame = content;
|
||||
if (msg.data.hasOwnProperty("frame")) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
function destroy_transient_docshell() {
|
||||
let windowlessBrowser = Services.appShell.createWindowlessBrowser(false);
|
||||
let windowlessBrowser = Services.appShell.createWindowlessBrowser(true);
|
||||
windowlessBrowser.docShell.setOriginAttributes({ privateBrowsingId: 1 });
|
||||
windowlessBrowser.close();
|
||||
do_test_pending();
|
||||
|
@ -12,7 +12,7 @@ var observer = {
|
||||
};
|
||||
|
||||
function run_test() {
|
||||
let windowlessBrowser = Services.appShell.createWindowlessBrowser(false);
|
||||
let windowlessBrowser = Services.appShell.createWindowlessBrowser(true);
|
||||
windowlessBrowser.docShell.addWeakPrivacyTransitionObserver(observer);
|
||||
windowlessBrowser.docShell.setOriginAttributes({ privateBrowsingId: 1 });
|
||||
windowlessBrowser.docShell.setOriginAttributes({ privateBrowsingId: 0 });
|
||||
|
@ -1,96 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
const { AppConstants } = ChromeUtils.import(
|
||||
"resource://gre/modules/AppConstants.jsm"
|
||||
);
|
||||
|
||||
add_task(async function() {
|
||||
let webNav = Services.appShell.createWindowlessBrowser(false);
|
||||
|
||||
let docShell = webNav.docShell;
|
||||
|
||||
let loadContext = docShell.QueryInterface(Ci.nsILoadContext);
|
||||
|
||||
equal(
|
||||
loadContext.usePrivateBrowsing,
|
||||
false,
|
||||
"Should start out in non-private mode"
|
||||
);
|
||||
|
||||
loadContext.usePrivateBrowsing = true;
|
||||
equal(
|
||||
loadContext.usePrivateBrowsing,
|
||||
true,
|
||||
"Should be able to change to private mode prior to a document load"
|
||||
);
|
||||
|
||||
loadContext.usePrivateBrowsing = false;
|
||||
equal(
|
||||
loadContext.usePrivateBrowsing,
|
||||
false,
|
||||
"Should be able to change to non-private mode prior to a document load"
|
||||
);
|
||||
|
||||
let oa = docShell.getOriginAttributes();
|
||||
|
||||
oa.privateBrowsingId = 1;
|
||||
docShell.setOriginAttributes(oa);
|
||||
|
||||
equal(
|
||||
loadContext.usePrivateBrowsing,
|
||||
true,
|
||||
"Should be able to change origin attributes prior to a document load"
|
||||
);
|
||||
|
||||
oa.privateBrowsingId = 0;
|
||||
docShell.setOriginAttributes(oa);
|
||||
|
||||
equal(
|
||||
loadContext.usePrivateBrowsing,
|
||||
false,
|
||||
"Should be able to change origin attributes prior to a document load"
|
||||
);
|
||||
|
||||
let loadURIOptions = {
|
||||
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
};
|
||||
webNav.loadURI("data:text/html,", loadURIOptions);
|
||||
|
||||
// Return to the event loop so the load can begin.
|
||||
await new Promise(executeSoon);
|
||||
|
||||
// This causes a failed assertion rather than an exception on debug
|
||||
// builds.
|
||||
if (!AppConstants.DEBUG) {
|
||||
Assert.throws(
|
||||
() => {
|
||||
loadContext.usePrivateBrowsing = true;
|
||||
},
|
||||
/NS_ERROR_FAILURE/,
|
||||
"Should not be able to change private browsing state after initial load has started"
|
||||
);
|
||||
|
||||
oa.privateBrowsingId = 1;
|
||||
Assert.throws(
|
||||
() => {
|
||||
docShell.setOriginAttributes(oa);
|
||||
},
|
||||
/NS_ERROR_FAILURE/,
|
||||
"Should not be able to change origin attributes after initial load has started"
|
||||
);
|
||||
|
||||
equal(
|
||||
loadContext.usePrivateBrowsing,
|
||||
false,
|
||||
"Should not be able to change private browsing state after initial load has started"
|
||||
);
|
||||
|
||||
loadContext.usePrivateBrowsing = false;
|
||||
ok(
|
||||
true,
|
||||
"Should be able to set usePrivateBrowsing to its current value even after initial load"
|
||||
);
|
||||
}
|
||||
|
||||
webNav.close();
|
||||
});
|
@ -14,5 +14,3 @@ skip-if = os == 'android'
|
||||
# Bug 751575: unrelated JS changes cause timeouts on random platforms
|
||||
skip-if = true
|
||||
[test_privacy_transition.js]
|
||||
[test_setUsePrivateBrowsing.js]
|
||||
skip-if = os == 'android' && processor == 'x86_64' && debug
|
||||
|
@ -790,6 +790,7 @@ skip-if = toolkit == 'android' # Plugins don't work on Android
|
||||
[test_postMessages_messagePort.html]
|
||||
[test_postMessage_originAttributes.html]
|
||||
support-files = file_receiveMessage.html
|
||||
skip-if = true # Uses mismatched OriginAttributes for iframe (bug 1616353)
|
||||
[test_processing_instruction_update_stylesheet.xhtml]
|
||||
[test_progress_events_for_gzip_data.html]
|
||||
skip-if = tsan # Bug 1621323
|
||||
|
Loading…
Reference in New Issue
Block a user