Bug 1486949 - Part 6: Fix ReadableStreamDefaultReader::Read to use the constructor realm r=smaug

Other methods probably should do the same, but for now this fulfills the test requirement. The rest is (or should be) tracked by https://bugzilla.mozilla.org/show_bug.cgi?id=1756661.

Differential Revision: https://phabricator.services.mozilla.com/D153977
This commit is contained in:
Kagami Sascha Rosylight 2022-08-12 15:59:05 +00:00
Родитель 0c2f2d038f
Коммит c45758d39e
4 изменённых файлов: 7 добавлений и 15 удалений

Просмотреть файл

@ -717,10 +717,6 @@ DOMInterfaces = {
'implicitJSContext': ['close'],
},
'ReadableStreamDefaultReader': {
'implicitJSContext': ['read'],
},
'Request': {
'implicitJSContext': [ 'arrayBuffer', 'blob', 'formData', 'json', 'text' ],
},

Просмотреть файл

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/ReadableStreamDefaultReader.h"
#include "mozilla/dom/AutoEntryScript.h"
#include "mozilla/dom/ReadableStream.h"
#include "mozilla/dom/RootedDictionary.h"
#include "js/PropertyAndElement.h"
@ -238,8 +239,7 @@ void ReadableStreamDefaultReaderRead(JSContext* aCx,
// Return a raw pointer here to avoid refcounting, but make sure it's safe
// (the object should be kept alive by the callee).
// https://streams.spec.whatwg.org/#default-reader-read
already_AddRefed<Promise> ReadableStreamDefaultReader::Read(JSContext* aCx,
ErrorResult& aRv) {
already_AddRefed<Promise> ReadableStreamDefaultReader::Read(ErrorResult& aRv) {
// Step 1.
if (!mStream) {
aRv.ThrowTypeError("Reading is not possible after calling releaseLock.");
@ -253,7 +253,10 @@ already_AddRefed<Promise> ReadableStreamDefaultReader::Read(JSContext* aCx,
RefPtr<ReadRequest> request = new Read_ReadRequest(promise);
// Step 4.
ReadableStreamDefaultReaderRead(aCx, this, request, aRv);
AutoEntryScript aes(mGlobal, "ReadableStreamDefaultReader::Read");
JSContext* cx = aes.cx();
ReadableStreamDefaultReaderRead(cx, this, request, aRv);
if (aRv.Failed()) {
return nullptr;
}

Просмотреть файл

@ -75,8 +75,7 @@ class ReadableStreamDefaultReader final : public ReadableStreamGenericReader,
static already_AddRefed<ReadableStreamDefaultReader> Constructor(
const GlobalObject& aGlobal, ReadableStream& stream, ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> Read(JSContext* aCx,
ErrorResult& aRv);
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> Read(ErrorResult& aRv);
void ReleaseLock(ErrorResult& aRv);

Просмотреть файл

@ -1,6 +0,0 @@
[realms.window.html]
[the output chunks when read is called after write should come from the same realm as the constructor of TextEncoderStream]
expected: FAIL
[the result object when read is called after write should come from the same realm as the constructor of TextDecoderStream]
expected: FAIL