Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / netwerk / test / unit / test_websocket_offline.js
blobef8fe0e8dc767d6d75e5c230650387f06811481c
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 "use strict";
6 // checking to make sure we don't hang as per 1038304
7 // offline so url isn't impt
8 var url = "ws://localhost";
9 var chan;
10 var offlineStatus;
12 var listener = {
13 onAcknowledge() {},
14 onBinaryMessageAvailable() {},
15 onMessageAvailable() {},
16 onServerClose() {},
17 onStart() {
18 // onStart is not called when a connection fails
19 Assert.ok(false);
21 onStop(aContext, aStatusCode) {
22 Assert.notEqual(aStatusCode, Cr.NS_OK);
23 Services.io.offline = offlineStatus;
24 do_test_finished();
28 function run_test() {
29 offlineStatus = Services.io.offline;
30 Services.io.offline = true;
32 try {
33 chan = Cc["@mozilla.org/network/protocol;1?name=ws"].createInstance(
34 Ci.nsIWebSocketChannel
36 chan.initLoadInfo(
37 null, // aLoadingNode
38 Services.scriptSecurityManager.getSystemPrincipal(),
39 null, // aTriggeringPrincipal
40 Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_SEC_CONTEXT_IS_NULL,
41 Ci.nsIContentPolicy.TYPE_WEBSOCKET
44 var uri = Services.io.newURI(url);
45 chan.asyncOpen(uri, url, {}, 0, listener, null);
46 do_test_pending();
47 } catch (x) {
48 dump("throwing " + x);
49 do_throw(x);