2 <p>Test SharedWorker script error handling functionality. Should print a series of PASS messages, followed with DONE.
</p>
7 document
.getElementById("result").innerHTML
+= message
+ "<br>";
11 "testScriptErrorUnhandled",
12 "testScriptErrorHandled"
16 function runNextTest()
18 if (testIndex
< testCases
.length
) {
21 window
[testCases
[testIndex
- 1]]();
23 log("FAIL: unexpected exception " + ex
);
28 // Wait briefly to make sure that any pending console messages get written out so they don't spill over into subsequent tests and cause failures.
29 setTimeout(function() {
30 if (window
.testRunner
)
31 testRunner
.notifyDone();
36 function testScriptErrorUnhandled()
38 var worker
= new SharedWorker("resources/shared-worker-script-error.js", "name");
39 // SharedWorkers should only invoke onerror for loading errors.
40 worker
.onerror = function(evt
) {
41 log("FAIL: onerror invoked for a script error");
43 worker
.port
.postMessage("unhandledError");
44 worker
.port
.onmessage = function(evt
) {
50 function testScriptErrorHandled()
52 var worker
= new SharedWorker("resources/shared-worker-script-error.js", "name2");
53 // SharedWorkers should only invoke onerror for loading errors.
54 worker
.onerror = function(evt
) {
55 log("FAIL: onerror invoked for a script error");
57 worker
.port
.postMessage("handledError");
58 worker
.port
.onmessage = function(evt
) {
64 if (window
.testRunner
) {
65 testRunner
.dumpAsText();
66 testRunner
.waitUntilDone();