Skip to content

Commit

Permalink
chore: update WPT
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak authored and github-actions[bot] committed Dec 2, 2024
1 parent ee752e7 commit 19ea02d
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 66 deletions.
2 changes: 1 addition & 1 deletion test/fixtures/wpt/interfaces/compute-pressure.idl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// (https://github.com/w3c/webref)
// Source: Compute Pressure Level 1 (https://w3c.github.io/compute-pressure/)

enum PressureSource { "thermals", "cpu" };
enum PressureSource { "cpu" };

enum PressureState { "nominal", "fair", "serious", "critical" };

Expand Down
4 changes: 3 additions & 1 deletion test/fixtures/wpt/interfaces/fedcm.idl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ dictionary IdentityProviderRequestOptions : IdentityProviderConfig {
};

dictionary IdentityProviderWellKnown {
required sequence<USVString> provider_urls;
sequence<USVString> provider_urls;
USVString accounts_endpoint;
USVString login_url;
};

dictionary IdentityProviderIcon {
Expand Down
17 changes: 10 additions & 7 deletions test/fixtures/wpt/interfaces/html.idl
Original file line number Diff line number Diff line change
Expand Up @@ -2520,6 +2520,11 @@ interface MessageChannel {
readonly attribute MessagePort port2;
};

interface mixin MessageEventTarget {
attribute EventHandler onmessage;
attribute EventHandler onmessageerror;
};

[Exposed=(Window,Worker,AudioWorklet), Transferable]
interface MessagePort : EventTarget {
undefined postMessage(any message, sequence<object> transfer);
Expand All @@ -2528,11 +2533,11 @@ interface MessagePort : EventTarget {
undefined close();

// event handlers
attribute EventHandler onmessage;
attribute EventHandler onmessageerror;
attribute EventHandler onclose;
};

MessagePort includes MessageEventTarget;

dictionary StructuredSerializeOptions {
sequence<object> transfer = [];
};
Expand Down Expand Up @@ -2571,11 +2576,10 @@ interface DedicatedWorkerGlobalScope : WorkerGlobalScope {
undefined postMessage(any message, optional StructuredSerializeOptions options = {});

undefined close();

attribute EventHandler onmessage;
attribute EventHandler onmessageerror;
};

DedicatedWorkerGlobalScope includes MessageEventTarget;

[Global=(Worker,SharedWorker),Exposed=SharedWorker]
interface SharedWorkerGlobalScope : WorkerGlobalScope {
[Replaceable] readonly attribute DOMString name;
Expand All @@ -2597,8 +2601,6 @@ interface Worker : EventTarget {

undefined postMessage(any message, sequence<object> transfer);
undefined postMessage(any message, optional StructuredSerializeOptions options = {});
attribute EventHandler onmessage;
attribute EventHandler onmessageerror;
};

dictionary WorkerOptions {
Expand All @@ -2610,6 +2612,7 @@ dictionary WorkerOptions {
enum WorkerType { "classic", "module" };

Worker includes AbstractWorker;
Worker includes MessageEventTarget;

[Exposed=Window]
interface SharedWorker : EventTarget {
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/wpt/interfaces/long-animation-frames.idl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ interface PerformanceLongAnimationFrameTiming : PerformanceEntry {
[Default] object toJSON();
};

PerformanceLongAnimationFrameTiming includes PaintTimingMixin;

enum ScriptInvokerType {
"classic-script",
"module-script",
Expand Down
25 changes: 25 additions & 0 deletions test/fixtures/wpt/interfaces/webnn.idl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ interface ML {
};

typedef record<USVString, ArrayBufferView> MLNamedArrayBufferViews;
typedef record<USVString, MLTensor> MLNamedTensors;

dictionary MLComputeResult {
MLNamedArrayBufferViews inputs;
Expand All @@ -41,8 +42,17 @@ dictionary MLComputeResult {

[SecureContext, Exposed=(Window, DedicatedWorker)]
interface MLContext {
// ISSUE(791): compute() will soon be removed in favor of dispatch().
Promise<MLComputeResult> compute(
MLGraph graph, MLNamedArrayBufferViews inputs, MLNamedArrayBufferViews outputs);
undefined dispatch(MLGraph graph, MLNamedTensors inputs, MLNamedTensors outputs);

Promise<MLTensor> createTensor(MLTensorDescriptor descriptor);

Promise<ArrayBuffer> readTensor(MLTensor tensor);
Promise<undefined> readTensor(MLTensor tensor, AllowSharedBufferSource outputData);

undefined writeTensor(MLTensor tensor, AllowSharedBufferSource inputData);

MLOpSupportLimits opSupportLimits();
};
Expand Down Expand Up @@ -105,6 +115,21 @@ dictionary MLOperatorOptions {

typedef (bigint or unrestricted double) MLNumber;

dictionary MLTensorDescriptor : MLOperandDescriptor {
boolean readable = false;
boolean writable = false;
};

[SecureContext, Exposed=(Window, DedicatedWorker)]
interface MLTensor {
readonly attribute MLOperandDataType dataType;
readonly attribute FrozenArray<unsigned long> shape;
readonly attribute boolean readable;
readonly attribute boolean writable;

undefined destroy();
};

typedef record<USVString, MLOperand> MLNamedOperands;

[SecureContext, Exposed=(Window, DedicatedWorker)]
Expand Down
52 changes: 0 additions & 52 deletions test/fixtures/wpt/resources/idlharness-shadowrealm.js

This file was deleted.

19 changes: 16 additions & 3 deletions test/fixtures/wpt/resources/idlharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ IdlArray.prototype.test = function()

Object.getOwnPropertyNames(this.members).forEach(function(memberName) {
var member = this.members[memberName];
if (!(member instanceof IdlInterface)) {
if (!(member instanceof IdlInterface || member instanceof IdlNamespace)) {
return;
}

Expand Down Expand Up @@ -1421,7 +1421,7 @@ IdlInterface.prototype.test = function()
if (!this.untested)
{
subsetTestByKey(this.name, test, function() {
assert_false(this.name in self);
assert_false(this.name in self, this.name + " interface should not exist");
}.bind(this), this.name + " interface: existence and properties of interface object");
}
return;
Expand Down Expand Up @@ -3451,6 +3451,17 @@ IdlNamespace.prototype.test_self = function ()

IdlNamespace.prototype.test = function ()
{
// If the namespace object is not exposed, only test that. Members can't be
// tested either
if (!this.exposed) {
if (!this.untested) {
subsetTestByKey(this.name, test, function() {
assert_false(this.name in self, this.name + " namespace should not exist");
}.bind(this), this.name + " namespace: existence and properties of namespace object");
}
return;
}

if (!this.untested) {
this.test_self();
}
Expand Down Expand Up @@ -3498,7 +3509,7 @@ function idl_test(srcs, deps, idl_setup_func) {
"require-exposed"
];
return Promise.all(
srcs.concat(deps).map(fetch_spec))
srcs.concat(deps).map(globalThis.fetch_spec))
.then(function(results) {
const astArray = results.map(result =>
WebIDL2.parse(result.idl, { sourceName: result.spec })
Expand Down Expand Up @@ -3539,9 +3550,11 @@ function idl_test(srcs, deps, idl_setup_func) {
});
}, 'idl_test setup');
}
globalThis.idl_test = idl_test;

/**
* fetch_spec is a shorthand for a Promise that fetches the spec's content.
* Note: ShadowRealm-specific implementation in testharness-shadowrealm-inner.js
*/
function fetch_spec(spec) {
var url = '/interfaces/' + spec + '.idl';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@
namespace baz {
DOMString LongStory(any hero, DOMString... details);
DOMString ShortStory(DOMString... details);
};`);
};
[Exposed=Worker]
namespace Absent {
undefined Lies();
};
`);
idlArray.test();
</script>
<script type="text/json" id="expected">
Expand Down Expand Up @@ -233,6 +238,12 @@
"status_string": "PASS",
"properties": {},
"message": null
},
{
"name": "Absent namespace: existence and properties of namespace object",
"status_string": "PASS",
"properties": {},
"message": null
}
],
"type": "complete"
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/wpt/resources/testharness-shadowrealm-inner.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ globalThis.setShadowRealmGlobalProperties = function (queryString, fetchAdaptor)
return new Promise(executor).then((s) => JSON.parse(s));
};

// Used only by idlharness.js
globalThis.fetch_spec = (spec) => {
const resource = `/interfaces/${spec}.idl`;
const executor = fetchAdaptor(resource);
return new Promise(executor).then(
idl => ({ spec, idl }),
() => {
throw new IdlHarnessError(`Error fetching ${resource}.`);
});
}

globalThis.location = { search: queryString };
};

Expand Down
24 changes: 23 additions & 1 deletion test/fixtures/wpt/resources/testharness-shadowrealm-outer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* Convenience function for evaluating some async code in the ShadowRealm and
* waiting for the result.
*
* In case of error, this function intentionally exposes the stack trace (if it
* is available) to the hosting realm, for debugging purposes.
*
* @param {ShadowRealm} realm - the ShadowRealm to evaluate the code in
* @param {string} asyncBody - the code to evaluate; will be put in the body of
* an async function, and must return a value explicitly if a value is to be
Expand All @@ -15,7 +18,7 @@ globalThis.shadowRealmEvalAsync = function (realm, asyncBody) {
(resolve, reject) => {
(async () => {
${asyncBody}
})().then(resolve, (e) => reject(e.toString()));
})().then(resolve, (e) => reject(e.toString() + "\\n" + (e.stack || "")));
}
`));
};
Expand Down Expand Up @@ -125,3 +128,22 @@ globalThis.setupFakeFetchOverMessagePort = function (port) {
});
port.start();
}

/**
* Returns a message suitable for posting with postMessage() that will signal to
* the test harness that the tests are finished and there was an error in the
* setup code.
*
* @param {message} string - error message
*/
globalThis.createSetupErrorResult = function (message) {
return {
type: "complete",
tests: [],
asserts: [],
status: {
status: 1, // TestsStatus.ERROR,
message,
},
};
};

0 comments on commit 19ea02d

Please sign in to comment.