Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 0 additions & 17 deletions .github/workflows/close-pr.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI
concurrency:
group: ${{ github.head_ref }}-${{ github.workflow}}
cancel-in-progress: true
on:
pull_request:
defaults:
run:
shell: bash

jobs:
test:
strategy:
fail-fast: false
matrix:
test: [jstests, jit-test]
mozconfig: [ debug, pbl-debug, pbl-release, release, aot-ics-release ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- run: ./mach --no-interactive bootstrap --application-choice=js
- run: MOZCONFIG=.github/workflows/mozconfig-${{ matrix.mozconfig }} ./mach build
- run: MOZCONFIG=.github/workflows/mozconfig-${{ matrix.mozconfig }} ./mach ${{ matrix.test }} ${{ matrix.test == 'jit-test' && '--exclude wasm/atomicity.js' || '' }}
13 changes: 13 additions & 0 deletions .github/workflows/mozconfig-aot-ics-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ac_add_options --enable-project=js
ac_add_options --enable-application=js
ac_add_options --enable-jitspew
ac_add_options --enable-optimize=-O3
ac_add_options --enable-js-streams
ac_add_options --disable-stdcxx-compat
ac_add_options --enable-portable-baseline-interp
ac_add_options --enable-portable-baseline-interp-force
ac_add_options --enable-aot-ics
ac_add_options --enable-aot-ics-force
ac_add_options --enable-aot-ics-enforce

ac_add_options --disable-debug
8 changes: 8 additions & 0 deletions .github/workflows/mozconfig-debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ac_add_options --enable-project=js
ac_add_options --enable-application=js
ac_add_options --enable-jitspew
ac_add_options --enable-optimize=-O3
ac_add_options --enable-js-streams
ac_add_options --disable-stdcxx-compat

ac_add_options --enable-debug
10 changes: 10 additions & 0 deletions .github/workflows/mozconfig-pbl-debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ac_add_options --enable-project=js
ac_add_options --enable-application=js
ac_add_options --enable-jitspew
ac_add_options --enable-optimize=-O3
ac_add_options --enable-js-streams
ac_add_options --disable-stdcxx-compat

ac_add_options --enable-debug
ac_add_options --enable-portable-baseline-interp
ac_add_options --enable-portable-baseline-interp-force
10 changes: 10 additions & 0 deletions .github/workflows/mozconfig-pbl-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ac_add_options --enable-project=js
ac_add_options --enable-application=js
ac_add_options --enable-jitspew
ac_add_options --enable-optimize=-O3
ac_add_options --enable-js-streams
ac_add_options --disable-stdcxx-compat

ac_add_options --disable-debug
ac_add_options --enable-portable-baseline-interp
ac_add_options --enable-portable-baseline-interp-force
8 changes: 8 additions & 0 deletions .github/workflows/mozconfig-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ac_add_options --enable-project=js
ac_add_options --enable-application=js
ac_add_options --enable-jitspew
ac_add_options --enable-optimize=-O3
ac_add_options --enable-js-streams
ac_add_options --disable-stdcxx-compat

ac_add_options --disable-debug
168 changes: 168 additions & 0 deletions dom/base/BodyStream.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef mozilla_dom_BodyStream_h
#define mozilla_dom_BodyStream_h

#include "jsapi.h"
#include "js/Stream.h"
#include "mozilla/AlreadyAddRefed.h"
#include "mozilla/dom/ByteStreamHelpers.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "nsIAsyncInputStream.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIObserver.h"
#include "nsISupportsImpl.h"
#include "nsNetCID.h"
#include "nsWeakReference.h"

class nsIGlobalObject;

class nsIInputStream;

namespace mozilla {
class ErrorResult;

namespace dom {

class BodyStream;
class StrongWorkerRef;
class ReadableStream;
class ReadableStreamController;

class BodyStreamUnderlyingSourceAlgorithms;

class BodyStreamHolder : public nsISupports {
friend class BodyStream;
friend class BodyStreamUnderlyingSourceAlgorithms;
friend class BodyStreamUnderlyingSourceErrorCallbackHelper;

public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(BodyStreamHolder)

BodyStreamHolder();

virtual void NullifyStream() { mReadableStreamBody = nullptr; }

virtual void MarkAsRead() {}

void SetReadableStreamBody(ReadableStream* aBody) {
mReadableStreamBody = aBody;
}
ReadableStream* GetReadableStreamBody() { return mReadableStreamBody; }

protected:
virtual ~BodyStreamHolder() = default;

// This is the ReadableStream exposed to content. It's underlying source is a
// BodyStream object.
RefPtr<ReadableStream> mReadableStreamBody;

private:
void StoreBodyStream(BodyStream* aBodyStream);
already_AddRefed<BodyStream> TakeBodyStream() {
MOZ_ASSERT_IF(mStreamCreated, mBodyStream);
return mBodyStream.forget();
}
BodyStream* GetBodyStream() { return mBodyStream; }

RefPtr<BodyStream> mBodyStream;

#ifdef DEBUG
bool mStreamCreated = false;
#endif
};

class BodyStream final : public nsIInputStreamCallback,
public nsIObserver,
public nsSupportsWeakReference {
friend class BodyStreamHolder;

public:
NS_DECL_ISUPPORTS
NS_DECL_NSIINPUTSTREAMCALLBACK
NS_DECL_NSIOBSERVER

// This method creates a JS ReadableStream object and it assigns it to the
// aStreamHolder calling SetReadableStreamBody().
MOZ_CAN_RUN_SCRIPT_BOUNDARY
static void Create(JSContext* aCx, BodyStreamHolder* aStreamHolder,
nsIGlobalObject* aGlobal, nsIInputStream* aInputStream,
ErrorResult& aRv);

void Close();

static nsresult RetrieveInputStream(BodyStreamHolder* aStream,
nsIInputStream** aInputStream);

private:
BodyStream(nsIGlobalObject* aGlobal, BodyStreamHolder* aStreamHolder,
nsIInputStream* aInputStream);
~BodyStream();

public:
// Pull Callback
already_AddRefed<Promise> PullCallback(JSContext* aCx,
ReadableStreamController& aController,
ErrorResult& aRv);

void CloseInputAndReleaseObjects();

private:
// Fills a buffer with bytes from the stream.
void WriteIntoReadRequestBuffer(JSContext* aCx, ReadableStream* aStream,
JS::Handle<JSObject*> aBuffer,
uint32_t aLength, uint32_t* aByteWritten);

// This is a script boundary until Bug 1750605 is resolved and allows us
// to replace this with MOZ_CAN_RUN_SCRIPT.
MOZ_CAN_RUN_SCRIPT_BOUNDARY void EnqueueChunkWithSizeIntoStream(
JSContext* aCx, ReadableStream* aStream, uint64_t aAvailableData,
ErrorResult& aRv);

void ErrorPropagation(JSContext* aCx, ReadableStream* aStream,
nsresult aError);

// TODO: convert this to MOZ_CAN_RUN_SCRIPT (bug 1750605)
MOZ_CAN_RUN_SCRIPT_BOUNDARY void CloseAndReleaseObjects(
JSContext* aCx, ReadableStream* aStream);

class WorkerShutdown;

void ReleaseObjects();

// The closed state should ultimately be managed by the source algorithms
// class. See also bug 1815997.
bool IsClosed() { return !mStreamHolder; }

// Common methods

// mGlobal is set on creation, and isn't modified off the owning thread.
// It isn't set to nullptr until ReleaseObjects() runs.
nsCOMPtr<nsIGlobalObject> mGlobal;
// Same for mStreamHolder. mStreamHolder being nullptr means the stream is
// closed.
RefPtr<BodyStreamHolder> mStreamHolder;
nsCOMPtr<nsIEventTarget> mOwningEventTarget;
// Same as mGlobal but set to nullptr on OnInputStreamReady (on the owning
// thread).
RefPtr<Promise> mPullPromise;

// This is the original inputStream received during the CTOR. It will be
// converted into an nsIAsyncInputStream and stored into mInputStream at the
// first use.
nsCOMPtr<nsIInputStream> mOriginalInputStream;
nsCOMPtr<nsIAsyncInputStream> mInputStream;

RefPtr<StrongWorkerRef> mWorkerRef;
RefPtr<StrongWorkerRef> mAsyncWaitWorkerRef;
};

} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_BodyStream_h
1 change: 1 addition & 0 deletions dom/fetch/FetchStreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "FetchStreamReader.h"

#include "InternalResponse.h"
#include "js/Stream.h"
#include "jsapi.h"
#include "mozilla/ConsoleReportCollector.h"
#include "mozilla/ErrorResult.h"
Expand Down
1 change: 1 addition & 0 deletions dom/serviceworkers/test/browser_download_canceled.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ add_task(async function interruptedDownloads() {
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.exemptFromPerDomainMax", true],
["dom.serviceWorkers.testing.enabled", true],
["javascript.options.streams", true],
],
});

Expand Down
3 changes: 3 additions & 0 deletions dom/serviceworkers/test/test_fetch_event.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
["dom.serviceWorkers.exemptFromPerDomainMax", true],
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.testing.enabled", true],
["browser.opaqueResponseBlocking", true],
["browser.opaqueResponseBlocking.javascriptValidator", true]
["javascript.options.streams", true],
]}, runTest);
</script>
</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
["dom.serviceWorkers.exemptFromPerDomainMax", true],
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.testing.enabled", true],
["javascript.options.streams", true],
["network.cookie.cookieBehavior", COOKIE_BEHAVIOR_REJECTFOREIGN],
]}, runTest);
</script>
Expand Down
11 changes: 11 additions & 0 deletions dom/streams/ReadableStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ already_AddRefed<ReadableStream> ReadableStream::Constructor(
}

// Step 4.3
if (!StaticPrefs::dom_streams_byte_streams_enabled()) {
aRv.ThrowNotSupportedError("BYOB byte streams not yet supported.");
return nullptr;
}

SetUpReadableByteStreamControllerFromUnderlyingSource(
aGlobal.Context(), readableStream, underlyingSourceObj,
underlyingSourceDict, highWaterMark, aRv);
Expand Down Expand Up @@ -708,6 +713,12 @@ void ReadableStream::GetReader(const ReadableStreamGetReaderOptions& aOptions,
MOZ_ASSERT(aOptions.mMode.Value() == ReadableStreamReaderMode::Byob);

// Step 3. Return ? AcquireReadableStreamBYOBReader(this).
if (!StaticPrefs::dom_streams_byte_streams_enabled()) {
aRv.ThrowTypeError("BYOB byte streams reader not yet supported.");
return;
}

RefPtr<ReadableStream> thisRefPtr = this;
RefPtr<ReadableStreamBYOBReader> byobReader =
AcquireReadableStreamBYOBReader(this, aRv);
if (aRv.Failed()) {
Expand Down
2 changes: 1 addition & 1 deletion dom/webidl/ReadableByteStreamController.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* https://streams.spec.whatwg.org/#rbs-controller-class-definition
*/

[Exposed=*]
[Exposed=*, Pref="dom.streams.byte_streams.enabled"]
interface ReadableByteStreamController {
[Throws] // Throws on OOM
readonly attribute ReadableStreamBYOBRequest? byobRequest;
Expand Down
4 changes: 2 additions & 2 deletions dom/webidl/ReadableStream.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ interface ReadableStream {
[Throws]
ReadableStreamReader getReader(optional ReadableStreamGetReaderOptions options = {});

[Throws]
[Pref="dom.streams.transform_streams.enabled", Throws]
ReadableStream pipeThrough(ReadableWritablePair transform, optional StreamPipeOptions options = {});

[NewObject]
[Pref="dom.streams.pipeTo.enabled", NewObject]
Promise<undefined> pipeTo(WritableStream destination, optional StreamPipeOptions options = {});

[Throws]
Expand Down
2 changes: 1 addition & 1 deletion dom/webidl/ReadableStreamBYOBReader.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* https://streams.spec.whatwg.org/#byob-reader-class-definition
*/

[Exposed=*]
[Exposed=*, Pref="dom.streams.byte_streams.enabled"]
interface ReadableStreamBYOBReader {
[Throws]
constructor(ReadableStream stream);
Expand Down
2 changes: 1 addition & 1 deletion dom/webidl/ReadableStreamBYOBRequest.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* https://streams.spec.whatwg.org/#rs-byob-request-class-definition
*/

[Exposed=*]
[Exposed=*, Pref="dom.streams.byte_streams.enabled"]
interface ReadableStreamBYOBRequest {
readonly attribute ArrayBufferView? view;

Expand Down
2 changes: 1 addition & 1 deletion dom/webidl/ReadableStreamDefaultController.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* https://streams.spec.whatwg.org/#rs-default-controller-class-definition
*/

[Exposed=*]
[Exposed=*, Pref="dom.streams.readable_stream_default_controller.enabled"]
interface ReadableStreamDefaultController {
readonly attribute unrestricted double? desiredSize;

Expand Down
3 changes: 2 additions & 1 deletion dom/webidl/ReadableStreamDefaultReader.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ interface mixin ReadableStreamGenericReader {
Promise<undefined> cancel(optional any reason);
};

[Exposed=*]
[Exposed=*,
Pref="dom.streams.readable_stream_default_reader.enabled"]
interface ReadableStreamDefaultReader {
[Throws]
constructor(ReadableStream stream);
Expand Down
2 changes: 1 addition & 1 deletion dom/webidl/Response.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Response includes Body;
// This should be part of Body but we don't want to expose body to request yet.
// See bug 1387483.
partial interface Response {
[GetterThrows]
[GetterThrows, Pref="javascript.options.streams"]
readonly attribute ReadableStream? body;
};

Expand Down
Loading