Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(800)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/workers/shared-worker-shared.html

Issue 2604733002: SharedWorker: Make shared workers keyed by a pair of url and name (Closed)
Patch Set: clean up Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <body> 1 <body>
2 <p>Test simple shared worker sharing cases. Should print several PASS lines foll owed by DONE.</p> 2 <p>Test simple shared worker sharing cases. Should print several PASS lines foll owed by DONE.</p>
3 <div id=result></div> 3 <div id=result></div>
4 <script> 4 <script>
5 function log(message) 5 function log(message)
6 { 6 {
7 document.getElementById("result").innerHTML += message + "<br>"; 7 document.getElementById("result").innerHTML += message + "<br>";
8 } 8 }
9 9
10 if (window.testRunner) { 10 if (window.testRunner) {
11 testRunner.dumpAsText(); 11 testRunner.dumpAsText();
12 testRunner.waitUntilDone(); 12 testRunner.waitUntilDone();
13 } 13 }
14 14
15 // Load two workers simultaneously, to ensure that simultaneous loads also yield the same instance. 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 doc ument exits, because other tests also create workers with that same name but wit h different URLs. 16 // Loading a worker named "name" tests that workers shutdown when the parent doc ument exits, because other tests also create workers with that same name but wit h different URLs.
17 var worker = new SharedWorker('resources/shared-worker-common.js', 'name'); 17 var worker = new SharedWorker('resources/shared-worker-common.js', 'name');
18 var worker2 = new SharedWorker('resources/shared-worker-common.js', 'name'); 18 var worker2 = new SharedWorker('resources/shared-worker-common.js', 'name');
19 19
20 try { 20 try {
21 new SharedWorker('resources/some-other-url.js', 'name'); 21 new SharedWorker('resources/some-other-url.js', 'name');
22 log("FAIL: Creating SharedWorker with different URLs but the same name shoul d fail"); 22 log("PASS: Creating SharedWorker with different URLs but the same name");
23 } catch (ex) { 23 } catch (ex) {
24 var exString = ex.toString(); 24 var exString = ex.toString();
25 exString = exString.replace(/file:\/\/.*\//, "") 25 exString = exString.replace(/file:\/\/.*\//, "")
26 log("PASS: Exception thrown when creating SharedWorker with different URLs b ut same name: " + exString); 26 log("FAIL: Exception thrown when creating SharedWorker with different URLs b ut same name: " + exString);
27 } 27 }
28 28
29 29
30 // Set something in global context in one worker, read value back on other worke r, to make sure they are truly shared. 30 // Set something in global context in one worker, read value back on other worke r, to make sure they are truly shared.
31 worker.port.postMessage("eval self.foo"); 31 worker.port.postMessage("eval self.foo");
32 worker.port.onmessage = function(event) 32 worker.port.onmessage = function(event)
33 { 33 {
34 log((event.data == "self.foo: undefined" ? "PASS: " : "FAIL: ") + "Accessing new instance of shared worker: " + event.data); 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"); 35 worker.port.postMessage("eval self.foo = 1234");
36 worker.port.onmessage = function(event) 36 worker.port.onmessage = function(event)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 70 }
71 71
72 function done() 72 function done()
73 { 73 {
74 log("DONE"); 74 log("DONE");
75 if (window.testRunner) 75 if (window.testRunner)
76 testRunner.notifyDone(); 76 testRunner.notifyDone();
77 } 77 }
78 </script> 78 </script>
79 </body> 79 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698