2 <p>Test SharedWorker constructor functionality. Should print a series of PASS messages, followed with DONE.
</p>
7 document
.getElementById("result").innerHTML
+= message
+ "<br>";
10 if (window
.testRunner
) {
11 testRunner
.dumpAsText();
12 testRunner
.waitUntilDone();
16 new SharedWorker({toString:function(){throw "exception"}}, "name")
17 log("FAIL: toString exception not propagated.");
19 if (ex
== "exception")
20 log("PASS: toString exception propagated correctly.");
22 log("FAIL: unexpected exception (" + ex
+ ") received instead of one propagated from toString.");
26 var foo
= {toString:function(){new Worker(foo
)}}
27 new SharedWorker(foo
, name
);
28 log("FAIL: no exception when trying to create workers recursively");
30 log("PASS: trying to create workers recursively resulted in an exception (" + ex
+ ")");
35 log("FAIL: invoking SharedWorker constructor without arguments did not result in an exception");
37 log("PASS: invoking SharedWorker constructor without arguments resulted in an exception (" + ex
+ ")");
41 var worker
= new SharedWorker("resources/shared-worker-common.js");
42 log("PASS: invoking SharedWorker constructor without name did not result in an exception");
44 log("FAIL: Constructor failed when no name is passed: (" + ex
+ ")");
48 new SharedWorker("resources/shared-worker-common.js", null);
49 log("PASS: invoking SharedWorker constructor with null name did not result in an exception");
51 log("FAIL: invoking SharedWorker constructor with null name resulted in an exception (" + ex
+ ")");
55 new SharedWorker("resources/shared-worker-common.js", undefined);
56 log("PASS: invoking SharedWorker constructor with undefined name did not result in an exception");
58 log("FAIL: invoking SharedWorker constructor with undefined name resulted in an exception (" + ex
+ ")");
62 var worker
= new SharedWorker("resources/shared-worker-common.js", "name");
63 log ("PASS: SharedWorker constructor succeeded: " + worker
);
65 log("FAIL: invoking SharedWorker constructor resulted in an exception (" + ex
+ ")");
69 if (window
.testRunner
)
70 testRunner
.notifyDone();