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 Nov 21, 2024
1 parent a427e4b commit c5a318e
Show file tree
Hide file tree
Showing 13 changed files with 390 additions and 77 deletions.
1 change: 1 addition & 0 deletions test/fixtures/wpt/eventsource/META.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ suggested_reviewers:
- odinho
- Yaffle
- annevk
- rexxars
52 changes: 29 additions & 23 deletions test/fixtures/wpt/fetch/fetch-later/quota.tentative.https.window.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

'use strict';

const kQuotaPerOrigin = 64 * 1024; // 64 kilobytes per spec.
const QUOTA_PER_ORIGIN = 64 * 1024; // 64 kilobytes per spec.
const {ORIGIN, HTTPS_NOTSAMESITE_ORIGIN} = get_host_info();
const TEST_ENDPOINT = '/fetch-later';

// Runs a test case that cover a single fetchLater() call with `body` in its
// request payload. The call is not expected to throw any errors.
function fetchLaterPostTest(body, description) {
test(() => {
const controller = new AbortController();
const result = fetchLater(
'/fetch-later',
{method: 'POST', signal: controller.signal, body: body});
TEST_ENDPOINT, {method: 'POST', signal: controller.signal, body: body});
assert_false(result.activated);
// Release quota taken by the pending request for subsequent tests.
controller.abort();
Expand All @@ -30,19 +30,25 @@ for (const [dataType, skipCharset] of Object.entries(
}

// Test various size of payloads for the same origin.
for (const dataType in BeaconDataType) {
if (dataType !== BeaconDataType.FormData &&
dataType !== BeaconDataType.URLSearchParams) {
// Skips FormData & URLSearchParams, as browser adds extra bytes to them
// in addition to the user-provided content. It is difficult to test a
// request right at the quota limit.
fetchLaterPostTest(
// Generates data that is exactly 64 kilobytes.
makeBeaconData(generatePayload(kQuotaPerOrigin), dataType),
`A single fetchLater() call takes up the per-origin quota for its ` +
`body of ${dataType}.`);
}
}

// Test max possible size of payload.
// Length of absolute URL to the endpoint.
const POST_TEST_REQUEST_URL_SIZE = (ORIGIN + TEST_ENDPOINT).length;
// Total size of the request header.
const POST_TEST_REQUEST_HEADER_SIZE = 36;
// Runs this test only for String type beacon, as browser adds extra bytes to
// body for some other types (FormData & URLSearchParams), and the request
// header sizes varies for every other types. It is difficult to test a request
// right at the quota limit.
fetchLaterPostTest(
// Generates data that is exactly 64 kilobytes.
makeBeaconData(
generatePayload(
QUOTA_PER_ORIGIN - POST_TEST_REQUEST_URL_SIZE -
POST_TEST_REQUEST_HEADER_SIZE),
BeaconDataType.String),
`A single fetchLater() call takes up the per-origin quota for its ` +
`body of String.`);

// Test empty payload.
for (const dataType in BeaconDataType) {
Expand All @@ -64,8 +70,8 @@ for (const dataType in BeaconDataType) {
() => fetchLater('/fetch-later', {
method: 'POST',
// Generates data that exceeds 64 kilobytes.
body:
makeBeaconData(generatePayload(kQuotaPerOrigin + 1), dataType)
body: makeBeaconData(
generatePayload(QUOTA_PER_ORIGIN + 1), dataType)
}));
},
`A single fetchLater() call is not allowed to exceed per-origin quota ` +
Expand All @@ -81,7 +87,7 @@ for (const dataType in BeaconDataType) {
fetchLater('/fetch-later', {
method: 'POST',
signal: controller.signal,
body: makeBeaconData(generatePayload(kQuotaPerOrigin / 2), dataType)
body: makeBeaconData(generatePayload(QUOTA_PER_ORIGIN / 2), dataType)
});

// Makes the 2nd call that sends half+1 of allowed quota.
Expand All @@ -90,7 +96,7 @@ for (const dataType in BeaconDataType) {
method: 'POST',
signal: controller.signal,
body: makeBeaconData(
generatePayload(kQuotaPerOrigin / 2 + 1), dataType)
generatePayload(QUOTA_PER_ORIGIN / 2 + 1), dataType)
});
});
// Release quota taken by the pending requests for subsequent tests.
Expand All @@ -109,16 +115,16 @@ for (const dataType in BeaconDataType) {
fetchLater('/fetch-later', {
method: 'POST',
signal: controller.signal,
body: makeBeaconData(generatePayload(kQuotaPerOrigin / 2), dataType)
body: makeBeaconData(generatePayload(QUOTA_PER_ORIGIN / 2), dataType)
});

// Makes the 2nd call that sends half+1 of allowed quota, but to a
// different origin.
fetchLater(`${HTTPS_NOTSAMESITE_ORIGIN}/fetch-later`, {
method: 'POST',
signal: controller.signal,
body:
makeBeaconData(generatePayload(kQuotaPerOrigin / 2 + 1), dataType)
body: makeBeaconData(
generatePayload(QUOTA_PER_ORIGIN / 2 + 1), dataType)
});
// Release quota taken by the pending requests for subsequent tests.
controller.abort();
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/wpt/interfaces/fenced-frame.idl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ interface Fence {
undefined reportEvent(optional ReportEventType event = {});
undefined setReportEventDataForAutomaticBeacons(optional FenceEvent event = {});
sequence<FencedFrameConfig> getNestedConfigs();
Promise<undefined> disableUntrustedNetwork();
undefined notifyEvent(Event event);
};

Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/wpt/interfaces/paint-timing.idl
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@
// (https://github.com/w3c/webref)
// Source: Paint Timing (https://w3c.github.io/paint-timing/)

[Exposed=Window]
interface mixin PaintTimingMixin {
readonly attribute DOMHighResTimeStamp paintTime;
readonly attribute DOMHighResTimeStamp? presentationTime;
};

[Exposed=Window]
interface PerformancePaintTiming : PerformanceEntry {};
PerformancePaintTiming includes PaintTimingMixin;
6 changes: 3 additions & 3 deletions test/fixtures/wpt/interfaces/shared-storage.idl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

typedef (USVString or FencedFrameConfig) SharedStorageResponse;

enum SharedStorageDataOrigin { "context-origin", "script-origin" };

[Exposed=(Window)]
interface SharedStorageWorklet : Worklet {
Promise<SharedStorageResponse> selectURL(DOMString name,
Expand All @@ -25,6 +23,8 @@ interface SharedStorageWorkletGlobalScope : WorkletGlobalScope {

readonly attribute SharedStorage sharedStorage;
readonly attribute PrivateAggregation privateAggregation;

Promise<sequence<StorageInterestGroup>> interestGroups();
};

dictionary SharedStorageUrlWithMetadata {
Expand Down Expand Up @@ -93,7 +93,7 @@ dictionary SharedStorageRunOperationMethodOptions {
};

dictionary SharedStorageWorkletOptions : WorkletOptions {
SharedStorageDataOrigin dataOrigin = "context-origin";
USVString dataOrigin = "context-origin";
};

interface mixin HTMLSharedStorageWritableElementUtils {
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/wpt/interfaces/webauthn.idl
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ partial dictionary AuthenticationExtensionsClientInputs {

dictionary CredentialPropertiesOutput {
boolean rk;
DOMString authenticatorDisplayName;
};

partial dictionary AuthenticationExtensionsClientOutputs {
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/wpt/interfaces/webgpu.idl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ interface GPU {
};

dictionary GPURequestAdapterOptions {
DOMString featureLevel;
DOMString featureLevel = "core";
GPUPowerPreference powerPreference;
boolean forceFallbackAdapter = false;
};
Expand Down Expand Up @@ -128,6 +128,7 @@ enum GPUFeatureName {
interface GPUDevice : EventTarget {
[SameObject] readonly attribute GPUSupportedFeatures features;
[SameObject] readonly attribute GPUSupportedLimits limits;
[SameObject] readonly attribute GPUAdapterInfo adapterInfo;

[SameObject] readonly attribute GPUQueue queue;

Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/wpt/interfaces/webrtc-stats.idl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ dictionary RTCInboundRtpStreamStats : RTCReceivedRtpStreamStats {
unsigned long long retransmittedBytesReceived;
unsigned long rtxSsrc;
unsigned long fecSsrc;
double totalCorruptionProbability;
double totalSquaredCorruptionProbability;
unsigned long long corruptionMeasurements;
};

dictionary RTCRemoteInboundRtpStreamStats : RTCReceivedRtpStreamStats {
Expand Down
47 changes: 19 additions & 28 deletions test/fixtures/wpt/resources/idlharness-shadowrealm.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/* global shadowRealmEvalAsync */

// requires /resources/idlharness-shadowrealm-outer.js

// TODO: it would be nice to support `idl_array.add_objects`
function fetch_text(url) {
return fetch(url).then(function (r) {
Expand All @@ -23,38 +27,25 @@ function fetch_text(url) {
function idl_test_shadowrealm(srcs, deps) {
promise_setup(async t => {
const realm = new ShadowRealm();
// https://github.com/web-platform-tests/wpt/issues/31996
realm.evaluate("globalThis.self = globalThis; undefined;");

realm.evaluate(`
globalThis.self.GLOBAL = {
isWindow: function() { return false; },
isWorker: function() { return false; },
isShadowRealm: function() { return true; },
}; undefined;
`);
const specs = await Promise.all(srcs.concat(deps).map(spec => {
return fetch_text("/interfaces/" + spec + ".idl");
}));
const idls = JSON.stringify(specs);
await new Promise(
realm.evaluate(`(resolve,reject) => {
(async () => {
await import("/resources/testharness.js");
await import("/resources/WebIDLParser.js");
await import("/resources/idlharness.js");
const idls = ${idls};
const idl_array = new IdlArray();
for (let i = 0; i < ${srcs.length}; i++) {
idl_array.add_idls(idls[i]);
}
for (let i = ${srcs.length}; i < ${srcs.length + deps.length}; i++) {
idl_array.add_dependency_idls(idls[i]);
}
idl_array.test();
})().then(resolve, (e) => reject(e.toString()));
}`)
);
await shadowRealmEvalAsync(realm, `
await import("/resources/testharness-shadowrealm-inner.js");
await import("/resources/testharness.js");
await import("/resources/WebIDLParser.js");
await import("/resources/idlharness.js");
const idls = ${idls};
const idl_array = new IdlArray();
for (let i = 0; i < ${srcs.length}; i++) {
idl_array.add_idls(idls[i]);
}
for (let i = ${srcs.length}; i < ${srcs.length + deps.length}; i++) {
idl_array.add_dependency_idls(idls[i]);
}
idl_array.test();
`);
await fetch_tests_from_shadow_realm(realm);
});
}
Expand Down
Loading

0 comments on commit c5a318e

Please sign in to comment.