diff --git a/testing/web-platform/meta/trusted-types/WorkerGlobalScope-worker-constructor.html.ini b/testing/web-platform/meta/trusted-types/WorkerGlobalScope-worker-constructor.html.ini new file mode 100644 index 0000000000000..288b7abd650ca --- /dev/null +++ b/testing/web-platform/meta/trusted-types/WorkerGlobalScope-worker-constructor.html.ini @@ -0,0 +1,22 @@ +[ +WorkerGlobalScope +- +worker +- +constructor +. +html +] +[ +Creating +a +Worker +from +a +string +should +throw +] +expected +: +FAIL diff --git a/testing/web-platform/tests/trusted-types/WorkerGlobalScope-worker-constructor.html b/testing/web-platform/tests/trusted-types/WorkerGlobalScope-worker-constructor.html new file mode 100644 index 0000000000000..f012763b4b292 --- /dev/null +++ b/testing/web-platform/tests/trusted-types/WorkerGlobalScope-worker-constructor.html @@ -0,0 +1,96 @@ +< +! +DOCTYPE +html +> +< +html +> +< +head +> +< +meta +charset += +" +utf +- +8 +" +> +< +script +src += +" +/ +resources +/ +testharness +. +js +" +> +< +/ +script +> +< +script +src += +" +/ +resources +/ +testharnessreport +. +js +" +> +< +/ +script +> +< +/ +head +> +< +body +> +< +script +> +fetch_tests_from_worker +( +new +Worker +( +" +support +/ +WorkerGlobalScope +- +worker +- +constructor +. +js +" +) +) +; +< +/ +script +> +< +/ +body +> +< +/ +html +> diff --git a/testing/web-platform/tests/trusted-types/support/WorkerGlobalScope-worker-constructor.js b/testing/web-platform/tests/trusted-types/support/WorkerGlobalScope-worker-constructor.js new file mode 100644 index 0000000000000..bd03b83fdcd2e --- /dev/null +++ b/testing/web-platform/tests/trusted-types/support/WorkerGlobalScope-worker-constructor.js @@ -0,0 +1,172 @@ +const +test_setup_policy += +trustedTypes +. +createPolicy +( +" +p +" +{ +createScriptURL +: +s += +> +s +} +) +; +importScripts +( +test_setup_policy +. +createScriptURL +( +" +/ +resources +/ +testharness +. +js +" +) +) +; +test +( +( +) += +> +{ +assert_throws_js +( +TypeError +( +) += +> +{ +new +Worker +( +" +w +" +) +; +} +" +Creating +a +Worker +threw +" +) +; +} +" +Creating +a +Worker +from +a +string +should +throw +" +) +; +test +( +( +) += +> +{ +new +Worker +( +test_setup_policy +. +createScriptURL +( +" +u +" +) +) +; +} +" +Creating +a +Worker +from +a +TrustedScriptURL +should +not +throw +" +) +; +test +( +( +) += +> +{ +trustedTypes +. +createPolicy +( +" +default +" +{ +createScriptURL +: +s += +> +" +defaultValue +" +} +) +; +new +Worker +( +" +s +" +) +; +} +" +Creating +a +Worker +from +a +string +with +a +default +policy +should +not +throw +" +) +; +done +( +) +; diff --git a/testing/web-platform/tests/trusted-types/support/WorkerGlobalScope-worker-constructor.js.headers b/testing/web-platform/tests/trusted-types/support/WorkerGlobalScope-worker-constructor.js.headers new file mode 100644 index 0000000000000..6b6f2522ef7ab --- /dev/null +++ b/testing/web-platform/tests/trusted-types/support/WorkerGlobalScope-worker-constructor.js.headers @@ -0,0 +1,16 @@ +Content +- +Security +- +Policy +: +require +- +trusted +- +types +- +for +' +script +'