forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserviceworker_cookieStore_cross_origin.tentative.https.sub.html
41 lines (33 loc) · 1.42 KB
/
serviceworker_cookieStore_cross_origin.tentative.https.sub.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!doctype html>
<meta charset='utf-8'>
<title>Async Cookies: cookieStore API in ServiceWorker across origins</title>
<link rel='help' href='https://github.com/WICG/cookie-store'>
<link rel='author' href='[email protected]' title='Jarryd Goodman'>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<script src='resources/helpers.js'></script>
<style>iframe {display: none}</style>
<script>
'use strict';
const kPath = '/cookie-store/resources/helper_iframe.sub.html';
const kCorsBase = `https://{{domains[www1]}}:{{ports[https][0]}}`;
const kCorsUrl = `${kCorsBase}${kPath}`;
promise_test(async t => {
const iframe = await createIframe(kCorsUrl, t);
assert_true(iframe != null);
const serviceWorker = await createServiceWorker(t,
'serviceworker_cookieStore_cross_origin.js', '/does/not/exist');
iframe.contentWindow.postMessage({
opname: 'set-cookie',
name: 'cookie-name',
value: 'cookie-value',
}, kCorsBase);
t.add_cleanup(async () => { await cookieStore.delete('cookie-name'); });
await waitForMessage();
const { workerCookies } = await sendMessageOverChannel({ op: 'get-cookies' },
serviceWorker);
assert_equals(workerCookies.length, 1);
assert_equals(workerCookies[0].name, 'cookie-name');
assert_equals(workerCookies[0].value, 'cookie-value');
}, 'cookieStore.get() in ServiceWorker reads cookie set in cross-origin frame');
</script>