How to use preventClose method in wpt

Best JavaScript code snippet using wpt

close-propagation-forward.any.js

Source:close-propagation-forward.any.js Github

copy

Full Screen

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';7promise_test(() => {8 const rs = recordingReadableStream({9 start(controller) {10 controller.close();11 }12 });13 const ws = recordingWritableStream();14 return rs.pipeTo(ws).then(value => {15 assert_equals(value, undefined, 'the promise must fulfill with undefined');16 })17 .then(() => {18 assert_array_equals(rs.events, []);19 assert_array_equals(ws.events, ['close']);20 return Promise.all([21 rs.getReader().closed,22 ws.getWriter().closed23 ]);24 });25}, 'Closing must be propagated forward: starts closed; preventClose omitted; fulfilled close promise');26promise_test(t => {27 const rs = recordingReadableStream({28 start(controller) {29 controller.close();30 }31 });32 const ws = recordingWritableStream({33 close() {34 throw error1;35 }36 });37 return promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the same error').then(() => {38 assert_array_equals(rs.events, []);39 assert_array_equals(ws.events, ['close']);40 return Promise.all([41 rs.getReader().closed,42 promise_rejects(t, error1, ws.getWriter().closed)43 ]);44 });45}, 'Closing must be propagated forward: starts closed; preventClose omitted; rejected close promise');46for (const falsy of [undefined, null, false, +0, -0, NaN, '']) {47 const stringVersion = Object.is(falsy, -0) ? '-0' : String(falsy);48 promise_test(() => {49 const rs = recordingReadableStream({50 start(controller) {51 controller.close();52 }53 });54 const ws = recordingWritableStream();55 return rs.pipeTo(ws, { preventClose: falsy }).then(value => {56 assert_equals(value, undefined, 'the promise must fulfill with undefined');57 })58 .then(() => {59 assert_array_equals(rs.events, []);60 assert_array_equals(ws.events, ['close']);61 return Promise.all([62 rs.getReader().closed,63 ws.getWriter().closed64 ]);65 });66 }, `Closing must be propagated forward: starts closed; preventClose = ${stringVersion} (falsy); fulfilled close ` +67 `promise`);68}69for (const truthy of [true, 'a', 1, Symbol(), { }]) {70 promise_test(() => {71 const rs = recordingReadableStream({72 start(controller) {73 controller.close();74 }75 });76 const ws = recordingWritableStream();77 return rs.pipeTo(ws, { preventClose: truthy }).then(value => {78 assert_equals(value, undefined, 'the promise must fulfill with undefined');79 })80 .then(() => {81 assert_array_equals(rs.events, []);82 assert_array_equals(ws.events, []);83 return rs.getReader().closed;84 });85 }, `Closing must be propagated forward: starts closed; preventClose = ${String(truthy)} (truthy)`);86}87promise_test(() => {88 const rs = recordingReadableStream({89 start(controller) {90 controller.close();91 }92 });93 const ws = recordingWritableStream();94 return rs.pipeTo(ws, { preventClose: true, preventAbort: true }).then(value => {95 assert_equals(value, undefined, 'the promise must fulfill with undefined');96 })97 .then(() => {98 assert_array_equals(rs.events, []);99 assert_array_equals(ws.events, []);100 return rs.getReader().closed;101 });102}, 'Closing must be propagated forward: starts closed; preventClose = true, preventAbort = true');103promise_test(() => {104 const rs = recordingReadableStream({105 start(controller) {106 controller.close();107 }108 });109 const ws = recordingWritableStream();110 return rs.pipeTo(ws, { preventClose: true, preventAbort: true, preventCancel: true }).then(value => {111 assert_equals(value, undefined, 'the promise must fulfill with undefined');112 })113 .then(() => {114 assert_array_equals(rs.events, []);115 assert_array_equals(ws.events, []);116 return rs.getReader().closed;117 });118}, 'Closing must be propagated forward: starts closed; preventClose = true, preventAbort = true, preventCancel = true');119promise_test(t => {120 const rs = recordingReadableStream();121 const ws = recordingWritableStream();122 const pipePromise = rs.pipeTo(ws);123 t.step_timeout(() => rs.controller.close());124 return pipePromise.then(value => {125 assert_equals(value, undefined, 'the promise must fulfill with undefined');126 })127 .then(() => {128 assert_array_equals(rs.eventsWithoutPulls, []);129 assert_array_equals(ws.events, ['close']);130 return Promise.all([131 rs.getReader().closed,132 ws.getWriter().closed133 ]);134 });135}, 'Closing must be propagated forward: becomes closed asynchronously; preventClose omitted; fulfilled close promise');136promise_test(t => {137 const rs = recordingReadableStream();138 const ws = recordingWritableStream({139 close() {140 throw error1;141 }142 });143 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the same error');144 t.step_timeout(() => rs.controller.close());145 return pipePromise.then(() => {146 assert_array_equals(rs.eventsWithoutPulls, []);147 assert_array_equals(ws.events, ['close']);148 return Promise.all([149 rs.getReader().closed,150 promise_rejects(t, error1, ws.getWriter().closed)151 ]);152 });153}, 'Closing must be propagated forward: becomes closed asynchronously; preventClose omitted; rejected close promise');154promise_test(t => {155 const rs = recordingReadableStream();156 const ws = recordingWritableStream();157 const pipePromise = rs.pipeTo(ws, { preventClose: true });158 t.step_timeout(() => rs.controller.close());159 return pipePromise.then(value => {160 assert_equals(value, undefined, 'the promise must fulfill with undefined');161 })162 .then(() => {163 assert_array_equals(rs.eventsWithoutPulls, []);164 assert_array_equals(ws.events, []);165 return rs.getReader().closed;166 });167}, 'Closing must be propagated forward: becomes closed asynchronously; preventClose = true');168promise_test(t => {169 const rs = recordingReadableStream();170 const ws = recordingWritableStream(undefined, new CountQueuingStrategy({ highWaterMark: 0 }));171 const pipePromise = rs.pipeTo(ws);172 t.step_timeout(() => rs.controller.close());173 return pipePromise.then(value => {174 assert_equals(value, undefined, 'the promise must fulfill with undefined');175 })176 .then(() => {177 assert_array_equals(rs.eventsWithoutPulls, []);178 assert_array_equals(ws.events, ['close']);179 return Promise.all([180 rs.getReader().closed,181 ws.getWriter().closed182 ]);183 });184}, 'Closing must be propagated forward: becomes closed asynchronously; dest never desires chunks; ' +185 'preventClose omitted; fulfilled close promise');186promise_test(t => {187 const rs = recordingReadableStream();188 const ws = recordingWritableStream({189 close() {190 throw error1;191 }192 }, new CountQueuingStrategy({ highWaterMark: 0 }));193 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the same error');194 t.step_timeout(() => rs.controller.close());195 return pipePromise.then(() => {196 assert_array_equals(rs.eventsWithoutPulls, []);197 assert_array_equals(ws.events, ['close']);198 return Promise.all([199 rs.getReader().closed,200 promise_rejects(t, error1, ws.getWriter().closed)201 ]);202 });203}, 'Closing must be propagated forward: becomes closed asynchronously; dest never desires chunks; ' +204 'preventClose omitted; rejected close promise');205promise_test(t => {206 const rs = recordingReadableStream();207 const ws = recordingWritableStream(undefined, new CountQueuingStrategy({ highWaterMark: 0 }));208 const pipePromise = rs.pipeTo(ws, { preventClose: true });209 t.step_timeout(() => rs.controller.close());210 return pipePromise.then(value => {211 assert_equals(value, undefined, 'the promise must fulfill with undefined');212 })213 .then(() => {214 assert_array_equals(rs.eventsWithoutPulls, []);215 assert_array_equals(ws.events, []);216 return rs.getReader().closed;217 });218}, 'Closing must be propagated forward: becomes closed asynchronously; dest never desires chunks; ' +219 'preventClose = true');220promise_test(t => {221 const rs = recordingReadableStream();222 const ws = recordingWritableStream();223 const pipePromise = rs.pipeTo(ws);224 t.step_timeout(() => {225 rs.controller.enqueue('Hello');226 t.step_timeout(() => rs.controller.close());227 }, 10);228 return pipePromise.then(value => {229 assert_equals(value, undefined, 'the promise must fulfill with undefined');230 })231 .then(() => {232 assert_array_equals(rs.eventsWithoutPulls, []);233 assert_array_equals(ws.events, ['write', 'Hello', 'close']);234 return Promise.all([235 rs.getReader().closed,236 ws.getWriter().closed237 ]);238 });239}, 'Closing must be propagated forward: becomes closed after one chunk; preventClose omitted; fulfilled close promise');240promise_test(t => {241 const rs = recordingReadableStream();242 const ws = recordingWritableStream({243 close() {244 throw error1;245 }246 });247 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the same error');248 t.step_timeout(() => {249 rs.controller.enqueue('Hello');250 t.step_timeout(() => rs.controller.close());251 }, 10);252 return pipePromise.then(() => {253 assert_array_equals(rs.eventsWithoutPulls, []);254 assert_array_equals(ws.events, ['write', 'Hello', 'close']);255 return Promise.all([256 rs.getReader().closed,257 promise_rejects(t, error1, ws.getWriter().closed)258 ]);259 });260}, 'Closing must be propagated forward: becomes closed after one chunk; preventClose omitted; rejected close promise');261promise_test(t => {262 const rs = recordingReadableStream();263 const ws = recordingWritableStream();264 const pipePromise = rs.pipeTo(ws, { preventClose: true });265 t.step_timeout(() => {266 rs.controller.enqueue('Hello');267 t.step_timeout(() => rs.controller.close());268 }, 10);269 return pipePromise.then(value => {270 assert_equals(value, undefined, 'the promise must fulfill with undefined');271 })272 .then(() => {273 assert_array_equals(rs.eventsWithoutPulls, []);274 assert_array_equals(ws.events, ['write', 'Hello']);275 return rs.getReader().closed;276 });277}, 'Closing must be propagated forward: becomes closed after one chunk; preventClose = true');278promise_test(() => {279 const rs = recordingReadableStream();280 let resolveWritePromise;281 const ws = recordingWritableStream({282 write() {283 return new Promise(resolve => {284 resolveWritePromise = resolve;285 });286 }287 });288 let pipeComplete = false;289 const pipePromise = rs.pipeTo(ws).then(() => {290 pipeComplete = true;291 });292 rs.controller.enqueue('a');293 rs.controller.close();294 // Flush async events and verify that no shutdown occurs.295 return flushAsyncEvents().then(() => {296 assert_array_equals(ws.events, ['write', 'a']); // no 'close'297 assert_equals(pipeComplete, false, 'the pipe must not be complete');298 resolveWritePromise();299 return pipePromise.then(() => {300 assert_array_equals(ws.events, ['write', 'a', 'close']);301 });302 });303}, 'Closing must be propagated forward: shutdown must not occur until the final write completes');304promise_test(() => {305 const rs = recordingReadableStream();306 let resolveWritePromise;307 const ws = recordingWritableStream({308 write() {309 return new Promise(resolve => {310 resolveWritePromise = resolve;311 });312 }313 });314 let pipeComplete = false;315 const pipePromise = rs.pipeTo(ws, { preventClose: true }).then(() => {316 pipeComplete = true;317 });318 rs.controller.enqueue('a');319 rs.controller.close();320 // Flush async events and verify that no shutdown occurs.321 return flushAsyncEvents().then(() => {322 assert_array_equals(ws.events, ['write', 'a'],323 'the chunk must have been written, but close must not have happened');324 assert_equals(pipeComplete, false, 'the pipe must not be complete');325 resolveWritePromise();326 return pipePromise;327 }).then(() => flushAsyncEvents()).then(() => {328 assert_array_equals(ws.events, ['write', 'a'],329 'the chunk must have been written, but close must not have happened');330 });331}, 'Closing must be propagated forward: shutdown must not occur until the final write completes; preventClose = true');332promise_test(() => {333 const rs = recordingReadableStream();334 let resolveWriteCalled;335 const writeCalledPromise = new Promise(resolve => {336 resolveWriteCalled = resolve;337 });338 let resolveWritePromise;339 const ws = recordingWritableStream({340 write() {341 resolveWriteCalled();342 return new Promise(resolve => {343 resolveWritePromise = resolve;344 });345 }346 }, new CountQueuingStrategy({ highWaterMark: 2 }));347 let pipeComplete = false;348 const pipePromise = rs.pipeTo(ws).then(() => {349 pipeComplete = true;350 });351 rs.controller.enqueue('a');352 rs.controller.enqueue('b');353 return writeCalledPromise.then(() => flushAsyncEvents()).then(() => {354 assert_array_equals(ws.events, ['write', 'a'],355 'the first chunk must have been written, but close must not have happened yet');356 assert_false(pipeComplete, 'the pipe should not complete while the first write is pending');357 rs.controller.close();358 resolveWritePromise();359 }).then(() => flushAsyncEvents()).then(() => {360 assert_array_equals(ws.events, ['write', 'a', 'write', 'b'],361 'the second chunk must have been written, but close must not have happened yet');362 assert_false(pipeComplete, 'the pipe should not complete while the second write is pending');363 resolveWritePromise();364 return pipePromise;365 }).then(() => {366 assert_array_equals(ws.events, ['write', 'a', 'write', 'b', 'close'],367 'all chunks must have been written and close must have happened');368 });369}, 'Closing must be propagated forward: shutdown must not occur until the final write completes; becomes closed after first write');370promise_test(() => {371 const rs = recordingReadableStream();372 let resolveWriteCalled;373 const writeCalledPromise = new Promise(resolve => {374 resolveWriteCalled = resolve;375 });376 let resolveWritePromise;377 const ws = recordingWritableStream({378 write() {379 resolveWriteCalled();380 return new Promise(resolve => {381 resolveWritePromise = resolve;382 });383 }384 }, new CountQueuingStrategy({ highWaterMark: 2 }));385 let pipeComplete = false;386 const pipePromise = rs.pipeTo(ws, { preventClose: true }).then(() => {387 pipeComplete = true;388 });389 rs.controller.enqueue('a');390 rs.controller.enqueue('b');391 return writeCalledPromise.then(() => flushAsyncEvents()).then(() => {392 assert_array_equals(ws.events, ['write', 'a'],393 'the first chunk must have been written, but close must not have happened');394 assert_false(pipeComplete, 'the pipe should not complete while the first write is pending');395 rs.controller.close();396 resolveWritePromise();397 }).then(() => flushAsyncEvents()).then(() => {398 assert_array_equals(ws.events, ['write', 'a', 'write', 'b'],399 'the second chunk must have been written, but close must not have happened');400 assert_false(pipeComplete, 'the pipe should not complete while the second write is pending');401 resolveWritePromise();402 return pipePromise;403 }).then(() => flushAsyncEvents()).then(() => {404 assert_array_equals(ws.events, ['write', 'a', 'write', 'b'],405 'all chunks must have been written, but close must not have happened');406 });407}, 'Closing must be propagated forward: shutdown must not occur until the final write completes; becomes closed after first write; preventClose = true');408promise_test(t => {409 const rs = recordingReadableStream({410 start(c) {411 c.enqueue('a');412 c.enqueue('b');413 c.close();414 }415 });416 let rejectWritePromise;417 const ws = recordingWritableStream({418 write() {419 return new Promise((resolve, reject) => {420 rejectWritePromise = reject;421 });422 }423 }, { highWaterMark: 3 });424 const pipeToPromise = rs.pipeTo(ws);425 return delay(0).then(() => {426 rejectWritePromise(error1);427 return promise_rejects(t, error1, pipeToPromise, 'pipeTo should reject');428 }).then(() => {429 assert_array_equals(rs.events, []);430 assert_array_equals(ws.events, ['write', 'a']);431 return Promise.all([432 rs.getReader().closed,433 promise_rejects(t, error1, ws.getWriter().closed, 'ws should be errored')434 ]);435 });...

Full Screen

Full Screen

close-propagation-forward.js

Source:close-propagation-forward.js Github

copy

Full Screen

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';9promise_test(() => {10 const rs = recordingReadableStream({11 start(controller) {12 controller.close();13 }14 });15 const ws = recordingWritableStream();16 return rs.pipeTo(ws).then(value => {17 assert_equals(value, undefined, 'the promise must fulfill with undefined');18 })19 .then(() => {20 assert_array_equals(rs.events, []);21 assert_array_equals(ws.events, ['close']);22 return Promise.all([23 rs.getReader().closed,24 ws.getWriter().closed25 ]);26 });27}, 'Closing must be propagated forward: starts closed; preventClose omitted; fulfilled close promise');28promise_test(t => {29 const rs = recordingReadableStream({30 start(controller) {31 controller.close();32 }33 });34 const ws = recordingWritableStream({35 close() {36 throw error1;37 }38 });39 return promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the same error').then(() => {40 assert_array_equals(rs.events, []);41 assert_array_equals(ws.events, ['close']);42 return Promise.all([43 rs.getReader().closed,44 promise_rejects(t, error1, ws.getWriter().closed)45 ]);46 });47}, 'Closing must be propagated forward: starts closed; preventClose omitted; rejected close promise');48for (const falsy of [undefined, null, false, +0, -0, NaN, '']) {49 const stringVersion = Object.is(falsy, -0) ? '-0' : String(falsy);50 promise_test(() => {51 const rs = recordingReadableStream({52 start(controller) {53 controller.close();54 }55 });56 const ws = recordingWritableStream();57 return rs.pipeTo(ws, { preventClose: falsy }).then(value => {58 assert_equals(value, undefined, 'the promise must fulfill with undefined');59 })60 .then(() => {61 assert_array_equals(rs.events, []);62 assert_array_equals(ws.events, ['close']);63 return Promise.all([64 rs.getReader().closed,65 ws.getWriter().closed66 ]);67 });68 }, `Closing must be propagated forward: starts closed; preventClose = ${stringVersion} (falsy); fulfilled close ` +69 `promise`);70}71for (const truthy of [true, 'a', 1, Symbol(), { }]) {72 promise_test(() => {73 const rs = recordingReadableStream({74 start(controller) {75 controller.close();76 }77 });78 const ws = recordingWritableStream();79 return rs.pipeTo(ws, { preventClose: truthy }).then(value => {80 assert_equals(value, undefined, 'the promise must fulfill with undefined');81 })82 .then(() => {83 assert_array_equals(rs.events, []);84 assert_array_equals(ws.events, []);85 return rs.getReader().closed;86 });87 }, `Closing must be propagated forward: starts closed; preventClose = ${String(truthy)} (truthy)`);88}89promise_test(() => {90 const rs = recordingReadableStream({91 start(controller) {92 controller.close();93 }94 });95 const ws = recordingWritableStream();96 return rs.pipeTo(ws, { preventClose: true, preventAbort: true }).then(value => {97 assert_equals(value, undefined, 'the promise must fulfill with undefined');98 })99 .then(() => {100 assert_array_equals(rs.events, []);101 assert_array_equals(ws.events, []);102 return rs.getReader().closed;103 });104}, 'Closing must be propagated forward: starts closed; preventClose = true, preventAbort = true');105promise_test(() => {106 const rs = recordingReadableStream({107 start(controller) {108 controller.close();109 }110 });111 const ws = recordingWritableStream();112 return rs.pipeTo(ws, { preventClose: true, preventAbort: true, preventCancel: true }).then(value => {113 assert_equals(value, undefined, 'the promise must fulfill with undefined');114 })115 .then(() => {116 assert_array_equals(rs.events, []);117 assert_array_equals(ws.events, []);118 return rs.getReader().closed;119 });120}, 'Closing must be propagated forward: starts closed; preventClose = true, preventAbort = true, preventCancel = true');121promise_test(() => {122 const rs = recordingReadableStream();123 const ws = recordingWritableStream();124 const pipePromise = rs.pipeTo(ws);125 setTimeout(() => rs.controller.close());126 return pipePromise.then(value => {127 assert_equals(value, undefined, 'the promise must fulfill with undefined');128 })129 .then(() => {130 assert_array_equals(rs.eventsWithoutPulls, []);131 assert_array_equals(ws.events, ['close']);132 return Promise.all([133 rs.getReader().closed,134 ws.getWriter().closed135 ]);136 });137}, 'Closing must be propagated forward: becomes closed asynchronously; preventClose omitted; fulfilled close promise');138promise_test(t => {139 const rs = recordingReadableStream();140 const ws = recordingWritableStream({141 close() {142 throw error1;143 }144 });145 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the same error');146 setTimeout(() => rs.controller.close());147 return pipePromise.then(() => {148 assert_array_equals(rs.eventsWithoutPulls, []);149 assert_array_equals(ws.events, ['close']);150 return Promise.all([151 rs.getReader().closed,152 promise_rejects(t, error1, ws.getWriter().closed)153 ]);154 });155}, 'Closing must be propagated forward: becomes closed asynchronously; preventClose omitted; rejected close promise');156promise_test(() => {157 const rs = recordingReadableStream();158 const ws = recordingWritableStream();159 const pipePromise = rs.pipeTo(ws, { preventClose: true });160 setTimeout(() => rs.controller.close());161 return pipePromise.then(value => {162 assert_equals(value, undefined, 'the promise must fulfill with undefined');163 })164 .then(() => {165 assert_array_equals(rs.eventsWithoutPulls, []);166 assert_array_equals(ws.events, []);167 return rs.getReader().closed;168 });169}, 'Closing must be propagated forward: becomes closed asynchronously; preventClose = true');170promise_test(() => {171 const rs = recordingReadableStream();172 const ws = recordingWritableStream(undefined, new CountQueuingStrategy({ highWaterMark: 0 }));173 const pipePromise = rs.pipeTo(ws);174 setTimeout(() => rs.controller.close());175 return pipePromise.then(value => {176 assert_equals(value, undefined, 'the promise must fulfill with undefined');177 })178 .then(() => {179 assert_array_equals(rs.eventsWithoutPulls, []);180 assert_array_equals(ws.events, ['close']);181 return Promise.all([182 rs.getReader().closed,183 ws.getWriter().closed184 ]);185 });186}, 'Closing must be propagated forward: becomes closed asynchronously; dest never desires chunks; ' +187 'preventClose omitted; fulfilled close promise');188promise_test(t => {189 const rs = recordingReadableStream();190 const ws = recordingWritableStream({191 close() {192 throw error1;193 }194 }, new CountQueuingStrategy({ highWaterMark: 0 }));195 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the same error');196 setTimeout(() => rs.controller.close());197 return pipePromise.then(() => {198 assert_array_equals(rs.eventsWithoutPulls, []);199 assert_array_equals(ws.events, ['close']);200 return Promise.all([201 rs.getReader().closed,202 promise_rejects(t, error1, ws.getWriter().closed)203 ]);204 });205}, 'Closing must be propagated forward: becomes closed asynchronously; dest never desires chunks; ' +206 'preventClose omitted; rejected close promise');207promise_test(() => {208 const rs = recordingReadableStream();209 const ws = recordingWritableStream(undefined, new CountQueuingStrategy({ highWaterMark: 0 }));210 const pipePromise = rs.pipeTo(ws, { preventClose: true });211 setTimeout(() => rs.controller.close());212 return pipePromise.then(value => {213 assert_equals(value, undefined, 'the promise must fulfill with undefined');214 })215 .then(() => {216 assert_array_equals(rs.eventsWithoutPulls, []);217 assert_array_equals(ws.events, []);218 return rs.getReader().closed;219 });220}, 'Closing must be propagated forward: becomes closed asynchronously; dest never desires chunks; ' +221 'preventClose = true');222promise_test(() => {223 const rs = recordingReadableStream();224 const ws = recordingWritableStream();225 const pipePromise = rs.pipeTo(ws);226 setTimeout(() => {227 rs.controller.enqueue('Hello');228 setTimeout(() => rs.controller.close());229 }, 10);230 return pipePromise.then(value => {231 assert_equals(value, undefined, 'the promise must fulfill with undefined');232 })233 .then(() => {234 assert_array_equals(rs.eventsWithoutPulls, []);235 assert_array_equals(ws.events, ['write', 'Hello', 'close']);236 return Promise.all([237 rs.getReader().closed,238 ws.getWriter().closed239 ]);240 });241}, 'Closing must be propagated forward: becomes closed after one chunk; preventClose omitted; fulfilled close promise');242promise_test(t => {243 const rs = recordingReadableStream();244 const ws = recordingWritableStream({245 close() {246 throw error1;247 }248 });249 const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws), 'pipeTo must reject with the same error');250 setTimeout(() => {251 rs.controller.enqueue('Hello');252 setTimeout(() => rs.controller.close());253 }, 10);254 return pipePromise.then(() => {255 assert_array_equals(rs.eventsWithoutPulls, []);256 assert_array_equals(ws.events, ['write', 'Hello', 'close']);257 return Promise.all([258 rs.getReader().closed,259 promise_rejects(t, error1, ws.getWriter().closed)260 ]);261 });262}, 'Closing must be propagated forward: becomes closed after one chunk; preventClose omitted; rejected close promise');263promise_test(() => {264 const rs = recordingReadableStream();265 const ws = recordingWritableStream();266 const pipePromise = rs.pipeTo(ws, { preventClose: true });267 setTimeout(() => {268 rs.controller.enqueue('Hello');269 setTimeout(() => rs.controller.close());270 }, 10);271 return pipePromise.then(value => {272 assert_equals(value, undefined, 'the promise must fulfill with undefined');273 })274 .then(() => {275 assert_array_equals(rs.eventsWithoutPulls, []);276 assert_array_equals(ws.events, ['write', 'Hello']);277 return rs.getReader().closed;278 });279}, 'Closing must be propagated forward: becomes closed after one chunk; preventClose = true');280promise_test(() => {281 const rs = recordingReadableStream();282 let resolveWritePromise;283 const ws = recordingWritableStream({284 write() {285 return new Promise(resolve => {286 resolveWritePromise = resolve;287 });288 }289 });290 let pipeComplete = false;291 const pipePromise = rs.pipeTo(ws).then(() => {292 pipeComplete = true;293 });294 rs.controller.enqueue('a');295 rs.controller.close();296 // Flush async events and verify that no shutdown occurs.297 return flushAsyncEvents().then(() => {298 assert_array_equals(ws.events, ['write', 'a']); // no 'close'299 assert_equals(pipeComplete, false, 'the pipe must not be complete');300 resolveWritePromise();301 return pipePromise.then(() => {302 assert_array_equals(ws.events, ['write', 'a', 'close']);303 });304 });305}, 'Closing must be propagated forward: shutdown must not occur until the final write completes');306promise_test(() => {307 const rs = recordingReadableStream();308 let resolveWritePromise;309 const ws = recordingWritableStream({310 write() {311 return new Promise(resolve => {312 resolveWritePromise = resolve;313 });314 }315 });316 let pipeComplete = false;317 const pipePromise = rs.pipeTo(ws, { preventClose: true }).then(() => {318 pipeComplete = true;319 });320 rs.controller.enqueue('a');321 rs.controller.close();322 // Flush async events and verify that no shutdown occurs.323 return flushAsyncEvents().then(() => {324 assert_array_equals(ws.events, ['write', 'a'],325 'the chunk must have been written, but close must not have happened yet');326 assert_equals(pipeComplete, false, 'the pipe must not be complete');327 resolveWritePromise();328 return pipePromise;329 });330}, 'Closing must be propagated forward: shutdown must not occur until the final write completes; preventClose = true');...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1import React from 'react';2import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';3import { Button, ListItem } from '@material-ui/core';4import { ContextMenu, MenuItem, ContextMenuTrigger } from 'react-contextmenu';5export default function LivePreviewExample() {6 const attributes = {7 className: 'nav-item my-1'8 };9 const attributes3 = {10 className: 'd-block text-left p-3'11 };12 return (13 <>14 <div className="text-center">15 <span className="position-relative">16 <ContextMenuTrigger renderTag="span" id="ContextMenuTrigger1">17 <Button className="btn-primary m-2">Right click menu 1</Button>18 </ContextMenuTrigger>19 <ContextMenu20 className="rel-container rounded-sm shadow-xxl bg-white dropdown-menu nav nav-neutral-danger nav-pills flex-column p-3 dropdown-menu-lg"21 id="ContextMenuTrigger1">22 <MenuItem preventClose={true} attributes={attributes}>23 <ListItem24 component="a"25 button26 href="#/"27 onClick={(e) => e.preventDefault()}28 className="rounded-sm">29 <div className="nav-link-icon">30 <FontAwesomeIcon icon={['far', 'object-group']} />31 </div>32 <span>Dashboard</span>33 </ListItem>34 </MenuItem>35 <MenuItem preventClose={true} attributes={attributes}>36 <ListItem37 component="a"38 button39 href="#/"40 onClick={(e) => e.preventDefault()}41 className="rounded-sm">42 <div className="nav-link-icon">43 <FontAwesomeIcon icon={['far', 'building']} />44 </div>45 <span>Accounts</span>46 </ListItem>47 </MenuItem>48 <MenuItem className="my-3" divider />49 <MenuItem preventClose={true} attributes={attributes}>50 <ListItem51 component="a"52 button53 href="#/"54 onClick={(e) => e.preventDefault()}55 className="rounded-sm">56 <div className="nav-link-icon">57 <FontAwesomeIcon icon={['far', 'keyboard']} />58 </div>59 <span>Reports</span>60 </ListItem>61 </MenuItem>62 <MenuItem preventClose={true} attributes={attributes}>63 <ListItem64 component="a"65 button66 href="#/"67 onClick={(e) => e.preventDefault()}68 className="rounded-sm">69 <div className="nav-link-icon">70 <FontAwesomeIcon icon={['far', 'chart-bar']} />71 </div>72 <span>Deliveries</span>73 </ListItem>74 </MenuItem>75 </ContextMenu>76 </span>77 <span className="position-relative">78 <ContextMenuTrigger renderTag="span" id="ContextMenuTrigger2">79 <Button className="btn-primary m-2">Right click menu 2</Button>80 </ContextMenuTrigger>81 <ContextMenu82 className="rel-container shadow-sm rounded-lg bg-white dropdown-menu nav nav-neutral-warning nav-pills dropdown-menu-xl nav-pills-rounded flex-column p-3"83 id="ContextMenuTrigger2">84 <MenuItem preventClose={true} attributes={attributes}>85 <ListItem86 component="a"87 button88 href="#/"89 onClick={(e) => e.preventDefault()}90 className="rounded-lg">91 <div className="nav-link-icon">92 <FontAwesomeIcon icon={['far', 'lightbulb']} />93 </div>94 <span>My Account</span>95 </ListItem>96 </MenuItem>97 <MenuItem preventClose={true} attributes={attributes}>98 <ListItem99 component="a"100 button101 href="#/"102 onClick={(e) => e.preventDefault()}103 selected104 className="rounded-lg">105 <div className="nav-link-icon">106 <FontAwesomeIcon icon={['far', 'heart']} />107 </div>108 <span>Profile settings</span>109 </ListItem>110 </MenuItem>111 <MenuItem preventClose={true} attributes={attributes}>112 <ListItem113 component="a"114 button115 href="#/"116 onClick={(e) => e.preventDefault()}117 className="rounded-lg">118 <span className="d-flex align-items-center">119 <div className="nav-link-icon">120 <FontAwesomeIcon icon={['far', 'user']} />121 </div>122 <span>Active tasks</span>123 </span>124 <div className="badge badge-pill badge-success ml-auto">125 New126 </div>127 </ListItem>128 </MenuItem>129 <MenuItem preventClose={true} attributes={attributes}>130 <ListItem131 component="a"132 button133 href="#/"134 onClick={(e) => e.preventDefault()}135 className="rounded-lg">136 <div className="nav-link-icon">137 <FontAwesomeIcon icon={['far', 'bell']} />138 </div>139 <span>Customers</span>140 </ListItem>141 </MenuItem>142 <MenuItem preventClose={true} attributes={attributes}>143 <ListItem144 component="a"145 button146 href="#/"147 onClick={(e) => e.preventDefault()}148 className="rounded-lg">149 <div className="nav-link-icon">150 <FontAwesomeIcon icon={['far', 'eye']} />151 </div>152 <span>Statistics</span>153 </ListItem>154 </MenuItem>155 </ContextMenu>156 </span>157 <span className="position-relative">158 <ContextMenuTrigger renderTag="span" id="ContextMenuTrigger3">159 <Button className="btn-primary m-2">Right click menu 3</Button>160 </ContextMenuTrigger>161 <ContextMenu162 className="rel-container shadow-lg rounded bg-white dropdown-menu py-0 list-group list-group-flush dropdown-menu-xl"163 id="ContextMenuTrigger3">164 <MenuItem preventClose={true} attributes={attributes3}>165 <a166 href="#/"167 onClick={(e) => e.preventDefault()}168 className="align-box-row w-100">169 <div className="mr-3">170 <div className="bg-grow-early btn-icon text-center text-white font-size-xl d-50 rounded-circle">171 <FontAwesomeIcon icon={['far', 'bell']} />172 </div>173 </div>174 <div>175 <div className="font-weight-bold text-primary d-block">176 Sales177 </div>178 <small className="text-success">179 <FontAwesomeIcon180 icon={['fas', 'chevron-up']}181 className="text-success mr-1"182 />183 <span>15.4% increase</span>184 </small>185 </div>186 </a>187 </MenuItem>188 <MenuItem preventClose={true} attributes={attributes3}>189 <a190 href="#/"191 onClick={(e) => e.preventDefault()}192 className="align-box-row w-100">193 <div className="mr-3">194 <div className="bg-warning btn-icon text-center text-white font-size-xl d-50 rounded-circle">195 <FontAwesomeIcon icon={['far', 'chart-bar']} />196 </div>197 </div>198 <div>199 <div className="font-weight-bold text-primary d-block">200 Expenses201 </div>202 <small className="text-warning">203 <FontAwesomeIcon204 icon={['fas', 'arrow-down']}205 className="text-warning mr-1"206 />207 <span>5.2% down</span>208 </small>209 </div>210 </a>211 </MenuItem>212 </ContextMenu>213 </span>214 <span className="position-relative">215 <ContextMenuTrigger renderTag="span" id="ContextMenuTrigger4">216 <Button className="btn-primary m-2">Right click menu 4</Button>217 </ContextMenuTrigger>218 <ContextMenu219 className="rel-container rounded modal-content bg-white dropdown-menu nav nav-neutral-primary nav-pills dropdown-menu-xl flex-column p-3"220 id="ContextMenuTrigger4">221 <MenuItem preventClose={true} attributes={attributes}>222 <span className="font-weight-bold px-2 pb-2 text-left w-100 d-block text-primary text-uppercase font-size-sm">223 Reports224 </span>225 </MenuItem>226 <MenuItem preventClose={true} attributes={attributes}>227 <ListItem228 component="a"229 button230 href="#/"231 onClick={(e) => e.preventDefault()}232 className="rounded-sm">233 <span>My Account</span>234 </ListItem>235 </MenuItem>236 <MenuItem preventClose={true} attributes={attributes}>237 <ListItem238 button239 selected240 href="#/"241 onClick={(e) => e.preventDefault()}>242 <span>Profile settings</span>243 <div className="badge badge-first ml-auto">23</div>244 </ListItem>245 </MenuItem>246 <MenuItem preventClose={true} attributes={attributes}>247 <ListItem248 component="a"249 button250 href="#/"251 onClick={(e) => e.preventDefault()}252 className="rounded-sm">253 <span>Active tasks</span>254 </ListItem>255 </MenuItem>256 <MenuItem className="my-2" divider />257 <MenuItem preventClose={true} attributes={attributes}>258 <ListItem259 component="a"260 button261 href="#/"262 onClick={(e) => e.preventDefault()}263 className="rounded-sm">264 <div className="nav-link-icon">265 <FontAwesomeIcon icon={['far', 'bell']} />266 </div>267 <span>Customers</span>268 </ListItem>269 </MenuItem>270 <MenuItem preventClose={true} attributes={attributes}>271 <ListItem272 component="a"273 button274 href="#/"275 onClick={(e) => e.preventDefault()}276 className="rounded-sm">277 <div className="nav-link-icon">278 <FontAwesomeIcon icon={['far', 'eye']} />279 </div>280 <span>Statistics</span>281 </ListItem>282 </MenuItem>283 </ContextMenu>284 </span>285 </div>286 </>287 );...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3}, function(err, data) {4 if (err) return console.error(err);5 console.log('Test status: ' + data.statusText);6 if (data.statusCode === 200) {7 console.log('View your test at: ' + data.data.userUrl);8 } else {9 console.log('Test still running');10 wpt.preventClose(data.data.testId, function(err, data) {11 if (err) return console.error(err);12 console.log('PreventClose status: ' + data.statusText);13 });14 }15});16var wpt = require('webpagetest');17var wpt = new WebPageTest('www.webpagetest.org');18}, function(err, data) {19 if (err) return console.error(err);20 console.log('Test status: ' + data.statusText);21 if (data.statusCode === 200) {22 console.log('View your test at: ' + data.data.userUrl);23 } else {24 console.log('Test still running');25 }26});27var wpt = require('webpagetest');28var wpt = new WebPageTest('www.webpagetest.org');29}, function(err, data) {30 if (err) return console.error(err);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var api = new WebPageTest('www.webpagetest.org');3var options = {url: 'www.google.com', location: 'Dulles:Chrome', runs: 3};4api.runTest(options, function(err, data) {5 if (err) return console.error(err);6 console.log('Test ID: %s', data.data.testId);7 api.getTestStatus(data.data.testId, function(err, data) {8 if (err) return console.error(err);9 console.log('Test Status: %s', data.data.statusText);10 if (data.data.statusText === 'Test Complete') {11 api.getTestResults(data.data.testId, function(err, data) {12 if (err) return console.error(err);13 console.log('Test Results: %j', data.data);14 });15 }16 });17});18var wpt = require('webpagetest');19var api = new WebPageTest('www.webpagetest.org');20var options = {url: 'www.google.com', location: 'Dulles:Chrome', runs: 3};21api.runTest(options, function(err, data) {22 if (err) return console.error(err);23 console.log('Test ID: %s', data.data.testId);24 api.getTestStatus(data.data.testId, function(err, data) {25 if (err) return console.error(err);26 console.log('Test Status: %s', data.data.statusText);27 if (data.data.statusText === 'Test Complete') {28 api.getTestResults(data.data.testId, function(err, data) {29 if (err) return console.error(err);30 console.log('Test Results: %j', data.data);31 });32 }33 });34});35var wpt = require('webpagetest');36var api = new WebPageTest('www.webpagetest.org');37var options = {url: 'www.google.com', location: 'Dulles:Chrome', runs: 3};38api.runTest(options, function(err, data) {39 if (err) return console.error

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('./wptoolkit');2var wp = new wptoolkit();3var title = "Google";4var close = false;5wp.launch(url, title, close);6wp.preventClose();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolbar = require('wptoolbar');2wptoolbar.preventClose();3wptoolbar.allowClose();4### wptoolbar.preventClose()5### wptoolbar.allowClose()6### wptoolbar.isToolbarOpen()7### wptoolbar.isToolbarClosed()8### wptoolbar.open()9### wptoolbar.close()10### wptoolbar.toggle()11### wptoolbar.setTheme(theme)12### wptoolbar.getTheme()13### wptoolbar.setCustomTheme(theme)14### wptoolbar.getCustomTheme()15### wptoolbar.setCustomThemeColors(colors)16### wptoolbar.getCustomThemeColors()

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful