Bug 504553 - patch 4 - WebSockes in Workers: tests, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 10 Oct 2014 17:58:12 +0100
changeset 209872 8edaa32e2278b7f1a8835a4f85d9a7b0d4eb5b53
parent 209871 f23cea600bd00a7cce19a0a4bd178e8e4c9f81d1
child 209873 e289b886cccb57acfb9717b6d46126f6ded12948
push id27628
push userkwierso@gmail.com
push dateSat, 11 Oct 2014 02:00:16 +0000
treeherdermozilla-central@f74ad36bb97b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs504553
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 504553 - patch 4 - WebSockes in Workers: tests, r=smaug
dom/workers/test/mochitest.ini
dom/workers/test/test_websocket.html
dom/workers/test/test_websocket_basic.html
dom/workers/test/test_websocket_loadgroup.html
dom/workers/test/websocket_basic_worker.js
dom/workers/test/websocket_loadgroup_worker.js
dom/workers/test/websocket_worker.js
--- a/dom/workers/test/mochitest.ini
+++ b/dom/workers/test/mochitest.ini
@@ -62,16 +62,19 @@ support-files =
   threadErrors_worker3.js
   threadErrors_worker4.js
   threadTimeouts_worker.js
   throwingOnerror_worker.js
   timeoutTracing_worker.js
   transferable_worker.js
   urlApi_worker.js
   url_worker.js
+  websocket_basic_worker.js
+  websocket_loadgroup_worker.js
+  websocket_worker.js
   workersDisabled_worker.js
   xhr2_worker.js
   xhrAbort_worker.js
   xhr_implicit_cancel_worker.js
   xhr_worker.js
   xhr_headers_worker.js
   xhr_headers_server.sjs
   url_exceptions_worker.js
@@ -170,9 +173,15 @@ skip-if = buildapp == 'b2g' || e10s
 [test_xhr_system.html]
 skip-if = buildapp == 'b2g' || e10s
 [test_xhr_system.js]
 [test_xhr_timeout.html]
 skip-if = (os == "win") || (os == "mac") || toolkit == 'android' || e10s #bug 798220
 [test_url_exceptions.html]
 [test_urlSearchParams.html]
 [test_bug1060621.html]
+[test_websocket_basic.html]
+skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #bug 982828
+[test_websocket.html]
+skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #bug 982828
+[test_websocket_loadgroup.html]
+skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #bug 982828
 [test_bug1062920.html]
new file mode 100644
--- /dev/null
+++ b/dom/workers/test/test_websocket.html
@@ -0,0 +1,46 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for WebSocket object in workers</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<p id="display"></p>
+<pre id="feedback"></pre>
+<script class="testbody" type="text/javascript">
+
+  var worker = new Worker("websocket_worker.js");
+
+  worker.onmessage = function(event) {
+    is(event.target, worker, "event.target should be a worker!");
+
+    if (event.data.type == 'finish') {
+      info("All done!");
+      SimpleTest.finish();
+    } else if (event.data.type == 'status') {
+      ok(event.data.status, event.data.msg);
+    } else if (event.data.type == 'feedback') {
+      info(event.data.msg);
+      document.getElementById('feedback').innerHTML += event.data.msg + "\n";
+    }
+  };
+
+  worker.onerror = function(event) {
+    is(event.target, worker);
+    info("error!");
+    ok(false, "Worker had an error: " + event.data);
+    SimpleTest.finish();
+  };
+
+  worker.postMessage('foobar');
+  SimpleTest.waitForExplicitFinish();
+
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/workers/test/test_websocket_basic.html
@@ -0,0 +1,57 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for WebSocket object in workers</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+<pre id="test"></pre>
+<script class="testbody" type="text/javascript">
+
+  var worker = new Worker("websocket_basic_worker.js");
+
+  worker.onmessage = function(event) {
+    is(event.target, worker);
+
+    if (event.data.type == 'finish') {
+      runTest();
+    } else if (event.data.type == 'status') {
+      ok(event.data.status, event.data.msg);
+    }
+  };
+
+  worker.onerror = function(event) {
+    is(event.target, worker);
+    ok(false, "Worker had an error: " + event.data);
+    SimpleTest.finish();
+  };
+
+  var tests = [
+    function() { worker.postMessage(0); },
+    function() { worker.postMessage(1); }
+  ];
+
+  function runTest() {
+    if (!tests.length) {
+      SimpleTest.finish();
+      return;
+    }
+
+    var test = tests.shift();
+    test();
+  }
+
+  runTest();
+  SimpleTest.waitForExplicitFinish();
+
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/workers/test/test_websocket_loadgroup.html
@@ -0,0 +1,61 @@
+<!--
+  Any copyright is dedicated to the Public Domain.
+  http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for WebSocket object in workers</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+<pre id="test"></pre>
+<script class="testbody" type="text/javascript">
+
+  var worker = new Worker("websocket_loadgroup_worker.js");
+
+  var stopped = false;
+  worker.onmessage = function(e) {
+    if (e.data == 'opened') {
+      stopped = true;
+      window.stop();
+    } else if (e.data == 'closed') {
+      ok(stopped, "Good!");
+      stopped = false;
+      runTest();
+    } else {
+      ok(false, "An error has been received");
+    }
+  };
+
+  worker.onerror = function(event) {
+    is(event.target, worker);
+    ok(false, "Worker had an error: " + event.data);
+    SimpleTest.finish();
+  };
+
+  var tests = [
+    function() { worker.postMessage(0); },
+    function() { worker.postMessage(1); }
+  ];
+
+  function runTest() {
+    if (!tests.length) {
+      SimpleTest.finish();
+      return;
+    }
+
+    var test = tests.shift();
+    test();
+  }
+
+  runTest();
+  SimpleTest.waitForExplicitFinish();
+
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/workers/test/websocket_basic_worker.js
@@ -0,0 +1,39 @@
+onmessage = function(event) {
+  if (event.data != 0) {
+    var worker = new Worker('websocket_basic_worker.js');
+    worker.onmessage = function(event) {
+      postMessage(event.data);
+    }
+
+    worker.postMessage(event.data - 1);
+    return;
+  }
+
+  status = false;
+  try {
+    if ((WebSocket instanceof Object)) {
+      status = true;
+    }
+  } catch(e) {
+  }
+
+  postMessage({type: 'status', status: status, msg: 'WebSocket object:' + WebSocket});
+
+  var ws = new WebSocket("ws://mochi.test:8888/tests/content/base/test/file_websocket_hello");
+  ws.onopen = function(e) {
+    postMessage({type: 'status', status: true, msg: 'OnOpen called' });
+    ws.send("data");
+  }
+
+  ws.onclose = function(e) {}
+
+  ws.onerror = function(e) {
+    postMessage({type: 'status', status: false, msg: 'onerror called!'});
+  }
+
+  ws.onmessage = function(e) {
+    postMessage({type: 'status', status: e.data == 'Hello world!', msg: 'Wrong data'});
+    ws.close();
+    postMessage({type: 'finish' });
+  }
+}
new file mode 100644
--- /dev/null
+++ b/dom/workers/test/websocket_loadgroup_worker.js
@@ -0,0 +1,24 @@
+onmessage = function(event) {
+  if (event.data != 0) {
+    var worker = new Worker('websocket_loadgroup_worker.js');
+    worker.onmessage = function(event) {
+      postMessage(event.data);
+    }
+
+    worker.postMessage(event.data - 1);
+    return;
+  }
+
+  var ws = new WebSocket("ws://mochi.test:8888/tests/content/base/test/file_websocket_hello");
+  ws.onopen = function(e) {
+    postMessage('opened');
+  }
+
+  ws.onclose = function(e) {
+    postMessage('closed');
+  }
+
+  ws.onerror = function(e) {
+    postMessage('error');
+  }
+}
copy from content/base/test/test_websocket.html
copy to dom/workers/test/websocket_worker.js
--- a/content/base/test/test_websocket.html
+++ b/dom/workers/test/websocket_worker.js
@@ -1,26 +1,8 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"></meta>
-  <title>WebSocket test</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body onload="testWebSocket()">
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=472529">Mozilla Bug </a>
-<p id="display">
-  <input id="fileList" type="file"></input>
-</p>
-<div id="content">
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
 /*
  * tests:
  *  1. client tries to connect to a http scheme location;
  *  2. assure serialization of the connections;
  *  3. client tries to connect to an non-existent ws server;
  *  4. client tries to connect using a relative url;
  *  5. client uses an invalid protocol value;
  *  6. counter and encoding check;
@@ -31,24 +13,24 @@
  * 10. client sends a message before the ws connection is established;
  * 11. a simple hello echo;
  * 12. client sends a message containing unpaired surrogates
  * 13. server sends an invalid message;
  * 14. server sends the close frame, it doesn't close the tcp connection and
  *     it keeps sending normal ws messages;
  * 15. server closes the tcp connection, but it doesn't send the close frame;
  * 16. client calls close() and tries to send a message;
- * 17. see bug 572975 - all event listeners set
+ * 17. see bug 572975 - all event listeners set - Only in the main thread tests (requires forcegc)
  * 18. client tries to connect to an http resource;
  * 19. server closes the tcp connection before establishing the ws connection;
- * 20. see bug 572975 - only on error and onclose event listeners set
+ * 20. see bug 572975 - only on error and onclose event listeners set - Only in the main thread worker tests (requires forcegc)
  * 21. see bug 572975 - same as test 17, but delete strong event listeners when
- *     receiving the message event;
- * 22. server takes too long to establish the ws connection;
- * 23. should detect WebSocket on window object;
+ *     receiving the message event - Only in the main thread worker tests (requires forcegc and window)
+ * 22. server takes too long to establish the ws connection - Only in the main thread worker tests (requires SpecialPower object)
+ * 23. should detect WebSocket on window object - Only in the main thread worker tests (requires window object)
  * 24. server rejects sub-protocol string
  * 25. ctor with valid empty sub-protocol array
  * 26. ctor with invalid sub-protocol array containing 1 empty element
  * 27. ctor with invalid sub-protocol array containing an empty element in list
  * 28. ctor using valid 1 element sub-protocol array
  * 29. ctor using all valid 5 element sub-protocol array
  * 30. ctor using valid 1 element sub-protocol array with element server will
  *     reject
@@ -61,22 +43,37 @@
  * 36. negative test for sending out of range close code
  * 37. negative test for too long of a close reason
  * 38. ensure extensions attribute is defined
  * 39. a basic wss:// connectivity test
  * 40. negative test for wss:// with no cert
  * 41. HSTS
  * 42. non-char utf-8 sequences
  * 43. Test setting binaryType attribute
- * 44. Test sending/receving binary ArrayBuffer 
- * 45. Test sending/receving binary Blob 
+ * 44. Test sending/receiving binary ArrayBuffer
+ * 45. Test sending/receiving binary Blob  - Only in the main thread worker tests (requires SpecialPower object)
  * 46. Test that we don't dispatch incoming msgs once in CLOSING state
  * 47. Make sure onerror/onclose aren't called during close()
  */
 
+function feedback(msg)
+{
+    postMessage({type: 'feedback', msg: msg });
+}
+
+function ok(status, msg)
+{
+  postMessage({type: 'status', status: !!status, msg: msg});
+}
+
+function is(a, b, msg)
+{
+  ok(a == b, msg);
+}
+
 var first_test = 1;
 var last_test = 47;
 
 
 // Set this to >1 if you want to run the suite multiple times to probe for
 // random orange failures. 
 // - Do NOT check into mozilla-central with a value != 1.
 // - Too large a count will wind up causing tryserver to timeout the test (which
@@ -143,17 +140,22 @@ function CreateTestWS(ws_location, ws_pr
       ws = new WebSocket(ws_location);
     } else {
       ws = new WebSocket(ws_location, ws_protocol);
     }
 
 
     ws._testNumber = current_test;
     ws._receivedCloseEvent = false;
-    ok(true, "Created websocket for test " + ws._testNumber +"\n");
+    var infoString = "Created websocket for test " + ws._testNumber;
+    if (undefined != ws_protocol) {
+      infoString += " " + ws_protocol;
+    }
+    infoString += "\n";
+    ok(true, infoString);
 
     ws.onerror = function(e)
     {
       ok(false, "onerror called on test " + e.target._testNumber + "!");
     };
     ws.addEventListener("close", function(e)
     {
       ws._receivedCloseEvent = true;
@@ -167,39 +169,29 @@ function CreateTestWS(ws_location, ws_pr
       current_test++;
     }
   }
 
   all_ws.push(ws);
   return ws;
 }
 
-function forcegc()
-{
-  SpecialPowers.forceGC();
-  SpecialPowers.gc();
-  setTimeout(function()
-  {
-    SpecialPowers.gc();
-  }, 0);
-}
-
 function doTest(number)
 {
   if (number > last_test) {
     ranAllTests = true;
     maybeFinished();
     return;
   }
 
   if (testsuite_iteration > 1) {
-    $("feedback").innerHTML = "test suite iteration #" + testsuite_iteration + " of " + testsuite_iterations + 
-      ": executing test: " + number + " of " + last_test + " tests.";
+    feedback("Test suite iteration #" + testsuite_iteration + " of " + testsuite_iterations +
+      ": Executing test: " + number + " of " + last_test + " tests.");
   } else {
-    $("feedback").innerHTML = "executing test: " + number + " of " + last_test + " tests.";
+    feedback("Executing test: " + number + " of " + last_test + " tests.");
   }
 
   var fnTest = eval("test" + number + "");
 
   if (test_started[number] === true) {
     doTest(number + 1);
     return;
   }
@@ -585,78 +577,20 @@ function test16()
     ok(false, "shouldn't send message after calling close()");
   }
 
   ws.onerror = function()
   {
   }
   ws.onclose = function()
   {
-    doTest(17);
+    doTest(18);
   }
 }
 
-var status_test17 = "not started";
-
-var waitTest17 = false;
-
-var test17func = function()
-{
-  waitTest17 = true;
-
-  var local_ws = new WebSocket("ws://sub1.test2.example.org/tests/content/base/test/file_websocket", "test-17");
-  local_ws._testNumber = "local17";
-  local_ws._testNumber = current_test++;
-
-  status_test17 = "started";
-
-  local_ws.onopen = function(e)
-  {
-    status_test17 = "opened";
-    e.target.send("client data");
-    forcegc();
-  };
-
-  local_ws.onerror = function()
-  {
-    ok(false, "onerror called on test " + e.target._testNumber + "!");
-  };
-
-  local_ws.onmessage = function(e)
-  {
-    ok(e.data == "server data", "Bad message in test-17");
-    status_test17 = "got message";
-    forcegc();
-  };
-
-  local_ws.onclose = function(e)
-  {
-    ok(status_test17 == "got message", "Didn't got message in test-17!");
-    shouldCloseCleanly(e);
-    status_test17 = "closed";
-    forcegc();
-    waitTest17 = false;
-    maybeFinished();
-  };
-
-  local_ws = null;
-  window._test17 = null;
-  forcegc();
-
-// do this in the background
-  doTest(18);
-  forcegc();
-}
-
-function test17()
-{
-  window._test17 = test17func;
-  window._test17();
-}
-
 // The tests that expects that their websockets neither open nor close MUST
 // be in the end of the tests, i.e. HERE, in order to prevent blocking the other
 // tests.
 
 function test18()
 {
   var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket_http_resource.txt");
   ws.onopen = shouldNotOpen;
@@ -671,138 +605,18 @@ function test18()
 function test19()
 {
   var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-19");
   ws.onopen = shouldNotOpen;
   ws.onerror = ignoreError;
   ws.onclose = function(e)
   {
     shouldCloseNotCleanly(e);
-    doTest(20);
-  };
-}
-
-var waitTest20 = false;
-
-var test20func = function()
-{
-  waitTest20 = true;
-
-  var local_ws = new WebSocket("ws://sub1.test1.example.org/tests/content/base/test/file_websocket", "test-20");
-  local_ws._testNumber = "local20";
-  local_ws._testNumber = current_test++;
-
-  local_ws.onerror = function()
-  {
-    ok(false, "onerror called on test " + e.target._testNumber + "!");
-  };
-
-  local_ws.onclose = function(e)
-  {
-    ok(true, "test 20 closed despite gc");
-    waitTest20 = false;
-    maybeFinished();
-  };
-
-  local_ws = null;
-  window._test20 = null;
-  forcegc();
-
-  // let test run in the background
-  doTest(21);
-}
-
-function test20()
-{
-  window._test20 = test20func;
-  window._test20();
-}
-
-var waitTest21 = false;
-
-test21func = function()
-{
-  waitTest21 = true;
-
-  var local_ws = new WebSocket("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-21");
-  local_ws._testNumber = current_test++;
-  var received_message = false;
-
-  local_ws.onopen = function(e)
-  {
-    e.target.send("client data");
-    forcegc();
-    e.target.onopen = null;
-    forcegc();
+    doTest(24);
   };
-
-  local_ws.onerror = function()
-  {
-    ok(false, "onerror called on test " + e.target._testNumber + "!");
-  };
-
-  local_ws.onmessage = function(e)
-  {
-    ok(e.data == "server data", "Bad message in test-21");
-    received_message = true;
-    forcegc();
-    e.target.onmessage = null;
-    forcegc();
-  };
-
-  local_ws.onclose = function(e)
-  {
-    shouldCloseCleanly(e);
-    ok(received_message, "close transitioned through onmessage");
-    waitTest21 = false;
-    maybeFinished();
-  };
-
-  local_ws = null;
-  window._test21 = null;
-  forcegc();
-
-  doTest(22);
-
-}
-
-function test21()
-{
-  window._test21 = test21func;
-  window._test21();
-}
-
-var waitTest22 = false;
-
-function test22()
-{
-  waitTest22 = true;
-
-  const pref_open = "network.websocket.timeout.open";
-  SpecialPowers.setIntPref(pref_open, 5);
-
-  var ws = CreateTestWS("ws://sub2.test2.example.org/tests/content/base/test/file_websocket", "test-22");
-  ws.onopen = shouldNotOpen;
-  ws.onerror = ignoreError;
-  ws.onclose = function(e)
-  {
-    shouldCloseNotCleanly(e);
-    waitTest22 = false;
-    maybeFinished();
-  };
-
-  SpecialPowers.clearUserPref(pref_open);
-  doTest(23);
-}
-
-function test23()
-{
-  current_test++;
-  is(true, "WebSocket" in window, "WebSocket should be available on window object");
-  doTest(24);
 }
 
 function test24()
 {
   var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-does-not-exist");
   ws.onopen = shouldNotOpen;
   ws.onclose = function(e)
   {
@@ -1172,81 +986,18 @@ function test40()
     ok(false, "test 40 open");
     ws.close();
   };
 
   ws.onclose = function(e)
   {
     ok(true, "test 40 close");
     ok(status_test40 == "started", "test 40 did not open"); 
-    doTest(41);
-  };
-}
-
-function test41()
-{
-  var ws = CreateTestWS("ws://example.com/tests/content/base/test/file_websocket", "test-41a", 1);
-
-  ws.onopen = function(e)
-  {
-    ok(true, "test 41a open");
-    ok(ws.url == "ws://example.com/tests/content/base/test/file_websocket",
-       "test 41a initial ws should not be redirected");
-    ws.close();
+    doTest(42);
   };
-
-  ws.onclose = function(e)
-  {
-    ok(true, "test 41a close");
-
-    // establish a hsts policy for example.com
-    var wsb = CreateTestWS("wss://example.com/tests/content/base/test/file_websocket", "test-41b", 1);
-    wsb.onopen = function(e)
-    {
-      ok(true, "test 41b open");
-      wsb.close();
-    }
-
-    wsb.onclose = function(e)
-    {
-      ok(true, "test 41b close");
-
-      // try ws:// again, it should be done over wss:// now due to hsts
-      var wsc = CreateTestWS("ws://example.com/tests/content/base/test/file_websocket", "test-41c");
-   
-      wsc.onopen = function(e)
-      {
-        ok(true, "test 41c open");
-        ok(wsc.url == "wss://example.com/tests/content/base/test/file_websocket",
-           "test 41c ws should be redirected by hsts to wss");
-        wsc.close();
-      }
-
-      wsc.onclose = function(e)
-      {
-        ok(true, "test 41c close");
-
-        // clean up the STS state
-        const Cc = SpecialPowers.Cc;
-        const Ci = SpecialPowers.Ci;
-        var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
-        var thehost = ios.newURI("http://example.com", null, null);
-        var sss = Cc["@mozilla.org/ssservice;1"].getService(Ci.nsISiteSecurityService);
-        var loadContext = SpecialPowers.wrap(window)
-                          .QueryInterface(Ci.nsIInterfaceRequestor)
-                          .getInterface(Ci.nsIWebNavigation)
-                          .QueryInterface(Ci.nsILoadContext);
-        var flags = 0;
-        if (loadContext.usePrivateBrowsing)
-          flags |= Ci.nsISocketProvider.NO_PERMANENT_STORAGE;
-        sss.removeState(Ci.nsISiteSecurityService.HEADER_HSTS, thehost, flags);
-        doTest(42);
-       }
-     }
-  }
 }
 
 function test42()
 {
 // test some utf-8 non-characters. They should be allowed in the
 // websockets context. Test via round trip echo.
   var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-42");
   var data = ["U+FFFE \ufffe",
@@ -1327,88 +1078,17 @@ function test44()
     var view = new Uint8Array(e.data);
     ok(view.length == 2 && view[0] == 0 && view[1] ==4, "testing Reply arraybuffer" );
     ws.close();
   }
   ws.onclose = function(e)
   {
     ok(ws.readyState == 3, "onclose bad readyState in test-44!");
     shouldCloseCleanly(e);
-    doTest(45);
-  }
-}
-
-function createDOMFile(fileName, fileData)
-{
-  // create File in profile dir 
-  var dirSvc = SpecialPowers.Cc["@mozilla.org/file/directory_service;1"]
-                         .getService(SpecialPowers.Ci.nsIProperties);
-  var testFile = dirSvc.get("ProfD", SpecialPowers.Ci.nsIFile);
-  testFile.append(fileName);
-  var outStream = SpecialPowers.Cc["@mozilla.org/network/file-output-stream;1"]
-                            .createInstance(SpecialPowers.Ci.nsIFileOutputStream);
-  outStream.init(testFile, 0x02 | 0x08 | 0x20, 0666, 0);
-  outStream.write(fileData, fileData.length);
-  outStream.close();
-
-  // Set filename into DOM <input> field, as if selected by user 
-  var fileList = document.getElementById('fileList');
-  SpecialPowers.wrap(fileList).value = testFile.path;
-
-  // return JS File object, aka Blob
-  return fileList.files[0];
-}
-
-function test45()
-{
-  var blobFile = createDOMFile("testBlobFile", "flob");
-
-  var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-45");
-  ok(ws.readyState == 0, "bad readyState in test-45!");
-
-//  ws.binaryType = "blob";  // Don't need to specify: blob is the default
-
-  ws.onopen = function()
-  {
-    ok(ws.readyState == 1, "open bad readyState in test-45!");
-    ws.send(blobFile);
-  }
-
-  var test45blob;
-
-  ws.onmessage = function(e)
-  {
-    test45blob = e.data;
-    ok(test45blob instanceof Blob, "We should be receiving a Blob");
-
-    ws.close();
-  }
-
-  ws.onclose = function(e)
-  {
-    ok(ws.readyState == 3, "onclose bad readyState in test-45!");
-    shouldCloseCleanly(e);
-
-    // check blob contents
-    var reader = new FileReader();
-    reader.onload = function(event)
-    {
-      ok(reader.result == "flob", "response should be 'flob': got '" 
-         + reader.result + "'");
-    };
-    reader.onerror = function(event)
-    {
-      testFailed("Failed to read blob: error code = " + reader.error.code);
-    };
-    reader.onloadend = function(event)
-    {
-      doTest(46);
-    };
-
-    reader.readAsBinaryString(test45blob);
+    doTest(46);
   }
 }
 
 function test46()
 {
   var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-46");
   ok(ws.readyState == 0, "create bad readyState in test-46!");
   ws.onopen = function()
@@ -1466,47 +1146,33 @@ function test47()
 
 var ranAllTests = false;
 
 function maybeFinished()
 {
   if (!ranAllTests)
     return;
 
-  if (waitTest2Part1 || waitTest2Part2 || waitTest9 || waitTest10 ||
-      waitTest17 || waitTest20 || waitTest21 || waitTest22)
+  if (waitTest2Part1 || waitTest2Part2 || waitTest9 || waitTest10)
     return;
 
   for (i = 0; i < all_ws.length; ++i) {
     if (all_ws[i] != shouldNotReceiveCloseEvent &&
         !all_ws[i]._receivedCloseEvent) {
       ok(false, "didn't called close on test " + all_ws[i]._testNumber + "!");
     }
   }
 
   if (testsuite_iteration++ < testsuite_iterations) {
     // play it again, Sam...
     ok(1, "starting testsuite iteration " + testsuite_iteration);
     test_started = new Array(last_test);
     doTest(current_test = first_test);
   } else {
     // all done
-    SimpleTest.finish();
+    postMessage({type: 'finish' });
   }
 }
 
-function testWebSocket ()
+onmessage = function()
 {
   doTest(first_test);
 }
-
-SimpleTest.requestFlakyTimeout("The web socket tests are really fragile, but avoiding timeouts might be hard, since it's testing stuff on the network. " +
-                               "Expect all sorts of flakiness in this test...");
-SimpleTest.waitForExplicitFinish();
-
-</script>
-</pre>
-
-<div id="feedback">
-</div>
-
-</body>
-</html>