Bug 1296934: Prevent background pages from showing up in global history. r?krizsa draft
authorKris Maglione <maglione.k@gmail.com>
Sun, 21 Aug 2016 12:43:50 -0700
changeset 403716 c58ac81f7eaab5e88cd701cd9949a8d6c064ddc6
parent 403715 64fc57e6ee841f55e2d2f196b51aff11b71a428e
child 528976 4ea58ebdb8a2fb96e8eff1aa95ab606ea5c3899b
push id26986
push usermaglione.k@gmail.com
push dateSun, 21 Aug 2016 19:44:19 +0000
reviewerskrizsa
bugs1296934
milestone51.0a1
Bug 1296934: Prevent background pages from showing up in global history. r?krizsa MozReview-Commit-ID: GRIJwCsfqVB
toolkit/components/extensions/ext-backgroundPage.js
toolkit/components/extensions/test/xpcshell/test_ext_background_global_history.js
toolkit/components/extensions/test/xpcshell/xpcshell.ini
--- a/toolkit/components/extensions/ext-backgroundPage.js
+++ b/toolkit/components/extensions/ext-backgroundPage.js
@@ -58,16 +58,17 @@ BackgroundPage.prototype = {
     // underlying docShell, and `QueryInterface(nsIWebNavigation)` gives us
     // access to the webNav methods that are already available on the
     // windowless browser, but contrary to appearances, they are not the same
     // object.
     let chromeShell = windowlessBrowser.QueryInterface(Ci.nsIInterfaceRequestor)
                                        .getInterface(Ci.nsIDocShell)
                                        .QueryInterface(Ci.nsIWebNavigation);
 
+    chromeShell.useGlobalHistory = false;
     chromeShell.createAboutBlankContentViewer(system);
     chromeShell.loadURI(XUL_URL, 0, null, null, null);
 
 
     yield promiseObserved("chrome-document-global-created",
                           win => win.document == chromeShell.document);
 
     let chromeDoc = yield promiseDocumentLoaded(chromeShell.document);
new file mode 100644
--- /dev/null
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_background_global_history.js
@@ -0,0 +1,22 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
+Cu.import("resource://testing-common/PlacesTestUtils.jsm");
+
+add_task(function* test_global_history() {
+  let extension = ExtensionTestUtils.loadExtension({
+    background() {
+      browser.test.sendMessage("background-loaded", location.href);
+    },
+  });
+
+  yield extension.startup();
+
+  let backgroundURL = yield extension.awaitMessage("background-loaded");
+
+  yield extension.unload();
+
+  let exists = yield PlacesTestUtils.isPageInDB(backgroundURL);
+  ok(!exists, "Background URL should not be in history database");
+});
--- a/toolkit/components/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell.ini
@@ -10,16 +10,18 @@ tags = webextensions
 [test_csp_custom_policies.js]
 [test_csp_validator.js]
 [test_ext_alarms.js]
 [test_ext_alarms_does_not_fire.js]
 [test_ext_alarms_periodic.js]
 [test_ext_alarms_replaces.js]
 [test_ext_background_generated_load_events.js]
 [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_runtime_connect_params.js]
 [test_ext_background_sub_windows.js]
 [test_ext_background_window_properties.js]
 skip-if = os == "android"
 [test_ext_contexts.js]
 [test_ext_downloads.js]
 [test_ext_downloads_download.js]
 skip-if = os == "android"