From adfd373291f4130124d8d59e87d859562a410f62 Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Wed, 4 Jun 2014 13:21:08 +0100 Subject: [PATCH] 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 --- dom/browser-element/BrowserElementParent.jsm | 22 +------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/dom/browser-element/BrowserElementParent.jsm b/dom/browser-element/BrowserElementParent.jsm index ca5cf9e25ab0..13025f019848 100644 --- a/dom/browser-element/BrowserElementParent.jsm +++ b/dom/browser-element/BrowserElementParent.jsm @@ -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) { obj[name] = value; 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 // detail. For now, it's OK. if (detail !== undefined && detail !== null) { - exposeAll(detail); + detail = Cu.cloneInto(detail, this._window); return new this._window.CustomEvent('mozbrowser' + evtName, { bubbles: true, cancelable: cancelable,