mirror of
https://github.com/servo/servo.git
synced 2025-08-14 01:45:33 +01:00
Update web-platform-tests to revision be5419e845d39089ba6dc338c1bd0fa279108317
This commit is contained in:
parent
aa199307c8
commit
2b6f573eb5
3440 changed files with 109438 additions and 41750 deletions
|
@ -1,106 +1,130 @@
|
|||
function createCookieValue(settings) {
|
||||
return settings.credentials + '-' + settings.origin;
|
||||
}
|
||||
|
||||
function createSetCookieURL(settings) {
|
||||
const params = new URLSearchParams;
|
||||
params.append('name', 'cookieName');
|
||||
params.append('value', createCookieValue(settings));
|
||||
if (settings.origin == 'same') {
|
||||
return get_host_info().HTTPS_ORIGIN +
|
||||
'/worklets/resources/set-cookie.py?' + params;
|
||||
}
|
||||
if (settings.origin == 'remote') {
|
||||
return get_host_info().HTTPS_REMOTE_ORIGIN +
|
||||
'/worklets/resources/set-cookie.py?' + params;
|
||||
}
|
||||
assert_unreached('settings.origin has an invalid value.');
|
||||
}
|
||||
|
||||
function createScriptURL(settings) {
|
||||
const params = new URLSearchParams;
|
||||
if (settings.expectCredentialsSent)
|
||||
params.append('value', createCookieValue(settings));
|
||||
if (settings.origin == 'same') {
|
||||
return get_host_info().HTTPS_ORIGIN +
|
||||
'/worklets/resources/credentials.py?' + params;
|
||||
}
|
||||
if (settings.origin == 'remote') {
|
||||
return get_host_info().HTTPS_REMOTE_ORIGIN +
|
||||
'/worklets/resources/credentials.py?' + params;
|
||||
}
|
||||
assert_unreached('settings.origin has an invalid value.');
|
||||
}
|
||||
|
||||
function createWorkletOptions(settings) {
|
||||
if (settings.credentials == '')
|
||||
return {};
|
||||
return { credentials: settings.credentials };
|
||||
}
|
||||
|
||||
// Run a credentials test with the given settings.
|
||||
//
|
||||
// Example:
|
||||
// settings = {
|
||||
// workletType: 'paint',
|
||||
// credentials: 'include',
|
||||
// origin: 'same', // 'same' or 'remote'
|
||||
// expectCredentialsSent: true
|
||||
// };
|
||||
function runCredentialsTest(settings) {
|
||||
const worklet = get_worklet(settings.workletType);
|
||||
const setCookieURL = createSetCookieURL(settings);
|
||||
const scriptURL = createScriptURL(settings);
|
||||
const options = createWorkletOptions(settings);
|
||||
|
||||
// { credentials: 'include' } is necessary for configuring document's cookies
|
||||
// with the Set-Cookie: header of the response.
|
||||
return fetch(setCookieURL, { mode: 'cors', credentials: 'include' })
|
||||
.then(response => worklet.addModule(scriptURL, options));
|
||||
}
|
||||
|
||||
// Runs a series of tests related to credentials on a worklet.
|
||||
//
|
||||
// Usage:
|
||||
// runCredentialsTests("paint");
|
||||
function runCredentialsTests(worklet_type) {
|
||||
const worklet = get_worklet(worklet_type);
|
||||
|
||||
promise_test(() => {
|
||||
document.cookie = 'cookieName=default';
|
||||
const kScriptURL = 'resources/credentials.py?mode=default';
|
||||
return worklet.addModule(kScriptURL).then(undefined_arg => {
|
||||
assert_equals(undefined_arg, undefined);
|
||||
});
|
||||
return runCredentialsTest({ workletType: worklet_type,
|
||||
credentials: '',
|
||||
origin: 'same',
|
||||
expectCredentialsSent: false });
|
||||
}, 'Importing a same-origin script with the default WorkletOptions should ' +
|
||||
'omit the credentials');
|
||||
'not send the credentials');
|
||||
|
||||
promise_test(() => {
|
||||
const kSetCookieURL =
|
||||
get_host_info().HTTPS_REMOTE_ORIGIN +
|
||||
'/worklets/resources/set-cookie.py?name=cookieName';
|
||||
const kScriptURL = get_host_info().HTTPS_REMOTE_ORIGIN +
|
||||
'/worklets/resources/credentials.py?mode=default';
|
||||
const kOptions = { credentials: 'same-origin' };
|
||||
|
||||
// Set a cookie in the remote origin and then start a worklet.
|
||||
return fetch(kSetCookieURL, { mode: 'cors' })
|
||||
.then(() => worklet.addModule(kScriptURL, kOptions))
|
||||
.then(undefined_arg => assert_equals(undefined_arg, undefined));
|
||||
return runCredentialsTest({ workletType: worklet_type,
|
||||
credentials: '',
|
||||
origin: 'remote',
|
||||
expectCredentialsSent: false });
|
||||
}, 'Importing a remote-origin script with the default WorkletOptions ' +
|
||||
'should not include the credentials');
|
||||
'should not send the credentials');
|
||||
|
||||
promise_test(() => {
|
||||
document.cookie = 'cookieName=omit';
|
||||
const kScriptURL = 'resources/credentials.py?mode=omit';
|
||||
const kOptions = { credentials: 'omit' };
|
||||
return worklet.addModule(kScriptURL, kOptions).then(undefined_arg => {
|
||||
assert_equals(undefined_arg, undefined);
|
||||
});
|
||||
}, 'Importing a same-origin script with credentials=omit should omit the ' +
|
||||
'credentials');
|
||||
|
||||
promise_test(() => {
|
||||
const kSetCookieURL =
|
||||
get_host_info().HTTPS_REMOTE_ORIGIN +
|
||||
'/worklets/resources/set-cookie.py?name=cookieName';
|
||||
const kScriptURL = get_host_info().HTTPS_REMOTE_ORIGIN +
|
||||
'/worklets/resources/credentials.py?mode=omit';
|
||||
const kOptions = { credentials: 'omit' };
|
||||
|
||||
// Set a cookie in the remote origin and then start a worklet.
|
||||
return fetch(kSetCookieURL, { mode: 'cors' })
|
||||
.then(() => worklet.addModule(kScriptURL, kOptions))
|
||||
.then(undefined_arg => assert_equals(undefined_arg, undefined));
|
||||
}, 'Importing a remote-origin script with credentials=omit should omit the ' +
|
||||
'credentials');
|
||||
|
||||
promise_test(() => {
|
||||
document.cookie = 'cookieName=same-origin';
|
||||
const kScriptURL = 'resources/credentials.py?mode=same-origin';
|
||||
const kOptions = { credentials: 'same-origin' };
|
||||
return worklet.addModule(kScriptURL, kOptions).then(undefined_arg => {
|
||||
assert_equals(undefined_arg, undefined);
|
||||
});
|
||||
}, 'Importing a same-origin script with credentials=same-origin should ' +
|
||||
'include the credentials');
|
||||
|
||||
promise_test(() => {
|
||||
const kSetCookieURL =
|
||||
get_host_info().HTTPS_REMOTE_ORIGIN +
|
||||
'/worklets/resources/set-cookie.py?name=cookieName';
|
||||
const kScriptURL = get_host_info().HTTPS_REMOTE_ORIGIN +
|
||||
'/worklets/resources/credentials.py?mode=same-origin';
|
||||
const kOptions = { credentials: 'same-origin' };
|
||||
|
||||
// Set a cookie in the remote origin and then start a worklet.
|
||||
return fetch(kSetCookieURL, { mode: 'cors' })
|
||||
.then(() => worklet.addModule(kScriptURL, kOptions))
|
||||
.then(undefined_arg => assert_equals(undefined_arg, undefined));
|
||||
}, 'Importing a remote-origin script with credentials=same-origin should ' +
|
||||
'not include the credentials');
|
||||
|
||||
promise_test(() => {
|
||||
document.cookie = 'cookieName=include';
|
||||
const kScriptURL = 'resources/credentials.py?mode=include';
|
||||
const kOptions = { credentials: 'include' };
|
||||
return worklet.addModule(kScriptURL, kOptions).then(undefined_arg => {
|
||||
assert_equals(undefined_arg, undefined);
|
||||
});
|
||||
}, 'Importing a same-origin script with credentials=include should include ' +
|
||||
return runCredentialsTest({ workletType: worklet_type,
|
||||
credentials: 'omit',
|
||||
origin: 'same',
|
||||
expectCredentialsSent: false });
|
||||
}, 'Importing a same-origin script with credentials=omit should not send ' +
|
||||
'the credentials');
|
||||
|
||||
promise_test(() => {
|
||||
const kSetCookieURL =
|
||||
get_host_info().HTTPS_REMOTE_ORIGIN +
|
||||
'/worklets/resources/set-cookie.py?name=cookieName';
|
||||
const kScriptURL = get_host_info().HTTPS_REMOTE_ORIGIN +
|
||||
'/worklets/resources/credentials.py?mode=include';
|
||||
const kOptions = { credentials: 'include' };
|
||||
return runCredentialsTest({ workletType: worklet_type,
|
||||
credentials: 'omit',
|
||||
origin: 'remote',
|
||||
expectCredentialsSent: false });
|
||||
}, 'Importing a remote-origin script with credentials=omit should not send ' +
|
||||
'the credentials');
|
||||
|
||||
// Set a cookie in the remote origin and then start a worklet.
|
||||
return fetch(kSetCookieURL, { mode: 'cors' })
|
||||
.then(() => worklet.addModule(kScriptURL, kOptions))
|
||||
.then(undefined_arg => assert_equals(undefined_arg, undefined));
|
||||
promise_test(() => {
|
||||
return runCredentialsTest({ workletType: worklet_type,
|
||||
credentials: 'same-origin',
|
||||
origin: 'same',
|
||||
expectCredentialsSent: true });
|
||||
}, 'Importing a same-origin script with credentials=same-origin should ' +
|
||||
'send the credentials');
|
||||
|
||||
promise_test(() => {
|
||||
return runCredentialsTest({ workletType: worklet_type,
|
||||
credentials: 'same-origin',
|
||||
origin: 'remote',
|
||||
expectCredentialsSent: false });
|
||||
}, 'Importing a remote-origin script with credentials=same-origin should ' +
|
||||
'not send the credentials');
|
||||
|
||||
promise_test(() => {
|
||||
return runCredentialsTest({ workletType: worklet_type,
|
||||
credentials: 'include',
|
||||
origin: 'same',
|
||||
expectCredentialsSent: true });
|
||||
}, 'Importing a same-origin script with credentials=include should send ' +
|
||||
'the credentials');
|
||||
|
||||
promise_test(() => {
|
||||
return runCredentialsTest({ workletType: worklet_type,
|
||||
credentials: 'include',
|
||||
origin: 'remote',
|
||||
expectCredentialsSent: true });
|
||||
}, 'Importing a remote-origin script with credentials=include should ' +
|
||||
'include the credentials');
|
||||
'send the credentials');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue