diff --git a/lib/frame.js b/lib/frame.js index cc134a7..a9b31a9 100644 --- a/lib/frame.js +++ b/lib/frame.js @@ -8,6 +8,7 @@ const {ask} = require("./askForPermission.js"); const lists = require("./lists.js"); const {check: originalCheck, checkStack: originalCheckStack} = require("./check.js"); + const getWrapped = require("sdk/getWrapped"); const logging = require("./logging"); const {error, warning, message, notice, verbose, setPrefix: setLogPrefix} = logging; @@ -100,11 +101,11 @@ {check, checkStack, ask: askWrapper, notify, prefs} ); message("prepare to intercept (i)frames."); - + [window.HTMLIFrameElement, window.HTMLFrameElement].forEach(function(constructor){ var oldContentWindowGetter = constructor.prototype.__lookupGetter__("contentWindow"); Object.defineProperty( - constructor.prototype.wrappedJSObject, + getWrapped(constructor.prototype), "contentWindow", { enumerable: true, @@ -118,7 +119,7 @@ ); var oldContentDocumentGetter = constructor.prototype.__lookupGetter__("contentDocument"); Object.defineProperty( - constructor.prototype.wrappedJSObject, + getWrapped(constructor.prototype), "contentDocument", { enumerable: true, diff --git a/lib/intercept.js b/lib/intercept.js index 632a756..535796c 100644 --- a/lib/intercept.js +++ b/lib/intercept.js @@ -15,6 +15,8 @@ const {changedFunctions, setRandomSupply} = require("./modifiedAPI"); const randomSupplies = require("./randomSupplies"); + const getWrapped = require("sdk/getWrapped"); + setRandomSupply(randomSupplies.nonPersistent); var apiNames = Object.keys(changedFunctions); var undef; @@ -64,7 +66,7 @@ changedFunction.object: [changedFunction.object] ).forEach(function(object){ - var constructor = window.wrappedJSObject[object]; + var constructor = getWrapped(window)[object]; if (constructor){ var original = constructor.prototype[name]; @@ -134,7 +136,7 @@ case false: return undef; default: - return exportFunction(fake, window.wrappedJSObject); + return exportFunction(fake, getWrapped(window)); } //case "block": default: diff --git a/lib/modifiedAPI.js b/lib/modifiedAPI.js index 3d89667..931bf7a 100644 --- a/lib/modifiedAPI.js +++ b/lib/modifiedAPI.js @@ -16,6 +16,7 @@ const colorStatistics = require("./colorStatistics"); const logging = require("./logging"); const {copyCanvasToWebgl} = require("./webgl"); + const getWrapped = require("sdk/getWrapped"); var randomSupply = null; @@ -30,8 +31,8 @@ var imageData; var source; if ((context.canvas.width || 0) * (context.canvas.height || 0) === 0){ - imageData = new window.wrappedJSObject.ImageData(0, 0); - source = new window.wrappedJSObject.ImageData(0, 0); + imageData = new getWrapped(window).ImageData(0, 0); + source = new getWrapped(window).ImageData(0, 0); } else if (context instanceof window.CanvasRenderingContext2D){ imageData = window.CanvasRenderingContext2D.prototype.getImageData.call( @@ -42,7 +43,7 @@ source = imageData.data; } else { - imageData = new window.wrappedJSObject.ImageData(context.canvas.width, context.canvas.height); + imageData = new getWrapped(window).ImageData(context.canvas.width, context.canvas.height); source = new Uint8Array(imageData.data.length); window.WebGLRenderingContext.prototype.readPixels.call( context, diff --git a/lib/require.js b/lib/require.js index 3465c5a..ec05826 100644 --- a/lib/require.js +++ b/lib/require.js @@ -9,6 +9,11 @@ function require(module){ var scopeName = module.substr(2).replace(/\..+/, ""); return window.scope[scopeName]; } + else if (module === "sdk/getWrapped"){ + return function getWrapped(obj){ + return obj.wrappedJSObject || obj; + }; + } else if (module === "sdk/simple-prefs"){ return { prefs: settings,