mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1319452: Part 1 - Load background page in private browsing mode during permanent private browsing. r=billm
MozReview-Commit-ID: KXA7xlq8Voc --HG-- extra : rebase_source : 558e3f979df38b8c43333644611f3902629de2b7
This commit is contained in:
parent
921224f8f4
commit
c8594e2c87
@ -7,6 +7,8 @@ Cu.import("resource://gre/modules/Task.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
|
||||
"resource://gre/modules/AddonManager.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
|
||||
"resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
|
||||
Cu.import("resource://gre/modules/ExtensionUtils.jsm");
|
||||
const {
|
||||
@ -92,6 +94,12 @@ class BackgroundPageBase {
|
||||
}
|
||||
|
||||
initParentWindow(chromeShell) {
|
||||
if (PrivateBrowsingUtils.permanentPrivateBrowsing) {
|
||||
let attrs = chromeShell.getOriginAttributes();
|
||||
attrs.privateBrowsingId = 1;
|
||||
chromeShell.setOriginAttributes(attrs);
|
||||
}
|
||||
|
||||
let system = Services.scriptSecurityManager.getSystemPrincipal();
|
||||
chromeShell.createAboutBlankContentViewer(system);
|
||||
chromeShell.useGlobalHistory = false;
|
||||
|
@ -0,0 +1,40 @@
|
||||
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set sts=2 sw=2 et tw=80: */
|
||||
"use strict";
|
||||
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
|
||||
function* testBackgroundPage(expected) {
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
async background() {
|
||||
browser.test.assertEq(window, browser.extension.getBackgroundPage(),
|
||||
"Caller should be able to access itself as a background page");
|
||||
browser.test.assertEq(window, await browser.runtime.getBackgroundPage(),
|
||||
"Caller should be able to access itself as a background page");
|
||||
|
||||
browser.test.sendMessage("incognito", browser.extension.inIncognitoContext);
|
||||
},
|
||||
});
|
||||
|
||||
yield extension.startup();
|
||||
|
||||
let incognito = yield extension.awaitMessage("incognito");
|
||||
equal(incognito, expected.incognito, "Expected incognito value");
|
||||
|
||||
yield extension.unload();
|
||||
}
|
||||
|
||||
add_task(function* test_background_incognito() {
|
||||
do_print("Test background page incognito value with permanent private browsing disabled");
|
||||
|
||||
yield testBackgroundPage({incognito: false});
|
||||
|
||||
do_print("Test background page incognito value with permanent private browsing enabled");
|
||||
|
||||
Preferences.set("browser.privatebrowsing.autostart", true);
|
||||
do_register_cleanup(() => {
|
||||
Preferences.reset("browser.privatebrowsing.autostart");
|
||||
});
|
||||
|
||||
yield testBackgroundPage({incognito: true});
|
||||
});
|
@ -19,6 +19,7 @@ tags = webextensions
|
||||
[test_ext_background_generated_reload.js]
|
||||
[test_ext_background_global_history.js]
|
||||
skip-if = os == "android" # Android does not use Places for history.
|
||||
[test_ext_background_private_browsing.js]
|
||||
[test_ext_background_runtime_connect_params.js]
|
||||
[test_ext_background_sub_windows.js]
|
||||
[test_ext_background_window_properties.js]
|
||||
|
Loading…
Reference in New Issue
Block a user