nntoan / scriptify

Automatically exported from code.google.com/p/scriptify
MIT License
0 stars 0 forks source link

unsafeWindow issue with Firefox 34 #15

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. in a script, do something like unsafeWindow.hello = 'world';
2. on the page, execute console.log(window.hello);

What is the expected output? What do you see instead?

Expect to see "world" output to console
console log outputs undefined instead

Please provide any additional information below.

Fixed by the following patch (borrowed from greasemonkey)

diff -r 49b81764ad78 scriptified/bootstrap.js
--- a/scriptified/bootstrap.js  Mon Aug 04 17:33:49 2014 -0700
+++ b/scriptified/bootstrap.js  Wed Dec 03 20:25:56 2014 +1100
@@ -784,7 +784,8 @@

             let sandbox = Cu.Sandbox(window, { sandboxPrototype: window });
-            sandbox.unsafeWindow = window.wrappedJSObject;
+            let unsafeWindowGetter = new sandbox.Function('return 
window.wrappedJSObject || window;');
+            Object.defineProperty(sandbox, 'unsafeWindow', {get: 
unsafeWindowGetter});

             let api = new API(sandbox, script);

Original issue reported on code.google.com by jaroma...@gmail.com on 3 Dec 2014 at 9:30