Bug 1287007 - Move extension.getViews to child r=billm
authorRob Wu <rob@robwu.nl>
Wed, 07 Sep 2016 22:54:07 -0700
changeset 428708 f86e5930ef497a5cdce73f04d3f16fa73871d144
parent 428707 1ed5b81ab606d9c1c9cf737b9d6ffbb50378799f
child 428709 9746d5da8a517c1e3d47d3a87f867c82ed1c576a
push id33405
push userbcampen@mozilla.com
push dateMon, 24 Oct 2016 15:32:53 +0000
reviewersbillm
bugs1287007
milestone52.0a1
Bug 1287007 - Move extension.getViews to child r=billm MozReview-Commit-ID: SG2pmulzaP
toolkit/components/extensions/ext-c-extension.js
toolkit/components/extensions/ext-extension.js
--- a/toolkit/components/extensions/ext-c-extension.js
+++ b/toolkit/components/extensions/ext-c-extension.js
@@ -18,8 +18,36 @@ function extensionApiFactory(context) {
         return PrivateBrowsingUtils.isContentWindowPrivate(context.contentWindow);
       },
     },
   };
 }
 
 extensions.registerSchemaAPI("extension", "addon_child", extensionApiFactory);
 extensions.registerSchemaAPI("extension", "content_child", extensionApiFactory);
+extensions.registerSchemaAPI("extension", "addon_child", context => {
+  return {
+    extension: {
+      getViews: function(fetchProperties) {
+        let result = Cu.cloneInto([], context.cloneScope);
+
+        for (let view of context.extension.views) {
+          if (!view.active) {
+            continue;
+          }
+          if (fetchProperties !== null) {
+            if (fetchProperties.type !== null && view.viewType != fetchProperties.type) {
+              continue;
+            }
+
+            if (fetchProperties.windowId !== null && view.windowId != fetchProperties.windowId) {
+              continue;
+            }
+          }
+
+          result.push(view.contentWindow);
+        }
+
+        return result;
+      },
+    },
+  };
+});
--- a/toolkit/components/extensions/ext-extension.js
+++ b/toolkit/components/extensions/ext-extension.js
@@ -1,39 +1,14 @@
 "use strict";
 
 extensions.registerSchemaAPI("extension", "addon_parent", context => {
-  let {extension} = context;
   return {
     extension: {
-      getViews: function(fetchProperties) {
-        let result = Cu.cloneInto([], context.cloneScope);
-
-        for (let view of extension.views) {
-          if (!view.active) {
-            continue;
-          }
-          if (fetchProperties !== null) {
-            if (fetchProperties.type !== null && view.viewType != fetchProperties.type) {
-              continue;
-            }
-
-            if (fetchProperties.windowId !== null && view.windowId != fetchProperties.windowId) {
-              continue;
-            }
-          }
-
-          result.push(view.contentWindow);
-        }
-
-        return result;
-      },
-
       get lastError() {
-        // TODO(robwu): See comment about lastError in ext-runtime.js
         return context.lastError;
       },
 
       isAllowedIncognitoAccess() {
         return Promise.resolve(true);
       },
 
       isAllowedFileSchemeAccess() {