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

Side by Side Diff: chrome/test/data/extensions/api_test/websocket/test.js

Issue 11087027: WebSocket test server migration on ExtensionApiTest.WebSocket (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 function echoTest(port) { 5 function echoTest(port) {
6 var url = 6 var url = "ws://localhost:" + port + "/echo";
7 "ws://localhost:" + port + "/websocket/tests/hybi/workers/resources/echo";
8 var ws = new WebSocket(url); 7 var ws = new WebSocket(url);
9 var MESSAGE_A = "message a"; 8 var MESSAGE_A = "message a";
10 var MESSAGE_B = "message b"; 9 var MESSAGE_B = "message b";
11 10
12 ws.onopen = function() { 11 ws.onopen = function() {
13 chrome.test.log("websocket opened."); 12 chrome.test.log("websocket opened.");
14 ws.send(MESSAGE_A); 13 ws.send(MESSAGE_A);
15 }; 14 };
16 15
17 ws.onclose = function() { 16 ws.onclose = function() {
18 chrome.test.log("websocket closed."); 17 chrome.test.log("websocket closed.");
19 } 18 }
20 19
21 ws.onmessage = function(messageEvent) { 20 ws.onmessage = function(messageEvent) {
22 chrome.test.log("message received: " + messageEvent.data); 21 chrome.test.log("message received: " + messageEvent.data);
23 chrome.test.assertEq(MESSAGE_A, messageEvent.data); 22 chrome.test.assertEq(MESSAGE_A, messageEvent.data);
24 23
25 ws.onmessage = function(messageEvent) { 24 ws.onmessage = function(messageEvent) {
26 chrome.test.log("message received: " + messageEvent.data); 25 chrome.test.log("message received: " + messageEvent.data);
27 chrome.test.assertEq(MESSAGE_B, messageEvent.data); 26 chrome.test.assertEq(MESSAGE_B, messageEvent.data);
28 ws.close(); 27 ws.close();
29 28
30 chrome.test.succeed(); 29 chrome.test.succeed();
31 }; 30 };
32 31
33 ws.send(MESSAGE_B); 32 ws.send(MESSAGE_B);
34 }; 33 };
35 } 34 }
36 35
37 chrome.test.runTests([ 36 chrome.test.getConfig(function(config) {
38 chrome.test.getConfig(function(config) { 37 chrome.test.runTests([
Takashi Toyoshima 2012/10/09 13:54:48 Oops. This was wrong. Old implementation always pa
39 echoTest(config.testWebSocketPort); 38 function runEchoTest() {
40 }) 39 echoTest(config.testWebSocketPort);
41 ]); 40 }
41 ]);
42 });
43
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_websocket_apitest.cc ('k') | net/data/websocket/echo_wsh.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698