Update web-platform-tests to revision 7a767a52741f628430ffbbed46e7f3df68ba3534

Fixes #15648.
This commit is contained in:
Ms2ger 2017-02-20 11:44:42 +01:00
parent a1e4c547f0
commit 4fadf9b0b6
1184 changed files with 22551 additions and 9856 deletions

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>floating-point-total-queue-size.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('floating-point-total-queue-size.js'));
</script>

View file

@ -0,0 +1,10 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>floating-point-total-queue-size.js browser context wrapper file</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="floating-point-total-queue-size.js"></script>

View file

@ -0,0 +1,119 @@
'use strict';
if (self.importScripts) {
self.importScripts('/resources/testharness.js');
}
// Due to the limitations of floating-point precision, the calculation of desiredSize sometimes gives different answers
// than adding up the items in the queue would. It is important that implementations give the same result in these edge
// cases so that developers do not come to depend on non-standard behaviour. See
// https://github.com/whatwg/streams/issues/582 and linked issues for further discussion.
promise_test(() => {
const { reader, controller } = setupTestStream();
controller.enqueue(2);
assert_equals(controller.desiredSize, 0 - 2, 'desiredSize must be -2 after enqueueing such a chunk');
controller.enqueue(Number.MAX_SAFE_INTEGER);
assert_equals(controller.desiredSize, 0 - Number.MAX_SAFE_INTEGER - 2,
'desiredSize must be calculated using double-precision floating-point arithmetic (adding a second chunk)');
return reader.read().then(() => {
assert_equals(controller.desiredSize, 0 - Number.MAX_SAFE_INTEGER - 2 + 2,
'desiredSize must be calculated using double-precision floating-point arithmetic (subtracting a chunk)');
return reader.read();
}).then(() => {
assert_equals(controller.desiredSize, 0, '[[queueTotalSize]] must clamp to 0 if it becomes negative');
});
}, 'Floating point arithmetic must manifest near NUMBER.MAX_SAFE_INTEGER (total ends up positive)');
promise_test(() => {
const { reader, controller } = setupTestStream();
controller.enqueue(1e-16);
assert_equals(controller.desiredSize, 0 - 1e-16, 'desiredSize must be -1e16 after enqueueing such a chunk');
controller.enqueue(1);
assert_equals(controller.desiredSize, 0 - 1e-16 - 1,
'desiredSize must be calculated using double-precision floating-point arithmetic (adding a second chunk)');
return reader.read().then(() => {
assert_equals(controller.desiredSize, 0 - 1e-16 - 1 + 1e-16,
'desiredSize must be calculated using double-precision floating-point arithmetic (subtracting a chunk)');
return reader.read();
}).then(() => {
assert_equals(controller.desiredSize, 0, '[[queueTotalSize]] must clamp to 0 if it becomes negative');
});
}, 'Floating point arithmetic must manifest near 0 (total ends up positive, but clamped)');
promise_test(() => {
const { reader, controller } = setupTestStream();
controller.enqueue(1e-16);
assert_equals(controller.desiredSize, 0 - 1e-16, 'desiredSize must be -2e16 after enqueueing such a chunk');
controller.enqueue(1);
assert_equals(controller.desiredSize, 0 - 1e-16 - 1,
'desiredSize must be calculated using double-precision floating-point arithmetic (adding a second chunk)');
controller.enqueue(2e-16);
assert_equals(controller.desiredSize, 0 - 1e-16 - 1 - 2e-16,
'desiredSize must be calculated using double-precision floating-point arithmetic (adding a third chunk)');
return reader.read().then(() => {
assert_equals(controller.desiredSize, 0 - 1e-16 - 1 - 2e-16 + 1e-16,
'desiredSize must be calculated using double-precision floating-point arithmetic (subtracting a chunk)');
return reader.read();
}).then(() => {
assert_equals(controller.desiredSize, 0 - 1e-16 - 1 - 2e-16 + 1e-16 + 1,
'desiredSize must be calculated using double-precision floating-point arithmetic (subtracting a second chunk)');
return reader.read();
}).then(() => {
assert_equals(controller.desiredSize, 0 - 1e-16 - 1 - 2e-16 + 1e-16 + 1 + 2e-16,
'desiredSize must be calculated using double-precision floating-point arithmetic (subtracting a third chunk)');
});
}, 'Floating point arithmetic must manifest near 0 (total ends up positive, and not clamped)');
promise_test(() => {
const { reader, controller } = setupTestStream();
controller.enqueue(2e-16);
assert_equals(controller.desiredSize, 0 - 2e-16, 'desiredSize must be -2e16 after enqueueing such a chunk');
controller.enqueue(1);
assert_equals(controller.desiredSize, 0 - 2e-16 - 1,
'desiredSize must be calculated using double-precision floating-point arithmetic (adding a second chunk)');
return reader.read().then(() => {
assert_equals(controller.desiredSize, 0 - 2e-16 - 1 + 2e-16,
'desiredSize must be calculated using double-precision floating-point arithmetic (subtracting a chunk)');
return reader.read();
}).then(() => {
assert_equals(controller.desiredSize, 0,
'desiredSize must be calculated using double-precision floating-point arithmetic (subtracting a second chunk)');
});
}, 'Floating point arithmetic must manifest near 0 (total ends up zero)');
function setupTestStream() {
const strategy = {
size(x) {
return x;
},
highWaterMark: 0
};
let controller;
const rs = new ReadableStream({
start(c) {
controller = c;
}
}, strategy);
return { reader: rs.getReader(), controller };
}

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>floating-point-total-queue-size.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('floating-point-total-queue-size.js', 'Service worker test setup');
</script>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>floating-point-total-queue-size.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('floating-point-total-queue-size.js'));
</script>

View file

@ -732,6 +732,30 @@ promise_test(() => {
}, 'ReadableStream: should call underlying source methods as methods');
test(() => {
const rs = new ReadableStream({
start(c) {
assert_equals(c.desiredSize, 10, 'desiredSize must start at highWaterMark');
c.close();
assert_equals(c.desiredSize, 0, 'after closing, desiredSize must be 0');
}
}, {
highWaterMark: 10
});
}, 'ReadableStream: desiredSize when closed');
test(() => {
const rs = new ReadableStream({
start(c) {
assert_equals(c.desiredSize, 10, 'desiredSize must start at highWaterMark');
c.error();
assert_equals(c.desiredSize, null, 'after erroring, desiredSize must be null');
}
}, {
highWaterMark: 10
});
}, 'ReadableStream: desiredSize when errored');
test(() => {
let startCalled = false;

View file

@ -61,7 +61,7 @@ promise_test(t => {
const writer = ws.getWriter();
const p1 = promise_rejects(t, error1, writer.write('a'), 'write should reject with the thrown error');
const p1 = promise_rejects(t, new TypeError(), writer.write('a'), 'write should reject with a TypeError');
const p2 = promise_rejects(t, error1, writer.closed, 'closed should reject with the thrown error');

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>floating-point-total-queue-size.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('floating-point-total-queue-size.js'));
</script>

View file

@ -0,0 +1,10 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>floating-point-total-queue-size.js browser context wrapper file</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="floating-point-total-queue-size.js"></script>

View file

@ -0,0 +1,90 @@
'use strict';
if (self.importScripts) {
self.importScripts('/resources/testharness.js');
}
// Due to the limitations of floating-point precision, the calculation of desiredSize sometimes gives different answers
// than adding up the items in the queue would. It is important that implementations give the same result in these edge
// cases so that developers do not come to depend on non-standard behaviour. See
// https://github.com/whatwg/streams/issues/582 and linked issues for further discussion.
promise_test(() => {
const writer = setupTestStream();
const writePromises = [
writer.write(2),
writer.write(Number.MAX_SAFE_INTEGER)
];
assert_equals(writer.desiredSize, 0 - 2 - Number.MAX_SAFE_INTEGER,
'desiredSize must be calculated using double-precision floating-point arithmetic (after writing two chunks)');
return Promise.all(writePromises).then(() => {
assert_equals(writer.desiredSize, 0, '[[queueTotalSize]] must clamp to 0 if it becomes negative');
});
}, 'Floating point arithmetic must manifest near NUMBER.MAX_SAFE_INTEGER (total ends up positive)');
promise_test(() => {
const writer = setupTestStream();
const writePromises = [
writer.write(1e-16),
writer.write(1)
];
assert_equals(writer.desiredSize, 0 - 1e-16 - 1,
'desiredSize must be calculated using double-precision floating-point arithmetic (after writing two chunks)');
return Promise.all(writePromises).then(() => {
assert_equals(writer.desiredSize, 0, '[[queueTotalSize]] must clamp to 0 if it becomes negative');
});
}, 'Floating point arithmetic must manifest near 0 (total ends up positive, but clamped)');
promise_test(() => {
const writer = setupTestStream();
const writePromises = [
writer.write(1e-16),
writer.write(1),
writer.write(2e-16)
];
assert_equals(writer.desiredSize, 0 - 1e-16 - 1 - 2e-16,
'desiredSize must be calculated using double-precision floating-point arithmetic (after writing three chunks)');
return Promise.all(writePromises).then(() => {
assert_equals(writer.desiredSize, 0 - 1e-16 - 1 - 2e-16 + 1e-16 + 1 + 2e-16,
'desiredSize must be calculated using floating-point arithmetic (after the three chunks have finished writing)');
});
}, 'Floating point arithmetic must manifest near 0 (total ends up positive, and not clamped)');
promise_test(() => {
const writer = setupTestStream();
const writePromises = [
writer.write(2e-16),
writer.write(1)
];
assert_equals(writer.desiredSize, 0 - 2e-16 - 1,
'desiredSize must be calculated using double-precision floating-point arithmetic (after writing two chunks)');
return Promise.all(writePromises).then(() => {
assert_equals(writer.desiredSize, 0 - 2e-16 - 1 + 2e-16 + 1,
'desiredSize must be calculated using floating-point arithmetic (after the two chunks have finished writing)');
});
}, 'Floating point arithmetic must manifest near 0 (total ends up zero)');
function setupTestStream() {
const strategy = {
size(x) {
return x;
},
highWaterMark: 0
};
const ws = new WritableStream({}, strategy);
return ws.getWriter();
}

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>floating-point-total-queue-size.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('floating-point-total-queue-size.js', 'Service worker test setup');
</script>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>floating-point-total-queue-size.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('floating-point-total-queue-size.js'));
</script>

View file

@ -32,6 +32,17 @@ promise_test(() => {
});
}, 'desiredSize on a writer for a closed stream');
test(() => {
const ws = new WritableStream({
start(c) {
c.error();
}
});
const writer = ws.getWriter();
assert_equals(writer.desiredSize, null, 'desiredSize should be null');
}, 'desiredSize on a writer for an errored stream');
test(() => {
const ws = new WritableStream({});

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>reentrant-strategy.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('reentrant-strategy.js'));
</script>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>reentrant-strategy.js browser context wrapper file</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/test-utils.js"></script>
<script src="../resources/recording-streams.js"></script>
<script src="reentrant-strategy.js"></script>

View file

@ -0,0 +1,179 @@
'use strict';
// These tests exercise the pathological case of calling WritableStream* methods from within the strategy.size()
// callback. This is not something any real code should ever do. Failures here indicate subtle deviations from the
// standard that may affect real, non-pathological code.
if (self.importScripts) {
self.importScripts('/resources/testharness.js');
self.importScripts('../resources/test-utils.js');
self.importScripts('../resources/recording-streams.js');
}
const error1 = { name: 'error1' };
promise_test(() => {
let writer;
const strategy = {
size(chunk) {
if (chunk > 0) {
writer.write(chunk - 1);
}
return chunk;
}
};
const ws = recordingWritableStream({}, strategy);
writer = ws.getWriter();
return writer.write(2)
.then(() => {
assert_array_equals(ws.events, ['write', 0, 'write', 1, 'write', 2], 'writes should appear in order');
});
}, 'writes should be written in the standard order');
promise_test(() => {
let writer;
const events = [];
const strategy = {
size(chunk) {
events.push('size', chunk);
if (chunk > 0) {
writer.write(chunk - 1)
.then(() => events.push('writer.write done', chunk - 1));
}
return chunk;
}
};
const ws = new WritableStream({
write(chunk) {
events.push('sink.write', chunk);
}
}, strategy);
writer = ws.getWriter();
return writer.write(2)
.then(() => events.push('writer.write done', 2))
.then(() => flushAsyncEvents())
.then(() => {
assert_array_equals(events, ['size', 2, 'size', 1, 'size', 0,
'sink.write', 0, 'sink.write', 1, 'writer.write done', 0,
'sink.write', 2, 'writer.write done', 1,
'writer.write done', 2],
'events should happen in standard order');
});
}, 'writer.write() promises should resolve in the standard order');
promise_test(t => {
let controller;
const strategy = {
size() {
controller.error(error1);
return 1;
}
};
const ws = recordingWritableStream({
start(c) {
controller = c;
}
}, strategy);
const resolved = [];
const writer = ws.getWriter();
const readyPromise1 = writer.ready.then(() => resolved.push('ready1'));
const writePromise = promise_rejects(t, new TypeError(), writer.write(),
'write() should reject with a TypeError')
.then(() => resolved.push('write'));
const readyPromise2 = promise_rejects(t, error1, writer.ready, 'ready should reject with error1')
.then(() => resolved.push('ready2'));
const closedPromise = promise_rejects(t, error1, writer.closed, 'closed should reject with error1')
.then(() => resolved.push('closed'));
return Promise.all([readyPromise1, writePromise, readyPromise2, closedPromise])
.then(() => {
assert_array_equals(resolved, ['ready1', 'write', 'ready2', 'closed'],
'promises should resolve in standard order');
assert_array_equals(ws.events, [], 'underlying sink write should not be called');
});
}, 'controller.error() should work when called from within strategy.size()');
promise_test(t => {
let writer;
const strategy = {
size() {
writer.close();
return 1;
}
};
const ws = recordingWritableStream({}, strategy);
writer = ws.getWriter();
return promise_rejects(t, new TypeError(), writer.write('a'), 'write() promise should reject')
.then(() => {
assert_array_equals(ws.events, ['close'], 'sink.write() should not be called');
});
}, 'close() should work when called from within strategy.size()');
promise_test(t => {
let writer;
const strategy = {
size() {
writer.abort('nice');
return 1;
}
};
const ws = recordingWritableStream({}, strategy);
writer = ws.getWriter();
return promise_rejects(t, new TypeError(), writer.write('a'), 'write() promise should reject')
.then(() => {
assert_array_equals(ws.events, ['abort', 'nice'], 'sink.write() should not be called');
});
}, 'abort() should work when called from within strategy.size()');
promise_test(t => {
let writer;
const strategy = {
size() {
writer.releaseLock();
return 1;
}
};
const ws = recordingWritableStream({}, strategy);
writer = ws.getWriter();
const writePromise = promise_rejects(t, new TypeError(), writer.write('a'), 'write() promise should reject');
const readyPromise = promise_rejects(t, new TypeError(), writer.ready, 'ready promise should reject');
const closedPromise = promise_rejects(t, new TypeError(), writer.closed, 'closed promise should reject');
return Promise.all([writePromise, readyPromise, closedPromise])
.then(() => {
assert_array_equals(ws.events, [], 'sink.write() should not be called');
});
}, 'releaseLock() should abort the write() when called within strategy.size()');
promise_test(t => {
let writer1;
let ws;
let writePromise2;
let closePromise;
let closedPromise2;
const strategy = {
size(chunk) {
if (chunk > 0) {
writer1.releaseLock();
const writer2 = ws.getWriter();
writePromise2 = writer2.write(0);
closePromise = writer2.close();
closedPromise2 = writer2.closed;
}
return 1;
}
};
ws = recordingWritableStream({}, strategy);
writer1 = ws.getWriter();
const writePromise1 = promise_rejects(t, new TypeError(), writer1.write(1), 'write() promise should reject');
const readyPromise = promise_rejects(t, new TypeError(), writer1.ready, 'ready promise should reject');
const closedPromise1 = promise_rejects(t, new TypeError(), writer1.closed, 'closed promise should reject');
return Promise.all([writePromise1, readyPromise, closedPromise1, writePromise2, closePromise, closedPromise2])
.then(() => {
assert_array_equals(ws.events, ['write', 0, 'close'], 'sink.write() should only be called once');
});
}, 'original reader should error when new reader is created within strategy.size()');
done();

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>reentrant-strategy.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('reentrant-strategy.js', 'Service worker test setup');
</script>

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>reentrant-strategy.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('reentrant-strategy.js'));
</script>