Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update wpts #2108

Merged
merged 1 commit into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions CONTRIBUTING.md
Expand Up @@ -91,14 +91,17 @@ Here are the steps to update them.
```bash
git clone --depth 1 --single-branch --branch epochs/daily --filter=blob:none --sparse https://github.com/web-platform-tests/wpt.git test/wpt/tests
cd test/wpt/tests

git sparse-checkout add /resources
git sparse-checkout add /interfaces
git sparse-checkout add /common
git sparse-checkout add /fetch
git sparse-checkout add /FileAPI
git sparse-checkout add /xhr
git sparse-checkout add /websockets
git sparse-checkout add /resources
git sparse-checkout add /common
git sparse-checkout add /mimesniff
git sparse-checkout add /interfaces
git sparse-checkout add /storage
git sparse-checkout add /service-workers
```
</details>

Expand Down
8 changes: 8 additions & 0 deletions test/wpt/status/fetch.status.json
Expand Up @@ -99,6 +99,14 @@
]
}
},
"body": {
"mime-type.any.js": {
"note": "fails on all platforms, https://wpt.fyi/results/fetch/api/body/mime-type.any.html?label=master&label=experimental&product=chrome&product=firefox&product=safari&product=node.js&product=deno&aligned",
"fail": [
"Response: Extract a MIME type with clone"
]
}
},
"cors": {
"note": "undici doesn't implement CORs",
"skip": true
Expand Down
37 changes: 37 additions & 0 deletions test/wpt/tests/.azure-pipelines.yml
Expand Up @@ -541,3 +541,40 @@ jobs:
parameters:
dependsOn: results_safari_preview
artifactName: safari-preview-results

- job: results_wktr_preview
displayName: 'all tests: WebKitTestRunner'
condition: |
or(eq(variables['Build.SourceBranch'], 'refs/heads/triggers/wktr_preview'),
and(eq(variables['Build.Reason'], 'Manual'), variables['run_all_wktr_preview']))
strategy:
parallel: 8 # chosen to make runtime ~2h
timeoutInMinutes: 180
pool:
vmImage: 'macOS-12'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.10'
- template: tools/ci/azure/checkout.yml
- template: tools/ci/azure/pip_install.yml
parameters:
packages: virtualenv
- template: tools/ci/azure/install_certs.yml
- template: tools/ci/azure/update_hosts.yml
- template: tools/ci/azure/update_manifest.yml
- script: |
set -eux -o pipefail
export SYSTEM_VERSION_COMPAT=0
./wpt run --no-manifest-update --no-restart-on-unexpected --no-fail-on-unexpected --this-chunk=$(System.JobPositionInPhase) --total-chunks=$(System.TotalJobsInPhase) --chunk-type hash --log-wptreport $(Build.ArtifactStagingDirectory)/wpt_report_$(System.JobPositionInPhase).json --log-wptscreenshot $(Build.ArtifactStagingDirectory)/wpt_screenshot_$(System.JobPositionInPhase).txt --log-mach - --log-mach-level info --channel main --install-browser wktr
displayName: 'Run tests'
- task: PublishBuildArtifacts@1
displayName: 'Publish results'
inputs:
artifactName: 'wktr-preview-results'
- template: tools/ci/azure/publish_logs.yml
- template: tools/ci/azure/sysdiagnose.yml
- template: tools/ci/azure/fyi_hook.yml
parameters:
dependsOn: results_wktr_preview
artifactName: wktr-preview-results
1 change: 0 additions & 1 deletion test/wpt/tests/.gitignore
Expand Up @@ -45,7 +45,6 @@ scratch
/css/build-temp
/css/dist
/css/dist_last
/css/tools/cache
/url/tools/IdnaTestV2.txt
/webaudio/idl/*

Expand Down
2 changes: 1 addition & 1 deletion test/wpt/tests/.taskcluster.yml
Expand Up @@ -57,7 +57,7 @@ tasks:
owner: ${owner}
source: ${event.repository.clone_url}
payload:
image: webplatformtests/wpt:0.52
image: webplatformtests/wpt:0.53
maxRunTime: 7200
artifacts:
public/results:
Expand Down
3 changes: 0 additions & 3 deletions test/wpt/tests/CODEOWNERS
Validating CODEOWNERS rules …
@@ -1,6 +1,3 @@
# Prevent accidentially touching CSS subtree
/css/tools/apiclient/ @plinss @web-platform-tests/wpt-core-team

# Require review for changes that often need an RFC
/resources/testdriver* @web-platform-tests/wpt-core-team
/resources/testharness* @web-platform-tests/wpt-core-team
Expand Down
10 changes: 0 additions & 10 deletions test/wpt/tests/fetch/api/basic/keepalive.any.js
Expand Up @@ -27,13 +27,3 @@ for (const method of ['GET', 'POST']) {
assertStashedTokenAsync(`simple ${method} request: no payload`, token1);
}, `simple ${method} request: no payload; setting up`);
}

promise_test(async (test) => {
const w = window.open(`${
HTTP_NOTSAMESITE_ORIGIN}/fetch/api/resources/keepalive-redirect-window.html`);
const token = await getTokenFromMessage();
w.close();

assertStashedTokenAsync(
'keepalive in onunload in nested frame in another window', token);
}, 'keepalive in onunload in nested frame in another window; setting up');
87 changes: 87 additions & 0 deletions test/wpt/tests/fetch/api/body/mime-type.any.js
Expand Up @@ -38,3 +38,90 @@
assert_equals(blob.type, newMIMEType);
}, `${bodyContainer.constructor.name}: setting missing Content-Type`);
});

[
() => new Request("about:blank", { method: "POST" }),
() => new Response(),
].forEach(bodyContainerCreator => {
const bodyContainer = bodyContainerCreator();
promise_test(async t => {
const blob = await bodyContainer.blob();
assert_equals(blob.type, "");
}, `${bodyContainer.constructor.name}: MIME type for Blob from empty body`);
});

[
() => new Request("about:blank", { method: "POST", headers: [["Content-Type", "Mytext/Plain"]] }),
() => new Response("", { headers: [["Content-Type", "Mytext/Plain"]] })
].forEach(bodyContainerCreator => {
const bodyContainer = bodyContainerCreator();
promise_test(async t => {
const blob = await bodyContainer.blob();
assert_equals(blob.type, 'mytext/plain');
}, `${bodyContainer.constructor.name}: MIME type for Blob from empty body with Content-Type`);
});

[
() => new Request("about:blank", { body: new Blob([""]), method: "POST" }),
() => new Response(new Blob([""]))
].forEach(bodyContainerCreator => {
const bodyContainer = bodyContainerCreator();
promise_test(async t => {
const blob = await bodyContainer.blob();
assert_equals(blob.type, "");
assert_equals(bodyContainer.headers.get("Content-Type"), null);
}, `${bodyContainer.constructor.name}: MIME type for Blob`);
});

[
() => new Request("about:blank", { body: new Blob([""], { type: "Text/Plain" }), method: "POST" }),
() => new Response(new Blob([""], { type: "Text/Plain" }))
].forEach(bodyContainerCreator => {
const bodyContainer = bodyContainerCreator();
promise_test(async t => {
const blob = await bodyContainer.blob();
assert_equals(blob.type, "text/plain");
assert_equals(bodyContainer.headers.get("Content-Type"), "text/plain");
}, `${bodyContainer.constructor.name}: MIME type for Blob with non-empty type`);
});

[
() => new Request("about:blank", { method: "POST", body: new Blob([""], { type: "Text/Plain" }), headers: [["Content-Type", "Text/Html"]] }),
() => new Response(new Blob([""], { type: "Text/Plain" }, { headers: [["Content-Type", "Text/Html"]] }))
].forEach(bodyContainerCreator => {
const bodyContainer = bodyContainerCreator();
const cloned = bodyContainer.clone();
promise_test(async t => {
const blobs = [await bodyContainer.blob(), await cloned.blob()];
assert_equals(blobs[0].type, "text/html");
assert_equals(blobs[1].type, "text/html");
assert_equals(bodyContainer.headers.get("Content-Type"), "Text/Html");
assert_equals(cloned.headers.get("Content-Type"), "Text/Html");
}, `${bodyContainer.constructor.name}: Extract a MIME type with clone`);
});

[
() => new Request("about:blank", { body: new Blob([], { type: "text/plain" }), method: "POST", headers: [["Content-Type", "text/html"]] }),
() => new Response(new Blob([], { type: "text/plain" }), { headers: [["Content-Type", "text/html"]] }),
].forEach(bodyContainerCreator => {
const bodyContainer = bodyContainerCreator();
promise_test(async t => {
assert_equals(bodyContainer.headers.get("Content-Type"), "text/html");
const blob = await bodyContainer.blob();
assert_equals(blob.type, "text/html");
}, `${bodyContainer.constructor.name}: Content-Type in headers wins Blob"s type`);
});

[
() => new Request("about:blank", { body: new Blob([], { type: "text/plain" }), method: "POST" }),
() => new Response(new Blob([], { type: "text/plain" })),
].forEach(bodyContainerCreator => {
const bodyContainer = bodyContainerCreator();
promise_test(async t => {
assert_equals(bodyContainer.headers.get("Content-Type"), "text/plain");
const newMIMEType = "text/html";
bodyContainer.headers.set("Content-Type", newMIMEType);
const blob = await bodyContainer.blob();
assert_equals(blob.type, newMIMEType);
}, `${bodyContainer.constructor.name}: setting missing Content-Type in headers and it wins Blob"s type`);
});
118 changes: 78 additions & 40 deletions test/wpt/tests/fetch/api/redirect/redirect-keepalive.any.js
Expand Up @@ -14,43 +14,81 @@ const {
HTTP_REMOTE_ORIGIN_WITH_DIFFERENT_PORT
} = get_host_info();

promise_test(async (test) => {
const token1 = token();
const iframe = document.createElement('iframe');
iframe.src = getKeepAliveAndRedirectIframeUrl(
token1, '', '', /*withPreflight=*/ false);
document.body.appendChild(iframe);
await iframeLoaded(iframe);
assert_equals(await getTokenFromMessage(), token1);
iframe.remove();

assertStashedTokenAsync('same-origin redirect', token1);
}, 'same-origin redirect; setting up');

promise_test(async (test) => {
const token1 = token();
const iframe = document.createElement('iframe');
iframe.src = getKeepAliveAndRedirectIframeUrl(
token1, HTTP_REMOTE_ORIGIN, HTTP_REMOTE_ORIGIN_WITH_DIFFERENT_PORT,
/*withPreflight=*/ false);
document.body.appendChild(iframe);
await iframeLoaded(iframe);
assert_equals(await getTokenFromMessage(), token1);
iframe.remove();

assertStashedTokenAsync('cross-origin redirect', token1);
}, 'cross-origin redirect; setting up');

promise_test(async (test) => {
const token1 = token();
const iframe = document.createElement('iframe');
iframe.src = getKeepAliveAndRedirectIframeUrl(
token1, HTTP_REMOTE_ORIGIN, HTTP_REMOTE_ORIGIN_WITH_DIFFERENT_PORT,
/*withPreflight=*/ true);
document.body.appendChild(iframe);
await iframeLoaded(iframe);
assert_equals(await getTokenFromMessage(), token1);
iframe.remove();

assertStashedTokenAsync('cross-origin redirect with preflight', token1);
}, 'cross-origin redirect with preflight; setting up');
/**
* In an iframe, test to fetch a keepalive URL that involves in redirect to
* another URL.
*/
function keepaliveRedirectTest(
desc, {origin1 = '', origin2 = '', withPreflight = false} = {}) {
desc = `[keepalive] ${desc}`;
promise_test(async (test) => {
const tokenToStash = token();
const iframe = document.createElement('iframe');
iframe.src = getKeepAliveAndRedirectIframeUrl(
tokenToStash, origin1, origin2, withPreflight);
document.body.appendChild(iframe);
await iframeLoaded(iframe);
assert_equals(await getTokenFromMessage(), tokenToStash);
iframe.remove();

assertStashedTokenAsync(desc, tokenToStash);
}, `${desc}; setting up`);
}

/**
* Opens a different site window, and in `unload` event handler, test to fetch
* a keepalive URL that involves in redirect to another URL.
*/
function keepaliveRedirectInUnloadTest(desc, {
origin1 = '',
origin2 = '',
url2 = '',
withPreflight = false,
shouldPass = true
} = {}) {
desc = `[keepalive][new window][unload] ${desc}`;

promise_test(async (test) => {
const targetUrl =
`${HTTP_NOTSAMESITE_ORIGIN}/fetch/api/resources/keepalive-redirect-window.html?` +
`origin1=${origin1}&` +
`origin2=${origin2}&` +
`url2=${url2}&` + (withPreflight ? `with-headers` : ``);
const w = window.open(targetUrl);
const token = await getTokenFromMessage();
w.close();

assertStashedTokenAsync(desc, token, {shouldPass});
}, `${desc}; setting up`);
}

keepaliveRedirectTest(`same-origin redirect`);
keepaliveRedirectTest(
`same-origin redirect + preflight`, {withPreflight: true});
keepaliveRedirectTest(`cross-origin redirect`, {
origin1: HTTP_REMOTE_ORIGIN,
origin2: HTTP_REMOTE_ORIGIN_WITH_DIFFERENT_PORT
});
keepaliveRedirectTest(`cross-origin redirect + preflight`, {
origin1: HTTP_REMOTE_ORIGIN,
origin2: HTTP_REMOTE_ORIGIN_WITH_DIFFERENT_PORT,
withPreflight: true
});

keepaliveRedirectInUnloadTest('same-origin redirect');
keepaliveRedirectInUnloadTest(
'same-origin redirect + preflight', {withPreflight: true});
keepaliveRedirectInUnloadTest('cross-origin redirect', {
origin1: HTTP_REMOTE_ORIGIN,
origin2: HTTP_REMOTE_ORIGIN_WITH_DIFFERENT_PORT
});
keepaliveRedirectInUnloadTest('cross-origin redirect + preflight', {
origin1: HTTP_REMOTE_ORIGIN,
origin2: HTTP_REMOTE_ORIGIN_WITH_DIFFERENT_PORT,
withPreflight: true
});
keepaliveRedirectInUnloadTest(
'redirect to file URL', {url2: 'file://tmp/bar.txt', shouldPass: false});
keepaliveRedirectInUnloadTest(
'redirect to data URL',
{url2: 'data:text/plain;base64,cmVzcG9uc2UncyBib2R5', shouldPass: false});
8 changes: 6 additions & 2 deletions test/wpt/tests/fetch/api/resources/keepalive-helper.js
Expand Up @@ -60,7 +60,7 @@ async function queryToken(token) {
// for the rest of the work. Note that we want the serialized behavior
// for the steps so far, so we don't want to make the entire test case
// an async_test.
function assertStashedTokenAsync(testName, token) {
function assertStashedTokenAsync(testName, token, {shouldPass = true} = {}) {
async_test((test) => {
new Promise((resolve) => test.step_timeout(resolve, 3000))
.then(() => {
Expand All @@ -73,7 +73,11 @@ function assertStashedTokenAsync(testName, token) {
test.done();
})
.catch(test.step_func((e) => {
assert_unreached(e);
if (shouldPass) {
assert_unreached(e);
} else {
test.done();
}
}));
}, testName);
}
18 changes: 13 additions & 5 deletions test/wpt/tests/fetch/api/resources/keepalive-redirect-window.html
Expand Up @@ -10,20 +10,28 @@
HTTP_REMOTE_ORIGIN,
HTTP_REMOTE_ORIGIN_WITH_DIFFERENT_PORT
} = get_host_info();
const REDIRECT_DESTINATION =
`${HTTP_REMOTE_ORIGIN_WITH_DIFFERENT_PORT}/fetch/api/resources/stash-put.py` +

const SEARCH_PARAMS = new URL(location.href).searchParams;
const WITH_HEADERS = !!SEARCH_PARAMS.has('with-headers');
const ORIGIN1 = SEARCH_PARAMS.get('origin1') || '';
const ORIGIN2 = SEARCH_PARAMS.get('origin2') || '';
const URL2 = SEARCH_PARAMS.get('url2') || '';

const REDIRECT_DESTINATION = URL2 ? URL2 :
`${ORIGIN2}/fetch/api/resources/stash-put.py` +
`?key=${TOKEN}&value=on`;
const URL =
`${HTTP_REMOTE_ORIGIN}/fetch/api/resources/redirect.py?` +
const FROM_URL =
`${ORIGIN1}/fetch/api/resources/redirect.py?` +
`delay=500&` +
`allow_headers=foo&` +
`location=${encodeURIComponent(REDIRECT_DESTINATION)}`;

addEventListener('load', () => {
const headers = WITH_HEADERS ? {'foo': 'bar'} : undefined;
const iframe = document.createElement('iframe');
document.body.appendChild(iframe);
iframe.contentWindow.addEventListener('unload', () => {
iframe.contentWindow.fetch(URL, {keepalive: true, headers: {foo: 'bar'}});
iframe.contentWindow.fetch(FROM_URL, {keepalive: true, headers});
});

window.opener.postMessage(TOKEN, '*');
Expand Down