Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / workers / worker-close-more.html
blob90493afd584e10a60b39dc588376baab0b356606
1 <body>
2 <p>Test WorkerGlobalScope.close() method. Will print PASS multiple times, followed by DONE.</p>
3 <div id=result></div>
4 <script src="resources/worker-util.js"></script>
5 <script>
6 if (window.testRunner) {
7 testRunner.dumpAsText();
8 testRunner.waitUntilDone();
9 waitUntilWorkerThreadsExit(runTests);
10 } else {
11 log("NOTE: Test relies on window.testRunner to detect when worker threads have exited. Please run this test via DumpRenderTree");
12 waitUntilWorkerThreadsExit(runTests);
15 var worker;
17 function startWorker()
19 if (window.testRunner)
20 log("PASS: workerThreadCount = " + internals.workerThreadCount);
21 worker = new Worker('resources/worker-close.js');
24 function runTests()
26 log("Test 1: Call close() in the worker, then enter infinite loop. From the Worker object side, call terminate(). Verify the loop is terminated.")
27 startWorker();
28 worker.postMessage("close_post_loop"); // Close the worker but put it immediately into infinite loop.
29 worker.onmessage = function(event) {
30 if (window.testRunner) {
31 log("PASS: Worker thread created and closed, received message: " + event.data);
32 // Terminate the worker.
33 worker.terminate();
34 waitUntilWorkerThreadsExit(testCloseWithAccumulatedMessages);
39 function testCloseWithAccumulatedMessages()
41 log("PASS: Worker exited after terminate() terminated the infinite loop.");
42 log("Test 2: post 2 messages to a MessagePort into the worker. port.onmessage handler inside the worker will call close(). Verify that the second onmessage was not executed.")
43 startWorker();
44 var channel = new MessageChannel();
45 worker.onmessage = function(event) {
46 if (event.data == "echo_ping2")
47 log("FAIL: The MessagePort message was dispatched after a JS fragment that called 'close()' exited.");
48 else
49 log("PASS: MessagePort multiple message test, received message: " + event.data);
50 setTimeout("waitUntilWorkerThreadsExit(workerExited)", 100); // Let it run a bit to catch the echo_ping2 if it arrives.
52 worker.postMessage("take_port", [channel.port2]);
54 // Queue 2 messages.
55 channel.port1.postMessage("ping1");
56 channel.port1.postMessage("ping2");
58 // Now enable the messages to be delivered. Only first should echo back.
59 worker.postMessage("start_port");
62 function workerExited()
64 log("PASS: MessagePort messages were not delivered asfter close().");
65 done();
67 </script>
68 </body>