Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / workers / shared-worker-shared.html
blobef6165d821e3b8d050245be07fba25a2ffb614bf
1 <body>
2 <p>Test simple shared worker sharing cases. Should print several PASS lines followed by DONE.</p>
3 <div id=result></div>
4 <script>
5 function log(message)
7 document.getElementById("result").innerHTML += message + "<br>";
10 if (window.testRunner) {
11 testRunner.dumpAsText();
12 testRunner.waitUntilDone();
15 // Load two workers simultaneously, to ensure that simultaneous loads also yield the same instance.
16 // Loading a worker named "name" tests that workers shutdown when the parent document exits, because other tests also create workers with that same name but with different URLs.
17 var worker = new SharedWorker('resources/shared-worker-common.js', 'name');
18 var worker2 = new SharedWorker('resources/shared-worker-common.js', 'name');
20 try {
21 new SharedWorker('resources/some-other-url.js', 'name');
22 log("FAIL: Creating SharedWorker with different URLs but the same name should fail");
23 } catch (ex) {
24 var exString = ex.toString();
25 exString = exString.replace(/file:\/\/.*\//, "")
26 log("PASS: Exception thrown when creating SharedWorker with different URLs but same name: " + exString);
30 // Set something in global context in one worker, read value back on other worker, to make sure they are truly shared.
31 worker.port.postMessage("eval self.foo");
32 worker.port.onmessage = function(event)
34 log((event.data == "self.foo: undefined" ? "PASS: " : "FAIL: ") + "Accessing new instance of shared worker: " + event.data);
35 worker.port.postMessage("eval self.foo = 1234");
36 worker.port.onmessage = function(event)
38 log((event.data == "self.foo = 1234: 1234" ? "PASS: " : "FAIL: ") + "Setting global variable in shared worker: " + event.data);
39 worker2.port.postMessage("eval self.foo");
40 worker2.port.onmessage = function(event)
42 log((event.data == "self.foo: 1234" ? "PASS: " : "FAIL: ") + "Accessing simultaneously-loaded instance of shared worker: " + event.data);
43 testNewWorker();
48 function testNewWorker()
50 // New name, so should be a distinct worker from the previous one.
51 var worker3 = new SharedWorker('resources/shared-worker-common.js', 'name2');
52 worker3.port.postMessage("eval self.foo");
53 worker3.port.onmessage = function(event)
55 log((event.data == "self.foo: undefined" ? "PASS: " : "FAIL: ") + "Accessing new instance of shared worker: " + event.data);
56 testAlreadyLoaded();
60 function testAlreadyLoaded()
62 // Make sure that referencing a worker that is already loaded yields the same instance.
63 var worker4 = new SharedWorker('resources/shared-worker-common.js', 'name');
64 worker4.port.postMessage("eval self.foo");
65 worker4.port.onmessage = function(event)
67 log((event.data == "self.foo: 1234" ? "PASS: " : "FAIL: ") + "Accessing already-loaded instance of shared worker: " + event.data);
68 done();
72 function done()
74 log("DONE");
75 if (window.testRunner)
76 testRunner.notifyDone();
78 </script>
79 </body>