Bug 1162657 - Turn NewChannel deprecation warnings into assertions (r=sworkman,sicking,paolo)

This commit is contained in:
Christoph Kerschbaumer 2015-05-13 17:58:52 -07:00
parent 05649b2f53
commit ec48d470b8
3 changed files with 13 additions and 32 deletions

View File

@ -600,7 +600,7 @@ nsIOService::NewChannelFromURIWithLoadInfo(nsIURI* aURI,
NS_IMETHODIMP
nsIOService::NewChannelFromURI(nsIURI *aURI, nsIChannel **result)
{
NS_WARNING("Deprecated, use NewChannelFromURI2 providing loadInfo arguments!");
NS_ASSERTION(false, "Deprecated, use NewChannelFromURI2 providing loadInfo arguments!");
return NewChannelFromURI2(aURI,
nullptr, // aLoadingNode
nullptr, // aLoadingPrincipal
@ -764,10 +764,8 @@ nsIOService::NewChannelFromURIWithProxyFlags2(nsIURI* aURI,
loadingNode,
aSecurityFlags,
aContentPolicyType);
if (!loadInfo) {
return NS_ERROR_UNEXPECTED;
}
}
NS_ASSERTION(loadInfo, "Please pass security info when creating a channel");
return NewChannelFromURIWithProxyFlagsInternal(aURI,
aProxyURI,
aProxyFlags,
@ -791,7 +789,7 @@ nsIOService::NewChannelFromURIWithProxyFlags(nsIURI *aURI,
uint32_t aProxyFlags,
nsIChannel **result)
{
NS_WARNING("Deprecated, use NewChannelFromURIWithProxyFlags2 providing loadInfo arguments!");
NS_ASSERTION(false, "Deprecated, use NewChannelFromURIWithProxyFlags2 providing loadInfo arguments!");
return NewChannelFromURIWithProxyFlags2(aURI,
aProxyURI,
aProxyFlags,
@ -841,7 +839,7 @@ nsIOService::NewChannel2(const nsACString& aSpec,
NS_IMETHODIMP
nsIOService::NewChannel(const nsACString &aSpec, const char *aCharset, nsIURI *aBaseURI, nsIChannel **result)
{
NS_WARNING("Deprecated, use NewChannel2 providing loadInfo arguments!");
NS_ASSERTION(false, "Deprecated, use NewChannel2 providing loadInfo arguments!");
return NewChannel2(aSpec,
aCharset,
aBaseURI,

View File

@ -530,7 +530,10 @@ function test_newChannel_with_string()
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let NetUtilChannel = NetUtil.newChannel(TEST_SPEC);
let NetUtilChannel = NetUtil.newChannel({
uri: TEST_SPEC,
loadUsingSystemPrincipal: true
});
do_check_true(iosChannel.URI.equals(NetUtilChannel.URI));
run_next_test();
@ -549,29 +552,10 @@ function test_newChannel_with_nsIURI()
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let NetUtilChannel = NetUtil.newChannel(uri);
do_check_true(iosChannel.URI.equals(NetUtilChannel.URI));
run_next_test();
}
function test_newChannel_with_nsIFile()
{
let file = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties).
get("ProfD", Ci.nsIFile);
file.append("NetUtil-test-file.tmp");
// Check that we get the same URI back from channel the IO service creates and
// the channel the utility method creates.
let uri = NetUtil.newURI(file);
let iosChannel = NetUtil.ioService.newChannelFromURI2(uri,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let NetUtilChannel = NetUtil.newChannel(file);
let NetUtilChannel = NetUtil.newChannel({
uri: uri,
loadUsingSystemPrincipal: true
});
do_check_true(iosChannel.URI.equals(NetUtilChannel.URI));
run_next_test();
@ -802,7 +786,6 @@ function test_readInputStreamToString_invalid_sequence()
test_newChannel_no_specifier,
test_newChannel_with_string,
test_newChannel_with_nsIURI,
test_newChannel_with_nsIFile,
test_newChannel_with_options,
test_newChannel_with_wrong_options,
test_readInputStreamToString,

View File

@ -534,7 +534,7 @@ function promiseVerifyContents(aPath, aExpectedContents)
let deferred = Promise.defer();
NetUtil.asyncFetch(
file,
{ uri: NetUtil.newURI(file), loadUsingSystemPrincipal: true },
function(aInputStream, aStatus) {
do_check_true(Components.isSuccessCode(aStatus));
let contents = NetUtil.readInputStreamToString(aInputStream,