Skip to content

Instantly share code, notes, and snippets.

@eagletmt
Created October 12, 2011 09:00
Show Gist options
  • Save eagletmt/1280704 to your computer and use it in GitHub Desktop.
Save eagletmt/1280704 to your computer and use it in GitHub Desktop.
diff --git a/components/greasemonkey.js b/components/greasemonkey.js
index 121f661..b199425 100644
--- a/components/greasemonkey.js
+++ b/components/greasemonkey.js
@@ -67,7 +67,7 @@ function GM_apiLeakCheck(apiName) {
}
function createSandbox(
- aScript, aContentWin, aChromeWin, aFirebugConsole, aUrl
+ aScript, aContentWin, aChromeWin, aFirebugConsole, aUrl, aSharedWin
) {
var unsafeWin = aContentWin.wrappedJSObject;
var sandbox = new Components.utils.Sandbox(aContentWin);
@@ -78,6 +78,7 @@ function createSandbox(
sandbox.document = aContentWin.document;
}
+ sandbox.window = aSharedWin;
sandbox.__proto__ = aContentWin;
sandbox.unsafeWindow = unsafeWin;
sandbox.XPathResult = Ci.nsIDOMXPathResult;
@@ -429,10 +430,13 @@ service.prototype.injectScripts = function(
scripts, url, wrappedContentWin, chromeWin
) {
var firebugConsole = getFirebugConsole(wrappedContentWin, chromeWin);
+ var sharedWin = {};
+ sharedWin.window = sharedWin;
+ sharedWin.__proto__ = wrappedContentWin;
for (var i = 0, script = null; script = scripts[i]; i++) {
var sandbox = createSandbox(
- script, wrappedContentWin, chromeWin, firebugConsole, url);
+ script, wrappedContentWin, chromeWin, firebugConsole, url, sharedWin);
var requires = [];
var offsets = [];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment