Bug 990293 - Pass false to WrapNative in nsIDocument::WrapObject. r=bz, a=lsblakk
authorAndrew McCreight <continuation@gmail.com>
Fri, 11 Apr 2014 14:31:23 -0400
changeset 191713 a8575f98bb8afa52e5fa645d0950c9c1f122c7ea
parent 191712 d39a8f58016bd5e93f56330d4b3925d213404c5b
child 191714 86a35aa4500da40d506895e3b69a13cf02572d6e
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, lsblakk
bugs990293
milestone30.0a2
Bug 990293 - Pass false to WrapNative in nsIDocument::WrapObject. r=bz, a=lsblakk
content/base/public/nsContentUtils.h
content/base/src/nsDocument.cpp
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -1643,19 +1643,20 @@ public:
    * If there is no JS in the stack or privileged JS is running, this
    * method returns true, otherwise false.
    */
   static bool CanAccessNativeAnon();
 
   MOZ_WARN_UNUSED_RESULT
   static nsresult WrapNative(JSContext *cx, JS::Handle<JSObject*> scope,
                              nsISupports *native, const nsIID* aIID,
-                             JS::MutableHandle<JS::Value> vp)
+                             JS::MutableHandle<JS::Value> vp,
+                             bool aAllowWrapping = true)
   {
-    return WrapNative(cx, scope, native, nullptr, aIID, vp, true);
+    return WrapNative(cx, scope, native, nullptr, aIID, vp, aAllowWrapping);
   }
 
   // Same as the WrapNative above, but use this one if aIID is nsISupports' IID.
   MOZ_WARN_UNUSED_RESULT
   static nsresult WrapNative(JSContext *cx, JS::Handle<JSObject*> scope,
                              nsISupports *native, JS::MutableHandle<JS::Value> vp,
                              bool aAllowWrapping = true)
   {
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -12084,25 +12084,23 @@ nsIDocument::WrapObject(JSContext *aCx, 
     return obj;
   }
 
   JSAutoCompartment ac(aCx, obj);
 
   JS::Rooted<JS::Value> winVal(aCx);
   nsresult rv = nsContentUtils::WrapNative(aCx, obj, win,
                                            &NS_GET_IID(nsIDOMWindow),
-                                           &winVal);
+                                           &winVal,
+                                           false);
   if (NS_FAILED(rv)) {
     Throw(aCx, rv);
     return nullptr;
   }
 
-  MOZ_ASSERT(&winVal.toObject() == js::UncheckedUnwrap(&winVal.toObject()),
-             "WrapNative shouldn't create a cross-compartment wrapper");
-
   NS_NAMED_LITERAL_STRING(doc_str, "document");
 
   if (!JS_DefineUCProperty(aCx, JSVAL_TO_OBJECT(winVal), doc_str.get(),
                            doc_str.Length(), JS::ObjectValue(*obj),
                            JS_PropertyStub, JS_StrictPropertyStub,
                            JSPROP_READONLY | JSPROP_ENUMERATE)) {
     return nullptr;
   }