Bug 1065185 - Fix devtools actors. r=bz
authorBobby Holley <bobbyholley@gmail.com>
Fri, 03 Oct 2014 10:05:50 +0200
changeset 208539 5f82762afba953e866884feb0cdc2e6d8bad57e0
parent 208538 7fe212396640d6efbf8af7a2a0785f075d112964
child 208540 c244a7df8cfe82c109e4c4d65267191468ef997e
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbz
bugs1065185
milestone35.0a1
Bug 1065185 - Fix devtools actors. r=bz See browser/devtools/canvasdebugger/test/browser_canvas-actor-test-02.js. And note that we need to re-waive the result, otherwise we get failures in browser/devtools/canvasdebugger/test/browser_canvas-actor-test-10.js. See browser/devtools/shadereditor/test/browser_se_editors-contents.js for the webgls stuff.
toolkit/devtools/server/actors/call-watcher.js
toolkit/devtools/server/actors/webgl.js
--- a/toolkit/devtools/server/actors/call-watcher.js
+++ b/toolkit/devtools/server/actors/call-watcher.js
@@ -407,21 +407,23 @@ let CallWatcherActor = exports.CallWatch
         return;
       }
     }
 
     /**
      * Instruments a function on the specified target object.
      */
     function overrideFunction(global, target, name, descriptor, callback) {
-      let originalFunc = target[name];
+      // Invoking .apply on an unxrayed content function doesn't work, because
+      // the arguments array is inaccessible to it. Get Xrays back.
+      let originalFunc = Cu.unwaiveXrays(target[name]);
 
       Object.defineProperty(target, name, {
         value: function(...args) {
-          let result = originalFunc.apply(this, args);
+          let result = Cu.waiveXrays(originalFunc.apply(this, args));
 
           if (self._recording) {
             let stack = getStack(name);
             let type = CallWatcherFront.METHOD_FUNCTION;
             callback(unwrappedWindow, global, this, type, name, stack, args, result);
           }
           return result;
         },
@@ -430,23 +432,25 @@ let CallWatcherActor = exports.CallWatch
         writable: true
       });
     }
 
     /**
      * Instruments a getter or setter on the specified target object.
      */
     function overrideAccessor(global, target, name, descriptor, callback) {
-      let originalGetter = target.__lookupGetter__(name);
-      let originalSetter = target.__lookupSetter__(name);
+      // Invoking .apply on an unxrayed content function doesn't work, because
+      // the arguments array is inaccessible to it. Get Xrays back.
+      let originalGetter = Cu.unwaiveXrays(target.__lookupGetter__(name));
+      let originalSetter = Cu.unwaiveXrays(target.__lookupSetter__(name));
 
       Object.defineProperty(target, name, {
         get: function(...args) {
           if (!originalGetter) return undefined;
-          let result = originalGetter.apply(this, args);
+          let result = Cu.waiveXrays(originalGetter.apply(this, args));
 
           if (self._recording) {
             let stack = getStack(name);
             let type = CallWatcherFront.GETTER_FUNCTION;
             callback(unwrappedWindow, global, this, type, name, stack, args, result);
           }
           return result;
         },
--- a/toolkit/devtools/server/actors/webgl.js
+++ b/toolkit/devtools/server/actors/webgl.js
@@ -487,17 +487,19 @@ let WebGLInstrumenter = {
     let afterFuncName = callbackName[1] || callbackName[0] || funcName;
 
     context[funcName] = function(...glArgs) {
       if (timing <= 0 && !observer.suppressHandlers) {
         let glBreak = observer[beforeFuncName](glArgs, cache, proxy);
         if (glBreak) return undefined;
       }
 
-      let glResult = originalFunc.apply(this, glArgs);
+      // Invoking .apply on an unxrayed content function doesn't work, because
+      // the arguments array is inaccessible to it. Get Xrays back.
+      let glResult = Cu.waiveXrays(Cu.unwaiveXrays(originalFunc).apply(this, glArgs));
 
       if (timing >= 0 && !observer.suppressHandlers) {
         let glBreak = observer[afterFuncName](glArgs, glResult, cache, proxy);
         if (glBreak) return undefined;
       }
 
       return glResult;
     };