Bug 1633750 - Only build the extension storage Rust-C++ glue if `MOZ_NEW_WEBEXT_STORAGE` is enabled. r=markh
authorLina Cambridge <lina@yakshaving.ninja>
Wed, 29 Apr 2020 04:41:31 +0000
changeset 526619 0c34140588047807745dcd10e7a505f8b14a223c
parent 526618 bfb47bf5fcbffb017a5d102f788099431f1444b2
child 526620 cfdd3c486d421c97a272fa497614f1657a3652d8
push id114394
push userkcambridge@mozilla.com
push dateWed, 29 Apr 2020 04:43:50 +0000
treeherderautoland@0c3414058804 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarkh
bugs1633750
milestone77.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 1633750 - Only build the extension storage Rust-C++ glue if `MOZ_NEW_WEBEXT_STORAGE` is enabled. r=markh Differential Revision: https://phabricator.services.mozilla.com/D72965
toolkit/components/extensions/storage/components.conf
toolkit/components/extensions/storage/moz.build
toolkit/components/extensions/test/xpcshell/test_StorageSyncService.js
toolkit/modules/AppConstants.jsm
--- a/toolkit/components/extensions/storage/components.conf
+++ b/toolkit/components/extensions/storage/components.conf
@@ -1,22 +1,24 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-Classes = [
-    {
-        'cid': '{f1e424f2-67fe-4f69-a8f8-3993a71f44fa}',
-        'contract_ids': ['@mozilla.org/extensions/storage/internal/sync-area;1'],
-        'type': 'mozIConfigurableExtensionStorageArea',
-        'headers': ['mozilla/extensions/storage/ExtensionStorageComponents.h'],
-        'constructor': 'mozilla::extensions::storage::NewSyncArea',
-    },
-    {
-        'cid': '{5b7047b4-fe17-4661-8e13-871402bc2023}',
-        'contract_ids': ['@mozilla.org/extensions/storage/sync;1'],
-        'jsm': 'resource://gre/modules/ExtensionStorageComponents.jsm',
-        'constructor': 'StorageSyncService',
-        'singleton': True,
-    },
-]
+Classes = []
+if defined('MOZ_NEW_WEBEXT_STORAGE'):
+    Classes += [
+        {
+            'cid': '{f1e424f2-67fe-4f69-a8f8-3993a71f44fa}',
+            'contract_ids': ['@mozilla.org/extensions/storage/internal/sync-area;1'],
+            'type': 'mozIConfigurableExtensionStorageArea',
+            'headers': ['mozilla/extensions/storage/ExtensionStorageComponents.h'],
+            'constructor': 'mozilla::extensions::storage::NewSyncArea',
+        },
+        {
+            'cid': '{5b7047b4-fe17-4661-8e13-871402bc2023}',
+            'contract_ids': ['@mozilla.org/extensions/storage/sync;1'],
+            'jsm': 'resource://gre/modules/ExtensionStorageComponents.jsm',
+            'constructor': 'StorageSyncService',
+            'singleton': True,
+        },
+    ]
--- a/toolkit/components/extensions/storage/moz.build
+++ b/toolkit/components/extensions/storage/moz.build
@@ -12,17 +12,17 @@ XPIDL_MODULE = 'webextensions-storage'
 XPIDL_SOURCES += [
     'mozIExtensionStorageArea.idl',
 ]
 
 # Don't build the Rust `storage.sync` bridge for GeckoView, as it will expose
 # a delegate for consumers to use instead. Android Components can then provide
 # an implementation of the delegate that's backed by the Rust component. For
 # details, please see bug 1626506, comment 4.
-if CONFIG['MOZ_WIDGET_TOOLKIT'] != "android":
+if CONFIG['MOZ_WIDGET_TOOLKIT'] != "android" and CONFIG['MOZ_NEW_WEBEXT_STORAGE']:
     EXPORTS.mozilla.extensions.storage += [
         'ExtensionStorageComponents.h',
     ]
 
     EXTRA_JS_MODULES += [
         'ExtensionStorageComponents.jsm',
     ]
 
--- a/toolkit/components/extensions/test/xpcshell/test_StorageSyncService.js
+++ b/toolkit/components/extensions/test/xpcshell/test_StorageSyncService.js
@@ -22,67 +22,72 @@ function promisify(func, ...params) {
       },
       handleError(code, message) {
         reject(Components.Exception(message, code));
       },
     });
   });
 }
 
-add_task(async function test_storage_sync_service() {
-  // So that we can write to the profile directory.
-  do_get_profile();
-
-  const service = Cc["@mozilla.org/extensions/storage/sync;1"]
-    .getService(Ci.nsIInterfaceRequestor)
-    .getInterface(Ci.mozIExtensionStorageArea);
+add_task(
   {
-    let { changes, value } = await promisify(
-      service.set,
-      "ext-1",
-      JSON.stringify({
-        hi: "hello! 馃挅",
-        bye: "adi贸s",
-      })
-    );
-    deepEqual(
-      changes,
-      [
+    skip_if: () => !AppConstants.MOZ_NEW_WEBEXT_STORAGE,
+  },
+  async function test_storage_sync_service() {
+    // So that we can write to the profile directory.
+    do_get_profile();
+
+    const service = Cc["@mozilla.org/extensions/storage/sync;1"]
+      .getService(Ci.nsIInterfaceRequestor)
+      .getInterface(Ci.mozIExtensionStorageArea);
+    {
+      let { changes, value } = await promisify(
+        service.set,
+        "ext-1",
+        JSON.stringify({
+          hi: "hello! 馃挅",
+          bye: "adi贸s",
+        })
+      );
+      deepEqual(
+        changes,
+        [
+          {
+            hi: {
+              newValue: JSON.stringify("hello! 馃挅"),
+            },
+            bye: {
+              newValue: JSON.stringify("adi贸s"),
+            },
+          },
+        ],
+        "`set` should notify listeners about changes"
+      );
+      ok(!value, "`set` should not return a value");
+    }
+
+    {
+      let { changes, value } = await promisify(
+        service.get,
+        "ext-1",
+        JSON.stringify(["hi"])
+      );
+      deepEqual(changes, [], "`get` should not notify listeners");
+      deepEqual(
+        value,
         {
-          hi: {
-            newValue: JSON.stringify("hello! 馃挅"),
-          },
-          bye: {
-            newValue: JSON.stringify("adi贸s"),
-          },
+          hi: "hello! 馃挅",
         },
-      ],
-      "`set` should notify listeners about changes"
-    );
-    ok(!value, "`set` should not return a value");
-  }
+        "`get` with key should return value"
+      );
 
-  {
-    let { changes, value } = await promisify(
-      service.get,
-      "ext-1",
-      JSON.stringify(["hi"])
-    );
-    deepEqual(changes, [], "`get` should not notify listeners");
-    deepEqual(
-      value,
-      {
-        hi: "hello! 馃挅",
-      },
-      "`get` with key should return value"
-    );
-
-    let { value: allValues } = await promisify(service.get, "ext-1", "null");
-    deepEqual(
-      allValues,
-      {
-        hi: "hello! 馃挅",
-        bye: "adi贸s",
-      },
-      "`get` without a key should return all values"
-    );
+      let { value: allValues } = await promisify(service.get, "ext-1", "null");
+      deepEqual(
+        allValues,
+        {
+          hi: "hello! 馃挅",
+          bye: "adi贸s",
+        },
+        "`get` without a key should return all values"
+      );
+    }
   }
-});
+);
--- a/toolkit/modules/AppConstants.jsm
+++ b/toolkit/modules/AppConstants.jsm
@@ -399,9 +399,16 @@ this.AppConstants = Object.freeze({
 #endif
 
   ENABLE_REMOTE_AGENT:
 #ifdef ENABLE_REMOTE_AGENT
     true,
 #else
     false,
 #endif
+
+  MOZ_NEW_WEBEXT_STORAGE:
+#ifdef MOZ_NEW_WEBEXT_STORAGE
+    true,
+#else
+    false,
+#endif
 });