mirror of
https://github.com/servo/servo.git
synced 2025-08-29 00:58:20 +01:00
Update web-platform-tests to revision 8fed98324bc133df221d778c62cbff210d43b0ce
This commit is contained in:
parent
be902d56c0
commit
8a6476740e
246 changed files with 15482 additions and 1281 deletions
|
@ -428,4 +428,52 @@ promise_test(t => {
|
|||
|
||||
}, 'Errors must be propagated forward: shutdown must not occur until the final write completes');
|
||||
|
||||
promise_test(t => {
|
||||
|
||||
const rs = recordingReadableStream();
|
||||
|
||||
let resolveWriteCalled;
|
||||
const writeCalledPromise = new Promise(resolve => {
|
||||
resolveWriteCalled = resolve;
|
||||
});
|
||||
|
||||
let resolveWritePromise;
|
||||
const ws = recordingWritableStream({
|
||||
write() {
|
||||
resolveWriteCalled();
|
||||
|
||||
return new Promise(resolve => {
|
||||
resolveWritePromise = resolve;
|
||||
});
|
||||
}
|
||||
}, new CountQueuingStrategy({ highWaterMark: 2 }));
|
||||
|
||||
let pipeComplete = false;
|
||||
const pipePromise = promise_rejects(t, error1, rs.pipeTo(ws)).then(() => {
|
||||
pipeComplete = true;
|
||||
});
|
||||
|
||||
rs.controller.enqueue('a');
|
||||
rs.controller.enqueue('b');
|
||||
|
||||
return writeCalledPromise.then(() => flushAsyncEvents()).then(() => {
|
||||
assert_array_equals(ws.events, ['write', 'a'], 'abort should not be called before the first write completes');
|
||||
assert_false(pipeComplete, 'the pipe should not complete while the first write is pending');
|
||||
|
||||
rs.controller.error(error1);
|
||||
resolveWritePromise();
|
||||
return flushAsyncEvents();
|
||||
}).then(() => {
|
||||
assert_array_equals(ws.events, ['write', 'a', 'write', 'b'],
|
||||
'abort should not be called before the second write completes');
|
||||
assert_false(pipeComplete, 'the pipe should not complete while the second write is pending');
|
||||
|
||||
resolveWritePromise();
|
||||
return pipePromise;
|
||||
}).then(() => {
|
||||
assert_array_equals(ws.events, ['write', 'a', 'write', 'b', 'abort', error1], 'sink abort should be called');
|
||||
});
|
||||
|
||||
}, 'Errors must be propagated forward: abort should not happen until all queued writes complete');
|
||||
|
||||
done();
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>construct-byob-request.js dedicated worker wrapper file</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<script>
|
||||
'use strict';
|
||||
fetch_tests_from_worker(new Worker('construct-byob-request.js'));
|
||||
</script>
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>construct-byob-request.js browser context wrapper file</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<script src="../resources/rs-utils.js"></script>
|
||||
|
||||
<script src="construct-byob-request.js"></script>
|
|
@ -0,0 +1,82 @@
|
|||
'use strict';
|
||||
|
||||
// Prior to whatwg/stream#870 it was possible to construct a ReadableStreamBYOBRequest directly. This made it possible
|
||||
// to construct requests that were out-of-sync with the state of the ReadableStream. They could then be used to call
|
||||
// internal operations, resulting in asserts or bad behaviour. This file contains regression tests for the change.
|
||||
|
||||
if (self.importScripts) {
|
||||
self.importScripts('../resources/rs-utils.js');
|
||||
self.importScripts('/resources/testharness.js');
|
||||
}
|
||||
|
||||
function getRealByteStreamController() {
|
||||
let controller;
|
||||
new ReadableStream({
|
||||
start(c) {
|
||||
controller = c;
|
||||
},
|
||||
type: 'bytes'
|
||||
});
|
||||
return controller;
|
||||
}
|
||||
|
||||
const ReadableByteStreamController = getRealByteStreamController().constructor;
|
||||
|
||||
// Create an object pretending to have prototype |prototype|, of type |type|. |type| is one of "undefined", "null",
|
||||
// "fake", or "real". "real" will call the realObjectCreator function to get a real instance of the object.
|
||||
function createDummyObject(prototype, type, realObjectCreator) {
|
||||
switch (type) {
|
||||
case 'undefined':
|
||||
return undefined;
|
||||
|
||||
case 'null':
|
||||
return null;
|
||||
|
||||
case 'fake':
|
||||
return Object.create(prototype);
|
||||
|
||||
case 'real':
|
||||
return realObjectCreator();
|
||||
}
|
||||
|
||||
throw new Error('not reached');
|
||||
}
|
||||
|
||||
const dummyTypes = ['undefined', 'null', 'fake', 'real'];
|
||||
|
||||
function runTests(ReadableStreamBYOBRequest) {
|
||||
for (const controllerType of dummyTypes) {
|
||||
const controller = createDummyObject(ReadableByteStreamController.prototype, controllerType,
|
||||
getRealByteStreamController);
|
||||
for (const viewType of dummyTypes) {
|
||||
const view = createDummyObject(Uint8Array.prototype, viewType, () => new Uint8Array(16));
|
||||
test(() => {
|
||||
assert_throws(new TypeError(), () => new ReadableStreamBYOBRequest(controller, view),
|
||||
'constructor should throw');
|
||||
}, `ReadableStreamBYOBRequest constructor should throw when passed a ${controllerType} ` +
|
||||
`ReadableByteStreamController and a ${viewType} view`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getConstructorAndRunTests() {
|
||||
let ReadableStreamBYOBRequest;
|
||||
const rs = new ReadableStream({
|
||||
pull(controller) {
|
||||
const byobRequest = controller.byobRequest;
|
||||
ReadableStreamBYOBRequest = byobRequest.constructor;
|
||||
byobRequest.respond(4);
|
||||
},
|
||||
type: 'bytes'
|
||||
});
|
||||
rs.getReader({ mode: 'byob' }).read(new Uint8Array(8)).then(() => {
|
||||
runTests(ReadableStreamBYOBRequest);
|
||||
done();
|
||||
});
|
||||
}
|
||||
|
||||
// We can only get at the ReadableStreamBYOBRequest constructor asynchronously, so we need to make the test harness wait
|
||||
// for us to explicitly tell it all our tests have run.
|
||||
setup({ explicit_done: true });
|
||||
|
||||
getConstructorAndRunTests();
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>construct-byob-request.js service worker wrapper file</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
|
||||
|
||||
<script>
|
||||
'use strict';
|
||||
service_worker_test('construct-byob-request.js', 'Service worker test setup');
|
||||
</script>
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>construct-byob-request.js shared worker wrapper file</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<script>
|
||||
'use strict';
|
||||
fetch_tests_from_worker(new SharedWorker('construct-byob-request.js'));
|
||||
</script>
|
|
@ -6,5 +6,6 @@
|
|||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<script src="../resources/rs-utils.js"></script>
|
||||
<script src="../resources/test-utils.js"></script>
|
||||
|
||||
<script src="general.js"></script>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
if (self.importScripts) {
|
||||
self.importScripts('../resources/rs-utils.js');
|
||||
self.importScripts('../resources/test-utils.js');
|
||||
self.importScripts('/resources/testharness.js');
|
||||
}
|
||||
|
||||
|
@ -1882,6 +1883,93 @@ promise_test(t => {
|
|||
}, 'ReadableStream with byte source: Throwing in pull in response to read(view) must be ignored if the stream is ' +
|
||||
'errored in it');
|
||||
|
||||
promise_test(() => {
|
||||
let byobRequest;
|
||||
const rs = new ReadableStream({
|
||||
pull(controller) {
|
||||
byobRequest = controller.byobRequest;
|
||||
byobRequest.respond(4);
|
||||
},
|
||||
type: 'bytes'
|
||||
});
|
||||
const reader = rs.getReader({ mode: 'byob' });
|
||||
const view = new Uint8Array(16);
|
||||
return reader.read(view).then(() => {
|
||||
assert_throws(new TypeError(), () => byobRequest.respond(4), 'respond() should throw a TypeError');
|
||||
});
|
||||
}, 'calling respond() twice on the same byobRequest should throw');
|
||||
|
||||
promise_test(() => {
|
||||
let byobRequest;
|
||||
const newView = () => new Uint8Array(16);
|
||||
const rs = new ReadableStream({
|
||||
pull(controller) {
|
||||
byobRequest = controller.byobRequest;
|
||||
byobRequest.respondWithNewView(newView());
|
||||
},
|
||||
type: 'bytes'
|
||||
});
|
||||
const reader = rs.getReader({ mode: 'byob' });
|
||||
return reader.read(newView()).then(() => {
|
||||
assert_throws(new TypeError(), () => byobRequest.respondWithNewView(newView()),
|
||||
'respondWithNewView() should throw a TypeError');
|
||||
});
|
||||
}, 'calling respondWithNewView() twice on the same byobRequest should throw');
|
||||
|
||||
promise_test(() => {
|
||||
let byobRequest;
|
||||
let resolvePullCalledPromise;
|
||||
const pullCalledPromise = new Promise(resolve => {
|
||||
resolvePullCalledPromise = resolve;
|
||||
});
|
||||
let resolvePull;
|
||||
const rs = new ReadableStream({
|
||||
pull(controller) {
|
||||
byobRequest = controller.byobRequest;
|
||||
resolvePullCalledPromise();
|
||||
return new Promise(resolve => {
|
||||
resolvePull = resolve;
|
||||
});
|
||||
},
|
||||
type: 'bytes'
|
||||
});
|
||||
const reader = rs.getReader({ mode: 'byob' });
|
||||
const readPromise = reader.read(new Uint8Array(16));
|
||||
return pullCalledPromise.then(() => {
|
||||
const cancelPromise = reader.cancel('meh');
|
||||
resolvePull();
|
||||
byobRequest.respond(0);
|
||||
return Promise.all([readPromise, cancelPromise]).then(() => {
|
||||
assert_throws(new TypeError(), () => byobRequest.respond(0), 'respond() should throw');
|
||||
});
|
||||
});
|
||||
}, 'calling respond(0) twice on the same byobRequest should throw even when closed');
|
||||
|
||||
promise_test(() => {
|
||||
let resolvePullCalledPromise;
|
||||
const pullCalledPromise = new Promise(resolve => {
|
||||
resolvePullCalledPromise = resolve;
|
||||
});
|
||||
let resolvePull;
|
||||
const rs = new ReadableStream({
|
||||
pull() {
|
||||
resolvePullCalledPromise();
|
||||
return new Promise(resolve => {
|
||||
resolvePull = resolve;
|
||||
});
|
||||
},
|
||||
type: 'bytes'
|
||||
});
|
||||
const reader = rs.getReader({ mode: 'byob' });
|
||||
reader.read(new Uint8Array(16));
|
||||
return pullCalledPromise.then(() => {
|
||||
resolvePull();
|
||||
return delay(0).then(() => {
|
||||
assert_throws(new TypeError(), () => reader.releaseLock(), 'releaseLock() should throw');
|
||||
});
|
||||
});
|
||||
}, 'pull() resolving should not make releaseLock() possible');
|
||||
|
||||
promise_test(() => {
|
||||
// Tests https://github.com/whatwg/streams/issues/686
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue