2011-07-05 Yuta Kitamura <yutak@chromium.org>
[WebKit-https.git] / LayoutTests / http / tests / websocket / tests / hixie76 / bufferedAmount-after-close.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <link rel="stylesheet" href="../../../../js-test-resources/js-test-style.css">
5 <script src="../../../../js-test-resources/js-test-pre.js"></script>
6 </head>
7 <body>
8 <div id="description"></div>
9 <div id="console"></div>
10 <script type="text/javascript">
11 description("Web Socket bufferedAmount after closed");
12
13 window.jsTestIsAsync = true;
14
15 var ws = new WebSocket("ws://localhost:8880/websocket/tests/hixie76/simple");
16
17 ws.onopen = function()
18 {
19     debug("Connected.");
20     ws.close();
21 };
22
23 ws.onclose = function()
24 {
25     debug("Closed.");
26     shouldBe("ws.readyState", "3");
27     shouldBe("ws.bufferedAmount", "0");
28     shouldBeFalse("ws.send('send to closed socket')");
29     // If the connection is closed, bufferedAmount attribute's value will only
30     // increase with each call to the send() method.
31     // (the number does not reset to zero once the connection closes).
32     shouldBe("ws.bufferedAmount", "23");
33     finishJSTest();
34 };
35
36 var successfullyParsed = true;
37 </script>
38 <script src="../../../../js-test-resources/js-test-post.js"></script>
39 </body>
40 </html>