Bug 1081990 - Fix up BrowserElement API to use function forwarders rather than direct chrome function references. r=gabor
authorBobby Holley <bobbyholley@gmail.com>
Sat, 18 Oct 2014 11:02:09 +0200
changeset 211107 6fe41be8cfb0257837691750543d76bc339d1467
parent 211106 fc25ace509cf79df817f852593e4e56837712396
child 211108 5d6eec6916363291eedb1bb36d836662620d8c80
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersgabor
bugs1081990
milestone36.0a1
Bug 1081990 - Fix up BrowserElement API to use function forwarders rather than direct chrome function references. r=gabor
dom/browser-element/BrowserElementParent.jsm
--- a/dom/browser-element/BrowserElementParent.jsm
+++ b/dom/browser-element/BrowserElementParent.jsm
@@ -83,42 +83,42 @@ function BrowserElementParent(frameLoade
     return;
   }
 
   Services.obs.addObserver(this, 'ask-children-to-exit-fullscreen', /* ownsWeak = */ true);
   Services.obs.addObserver(this, 'oop-frameloader-crashed', /* ownsWeak = */ true);
   Services.obs.addObserver(this, 'copypaste-docommand', /* ownsWeak = */ true);
 
   let defineMethod = function(name, fn) {
-    XPCNativeWrapper.unwrap(self._frameElement)[name] = function() {
+    XPCNativeWrapper.unwrap(self._frameElement)[name] = Cu.exportFunction(function() {
       if (self._isAlive()) {
         return fn.apply(self, arguments);
       }
-    };
+    }, self._frameElement);
   }
 
   let defineNoReturnMethod = function(name, fn) {
-    XPCNativeWrapper.unwrap(self._frameElement)[name] = function method() {
+    XPCNativeWrapper.unwrap(self._frameElement)[name] = Cu.exportFunction(function method() {
       if (!self._domRequestReady) {
         // Remote browser haven't been created, we just queue the API call.
         let args = Array.slice(arguments);
         args.unshift(self);
         self._pendingAPICalls.push(method.bind.apply(fn, args));
         return;
       }
       if (self._isAlive()) {
         fn.apply(self, arguments);
       }
-    };
+    }, self._frameElement);
   };
 
   let defineDOMRequestMethod = function(domName, msgName) {
-    XPCNativeWrapper.unwrap(self._frameElement)[domName] = function() {
+    XPCNativeWrapper.unwrap(self._frameElement)[domName] = Cu.exportFunction(function() {
       return self._sendDOMRequest(msgName);
-    };
+    }, self._frameElement);
   }
 
   // Define methods on the frame element.
   defineNoReturnMethod('setVisible', this._setVisible);
   defineDOMRequestMethod('getVisible', 'get-visible');
 
   // Not expose security sensitive browser API for widgets
   if (!this._frameLoader.QueryInterface(Ci.nsIFrameLoader).ownerIsWidget) {