-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
68 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// META: global=window,worker | ||
// META: script=../resources/test-utils.js | ||
// META: script=../resources/rs-utils.js | ||
'use strict'; | ||
|
||
test(() => { | ||
new ReadableStream({ type: 'owning' }); // ReadableStream constructed with 'owning' type | ||
}, 'ReadableStream can be constructed with owning type'); | ||
|
||
test(() => { | ||
let startCalled = false; | ||
|
||
const source = { | ||
start(controller) { | ||
assert_equals(this, source, 'source is this during start'); | ||
assert_true(controller instanceof ReadableStreamDefaultController, 'default controller'); | ||
startCalled = true; | ||
}, | ||
type: 'owning' | ||
}; | ||
|
||
new ReadableStream(source); | ||
assert_true(startCalled); | ||
}, 'ReadableStream of type owning should call start with a ReadableStreamDefaultController'); | ||
|
||
promise_test(async () => { | ||
const uint8Array = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]); | ||
const buffer = uint8Array.buffer; | ||
buffer.test = 1; | ||
const source = { | ||
start(controller) { | ||
assert_equals(buffer.byteLength, 8); | ||
controller.enqueue(buffer, { transfer : [ buffer ] }); | ||
assert_equals(buffer.test, 1); | ||
}, | ||
type: 'owning' | ||
}; | ||
|
||
const stream = new ReadableStream(source); | ||
const reader = stream.getReader(); | ||
|
||
const chunk = await reader.read(); | ||
|
||
assert_not_equals(chunk.value, buffer); | ||
assert_equals(chunk.value.byteLength, 8); | ||
assert_equals(chunk.value.test, undefined); | ||
}, 'ReadableStream of type owning should transfer enqueued chunks'); |
Oops, something went wrong.
b388278
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh oh! Looks like an error! Details
HttpError: Invalid request.
Only 65535 characters are allowed; 85636 were supplied.