Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /workers/interfaces/WorkerUtils/importScripts/catch.sub.any.serviceworker.html - WPT Dashboard Interop Dashboard
- /workers/interfaces/WorkerUtils/importScripts/catch.sub.any.sharedworker.html - WPT Dashboard Interop Dashboard
- /workers/interfaces/WorkerUtils/importScripts/catch.sub.any.worker.html - WPT Dashboard Interop Dashboard
// META: global=worker
const redirectToCrossOrigin = "/common/redirect.py?location=" + crossOrigin;
test(function() {
assert_throws_js(SyntaxError, function() {
importScripts("/workers/modules/resources/syntax-error.js");
});
}, "Same-origin syntax error");
test(function() {
assert_throws_js(Error, function() {
importScripts("/workers/modules/resources/throw.js");
});
}, "Same-origin throw");
// Step 8.2. If rethrow errors is true and script's muted errors is true, then:
// Step 8.2.2. Throw a "NetworkError" DOMException.
test(function() {
assert_throws_dom("NetworkError", function() {
importScripts(crossOrigin +
"/workers/modules/resources/syntax-error.js");
});
}, "Cross-origin syntax error");
test(function() {
assert_throws_dom("NetworkError", function() {
importScripts(crossOrigin +
"/workers/modules/resources/throw.js");
});
}, "Cross-origin throw");
test(function() {
assert_throws_dom("NetworkError", function() {
importScripts(redirectToCrossOrigin +
"/workers/modules/resources/syntax-error.js");
});
}, "Redirect-to-cross-origin syntax error");
test(function() {
assert_throws_dom("NetworkError", function() {
importScripts(redirectToCrossOrigin +
"/workers/modules/resources/throw.js");
});
}, "Redirect-to-Cross-origin throw");