Skip to content

Commit

Permalink
test: update wpt
Browse files Browse the repository at this point in the history
  • Loading branch information
avivkeller committed Aug 28, 2024
1 parent 3a71ccf commit bf3a767
Show file tree
Hide file tree
Showing 248 changed files with 8,671 additions and 1,339 deletions.
397 changes: 313 additions & 84 deletions test/fixtures/wpt/FileAPI/BlobURL/cross-partition.tentative.https.html

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions test/fixtures/wpt/FileAPI/blob/Blob-constructor.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,22 @@ test_blob(function() {
new Int16Array([0x4150, 0x5353]),
new Uint32Array([0x53534150]),
new Int32Array([0x53534150]),
new Float16Array([2.65625, 58.59375]),
new Float32Array([0xD341500000])
]);
}, {
expected: "PASSPASSPASSPASSPASSPASSPASSPASS",
expected: "PASSPASSPASSPASSPASSPASSPASS",
type: "",
desc: "Passing typed arrays as elements of the blobParts array should work."
});
test_blob(function() {
return new Blob([
new Float16Array([2.65625, 58.59375])
]);
}, {
expected: "PASS",
type: "",
desc: "Passing a Float16Array as element of the blobParts array should work."
});
test_blob(function() {
return new Blob([
// 0x535 3415053534150
Expand Down
40 changes: 20 additions & 20 deletions test/fixtures/wpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@ See [test/wpt](../../wpt/README.md) for information on how these tests are run.

Last update:

- common: https://github.com/web-platform-tests/wpt/tree/dbd648158d/common
- compression: https://github.com/web-platform-tests/wpt/tree/5aa50dd415/compression
- console: https://github.com/web-platform-tests/wpt/tree/767ae35464/console
- dom/abort: https://github.com/web-platform-tests/wpt/tree/d1f1ecbd52/dom/abort
- dom/events: https://github.com/web-platform-tests/wpt/tree/ab8999891c/dom/events
- common: https://github.com/web-platform-tests/wpt/tree/d8da9d4d1d/common
- compression: https://github.com/web-platform-tests/wpt/tree/da8d6860b2/compression
- console: https://github.com/web-platform-tests/wpt/tree/e48251b778/console
- dom/abort: https://github.com/web-platform-tests/wpt/tree/07a9d09a8f/dom/abort
- dom/events: https://github.com/web-platform-tests/wpt/tree/0a811c5161/dom/events
- encoding: https://github.com/web-platform-tests/wpt/tree/5aa50dd415/encoding
- fetch/data-urls/resources: https://github.com/web-platform-tests/wpt/tree/7c79d998ff/fetch/data-urls/resources
- FileAPI: https://github.com/web-platform-tests/wpt/tree/cceaf3628d/FileAPI
- hr-time: https://github.com/web-platform-tests/wpt/tree/34cafd797e/hr-time
- FileAPI: https://github.com/web-platform-tests/wpt/tree/1d5fb397da/FileAPI
- hr-time: https://github.com/web-platform-tests/wpt/tree/614e81711c/hr-time
- html/webappapis/atob: https://github.com/web-platform-tests/wpt/tree/f267e1dca6/html/webappapis/atob
- html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/2c5c3c4c27/html/webappapis/microtask-queuing
- html/webappapis/structured-clone: https://github.com/web-platform-tests/wpt/tree/47d3fb280c/html/webappapis/structured-clone
- html/webappapis/timers: https://github.com/web-platform-tests/wpt/tree/5873f2d8f1/html/webappapis/timers
- interfaces: https://github.com/web-platform-tests/wpt/tree/e90ece61d6/interfaces
- performance-timeline: https://github.com/web-platform-tests/wpt/tree/17ebc3aea0/performance-timeline
- resource-timing: https://github.com/web-platform-tests/wpt/tree/22d38586d0/resource-timing
- resources: https://github.com/web-platform-tests/wpt/tree/1e140d63ec/resources
- streams: https://github.com/web-platform-tests/wpt/tree/2bd26e124c/streams
- url: https://github.com/web-platform-tests/wpt/tree/6a39784534/url
- html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/22ecfc9bac/html/webappapis/microtask-queuing
- html/webappapis/structured-clone: https://github.com/web-platform-tests/wpt/tree/c29dcddf37/html/webappapis/structured-clone
- html/webappapis/timers: https://github.com/web-platform-tests/wpt/tree/7a0548ac47/html/webappapis/timers
- interfaces: https://github.com/web-platform-tests/wpt/tree/ab18bf796b/interfaces
- performance-timeline: https://github.com/web-platform-tests/wpt/tree/94caab7038/performance-timeline
- resource-timing: https://github.com/web-platform-tests/wpt/tree/95e7763ca9/resource-timing
- resources: https://github.com/web-platform-tests/wpt/tree/ff5b1bc4db/resources
- streams: https://github.com/web-platform-tests/wpt/tree/b5f2d0c48a/streams
- url: https://github.com/web-platform-tests/wpt/tree/30de089033/url
- user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/140f5c80fd/wasm/jsapi
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/28456b73ca/wasm/webapi
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/5e042cbc4e/WebCryptoAPI
- webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/a370aad338/webidl/ecmascript-binding/es-exceptions
- webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/e97fac4791/webmessaging/broadcastchannel
- webstorage: https://github.com/web-platform-tests/wpt/tree/9dafa89214/webstorage
- webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/6495c91853/webmessaging/broadcastchannel
- webstorage: https://github.com/web-platform-tests/wpt/tree/1291340aaa/webstorage

[Web Platform Tests]: https://github.com/web-platform-tests/wpt
[`git node wpt`]: https://github.com/nodejs/node-core-utils/blob/main/docs/git-node.md#git-node-wpt
1 change: 0 additions & 1 deletion test/fixtures/wpt/common/META.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
suggested_reviewers:
- zqzhang
- deniak
29 changes: 27 additions & 2 deletions test/fixtures/wpt/common/dispatcher/dispatcher.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
// Define a universal message passing API. It works cross-origin and across
// browsing context groups.
const dispatcher_path = "/common/dispatcher/dispatcher.py";
const dispatcher_url = new URL(dispatcher_path, location.href).href;

// Finds the nearest ancestor window that has a non srcdoc location. This should
// give us a usable location for constructing further URLs.
function findLocationFromAncestors(w) {
if (w.location.href == 'about:srcdoc') {
return findLocationFromAncestors(w.parent);
}
return w.location;
}

// Handles differences between workers vs frames (src vs srcdoc).
function findLocation() {
if (location.href == 'about:srcdoc') {
return findLocationFromAncestors(window.parent);
}
if (location.protocol == 'blob:' || location.protocol == 'data:') {
// Allows working around blob and data URLs.
if (self.document && self.document.baseURI) {
return self.document.baseURI;
}
}
return location;
}

const dispatcherLocation = findLocation();
const dispatcher_url = new URL(dispatcher_path, dispatcherLocation).href;

// Return a promise, limiting the number of concurrent accesses to a shared
// resources to |max_concurrent_access|.
Expand Down Expand Up @@ -138,7 +163,7 @@ const cacheableShowRequestHeaders = function(origin, uuid) {
// protocol: (optional) Sets the returned URL's `protocol` property.
// }
function remoteExecutorUrl(uuid, options) {
const url = new URL("/common/dispatcher/remote-executor.html", location);
const url = new URL("/common/dispatcher/remote-executor.html", dispatcherLocation);
url.searchParams.set("uuid", uuid);

if (options?.host) {
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/wpt/common/dummy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
16 changes: 9 additions & 7 deletions test/fixtures/wpt/common/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ function getVideoURI(base)

var videotag = document.createElement("video");

if ( videotag.canPlayType &&
videotag.canPlayType('video/ogg; codecs="theora, vorbis"') )
if ( videotag.canPlayType )
{
extension = '.ogv';
if (videotag.canPlayType('video/webm; codecs="vp9, opus"') )
{
extension = '.webm';
}
}

return base + extension;
Expand Down Expand Up @@ -46,10 +48,10 @@ function getAudioURI(base)
function getMediaContentType(url) {
var extension = new URL(url, location).pathname.split(".").pop();
var map = {
"mp4": "video/mp4",
"ogv": "application/ogg",
"mp3": "audio/mp3",
"oga": "application/ogg",
"mp4" : "video/mp4",
"webm": "video/webm",
"mp3" : "audio/mp3",
"oga" : "application/ogg",
};
return map[extension];
}
29 changes: 29 additions & 0 deletions test/fixtures/wpt/common/top-layer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// This function is a version of test_driver.bless which works while there are
// elements in the top layer:
// https://github.com/web-platform-tests/wpt/issues/41218.
// Pass it the element at the top of the top layer stack.
window.blessTopLayer = async (topLayerElement) => {
const button = document.createElement('button');
topLayerElement.append(button);
let wait_click = new Promise(resolve => button.addEventListener("click", resolve, {once: true}));
await test_driver.click(button);
await wait_click;
button.remove();
};

window.isTopLayer = (el) => {
// A bit of a hack. Just test a few properties of the ::backdrop pseudo
// element that change when in the top layer.
const properties = ['right','background'];
const testEl = document.createElement('div');
document.body.appendChild(testEl);
const computedStyle = getComputedStyle(testEl, '::backdrop');
const nonTopLayerValues = properties.map(p => computedStyle[p]);
testEl.remove();
for(let i=0;i<properties.length;++i) {
if (getComputedStyle(el,'::backdrop')[properties[i]] !== nonTopLayerValues[i]) {
return true;
}
}
return false;
};
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const bufferSourceChunksForDeflate = [
},
{
name: 'Float16Array',
value: new Float16Array(new Uint8Array(compressedBytesWithDeflate).buffer)
value: () => new Float16Array(new Uint8Array(compressedBytesWithDeflate).buffer)
},
{
name: 'Float32Array',
Expand Down Expand Up @@ -100,7 +100,7 @@ const bufferSourceChunksForGzip = [
},
{
name: 'Float16Array',
value: new Float16Array(new Uint8Array(compressedBytesWithGzip).buffer)
value: () => new Float16Array(new Uint8Array(compressedBytesWithGzip).buffer)
},
{
name: 'Float32Array',
Expand Down Expand Up @@ -151,7 +151,7 @@ const bufferSourceChunksForDeflateRaw = [
},
{
name: 'Float16Array',
value: new Float16Array(new Uint8Array(compressedBytesWithDeflateRaw).buffer)
value: () => new Float16Array(new Uint8Array(compressedBytesWithDeflateRaw).buffer)
},
{
name: 'Float32Array',
Expand All @@ -172,7 +172,7 @@ for (const chunk of bufferSourceChunksForDeflate) {
const ds = new DecompressionStream('deflate');
const reader = ds.readable.getReader();
const writer = ds.writable.getWriter();
const writePromise = writer.write(chunk.value);
const writePromise = writer.write(typeof chunk.value === 'function' ? chunk.value() : chunk.value);
writer.close();
const { value } = await reader.read();
assert_array_equals(Array.from(value), deflateExpectedChunkValue, 'value should match');
Expand All @@ -184,7 +184,7 @@ for (const chunk of bufferSourceChunksForGzip) {
const ds = new DecompressionStream('gzip');
const reader = ds.readable.getReader();
const writer = ds.writable.getWriter();
const writePromise = writer.write(chunk.value);
const writePromise = writer.write(typeof chunk.value === 'function' ? chunk.value() : chunk.value);
writer.close();
const { value } = await reader.read();
assert_array_equals(Array.from(value), gzipExpectedChunkValue, 'value should match');
Expand All @@ -196,7 +196,7 @@ for (const chunk of bufferSourceChunksForDeflateRaw) {
const ds = new DecompressionStream('deflate-raw');
const reader = ds.readable.getReader();
const writer = ds.writable.getWriter();
const writePromise = writer.write(chunk.value);
const writePromise = writer.write(typeof chunk.value === 'function' ? chunk.value() : chunk.value);
writer.close();
const { value } = await reader.read();
assert_array_equals(Array.from(value), deflateRawExpectedChunkValue, 'value should match');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,25 @@
console.count();
console.countReset();
console.count();
console.countReset();

console.count(undefined);
console.countReset(undefined);
console.count(undefined);
console.countReset(undefined);

console.count("default");
console.countReset("default");
console.count("default");
console.countReset("default");

console.count({toString() {return "default"}});
console.countReset({toString() {return "default"}});
console.count({toString() {return "default"}});
console.countReset({toString() {return "default"}});

console.count("a label");
console.countReset();
console.countReset("a label");
console.count("a label");

console.countReset("b"); // should produce a warning
Expand Down
8 changes: 8 additions & 0 deletions test/fixtures/wpt/console/console-log-large-array.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// META: global=window,dedicatedworker,shadowrealm
"use strict";
// https://console.spec.whatwg.org/

test(() => {
console.log(new Array(10000000).fill("x"));
console.log(new Uint8Array(10000000));
}, "Logging large arrays works");
10 changes: 10 additions & 0 deletions test/fixtures/wpt/console/console-log-symbol.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// META: global=window,dedicatedworker,shadowrealm
"use strict";
// https://console.spec.whatwg.org/

test(() => {
console.log(Symbol());
console.log(Symbol("abc"));
console.log(Symbol.for("def"));
console.log(Symbol.isConcatSpreadable);
}, "Logging a symbol doesn't throw");
6 changes: 6 additions & 0 deletions test/fixtures/wpt/dom/abort/WEB_FEATURES.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
features:
- name: aborting
files: "**"
- name: abortsignal-any
files:
- abort-signal-any.any.js
23 changes: 23 additions & 0 deletions test/fixtures/wpt/dom/abort/abort-signal-any-crash.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html class=test-wait>
<head>
<title>AbortSignal::Any when source signal was garbage collected</title>
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1908466">
<link rel="author" title="Vincent Hilla" href="mailto:[email protected]">
<script src="/common/gc.js"></script>
</head>
<body>
<p>Test passes if the browser does not crash.</p>
<script>
async function test() {
let controller = new AbortController();
let signal = AbortSignal.any([controller.signal]);
controller = undefined;
await garbageCollect();
AbortSignal.any([signal]);
document.documentElement.classList.remove('test-wait');
}
test();
</script>
</body>
</html>
39 changes: 39 additions & 0 deletions test/fixtures/wpt/dom/abort/resources/abort-signal-any-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,43 @@ function abortSignalAnyTests(signalInterface, controllerInterface) {
controller.abort();
assert_equals(result, "01234");
}, `Abort events for ${desc} signals fire in the right order ${suffix}`);

test(t => {
const controller = new controllerInterface();
const signal1 = signalInterface.any([controller.signal]);
const signal2 = signalInterface.any([signal1]);
let eventFired = false;

controller.signal.addEventListener('abort', () => {
const signal3 = signalInterface.any([signal2]);
assert_true(controller.signal.aborted);
assert_true(signal1.aborted);
assert_true(signal2.aborted);
assert_true(signal3.aborted);
eventFired = true;
});

controller.abort();
assert_true(eventFired, "event fired");
}, `Dependent signals for ${desc} are marked aborted before abort events fire ${suffix}`);

test(t => {
const controller1 = new controllerInterface();
const controller2 = new controllerInterface();
const signal = signalInterface.any([controller1.signal, controller2.signal]);
let count = 0;

controller1.signal.addEventListener('abort', () => {
controller2.abort("reason 2");
});

signal.addEventListener('abort', () => {
count++;
});

controller1.abort("reason 1");
assert_equals(count, 1);
assert_true(signal.aborted);
assert_equals(signal.reason, "reason 1");
}, `Dependent signals for ${desc} are aborted correctly for reentrant aborts ${suffix}`);
}
Loading

0 comments on commit bf3a767

Please sign in to comment.