| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,7 +26,7 @@ Last update: | |||
| 26 | 26 | - performance-timeline: https://github.com/web-platform-tests/wpt/tree/17ebc3aea0/performance-timeline | |
| 27 | 27 | - resource-timing: https://github.com/web-platform-tests/wpt/tree/22d38586d0/resource-timing | |
| 28 | 28 | - resources: https://github.com/web-platform-tests/wpt/tree/1e140d63ec/resources | |
| 29 | - - streams: https://github.com/web-platform-tests/wpt/tree/9b03282a99/streams | ||
| 29 | + - streams: https://github.com/web-platform-tests/wpt/tree/2bd26e124c/streams | ||
| 30 | 30 | - url: https://github.com/web-platform-tests/wpt/tree/6a39784534/url | |
| 31 | 31 | - user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing | |
| 32 | 32 | - wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -183,6 +183,46 @@ for (const reason of [null, undefined, error1]) { | |||
| 183 | 183 | }, `(reason: '${reason}') all pending writes should complete on abort`); | |
| 184 | 184 | } | |
| 185 | 185 | ||
| 186 | + for (const reason of [null, undefined, error1]) { | ||
| 187 | + promise_test(async t => { | ||
| 188 | + let rejectPull; | ||
| 189 | + const pullPromise = new Promise((_, reject) => { | ||
| 190 | + rejectPull = reject; | ||
| 191 | + }); | ||
| 192 | + let rejectCancel; | ||
| 193 | + const cancelPromise = new Promise((_, reject) => { | ||
| 194 | + rejectCancel = reject; | ||
| 195 | + }); | ||
| 196 | + const rs = recordingReadableStream({ | ||
| 197 | + async pull() { | ||
| 198 | + await Promise.race([ | ||
| 199 | + pullPromise, | ||
| 200 | + cancelPromise, | ||
| 201 | + ]); | ||
| 202 | + }, | ||
| 203 | + cancel(reason) { | ||
| 204 | + rejectCancel(reason); | ||
| 205 | + }, | ||
| 206 | + }); | ||
| 207 | + const ws = new WritableStream(); | ||
| 208 | + const abortController = new AbortController(); | ||
| 209 | + const signal = abortController.signal; | ||
| 210 | + const pipeToPromise = rs.pipeTo(ws, { signal }); | ||
| 211 | + pipeToPromise.catch(() => {}); // Prevent unhandled rejection. | ||
| 212 | + await delay(0); | ||
| 213 | + abortController.abort(reason); | ||
| 214 | + rejectPull('should not catch pull rejection'); | ||
| 215 | + await delay(0); | ||
| 216 | + assert_equals(rs.eventsWithoutPulls.length, 2, 'cancel should have been called'); | ||
| 217 | + assert_equals(rs.eventsWithoutPulls[0], 'cancel', 'first event should be cancel'); | ||
| 218 | + if (reason !== undefined) { | ||
| 219 | + await promise_rejects_exactly(t, reason, pipeToPromise, 'pipeTo rejects with abort reason'); | ||
| 220 | + } else { | ||
| 221 | + await promise_rejects_dom(t, 'AbortError', pipeToPromise, 'pipeTo rejects with AbortError'); | ||
| 222 | + } | ||
| 223 | + }, `(reason: '${reason}') underlyingSource.cancel() should called when abort, even with pending pull`); | ||
| 224 | + } | ||
| 225 | + | ||
| 186 | 226 | promise_test(t => { | |
| 187 | 227 | const rs = new ReadableStream({ | |
| 188 | 228 | pull(controller) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -234,3 +234,28 @@ promise_test(() => { | |||
| 234 | 234 | return Promise.all([rs.cancel(), rs.getReader().closed]); | |
| 235 | 235 | ||
| 236 | 236 | }, 'ReadableStream cancellation: cancelling before start finishes should prevent pull() from being called'); | |
| 237 | + | ||
| 238 | + promise_test(async () => { | ||
| 239 | + | ||
| 240 | + const events = []; | ||
| 241 | + | ||
| 242 | + const pendingPromise = new Promise(() => {}); | ||
| 243 | + | ||
| 244 | + const rs = new ReadableStream({ | ||
| 245 | + pull() { | ||
| 246 | + events.push('pull'); | ||
| 247 | + return pendingPromise; | ||
| 248 | + }, | ||
| 249 | + cancel() { | ||
| 250 | + events.push('cancel'); | ||
| 251 | + } | ||
| 252 | + }); | ||
| 253 | + | ||
| 254 | + const reader = rs.getReader(); | ||
| 255 | + reader.read().catch(() => {}); // No await. | ||
| 256 | + await delay(0); | ||
| 257 | + await Promise.all([reader.cancel(), reader.closed]); | ||
| 258 | + | ||
| 259 | + assert_array_equals(events, ['pull', 'cancel'], 'cancel should have been called'); | ||
| 260 | + | ||
| 261 | + }, 'ReadableStream cancellation: underlyingSource.cancel() should called, even with pending pull'); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,44 +51,50 @@ const iterableFactories = [ | |||
| 51 | 51 | ||
| 52 | 52 | ['a sync iterable of values', () => { | |
| 53 | 53 | const chunks = ['a', 'b']; | |
| 54 | - const it = { | ||
| 54 | + const iterator = { | ||
| 55 | 55 | next() { | |
| 56 | 56 | return { | |
| 57 | 57 | done: chunks.length === 0, | |
| 58 | 58 | value: chunks.shift() | |
| 59 | 59 | }; | |
| 60 | - }, | ||
| 61 | - [Symbol.iterator]: () => it | ||
| 60 | + } | ||
| 61 | + }; | ||
| 62 | + const iterable = { | ||
| 63 | + [Symbol.iterator]: () => iterator | ||
| 62 | 64 | }; | |
| 63 | - return it; | ||
| 65 | + return iterable; | ||
| 64 | 66 | }], | |
| 65 | 67 | ||
| 66 | 68 | ['a sync iterable of promises', () => { | |
| 67 | 69 | const chunks = ['a', 'b']; | |
| 68 | - const it = { | ||
| 70 | + const iterator = { | ||
| 69 | 71 | next() { | |
| 70 | 72 | return chunks.length === 0 ? { done: true } : { | |
| 71 | 73 | done: false, | |
| 72 | 74 | value: Promise.resolve(chunks.shift()) | |
| 73 | 75 | }; | |
| 74 | - }, | ||
| 75 | - [Symbol.iterator]: () => it | ||
| 76 | + } | ||
| 77 | + }; | ||
| 78 | + const iterable = { | ||
| 79 | + [Symbol.iterator]: () => iterator | ||
| 76 | 80 | }; | |
| 77 | - return it; | ||
| 81 | + return iterable; | ||
| 78 | 82 | }], | |
| 79 | 83 | ||
| 80 | 84 | ['an async iterable', () => { | |
| 81 | 85 | const chunks = ['a', 'b']; | |
| 82 | - const it = { | ||
| 86 | + const asyncIterator = { | ||
| 83 | 87 | next() { | |
| 84 | 88 | return Promise.resolve({ | |
| 85 | 89 | done: chunks.length === 0, | |
| 86 | 90 | value: chunks.shift() | |
| 87 | 91 | }) | |
| 88 | - }, | ||
| 89 | - [Symbol.asyncIterator]: () => it | ||
| 92 | + } | ||
| 93 | + }; | ||
| 94 | + const asyncIterable = { | ||
| 95 | + [Symbol.asyncIterator]: () => asyncIterator | ||
| 90 | 96 | }; | |
| 91 | - return it; | ||
| 97 | + return asyncIterable; | ||
| 92 | 98 | }], | |
| 93 | 99 | ||
| 94 | 100 | ['a ReadableStream', () => { | |
@@ -186,6 +192,18 @@ test(t => { | |||
| 186 | 192 | assert_throws_exactly(theError, () => ReadableStream.from(iterable), 'from() should re-throw the error'); | |
| 187 | 193 | }, `ReadableStream.from ignores @@iterator if @@asyncIterator exists`); | |
| 188 | 194 | ||
| 195 | + test(() => { | ||
| 196 | + const theError = new Error('a unique string'); | ||
| 197 | + const iterable = { | ||
| 198 | + [Symbol.asyncIterator]: null, | ||
| 199 | + [Symbol.iterator]() { | ||
| 200 | + throw theError | ||
| 201 | + } | ||
| 202 | + }; | ||
| 203 | + | ||
| 204 | + assert_throws_exactly(theError, () => ReadableStream.from(iterable), 'from() should re-throw the error'); | ||
| 205 | + }, `ReadableStream.from ignores a null @@asyncIterator`); | ||
| 206 | + | ||
| 189 | 207 | promise_test(async () => { | |
| 190 | 208 | ||
| 191 | 209 | const iterable = { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,7 +64,7 @@ | |||
| 64 | 64 | "path": "resources" | |
| 65 | 65 | }, | |
| 66 | 66 | "streams": { | |
| 67 | - "commit": "9b03282a99ef2314c1c2d5050a105a74a2940019", | ||
| 67 | + "commit": "2bd26e124cf17b2f0a25c150794d640b07b2a870", | ||
| 68 | 68 | "path": "streams" | |
| 69 | 69 | }, | |
| 70 | 70 | "url": { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,13 @@ | |||
| 16 | 16 | "readable-streams/cross-realm-crash.window.js": { | |
| 17 | 17 | "skip": "Browser-specific test" | |
| 18 | 18 | }, | |
| 19 | + "readable-streams/from.any.js": { | ||
| 20 | + "fail": { | ||
| 21 | + "expected": [ | ||
| 22 | + "ReadableStream.from ignores a null @@asyncIterator" | ||
| 23 | + ] | ||
| 24 | + } | ||
| 25 | + }, | ||
| 19 | 26 | "readable-streams/owning-type-message-port.any.js": { | |
| 20 | 27 | "fail": { | |
| 21 | 28 | "note": "Readable streams with type owning are not yet supported", | |
@@ -40,6 +47,9 @@ | |||
| 40 | 47 | ] | |
| 41 | 48 | } | |
| 42 | 49 | }, | |
| 50 | + "readable-streams/read-task-handling.window.js": { | ||
| 51 | + "skip": "Browser-specific test" | ||
| 52 | + }, | ||
| 43 | 53 | "transferable/deserialize-error.window.js": { | |
| 44 | 54 | "skip": "Browser-specific test" | |
| 45 | 55 | }, | |
@@ -56,8 +66,5 @@ | |||
| 56 | 66 | }, | |
| 57 | 67 | "transform-streams/invalid-realm.tentative.window.js": { | |
| 58 | 68 | "skip": "Browser-specific test" | |
| 59 | - }, | ||
| 60 | - "readable-streams/read-task-handling.window.js": { | ||
| 61 | - "skip": "Browser-specific test" | ||
| 62 | 69 | } | |
| 63 | 70 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments