Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /shared-storage/same-origin-worklet-select-url-and-verify-custom-data-origin.tentative.https.sub.html - WPT Dashboard Interop Dashboard
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
<script src="/shared-storage/resources/util.js"></script>
<script src="/shared-storage/resources/util.sub.js"></script>
<script src="/fenced-frame/resources/utils.js"></script>
<body>
<script>
'use strict';
const sameOrigin = location.origin;
async_test(t => {
createWorkletAndVerifyDataOrigin(
t, /*data_origin=*/sameOrigin, /*script_origin=*/sameOrigin,
/*expect_success=*/true, /*error_type=*/null);
}, `For same-origin createWorklet with custom dataOrigin ${sameOrigin}, `
+ `where dataOrigin is same origin to the context's origin, `
+ `test selectURL() and verify its data origin.`);
async_test(t => {
createWorkletAndVerifyDataOrigin(
t, /*data_origin=*/customOrigin0, /*script_origin=*/sameOrigin,
/*expect_success=*/true, /*error_type=*/null);
}, `For same-origin createWorklet with custom dataOrigin ${customOrigin0},`
+ ` where dataOrigin has opted in, test selectURL() and verify its data `
+ `origin.`);
async_test(t => {
createWorkletAndVerifyDataOrigin(
t, /*data_origin=*/customOrigin1, /*script_origin=*/sameOrigin,
/*expect_success=*/true, /*error_type=*/null);
}, `For same-origin createWorklet with custom dataOrigin ${customOrigin1},`
+ ` where dataOrigin has opted in with "*", test selectURL() and verify `
+ `its data origin.`);
async_test(t => {
createWorkletAndVerifyDataOrigin(
t, /*data_origin=*/customOrigin2, /*script_origin=*/sameOrigin,
/*expect_success=*/false, /*error_type=*/'OperationError');
}, `For same-origin createWorklet with custom dataOrigin ${customOrigin2},`
+` where dataOrigin has not opted in, worklet creation will fail.`);
async_test(t => {
createWorkletAndVerifyDataOrigin(
t, /*data_origin=*/'invalid', /*script_origin=*/sameOrigin,
/*expect_success=*/false, /*error_type=*/'TypeError');
}, 'For same-origin createWorklet with dataOrigin option "invalid", '
+ 'there is a TypeError thrown.');
async_test(t => {
createWorkletAndVerifyDataOrigin(
t, /*data_origin=*/'data:application/javascript;alert("Hi!")',
/*script_origin=*/sameOrigin, /*expect_success=*/false,
/*error_type=*/'InvalidAccessError');
}, 'For same-origin createWorklet with opaque dataOrigin, '
+ 'there is an InvalidAccessError thrown.');
</script>
</body>