|
9 | 9 | <script>
|
10 | 10 | 'use strict';
|
11 | 11 |
|
12 |
| -promise_test(async () => { |
| 12 | +async function verifyStoreCookieCrossOriginCreateWorkletIncludeCredentials( |
| 13 | + helper_url_params, data_origin_option) { |
13 | 14 | const ancestor_key = token();
|
14 | 15 | const crossOrigin = 'https://{{domains[www]}}:{{ports[https][0]}}';
|
15 | 16 | const set_cookie_url = crossOrigin + `/cookies/resources/set-cookie.py` +
|
16 | 17 | `?name=key0` +
|
17 | 18 | `&path=/shared-storage/`;
|
18 | 19 | const helper_url = crossOrigin +
|
19 | 20 | `/shared-storage/resources/credentials-test-helper.py` +
|
20 |
| - `?access_control_allow_origin_header=${window.origin}` + |
21 |
| - `&access_control_allow_credentials_header=true` + |
22 |
| - `&shared_storage_cross_origin_worklet_allowed_header=?1` + |
23 |
| - `&token=${ancestor_key}`; |
| 21 | + helper_url_params + `&token=${ancestor_key}`; |
24 | 22 |
|
25 | 23 | await fetch(set_cookie_url, { mode: 'no-cors', credentials: 'include' });
|
26 | 24 |
|
| 25 | + const options = (data_origin_option === '') ? { credentials: "include" } |
| 26 | + : { credentials: "include", dataOrigin: data_origin_option }; |
| 27 | + |
27 | 28 | const worklet = await sharedStorage.createWorklet(
|
28 |
| - helper_url + `&action=store-cookie`, |
29 |
| - { credentials: "include" }); |
| 29 | + helper_url + `&action=store-cookie`, options); |
30 | 30 |
|
31 | 31 | const request_cookie_fetch_response =
|
32 | 32 | await fetch(helper_url + `&action=get-cookie`);
|
33 | 33 |
|
34 | 34 | const request_cookie_text = await request_cookie_fetch_response.text();
|
35 | 35 |
|
36 | 36 | assert_equals(request_cookie_text, "key0=1");
|
37 |
| -}, 'createWorklet() with cross-origin module script and credentials "include"'); |
| 37 | +} |
| 38 | + |
| 39 | +promise_test(async () => { |
| 40 | + const helper_url_params = |
| 41 | + `?access_control_allow_origin_header=${window.origin}` + |
| 42 | + `&access_control_allow_credentials_header=true`; |
| 43 | + |
| 44 | + await verifyStoreCookieCrossOriginCreateWorkletIncludeCredentials( |
| 45 | + helper_url_params, /*data_origin_option=*/''); |
| 46 | +}, 'createWorklet() with cross-origin module script, credentials "include",' |
| 47 | + + 'and default data origin (context origin).'); |
| 48 | + |
| 49 | +promise_test(async () => { |
| 50 | + const helper_url_params = |
| 51 | + `?access_control_allow_origin_header=${window.origin}` + |
| 52 | + `&access_control_allow_credentials_header=true`; |
| 53 | + |
| 54 | + await verifyStoreCookieCrossOriginCreateWorkletIncludeCredentials( |
| 55 | + helper_url_params, /*data_origin_option=*/'context-origin'); |
| 56 | +}, 'createWorklet() with cross-origin module script, credentials "include",' |
| 57 | + + 'and "context-origin" as dataOrigin.'); |
| 58 | + |
| 59 | +promise_test(async () => { |
| 60 | + const helper_url_params = |
| 61 | + `?access_control_allow_origin_header=${window.origin}` + |
| 62 | + `&access_control_allow_credentials_header=true` + |
| 63 | + `&shared_storage_cross_origin_worklet_allowed_header=?1`; |
| 64 | + |
| 65 | + await verifyStoreCookieCrossOriginCreateWorkletIncludeCredentials( |
| 66 | + helper_url_params, /*data_origin_option=*/'script-origin'); |
| 67 | +}, 'createWorklet() with cross-origin module script, credentials "include",' |
| 68 | + + 'and "script-origin" as dataOrigin.'); |
38 | 69 |
|
39 | 70 | </script>
|
40 | 71 | </body>
|
0 commit comments