2 <p>Test Worker constructor functionality. Should print a series of PASS messages, followed with DONE.</p>
7 document.getElementById("result").innerHTML += message + "<br>";
10 function runNextTest()
13 // Loop until there are no more tests to run
14 var testName = 'test' + testIndex;
15 if (window[testName]) {
19 if (window.layoutTestController)
20 layoutTestController.notifyDone();
27 new Worker({toString:function(){throw "exception"}})
28 log("FAIL: toString exception not propagated.");
30 if (ex == "exception")
31 log("PASS: toString exception propagated correctly.");
33 log("FAIL: unexpected exception (" + ex + ") received instead of one propagated from toString.");
41 var foo = {toString:function(){new Worker(foo)}}
43 log("FAIL: no exception when trying to create workers recursively");
45 log("PASS: trying to create workers recursively resulted in an exception (" + ex + ")");
54 log("FAIL: invoking Worker constructor without arguments did not result in an exception");
56 log("PASS: invoking Worker constructor without arguments resulted in an exception (" + ex + ")");
64 var worker = new Worker("");
65 worker.onerror = function() {
66 log("PASS: onerror invoked for an empty script URL.");
70 log("FAIL: unexpected exception " + ex);
78 var worker = new Worker("invalidurl://");
79 worker.onerror = function() {
80 log("PASS: onerror invoked for an invalid script URL.");
84 log("FAIL: unexpected exception " + ex);
92 var worker = new Worker("does-not-exist.js");
93 worker.onerror = function() {
94 log("PASS: onerror invoked for a script that could not be loaded.");
98 log("FAIL: unexpected exception " + ex);
106 var worker = new Worker("resources/worker-common.js");
107 // Make sure attributes from both Worker and AbstractWorker are visible.
108 if (!worker.postMessage)
109 log("FAIL: worker.postMessage did not exist.");
110 else if (!worker.addEventListener)
111 log("FAIL: worker.addEventListener did not exist.");
113 log("PASS: Successfully created worker.");
115 log("FAIL: unexpected exception (" + ex + ") thrown when creating worker");
120 if (window.layoutTestController) {
121 layoutTestController.dumpAsText();
122 layoutTestController.waitUntilDone();