OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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. |
| 4 |
| 5 chrome.test.runTests([ |
| 6 function echoTest() { |
| 7 var ws = new WebSocket( |
| 8 "ws://localhost:8880/websocket/tests/hybi/workers/resources/echo"); |
| 9 var MESSAGE_A = "message a"; |
| 10 var MESSAGE_B = "message b"; |
| 11 |
| 12 ws.onopen = function() { |
| 13 chrome.test.log("websocket opened."); |
| 14 ws.send(MESSAGE_A); |
| 15 }; |
| 16 |
| 17 ws.onclose = function() { |
| 18 chrome.test.log("websocket closed."); |
| 19 } |
| 20 |
| 21 ws.onmessage = function(messageEvent) { |
| 22 chrome.test.log("message received: " + messageEvent.data); |
| 23 chrome.test.assertEq(MESSAGE_A, messageEvent.data); |
| 24 |
| 25 ws.onmessage = function(messageEvent) { |
| 26 chrome.test.log("message received: " + messageEvent.data); |
| 27 chrome.test.assertEq(MESSAGE_B, messageEvent.data); |
| 28 ws.close(); |
| 29 |
| 30 chrome.test.succeed(); |
| 31 }; |
| 32 |
| 33 ws.send(MESSAGE_B); |
| 34 }; |
| 35 } |
| 36 ]); |
OLD | NEW |