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
3 // found in the LICENSE file.
5 function echoTest(port) {
6 var url = "ws://localhost:" + port + "/echo-with-no-extension";
7 var ws = new WebSocket(url);
8 var MESSAGE_A = "message a";
9 var MESSAGE_B = "message b";
11 ws.onopen = function() {
12 chrome.test.log("websocket opened.");
16 ws.onclose = function() {
17 chrome.test.log("websocket closed.");
20 ws.onmessage = function(messageEvent) {
21 chrome.test.log("message received: " + messageEvent.data);
22 chrome.test.assertEq(MESSAGE_A, messageEvent.data);
24 ws.onmessage = function(messageEvent) {
25 chrome.test.log("message received: " + messageEvent.data);
26 chrome.test.assertEq(MESSAGE_B, messageEvent.data);
29 chrome.test.succeed();
36 chrome.test.getConfig(function(config) {
37 chrome.test.runTests([
38 function runEchoTest() {
39 echoTest(config.testWebSocketPort);