Bug 1330349 - Part 4 - make sure theme type WebExtension support is covered by the existing test suite. r=mossop
☠☠ backed out by e4892021456d ☠ ☠
authorMike de Boer <mdeboer@mozilla.com>
Wed, 01 Mar 2017 22:40:04 +0100
changeset 394452 b55dd917881523cace3c6ccf7152d8540806436d
parent 394451 3e2083974a135cbdf5716222ebd61c382d84cd8b
child 394453 3a149a84ce479c5afb8c4e9b965fc1facd86a612
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1330349
milestone54.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 1330349 - Part 4 - make sure theme type WebExtension support is covered by the existing test suite. r=mossop MozReview-Commit-ID: JCbBZObWDQZ
toolkit/mozapps/extensions/test/xpcshell/test_temporary.js
toolkit/mozapps/extensions/test/xpcshell/test_webextension.js
toolkit/mozapps/extensions/test/xpcshell/test_webextension_icons.js
--- a/toolkit/mozapps/extensions/test/xpcshell/test_temporary.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_temporary.js
@@ -302,18 +302,50 @@ add_task(function*() {
     // temporary add-on is installed and started
     do_check_neq(addon, null);
     do_check_eq(addon.version, "5.0");
     do_check_eq(addon.name, "Test WebExtension 1 (temporary)");
     do_check_true(addon.isCompatible);
     do_check_false(addon.appDisabled);
     do_check_true(addon.isActive);
     do_check_eq(addon.type, "extension");
+    do_check_true(addon.isWebExtension);
     do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
 
+    // test reloading a webextension with the same name, but a different type.
+    webext.remove(false);
+    webext = createTempWebExtensionFile({
+      manifest: {
+        version: "6.0",
+        name: "Test WebExtension 1 (temporary)",
+        applications: {
+          gecko: {
+            id: ID
+          }
+        },
+        theme: { images: { headerURL: "https://example.com/example.png" } }
+      }
+    });
+
+    yield Promise.all([
+      AddonManager.installTemporaryAddon(webext),
+      promiseAddonStartup(),
+    ]);
+    addon = yield promiseAddonByID(ID);
+
+    do_check_neq(addon, null);
+    do_check_eq(addon.version, "6.0");
+    do_check_eq(addon.name, "Test WebExtension 1 (temporary)");
+    do_check_true(addon.isCompatible);
+    do_check_false(addon.appDisabled);
+    do_check_true(addon.isActive);
+    // This is what we're really interested in:
+    do_check_eq(addon.type, "theme");
+    do_check_true(addon.isWebExtension);
+
     restartManager();
 
     BootstrapMonitor.checkAddonInstalled(ID, "1.0");
     BootstrapMonitor.checkAddonStarted(ID, "1.0");
 
     addon = yield promiseAddonByID(ID);
 
     // existing add-on is back
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension.js
@@ -25,18 +25,21 @@ function promiseAddonStartup() {
 
     Management.on("ready", listener);
   });
 }
 
 function promiseInstallWebExtension(aData) {
   let addonFile = createTempWebExtensionFile(aData);
 
-  return promiseInstallAllFiles([addonFile]).then(() => {
+  return promiseInstallAllFiles([addonFile]).then(installs => {
     Services.obs.notifyObservers(addonFile, "flush-cache-entry", null);
+    // Since themes are disabled by default, it won't start up.
+    if ("theme" in aData.manifest)
+      return installs[0].addon;
     return promiseAddonStartup();
   });
 }
 
 add_task(function*() {
   equal(GlobalManager.extensionMap.size, 0);
 
   yield Promise.all([
@@ -413,8 +416,53 @@ add_task(function* authorNotString() {
       }
     });
 
     addon = yield promiseAddonByID(addon.id);
     equal(addon.creator, null);
     addon.uninstall();
   }
 });
+
+add_task(function* testThemeExtension() {
+  let addon = yield promiseInstallWebExtension({
+    manifest: {
+      "author": "Some author",
+      manifest_version: 2,
+      name: "Web Extension Name",
+      version: "1.0",
+      theme: { images: { headerURL: "https://example.com/example.png" } },
+    }
+  });
+
+  addon = yield promiseAddonByID(addon.id);
+  do_check_neq(addon, null);
+  do_check_eq(addon.creator, "Some author");
+  do_check_eq(addon.version, "1.0");
+  do_check_eq(addon.name, "Web Extension Name");
+  do_check_true(addon.isCompatible);
+  do_check_false(addon.appDisabled);
+  do_check_false(addon.isActive);
+  do_check_true(addon.userDisabled);
+  do_check_false(addon.isSystem);
+  do_check_eq(addon.type, "theme");
+  do_check_true(addon.isWebExtension);
+  do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
+
+  addon.uninstall();
+
+  // Also test one without a proper 'theme' section.
+  addon = yield promiseInstallWebExtension({
+    manifest: {
+      "author": "Some author",
+      manifest_version: 2,
+      name: "Web Extension Name",
+      version: "1.0",
+      theme: null,
+    }
+  });
+
+  addon = yield promiseAddonByID(addon.id);
+  do_check_eq(addon.type, "extension");
+  do_check_true(addon.isWebExtension);
+
+  addon.uninstall();
+});
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_icons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_icons.js
@@ -19,37 +19,22 @@ function promiseAddonStartup() {
       Management.off("startup", listener);
       resolve(extension);
     };
 
     Management.on("startup", listener);
   });
 }
 
-// Test simple icon set parsing
-add_task(function*() {
-  yield promiseWriteWebManifestForExtension({
-    name: "Web Extension Name",
-    version: "1.0",
-    manifest_version: 2,
-    applications: {
-      gecko: {
-        id: ID
-      }
-    },
-    icons: {
-      16: "icon16.png",
-      32: "icon32.png",
-      48: "icon48.png",
-      64: "icon64.png"
-    }
-  }, profileDir);
+function* testSimpleIconsetParsing(manifest) {
+  yield promiseWriteWebManifestForExtension(manifest, profileDir);
 
   yield promiseRestartManager();
-  yield promiseAddonStartup();
+  if (!manifest.theme)
+    yield promiseAddonStartup();
 
   let uri = do_get_addon_root_uri(profileDir, ID);
 
   let addon = yield promiseAddonByID(ID);
   do_check_neq(addon, null);
 
   function check_icons(addon_copy) {
     deepEqual(addon_copy.icons, {
@@ -71,50 +56,35 @@ add_task(function*() {
     equal(AddonManager.getPreferredIconURL(addon, 64), uri + "icon64.png");
     equal(AddonManager.getPreferredIconURL(addon, 128), uri + "icon64.png");
   }
 
   check_icons(addon);
 
   // check if icons are persisted through a restart
   yield promiseRestartManager();
-  yield promiseAddonStartup();
+  if (!manifest.theme)
+    yield promiseAddonStartup();
 
   addon = yield promiseAddonByID(ID);
   do_check_neq(addon, null);
 
   check_icons(addon);
 
   addon.uninstall();
 
   yield promiseRestartManager();
-});
+}
 
-// Test AddonManager.getPreferredIconURL for retina screen sizes
-add_task(function*() {
-  yield promiseWriteWebManifestForExtension({
-    name: "Web Extension Name",
-    version: "1.0",
-    manifest_version: 2,
-    applications: {
-      gecko: {
-        id: ID
-      }
-    },
-    icons: {
-      32: "icon32.png",
-      48: "icon48.png",
-      64: "icon64.png",
-      128: "icon128.png",
-      256: "icon256.png"
-    }
-  }, profileDir);
+function* testRetinaIconsetParsing(manifest) {
+  yield promiseWriteWebManifestForExtension(manifest, profileDir);
 
   yield promiseRestartManager();
-  yield promiseAddonStartup();
+  if (!manifest.theme)
+    yield promiseAddonStartup();
 
   let addon = yield promiseAddonByID(ID);
   do_check_neq(addon, null);
 
   let uri = do_get_addon_root_uri(profileDir, ID);
 
   // AddonManager displays larger icons for higher pixel density
   equal(AddonManager.getPreferredIconURL(addon, 32, {
@@ -127,40 +97,136 @@ add_task(function*() {
 
   equal(AddonManager.getPreferredIconURL(addon, 64, {
     devicePixelRatio: 2
   }), uri + "icon128.png");
 
   addon.uninstall();
 
   yield promiseRestartManager();
-});
+}
 
-// Handles no icons gracefully
-add_task(function*() {
-  yield promiseWriteWebManifestForExtension({
-    name: "Web Extension Name",
-    version: "1.0",
-    manifest_version: 2,
-    applications: {
-      gecko: {
-        id: ID
-      }
-    }
-  }, profileDir);
+function* testNoIconsParsing(manifest) {
+  yield promiseWriteWebManifestForExtension(manifest, profileDir);
 
   yield promiseRestartManager();
-  yield promiseAddonStartup();
+  if (!manifest.theme)
+    yield promiseAddonStartup();
 
   let addon = yield promiseAddonByID(ID);
   do_check_neq(addon, null);
 
   deepEqual(addon.icons, {});
 
   equal(addon.iconURL, null);
   equal(addon.icon64URL, null);
 
   equal(AddonManager.getPreferredIconURL(addon, 128), null);
 
   addon.uninstall();
 
   yield promiseRestartManager();
+}
+
+// Test simple icon set parsing
+add_task(function*() {
+  yield* testSimpleIconsetParsing({
+    name: "Web Extension Name",
+    version: "1.0",
+    manifest_version: 2,
+    applications: {
+      gecko: {
+        id: ID
+      }
+    },
+    icons: {
+      16: "icon16.png",
+      32: "icon32.png",
+      48: "icon48.png",
+      64: "icon64.png"
+    }
+  });
+
+  // Now for theme-type extensions too.
+  yield* testSimpleIconsetParsing({
+    name: "Web Extension Name",
+    version: "1.0",
+    manifest_version: 2,
+    applications: {
+      gecko: {
+        id: ID
+      }
+    },
+    icons: {
+      16: "icon16.png",
+      32: "icon32.png",
+      48: "icon48.png",
+      64: "icon64.png"
+    },
+    theme: { images: { headerURL: "https://example.com/example.png" } }
+  });
 });
+
+// Test AddonManager.getPreferredIconURL for retina screen sizes
+add_task(function*() {
+  yield* testRetinaIconsetParsing({
+    name: "Web Extension Name",
+    version: "1.0",
+    manifest_version: 2,
+    applications: {
+      gecko: {
+        id: ID
+      }
+    },
+    icons: {
+      32: "icon32.png",
+      48: "icon48.png",
+      64: "icon64.png",
+      128: "icon128.png",
+      256: "icon256.png"
+    }
+  });
+
+  yield* testRetinaIconsetParsing({
+    name: "Web Extension Name",
+    version: "1.0",
+    manifest_version: 2,
+    applications: {
+      gecko: {
+        id: ID
+      }
+    },
+    icons: {
+      32: "icon32.png",
+      48: "icon48.png",
+      64: "icon64.png",
+      128: "icon128.png",
+      256: "icon256.png"
+    },
+    theme: { images: { headerURL: "https://example.com/example.png" } }
+  });
+});
+
+// Handles no icons gracefully
+add_task(function*() {
+  yield* testNoIconsParsing({
+    name: "Web Extension Name",
+    version: "1.0",
+    manifest_version: 2,
+    applications: {
+      gecko: {
+        id: ID
+      }
+    }
+  });
+
+  yield* testNoIconsParsing({
+    name: "Web Extension Name",
+    version: "1.0",
+    manifest_version: 2,
+    applications: {
+      gecko: {
+        id: ID
+      }
+    },
+    theme: { images: { headerURL: "https://example.com/example.png" } }
+  });
+});