Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / netwerk / test / unit / test_bug376660.js
blobdb9c4458e6e45c6431401ff469f05ea51d424dca
1 var Cc = Components.classes;
2 var Ci = Components.interfaces;
4 var listener = {
5 expect_failure: false,
6 QueryInterface: function listener_qi(iid) {
7 if (iid.equals(Ci.nsISupports) ||
8 iid.equals(Ci.nsIUnicharStreamLoaderObserver)) {
9 return this;
11 throw Components.results.NS_ERROR_NO_INTERFACE;
13 onDetermineCharset : function onDetermineCharset(loader, context,
14 data, length)
16 return "us-ascii";
18 onStreamComplete : function onStreamComplete (loader, context, status, data)
20 try {
21 if (this.expect_failure)
22 do_check_false(Components.isSuccessCode(status));
23 else
24 do_check_eq(status, Components.results.NS_OK);
25 do_check_eq(data, null);
26 do_check_neq(loader.channel, null);
27 tests[current_test++]();
28 } finally {
29 do_test_finished();
34 var current_test = 0;
35 var tests = [test1, test2, done];
37 function run_test() {
38 tests[current_test++]();
41 function test1() {
42 var f =
43 Cc["@mozilla.org/network/unichar-stream-loader;1"].
44 createInstance(Ci.nsIUnicharStreamLoader);
45 f.init(listener, 4096);
47 var ios = Components.classes["@mozilla.org/network/io-service;1"]
48 .getService(Components.interfaces.nsIIOService);
49 var chan = ios.newChannel("data:text/plain,", null, null);
50 chan.asyncOpen(f, null);
51 do_test_pending();
54 function test2() {
55 var f =
56 Cc["@mozilla.org/network/unichar-stream-loader;1"].
57 createInstance(Ci.nsIUnicharStreamLoader);
58 f.init(listener, 4096);
60 var ios = Components.classes["@mozilla.org/network/io-service;1"]
61 .getService(Components.interfaces.nsIIOService);
62 var chan = ios.newChannel("http://localhost:0/", null, null);
63 listener.expect_failure = true;
64 chan.asyncOpen(f, null);
65 do_test_pending();
68 function done() {