Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / workers / worker-close.html
blob55dc7cb1a670602f0e4f70790d52c47fbc88a30b
1 <body>
2 <p>Test WorkerContext.close 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 if (window.testRunner)
12 testRunner.dumpAsText();
13 testRunner.waitUntilDone();
16 var worker = new Worker('resources/worker-close.js');
17 var timeout = 0;
19 worker.postMessage("typeofClose");
20 worker.onmessage = testTypeofClose;
22 function testTypeofClose(evt)
24 if (evt.data == "typeof close: function")
25 log("PASS: " + evt.data);
26 else
27 log("FAIL: " + evt.data);
28 worker.onmessage = testMessageAfterClose;
29 worker.postMessage("ping");
32 function testMessageAfterClose(evt) {
33 if (evt.data == "pong")
34 log("PASS: received message before close");
35 else
36 log("FAIL: received unknown response: " + evt.data);
38 // Tell the worker to close, then send a followup message. This message should not be delivered,
39 // since that would require JS to invoke the onmessage handler, which does not happen after the JS
40 // fragment with 'close()' in it exits. So, the 'ping' should not come back as 'pong'.
41 worker.postMessage("close");
42 worker.postMessage("ping");
43 worker.onmessage = function(evt) {
44 if (evt.data != "pong") {
45 log("PASS: Received message posted right after close() was invoked: " + evt.data);
46 timeout = setTimeout(testErrorAfterClose, 1000);
47 } else {
48 log("FAIL: Received a message originated from a handler in the worker after the JS fragment with close() exited" + evt.data);
49 done();
54 function testErrorAfterClose()
56 log("PASS: no messages arrive to worker after JS fragment with close() exits");
57 // Test that errors are delivered after close.
58 worker = new Worker('resources/worker-close.js');
59 worker.postMessage("closeWithError");
60 worker.onerror = function(event) {
61 log("PASS: Error arrived after close: " + event.message);
62 testPendingEvents();
63 return false;
67 function testPendingEvents()
69 // Now test that workers do not deliver pending events
70 worker = new Worker('resources/worker-close.js');
71 worker.postMessage("closeWithPendingEvents");
72 worker.onmessage = function(evt) {
73 log("FAIL: pending events should not fire:" + evt.data);
74 done();
76 worker.onerror = function(evt) {
77 log("FAIL: pending events should not fire:" + evt.message);
78 done();
80 timeout = setTimeout(testTerminateAfterClose, 500);
83 function testTerminateAfterClose()
85 log("PASS: close() did not dispatch pending events");
86 worker = new Worker('resources/worker-close.js');
87 worker.postMessage("close");
88 worker.onmessage = function(evt) {
89 log("PASS: Received message after worker closed: " + evt.data);
90 // Give worker a chance to close first, then terminate it.
91 timeout = setTimeout(function() {
92 worker.terminate();
93 done();
94 }, 500);
98 function done() {
99 if (timeout)
100 clearTimeout(timeout);
101 log("DONE");
102 if (window.testRunner)
103 testRunner.notifyDone();
105 </script>
106 </body>
107 </html>