mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 28da91dbe6c5 (bug 1233843) for failures in test_bug203271.js in various test suites
This commit is contained in:
parent
536679873f
commit
1bd1042511
@ -2,7 +2,7 @@
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=761228
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpServer.identity.primaryPort;
|
||||
@ -26,8 +26,16 @@ function make_uri(url) {
|
||||
}
|
||||
|
||||
function make_channel(url) {
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true})
|
||||
.QueryInterface(Ci.nsIHttpChannel);
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2(url,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER).QueryInterface(Ci.nsIHttpChannel);
|
||||
return chan;
|
||||
}
|
||||
|
||||
function clearCache() {
|
||||
@ -68,7 +76,7 @@ function consume304(request, buffer) {
|
||||
// a 304 response (i.e. when the server shouldn't have sent us one).
|
||||
add_test(function test_unexpected_304() {
|
||||
var chan = make_channel(baseURI + unexpected304);
|
||||
chan.asyncOpen2(new ChannelListener(consume304, null));
|
||||
chan.asyncOpen(new ChannelListener(consume304, null), null);
|
||||
});
|
||||
|
||||
// Test that we can cope with a 304 response that was (erroneously) stored in
|
||||
@ -90,6 +98,6 @@ add_test(function test_304_stored_in_cache() {
|
||||
chan.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
chan.setRequestHeader("If-None-Match", '"foo"', false);
|
||||
|
||||
chan.asyncOpen2(new ChannelListener(consume304, null));
|
||||
chan.asyncOpen(new ChannelListener(consume304, null), null);
|
||||
});
|
||||
});
|
||||
|
@ -5,7 +5,7 @@
|
||||
// take precedence
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Netutil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
const BUGID = "203271";
|
||||
|
||||
var httpserver = new HttpServer();
|
||||
@ -95,10 +95,17 @@ function logit(i, data, ctx) {
|
||||
}
|
||||
|
||||
function setupChannel(suffix, value) {
|
||||
var chan = NetUtil.newChannel({
|
||||
uri: "http://localhost:" + httpserver.identity.primaryPort + suffix,
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2("http://localhost:" +
|
||||
httpserver.identity.primaryPort + suffix,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
var httpChan = chan.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
httpChan.requestMethod = "GET"; // default value, just being paranoid...
|
||||
httpChan.setRequestHeader("x-request", value, false);
|
||||
@ -107,7 +114,7 @@ function setupChannel(suffix, value) {
|
||||
|
||||
function triggerNextTest() {
|
||||
var channel = setupChannel(tests[index].url, tests[index].server);
|
||||
channel.asyncOpen2(new ChannelListener(checkValueAndTrigger, channel));
|
||||
channel.asyncOpen(new ChannelListener(checkValueAndTrigger, channel), null);
|
||||
}
|
||||
|
||||
function checkValueAndTrigger(request, data, ctx) {
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
var httpserver;
|
||||
|
||||
@ -14,16 +13,23 @@ function inChildProcess() {
|
||||
.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
}
|
||||
function makeChan(path) {
|
||||
return NetUtil.newChannel({
|
||||
uri: "http://localhost:" + httpserver.identity.primaryPort + "/" + path,
|
||||
loadUsingSystemPrincipal: true
|
||||
}).QueryInterface(Ci.nsIHttpChannel);
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2("http://localhost:" + httpserver.identity.primaryPort + "/" + path,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER)
|
||||
.QueryInterface(Ci.nsIHttpChannel);
|
||||
return chan;
|
||||
}
|
||||
|
||||
function setup_chan(path, isPrivate, callback) {
|
||||
var chan = makeChan(path);
|
||||
chan.QueryInterface(Ci.nsIPrivateBrowsingChannel).setPrivate(isPrivate);
|
||||
chan.asyncOpen2(new ChannelListener(callback));
|
||||
chan.asyncOpen(new ChannelListener(callback), null);
|
||||
}
|
||||
|
||||
function set_cookie(value, callback) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
@ -34,9 +34,12 @@ function run_test() {
|
||||
// This file does not exist.
|
||||
let file = do_get_file("_NOT_EXIST_.txt", true);
|
||||
do_check_false(file.exists());
|
||||
let channel = NetUtil.newChannel({
|
||||
uri: ios.newFileURI(file),
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
channel.asyncOpen2(listener);
|
||||
|
||||
let channel = ios.newChannelFromURI2(ios.newFileURI(file),
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
channel.asyncOpen(listener, null);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const BUGID = "369787";
|
||||
var server = null;
|
||||
@ -55,12 +55,21 @@ function run_test() {
|
||||
server.start(-1);
|
||||
|
||||
// make request
|
||||
channel = NetUtil.newChannel({
|
||||
uri: "http://localhost:" + server.identity.primaryPort + "/bug" + BUGID,
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
channel =
|
||||
Components.classes["@mozilla.org/network/io-service;1"].
|
||||
getService(Components.interfaces.nsIIOService).
|
||||
newChannel2("http://localhost:" +
|
||||
server.identity.primaryPort + "/bug" + BUGID,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
|
||||
channel.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
channel.asyncOpen2(new TestListener());
|
||||
channel.asyncOpen(new TestListener(), null);
|
||||
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
@ -45,11 +45,17 @@ function test1() {
|
||||
createInstance(Ci.nsIUnicharStreamLoader);
|
||||
f.init(listener);
|
||||
|
||||
var chan = NetUtil.newChannel({
|
||||
uri: "data:text/plain,",
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
chan.asyncOpen2(f);
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var chan = ios.newChannel2("data:text/plain,",
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
chan.asyncOpen(f, null);
|
||||
do_test_pending();
|
||||
}
|
||||
|
||||
@ -59,12 +65,18 @@ function test2() {
|
||||
createInstance(Ci.nsIUnicharStreamLoader);
|
||||
f.init(listener);
|
||||
|
||||
var chan = NetUtil.newChannel({
|
||||
uri: "http://localhost:0/",
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var chan = ios.newChannel2("http://localhost:0/",
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
listener.expect_failure = true;
|
||||
chan.asyncOpen2(f);
|
||||
chan.asyncOpen(f, null);
|
||||
do_test_pending();
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
// definition of "explicit expiration time" being used here.
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var httpserver = new HttpServer();
|
||||
var index = 0;
|
||||
@ -57,10 +57,16 @@ function logit(i, data) {
|
||||
}
|
||||
|
||||
function setupChannel(suffix, value) {
|
||||
var chan = NetUtil.newChannel({
|
||||
uri: "http://localhost:" + httpserver.identity.primaryPort + suffix,
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2("http://localhost:" + httpserver.identity.primaryPort + suffix,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
var httpChan = chan.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
httpChan.requestMethod = "GET";
|
||||
httpChan.setRequestHeader("x-request", value, false);
|
||||
@ -69,7 +75,7 @@ function setupChannel(suffix, value) {
|
||||
|
||||
function triggerNextTest() {
|
||||
var channel = setupChannel(tests[index].url, tests[index].server);
|
||||
channel.asyncOpen2(new ChannelListener(checkValueAndTrigger, null));
|
||||
channel.asyncOpen(new ChannelListener(checkValueAndTrigger, null),null);
|
||||
}
|
||||
|
||||
function checkValueAndTrigger(request, data, ctx) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
a simple HTTP case */
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// This C-L is significantly larger than (U)INT32_MAX, to make sure we do
|
||||
// 64-bit properly.
|
||||
@ -47,11 +47,18 @@ function hugeContentLength(metadata, response) {
|
||||
}
|
||||
|
||||
function test_hugeContentLength() {
|
||||
var chan = NetUtil.newChannel({
|
||||
uri: "http://localhost:" + httpServer.identity.primaryPort + "/",
|
||||
loadUsingSystemPrincipal: true
|
||||
}).QueryInterface(Ci.nsIHttpChannel);
|
||||
chan.asyncOpen2(listener);
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2("http://localhost:" +
|
||||
httpServer.identity.primaryPort + "/",
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER)
|
||||
.QueryInterface(Ci.nsIHttpChannel);
|
||||
chan.asyncOpen(listener, null);
|
||||
}
|
||||
|
||||
add_test(test_hugeContentLength);
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var httpServer = null;
|
||||
var path = "/bug699001";
|
||||
@ -9,7 +9,16 @@ XPCOMUtils.defineLazyGetter(this, "URI", function() {
|
||||
});
|
||||
|
||||
function make_channel(url) {
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
}
|
||||
|
||||
var fetched;
|
||||
@ -108,7 +117,7 @@ function nextTest()
|
||||
// Give the old channel a chance to close the cache entry first.
|
||||
// XXX This is actually a race condition that might be considered a bug...
|
||||
do_execute_soon(function() {
|
||||
chan.asyncOpen2(new ChannelListener(checkAndShiftTest, null));
|
||||
chan.asyncOpen(new ChannelListener(checkAndShiftTest, null), null);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var httpserv;
|
||||
|
||||
@ -28,10 +28,19 @@ function clearCreds()
|
||||
}
|
||||
|
||||
function makeChan() {
|
||||
return NetUtil.newChannel({
|
||||
uri: "http://localhost:" + httpserv.identity.primaryPort + "/",
|
||||
loadUsingSystemPrincipal: true
|
||||
}).QueryInterface(Ci.nsIHttpChannel);
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2("http://localhost:" +
|
||||
httpserv.identity.primaryPort + "/",
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER)
|
||||
.QueryInterface(Ci.nsIHttpChannel);
|
||||
return chan;
|
||||
}
|
||||
|
||||
// Array of handlers that are called one by one in response to expected requests
|
||||
@ -139,46 +148,46 @@ var tests = [
|
||||
// Test 1: 200 (cacheable)
|
||||
function() {
|
||||
var ch = makeChan();
|
||||
ch.asyncOpen2(new ChannelListener(function(req, body) {
|
||||
ch.asyncOpen(new ChannelListener(function(req, body) {
|
||||
do_check_eq(body, "Response body 1");
|
||||
sync_and_run_next_test();
|
||||
}, null, CL_NOT_FROM_CACHE));
|
||||
}, null, CL_NOT_FROM_CACHE), null);
|
||||
},
|
||||
|
||||
// Test 2: 401 and 200 + new content
|
||||
function() {
|
||||
var ch = makeChan();
|
||||
ch.asyncOpen2(new ChannelListener(function(req, body) {
|
||||
ch.asyncOpen(new ChannelListener(function(req, body) {
|
||||
do_check_eq(body, "Response body 2");
|
||||
sync_and_run_next_test();
|
||||
}, null, CL_NOT_FROM_CACHE));
|
||||
}, null, CL_NOT_FROM_CACHE), null);
|
||||
},
|
||||
|
||||
// Test 3: 401 and 304
|
||||
function() {
|
||||
var ch = makeChan();
|
||||
ch.asyncOpen2(new ChannelListener(function(req, body) {
|
||||
ch.asyncOpen(new ChannelListener(function(req, body) {
|
||||
do_check_eq(body, "Response body 2");
|
||||
sync_and_run_next_test();
|
||||
}, null, CL_FROM_CACHE));
|
||||
}, null, CL_FROM_CACHE), null);
|
||||
},
|
||||
|
||||
// Test 4: 407 and 200 + new content
|
||||
function() {
|
||||
var ch = makeChan();
|
||||
ch.asyncOpen2(new ChannelListener(function(req, body) {
|
||||
ch.asyncOpen(new ChannelListener(function(req, body) {
|
||||
do_check_eq(body, "Response body 3");
|
||||
sync_and_run_next_test();
|
||||
}, null, CL_NOT_FROM_CACHE));
|
||||
}, null, CL_NOT_FROM_CACHE), null);
|
||||
},
|
||||
|
||||
// Test 5: 407 and 304
|
||||
function() {
|
||||
var ch = makeChan();
|
||||
ch.asyncOpen2(new ChannelListener(function(req, body) {
|
||||
ch.asyncOpen(new ChannelListener(function(req, body) {
|
||||
do_check_eq(body, "Response body 3");
|
||||
sync_and_run_next_test();
|
||||
}, null, CL_FROM_CACHE));
|
||||
}, null, CL_FROM_CACHE), null);
|
||||
},
|
||||
|
||||
// End of test run
|
||||
|
@ -2,7 +2,7 @@
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=760955
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var httpServer = null;
|
||||
const testFileName = "test_nsHttpChannel_CacheForOfflineUse-no-store";
|
||||
@ -20,8 +20,17 @@ var cacheUpdateObserver = null;
|
||||
var appCache = null;
|
||||
|
||||
function make_channel_for_offline_use(url, callback, ctx) {
|
||||
var chan = NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
|
||||
var cacheService = Components.classes["@mozilla.org/network/application-cache-service;1"].
|
||||
getService(Components.interfaces.nsIApplicationCacheService);
|
||||
appCache = cacheService.getApplicationCache(cacheClientID);
|
||||
@ -53,7 +62,7 @@ function checkNormal(request, buffer)
|
||||
}
|
||||
add_test(function test_normal() {
|
||||
var chan = make_channel_for_offline_use(baseURI + normalEntry);
|
||||
chan.asyncOpen2(new ChannelListener(checkNormal, chan));
|
||||
chan.asyncOpen(new ChannelListener(checkNormal, chan), null);
|
||||
});
|
||||
|
||||
// An HTTP channel for updating the offline cache should fail when it gets a
|
||||
@ -73,7 +82,8 @@ function checkNoStore(request, buffer)
|
||||
add_test(function test_noStore() {
|
||||
var chan = make_channel_for_offline_use(baseURI + noStoreEntry);
|
||||
// The no-store should cause the channel to fail to load.
|
||||
chan.asyncOpen2(new ChannelListener(checkNoStore, chan, CL_EXPECT_FAILURE));
|
||||
chan.asyncOpen(new ChannelListener(checkNoStore, chan, CL_EXPECT_FAILURE),
|
||||
null);
|
||||
});
|
||||
|
||||
function run_test()
|
||||
|
@ -1,6 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
@ -20,8 +19,15 @@ function cached_handler(metadata, response) {
|
||||
}
|
||||
|
||||
function makeChan(url, appId, inBrowser) {
|
||||
var chan = NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true})
|
||||
.QueryInterface(Ci.nsIHttpChannel);
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2(url,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER).QueryInterface(Ci.nsIHttpChannel);
|
||||
chan.notificationCallbacks = {
|
||||
appId: appId,
|
||||
isInBrowserElement: inBrowser,
|
||||
@ -47,7 +53,7 @@ function run_all_tests() {
|
||||
for (let test of firstTests) {
|
||||
handlers_called = 0;
|
||||
var chan = makeChan(URL, test[0], test[1]);
|
||||
chan.asyncOpen2(new ChannelListener(doneFirstLoad, test[2]));
|
||||
chan.asyncOpen(new ChannelListener(doneFirstLoad, test[2]), null);
|
||||
yield undefined;
|
||||
}
|
||||
|
||||
@ -65,7 +71,7 @@ function run_all_tests() {
|
||||
for (let test of secondTests) {
|
||||
handlers_called = 0;
|
||||
var chan = makeChan(URL, test[0], test[1]);
|
||||
chan.asyncOpen2(new ChannelListener(doneFirstLoad, test[2]));
|
||||
chan.asyncOpen(new ChannelListener(doneFirstLoad, test[2]), null);
|
||||
yield undefined;
|
||||
}
|
||||
|
||||
@ -75,7 +81,7 @@ function run_all_tests() {
|
||||
for (let test of thirdTests) {
|
||||
handlers_called = 0;
|
||||
var chan = makeChan(URL, test[0], test[1]);
|
||||
chan.asyncOpen2(new ChannelListener(doneFirstLoad, test[2]));
|
||||
chan.asyncOpen(new ChannelListener(doneFirstLoad, test[2]), null);
|
||||
yield undefined;
|
||||
}
|
||||
}
|
||||
@ -99,7 +105,7 @@ function doneFirstLoad(req, buffer, expected) {
|
||||
// Load it again, make sure it hits the cache
|
||||
var nc = req.notificationCallbacks.getInterface(Ci.nsILoadContext);
|
||||
var chan = makeChan(URL, nc.appId, nc.isInBrowserElement);
|
||||
chan.asyncOpen2(new ChannelListener(doneSecondLoad, expected));
|
||||
chan.asyncOpen(new ChannelListener(doneSecondLoad, expected), null);
|
||||
}
|
||||
|
||||
function doneSecondLoad(req, buffer, expected) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
// This file tests channel event sinks (bug 315598 et al)
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpserv.identity.primaryPort;
|
||||
@ -97,7 +97,19 @@ var listener = {
|
||||
};
|
||||
|
||||
function makeChan(url) {
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
var chan = ios.newChannel2(url,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER)
|
||||
.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
|
||||
return chan;
|
||||
}
|
||||
|
||||
var httpserv = null;
|
||||
@ -115,7 +127,7 @@ function run_test() {
|
||||
var chan = makeChan(URL + "/redirect");
|
||||
chan.notificationCallbacks = eventsink;
|
||||
|
||||
chan.asyncOpen2(listener);
|
||||
chan.asyncOpen(listener, null);
|
||||
|
||||
do_test_pending();
|
||||
}
|
||||
@ -141,7 +153,7 @@ function run_test_continued() {
|
||||
}
|
||||
|
||||
listener._iteration++;
|
||||
chan.asyncOpen2(listener);
|
||||
chan.asyncOpen(listener, null);
|
||||
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
var httpServer = null;
|
||||
// Need to randomize, because apparently no one clears our cache
|
||||
@ -11,9 +10,19 @@ XPCOMUtils.defineLazyGetter(this, "randomURI", function() {
|
||||
});
|
||||
|
||||
var cacheUpdateObserver = null;
|
||||
var systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
|
||||
|
||||
function make_channel(url, callback, ctx) {
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
systemPrincipal,
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
}
|
||||
|
||||
function make_uri(url) {
|
||||
@ -99,7 +108,7 @@ function run_test()
|
||||
chan.notificationCallbacks = new ChannelEventSink(ES_ABORT_REDIRECT);
|
||||
var chanac = chan.QueryInterface(Ci.nsIApplicationCacheChannel);
|
||||
chanac.chooseApplicationCache = true;
|
||||
chan.asyncOpen2(new ChannelListener(finish_test, null, CL_EXPECT_FAILURE));
|
||||
chan.asyncOpen(new ChannelListener(finish_test, null, CL_EXPECT_FAILURE), null);
|
||||
});
|
||||
}}
|
||||
|
||||
@ -114,7 +123,7 @@ function run_test()
|
||||
httpServer.identity.primaryPort + "/manifest"),
|
||||
make_uri("http://localhost:" +
|
||||
httpServer.identity.primaryPort + "/masterEntry"),
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
systemPrincipal,
|
||||
null);
|
||||
|
||||
do_test_pending();
|
||||
|
@ -7,7 +7,7 @@
|
||||
"use strict";
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var baseURL;
|
||||
const kResponseTimeoutPref = "network.http.response.timeout";
|
||||
@ -56,10 +56,19 @@ function testTimeout(timeoutEnabled, expectResponse) {
|
||||
prefService.setIntPref(kResponseTimeoutPref, 0);
|
||||
}
|
||||
|
||||
var chan = NetUtil.newChannel({uri: baseURL, loadUsingSystemPrincipal: true})
|
||||
.QueryInterface(Ci.nsIHttpChannel);
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2(baseURL,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER)
|
||||
.QueryInterface(Ci.nsIHttpChannel);
|
||||
var listener = new TimeoutListener(expectResponse);
|
||||
chan.asyncOpen2(listener);
|
||||
chan.asyncOpen(listener, null);
|
||||
}
|
||||
|
||||
function testTimeoutEnabled() {
|
||||
|
@ -5,7 +5,7 @@
|
||||
// expected: see comments that start with ENSURE_CALLED_BEFORE_CONNECT:
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
@ -73,8 +73,15 @@ var listener = {
|
||||
};
|
||||
|
||||
function makeChan(url) {
|
||||
var chan = NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true})
|
||||
.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
var chan = ios.newChannel2(url,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER)
|
||||
.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
|
||||
// ENSURE_CALLED_BEFORE_CONNECT: set original value
|
||||
var uri = ios.newURI("http://site1.com", null, null);
|
||||
@ -93,7 +100,7 @@ function execute_test() {
|
||||
obs = obs.QueryInterface(Components.interfaces.nsIObserverService);
|
||||
obs.addObserver(observer, "http-on-modify-request", false);
|
||||
|
||||
chan.asyncOpen2(listener);
|
||||
chan.asyncOpen(listener, null);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
var httpserver = new HttpServer();
|
||||
|
||||
var ios;
|
||||
@ -69,11 +69,18 @@ XPCOMUtils.defineLazyGetter(this, "listener_2", function() {
|
||||
|
||||
onStopRequest: function test_onStopR(request, ctx, status) {
|
||||
var channel = request.QueryInterface(Ci.nsIHttpChannel);
|
||||
var chan = NetUtil.newChannel({
|
||||
uri: "http://localhost:" + httpserver.identity.primaryPort + "/test1",
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
chan.asyncOpen2(listener_3);
|
||||
|
||||
var chan = ios.newChannel2("http://localhost:" +
|
||||
httpserver.identity.primaryPort +
|
||||
"/test1",
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
chan.asyncOpen(listener_3, null);
|
||||
}
|
||||
};
|
||||
});
|
||||
@ -100,12 +107,19 @@ XPCOMUtils.defineLazyGetter(this, "listener_1", function() {
|
||||
},
|
||||
|
||||
onStopRequest: function test_onStopR(request, ctx, status) {
|
||||
var channel = request.QueryInterface(Ci.nsIHttpChannel);
|
||||
var chan = NetUtil.newChannel({
|
||||
uri: "http://localhost:" + httpserver.identity.primaryPort + "/test1",
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
chan.asyncOpen2(listener_2);
|
||||
var channel = request.QueryInterface(Ci.nsIHttpChannel);
|
||||
|
||||
var chan = ios.newChannel2("http://localhost:" +
|
||||
httpserver.identity.primaryPort +
|
||||
"/test1",
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
chan.asyncOpen(listener_2, null);
|
||||
}
|
||||
};
|
||||
});
|
||||
@ -121,11 +135,16 @@ function run_test() {
|
||||
httpserver.start(-1);
|
||||
|
||||
var port = httpserver.identity.primaryPort;
|
||||
var chan = NetUtil.newChannel({
|
||||
uri: "http://localhost:" + port + "/test1",
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
chan.asyncOpen2(listener_1);
|
||||
|
||||
var chan = ios.newChannel2("http://localhost:" + port + "/test1",
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
chan.asyncOpen(listener_1, null);
|
||||
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var httpserver = null;
|
||||
|
||||
@ -8,7 +8,16 @@ XPCOMUtils.defineLazyGetter(this, "uri", function() {
|
||||
});
|
||||
|
||||
function make_channel(url) {
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
}
|
||||
|
||||
var multipartBody = "--boundary\r\n"+
|
||||
@ -30,6 +39,19 @@ var multipartBody = "--boundary\r\n"+
|
||||
"\r\n"+
|
||||
"--boundary--";
|
||||
|
||||
function make_channel(url) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
}
|
||||
|
||||
function contentHandler(metadata, response)
|
||||
{
|
||||
response.setHeader("Content-Type", 'multipart/byteranges; boundary="boundary"');
|
||||
@ -108,6 +130,6 @@ function run_test()
|
||||
null);
|
||||
|
||||
var chan = make_channel(uri);
|
||||
chan.asyncOpen2(conv, null);
|
||||
chan.asyncOpen(conv, null);
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -6,8 +6,6 @@
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "uri", function() {
|
||||
return "http://localhost:" + httpserver.identity.primaryPort;
|
||||
@ -20,7 +18,16 @@ const nsIBinaryInputStream = Components.Constructor("@mozilla.org/binaryinputstr
|
||||
|
||||
|
||||
function make_channel(url) {
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
}
|
||||
|
||||
function Listener(callback) {
|
||||
@ -224,10 +231,10 @@ function run_test()
|
||||
function test_channel_with_bad_signature() {
|
||||
var channel = make_channel(uri+"/package_with_bad_signature!//index.html");
|
||||
channel.notificationCallbacks = new LoadContextCallback(1024, false, false, false);
|
||||
channel.asyncOpen2(new Listener(function(l) {
|
||||
channel.asyncOpen(new Listener(function(l) {
|
||||
do_check_true(l.gotFileNotFound);
|
||||
run_next_test();
|
||||
}));
|
||||
}), null);
|
||||
}
|
||||
|
||||
function test_channel_with_bad_signature_from_trusted_origin() {
|
||||
@ -238,20 +245,20 @@ function test_channel_with_bad_signature_from_trusted_origin() {
|
||||
Services.prefs.setComplexValue(pref, Ci.nsISupportsString, origin);
|
||||
var channel = make_channel(uri+"/package_with_bad_signature!//index.html");
|
||||
channel.notificationCallbacks = new LoadContextCallback(1024, false, false, false);
|
||||
channel.asyncOpen2(new Listener(function(l) {
|
||||
channel.asyncOpen(new Listener(function(l) {
|
||||
do_check_true(l.gotStopRequestOK);
|
||||
Services.prefs.clearUserPref(pref);
|
||||
run_next_test();
|
||||
}));
|
||||
}), null);
|
||||
}
|
||||
|
||||
function test_channel_with_good_signature() {
|
||||
var channel = make_channel(uri+"/package_with_good_signature!//index.html");
|
||||
channel.notificationCallbacks = new LoadContextCallback(1024, false, false, false);
|
||||
channel.asyncOpen2(new Listener(function(l) {
|
||||
channel.asyncOpen(new Listener(function(l) {
|
||||
do_check_true(l.gotStopRequestOK);
|
||||
run_next_test();
|
||||
}));
|
||||
}), null);
|
||||
}
|
||||
|
||||
function test_channel(aNullNotificationCallbacks) {
|
||||
@ -261,13 +268,13 @@ function test_channel(aNullNotificationCallbacks) {
|
||||
channel.notificationCallbacks = new LoadContextCallback(1024, false, false, false);
|
||||
}
|
||||
|
||||
channel.asyncOpen2(new Listener(function(l) {
|
||||
channel.asyncOpen(new Listener(function(l) {
|
||||
// XXX: no content length available for this resource
|
||||
//do_check_true(channel.contentLength > 0);
|
||||
do_check_true(l.gotStartRequest);
|
||||
do_check_true(l.gotStopRequestOK);
|
||||
run_next_test();
|
||||
}));
|
||||
}), null);
|
||||
}
|
||||
|
||||
function test_channel_no_notificationCallbacks() {
|
||||
@ -277,7 +284,7 @@ function test_channel_no_notificationCallbacks() {
|
||||
function test_channel_uris() {
|
||||
// A `!//` in the query or ref should not be handled as a packaged app resource
|
||||
var channel = make_channel(uri+"/regular?bla!//bla#bla!//bla");
|
||||
channel.asyncOpen2(new ChannelListener(check_regular_response, null));
|
||||
channel.asyncOpen(new ChannelListener(check_regular_response, null), null);
|
||||
}
|
||||
|
||||
function check_regular_response(request, buffer) {
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpServer.identity.primaryPort;
|
||||
@ -18,7 +17,16 @@ XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
var httpServer = null;
|
||||
|
||||
function make_channel(url, callback, ctx) {
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
}
|
||||
|
||||
// Have 2kb response (8 * 2 ^ 8)
|
||||
@ -63,7 +71,7 @@ function run_test()
|
||||
httpServer.start(-1);
|
||||
|
||||
var chan = make_channel(URL + "/content");
|
||||
chan.asyncOpen2(new ChannelListener(firstTimeThrough, null, CL_IGNORE_CL));
|
||||
chan.asyncOpen(new ChannelListener(firstTimeThrough, null, CL_IGNORE_CL), null);
|
||||
do_test_pending();
|
||||
}
|
||||
|
||||
@ -73,7 +81,7 @@ function firstTimeThrough(request, buffer)
|
||||
Services.prefs.setIntPref("browser.cache.disk.max_entry_size", 1);
|
||||
|
||||
var chan = make_channel(URL + "/content");
|
||||
chan.asyncOpen2(new ChannelListener(finish_test, null));
|
||||
chan.asyncOpen(new ChannelListener(finish_test, null), null);
|
||||
}
|
||||
|
||||
function finish_test(request, buffer)
|
||||
|
@ -3,7 +3,7 @@
|
||||
//
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpserver.identity.primaryPort;
|
||||
@ -89,13 +89,21 @@ function run_test() {
|
||||
.setUploadStream(mime, "", mime.available());
|
||||
channel.requestMethod = "POST";
|
||||
channel.notificationCallbacks = listenerCallback;
|
||||
channel.asyncOpen2(new ChannelListener(checkRequest, channel));
|
||||
channel.asyncOpen(new ChannelListener(checkRequest, channel), null);
|
||||
do_test_pending();
|
||||
}
|
||||
|
||||
function setupChannel(path) {
|
||||
return NetUtil.newChannel({uri: URL + path, loadUsingSystemPrincipal: true})
|
||||
.QueryInterface(Ci.nsIHttpChannel);
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
return chan = ios.newChannel2(URL + path,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER)
|
||||
.QueryInterface(Ci.nsIHttpChannel);
|
||||
}
|
||||
|
||||
function serverHandler(metadata, response) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
//
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var httpserver = new HttpServer();
|
||||
var testpath = "/simple";
|
||||
@ -25,16 +25,23 @@ function run_test() {
|
||||
channel.QueryInterface(Ci.nsIPrivateBrowsingChannel);
|
||||
channel.setPrivate(true);
|
||||
|
||||
channel.asyncOpen2(new ChannelListener(checkRequest, channel));
|
||||
channel.asyncOpen(new ChannelListener(checkRequest, channel), null);
|
||||
|
||||
do_test_pending();
|
||||
}
|
||||
|
||||
function setupChannel(path) {
|
||||
return NetUtil.newChannel({
|
||||
uri: "http://localhost:" + httpserver.identity.primaryPort + path,
|
||||
loadUsingSystemPrincipal: true
|
||||
}).QueryInterface(Ci.nsIHttpChannel);
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
return chan = ios.newChannel2("http://localhost:" +
|
||||
httpserver.identity.primaryPort + path,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER)
|
||||
.QueryInterface(Ci.nsIHttpChannel);
|
||||
}
|
||||
|
||||
function serverHandler(metadata, response) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpserver.identity.primaryPort;
|
||||
@ -100,15 +100,21 @@ function run_test() {
|
||||
httpserver.registerPathHandler(testpath, serverHandler);
|
||||
httpserver.start(-1);
|
||||
var channel = setupChannel(testpath);
|
||||
channel.asyncOpen2(progressCallback);
|
||||
channel.asyncOpen(progressCallback, null);
|
||||
do_test_pending();
|
||||
}
|
||||
|
||||
function setupChannel(path) {
|
||||
var chan = NetUtil.newChannel({
|
||||
uri: URL + path,
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2(URL + path,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
chan.QueryInterface(Ci.nsIHttpChannel);
|
||||
chan.requestMethod = "GET";
|
||||
chan.notificationCallbacks = progressCallback;
|
||||
|
@ -1,10 +1,19 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var httpServer = null;
|
||||
|
||||
function make_channel(url, callback, ctx) {
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
}
|
||||
|
||||
const responseBody = "response body";
|
||||
@ -38,6 +47,6 @@ function run_test()
|
||||
|
||||
var chan = make_channel("http://localhost:" +
|
||||
httpServer.identity.primaryPort + "/content");
|
||||
chan.asyncOpen2(new ChannelListener(finish_test, null));
|
||||
chan.asyncOpen(new ChannelListener(finish_test, null), null);
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpServer.identity.primaryPort;
|
||||
@ -20,7 +20,16 @@ function inChildProcess() {
|
||||
}
|
||||
|
||||
function make_channel(url, callback, ctx) {
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
}
|
||||
|
||||
const redirectTargetBody = "response body";
|
||||
@ -46,6 +55,6 @@ function run_test()
|
||||
httpServer.start(-1);
|
||||
|
||||
var chan = make_channel(randomURI);
|
||||
chan.asyncOpen2(new ChannelListener(finish_test, null, 0));
|
||||
chan.asyncOpen(new ChannelListener(finish_test, null, 0), null);
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
/*
|
||||
* This xpcshell test checks whether we detect infinite HTTP redirect loops.
|
||||
@ -23,7 +23,16 @@ var emptyLoopPath = "/empty/";
|
||||
var emptyLoopURI = "http://localhost:" + PORT + emptyLoopPath;
|
||||
|
||||
function make_channel(url, callback, ctx) {
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
}
|
||||
|
||||
function fullLoopHandler(metadata, response)
|
||||
@ -56,7 +65,8 @@ function testFullLoop(request, buffer)
|
||||
do_check_eq(request.status, Components.results.NS_ERROR_REDIRECT_LOOP);
|
||||
|
||||
var chan = make_channel(relativeLoopURI);
|
||||
chan.asyncOpen2(new ChannelListener(testRelativeLoop, null, CL_EXPECT_FAILURE));
|
||||
chan.asyncOpen(new ChannelListener(testRelativeLoop, null, CL_EXPECT_FAILURE),
|
||||
null);
|
||||
}
|
||||
|
||||
function testRelativeLoop(request, buffer)
|
||||
@ -64,7 +74,8 @@ function testRelativeLoop(request, buffer)
|
||||
do_check_eq(request.status, Components.results.NS_ERROR_REDIRECT_LOOP);
|
||||
|
||||
var chan = make_channel(emptyLoopURI);
|
||||
chan.asyncOpen2(new ChannelListener(testEmptyLoop, null, CL_EXPECT_FAILURE));
|
||||
chan.asyncOpen(new ChannelListener(testEmptyLoop, null, CL_EXPECT_FAILURE),
|
||||
null);
|
||||
}
|
||||
|
||||
function testEmptyLoop(request, buffer)
|
||||
@ -81,6 +92,7 @@ function run_test()
|
||||
httpServer.registerPathHandler(emptyLoopPath, emptyLoopHandler);
|
||||
|
||||
var chan = make_channel(fullLoopURI);
|
||||
chan.asyncOpen2(new ChannelListener(testFullLoop, null, CL_EXPECT_FAILURE));
|
||||
chan.asyncOpen(new ChannelListener(testFullLoop, null, CL_EXPECT_FAILURE),
|
||||
null);
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpServer.identity.primaryPort;
|
||||
@ -14,7 +14,16 @@ XPCOMUtils.defineLazyGetter(this, "randomURI", function() {
|
||||
});
|
||||
|
||||
function make_channel(url, callback, ctx) {
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
}
|
||||
|
||||
const responseBody = "response body";
|
||||
@ -35,7 +44,7 @@ function firstTimeThrough(request, buffer)
|
||||
{
|
||||
do_check_eq(buffer, responseBody);
|
||||
var chan = make_channel(randomURI);
|
||||
chan.asyncOpen2(new ChannelListener(finish_test, null));
|
||||
chan.asyncOpen(new ChannelListener(finish_test, null), null);
|
||||
}
|
||||
|
||||
function finish_test(request, buffer)
|
||||
@ -52,6 +61,6 @@ function run_test()
|
||||
httpServer.start(-1);
|
||||
|
||||
var chan = make_channel(randomURI);
|
||||
chan.asyncOpen2(new ChannelListener(firstTimeThrough, null));
|
||||
chan.asyncOpen(new ChannelListener(firstTimeThrough, null), null);
|
||||
do_test_pending();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "URL", function() {
|
||||
return "http://localhost:" + httpserver.identity.primaryPort;
|
||||
@ -77,15 +77,23 @@ var listener = {
|
||||
};
|
||||
|
||||
function makeChan(url) {
|
||||
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true})
|
||||
.QueryInterface(Ci.nsIHttpChannel);
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2(url,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER).QueryInterface(Ci.nsIHttpChannel);
|
||||
return chan;
|
||||
}
|
||||
|
||||
function next_test()
|
||||
{
|
||||
var chan = makeChan(URL + testpath);
|
||||
chan.QueryInterface(Ci.nsIRequest);
|
||||
chan.asyncOpen2(listener);
|
||||
chan.asyncOpen(listener, null);
|
||||
}
|
||||
|
||||
function run_test()
|
||||
|
@ -5,7 +5,7 @@
|
||||
// Note: sets Cc and Ci variables
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var httpserver = new HttpServer();
|
||||
var testpath = "/simple_plainText";
|
||||
@ -29,7 +29,7 @@ add_test(function test_plainText() {
|
||||
httpserver.start(-1);
|
||||
var channel = setupChannel(testpath);
|
||||
// ChannelListener defined in head_channels.js
|
||||
channel.asyncOpen2(new ChannelListener(checkRequest, channel));
|
||||
channel.asyncOpen(new ChannelListener(checkRequest, channel), null);
|
||||
do_test_pending();
|
||||
if (dbg) { print("============== test_plainText: out"); }
|
||||
});
|
||||
@ -40,18 +40,25 @@ add_test(function test_GZip() {
|
||||
httpserver.start(-1);
|
||||
var channel = setupChannel(testpathGZip);
|
||||
// ChannelListener defined in head_channels.js
|
||||
channel.asyncOpen2(new ChannelListener(checkRequest, channel,
|
||||
CL_EXPECT_GZIP));
|
||||
channel.asyncOpen(new ChannelListener(checkRequest, channel,
|
||||
CL_EXPECT_GZIP), null);
|
||||
do_test_pending();
|
||||
if (dbg) { print("============== test_GZip: out"); }
|
||||
});
|
||||
|
||||
|
||||
function setupChannel(path) {
|
||||
var chan = NetUtil.newChannel({
|
||||
uri: "http://localhost:" + httpserver.identity.primaryPort + path,
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
var chan = ios.newChannel2("http://localhost:" +
|
||||
httpserver.identity.primaryPort + path,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
chan.QueryInterface(Ci.nsIHttpChannel);
|
||||
chan.requestMethod = "GET";
|
||||
return chan;
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
var CC = Components.Constructor;
|
||||
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const ServerSocket = CC("@mozilla.org/network/server-socket;1",
|
||||
"nsIServerSocket",
|
||||
@ -88,11 +88,17 @@ add_test(function testNoConnectChannelCanceledEarly() {
|
||||
serv = new TestServer();
|
||||
|
||||
obs.addObserver(requestListenerObserver, "http-on-modify-request", false);
|
||||
var chan = NetUtil.newChannel({
|
||||
uri:"http://localhost:" + serv.port,
|
||||
loadUsingSystemPrincipal: true
|
||||
});
|
||||
chan.asyncOpen2(listener);
|
||||
|
||||
var chan = ios.newChannel2("http://localhost:" + serv.port,
|
||||
"",
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER);
|
||||
|
||||
chan.asyncOpen(listener, chan);
|
||||
|
||||
do_register_cleanup(function(){ serv.stop(); });
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user