Bug 1474835 - Use implicit_jscontext for nsIWebNavigation.setOriginAttributesBeforeLoading. r=smaug
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 11 Jul 2018 15:23:54 +0200
changeset 426211 30e2bfed294438984fab63f434210906f4c14943
parent 426210 acc0d8ae4c88ad5978714b8b2344d02034dce24d
child 426212 5342b206e024494577d01704099ec25d10a33828
push id34267
push userrgurzau@mozilla.com
push dateWed, 11 Jul 2018 22:05:21 +0000
treeherdermozilla-central@3aca103e4915 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1474835
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1474835 - Use implicit_jscontext for nsIWebNavigation.setOriginAttributesBeforeLoading. r=smaug
docshell/base/nsDocShell.cpp
docshell/base/nsIWebNavigation.idl
docshell/shistory/nsSHistory.cpp
toolkit/components/browser/nsWebBrowser.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -13827,34 +13827,25 @@ nsDocShell::SetOriginAttributes(const Or
 
   SetPrivateBrowsing(isPrivate);
   AssertOriginAttributesMatchPrivateBrowsing();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDocShell::SetOriginAttributesBeforeLoading(JS::Handle<JS::Value> aOriginAttributes)
+nsDocShell::SetOriginAttributesBeforeLoading(JS::Handle<JS::Value> aOriginAttributes,
+                                             JSContext* aCx)
 {
   if (!aOriginAttributes.isObject()) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  AutoJSAPI jsapi;
-  if (!jsapi.Init(&aOriginAttributes.toObject())) {
-    return NS_ERROR_UNEXPECTED;
-  }
-
-  JSContext* cx = jsapi.cx();
-  if (NS_WARN_IF(!cx)) {
-    return NS_ERROR_FAILURE;
-  }
-
   OriginAttributes attrs;
-  if (!aOriginAttributes.isObject() || !attrs.Init(cx, aOriginAttributes)) {
+  if (!attrs.Init(aCx, aOriginAttributes)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   return SetOriginAttributes(attrs);
 }
 
 NS_IMETHODIMP
 nsDocShell::SetOriginAttributes(JS::Handle<JS::Value> aOriginAttributes,
--- a/docshell/base/nsIWebNavigation.idl
+++ b/docshell/base/nsIWebNavigation.idl
@@ -401,10 +401,11 @@ interface nsIWebNavigation : nsISupports
       .downcast<mozilla::dom::ChildSHistory>();
   }
   %}
 
   /**
    * Set an OriginAttributes dictionary in the docShell. This can be done only
    * before loading any content.
    */
+  [implicit_jscontext]
   void setOriginAttributesBeforeLoading(in jsval originAttributes);
 };
--- a/docshell/shistory/nsSHistory.cpp
+++ b/docshell/shistory/nsSHistory.cpp
@@ -1815,17 +1815,18 @@ nsSHistory::LoadURIWithOptions(const cha
                                nsIInputStream* aExtraHeaderStream,
                                nsIURI* aBaseURI,
                                nsIPrincipal* aTriggeringPrincipal)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHistory::SetOriginAttributesBeforeLoading(JS::HandleValue aOriginAttributes)
+nsSHistory::SetOriginAttributesBeforeLoading(JS::HandleValue aOriginAttributes,
+                                             JSContext* aCx)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHistory::LoadURI(const char16_t* aURI,
                     uint32_t aLoadFlags,
                     nsIURI* aReferringURI,
--- a/toolkit/components/browser/nsWebBrowser.cpp
+++ b/toolkit/components/browser/nsWebBrowser.cpp
@@ -667,19 +667,20 @@ nsWebBrowser::LoadURIWithOptions(const c
   NS_ENSURE_STATE(mDocShell);
 
   return mDocShellAsNav->LoadURIWithOptions(
     aURI, aLoadFlags, aReferringURI, aReferrerPolicy, aPostDataStream,
     aExtraHeaderStream, aBaseURI, aTriggeringPrincipal);
 }
 
 NS_IMETHODIMP
-nsWebBrowser::SetOriginAttributesBeforeLoading(JS::Handle<JS::Value> aOriginAttributes)
+nsWebBrowser::SetOriginAttributesBeforeLoading(JS::Handle<JS::Value> aOriginAttributes,
+                                               JSContext* aCx)
 {
-  return mDocShellAsNav->SetOriginAttributesBeforeLoading(aOriginAttributes);
+  return mDocShellAsNav->SetOriginAttributesBeforeLoading(aOriginAttributes, aCx);
 }
 
 NS_IMETHODIMP
 nsWebBrowser::LoadURI(const char16_t* aURI, uint32_t aLoadFlags,
                       nsIURI* aReferringURI,
                       nsIInputStream* aPostDataStream,
                       nsIInputStream* aExtraHeaderStream,
                       nsIPrincipal* aTriggeringPrincipal)