Update web-platform-tests to revision 84af6c875d378944b39d895acdcfc170736b2d3d

This commit is contained in:
WPT Sync Bot 2019-07-10 10:26:06 +00:00
parent d0bd2d5e44
commit b81cdc75ce
246 changed files with 10836 additions and 1337 deletions

View file

@ -1 +0,0 @@
onmessage = function (ev) { postMessage(ev.data); }

View file

@ -5,6 +5,7 @@
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
<script src="resources/test-sab.js"></script>
<div id="log"></div>
@ -13,9 +14,10 @@
"use strict";
async_test(t => {
const testId = token();
const sab = new SharedArrayBuffer(1);
window.addEventListener("message", t.step_func(({ data }) => {
if (data.testId !== 1) {
if (data.testId !== testId) {
return;
}
@ -24,15 +26,16 @@ async_test(t => {
t.done();
}));
window.postMessage({ sab, testId: 1 }, "*");
window.postMessage({ testId, sab }, "*");
}, "postMessaging to this window does not give back the same SharedArrayBuffer (but does use the same backing block)");
async_test(t => {
const testId = token();
const sab = new SharedArrayBuffer();
const worker = new Worker("resources/echo-worker.js");
const worker = new Worker("../resources/echo-worker.js");
worker.addEventListener("message", t.step_func(({ data }) => {
if (data.testId !== 2) {
if (data.testId !== testId) {
return;
}
@ -40,13 +43,14 @@ async_test(t => {
t.done();
}));
worker.postMessage({ testId: 2, sab });
worker.postMessage({ testId, sab });
}, "postMessaging to a worker and back does not give back the same SharedArrayBuffer");
async_test(t => {
const testId = token();
const sab = new SharedArrayBuffer();
window.addEventListener("message", t.step_func(({ data }) => {
if (data.testId !== 3) {
if (data.testId !== testId) {
return;
}
@ -56,9 +60,9 @@ async_test(t => {
const iframe = document.createElement("iframe");
iframe.onload = t.step_func(() => {
iframe.contentWindow.postMessage({ testId: 3, sab }, "*");
iframe.contentWindow.postMessage({ testId, sab }, "*");
});
iframe.src = "resources/echo-iframe.html";
iframe.src = "../resources/echo-iframe.html";
document.body.appendChild(iframe);
}, "postMessaging to an iframe and back does not give back the same SharedArrayBuffer");
</script>

View file

@ -17,7 +17,7 @@ test(() => {
test(() => {
const sab = new SharedArrayBuffer();
const worker = new Worker("resources/echo-worker.js");
const worker = new Worker("../resources/echo-worker.js");
assert_throws("DataCloneError", () => worker.postMessage(sab, [sab]));
assert_throws("DataCloneError", () => worker.postMessage("test", [sab]));
}, "Trying to transfer a SharedArrayBuffer to a worker throws");

View file

@ -0,0 +1,85 @@
// META: script=/common/utils.js
// .stack properties on errors are unspecified, but are present in most
// browsers, most of the time. https://github.com/tc39/proposal-error-stacks/ tracks standardizing them.
// Tests will pass automatically if the .stack property isn't present.
stackTests(() => {
return new Error('some message');
}, 'page-created Error');
stackTests(() => {
return new DOMException('InvalidStateError', 'some message');
}, 'page-created DOMException');
stackTests(() => {
try {
Object.defineProperty();
} catch (e) {
return e;
}
}, 'JS-engine-created TypeError');
stackTests(() => {
try {
HTMLParagraphElement.prototype.align;
} catch (e) {
return e;
}
}, 'web API-created TypeError');
stackTests(() => {
try {
document.createElement('');
} catch (e) {
return e;
}
}, 'web API-created DOMException');
function stackTests(errorFactory, description) {
async_test(t => {
const error = errorFactory();
const originalStack = error.stack;
if (!originalStack) {
t.done();
return;
}
const worker = new Worker('resources/echo-worker.js');
worker.onmessage = t.step_func_done(e => {
assert_equals(e.data.stack, originalStack);
});
worker.postMessage(error);
}, description + ' (worker)');
async_test(t => {
const thisTestId = token();
const error = errorFactory();
const originalStack = error.stack;
if (!originalStack) {
t.done();
return;
}
const iframe = document.createElement('iframe');
window.addEventListener('message', t.step_func(e => {
if (e.data.testId === thisTestId) {
assert_equals(e.data.error.stack, originalStack);
t.done();
}
}));
iframe.onload = t.step_func(() => {
iframe.contentWindow.postMessage({ error, testId: thisTestId }, "*");
});
const crossSiteEchoIFrame = new URL('resources/echo-iframe.html', location.href);
crossSiteEchoIFrame.hostname = '{{hosts[alt][www1]}}';
iframe.src = crossSiteEchoIFrame;
document.body.append(iframe);
}, description + ' (cross-site iframe)');
}

View file

@ -23,7 +23,7 @@
//the worker is used for each test in sequence
//worker's callback will be set for each test
//worker's internal onmessage echoes the data back to this thread through postMessage
worker = new Worker("./echo.js");
worker = new Worker("./resources/echo-worker.js");
testCollection = [
function() {
var t = async_test("Primitive BigInt is cloned");

View file

@ -9,6 +9,7 @@
</head>
<body>
<div id="log"></div>
<iframe></iframe> <!-- used for grabbing an URIError from another realm -->
<script type="text/javascript">
var worker;
@ -18,7 +19,7 @@
//the worker is used for each test in sequence
//worker's callback will be set for each test
//worker's internal onmessage echoes the data back to this thread through postMessage
worker = new Worker("./echo.js");
worker = new Worker("./resources/echo-worker.js");
testCollection = [
function() {
var t = async_test("Primitive string is cloned");
@ -367,7 +368,243 @@
assert_throws('DATA_CLONE_ERR', function() {worker.postMessage(document)});
});
t.done();
}
},
function() {
var t = async_test("Empty Error objects can be cloned");
t.id = 27;
worker.onmessage = t.step_func_done(function(e) {
assert_equals(Object.getPrototypeOf(e.data), Error.prototype, "Checking prototype");
assert_equals(e.data.constructor, Error, "Checking constructor");
assert_equals(e.data.name, "Error", "Checking name");
assert_false(e.data.hasOwnProperty("message"), "Checking message");
assert_equals(e.data.foo, undefined, "Checking custom property");
});
t.step(function() {
const error = Error();
assert_false(error.hasOwnProperty("message"), "Checking message on the source realm");
worker.postMessage(error);
});
},
function() {
var t = async_test("Error objects can be cloned");
t.id = 28;
worker.onmessage = t.step_func_done(function(e) {
assert_equals(Object.getPrototypeOf(e.data), Error.prototype, "Checking prototype");
assert_equals(e.data.constructor, Error, "Checking constructor");
assert_equals(e.data.name, "Error", "Checking name");
assert_equals(e.data.message, "some message", "Checking message");
assert_equals(e.data.foo, undefined, "Checking custom property");
});
t.step(function() {
const error = Error("some message");
error.foo = "bar";
worker.postMessage(error);
});
},
function() {
var t = async_test("EvalError objects can be cloned");
t.id = 29;
worker.onmessage = t.step_func_done(function(e) {
assert_equals(Object.getPrototypeOf(e.data), EvalError.prototype, "Checking prototype");
assert_equals(e.data.constructor, EvalError, "Checking constructor");
assert_equals(e.data.name, "EvalError", "Checking name");
assert_equals(e.data.message, "some message", "Checking message");
assert_equals(e.data.foo, undefined, "Checking custom property");
});
t.step(function() {
const error = EvalError("some message");
error.foo = "bar";
worker.postMessage(error);
});
},
function() {
var t = async_test("RangeError objects can be cloned");
t.id = 30;
worker.onmessage = t.step_func_done(function(e) {
assert_equals(Object.getPrototypeOf(e.data), RangeError.prototype, "Checking prototype");
assert_equals(e.data.constructor, RangeError, "Checking constructor");
assert_equals(e.data.name, "RangeError", "Checking name");
assert_equals(e.data.message, "some message", "Checking message");
assert_equals(e.data.foo, undefined, "Checking custom property");
});
t.step(function() {
const error = RangeError("some message");
error.foo = "bar";
worker.postMessage(error);
});
},
function() {
var t = async_test("ReferenceError objects can be cloned");
t.id = 31;
worker.onmessage = t.step_func_done(function(e) {
assert_equals(Object.getPrototypeOf(e.data), ReferenceError.prototype, "Checking prototype");
assert_equals(e.data.constructor, ReferenceError, "Checking constructor");
assert_equals(e.data.name, "ReferenceError", "Checking name");
assert_equals(e.data.message, "some message", "Checking message");
assert_equals(e.data.foo, undefined, "Checking custom property");
});
t.step(function() {
const error = ReferenceError("some message");
error.foo = "bar";
worker.postMessage(error);
});
},
function() {
var t = async_test("SyntaxError objects can be cloned");
t.id = 32;
worker.onmessage = t.step_func_done(function(e) {
assert_equals(Object.getPrototypeOf(e.data), SyntaxError.prototype, "Checking prototype");
assert_equals(e.data.constructor, SyntaxError, "Checking constructor");
assert_equals(e.data.name, "SyntaxError", "Checking name");
assert_equals(e.data.message, "some message", "Checking message");
assert_equals(e.data.foo, undefined, "Checking custom property");
});
t.step(function() {
const error = SyntaxError("some message");
error.foo = "bar";
worker.postMessage(error);
});
},
function() {
var t = async_test("TypeError objects can be cloned");
t.id = 33;
worker.onmessage = t.step_func_done(function(e) {
assert_equals(Object.getPrototypeOf(e.data), TypeError.prototype, "Checking prototype");
assert_equals(e.data.constructor, TypeError, "Checking constructor");
assert_equals(e.data.name, "TypeError", "Checking name");
assert_equals(e.data.message, "some message", "Checking message");
assert_equals(e.data.foo, undefined, "Checking custom property");
});
t.step(function() {
const error = TypeError("some message");
error.foo = "bar";
worker.postMessage(error);
});
},
function() {
var t = async_test("URIError objects can be cloned");
t.id = 34;
worker.onmessage = t.step_func_done(function(e) {
assert_equals(Object.getPrototypeOf(e.data), URIError.prototype, "Checking prototype");
assert_equals(e.data.constructor, URIError, "Checking constructor");
assert_equals(e.data.name, "URIError", "Checking name");
assert_equals(e.data.message, "some message", "Checking message");
assert_equals(e.data.foo, undefined, "Checking custom property");
});
t.step(function() {
const error = URIError("some message");
error.foo = "bar";
worker.postMessage(error);
});
},
function() {
var t = async_test("URIError objects from other realms are treated as Error");
t.id = 35;
worker.onmessage = t.step_func_done(function(e) {
assert_equals(Object.getPrototypeOf(e.data), Error.prototype, "Checking prototype");
assert_equals(e.data.constructor, Error, "Checking constructor");
assert_equals(e.data.name, "Error", "Checking name");
assert_equals(e.data.message, "some message", "Checking message");
assert_equals(e.data.foo, undefined, "Checking custom property");
});
t.step(function() {
const error = frames[0].URIError("some message");
assert_equals(Object.getPrototypeOf(error), frames[0].prototype, "Checking prototype before cloning");
assert_equals(error.constructor, frames[0].URIError, "Checking constructor before cloning");
assert_equals(error.name, "URIError", "Checking name before cloning");
error.foo = "bar";
worker.postMessage(error);
});
},
function() {
var t = async_test("Cloning a modified Error");
t.id = 36;
worker.onmessage = t.step_func_done(function(e) {
assert_equals(Object.getPrototypeOf(e.data), SyntaxError.prototype, "Checking prototype");
assert_equals(e.data.constructor, SyntaxError, "Checking constructor");
assert_equals(e.data.name, "SyntaxError", "Checking name");
assert_equals(e.data.message, "another message", "Checking message");
assert_equals(e.data.foo, undefined, "Checking custom property");
});
t.step(function() {
const error = URIError("some message");
Object.setPrototypeOf(error, SyntaxError.prototype);
error.message = {toString: () => "another message" }
error.constructor = RangeError;
error.name = "TypeError";
error.foo = "bar";
worker.postMessage(error);
});
},
function() {
var t = async_test("Error.message: getter is ignored when cloning");
t.id = 37;
worker.onmessage = t.step_func_done(function(e) {
assert_equals(Object.getPrototypeOf(e.data), Error.prototype, "Checking prototype");
assert_equals(e.data.constructor, Error, "Checking constructor");
assert_equals(e.data.name, "Error", "Checking name");
assert_false(e.data.hasOwnProperty("message"), "Checking message");
assert_equals(e.data.foo, undefined, "Checking custom property");
});
t.step(function() {
const error = Error();
Object.defineProperty(error, "message", { get: () => "hello" });
assert_equals(error.message, "hello", "Checking message on the source realm");
worker.postMessage(error);
});
},
function() {
var t = async_test("Error.message: undefined property is stringified");
t.id = 38;
worker.onmessage = t.step_func_done(function(e) {
assert_equals(Object.getPrototypeOf(e.data), Error.prototype, "Checking prototype");
assert_equals(e.data.constructor, Error, "Checking constructor");
assert_equals(e.data.name, "Error", "Checking name");
assert_equals(e.data.message, "undefined", "Checking message");
assert_equals(e.data.foo, undefined, "Checking custom property");
});
t.step(function() {
const error = Error();
error.message = undefined;
assert_equals(error.message, undefined, "Checking message on the source realm");
worker.postMessage(error);
});
},
function() {
var t = async_test("DOMException objects can be cloned");
t.id = 39;
worker.onmessage = t.step_func_done(function(e) {
assert_equals(Object.getPrototypeOf(e.data), DOMException.prototype, "Checking prototype");
assert_equals(e.data.constructor, DOMException, "Checking constructor");
assert_equals(e.data.name, "IndexSizeError", "Checking name");
assert_equals(e.data.message, "some message", "Checking message");
assert_equals(e.data.code, DOMException.INDEX_SIZE_ERR, "Checking code");
assert_equals(e.data.foo, undefined, "Checking custom property");
});
t.step(function() {
const error = new DOMException("some message", "IndexSizeError");
worker.postMessage(error);
});
},
function() {
var t = async_test("DOMException objects created by the UA can be cloned");
t.id = 40;
worker.onmessage = t.step_func_done(function(e) {
assert_equals(Object.getPrototypeOf(e.data), DOMException.prototype, "Checking prototype");
assert_equals(e.data.constructor, DOMException, "Checking constructor");
assert_equals(e.data.code, DOMException.DATA_CLONE_ERR, "Checking code");
assert_equals(e.data.name, "DataCloneError", "Checking name");
});
t.step(function() {
try {
worker.postMessage(window);
} catch (error) {
worker.postMessage(error);
return;
}
assert_unreached("Window must not be clonable");
});
},
];
}, {explicit_done:true});