Bug 1083427 - Remove exposedProps from sandbox code. r=gabor

This commit is contained in:
Bobby Holley 2014-10-16 15:28:30 +02:00
parent 822502877c
commit 4a39398fbf
2 changed files with 14 additions and 48 deletions

View File

@ -176,12 +176,8 @@ const WorkerSandbox = Class({
// by trading two methods that allow to send events to the other side:
// - `onEvent` called by content script
// - `result.emitToContent` called by addon script
// Bug 758203: We have to explicitely define `__exposedProps__` in order
// to allow access to these chrome object attributes from this sandbox with
// content priviledges
// https://developer.mozilla.org/en/XPConnect_wrappers#Other_security_wrappers
let onEvent = onContentEvent.bind(null, this);
let chromeAPI = createChromeAPI();
let chromeAPI = createChromeAPI(ContentWorker);
let result = Cu.waiveXrays(ContentWorker).inject(content, chromeAPI, onEvent, options);
// Merge `emitToContent` into our private model of the
@ -379,29 +375,16 @@ function emitToContent (workerSandbox, args) {
return modelFor(workerSandbox).emitToContent(args);
}
function createChromeAPI () {
return {
function createChromeAPI (scope) {
return Cu.cloneInto({
timers: {
setTimeout: timer.setTimeout,
setInterval: timer.setInterval,
clearTimeout: timer.clearTimeout,
clearInterval: timer.clearInterval,
__exposedProps__: {
setTimeout: 'r',
setInterval: 'r',
clearTimeout: 'r',
clearInterval: 'r'
},
setTimeout: timer.setTimeout.bind(timer),
setInterval: timer.setInterval.bind(timer),
clearTimeout: timer.clearTimeout.bind(timer),
clearInterval: timer.clearInterval.bind(timer),
},
sandbox: {
evaluate: evaluate,
__exposedProps__: {
evaluate: 'r'
}
},
__exposedProps__: {
timers: 'r',
sandbox: 'r'
}
};
}, scope, {cloneFunctions: true});
}

View File

@ -184,34 +184,17 @@ const WorkerSandbox = EventEmitter.compose({
// by trading two methods that allow to send events to the other side:
// - `onEvent` called by content script
// - `result.emitToContent` called by addon script
// Bug 758203: We have to explicitely define `__exposedProps__` in order
// to allow access to these chrome object attributes from this sandbox with
// content priviledges
// https://developer.mozilla.org/en/XPConnect_wrappers#Other_security_wrappers
let chromeAPI = {
let chromeAPI = Cu.cloneInto({
timers: {
setTimeout: timer.setTimeout,
setInterval: timer.setInterval,
clearTimeout: timer.clearTimeout,
clearInterval: timer.clearInterval,
__exposedProps__: {
setTimeout: 'r',
setInterval: 'r',
clearTimeout: 'r',
clearInterval: 'r'
}
setTimeout: timer.setTimeout.bind(timer),
setInterval: timer.setInterval.bind(timer),
clearTimeout: timer.clearTimeout.bind(timer),
clearInterval: timer.clearInterval.bind(timer),
},
sandbox: {
evaluate: evaluate,
__exposedProps__: {
evaluate: 'r',
}
},
__exposedProps__: {
timers: 'r',
sandbox: 'r',
}
};
}, ContentWorker, {cloneFunctions: true});
let onEvent = this._onContentEvent.bind(this);
let result = Cu.waiveXrays(ContentWorker).inject(content, chromeAPI, onEvent, options);
this._emitToContent = result;