diff --git a/dom/base/test/test_websocket_basic.html b/dom/base/test/test_websocket_basic.html index e3269382e682..fa5e6b4f2198 100644 --- a/dom/base/test/test_websocket_basic.html +++ b/dom/base/test/test_websocket_basic.html @@ -238,7 +238,7 @@ function testWebSocket5() { gTestElement.textContent += "\ntestWebSocket5() completed"; - SimpleTest.executeSoon(SimpleTest.finish); + SimpleTest.executeSoon(testWebSocket6); }; ws.onerror = function(e) { ok(false, "[5] onerror() should not have been called!"); @@ -247,6 +247,40 @@ function testWebSocket5() { }; } +function testWebSocket6() { + gTestElement.textContent = "Running testWebSocket6()"; + + var msgReceived = false; + ws = new WebSocket(kUrl, "test"); + ws.onopen = function(e) { + gTestElement.textContent += "\nSending ©"; + ws.send("©"); + gTestElement.textContent += " end"; + ws.send("end"); + }; + ws.onclose = function(e) { + ok(msgReceived, "[6] Number of received messages"); + ok(e.wasClean, "[6] Connection closed cleanly"); + + SimpleTest.executeSoon(SimpleTest.finish); + }; + ws.onerror = function(e) { + ok(false, "[6] onerror() should not have been called!"); + gTestElement.textContent += "\nonerror() should not have been called!"; + SimpleTest.executeSoon(SimpleTest.finish); + }; + + ws.onmessage = function(e) { + if (msgReceived) { + is(e.data, "end", "[6] Received message"); + } else { + gTestElement.textContent += "\nReceived: " + e.data; + is(e.data, "©", "[6] Received message"); + msgReceived = true; + } + }; +} + SimpleTest.waitForExplicitFinish();