Bug 1602126 - Add monochrome purpose, r=marcosc
authorTiger Oakes <contact@tigeroakes.com>
Mon, 06 Jul 2020 04:50:19 +0000
changeset 538874 778968ba4e038fe88c35c08dfd773a262ef7bd3c
parent 538873 e614d160ab92e8ea455f2a38a9925468d7547252
child 538875 f0df8a535c5255ada27503cbde30620d22f9bfd3
push id120785
push usermcaceres@mozilla.com
push dateMon, 06 Jul 2020 04:54:14 +0000
treeherderautoland@778968ba4e03 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarcosc
bugs1602126
milestone80.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 1602126 - Add monochrome purpose, r=marcosc Differential Revision: https://phabricator.services.mozilla.com/D82265
dom/manifest/ImageObjectProcessor.jsm
dom/manifest/test/test_ImageObjectProcessor_purpose.html
--- a/dom/manifest/ImageObjectProcessor.jsm
+++ b/dom/manifest/ImageObjectProcessor.jsm
@@ -29,17 +29,17 @@ const { Services } = ChromeUtils.import(
 XPCOMUtils.defineLazyGlobalGetters(this, ["URL"]);
 
 function ImageObjectProcessor(aErrors, aExtractor, aBundle) {
   this.errors = aErrors;
   this.extractor = aExtractor;
   this.domBundle = aBundle;
 }
 
-const iconPurposes = Object.freeze(["any", "maskable"]);
+const iconPurposes = Object.freeze(["any", "maskable", "monochrome"]);
 
 // Static getters
 Object.defineProperties(ImageObjectProcessor, {
   decimals: {
     get() {
       return /^\d+$/;
     },
   },
--- a/dom/manifest/test/test_ImageObjectProcessor_purpose.html
+++ b/dom/manifest/test/test_ImageObjectProcessor_purpose.html
@@ -48,36 +48,56 @@ https://bugzilla.mozilla.org/show_bug.cg
     invalidPurposes.forEach(invalidPurpose => {
       const expected = `Expect invalid purposes to invalidate the icon.`;
       testManifest.icons[0].purpose = invalidPurpose;
       data.jsonText = JSON.stringify(testManifest);
       const result = processor.process(data);
       is(result.icons.length, 0, expected);
     });
 
-    const mixedValidAndInvalidPurposes = [
+    const mixedMaskableAndInvalidPurposes = [
       "not-known-test-purpose maskable",
       "maskable invalid-purpose invalid-purpose",
       "no-purpose invalid-purpose maskable some-other-non-valid-purpose",
     ];
 
-    mixedValidAndInvalidPurposes.forEach(mixedPurpose => {
+    mixedMaskableAndInvalidPurposes.forEach(mixedPurpose => {
       const expected = `Expect on 'maskable' to remain.`;
       testManifest.icons[0].purpose = mixedPurpose;
       data.jsonText = JSON.stringify(testManifest);
       const result = processor.process(data);
       is(result.icons.length, 1, expected);
       is(result.icons[0].purpose.join(), "maskable", expected);
     });
 
+    const mixedMonochromeAndInvalidPurposes = [
+      "not-known-test-purpose monochrome",
+      "monochrome invalid-purpose invalid-purpose",
+      "no-purpose invalid-purpose monochrome some-other-non-valid-purpose",
+    ];
+
+    mixedMonochromeAndInvalidPurposes.forEach(mixedPurpose => {
+      const expected = `Expect on 'monochrome' to remain.`;
+      testManifest.icons[0].purpose = mixedPurpose;
+      data.jsonText = JSON.stringify(testManifest);
+      const result = processor.process(data);
+      is(result.icons.length, 1, expected);
+      is(result.icons[0].purpose.join(), "monochrome", expected);
+    });
+
     const validPurposes = [
       "maskable",
+      "monochrome",
       "any",
       "any maskable",
       "maskable any",
+      "any monochrome",
+      "monochrome any",
+      "maskable monochrome any",
+      "monochrome maskable"
     ];
 
     validPurposes.forEach(purpose => {
       testManifest.icons[0].purpose = purpose;
       data.jsonText = JSON.stringify(testManifest);
       var manifest = processor.process(data);
       is(manifest.icons[0].purpose.join(" "), purpose, `Expected "${purpose}" as purpose.`);
     });