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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/websocket/send-onmessage-origin.html

Issue 2706013002: Added support for self.origin in Window and WorkerGlobalScope (Closed)
Patch Set: Fixed websocket tests. Added [Replaceable] to the origin in *.idl Created 3 years, 10 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 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="/js-test-resources/js-test.js"></script> 4 <script src="/js-test-resources/js-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <script> 7 <script>
8 description("WebSocket message event origin attribute test (String message)"); 8 description("WebSocket message event origin attribute test (String message)");
9 9
10 window.jsTestIsAsync = true; 10 window.jsTestIsAsync = true;
11 11
12 function endTest() 12 function endTest()
13 { 13 {
14 clearTimeout(timeoutID); 14 clearTimeout(timeoutID);
15 finishJSTest(); 15 finishJSTest();
16 } 16 }
17 17
18 var ws = new WebSocket("ws://localhost:8880/send"); 18 var ws = new WebSocket("ws://localhost:8880/send");
19 19
20 var firstMessageToSend = "This is the first message to send to the server."; 20 var firstMessageToSend = "This is the first message to send to the server.";
21 var secondMessageToSend = "This is the second."; 21 var secondMessageToSend = "This is the second.";
22 // needs to be global to be accessbile from shouldBe(). 22 // needs to be global to be accessbile from shouldBe().
23 var data = ""; 23 var data = "";
24 var origin = ""; 24 var wsOrigin = "";
Mike West 2017/02/21 06:54:36 Hrm. You shouldn't have to do this; this is more o
andypaicu 2017/02/21 09:37:29 Raised https://bugs.chromium.org/p/chromium/issues
25 25
26 ws.onopen = function() 26 ws.onopen = function()
27 { 27 {
28 debug("Connected."); 28 debug("Connected.");
29 ws.send(firstMessageToSend); 29 ws.send(firstMessageToSend);
30 }; 30 };
31 31
32 ws.onmessage = function(messageEvent) 32 ws.onmessage = function(messageEvent)
33 { 33 {
34 // The server should echo back the first message. 34 // The server should echo back the first message.
35 data = messageEvent.data; 35 data = messageEvent.data;
36 shouldBe("data", "firstMessageToSend"); 36 shouldBe("data", "firstMessageToSend");
37 origin = messageEvent.origin; 37 wsOrigin = messageEvent.origin;
38 shouldBeEqualToString("origin", "ws://localhost:8880"); 38 shouldBeEqualToString("wsOrigin", "ws://localhost:8880");
39 ws.onmessage = function(messageEvent) { 39 ws.onmessage = function(messageEvent) {
40 // The server should echo back the second message. 40 // The server should echo back the second message.
41 data = messageEvent.data; 41 data = messageEvent.data;
42 shouldBe("data", "secondMessageToSend"); 42 shouldBe("data", "secondMessageToSend");
43 origin = messageEvent.origin; 43 wsOrigin = messageEvent.origin;
44 shouldBeEqualToString("origin", "ws://localhost:8880"); 44 shouldBeEqualToString("wsOrigin", "ws://localhost:8880");
45 }; 45 };
46 ws.send(secondMessageToSend); 46 ws.send(secondMessageToSend);
47 }; 47 };
48 48
49 ws.onclose = function() 49 ws.onclose = function()
50 { 50 {
51 debug("Closed."); 51 debug("Closed.");
52 endTest(); 52 endTest();
53 }; 53 };
54 54
55 function timeOutCallback() 55 function timeOutCallback()
56 { 56 {
57 testFailed("Timed out in state: " + ws.readyState); 57 testFailed("Timed out in state: " + ws.readyState);
58 endTest(); 58 endTest();
59 } 59 }
60 60
61 var timeoutID = setTimeout(timeOutCallback, 3000); 61 var timeoutID = setTimeout(timeOutCallback, 3000);
62 62
63 </script> 63 </script>
64 </body> 64 </body>
65 </html> 65 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698