|
| 1 | +<!doctype html> |
| 2 | +<script src="/resources/testharness.js"></script> |
| 3 | +<script src="/resources/testharnessreport.js"></script> |
| 4 | +<script src="/common/utils.js"></script> |
| 5 | +<script src="/shared-storage/resources/util.js"></script> |
| 6 | +<script src="/fenced-frame/resources/utils.js"></script> |
| 7 | + |
| 8 | +<body> |
| 9 | +<script> |
| 10 | +'use strict'; |
| 11 | + |
| 12 | +promise_test(async () => { |
| 13 | + const crossOrigin = 'https://{{domains[www]}}:{{ports[https][0]}}'; |
| 14 | + const script_url = crossOrigin + |
| 15 | + `/shared-storage/resources/simple-module.js`; |
| 16 | + |
| 17 | + const worklet = await sharedStorage.createWorklet( |
| 18 | + script_url, |
| 19 | + { credentials: "omit" }); |
| 20 | + |
| 21 | + const ancestor_key = token(); |
| 22 | + let url0 = generateURL("/shared-storage/resources/frame0.html", |
| 23 | + [ancestor_key]); |
| 24 | + |
| 25 | + let select_url_result = await worklet.selectURL( |
| 26 | + "test-url-selection-operation", |
| 27 | + [{ url: url0 }], { |
| 28 | + data: { |
| 29 | + 'mockResult': 0, |
| 30 | + 'setKey': 'key0', |
| 31 | + 'setValue': 'value0' |
| 32 | + }, |
| 33 | + resolveToConfig: true, |
| 34 | + keepAlive: true |
| 35 | + }); |
| 36 | + |
| 37 | + assert_true(validateSelectURLResult(select_url_result, true)); |
| 38 | + attachFencedFrame(select_url_result, 'opaque-ads'); |
| 39 | + const result0 = await nextValueFromServer(ancestor_key); |
| 40 | + assert_equals(result0, "frame0_loaded"); |
| 41 | + |
| 42 | + await verifyKeyValueForOrigin('key0', 'value0', crossOrigin); |
| 43 | +}, 'For a cross-origin worklet, test selectURL() and verify its data origin'); |
| 44 | + |
| 45 | +</script> |
| 46 | +</body> |
0 commit comments