diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 7e220f455809..214101a3197f 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -606,7 +606,7 @@ public: JSString * nsOuterWindowProxy::obj_toString(JSContext *cx, JSObject *proxy) { - JS_ASSERT(js::IsProxy(proxy)); + MOZ_ASSERT(js::IsProxy(proxy)); return JS_NewStringCopyZ(cx, "[object Window]"); } @@ -626,8 +626,29 @@ nsOuterWindowProxy::finalize(JSFreeOp *fop, JSObject *proxy) nsOuterWindowProxy nsOuterWindowProxy::singleton; +class nsChromeOuterWindowProxy : public nsOuterWindowProxy +{ +public: + nsChromeOuterWindowProxy() : nsOuterWindowProxy() {} + + virtual JSString *obj_toString(JSContext *cx, JSObject *wrapper); + + static nsChromeOuterWindowProxy singleton; +}; + +JSString * +nsChromeOuterWindowProxy::obj_toString(JSContext *cx, JSObject *proxy) +{ + MOZ_ASSERT(js::IsProxy(proxy)); + + return JS_NewStringCopyZ(cx, "[object ChromeWindow]"); +} + +nsChromeOuterWindowProxy +nsChromeOuterWindowProxy::singleton; + static JSObject* -NewOuterWindowProxy(JSContext *cx, JSObject *parent) +NewOuterWindowProxy(JSContext *cx, JSObject *parent, bool isChrome) { JSAutoCompartment ac(cx, parent); JSObject *proto; @@ -635,7 +656,9 @@ NewOuterWindowProxy(JSContext *cx, JSObject *parent) return nullptr; JSObject *obj = js::Wrapper::New(cx, parent, proto, parent, - &nsOuterWindowProxy::singleton); + isChrome ? &nsChromeOuterWindowProxy::singleton + : &nsOuterWindowProxy::singleton); + NS_ASSERTION(js::GetObjectClass(obj)->ext.innerObject, "bad class"); return obj; } @@ -1673,7 +1696,8 @@ nsGlobalWindow::CreateOuterObject(nsGlobalWindow* aNewInner) { JSContext* cx = mContext->GetNativeContext(); - if (IsChromeWindow()) { + bool isChrome = IsChromeWindow(); + if (isChrome) { // Always enable E4X for XUL and other chrome content -- there is no // need to preserve the