Bug 1451079 - Adding fix for setting empty url to set uninstall url during runtime. r=zombie
☠☠ backed out by c6ecca7fc988 ☠ ☠
authorsagarwala <shailja.agarwala21@gmail.com>
Thu, 28 Feb 2019 02:15:12 +0000
changeset 519465 56d817208b35b3b1c16833b3dcd7ad80a7297371
parent 519464 1d1443507be4aedaa6a868acf08e5086d607a9e0
child 519466 4d9ae84e669496a00d0d26b5f40ad9b9a9dd077d
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerszombie
bugs1451079
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1451079 - Adding fix for setting empty url to set uninstall url during runtime. r=zombie The bug indicated that the setUninstallURL did not honor empty url during runtime. Steps to reproduce: 1. Install an extension, uninstall URL is set 2. Update the extension, changing the uninstall URL string to null (empty) 3. Uninstall the extension Differential Revision: https://phabricator.services.mozilla.com/D18499
browser/components/extensions/test/browser/browser_ext_runtime_setUninstallURL.js
toolkit/components/extensions/parent/ext-runtime.js
--- a/browser/components/extensions/test/browser/browser_ext_runtime_setUninstallURL.js
+++ b/browser/components/extensions/test/browser/browser_ext_runtime_setUninstallURL.js
@@ -67,16 +67,37 @@ add_task(async function test_setuninstal
 
   addon.uninstall(true);
   info("uninstalled");
 
   // no need to explicitly check for the absence of a new tab,
   // BrowserTestUtils will eventually complain if one is opened.
 });
 
+// Test the documented behavior of setUninstallURL() that passing an
+// empty string is equivalent to not setting an uninstall URL
+// (i.e., no new tab is opened upon uninstall)
+// here we pass a null value to string and test
+add_task(async function test_setuninstall_null_url() {
+  async function backgroundScript() {
+    await browser.runtime.setUninstallURL(null);
+    browser.tabs.create({url: "http://example.com/addon_loaded"});
+  }
+
+  let addon = await makeAndInstallXPI("test_uinstallurl2@tests.mozilla.org",
+                                      backgroundScript,
+                                      "http://example.com/addon_loaded");
+
+  addon.uninstall(true);
+  info("uninstalled");
+
+  // no need to explicitly check for the absence of a new tab,
+  // BrowserTestUtils will eventually complain if one is opened.
+});
+
 add_task(async function test_setuninstallurl() {
   async function backgroundScript() {
     await browser.runtime.setUninstallURL("http://example.com/addon_uninstalled");
     browser.tabs.create({url: "http://example.com/addon_loaded"});
   }
 
   let addon = await makeAndInstallXPI("test_uinstallurl@tests.mozilla.org",
                                       backgroundScript,
--- a/toolkit/components/extensions/parent/ext-runtime.js
+++ b/toolkit/components/extensions/parent/ext-runtime.js
@@ -129,17 +129,18 @@ this.runtime = class extends ExtensionAP
 
           // This expects openOptionsPage to be defined in the file using this,
           // e.g. the browser/ version of ext-runtime.js
           /* global openOptionsPage:false */
           return openOptionsPage(extension).then(() => {});
         },
 
         setUninstallURL: function(url) {
-          if (url.length == 0) {
+          if (url === null || url.length === 0) {
+            extension.uninstallURL = null;
             return Promise.resolve();
           }
 
           let uri;
           try {
             uri = new URL(url);
           } catch (e) {
             return Promise.reject({message: `Invalid URL: ${JSON.stringify(url)}`});