Bug 1019643 - use Cu.cloneInto for browser elements instead of manually looping through objects and exposing them, r=bholley

--HG--
extra : transplant_source : %D4%CDG%19-%27F%C4%93%D5LF%2CE%0B%F7%2A6%94%E9
This commit is contained in:
Gijs Kruitbosch 2014-06-04 13:21:08 +01:00
Родитель 1e9b9fba77
Коммит adfd373291
1 изменённых файлов: 1 добавлений и 21 удалений

Просмотреть файл

@ -40,26 +40,6 @@ function getIntPref(prefName, def) {
} }
} }
function exposeAll(obj) {
// Filter for Objects and Arrays.
if (typeof obj !== "object" || !obj)
return;
// Recursively expose our children.
Object.keys(obj).forEach(function(key) {
exposeAll(obj[key]);
});
// If we're not an Array, generate an __exposedProps__ object for ourselves.
if (obj instanceof Array)
return;
var exposed = {};
Object.keys(obj).forEach(function(key) {
exposed[key] = 'rw';
});
obj.__exposedProps__ = exposed;
}
function defineAndExpose(obj, name, value) { function defineAndExpose(obj, name, value) {
obj[name] = value; obj[name] = value;
if (!('__exposedProps__' in obj)) if (!('__exposedProps__' in obj))
@ -499,7 +479,7 @@ BrowserElementParent.prototype = {
// This will have to change if we ever want to send a CustomEvent with null // This will have to change if we ever want to send a CustomEvent with null
// detail. For now, it's OK. // detail. For now, it's OK.
if (detail !== undefined && detail !== null) { if (detail !== undefined && detail !== null) {
exposeAll(detail); detail = Cu.cloneInto(detail, this._window);
return new this._window.CustomEvent('mozbrowser' + evtName, return new this._window.CustomEvent('mozbrowser' + evtName,
{ bubbles: true, { bubbles: true,
cancelable: cancelable, cancelable: cancelable,