Bug 1532553 - Use AutoRealm before calling JS::ReadableStreamGetMode(), r=jorendorff
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 12 Mar 2019 14:02:13 +0000
changeset 521755 0a8500467d6d
parent 521754 c49fff912f99
child 521756 b8c1398f5a90
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1532553
milestone67.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 1532553 - Use AutoRealm before calling JS::ReadableStreamGetMode(), r=jorendorff Differential Revision: https://phabricator.services.mozilla.com/D23117
dom/fetch/Fetch.cpp
--- a/dom/fetch/Fetch.cpp
+++ b/dom/fetch/Fetch.cpp
@@ -1067,16 +1067,18 @@ void FetchBody<Derived>::SetBodyUsed(JSC
 
   mBodyUsed = true;
 
   // If we already have a ReadableStreamBody and it has been created by DOM, we
   // have to lock it now because it can have been shared with other objects.
   if (mReadableStreamBody) {
     aRv.MightThrowJSException();
 
+    JSAutoRealm ar(aCx, mOwner->GetGlobalJSObject());
+
     JS::Rooted<JSObject*> readableStreamObj(aCx, mReadableStreamBody);
 
     JS::ReadableStreamMode mode;
     if (!JS::ReadableStreamGetMode(aCx, readableStreamObj, &mode)) {
       aRv.StealExceptionFromJSContext(aCx);
       return;
     }
 
@@ -1361,16 +1363,18 @@ void FetchBody<Derived>::MaybeTeeReadabl
   *aInputStream = nullptr;
 
   if (!mReadableStreamBody) {
     return;
   }
 
   aRv.MightThrowJSException();
 
+  JSAutoRealm ar(aCx, mOwner->GetGlobalJSObject());
+
   JS::Rooted<JSObject*> stream(aCx, mReadableStreamBody);
 
   // If this is a ReadableStream with an external source, this has been
   // generated by a Fetch. In this case, Fetch will be able to recreate it
   // again when GetBody() is called.
   JS::ReadableStreamMode streamMode;
   if (!JS::ReadableStreamGetMode(aCx, stream, &streamMode)) {
     aRv.StealExceptionFromJSContext(aCx);