Changeset 90100 in webkit


Ignore:
Timestamp:
Jun 30, 2011 2:31:01 AM (13 years ago)
Author:
yutak@chromium.org
Message:

2011-06-30 Yuta Kitamura <yutak@chromium.org>

Reviewed by Kent Tamura.

WebSocket: Don't use script-tests for WebSocket tests
https://bugs.webkit.org/show_bug.cgi?id=63691

Move content of script-tests/XXX.js into XXX.html.

No changes were made to script code. Hence, these tests are not using
window.jsTestAsync and finishJSTest() for now. I will fix this later.

  • http/tests/websocket/tests/alert-in-event-handler.html:
  • http/tests/websocket/tests/bad-handshake-crash.html:
  • http/tests/websocket/tests/bad-sub-protocol-control-chars.html:
  • http/tests/websocket/tests/bad-sub-protocol-empty.html:
  • http/tests/websocket/tests/bad-sub-protocol-non-ascii.html:
  • http/tests/websocket/tests/bufferedAmount-after-close.html:
  • http/tests/websocket/tests/cross-origin.html:
  • http/tests/websocket/tests/error-detect.html:
  • http/tests/websocket/tests/frame-length-longer-than-buffer.html:
  • http/tests/websocket/tests/frame-length-skip.html:
  • http/tests/websocket/tests/handshake-challenge-randomness.html:
  • http/tests/websocket/tests/handshake-error.html:
  • http/tests/websocket/tests/handshake-fail-by-cross-origin.html:
  • http/tests/websocket/tests/handshake-fail-by-no-cr.html:
  • http/tests/websocket/tests/handshake-fail-by-sub-protocol-mismatch.html:
  • http/tests/websocket/tests/long-invalid-header.html:
  • http/tests/websocket/tests/null-character.html:
  • http/tests/websocket/tests/script-tests/TEMPLATE.html: Removed.
  • http/tests/websocket/tests/script-tests/alert-in-event-handler.js: Removed.
  • http/tests/websocket/tests/script-tests/bad-handshake-crash.js: Removed.
  • http/tests/websocket/tests/script-tests/bad-sub-protocol-control-chars.js: Removed.
  • http/tests/websocket/tests/script-tests/bad-sub-protocol-empty.js: Removed.
  • http/tests/websocket/tests/script-tests/bad-sub-protocol-non-ascii.js: Removed.
  • http/tests/websocket/tests/script-tests/bufferedAmount-after-close.js: Removed.
  • http/tests/websocket/tests/script-tests/cross-origin.js: Removed.
  • http/tests/websocket/tests/script-tests/error-detect.js: Removed.
  • http/tests/websocket/tests/script-tests/frame-length-longer-than-buffer.js: Removed.
  • http/tests/websocket/tests/script-tests/frame-length-skip.js: Removed.
  • http/tests/websocket/tests/script-tests/handshake-challenge-randomness.js: Removed.
  • http/tests/websocket/tests/script-tests/handshake-error.js: Removed.
  • http/tests/websocket/tests/script-tests/handshake-fail-by-cross-origin.js: Removed.
  • http/tests/websocket/tests/script-tests/handshake-fail-by-no-cr.js: Removed.
  • http/tests/websocket/tests/script-tests/handshake-fail-by-sub-protocol-mismatch.js: Removed.
  • http/tests/websocket/tests/script-tests/long-invalid-header.js: Removed.
  • http/tests/websocket/tests/script-tests/null-character.js: Removed.
  • http/tests/websocket/tests/script-tests/send-throw.js: Removed.
  • http/tests/websocket/tests/script-tests/send.js: Removed.
  • http/tests/websocket/tests/script-tests/simple.js: Removed.
  • http/tests/websocket/tests/script-tests/sub-protocol-with-space.js: Removed.
  • http/tests/websocket/tests/script-tests/sub-protocol.js: Removed.
  • http/tests/websocket/tests/script-tests/unicode.js: Removed.
  • http/tests/websocket/tests/script-tests/url-no-trailing-slash.js: Removed.
  • http/tests/websocket/tests/script-tests/url-parsing.js: Removed.
  • http/tests/websocket/tests/script-tests/url-with-credential.js: Removed.
  • http/tests/websocket/tests/script-tests/url-with-empty-query.js: Removed.
  • http/tests/websocket/tests/script-tests/url-with-query-for-no-query.js: Removed.
  • http/tests/websocket/tests/script-tests/url-with-query.js: Removed.
  • http/tests/websocket/tests/script-tests/websocket-event-target.js: Removed.
  • http/tests/websocket/tests/script-tests/websocket-protocol-ignored.js: Removed.
  • http/tests/websocket/tests/send-throw.html:
  • http/tests/websocket/tests/send.html:
  • http/tests/websocket/tests/simple.html:
  • http/tests/websocket/tests/sub-protocol-with-space.html:
  • http/tests/websocket/tests/sub-protocol.html:
  • http/tests/websocket/tests/unicode.html:
  • http/tests/websocket/tests/url-no-trailing-slash.html:
  • http/tests/websocket/tests/url-parsing.html:
  • http/tests/websocket/tests/url-with-credential.html:
  • http/tests/websocket/tests/url-with-empty-query.html:
  • http/tests/websocket/tests/url-with-query-for-no-query.html:
  • http/tests/websocket/tests/url-with-query.html:
  • http/tests/websocket/tests/websocket-event-target.html:
  • http/tests/websocket/tests/websocket-protocol-ignored.html:
Location:
trunk/LayoutTests
Files:
32 deleted
32 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r90099 r90100  
     12011-06-30  Yuta Kitamura  <yutak@chromium.org>
     2
     3        Reviewed by Kent Tamura.
     4
     5        WebSocket: Don't use script-tests for WebSocket tests
     6        https://bugs.webkit.org/show_bug.cgi?id=63691
     7
     8        Move content of script-tests/XXX.js into XXX.html.
     9
     10        No changes were made to script code. Hence, these tests are not using
     11        window.jsTestAsync and finishJSTest() for now. I will fix this later.
     12
     13        * http/tests/websocket/tests/alert-in-event-handler.html:
     14        * http/tests/websocket/tests/bad-handshake-crash.html:
     15        * http/tests/websocket/tests/bad-sub-protocol-control-chars.html:
     16        * http/tests/websocket/tests/bad-sub-protocol-empty.html:
     17        * http/tests/websocket/tests/bad-sub-protocol-non-ascii.html:
     18        * http/tests/websocket/tests/bufferedAmount-after-close.html:
     19        * http/tests/websocket/tests/cross-origin.html:
     20        * http/tests/websocket/tests/error-detect.html:
     21        * http/tests/websocket/tests/frame-length-longer-than-buffer.html:
     22        * http/tests/websocket/tests/frame-length-skip.html:
     23        * http/tests/websocket/tests/handshake-challenge-randomness.html:
     24        * http/tests/websocket/tests/handshake-error.html:
     25        * http/tests/websocket/tests/handshake-fail-by-cross-origin.html:
     26        * http/tests/websocket/tests/handshake-fail-by-no-cr.html:
     27        * http/tests/websocket/tests/handshake-fail-by-sub-protocol-mismatch.html:
     28        * http/tests/websocket/tests/long-invalid-header.html:
     29        * http/tests/websocket/tests/null-character.html:
     30        * http/tests/websocket/tests/script-tests/TEMPLATE.html: Removed.
     31        * http/tests/websocket/tests/script-tests/alert-in-event-handler.js: Removed.
     32        * http/tests/websocket/tests/script-tests/bad-handshake-crash.js: Removed.
     33        * http/tests/websocket/tests/script-tests/bad-sub-protocol-control-chars.js: Removed.
     34        * http/tests/websocket/tests/script-tests/bad-sub-protocol-empty.js: Removed.
     35        * http/tests/websocket/tests/script-tests/bad-sub-protocol-non-ascii.js: Removed.
     36        * http/tests/websocket/tests/script-tests/bufferedAmount-after-close.js: Removed.
     37        * http/tests/websocket/tests/script-tests/cross-origin.js: Removed.
     38        * http/tests/websocket/tests/script-tests/error-detect.js: Removed.
     39        * http/tests/websocket/tests/script-tests/frame-length-longer-than-buffer.js: Removed.
     40        * http/tests/websocket/tests/script-tests/frame-length-skip.js: Removed.
     41        * http/tests/websocket/tests/script-tests/handshake-challenge-randomness.js: Removed.
     42        * http/tests/websocket/tests/script-tests/handshake-error.js: Removed.
     43        * http/tests/websocket/tests/script-tests/handshake-fail-by-cross-origin.js: Removed.
     44        * http/tests/websocket/tests/script-tests/handshake-fail-by-no-cr.js: Removed.
     45        * http/tests/websocket/tests/script-tests/handshake-fail-by-sub-protocol-mismatch.js: Removed.
     46        * http/tests/websocket/tests/script-tests/long-invalid-header.js: Removed.
     47        * http/tests/websocket/tests/script-tests/null-character.js: Removed.
     48        * http/tests/websocket/tests/script-tests/send-throw.js: Removed.
     49        * http/tests/websocket/tests/script-tests/send.js: Removed.
     50        * http/tests/websocket/tests/script-tests/simple.js: Removed.
     51        * http/tests/websocket/tests/script-tests/sub-protocol-with-space.js: Removed.
     52        * http/tests/websocket/tests/script-tests/sub-protocol.js: Removed.
     53        * http/tests/websocket/tests/script-tests/unicode.js: Removed.
     54        * http/tests/websocket/tests/script-tests/url-no-trailing-slash.js: Removed.
     55        * http/tests/websocket/tests/script-tests/url-parsing.js: Removed.
     56        * http/tests/websocket/tests/script-tests/url-with-credential.js: Removed.
     57        * http/tests/websocket/tests/script-tests/url-with-empty-query.js: Removed.
     58        * http/tests/websocket/tests/script-tests/url-with-query-for-no-query.js: Removed.
     59        * http/tests/websocket/tests/script-tests/url-with-query.js: Removed.
     60        * http/tests/websocket/tests/script-tests/websocket-event-target.js: Removed.
     61        * http/tests/websocket/tests/script-tests/websocket-protocol-ignored.js: Removed.
     62        * http/tests/websocket/tests/send-throw.html:
     63        * http/tests/websocket/tests/send.html:
     64        * http/tests/websocket/tests/simple.html:
     65        * http/tests/websocket/tests/sub-protocol-with-space.html:
     66        * http/tests/websocket/tests/sub-protocol.html:
     67        * http/tests/websocket/tests/unicode.html:
     68        * http/tests/websocket/tests/url-no-trailing-slash.html:
     69        * http/tests/websocket/tests/url-parsing.html:
     70        * http/tests/websocket/tests/url-with-credential.html:
     71        * http/tests/websocket/tests/url-with-empty-query.html:
     72        * http/tests/websocket/tests/url-with-query-for-no-query.html:
     73        * http/tests/websocket/tests/url-with-query.html:
     74        * http/tests/websocket/tests/websocket-event-target.html:
     75        * http/tests/websocket/tests/websocket-protocol-ignored.html:
     76
    1772011-06-30  Yuta Kitamura  <yutak@chromium.org>
    278
  • trunk/LayoutTests/http/tests/websocket/tests/alert-in-event-handler.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/alert-in-event-handler.js"></script>
     11<script type="text/javascript">
     12description("Make sure event handler called serially.");
     13
     14if (window.layoutTestController) {
     15    layoutTestController.waitUntilDone();
     16}
     17
     18function endTest()
     19{
     20    isSuccessfullyParsed();
     21    if (window.layoutTestController) {
     22        layoutTestController.notifyDone();
     23    }
     24}
     25
     26var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/send2");
     27
     28ws.onopen = function()
     29{
     30    debug("Connected");
     31};
     32
     33ws.onmessage = function(messageEvent)
     34{
     35    debug("Enter onmessage: " + messageEvent.data);
     36    // alert() will suspend/resume WebSocket.
     37    alert("message handled." + messageEvent.data);
     38    debug("Leave onmessage: " + messageEvent.data);
     39};
     40
     41ws.onclose = function()
     42{
     43    debug("Closed");
     44    endTest();
     45};
     46
     47debug("alert will suspend/resume WebSocket.");
     48alert("waiting for open");
     49debug("onopen should fire later.");
     50var successfullyParsed = true;
     51</script>
    1252</body>
    1353</html>
  • trunk/LayoutTests/http/tests/websocket/tests/bad-handshake-crash.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/bad-handshake-crash.js"></script>
     11<script type="text/javascript">
     12description("Make sure WebSocket doesn't crash with bad handshake message.");
     13if (window.layoutTestController)
     14    layoutTestController.waitUntilDone();
     15
     16function finish() {
     17    isSuccessfullyParsed();
     18    if (window.layoutTestController)
     19        layoutTestController.notifyDone();
     20}
     21
     22var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/bad-handshake-crash");
     23ws.onopen = function () {
     24    debug("WebSocket is open");
     25};
     26ws.onclose = function () {
     27    debug("WebSocket is closed");
     28    finish();
     29};
     30
     31var successfullyParsed = true;
     32</script>
    1233</body>
    1334</html>
  • trunk/LayoutTests/http/tests/websocket/tests/bad-sub-protocol-control-chars.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/bad-sub-protocol-control-chars.js"></script>
     11<script type="text/javascript">
     12description("Test WebSocket bad sub-protocol names by control characters.");
     13
     14// Fails if protocol contains an character less than U+0020.
     15shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u0000")');
     16shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u0009")');
     17shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u000A")');
     18shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u000D")');
     19shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u001B")');
     20
     21var successfullyParsed = true;
     22isSuccessfullyParsed();
     23</script>
    1224</body>
    1325</html>
  • trunk/LayoutTests/http/tests/websocket/tests/bad-sub-protocol-empty.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/bad-sub-protocol-empty.js"></script>
     11<script type="text/javascript">
     12description("Test WebSocket bad sub-protocol names (empty).");
     13
     14// Fails if protocol is an empty string.
     15shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "")');
     16
     17var successfullyParsed = true;
     18isSuccessfullyParsed();
     19</script>
    1220</body>
    1321</html>
  • trunk/LayoutTests/http/tests/websocket/tests/bad-sub-protocol-non-ascii.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/bad-sub-protocol-non-ascii.js"></script>
     11<script type="text/javascript">
     12description("Test WebSocket bad sub-protocol names by non-ASCII chars.");
     13
     14// Fails if protocol contains an character greater than U+007E.
     15shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u007F")');
     16shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u0080")');
     17shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\u3042")');
     18shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\uFFFF")');
     19shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\uFEFF")');
     20shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\uFFFE")');
     21// Surrogate pairs
     22shouldThrow('new WebSocket("ws://127.0.0.1:8880/simple", "\uD840\uDC0B")');
     23
     24var successfullyParsed = true;
     25isSuccessfullyParsed();
     26</script>
    1227</body>
    1328</html>
  • trunk/LayoutTests/http/tests/websocket/tests/bufferedAmount-after-close.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/bufferedAmount-after-close.js"></script>
     11<script type="text/javascript">
     12description("Web Socket bufferedAmount after closed");
     13
     14if (window.layoutTestController)
     15    layoutTestController.waitUntilDone();
     16
     17function endTest()
     18{
     19    isSuccessfullyParsed();
     20    if (window.layoutTestController)
     21        layoutTestController.notifyDone();
     22}
     23
     24var ws = new WebSocket("ws://localhost:8880/websocket/tests/simple");
     25
     26ws.onopen = function()
     27{
     28    debug("Connected.");
     29    ws.close();
     30};
     31
     32ws.onclose = function()
     33{
     34    debug("Closed.");
     35    shouldBe("ws.readyState", "3");
     36    shouldBe("ws.bufferedAmount", "0");
     37    shouldBeFalse("ws.send('send to closed socket')");
     38    // If the connection is closed, bufferedAmount attribute's value will only
     39    // increase with each call to the send() method.
     40    // (the number does not reset to zero once the connection closes).
     41    shouldBe("ws.bufferedAmount", "23");
     42    endTest();
     43};
     44
     45var successfullyParsed = true;
     46</script>
    1247</body>
    1348</html>
  • trunk/LayoutTests/http/tests/websocket/tests/cross-origin.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/cross-origin.js"></script>
     11<script type="text/javascript">
     12description("Web Socket Cross Origin test");
     13
     14if (window.layoutTestController)
     15    layoutTestController.waitUntilDone();
     16
     17var origin;
     18
     19function endTest()
     20{
     21    shouldBe("origin", '"http://127.0.0.1:8000"');
     22    clearTimeout(timeoutID);
     23    isSuccessfullyParsed();
     24    if (window.layoutTestController)
     25        layoutTestController.notifyDone();
     26}
     27
     28var url = "ws://localhost:8880/websocket/tests/origin-test";
     29debug("document.domain=" + document.domain);
     30debug("ws.url=" + url);
     31var ws = new WebSocket(url);
     32
     33ws.onopen = function()
     34{
     35    debug("Connected");
     36};
     37
     38ws.onmessage = function (messageEvent)
     39{
     40    origin = messageEvent.data;
     41    ws.close();
     42};
     43
     44ws.onclose = function()
     45{
     46    endTest();
     47};
     48
     49function timeOutCallback()
     50{
     51    debug("Timed out in state: " + ws.readyState);
     52    endTest();
     53}
     54
     55var timeoutID = setTimeout(timeOutCallback, 3000);
     56
     57var successfullyParsed = true;
     58</script>
    1259</body>
    1360</html>
  • trunk/LayoutTests/http/tests/websocket/tests/error-detect.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/error-detect.js"></script>
     11<script type="text/javascript">
     12description("Make sure WebSocket correctly fire error event for unknown frame type.");
     13if (window.layoutTestController)
     14    layoutTestController.waitUntilDone();
     15
     16var errorCount = 0;
     17
     18function finish() {
     19    shouldBe("errorCount", "255");
     20    isSuccessfullyParsed();
     21    if (window.layoutTestController)
     22        layoutTestController.notifyDone();
     23}
     24
     25var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/unknown-frame-type");
     26ws.onopen = function () {
     27    debug("WebSocket is open");
     28};
     29ws.onmessage = function (evt) {
     30    debug("received:" + evt.data);
     31};
     32ws.onerror = function () {
     33    errorCount += 1;
     34};
     35ws.onclose = function () {
     36    debug("WebSocket is closed");
     37    finish();
     38};
     39
     40var successfullyParsed = true;
     41</script>
    1242</body>
    1343</html>
  • trunk/LayoutTests/http/tests/websocket/tests/frame-length-longer-than-buffer.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/frame-length-longer-than-buffer.js"></script>
     11<script type="text/javascript">
     12description("Make sure WebSocket correctly skip lengthed frame even if received data has incomplete frame.");
     13if (window.layoutTestController)
     14    layoutTestController.waitUntilDone();
     15
     16var received_messages = [];
     17var expected_messages = ["hello"];
     18function finish() {
     19    clearTimeout(timeoutID);
     20    debug(received_messages.length);
     21    for (var i = 0; i < received_messages; i++) {
     22        debug("received[" + i + "]=" + received_messages[i]);
     23    }
     24
     25    shouldBeTrue("areArraysEqual(received_messages, expected_messages)");
     26
     27    isSuccessfullyParsed();
     28    if (window.layoutTestController)
     29        layoutTestController.notifyDone();
     30}
     31
     32var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/frame-length-longer-than-buffer");
     33ws.onopen = function () {
     34    debug("WebSocket is open");
     35};
     36ws.onmessage = function (evt) {
     37    debug("received:" + evt.data);
     38    received_messages.push(evt.data);
     39};
     40ws.onclose = function () {
     41    debug("WebSocket is closed");
     42    finish();
     43};
     44var timeoutID = setTimeout("finish()", 2000);
     45
     46var successfullyParsed = true;
     47</script>
    1248</body>
    1349</html>
  • trunk/LayoutTests/http/tests/websocket/tests/frame-length-skip.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/frame-length-skip.js"></script>
     11<script type="text/javascript">
     12description("Make sure WebSocket correctly skip lengthed frame.");
     13if (window.layoutTestController)
     14    layoutTestController.waitUntilDone();
     15
     16var received_messages = [];
     17var expected_messages = ["hello", "world"];
     18function finish() {
     19    clearTimeout(timeoutID);
     20    debug(received_messages.length);
     21    for (var i = 0; i < received_messages; i++) {
     22        debug("received[" + i + "]=" + received_messages[i]);
     23    }
     24
     25    shouldBeTrue("areArraysEqual(received_messages, expected_messages)");
     26
     27    isSuccessfullyParsed();
     28    if (window.layoutTestController)
     29        layoutTestController.notifyDone();
     30}
     31
     32var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/frame-length-skip");
     33ws.onopen = function () {
     34    debug("WebSocket is open");
     35};
     36ws.onmessage = function (evt) {
     37    debug("received:" + evt.data);
     38    received_messages.push(evt.data);
     39};
     40ws.onclose = function () {
     41    debug("WebSocket is closed");
     42    finish();
     43};
     44var timeoutID = setTimeout("finish()", 2000);
     45
     46var successfullyParsed = true;
     47</script>
    1248</body>
    1349</html>
  • trunk/LayoutTests/http/tests/websocket/tests/handshake-challenge-randomness.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/handshake-challenge-randomness.js"></script>
     11<script type="text/javascript">
     12description('Handshake request should contain random challenge values.');
     13
     14if (window.layoutTestController)
     15    layoutTestController.waitUntilDone();
     16
     17var challenge1;
     18var challenge2;
     19
     20function endTest()
     21{
     22    shouldBeFalse('challenge1 === challenge2');
     23    if (challenge1 === challenge2)
     24        debug('challenge was ' + challenge1);
     25
     26    isSuccessfullyParsed();
     27    if (window.layoutTestController)
     28        layoutTestController.notifyDone();
     29}
     30
     31var url = 'ws://localhost:8880/websocket/tests/echo-challenge';
     32var ws1 = new WebSocket(url);
     33
     34ws1.onmessage = function(messageEvent)
     35{
     36    challenge1 = messageEvent.data;
     37    ws1.close();
     38}
     39
     40ws1.onclose = function()
     41{
     42    var ws2 = new WebSocket(url);
     43
     44    ws2.onmessage = function(messageEvent)
     45    {
     46        challenge2 = messageEvent.data;
     47        ws2.close();
     48    }
     49
     50    ws2.onclose = function()
     51    {
     52        endTest();
     53    }
     54}
     55
     56var successfullyParsed = true;
     57</script>
    1258</body>
    1359</html>
  • trunk/LayoutTests/http/tests/websocket/tests/handshake-error.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/handshake-error.js"></script>
     11<script type="text/javascript">
     12description("Handshake error test");
     13
     14if (window.layoutTestController) {
     15    layoutTestController.waitUntilDone();
     16}
     17
     18function endTest()
     19{
     20    isSuccessfullyParsed();
     21    clearTimeout(timeoutID);
     22    if (window.layoutTestController) {
     23        layoutTestController.notifyDone();
     24    }
     25}
     26
     27var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/handshake-error");
     28
     29ws.onopen = function()
     30{
     31    testFailed("Unexpectedly Connected.");
     32};
     33
     34ws.onmessage = function(messageEvent)
     35{
     36    testFailed("Unexpectedly Received: '" + messageEvent.data + "'");
     37};
     38
     39ws.onclose = function()
     40{
     41    debug("Closed.");
     42    shouldBe("ws.readyState", "3")
     43    endTest();
     44};
     45
     46function timeOutCallback()
     47{
     48    testFailed("Timed out in state: " + ws.readyState);
     49    endTest();
     50}
     51
     52var timeoutID = setTimeout(timeOutCallback, 3000);
     53
     54var successfullyParsed = true;
     55</script>
    1256</body>
    1357</html>
  • trunk/LayoutTests/http/tests/websocket/tests/handshake-fail-by-cross-origin.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/handshake-fail-by-cross-origin.js"></script>
     11<script type="text/javascript">
     12description("Make sure Web Socket connection failed if origin mismatches.");
     13
     14if (window.layoutTestController)
     15    layoutTestController.waitUntilDone();
     16
     17var connected = false;
     18var origin;
     19
     20function endTest()
     21{
     22    shouldBeFalse("connected");
     23    shouldBeUndefined("origin");
     24    clearTimeout(timeoutID);
     25    isSuccessfullyParsed();
     26    if (window.layoutTestController)
     27        layoutTestController.notifyDone();
     28}
     29
     30var url = "ws://localhost:8880/websocket/tests/fixed-origin";
     31debug("document.domain=" + document.domain);
     32debug("ws.url=" + url);
     33var ws = new WebSocket(url);
     34
     35ws.onopen = function()
     36{
     37    debug("Connected");
     38    connected = true;
     39};
     40
     41ws.onmessage = function (messageEvent)
     42{
     43    origin = messageEvent.data;
     44    debug("origin=" + origin);
     45    ws.close();
     46};
     47
     48ws.onclose = function()
     49{
     50    endTest();
     51};
     52
     53function timeOutCallback()
     54{
     55    debug("Timed out in state: " + ws.readyState);
     56    endTest();
     57}
     58
     59var timeoutID = setTimeout(timeOutCallback, 3000);
     60
     61var successfullyParsed = true;
     62</script>
    1263</body>
    1364</html>
  • trunk/LayoutTests/http/tests/websocket/tests/handshake-fail-by-no-cr.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/handshake-fail-by-no-cr.js"></script>
     11<script type="text/javascript">
     12description('Handshake should fail when the first line does not end with CRLF.');
     13
     14if (window.layoutTestController)
     15    layoutTestController.waitUntilDone()
     16
     17var connected = false;
     18var origin;
     19
     20function endTest() {
     21    shouldBeFalse('connected');
     22    shouldBeUndefined('origin');
     23    clearTimeout(timeoutID);
     24    isSuccessfullyParsed();
     25    if (window.layoutTestController)
     26        layoutTestController.notifyDone();
     27}
     28
     29var url = 'ws://localhost:8880/websocket/tests/handshake-fail-by-no-cr';
     30var ws = new WebSocket(url);
     31
     32ws.onopen = function()
     33{
     34    debug('Connected');
     35    connected = true;
     36}
     37
     38ws.onmessage = function(messageEvent)
     39{
     40    origin = messageEvent.data;
     41    debug('origin = ' + origin);
     42    ws.close();
     43}
     44
     45ws.onclose = function()
     46{
     47    endTest();
     48}
     49
     50function timeoutCallback()
     51{
     52    debug('Timed out (state = ' + ws.readyState + ')');
     53    endTest();
     54}
     55
     56var timeoutID = setTimeout(timeoutCallback, 3000);
     57
     58var successfullyParsed = true;
     59</script>
    1260</body>
    1361</html>
  • trunk/LayoutTests/http/tests/websocket/tests/handshake-fail-by-sub-protocol-mismatch.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/handshake-fail-by-sub-protocol-mismatch.js"></script>
     11<script type="text/javascript">
     12description("Test WebSocket handshake fail if sub protocol name mismatches.");
     13
     14if (window.layoutTestController)
     15    layoutTestController.waitUntilDone();
     16
     17var protocol;
     18
     19function endTest()
     20{
     21    shouldBeUndefined("protocol");
     22    clearTimeout(timeoutID);
     23    isSuccessfullyParsed();
     24    if (window.layoutTestController)
     25        layoutTestController.notifyDone();
     26}
     27
     28var url = "ws://localhost:8880/websocket/tests/protocol-test?protocol=available-protocol";
     29var ws = new WebSocket(url, "requestting-protocol");
     30
     31ws.onopen = function()
     32{
     33    debug("Connected");
     34};
     35
     36ws.onmessage = function (messageEvent)
     37{
     38    protocol = messageEvent.data;
     39    ws.close();
     40};
     41
     42ws.onclose = function()
     43{
     44    endTest();
     45};
     46
     47function timeOutCallback()
     48{
     49    debug("Timed out in state: " + ws.readyState);
     50    endTest();
     51}
     52
     53var timeoutID = setTimeout(timeOutCallback, 3000);
     54
     55var successfullyParsed = true;
     56</script>
    1257</body>
    1358</html>
  • trunk/LayoutTests/http/tests/websocket/tests/long-invalid-header.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/long-invalid-header.js"></script>
     11<script type="text/javascript">
     12description("Make sure WebSocket gives errors on long invalid upgrade header.");
     13if (window.layoutTestController)
     14    layoutTestController.waitUntilDone();
     15
     16function finish() {
     17    clearTimeout(timeoutID);
     18
     19    isSuccessfullyParsed();
     20    if (window.layoutTestController)
     21        layoutTestController.notifyDone();
     22}
     23
     24var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/long-invalid-header");
     25ws.onopen = function () {
     26    debug("WebSocket is open");
     27};
     28ws.onclose = function () {
     29    debug("WebSocket is closed");
     30    finish();
     31};
     32var timeoutID = setTimeout("finish()", 2000);
     33
     34var successfullyParsed = true;
     35</script>
    1236</body>
    1337</html>
  • trunk/LayoutTests/http/tests/websocket/tests/null-character.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/null-character.js"></script>
     11<script type="text/javascript">
     12description("Make sure WebSocket transfer null character");
     13
     14if (window.layoutTestController)
     15    layoutTestController.waitUntilDone();
     16
     17function finish()
     18{
     19    isSuccessfullyParsed();
     20    if (window.layoutTestController)
     21        layoutTestController.notifyDone();
     22}
     23
     24var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/echo");
     25// \xff in string would be \xc3\xbf on websocket connection (UTF-8)
     26var expectedMessage = "Should Not\xff\0Split";
     27
     28ws.onopen = function()
     29{
     30    debug("WebSocket open");
     31    ws.send(expectedMessage);
     32};
     33
     34var msg;
     35ws.onmessage = function(messageEvent)
     36{
     37    msg = messageEvent.data;
     38    debug("msg should not be split by frame char \\xff\\0");
     39    shouldBe("msg", "expectedMessage");
     40    ws.close();
     41};
     42
     43ws.onclose = function()
     44{
     45    debug("WebSocket closed");
     46    finish();
     47};
     48
     49var successfullyParsed = true;
     50</script>
    1251</body>
    1352</html>
  • trunk/LayoutTests/http/tests/websocket/tests/send-throw.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/send-throw.js"></script>
     11<script type="text/javascript">
     12description("Web Socket send test");
     13
     14if (window.layoutTestController)
     15    layoutTestController.waitUntilDone();
     16
     17function endTest()
     18{
     19    isSuccessfullyParsed();
     20    clearTimeout(timeoutID);
     21    if (window.layoutTestController)
     22        layoutTestController.notifyDone();
     23}
     24
     25var ws = new WebSocket("ws://localhost:8880/websocket/tests/send");
     26
     27var FIRST_MESSAGE_TO_SEND = {
     28    toString: function() { throw "Pickles"; }
     29};
     30// data needs to be global to be accessbile from shouldBe().
     31var data = "";
     32
     33ws.onopen = function()
     34{
     35    debug("Connected.");
     36    try {
     37        ws.send(FIRST_MESSAGE_TO_SEND);
     38    } catch (ex) {
     39        debug("Caught exception: " + ex);
     40    }
     41    ws.close();
     42};
     43
     44ws.onclose = function()
     45{
     46    debug("Closed.");
     47    endTest();
     48};
     49
     50function timeOutCallback()
     51{
     52    testFailed("Timed out in state: " + ws.readyState);
     53    endTest();
     54}
     55
     56var timeoutID = setTimeout(timeOutCallback, 3000);
     57
     58var successfullyParsed = true;
     59</script>
    1260</body>
    1361</html>
  • trunk/LayoutTests/http/tests/websocket/tests/send.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/send.js"></script>
     11<script type="text/javascript">
     12description("Web Socket send test");
     13
     14if (window.layoutTestController)
     15    layoutTestController.waitUntilDone();
     16
     17function endTest()
     18{
     19    isSuccessfullyParsed();
     20    clearTimeout(timeoutID);
     21    if (window.layoutTestController)
     22        layoutTestController.notifyDone();
     23}
     24
     25var ws = new WebSocket("ws://localhost:8880/websocket/tests/send");
     26
     27var FIRST_MESSAGE_TO_SEND = "This is the first message to send to the server.";
     28var SECOND_MESSAGE_TO_SEND = "This is the second.";
     29// data needs to be global to be accessbile from shouldBe().
     30var data = "";
     31
     32ws.onopen = function()
     33{
     34    debug("Connected.");
     35    ws.send(FIRST_MESSAGE_TO_SEND);
     36};
     37
     38ws.onmessage = function(messageEvent)
     39{
     40    // The server should echo back the first message.
     41    data = messageEvent.data;
     42    shouldBe("data", "FIRST_MESSAGE_TO_SEND");
     43    ws.onmessage = function(messageEvent) {
     44        // The server should echo back the second message.
     45        data = messageEvent.data;
     46        shouldBe("data", "SECOND_MESSAGE_TO_SEND");
     47    };
     48    ws.send(SECOND_MESSAGE_TO_SEND);
     49};
     50
     51ws.onclose = function()
     52{
     53    debug("Closed.");
     54    endTest();
     55};
     56
     57function timeOutCallback()
     58{
     59    testFailed("Timed out in state: " + ws.readyState);
     60    endTest();
     61}
     62
     63var timeoutID = setTimeout(timeOutCallback, 3000);
     64
     65var successfullyParsed = true;
     66</script>
    1267</body>
    1368</html>
  • trunk/LayoutTests/http/tests/websocket/tests/simple.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/simple.js"></script>
     11<script type="text/javascript">
     12description("Simple Web Socket test");
     13
     14if (window.layoutTestController) {
     15    layoutTestController.waitUntilDone();
     16}
     17
     18function endTest()
     19{
     20    isSuccessfullyParsed();
     21    clearTimeout(timeoutID);
     22    if (window.layoutTestController) {
     23        layoutTestController.notifyDone();
     24    }
     25}
     26
     27var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/simple");
     28debug("Created a socket to '" + ws.URL + "'; readyState " + ws.readyState + ".");
     29
     30ws.onopen = function()
     31{
     32    debug("Connected; readyState " + ws.readyState);
     33};
     34
     35ws.onmessage = function(messageEvent)
     36{
     37    debug("Received: '" + messageEvent.data + "'; readyState " + ws.readyState);
     38};
     39
     40ws.onclose = function()
     41{
     42    debug("Closed; readyState " + ws.readyState + ".");
     43    endTest();
     44};
     45
     46function timeOutCallback()
     47{
     48    debug("Timed out in state: " + ws.readyState);
     49    endTest();
     50}
     51
     52var timeoutID = setTimeout(timeOutCallback, 3000);
     53
     54var successfullyParsed = true;
     55</script>
    1256</body>
    1357</html>
  • trunk/LayoutTests/http/tests/websocket/tests/sub-protocol-with-space.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/sub-protocol-with-space.js"></script>
     11<script type="text/javascript">
     12description("Test WebSocket handshake success with sub protocol contains space.");
     13
     14if (window.layoutTestController)
     15    layoutTestController.waitUntilDone();
     16
     17var protocol;
     18
     19function endTest()
     20{
     21    shouldBe("protocol", '"sub protocol"');
     22    clearTimeout(timeoutID);
     23    isSuccessfullyParsed();
     24    if (window.layoutTestController)
     25        layoutTestController.notifyDone();
     26}
     27
     28var url = "ws://localhost:8880/websocket/tests/protocol-test?protocol=sub%20protocol";
     29var ws = new WebSocket(url, "sub protocol");
     30
     31ws.onopen = function()
     32{
     33    debug("Connected");
     34};
     35
     36ws.onmessage = function (messageEvent)
     37{
     38    protocol = messageEvent.data;
     39    ws.close();
     40};
     41
     42ws.onclose = function()
     43{
     44    endTest();
     45};
     46
     47function timeOutCallback()
     48{
     49    debug("Timed out in state: " + ws.readyState);
     50    endTest();
     51}
     52
     53var timeoutID = setTimeout(timeOutCallback, 3000);
     54
     55var successfullyParsed = true;
     56</script>
    1257</body>
    1358</html>
  • trunk/LayoutTests/http/tests/websocket/tests/sub-protocol.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/sub-protocol.js"></script>
     11<script type="text/javascript">
     12description("Test WebSocket handshake success with sub protocol.");
     13
     14if (window.layoutTestController)
     15    layoutTestController.waitUntilDone();
     16
     17var protocol;
     18
     19function endTest()
     20{
     21    shouldBe("protocol", '"sub-protocol"');
     22    clearTimeout(timeoutID);
     23    isSuccessfullyParsed();
     24    if (window.layoutTestController)
     25        layoutTestController.notifyDone();
     26}
     27
     28var url = "ws://localhost:8880/websocket/tests/protocol-test?protocol=sub-protocol";
     29var ws = new WebSocket(url, "sub-protocol");
     30
     31ws.onopen = function()
     32{
     33    debug("Connected");
     34};
     35
     36ws.onmessage = function (messageEvent)
     37{
     38    protocol = messageEvent.data;
     39    ws.close();
     40};
     41
     42ws.onclose = function()
     43{
     44    endTest();
     45};
     46
     47function timeOutCallback()
     48{
     49    debug("Timed out in state: " + ws.readyState);
     50    endTest();
     51}
     52
     53var timeoutID = setTimeout(timeOutCallback, 3000);
     54
     55var successfullyParsed = true;
     56</script>
    1257</body>
    1358</html>
  • trunk/LayoutTests/http/tests/websocket/tests/unicode.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/unicode.js"></script>
     11<script type="text/javascript">
     12description("Web Socket unicode message test");
     13
     14if (window.layoutTestController)
     15    layoutTestController.waitUntilDone();
     16
     17function endTest()
     18{
     19    isSuccessfullyParsed();
     20    clearTimeout(timeoutID);
     21    if (window.layoutTestController)
     22        layoutTestController.notifyDone();
     23}
     24
     25var ws = new WebSocket("ws://localhost:8880/websocket/tests/unicode");
     26
     27// Hello in Japanese
     28var UNICODE_HELLO = "\u3053\u3093\u306b\u3061\u306f";
     29// Goodbye in Japanese
     30var UNICODE_GOODBYE = "\u3055\u3088\u3046\u306a\u3089";
     31
     32// data needs to be global to be accessbile from shouldBe().
     33var data = "";
     34
     35ws.onopen = function()
     36{
     37    debug("Connected.");
     38    debug("Send UNICODE_HELLO.");
     39    ws.send(UNICODE_HELLO);
     40};
     41
     42ws.onmessage = function(messageEvent)
     43{
     44    // The server should send back Goodbye if it receives Hello.
     45    data = messageEvent.data;
     46    shouldBe("data", "UNICODE_GOODBYE");
     47};
     48
     49ws.onclose = function()
     50{
     51    debug("Closed.");
     52    endTest();
     53};
     54
     55function timeOutCallback()
     56{
     57    testFailed("Timed out in state: " + ws.readyState);
     58    endTest();
     59}
     60
     61var timeoutID = setTimeout(timeOutCallback, 3000);
     62
     63var successfullyParsed = true;
     64</script>
    1265</body>
    1366</html>
  • trunk/LayoutTests/http/tests/websocket/tests/url-no-trailing-slash.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/url-no-trailing-slash.js"></script>
     11<script type="text/javascript">
     12description("URL that doesn't have trailing slash should not emit empty Request-URI.");
     13
     14if (window.layoutTestController)
     15    layoutTestController.waitUntilDone();
     16
     17var url = "ws://127.0.0.1:8880";
     18var handshake_success = false;
     19var ws_location;
     20
     21function endTest()
     22{
     23    shouldBeTrue("handshake_success");
     24    shouldBe("ws_location", '"ws://127.0.0.1:8880/"');
     25    isSuccessfullyParsed();
     26    if (window.layoutTestController)
     27        layoutTestController.notifyDone();
     28}
     29
     30
     31var ws = new WebSocket(url);
     32ws.onopen = function () {
     33    debug("WebSocket is open");
     34    handshake_success = true;
     35};
     36ws.onmessage = function (evt) {
     37    ws_location = evt.data;
     38    debug("received:" + ws_location);
     39    ws.close();
     40};
     41ws.onclose = function () {
     42    debug("WebSocket is closed");
     43    endTest();
     44};
     45
     46var successfullyParsed = true;
     47</script>
    1248</body>
    1349</html>
  • trunk/LayoutTests/http/tests/websocket/tests/url-parsing.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/url-parsing.js"></script>
     11<script type="text/javascript">
     12description("Test WebSocket URL parsing.");
     13
     14// Invalid url will fail to be parsed.
     15shouldThrow('new WebSocket("ws://javascript:a")');
     16
     17// Can't use relative URLs - because spec says so, and because the scheme is different anyway.
     18shouldThrow('new WebSocket("/applet")');
     19
     20// Non ws URL is not allowed.
     21shouldThrow('new WebSocket("javascript:a")');
     22
     23// UA is allowed to block access to some ports, which we do.
     24shouldThrow('new WebSocket("ws://127.0.0.1:25/")');
     25
     26// Resolve the url string using the resolve a Web address algorithm.
     27// Use 127.0.0.1:8880 and existing ws handler to make sure we don't receive unexpected response (so no console message appears)
     28shouldBe('(new WebSocket("ws://127.0.0.1:8880/a/../websocket/tests/simple")).URL', '"ws://127.0.0.1:8880/websocket/tests/simple"');
     29shouldBe('(new WebSocket("ws://127.0.0.1:8880/websocket/tests/simple?")).URL', '"ws://127.0.0.1:8880/websocket/tests/simple?"');
     30shouldBe('(new WebSocket("ws://127.0.0.1:8880/websocket/tests/simple?k=v")).URL', '"ws://127.0.0.1:8880/websocket/tests/simple?k=v"');
     31
     32// draft-hixie-thewebsocketprotocol-60 says If /url/ has a <fragment>
     33// component, then fail the parsing Web Socket URLs, so throw a SYNTAX_ERR
     34// exception.
     35shouldThrow('new WebSocket("ws://127.0.0.1/path#")');
     36shouldThrow('new WebSocket("ws://127.0.0.1/path#fragment")');
     37
     38var successfullyParsed = true;
     39isSuccessfullyParsed();
     40</script>
    1241</body>
    1342</html>
  • trunk/LayoutTests/http/tests/websocket/tests/url-with-credential.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/url-with-credential.js"></script>
     11<script type="text/javascript">
     12description("Make sure handshake with URL with credentail info success.");
     13
     14if (window.layoutTestController)
     15    layoutTestController.waitUntilDone();
     16
     17var url = "ws://user:pass@127.0.0.1:8880/websocket/tests/echo-location";
     18var handshake_success = false;
     19var ws_location;
     20
     21function endTest()
     22{
     23    clearTimeout(timeoutID);
     24    shouldBeTrue("handshake_success");
     25    shouldBe("ws_location", '"ws://127.0.0.1:8880/websocket/tests/echo-location"');
     26    isSuccessfullyParsed();
     27    if (window.layoutTestController)
     28        layoutTestController.notifyDone();
     29}
     30
     31debug("url=" + url);
     32var ws = new WebSocket(url);
     33ws.onopen = function () {
     34    debug("WebSocket is open");
     35    handshake_success = true;
     36};
     37ws.onmessage = function (evt) {
     38    ws_location = evt.data;
     39    debug("received:" + ws_location);
     40    ws.close();
     41};
     42ws.onclose = function () {
     43    debug("WebSocket is closed");
     44    endTest();
     45};
     46var timeoutID = setTimeout("endTest()", 2000);
     47
     48var successfullyParsed = true;
     49</script>
    1250</body>
    1351</html>
  • trunk/LayoutTests/http/tests/websocket/tests/url-with-empty-query.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/url-with-empty-query.js"></script>
     11<script type="text/javascript">
     12description("Make sure handshake with URL with empty query components success.");
     13
     14if (window.layoutTestController)
     15    layoutTestController.waitUntilDone();
     16
     17var url = "ws://127.0.0.1:8880/websocket/tests/echo-location?";
     18var handshake_success = false;
     19var ws_location;
     20
     21function endTest()
     22{
     23    clearTimeout(timeoutID);
     24    shouldBeTrue("handshake_success");
     25    shouldBe("ws_location", "url");
     26    isSuccessfullyParsed();
     27    if (window.layoutTestController)
     28        layoutTestController.notifyDone();
     29}
     30
     31debug("url=" + url);
     32var ws = new WebSocket(url);
     33ws.onopen = function () {
     34    debug("WebSocket is open");
     35    handshake_success = true;
     36};
     37ws.onmessage = function (evt) {
     38    ws_location = evt.data;
     39    debug("received:" + ws_location);
     40    ws.close();
     41};
     42ws.onclose = function () {
     43    debug("WebSocket is closed");
     44    endTest();
     45};
     46var timeoutID = setTimeout("endTest()", 2000);
     47
     48var successfullyParsed = true;
     49</script>
    1250</body>
    1351</html>
  • trunk/LayoutTests/http/tests/websocket/tests/url-with-query-for-no-query.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/url-with-query-for-no-query.js"></script>
     11<script type="text/javascript">
     12description("Make sure handshake with URL with query components fails against server that doesn't support query component.");
     13
     14if (window.layoutTestController)
     15    layoutTestController.waitUntilDone();
     16
     17var url = "ws://127.0.0.1:8880/websocket/tests/no-query?";
     18var handshake_success = false;
     19var ws_location;
     20
     21function endTest()
     22{
     23    clearTimeout(timeoutID);
     24    shouldBeFalse("handshake_success");
     25    shouldBeUndefined("ws_location");
     26    isSuccessfullyParsed();
     27    if (window.layoutTestController)
     28        layoutTestController.notifyDone();
     29}
     30
     31debug("url=" + url);
     32var ws = new WebSocket(url);
     33ws.onopen = function () {
     34    debug("WebSocket is open");
     35    handshake_success = true;
     36};
     37ws.onmessge = function (evt) {
     38    ws_location = evt.data;
     39    debug("received:" + ws_location);
     40    ws.close();
     41};
     42ws.onclose = function () {
     43    debug("WebSocket is closed");
     44    endTest();
     45};
     46var timeoutID = setTimeout("endTest()", 2000);
     47
     48var successfullyParsed = true;
     49</script>
    1250</body>
    1351</html>
  • trunk/LayoutTests/http/tests/websocket/tests/url-with-query.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/url-with-query.js"></script>
     11<script type="text/javascript">
     12description("Make sure handshake with URL with query components success.");
     13
     14if (window.layoutTestController)
     15    layoutTestController.waitUntilDone();
     16
     17var url = "ws://127.0.0.1:8880/websocket/tests/echo-location?q=v";
     18var handshake_success = false;
     19var ws_location;
     20
     21function endTest()
     22{
     23    clearTimeout(timeoutID);
     24    shouldBeTrue("handshake_success");
     25    shouldBe("ws_location", "url");
     26    isSuccessfullyParsed();
     27    if (window.layoutTestController)
     28        layoutTestController.notifyDone();
     29}
     30
     31debug("url=" + url);
     32var ws = new WebSocket(url);
     33ws.onopen = function () {
     34    debug("WebSocket is open");
     35    handshake_success = true;
     36};
     37ws.onmessage = function (evt) {
     38    ws_location = evt.data;
     39    debug("received:" + ws_location);
     40    ws.close();
     41};
     42ws.onclose = function () {
     43    debug("WebSocket is closed");
     44    endTest();
     45};
     46var timeoutID = setTimeout("endTest()", 2000);
     47
     48var successfullyParsed = true;
     49</script>
    1250</body>
    1351</html>
  • trunk/LayoutTests/http/tests/websocket/tests/websocket-event-target.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/websocket-event-target.js"></script>
     11<script type="text/javascript">
     12description("Make sure WebSocket object acts as EventTarget.");
     13
     14var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/simple");
     15ws.close(); // That is not a test with a WebSocket server, prevent logging an error to console.
     16var open_event_handled = false;
     17var message_event_handled = false;
     18var close_event_handled = false;
     19function openListener() {
     20    open_event_handled = true;
     21};
     22function messageListener() {
     23    message_event_handled = true;
     24};
     25function closeListener() {
     26    close_event_handled = true;
     27}
     28ws.addEventListener('open', openListener, false);
     29ws.addEventListener('message', messageListener, false);
     30ws.addEventListener('close', closeListener, false);
     31
     32shouldBe("open_event_handled", "false");
     33shouldBe("message_event_handled", "false");
     34shouldBe("close_event_handled", "false");
     35
     36var evt = document.createEvent("Events");
     37evt.initEvent("open", true, false);
     38ws.dispatchEvent(evt);
     39shouldBe("open_event_handled", "true");
     40
     41open_event_handled = false;
     42ws.removeEventListener('open', openListener);
     43ws.dispatchEvent(evt);
     44shouldBe("open_event_handled", "false");
     45
     46evt = document.createEvent("MessageEvent");
     47evt.initEvent("message", true, false);
     48ws.dispatchEvent(evt);
     49shouldBe("message_event_handled", "true");
     50
     51message_event_handled = false;
     52ws.removeEventListener('message', messageListener);
     53ws.dispatchEvent(evt);
     54shouldBe("message_event_handled", "false");
     55
     56evt = document.createEvent("Events");
     57evt.initEvent("close", true, false);
     58ws.dispatchEvent(evt);
     59shouldBe("close_event_handled", "true");
     60
     61close_event_handled = false;
     62ws.removeEventListener('close', closeListener);
     63ws.dispatchEvent(evt);
     64shouldBe("close_event_handled", "false");
     65
     66var successfullyParsed = true;
     67isSuccessfullyParsed();
     68</script>
    1269</body>
    1370</html>
  • trunk/LayoutTests/http/tests/websocket/tests/websocket-protocol-ignored.html

    r68914 r90100  
    99<div id="description"></div>
    1010<div id="console"></div>
    11 <script src="script-tests/websocket-protocol-ignored.js"></script>
     11<script type="text/javascript">
     12description("Test WebSocket handshake success without protocol and ignore WebSocket-Protocol from server.");
     13
     14if (window.layoutTestController)
     15    layoutTestController.waitUntilDone();
     16
     17var protocol;
     18
     19function endTest()
     20{
     21    shouldBe("protocol", '"sub-protocol"');
     22    clearTimeout(timeoutID);
     23    isSuccessfullyParsed();
     24    if (window.layoutTestController)
     25        layoutTestController.notifyDone();
     26}
     27
     28var url = "ws://localhost:8880/websocket/tests/protocol-test?protocol=sub-protocol";
     29var ws = new WebSocket(url);
     30
     31ws.onopen = function()
     32{
     33    debug("Connected");
     34};
     35
     36ws.onmessage = function (messageEvent)
     37{
     38    protocol = messageEvent.data;
     39    ws.close();
     40};
     41
     42ws.onclose = function()
     43{
     44    endTest();
     45};
     46
     47function timeOutCallback()
     48{
     49    debug("Timed out in state: " + ws.readyState);
     50    endTest();
     51}
     52
     53var timeoutID = setTimeout(timeOutCallback, 3000);
     54
     55var successfullyParsed = true;
     56</script>
    1257</body>
    1358</html>
Note: See TracChangeset for help on using the changeset viewer.