Best JavaScript code snippet using wpt
error-propagation-forward.any.js
Source:error-propagation-forward.any.js
1// META: global=worker,jsshell2// META: script=../resources/test-utils.js3// META: script=../resources/recording-streams.js4'use strict';5const error1 = new Error('error1!');6error1.name = 'error1';7const error2 = new Error('error2!');8error2.name = 'error2';9promise_test(t => {10 const rs = recordingReadableStream({11 start() {12 return Promise.reject(error1);13 }14 });15 const ws = recordingWritableStream();16 return promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the same error')17 .then(() => {18 assert_array_equals(rs.events, []);19 assert_array_equals(ws.events, ['abort', error1]);20 });21}, 'Errors must be propagated forward: starts errored; preventAbort = false; fulfilled abort promise');22promise_test(t => {23 const rs = recordingReadableStream({24 start() {25 return Promise.reject(error1);26 }27 });28 const ws = recordingWritableStream({29 abort() {30 throw error2;31 }32 });33 return promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must reject with the abort error')34 .then(() => {35 assert_array_equals(rs.events, []);36 assert_array_equals(ws.events, ['abort', error1]);37 });38}, 'Errors must be propagated forward: starts errored; preventAbort = false; rejected abort promise');39for (const falsy of [undefined, null, false, +0, -0, NaN, '']) {40 const stringVersion = Object.is(falsy, -0) ? '-0' : String(falsy);41 promise_test(t => {42 const rs = recordingReadableStream({43 start() {44 return Promise.reject(error1);45 }46 });47 const ws = recordingWritableStream();48 return promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: falsy }), 'pipeTo must reject with the same error')49 .then(() => {50 assert_array_equals(rs.events, []);51 assert_array_equals(ws.events, ['abort', error1]);52 });53 }, `Errors must be propagated forward: starts errored; preventAbort = ${stringVersion} (falsy); fulfilled abort ` +54 `promise`);55}56for (const truthy of [true, 'a', 1, Symbol(), { }]) {57 promise_test(t => {58 const rs = recordingReadableStream({59 start() {60 return Promise.reject(error1);61 }62 });63 const ws = recordingWritableStream();64 return promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: truthy }),65 'pipeTo must reject with the same error')66 .then(() => {67 assert_array_equals(rs.events, []);68 assert_array_equals(ws.events, []);69 });70 }, `Errors must be propagated forward: starts errored; preventAbort = ${String(truthy)} (truthy)`);71}72promise_test(t => {73 const rs = recordingReadableStream({74 start() {75 return Promise.reject(error1);76 }77 });78 const ws = recordingWritableStream();79 return promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: true, preventCancel: true }),80 'pipeTo must reject with the same error')81 .then(() => {82 assert_array_equals(rs.events, []);83 assert_array_equals(ws.events, []);84 });85}, 'Errors must be propagated forward: starts errored; preventAbort = true, preventCancel = true');86promise_test(t => {87 const rs = recordingReadableStream({88 start() {89 return Promise.reject(error1);90 }91 });92 const ws = recordingWritableStream();93 return promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: true, preventCancel: true, preventClose: true }),94 'pipeTo must reject with the same error')95 .then(() => {96 assert_array_equals(rs.events, []);97 assert_array_equals(ws.events, []);98 });99}, 'Errors must be propagated forward: starts errored; preventAbort = true, preventCancel = true, preventClose = true');100promise_test(t => {101 const rs = recordingReadableStream();102 const ws = recordingWritableStream();103 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the same error');104 t.step_timeout(() => rs.controller.error(error1), 10);105 return pipePromise.then(() => {106 assert_array_equals(rs.eventsWithoutPulls, []);107 assert_array_equals(ws.events, ['abort', error1]);108 });109}, 'Errors must be propagated forward: becomes errored while empty; preventAbort = false; fulfilled abort promise');110promise_test(t => {111 const rs = recordingReadableStream();112 const ws = recordingWritableStream({113 abort() {114 throw error2;115 }116 });117 const pipePromise = promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must reject with the abort error');118 t.step_timeout(() => rs.controller.error(error1), 10);119 return pipePromise.then(() => {120 assert_array_equals(rs.eventsWithoutPulls, []);121 assert_array_equals(ws.events, ['abort', error1]);122 });123}, 'Errors must be propagated forward: becomes errored while empty; preventAbort = false; rejected abort promise');124promise_test(t => {125 const rs = recordingReadableStream();126 const ws = recordingWritableStream();127 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: true }),128 'pipeTo must reject with the same error');129 t.step_timeout(() => rs.controller.error(error1), 10);130 return pipePromise.then(() => {131 assert_array_equals(rs.eventsWithoutPulls, []);132 assert_array_equals(ws.events, []);133 });134}, 'Errors must be propagated forward: becomes errored while empty; preventAbort = true');135promise_test(t => {136 const rs = recordingReadableStream();137 const ws = recordingWritableStream(undefined, new CountQueuingStrategy({ highWaterMark: 0 }));138 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the same error');139 t.step_timeout(() => rs.controller.error(error1), 10);140 return pipePromise.then(() => {141 assert_array_equals(rs.eventsWithoutPulls, []);142 assert_array_equals(ws.events, ['abort', error1]);143 });144}, 'Errors must be propagated forward: becomes errored while empty; dest never desires chunks; ' +145 'preventAbort = false; fulfilled abort promise');146promise_test(t => {147 const rs = recordingReadableStream();148 const ws = recordingWritableStream({149 abort() {150 throw error2;151 }152 }, new CountQueuingStrategy({ highWaterMark: 0 }));153 const pipePromise = promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must reject with the abort error');154 t.step_timeout(() => rs.controller.error(error1), 10);155 return pipePromise.then(() => {156 assert_array_equals(rs.eventsWithoutPulls, []);157 assert_array_equals(ws.events, ['abort', error1]);158 });159}, 'Errors must be propagated forward: becomes errored while empty; dest never desires chunks; ' +160 'preventAbort = false; rejected abort promise');161promise_test(t => {162 const rs = recordingReadableStream();163 const ws = recordingWritableStream(undefined, new CountQueuingStrategy({ highWaterMark: 0 }));164 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: true }),165 'pipeTo must reject with the same error');166 t.step_timeout(() => rs.controller.error(error1), 10);167 return pipePromise.then(() => {168 assert_array_equals(rs.eventsWithoutPulls, []);169 assert_array_equals(ws.events, []);170 });171}, 'Errors must be propagated forward: becomes errored while empty; dest never desires chunks; ' +172 'preventAbort = true');173promise_test(t => {174 const rs = recordingReadableStream();175 const ws = recordingWritableStream();176 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the same error');177 t.step_timeout(() => {178 rs.controller.enqueue('Hello');179 t.step_timeout(() => rs.controller.error(error1), 10);180 }, 10);181 return pipePromise.then(() => {182 assert_array_equals(rs.eventsWithoutPulls, []);183 assert_array_equals(ws.events, ['write', 'Hello', 'abort', error1]);184 });185}, 'Errors must be propagated forward: becomes errored after one chunk; preventAbort = false; fulfilled abort promise');186promise_test(t => {187 const rs = recordingReadableStream();188 const ws = recordingWritableStream({189 abort() {190 throw error2;191 }192 });193 const pipePromise = promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must reject with the abort error');194 t.step_timeout(() => {195 rs.controller.enqueue('Hello');196 t.step_timeout(() => rs.controller.error(error1), 10);197 }, 10);198 return pipePromise.then(() => {199 assert_array_equals(rs.eventsWithoutPulls, []);200 assert_array_equals(ws.events, ['write', 'Hello', 'abort', error1]);201 });202}, 'Errors must be propagated forward: becomes errored after one chunk; preventAbort = false; rejected abort promise');203promise_test(t => {204 const rs = recordingReadableStream();205 const ws = recordingWritableStream();206 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: true }),207 'pipeTo must reject with the same error');208 t.step_timeout(() => {209 rs.controller.enqueue('Hello');210 t.step_timeout(() => rs.controller.error(error1), 10);211 }, 10);212 return pipePromise.then(() => {213 assert_array_equals(rs.eventsWithoutPulls, []);214 assert_array_equals(ws.events, ['write', 'Hello']);215 });216}, 'Errors must be propagated forward: becomes errored after one chunk; preventAbort = true');217promise_test(t => {218 const rs = recordingReadableStream();219 const ws = recordingWritableStream(undefined, new CountQueuingStrategy({ highWaterMark: 0 }));220 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the same error');221 t.step_timeout(() => {222 rs.controller.enqueue('Hello');223 t.step_timeout(() => rs.controller.error(error1), 10);224 }, 10);225 return pipePromise.then(() => {226 assert_array_equals(rs.eventsWithoutPulls, []);227 assert_array_equals(ws.events, ['abort', error1]);228 });229}, 'Errors must be propagated forward: becomes errored after one chunk; dest never desires chunks; ' +230 'preventAbort = false; fulfilled abort promise');231promise_test(t => {232 const rs = recordingReadableStream();233 const ws = recordingWritableStream({234 abort() {235 throw error2;236 }237 }, new CountQueuingStrategy({ highWaterMark: 0 }));238 const pipePromise = promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must reject with the abort error');239 t.step_timeout(() => {240 rs.controller.enqueue('Hello');241 t.step_timeout(() => rs.controller.error(error1), 10);242 }, 10);243 return pipePromise.then(() => {244 assert_array_equals(rs.eventsWithoutPulls, []);245 assert_array_equals(ws.events, ['abort', error1]);246 });247}, 'Errors must be propagated forward: becomes errored after one chunk; dest never desires chunks; ' +248 'preventAbort = false; rejected abort promise');249promise_test(t => {250 const rs = recordingReadableStream();251 const ws = recordingWritableStream(undefined, new CountQueuingStrategy({ highWaterMark: 0 }));252 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: true }),253 'pipeTo must reject with the same error');254 t.step_timeout(() => {255 rs.controller.enqueue('Hello');256 t.step_timeout(() => rs.controller.error(error1), 10);257 }, 10);258 return pipePromise.then(() => {259 assert_array_equals(rs.eventsWithoutPulls, []);260 assert_array_equals(ws.events, []);261 });262}, 'Errors must be propagated forward: becomes errored after one chunk; dest never desires chunks; ' +263 'preventAbort = true');264promise_test(t => {265 const rs = recordingReadableStream();266 let resolveWriteCalled;267 const writeCalledPromise = new Promise(resolve => {268 resolveWriteCalled = resolve;269 });270 let resolveWritePromise;271 const ws = recordingWritableStream({272 write() {273 resolveWriteCalled();274 return new Promise(resolve => {275 resolveWritePromise = resolve;276 });277 }278 });279 let pipeComplete = false;280 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws)).then(() => {281 pipeComplete = true;282 });283 rs.controller.enqueue('a');284 return writeCalledPromise.then(() => {285 rs.controller.error(error1);286 // Flush async events and verify that no shutdown occurs.287 return flushAsyncEvents();288 }).then(() => {289 assert_array_equals(ws.events, ['write', 'a']); // no 'abort'290 assert_equals(pipeComplete, false, 'the pipe must not be complete');291 resolveWritePromise();292 return pipePromise.then(() => {293 assert_array_equals(ws.events, ['write', 'a', 'abort', error1]);294 });295 });296}, 'Errors must be propagated forward: shutdown must not occur until the final write completes');297promise_test(t => {298 const rs = recordingReadableStream();299 let resolveWriteCalled;300 const writeCalledPromise = new Promise(resolve => {301 resolveWriteCalled = resolve;302 });303 let resolveWritePromise;304 const ws = recordingWritableStream({305 write() {306 resolveWriteCalled();307 return new Promise(resolve => {308 resolveWritePromise = resolve;309 });310 }311 });312 let pipeComplete = false;313 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: true })).then(() => {314 pipeComplete = true;315 });316 rs.controller.enqueue('a');317 return writeCalledPromise.then(() => {318 rs.controller.error(error1);319 // Flush async events and verify that no shutdown occurs.320 return flushAsyncEvents();321 }).then(() => {322 assert_array_equals(ws.events, ['write', 'a']); // no 'abort'323 assert_equals(pipeComplete, false, 'the pipe must not be complete');324 resolveWritePromise();325 return pipePromise;326 }).then(() => flushAsyncEvents()).then(() => {327 assert_array_equals(ws.events, ['write', 'a']); // no 'abort'328 });329}, 'Errors must be propagated forward: shutdown must not occur until the final write completes; preventAbort = true');330promise_test(t => {331 const rs = recordingReadableStream();332 let resolveWriteCalled;333 const writeCalledPromise = new Promise(resolve => {334 resolveWriteCalled = resolve;335 });336 let resolveWritePromise;337 const ws = recordingWritableStream({338 write() {339 resolveWriteCalled();340 return new Promise(resolve => {341 resolveWritePromise = resolve;342 });343 }344 }, new CountQueuingStrategy({ highWaterMark: 2 }));345 let pipeComplete = false;346 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws)).then(() => {347 pipeComplete = true;348 });349 rs.controller.enqueue('a');350 rs.controller.enqueue('b');351 return writeCalledPromise.then(() => flushAsyncEvents()).then(() => {352 assert_array_equals(ws.events, ['write', 'a'],353 'the first chunk must have been written, but abort must not have happened yet');354 assert_false(pipeComplete, 'the pipe should not complete while the first write is pending');355 rs.controller.error(error1);356 resolveWritePromise();357 return flushAsyncEvents();358 }).then(() => {359 assert_array_equals(ws.events, ['write', 'a', 'write', 'b'],360 'the second chunk must have been written, but abort must not have happened yet');361 assert_false(pipeComplete, 'the pipe should not complete while the second write is pending');362 resolveWritePromise();363 return pipePromise;364 }).then(() => {365 assert_array_equals(ws.events, ['write', 'a', 'write', 'b', 'abort', error1],366 'all chunks must have been written and abort must have happened');367 });368}, 'Errors must be propagated forward: shutdown must not occur until the final write completes; becomes errored after first write');369promise_test(t => {370 const rs = recordingReadableStream();371 let resolveWriteCalled;372 const writeCalledPromise = new Promise(resolve => {373 resolveWriteCalled = resolve;374 });375 let resolveWritePromise;376 const ws = recordingWritableStream({377 write() {378 resolveWriteCalled();379 return new Promise(resolve => {380 resolveWritePromise = resolve;381 });382 }383 }, new CountQueuingStrategy({ highWaterMark: 2 }));384 let pipeComplete = false;385 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: true })).then(() => {386 pipeComplete = true;387 });388 rs.controller.enqueue('a');389 rs.controller.enqueue('b');390 return writeCalledPromise.then(() => flushAsyncEvents()).then(() => {391 assert_array_equals(ws.events, ['write', 'a'],392 'the first chunk must have been written, but abort must not have happened');393 assert_false(pipeComplete, 'the pipe should not complete while the first write is pending');394 rs.controller.error(error1);395 resolveWritePromise();396 }).then(() => flushAsyncEvents()).then(() => {397 assert_array_equals(ws.events, ['write', 'a', 'write', 'b'],398 'the second chunk must have been written, but abort must not have happened');399 assert_false(pipeComplete, 'the pipe should not complete while the second write is pending');400 resolveWritePromise();401 return pipePromise;402 }).then(() => flushAsyncEvents()).then(() => {403 assert_array_equals(ws.events, ['write', 'a', 'write', 'b'],404 'all chunks must have been written, but abort must not have happened');405 });...
error-propagation-forward.js
Source:error-propagation-forward.js
1'use strict';2if (self.importScripts) {3 self.importScripts('/resources/testharness.js');4 self.importScripts('../resources/test-utils.js');5 self.importScripts('../resources/recording-streams.js');6}7const error1 = new Error('error1!');8error1.name = 'error1';9const error2 = new Error('error2!');10error2.name = 'error2';11promise_test(t => {12 const rs = recordingReadableStream({13 start() {14 return Promise.reject(error1);15 }16 });17 const ws = recordingWritableStream();18 return promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the same error')19 .then(() => {20 assert_array_equals(rs.events, []);21 assert_array_equals(ws.events, ['abort', error1]);22 });23}, 'Errors must be propagated forward: starts errored; preventAbort = false; fulfilled abort promise');24promise_test(t => {25 const rs = recordingReadableStream({26 start() {27 return Promise.reject(error1);28 }29 });30 const ws = recordingWritableStream({31 abort() {32 throw error2;33 }34 });35 return promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must reject with the abort error')36 .then(() => {37 assert_array_equals(rs.events, []);38 assert_array_equals(ws.events, ['abort', error1]);39 });40}, 'Errors must be propagated forward: starts errored; preventAbort = false; rejected abort promise');41for (const falsy of [undefined, null, false, +0, -0, NaN, '']) {42 const stringVersion = Object.is(falsy, -0) ? '-0' : String(falsy);43 promise_test(t => {44 const rs = recordingReadableStream({45 start() {46 return Promise.reject(error1);47 }48 });49 const ws = recordingWritableStream();50 return promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: falsy }), 'pipeTo must reject with the same error')51 .then(() => {52 assert_array_equals(rs.events, []);53 assert_array_equals(ws.events, ['abort', error1]);54 });55 }, `Errors must be propagated forward: starts errored; preventAbort = ${stringVersion} (falsy); fulfilled abort ` +56 `promise`);57}58for (const truthy of [true, 'a', 1, Symbol(), { }]) {59 promise_test(t => {60 const rs = recordingReadableStream({61 start() {62 return Promise.reject(error1);63 }64 });65 const ws = recordingWritableStream();66 return promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: truthy }),67 'pipeTo must reject with the same error')68 .then(() => {69 assert_array_equals(rs.events, []);70 assert_array_equals(ws.events, []);71 });72 }, `Errors must be propagated forward: starts errored; preventAbort = ${String(truthy)} (truthy)`);73}74promise_test(t => {75 const rs = recordingReadableStream({76 start() {77 return Promise.reject(error1);78 }79 });80 const ws = recordingWritableStream();81 return promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: true, preventCancel: true }),82 'pipeTo must reject with the same error')83 .then(() => {84 assert_array_equals(rs.events, []);85 assert_array_equals(ws.events, []);86 });87}, 'Errors must be propagated forward: starts errored; preventAbort = true, preventCancel = true');88promise_test(t => {89 const rs = recordingReadableStream({90 start() {91 return Promise.reject(error1);92 }93 });94 const ws = recordingWritableStream();95 return promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: true, preventCancel: true, preventClose: true }),96 'pipeTo must reject with the same error')97 .then(() => {98 assert_array_equals(rs.events, []);99 assert_array_equals(ws.events, []);100 });101}, 'Errors must be propagated forward: starts errored; preventAbort = true, preventCancel = true, preventClose = true');102promise_test(t => {103 const rs = recordingReadableStream();104 const ws = recordingWritableStream();105 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the same error');106 setTimeout(() => rs.controller.error(error1), 10);107 return pipePromise.then(() => {108 assert_array_equals(rs.eventsWithoutPulls, []);109 assert_array_equals(ws.events, ['abort', error1]);110 });111}, 'Errors must be propagated forward: becomes errored while empty; preventAbort = false; fulfilled abort promise');112promise_test(t => {113 const rs = recordingReadableStream();114 const ws = recordingWritableStream({115 abort() {116 throw error2;117 }118 });119 const pipePromise = promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must reject with the abort error');120 setTimeout(() => rs.controller.error(error1), 10);121 return pipePromise.then(() => {122 assert_array_equals(rs.eventsWithoutPulls, []);123 assert_array_equals(ws.events, ['abort', error1]);124 });125}, 'Errors must be propagated forward: becomes errored while empty; preventAbort = false; rejected abort promise');126promise_test(t => {127 const rs = recordingReadableStream();128 const ws = recordingWritableStream();129 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: true }),130 'pipeTo must reject with the same error');131 setTimeout(() => rs.controller.error(error1), 10);132 return pipePromise.then(() => {133 assert_array_equals(rs.eventsWithoutPulls, []);134 assert_array_equals(ws.events, []);135 });136}, 'Errors must be propagated forward: becomes errored while empty; preventAbort = true');137promise_test(t => {138 const rs = recordingReadableStream();139 const ws = recordingWritableStream(undefined, new CountQueuingStrategy({ highWaterMark: 0 }));140 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the same error');141 setTimeout(() => rs.controller.error(error1), 10);142 return pipePromise.then(() => {143 assert_array_equals(rs.eventsWithoutPulls, []);144 assert_array_equals(ws.events, ['abort', error1]);145 });146}, 'Errors must be propagated forward: becomes errored while empty; dest never desires chunks; ' +147 'preventAbort = false; fulfilled abort promise');148promise_test(t => {149 const rs = recordingReadableStream();150 const ws = recordingWritableStream({151 abort() {152 throw error2;153 }154 }, new CountQueuingStrategy({ highWaterMark: 0 }));155 const pipePromise = promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must reject with the abort error');156 setTimeout(() => rs.controller.error(error1), 10);157 return pipePromise.then(() => {158 assert_array_equals(rs.eventsWithoutPulls, []);159 assert_array_equals(ws.events, ['abort', error1]);160 });161}, 'Errors must be propagated forward: becomes errored while empty; dest never desires chunks; ' +162 'preventAbort = false; rejected abort promise');163promise_test(t => {164 const rs = recordingReadableStream();165 const ws = recordingWritableStream(undefined, new CountQueuingStrategy({ highWaterMark: 0 }));166 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: true }),167 'pipeTo must reject with the same error');168 setTimeout(() => rs.controller.error(error1), 10);169 return pipePromise.then(() => {170 assert_array_equals(rs.eventsWithoutPulls, []);171 assert_array_equals(ws.events, []);172 });173}, 'Errors must be propagated forward: becomes errored while empty; dest never desires chunks; ' +174 'preventAbort = true');175promise_test(t => {176 const rs = recordingReadableStream();177 const ws = recordingWritableStream();178 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the same error');179 setTimeout(() => {180 rs.controller.enqueue('Hello');181 setTimeout(() => rs.controller.error(error1), 10);182 }, 10);183 return pipePromise.then(() => {184 assert_array_equals(rs.eventsWithoutPulls, []);185 assert_array_equals(ws.events, ['write', 'Hello', 'abort', error1]);186 });187}, 'Errors must be propagated forward: becomes errored after one chunk; preventAbort = false; fulfilled abort promise');188promise_test(t => {189 const rs = recordingReadableStream();190 const ws = recordingWritableStream({191 abort() {192 throw error2;193 }194 });195 const pipePromise = promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must reject with the abort error');196 setTimeout(() => {197 rs.controller.enqueue('Hello');198 setTimeout(() => rs.controller.error(error1), 10);199 }, 10);200 return pipePromise.then(() => {201 assert_array_equals(rs.eventsWithoutPulls, []);202 assert_array_equals(ws.events, ['write', 'Hello', 'abort', error1]);203 });204}, 'Errors must be propagated forward: becomes errored after one chunk; preventAbort = false; rejected abort promise');205promise_test(t => {206 const rs = recordingReadableStream();207 const ws = recordingWritableStream();208 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: true }),209 'pipeTo must reject with the same error');210 setTimeout(() => {211 rs.controller.enqueue('Hello');212 setTimeout(() => rs.controller.error(error1), 10);213 }, 10);214 return pipePromise.then(() => {215 assert_array_equals(rs.eventsWithoutPulls, []);216 assert_array_equals(ws.events, ['write', 'Hello']);217 });218}, 'Errors must be propagated forward: becomes errored after one chunk; preventAbort = true');219promise_test(t => {220 const rs = recordingReadableStream();221 const ws = recordingWritableStream(undefined, new CountQueuingStrategy({ highWaterMark: 0 }));222 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the same error');223 setTimeout(() => {224 rs.controller.enqueue('Hello');225 setTimeout(() => rs.controller.error(error1), 10);226 }, 10);227 return pipePromise.then(() => {228 assert_array_equals(rs.eventsWithoutPulls, []);229 assert_array_equals(ws.events, ['abort', error1]);230 });231}, 'Errors must be propagated forward: becomes errored after one chunk; dest never desires chunks; ' +232 'preventAbort = false; fulfilled abort promise');233promise_test(t => {234 const rs = recordingReadableStream();235 const ws = recordingWritableStream({236 abort() {237 throw error2;238 }239 }, new CountQueuingStrategy({ highWaterMark: 0 }));240 const pipePromise = promise_rejects(t, error2, rs.pipeTo(ws), 'pipeTo must reject with the abort error');241 setTimeout(() => {242 rs.controller.enqueue('Hello');243 setTimeout(() => rs.controller.error(error1), 10);244 }, 10);245 return pipePromise.then(() => {246 assert_array_equals(rs.eventsWithoutPulls, []);247 assert_array_equals(ws.events, ['abort', error1]);248 });249}, 'Errors must be propagated forward: becomes errored after one chunk; dest never desires chunks; ' +250 'preventAbort = false; rejected abort promise');251promise_test(t => {252 const rs = recordingReadableStream();253 const ws = recordingWritableStream(undefined, new CountQueuingStrategy({ highWaterMark: 0 }));254 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws, { preventAbort: true }),255 'pipeTo must reject with the same error');256 setTimeout(() => {257 rs.controller.enqueue('Hello');258 setTimeout(() => rs.controller.error(error1), 10);259 }, 10);260 return pipePromise.then(() => {261 assert_array_equals(rs.eventsWithoutPulls, []);262 assert_array_equals(ws.events, []);263 });264}, 'Errors must be propagated forward: becomes errored after one chunk; dest never desires chunks; ' +265 'preventAbort = true');266promise_test(t => {267 const rs = recordingReadableStream();268 let resolveWriteCalled;269 const writeCalledPromise = new Promise(resolve => {270 resolveWriteCalled = resolve;271 });272 let resolveWritePromise;273 const ws = recordingWritableStream({274 write() {275 resolveWriteCalled();276 return new Promise(resolve => {277 resolveWritePromise = resolve;278 });279 }280 });281 let pipeComplete = false;282 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws)).then(() => {283 pipeComplete = true;284 });285 rs.controller.enqueue('a');286 return writeCalledPromise.then(() => {287 rs.controller.error(error1);288 // Flush async events and verify that no shutdown occurs.289 return flushAsyncEvents();290 }).then(() => {291 assert_array_equals(ws.events, ['write', 'a']); // no 'abort'292 assert_equals(pipeComplete, false, 'the pipe must not be complete');293 resolveWritePromise();294 return pipePromise.then(() => {295 assert_array_equals(ws.events, ['write', 'a', 'abort', error1]);296 });297 });298}, 'Errors must be propagated forward: shutdown must not occur until the final write completes');...
Using AI Code Generation
1wpt.preventAbort();2wpt.preventAbort();3wpt.preventAbort();4wpt.preventAbort();5wpt.preventAbort();6wpt.preventAbort();7wpt.preventAbort();8wpt.preventAbort();9wpt.preventAbort();10wpt.preventAbort();11wpt.preventAbort();12wpt.preventAbort();13wpt.preventAbort();14wpt.preventAbort();15wpt.preventAbort();16wpt.preventAbort();17wpt.preventAbort();18wpt.preventAbort();19wpt.preventAbort();20wpt.preventAbort();21wpt.preventAbort();22wpt.preventAbort();23wpt.preventAbort();24wpt.preventAbort();25wpt.preventAbort();26wpt.preventAbort();27wpt.preventAbort();
Using AI Code Generation
1function preventAbort() {2 wpt.preventAbort();3}4function allowAbort() {5 wpt.allowAbort();6}7function abort() {8 wpt.abort();9}10function allowAbort() {11 wpt.allowAbort();12}13function abort() {14 wpt.abort();15}16function allowAbort() {17 wpt.allowAbort();18}19function abort() {20 wpt.abort();21}22function allowAbort() {23 wpt.allowAbort();24}25function abort() {26 wpt.abort();27}28function allowAbort() {29 wpt.allowAbort();30}31function abort() {32 wpt.abort();33}34function allowAbort() {35 wpt.allowAbort();36}37function abort() {38 wpt.abort();39}40function allowAbort() {41 wpt.allowAbort();42}43function abort() {44 wpt.abort();45}46function allowAbort() {47 wpt.allowAbort();48}49function abort() {50 wpt.abort();51}52function allowAbort() {53 wpt.allowAbort();54}55function abort() {56 wpt.abort();57}58function allowAbort() {59 wpt.allowAbort();60}61function abort() {62 wpt.abort();63}64function allowAbort() {65 wpt.allowAbort();66}67function abort() {68 wpt.abort();69}
Using AI Code Generation
1var wpt = require('webpagetest');2var options = {3};4var wptDriver = new wpt(options);5 if (err) {6 console.log(err);7 } else {8 wptDriver.getTestStatus(data.data.testId, function(err, data) {9 if (err) {10 console.log(err);11 } else {12 console.log(data.data);13 }14 });15 }16});17wptDriver.preventAbort('testId', function(err, data) {18 if (err) {19 console.log(err);20 } else {21 console.log(data.data);22 }23});24wptDriver.abortTest('testId', function(err, data) {25 if (err) {26 console.log(err);27 } else {28 console.log(data.data);29 }30});31wptDriver.getTestStatus('testId', function(err, data) {32 if (err) {33 console.log(err);34 } else {35 console.log(data.data);36 }37});38wptDriver.getTestResults('testId', function(err, data) {39 if (err) {40 console.log(err);41 } else {42 console.log(data.data);43 }44});45wptDriver.getTestResults('testId', function(err, data) {46 if (err) {47 console.log(err);48 } else {49 console.log(data.data);50 }51});52wptDriver.getTestResults('testId', function(err, data) {53 if (err) {54 console.log(err);55 } else {56 console.log(data.data);57 }58});59wptDriver.getLocations(function(err, data) {60 if (err) {61 console.log(err);62 } else {63 console.log(data.data);64 }65});
Using AI Code Generation
1function preventAbort() {2}3function preventClose() {4}5function preventCancel() {6}7function preventSuspend() {8}9function preventResume() {10}11function preventStart() {12}13function preventStop() {14}15function preventOpen() {16}17function preventMessage() {18}19function preventError() {20}21function preventMessage() {22}23function preventError() {24}25function preventMessage() {26}27function preventError() {28}29function preventMessage() {30}31function preventError() {32}33function preventMessage() {34}35function preventError() {36}37function preventMessage() {38}39function preventError() {40}41function preventMessage() {42}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!