Bug 1035395. r=smaug,bholley. a=abillings
authorSteve Fink <sfink@mozilla.com>
Thu, 17 Jul 2014 00:29:39 -0700
changeset 208116 943e0e47d815a5c02abafe915cf3a39b9fbcbdf7
parent 208115 5bb486b0f89a0853955b225da114fe6adfd1ead0
child 208117 4e4056fa74af476cc5ca11966d39a4b7a95bfe8f
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, bholley, abillings
bugs1035395
milestone32.0a2
Bug 1035395. r=smaug,bholley. a=abillings
caps/src/nsScriptSecurityManager.cpp
content/base/src/nsINode.cpp
dom/base/Navigator.cpp
dom/devicestorage/nsDeviceStorage.cpp
--- a/caps/src/nsScriptSecurityManager.cpp
+++ b/caps/src/nsScriptSecurityManager.cpp
@@ -870,18 +870,16 @@ nsScriptSecurityManager::CheckLoadURIStr
     return rv;
 }
 
 bool
 nsScriptSecurityManager::ScriptAllowed(JSObject *aGlobal)
 {
     MOZ_ASSERT(aGlobal);
     MOZ_ASSERT(JS_IsGlobalObject(aGlobal) || js::IsOuterObject(aGlobal));
-    AutoJSContext cx;
-    JS::RootedObject global(cx, js::UncheckedUnwrap(aGlobal, /* stopAtOuter = */ false));
 
     // Check the bits on the compartment private.
     return xpc::Scriptability::Get(aGlobal).Allowed();
 }
 
 ///////////////// Principals ///////////////////////
 
 NS_IMETHODIMP
--- a/content/base/src/nsINode.cpp
+++ b/content/base/src/nsINode.cpp
@@ -1473,18 +1473,20 @@ AdoptNodeIntoOwnerDoc(nsINode *aParent, 
 
   return NS_OK;
 }
 
 static nsresult
 CheckForOutdatedParent(nsINode* aParent, nsINode* aNode)
 {
   if (JSObject* existingObjUnrooted = aNode->GetWrapper()) {
+    JSRuntime* runtime = JS_GetObjectRuntime(existingObjUnrooted);
+    JS::Rooted<JSObject*> existingObj(runtime, existingObjUnrooted);
+
     AutoJSContext cx;
-    JS::Rooted<JSObject*> existingObj(cx, existingObjUnrooted);
     nsIGlobalObject* global = aParent->OwnerDoc()->GetScopeObject();
     MOZ_ASSERT(global);
 
     if (js::GetGlobalForObjectCrossCompartment(existingObj) !=
         global->GetGlobalJSObject()) {
       JSAutoCompartment ac(cx, existingObj);
       nsresult rv = ReparentWrapper(cx, existingObj);
       NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -2235,23 +2235,24 @@ Navigator::HasWifiManagerSupport(JSConte
   return nsIPermissionManager::ALLOW_ACTION == permission;
 }
 
 #ifdef MOZ_NFC
 /* static */
 bool
 Navigator::HasNFCSupport(JSContext* /* unused */, JSObject* aGlobal)
 {
+  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
+
   // Do not support NFC if NFC content helper does not exist.
   nsCOMPtr<nsISupports> contentHelper = do_GetService("@mozilla.org/nfc/content-helper;1");
   if (!contentHelper) {
     return false;
   }
 
-  nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
   return win && (CheckPermission(win, "nfc-read") ||
                  CheckPermission(win, "nfc-write"));
 }
 #endif // MOZ_NFC
 
 #ifdef MOZ_TIME_MANAGER
 /* static */
 bool
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -1645,22 +1645,21 @@ InterfaceToJsval(nsPIDOMWindow* aWindow,
   if (!sgo) {
     return JS::NullValue();
   }
 
   JSObject *unrootedScopeObj = sgo->GetGlobalJSObject();
   NS_ENSURE_TRUE(unrootedScopeObj, JS::NullValue());
   JSRuntime *runtime = JS_GetObjectRuntime(unrootedScopeObj);
   JS::Rooted<JS::Value> someJsVal(runtime);
+  JS::Rooted<JSObject*> scopeObj(runtime, unrootedScopeObj);
   nsresult rv;
 
   { // Protect someJsVal from moving GC in ~JSAutoCompartment
     AutoJSContext cx;
-
-    JS::Rooted<JSObject*> scopeObj(cx, unrootedScopeObj);
     JSAutoCompartment ac(cx, scopeObj);
 
     rv = nsContentUtils::WrapNative(cx, aObject, aIID, &someJsVal);
   }
   if (NS_FAILED(rv)) {
     return JS::NullValue();
   }