Back out b82e4d33ec28 (bug 1232901) on suspicion of breaking Gij-19's browser_context_menu_test.js

CLOSED TREE
This commit is contained in:
Phil Ringnalda 2016-01-20 19:40:44 -08:00
Родитель 7b2fec233a
Коммит 470e0c0634
1 изменённых файлов: 30 добавлений и 12 удалений

Просмотреть файл

@ -15,7 +15,6 @@ var Cr = Components.results;
*/
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/BrowserElementPromptService.jsm");
@ -1002,17 +1001,36 @@ BrowserElementParent.prototype = {
Ci.nsIRequestObserver])
};
let referrer = Services.io.newURI(_options.referrer, null, null);
let principal =
Services.scriptSecurityManager.createCodebasePrincipal(
referrer, this._frameLoader.loadContext.originAttributes);
// If we have a URI we'll use it to get the triggering principal to use,
// if not available a null principal is acceptable.
let referrer = null;
let principal = null;
if (_options.referrer) {
// newURI can throw on malformed URIs.
try {
referrer = Services.io.newURI(_options.referrer, null, null);
}
catch(e) {
debug('Malformed referrer -- ' + e);
}
let channel = NetUtil.newChannel({
uri: url,
loadingPrincipal: principal,
securityFlags: SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS,
contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER
});
// This simply returns null if there is no principal available
// for the requested uri. This is an acceptable fallback when
// calling newChannelFromURI2.
principal =
Services.scriptSecurityManager.createCodebasePrincipal(
referrer, this._frameLoader.loadContext.originAttributes);
}
debug('Using principal? ' + !!principal);
let channel =
Services.io.newChannelFromURI2(url,
null, // No document.
principal, // Loading principal
principal, // Triggering principal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
// XXX We would set private browsing information prior to calling this.
channel.notificationCallbacks = interfaceRequestor;
@ -1037,7 +1055,7 @@ BrowserElementParent.prototype = {
}
// Set-up complete, let's get things started.
channel.asyncOpen2(new DownloadListener());
channel.asyncOpen(new DownloadListener(), null);
return req;
},