Bug 742444 - Rejigger unsafeWindow definition to not rely on passing waivers across origins. r=gabor

This commit is contained in:
Bobby Holley 2014-07-22 16:14:26 -07:00
parent 63e0a08f40
commit 14a57b73c7
2 changed files with 25 additions and 14 deletions

View File

@ -156,14 +156,19 @@ const WorkerSandbox = Class({
// We need 'this === window === top' to be true in toplevel scope:
get window() content,
get top() top,
get parent() parent,
// Use the Greasemonkey naming convention to provide access to the
// unwrapped window object so the content script can access document
// JavaScript values.
// NOTE: this functionality is experimental and may change or go away
// at any time!
get unsafeWindow() window.wrappedJSObject
get parent() parent
});
// Use the Greasemonkey naming convention to provide access to the
// unwrapped window object so the content script can access document
// JavaScript values.
// NOTE: this functionality is experimental and may change or go away
// at any time!
//
// Note that because waivers aren't propagated between origins, we
// need the unsafeWindow getter to live in the sandbox.
var unsafeWindowGetter =
new content.Function('return window.wrappedJSObject || window;');
Object.defineProperty(content, 'unsafeWindow', {get: unsafeWindowGetter});
// Load trusted code that will inject content script API.
let ContentWorker = load(content, CONTENT_WORKER_URL);

View File

@ -166,14 +166,20 @@ const WorkerSandbox = EventEmitter.compose({
// We need "this === window === top" to be true in toplevel scope:
get window() content,
get top() top,
get parent() parent,
// Use the Greasemonkey naming convention to provide access to the
// unwrapped window object so the content script can access document
// JavaScript values.
// NOTE: this functionality is experimental and may change or go away
// at any time!
get unsafeWindow() window.wrappedJSObject
get parent() parent
});
// Use the Greasemonkey naming convention to provide access to the
// unwrapped window object so the content script can access document
// JavaScript values.
// NOTE: this functionality is experimental and may change or go away
// at any time!
//
// Note that because waivers aren't propagated between origins, we
// need the unsafeWindow getter to live in the sandbox.
var unsafeWindowGetter =
new content.Function('return window.wrappedJSObject || window;');
Object.defineProperty(content, 'unsafeWindow', {get: unsafeWindowGetter});
// Load trusted code that will inject content script API.
let ContentWorker = load(content, CONTENT_WORKER_URL);