Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / workers / worker-constructor.html
blob38f5423ada7e4a79a6fe1f080df1c0a34905139e
1 <body>
2 <p>Test Worker constructor functionality. Should print a series of PASS messages, followed with DONE.</p>
3 <div id=result></div>
4 <script>
5 function log(message)
7 document.getElementById("result").innerHTML += message + "<br>";
10 var testCases = [
11 "testArgumentException",
12 "testRecursiveWorkerCreation",
13 "testNoArgument",
14 "testEmptyScriptUrl",
15 "testInvalidScriptUrl",
16 "testNotExistentScriptUrl",
17 "testSuccessWorkerCreation",
19 var testIndex = 0;
21 function runNextTest()
23 if (testIndex < testCases.length) {
24 testIndex++;
25 window[testCases[testIndex - 1]]();
26 } else {
27 log("DONE");
28 if (window.testRunner)
29 testRunner.notifyDone();
33 function testArgumentException()
35 try {
36 new Worker({toString:function(){throw "exception"}})
37 log("FAIL: toString exception not propagated.");
38 } catch (ex) {
39 if (ex == "exception")
40 log("PASS: toString exception propagated correctly.");
41 else
42 log("FAIL: unexpected exception (" + ex + ") received instead of one propagated from toString.");
44 runNextTest();
47 function testRecursiveWorkerCreation()
49 try {
50 var foo = {toString:function(){new Worker(foo)}}
51 new Worker(foo);
52 log("FAIL: no exception when trying to create workers recursively");
53 } catch (ex) {
54 log("PASS: trying to create workers recursively resulted in an exception (" + ex + ")");
56 runNextTest();
59 function testNoArgument()
61 try {
62 new Worker();
63 log("FAIL: invoking Worker constructor without arguments did not result in an exception");
64 } catch (ex) {
65 log("PASS: invoking Worker constructor without arguments resulted in an exception (" + ex + ")");
67 runNextTest();
70 function testEmptyScriptUrl()
72 try {
73 var worker = new Worker("");
74 worker.onerror = function(e) {
75 log("PASS: onerror invoked for an empty script URL, resolving to this HTML document's URL.");
76 e.preventDefault();
77 runNextTest();
79 } catch (ex) {
80 log("FAIL: invoking Worker constructor with empty script URL resulted in a exception (" + ex + ")");
81 runNextTest();
85 function testInvalidScriptUrl()
87 try {
88 var worker = new Worker("http://invalid:123$");
89 worker.onerror = function() {
90 log("FAIL: onerror invoked for an invalid script URL.");
91 runNextTest();
93 } catch (ex) {
94 log("PASS: invoking Worker constructor with invalid script URL resulted in an exception (" + ex + ")");
95 runNextTest();
99 function testNotExistentScriptUrl()
101 try {
102 var worker = new Worker("does-not-exist.js");
103 worker.onerror = function() {
104 log("PASS: onerror invoked for a script that could not be loaded.");
105 runNextTest();
107 } catch (ex) {
108 log("FAIL: unexpected exception " + ex);
109 runNextTest();
113 function testSuccessWorkerCreation()
115 try {
116 var worker = new Worker("resources/worker-common.js");
117 // Make sure attributes from both Worker and AbstractWorker are visible.
118 if (!worker.postMessage)
119 log("FAIL: worker.postMessage did not exist.");
120 else if (!worker.addEventListener)
121 log("FAIL: worker.addEventListener did not exist.");
122 else
123 log("PASS: Successfully created worker.");
124 } catch (ex) {
125 log("FAIL: unexpected exception (" + ex + ") thrown when creating worker");
127 runNextTest();
130 if (window.testRunner) {
131 testRunner.dumpAsText();
132 testRunner.waitUntilDone();
135 runNextTest();
137 </script>
138 </body>