Update web-platform-tests to revision 5084587f6b05bf99ad09e7844be66dcc61070cdf

This commit is contained in:
WPT Sync Bot 2018-04-25 21:10:30 -04:00 committed by Anthony Ramine
parent 6d42d2f1e8
commit 7d1071a6a4
408 changed files with 8968 additions and 2608 deletions

View file

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

View file

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

View file

@ -0,0 +1,53 @@
'use strict';
if (self.importScripts) {
self.importScripts('/resources/testharness.js');
self.importScripts('../resources/constructor-ordering.js');
}
const operations = [
op('get', 'size'),
op('get', 'highWaterMark'),
op('get', 'type'),
op('validate', 'type'),
op('validate', 'size'),
op('tonumber', 'highWaterMark'),
op('validate', 'highWaterMark'),
op('get', 'pull'),
op('validate', 'pull'),
op('get', 'cancel'),
op('validate', 'cancel'),
op('get', 'autoAllocateChunkSize'),
op('tonumber', 'autoAllocateChunkSize'),
op('validate', 'autoAllocateChunkSize'),
op('get', 'start'),
op('validate', 'start')
];
for (const failureOp of operations) {
test(() => {
const record = new OpRecorder(failureOp);
const underlyingSource = createRecordingObjectWithProperties(record, ['start', 'pull', 'cancel']);
// The valid value for "type" is "bytes", so set it separately.
defineCheckedProperty(record, underlyingSource, 'type', () => record.check('type') ? 'invalid' : 'bytes');
// autoAllocateChunkSize is a special case because it has a tonumber step.
defineCheckedProperty(record, underlyingSource, 'autoAllocateChunkSize',
() => createRecordingNumberObject(record, 'autoAllocateChunkSize'));
const strategy = createRecordingStrategy(record);
try {
new ReadableStream(underlyingSource, strategy);
assert_unreached('constructor should throw');
} catch (e) {
assert_equals(typeof e, 'object', 'e should be an object');
}
assert_equals(record.actual(), expectedAsString(operations, failureOp),
'operations should be performed in the right order');
}, `ReadableStream constructor should stop after ${failureOp} fails`);
}
done();

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,42 @@
'use strict';
if (self.importScripts) {
self.importScripts('/resources/testharness.js');
self.importScripts('../resources/constructor-ordering.js');
}
const operations = [
op('get', 'size'),
op('get', 'highWaterMark'),
op('get', 'type'),
op('validate', 'type'),
op('validate', 'size'),
op('tonumber', 'highWaterMark'),
op('validate', 'highWaterMark'),
op('get', 'pull'),
op('validate', 'pull'),
op('get', 'cancel'),
op('validate', 'cancel'),
op('get', 'start'),
op('validate', 'start')
];
for (const failureOp of operations) {
test(() => {
const record = new OpRecorder(failureOp);
const underlyingSource = createRecordingObjectWithProperties(record, ['type', 'start', 'pull', 'cancel']);
const strategy = createRecordingStrategy(record);
try {
new ReadableStream(underlyingSource, strategy);
assert_unreached('constructor should throw');
} catch (e) {
assert_equals(typeof e, 'object', 'e should be an object');
}
assert_equals(record.actual(), expectedAsString(operations, failureOp),
'operations should be performed in the right order');
}, `ReadableStream constructor should stop after ${failureOp} fails`);
}
done();

View file

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

View file

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

View file

@ -0,0 +1,129 @@
'use strict';
// Helpers for tests that constructors perform getting and validation of properties in the standard order.
// See ../readable-streams/constructor.js for an example of how to use them.
// Describes an operation on a property. |type| is "get", "validate" or "tonumber". |name| is the name of the property
// in question. |side| is usually undefined, but is used by TransformStream to distinguish between the readable and
// writable strategies.
class Op {
constructor(type, name, side) {
this.type = type;
this.name = name;
this.side = side;
}
toString() {
return this.side === undefined ? `${this.type} on ${this.name}` : `${this.type} on ${this.name} (${this.side})`;
}
equals(otherOp) {
return this.type === otherOp.type && this.name === otherOp.name && this.side === otherOp.side;
}
}
// Provides a concise syntax to create an Op object. |side| is used by TransformStream to distinguish between the two
// strategies.
function op(type, name, side = undefined) {
return new Op(type, name, side);
}
// Records a sequence of operations. Also checks each operation against |failureOp| to see if it should fail.
class OpRecorder {
constructor(failureOp) {
this.ops = [];
this.failureOp = failureOp;
this.matched = false;
}
// Record an operation. Returns true if this operation should fail.
recordAndCheck(type, name, side = undefined) {
const recordedOp = op(type, name, side);
this.ops.push(recordedOp);
return this.failureOp.equals(recordedOp);
}
// Returns true if validation of this property should fail.
check(name, side = undefined) {
return this.failureOp.equals(op('validate', name, side));
}
// Returns the sequence of recorded operations as a string.
actual() {
return this.ops.toString();
}
}
// Creates an object with the list of properties named in |properties|. Every property access will be recorded in
// |record|, which will also be used to determine whether a particular property access should fail, or whether it should
// return an invalid value that will fail validation.
function createRecordingObjectWithProperties(record, properties) {
const recordingObject = {};
for (const property of properties) {
defineCheckedProperty(record, recordingObject, property, () => record.check(property) ? 'invalid' : undefined);
}
return recordingObject;
}
// Add a getter to |object| named |property| which throws if op('get', property) should fail, and otherwise calls
// getter() to get the return value.
function defineCheckedProperty(record, object, property, getter) {
Object.defineProperty(object, property, {
get() {
if (record.recordAndCheck('get', property)) {
throw new Error(`intentional failure of get ${property}`);
}
return getter();
}
});
}
// Similar to createRecordingObjectWithProperties(), but with specific functionality for "highWaterMark" so that numeric
// conversion can be recorded. Permits |side| to be specified so that TransformStream can distinguish between its two
// strategies.
function createRecordingStrategy(record, side = undefined) {
return {
get size() {
if (record.recordAndCheck('get', 'size', side)) {
throw new Error(`intentional failure of get size`);
}
return record.check('size', side) ? 'invalid' : undefined;
},
get highWaterMark() {
if (record.recordAndCheck('get', 'highWaterMark', side)) {
throw new Error(`intentional failure of get highWaterMark`);
}
return createRecordingNumberObject(record, 'highWaterMark', side);
}
};
}
// Creates an object which will record when it is converted to a number. It will assert if the conversion is to some
// other type, and will fail if op('tonumber', property, side) is set as the failure step. The object will convert to -1
// if 'validate' is set as the failure step, and 1 otherwise.
function createRecordingNumberObject(record, property, side = undefined) {
return {
[Symbol.toPrimitive](hint) {
assert_equals(hint, 'number', `hint for ${property} should be 'number'`);
if (record.recordAndCheck('tonumber', property, side)) {
throw new Error(`intentional failure of ${op('tonumber', property, side)}`);
}
return record.check(property, side) ? -1 : 1;
}
};
}
// Creates a string from everything in |operations| up to and including |failureOp|. "validate" steps are excluded from
// the output, as we cannot record them except by making them fail.
function expectedAsString(operations, failureOp) {
const expected = [];
for (const step of operations) {
if (step.type !== 'validate') {
expected.push(step);
}
if (step.equals(failureOp)) {
break;
}
}
return expected.toString();
}

View file

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

View file

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

View file

@ -0,0 +1,51 @@
'use strict';
if (self.importScripts) {
self.importScripts('/resources/testharness.js');
self.importScripts('../resources/constructor-ordering.js');
}
const operations = [
op('get', 'size', 'writable'),
op('get', 'highWaterMark', 'writable'),
op('get', 'size', 'readable'),
op('get', 'highWaterMark', 'readable'),
op('get', 'writableType'),
op('validate', 'writableType'),
op('validate', 'size', 'writable'),
op('tonumber', 'highWaterMark', 'writable'),
op('validate', 'highWaterMark', 'writable'),
op('get', 'readableType'),
op('validate', 'readableType'),
op('validate', 'size', 'readable'),
op('tonumber', 'highWaterMark', 'readable'),
op('validate', 'highWaterMark', 'readable'),
op('get', 'transform'),
op('validate', 'transform'),
op('get', 'flush'),
op('validate', 'flush'),
op('get', 'start'),
op('validate', 'start')
];
for (const failureOp of operations) {
test(() => {
const record = new OpRecorder(failureOp);
const transformer = createRecordingObjectWithProperties(
record, ['readableType', 'writableType', 'start', 'transform', 'flush']);
const writableStrategy = createRecordingStrategy(record, 'writable');
const readableStrategy = createRecordingStrategy(record, 'readable');
try {
new TransformStream(transformer, writableStrategy, readableStrategy);
assert_unreached('constructor should throw');
} catch (e) {
assert_equals(typeof e, 'object', 'e should be an object');
}
assert_equals(record.actual(), expectedAsString(operations, failureOp),
'operations should be performed in the right order');
}, `TransformStream constructor should stop after ${failureOp} fails`);
}
done();

View file

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

View file

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

View file

@ -182,10 +182,10 @@ for (const method in transformerMethods) {
}
const transformer = new Proxy({}, handler);
const ts = new TransformStream(transformer, undefined, { highWaterMark: Infinity });
assert_array_equals(touchedProperties, ['readableType', 'writableType', 'transform', 'flush', 'start'],
assert_array_equals(touchedProperties, ['writableType', 'readableType', 'transform', 'flush', 'start'],
'expected properties should be got');
return trigger(ts).then(() => {
assert_array_equals(touchedProperties, ['readableType', 'writableType', 'transform', 'flush', 'start'],
assert_array_equals(touchedProperties, ['writableType', 'readableType', 'transform', 'flush', 'start'],
'no properties should be accessed on method call');
});
}, `unexpected properties should not be accessed when calling transformer method ${method}`);

View file

@ -5,6 +5,6 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/constructor-ordering.js"></script>
<script src="constructor.js"></script>

View file

@ -2,6 +2,7 @@
if (self.importScripts) {
self.importScripts('/resources/testharness.js');
self.importScripts('../resources/constructor-ordering.js');
}
const error1 = new Error('error1');
@ -119,7 +120,7 @@ test(() => {
assert_throws(new TypeError(), () => new WritableStreamDefaultController({}),
'constructor should throw a TypeError exception');
}, 'WritableStreamDefaultController constructor should throw unless passed a WritableStream');
}, 'WritableStreamDefaultController constructor should throw');
test(() => {
let WritableStreamDefaultController;
@ -150,4 +151,40 @@ test(() => {
'constructor should throw a TypeError exception');
}, 'WritableStreamDefaultWriter constructor should throw when stream argument is locked');
const operations = [
op('get', 'size'),
op('get', 'highWaterMark'),
op('get', 'type'),
op('validate', 'type'),
op('validate', 'size'),
op('tonumber', 'highWaterMark'),
op('validate', 'highWaterMark'),
op('get', 'write'),
op('validate', 'write'),
op('get', 'close'),
op('validate', 'close'),
op('get', 'abort'),
op('validate', 'abort'),
op('get', 'start'),
op('validate', 'start')
];
for (const failureOp of operations) {
test(() => {
const record = new OpRecorder(failureOp);
const underlyingSink = createRecordingObjectWithProperties(record, ['type', 'start', 'write', 'close', 'abort']);
const strategy = createRecordingStrategy(record);
try {
new WritableStream(underlyingSink, strategy);
assert_unreached('constructor should throw');
} catch (e) {
assert_equals(typeof e, 'object', 'e should be an object');
}
assert_equals(record.actual(), expectedAsString(operations, failureOp),
'operations should be performed in the right order');
}, `WritableStream constructor should stop after ${failureOp} fails`);
}
done();