Bug 1342142 Part 2 Enable webextension permission prompts draft
authorAndrew Swan <aswan@mozilla.com>
Fri, 10 Mar 2017 16:05:26 -0800
changeset 503098 e0f264ff26414b3a7dc1c1e627e6d33024ee01e4
parent 503097 2d4174fdd33bdea3d9e7eb5add2ee8ea3ae08714
child 550350 1888276f3280e5009ab220dd094fd046b16eeb4b
push id50496
push useraswan@mozilla.com
push dateWed, 22 Mar 2017 20:54:18 +0000
bugs1342142
milestone55.0a1
Bug 1342142 Part 2 Enable webextension permission prompts MozReview-Commit-ID: 5p4lvWXn9Hh
browser/app/profile/firefox.js
browser/base/content/test/general/browser_bug553455.js
browser/base/content/test/webextensions/browser_extension_sideloading.js
browser/base/content/test/webextensions/browser_extension_update_background.js
browser/base/content/test/webextensions/browser_permissions_unsigned.js
browser/base/content/test/webextensions/browser_update_interactive.js
browser/base/content/test/webextensions/browser_update_interactive_noprompt.js
browser/base/content/test/webextensions/head.js
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -33,16 +33,17 @@ pref("extensions.strictCompatibility", f
 // Specifies a minimum maxVersion an addon needs to say it's compatible with
 // for it to be compatible by default.
 pref("extensions.minCompatibleAppVersion", "4.0");
 // Temporary preference to forcibly make themes more safe with Australis even if
 // extensions.checkCompatibility=false has been set.
 pref("extensions.checkCompatibility.temporaryThemeOverride_minAppVersion", "29.0a1");
 
 pref("xpinstall.customConfirmationUI", true);
+pref("extensions.webextPermissionPrompts", true);
 
 // Preferences for AMO integration
 pref("extensions.getAddons.cache.enabled", true);
 pref("extensions.getAddons.maxResults", 15);
 pref("extensions.getAddons.get.url", "https://services.addons.mozilla.org/%LOCALE%/firefox/api/%API_VERSION%/search/guid:%IDS%?src=firefox&appOS=%OS%&appVersion=%VERSION%");
 pref("extensions.getAddons.getWithPerformance.url", "https://services.addons.mozilla.org/%LOCALE%/firefox/api/%API_VERSION%/search/guid:%IDS%?src=firefox&appOS=%OS%&appVersion=%VERSION%&tMain=%TIME_MAIN%&tFirstPaint=%TIME_FIRST_PAINT%&tSessionRestored=%TIME_SESSION_RESTORED%");
 pref("extensions.getAddons.search.browseURL", "https://addons.mozilla.org/%LOCALE%/firefox/search?q=%TERMS%&platform=%OS%&appver=%VERSION%");
 pref("extensions.getAddons.search.url", "https://services.addons.mozilla.org/%LOCALE%/firefox/api/%API_VERSION%/search/%TERMS%/all/%MAX_RESULTS%/%OS%/%VERSION%/%COMPATIBILITY_MODE%?src=firefox");
--- a/browser/base/content/test/general/browser_bug553455.js
+++ b/browser/base/content/test/general/browser_bug553455.js
@@ -29,16 +29,18 @@ var gVersion = Services.appinfo.version;
 function getObserverTopic(aNotificationId) {
   let topic = aNotificationId;
   if (topic == "xpinstall-disabled")
     topic = "addon-install-disabled";
   else if (topic == "addon-progress")
     topic = "addon-install-started";
   else if (topic == "addon-install-restart")
     topic = "addon-install-complete";
+  else if (topic == "addon-installed")
+    topic = "webextension-install-notify";
   return topic;
 }
 
 function waitForProgressNotification(aPanelOpen = false, aExpectedCount = 1) {
   return Task.spawn(function* () {
     let notificationId = PROGRESS_NOTIFICATION;
     info("Waiting for " + notificationId + " notification");
 
@@ -436,24 +438,19 @@ function test_restartless() {
     let triggers = encodeURIComponent(JSON.stringify({
       "XPI": "restartless.xpi"
     }));
     gBrowser.selectedTab = gBrowser.addTab();
     gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
     yield progressPromise;
     let installDialog = yield dialogPromise;
 
-    let notificationPromise = waitForNotification("addon-install-complete");
+    let notificationPromise = waitForNotification("addon-installed");
     acceptInstallDialog(installDialog);
-    let panel = yield notificationPromise;
-
-    let notification = panel.childNodes[0];
-    is(notification.getAttribute("label"),
-       "XPI Test has been installed successfully.",
-       "Should have seen the right message");
+    yield notificationPromise;
 
     let installs = yield getInstalls();
     is(installs.length, 0, "Should be no pending installs");
 
     let addon = yield new Promise(resolve => {
       AddonManager.getAddonByID("restartless-xpi@tests.mozilla.org", result => {
         resolve(result);
       });
@@ -569,17 +566,17 @@ function test_allUnverified() {
     let message = notification.getAttribute("label");
     is(message, "Caution: This site would like to install an unverified add-on in " + gApp + ". Proceed at your own risk.");
 
     let container = document.getElementById("addon-install-confirmation-content");
     is(container.childNodes.length, 1, "Should be one item listed");
     is(container.childNodes[0].firstChild.getAttribute("value"), "XPI Test", "Should have the right add-on");
     is(container.childNodes[0].childNodes.length, 1, "Shouldn't have the unverified marker");
 
-    let notificationPromise = waitForNotification("addon-install-complete");
+    let notificationPromise = waitForNotification("addon-installed");
     acceptInstallDialog(installDialog);
     yield notificationPromise;
 
     let addon = yield new Promise(resolve => {
       AddonManager.getAddonByID("restartless-xpi@tests.mozilla.org", function(result) {
         resolve(result);
       });
     });
@@ -1019,17 +1016,17 @@ function test_failedSecurity() {
   });
 }
 ];
 
 var gTestStart = null;
 
 var XPInstallObserver = {
   observe(aSubject, aTopic, aData) {
-    var installInfo = aSubject.QueryInterface(Components.interfaces.amIWebInstallInfo);
+    var installInfo = aSubject.wrappedJSObject;
     info("Observed " + aTopic + " for " + installInfo.installs.length + " installs");
     installInfo.installs.forEach(function(aInstall) {
       info("Install of " + aInstall.sourceURI.spec + " was in state " + aInstall.state);
     });
   }
 };
 
 add_task(function* () {
@@ -1038,17 +1035,16 @@ add_task(function* () {
   Services.prefs.setBoolPref("extensions.logging.enabled", true);
   Services.prefs.setBoolPref("extensions.strictCompatibility", true);
   Services.prefs.setBoolPref("extensions.install.requireSecureOrigin", false);
   Services.prefs.setIntPref("security.dialog_enable_delay", 0);
 
   Services.obs.addObserver(XPInstallObserver, "addon-install-started", false);
   Services.obs.addObserver(XPInstallObserver, "addon-install-blocked", false);
   Services.obs.addObserver(XPInstallObserver, "addon-install-failed", false);
-  Services.obs.addObserver(XPInstallObserver, "addon-install-complete", false);
 
   registerCleanupFunction(function() {
     // Make sure no more test parts run in case we were timed out
     TESTS = [];
 
     AddonManager.getAllInstalls(function(aInstalls) {
       aInstalls.forEach(function(aInstall) {
         aInstall.cancel();
@@ -1058,17 +1054,16 @@ add_task(function* () {
     Services.prefs.clearUserPref("extensions.logging.enabled");
     Services.prefs.clearUserPref("extensions.strictCompatibility");
     Services.prefs.clearUserPref("extensions.install.requireSecureOrigin");
     Services.prefs.clearUserPref("security.dialog_enable_delay");
 
     Services.obs.removeObserver(XPInstallObserver, "addon-install-started");
     Services.obs.removeObserver(XPInstallObserver, "addon-install-blocked");
     Services.obs.removeObserver(XPInstallObserver, "addon-install-failed");
-    Services.obs.removeObserver(XPInstallObserver, "addon-install-complete");
   });
 
   for (let i = 0; i < TESTS.length; ++i) {
     if (gTestStart)
       info("Test part took " + (Date.now() - gTestStart) + "ms");
 
     ok(!PopupNotifications.isPanelOpen, "Notification should be closed");
 
--- a/browser/base/content/test/webextensions/browser_extension_sideloading.js
+++ b/browser/base/content/test/webextensions/browser_extension_sideloading.js
@@ -76,21 +76,16 @@ function promiseSetDisabled(addon) {
   return new Promise(resolve => {
     setCallbacks.set(addon, resolve);
   });
 }
 
 let cleanup;
 
 add_task(function* () {
-  // XXX remove this when prompts are enabled by default
-  yield SpecialPowers.pushPrefEnv({set: [
-    ["extensions.webextPermissionPrompts", true],
-  ]});
-
   // ICON_URL wouldn't ever appear as an actual webextension icon, but
   // we're just mocking out the addon here, so all we care about is that
   // that it propagates correctly to the popup.
   const ICON_URL = "chrome://mozapps/skin/extensions/category-extensions.svg";
   const DEFAULT_ICON_URL = "chrome://mozapps/skin/extensions/extensionGeneric.svg";
 
   const ID1 = "addon1@tests.mozilla.org";
   let mock1 = new MockAddon({
--- a/browser/base/content/test/webextensions/browser_extension_update_background.js
+++ b/browser/base/content/test/webextensions/browser_extension_update_background.js
@@ -30,19 +30,16 @@ function getBadgeStatus() {
 }
 
 // Set some prefs that apply to all the tests in this file
 add_task(function* setup() {
   yield SpecialPowers.pushPrefEnv({set: [
     // We don't have pre-pinned certificates for the local mochitest server
     ["extensions.install.requireBuiltInCerts", false],
     ["extensions.update.requireBuiltInCerts", false],
-
-    // XXX remove this when prompts are enabled by default
-    ["extensions.webextPermissionPrompts", true],
   ]});
 
   // Navigate away from the initial page so that about:addons always
   // opens in a new tab during tests
   gBrowser.selectedBrowser.loadURI("about:robots");
   yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
 
   registerCleanupFunction(function*() {
--- a/browser/base/content/test/webextensions/browser_permissions_unsigned.js
+++ b/browser/base/content/test/webextensions/browser_permissions_unsigned.js
@@ -2,19 +2,16 @@
 
 const ID = "permissions@test.mozilla.org";
 const WARNING_ICON = "chrome://browser/skin/warning.svg";
 
 add_task(async function test_unsigned() {
   await SpecialPowers.pushPrefEnv({set: [
     ["extensions.webapi.testing", true],
     ["extensions.install.requireBuiltInCerts", false],
-
-    // XXX remove this when prompts are enabled by default
-    ["extensions.webextPermissionPrompts", true],
   ]});
 
   let testURI = makeURI("https://example.com/");
   Services.perms.add(testURI, "install", Services.perms.ALLOW_ACTION);
   registerCleanupFunction(() => Services.perms.remove(testURI, "install"));
 
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
 
--- a/browser/base/content/test/webextensions/browser_update_interactive.js
+++ b/browser/base/content/test/webextensions/browser_update_interactive.js
@@ -3,19 +3,16 @@ const {AddonManagerPrivate} = Cu.import(
 const ID = "update2@tests.mozilla.org";
 
 // Set some prefs that apply to all the tests in this file
 add_task(function* setup() {
   yield SpecialPowers.pushPrefEnv({set: [
     // We don't have pre-pinned certificates for the local mochitest server
     ["extensions.install.requireBuiltInCerts", false],
     ["extensions.update.requireBuiltInCerts", false],
-
-    // XXX remove this when prompts are enabled by default
-    ["extensions.webextPermissionPrompts", true],
   ]});
 });
 
 // Helper function to test a specific scenario for interactive updates.
 // `checkFn` is a callable that triggers a check for updates.
 // `autoUpdate` specifies whether the test should be run with
 // updates applied automatically or not.
 function* interactiveUpdateTest(autoUpdate, checkFn) {
--- a/browser/base/content/test/webextensions/browser_update_interactive_noprompt.js
+++ b/browser/base/content/test/webextensions/browser_update_interactive_noprompt.js
@@ -3,19 +3,16 @@
 add_task(function* setup() {
   yield SpecialPowers.pushPrefEnv({set: [
     // We don't have pre-pinned certificates for the local mochitest server
     ["extensions.install.requireBuiltInCerts", false],
     ["extensions.update.requireBuiltInCerts", false],
 
     // Point updates to the local mochitest server
     ["extensions.update.url", `${BASE}/browser_webext_update.json`],
-
-    // XXX remove this when prompts are enabled by default
-    ["extensions.webextPermissionPrompts", true],
   ]});
 });
 
 // Helper to test that an update of a given extension does not
 // generate any permission prompts.
 async function testUpdateNoPrompt(filename, id,
                                   initialVersion = "1.0", updateVersion = "2.0") {
   // Navigate away to ensure that BrowserOpenAddonMgr() opens a new tab
--- a/browser/base/content/test/webextensions/head.js
+++ b/browser/base/content/test/webextensions/head.js
@@ -212,19 +212,16 @@ function checkNotification(panel, checkI
 async function testInstallMethod(installFn, telemetryBase) {
   const PERMS_XPI = "browser_webext_permissions.xpi";
   const NO_PERMS_XPI = "browser_webext_nopermissions.xpi";
   const ID = "permissions@test.mozilla.org";
 
   await SpecialPowers.pushPrefEnv({set: [
     ["extensions.webapi.testing", true],
     ["extensions.install.requireBuiltInCerts", false],
-
-    // XXX remove this when prompts are enabled by default
-    ["extensions.webextPermissionPrompts", true],
   ]});
 
   if (telemetryBase !== undefined) {
     hookExtensionsTelemetry();
   }
 
   let testURI = makeURI("https://example.com/");
   Services.perms.add(testURI, "install", Services.perms.ALLOW_ACTION);