Bug 1115193 - Make JS callers of ios.newChannel call ios.newChannel2 in browser/devtools (r=vporof)

This commit is contained in:
Christoph Kerschbaumer 2015-02-10 20:48:36 -08:00
parent 318ed9a8bd
commit b413c219d6
5 changed files with 42 additions and 10 deletions

View File

@ -416,10 +416,17 @@ let SnapshotsListView = Heritage.extend(WidgetMethods, {
return;
}
let channel = NetUtil.newChannel(fp.file);
let channel = NetUtil.newChannel2(fp.file,
null,
null,
window.document,
null, // aLoadingPrincipal
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
channel.contentType = "text/plain";
NetUtil.asyncFetch(channel, (inputStream, status) => {
NetUtil.asyncFetch2(channel, (inputStream, status) => {
if (!Components.isSuccessCode(status)) {
console.error("Could not import recorded animation frame snapshot file.");
return;

View File

@ -326,10 +326,17 @@ function saveRecordingToFile(recordingItem, file) {
function loadRecordingFromFile(file) {
let deferred = promise.defer();
let channel = NetUtil.newChannel(file);
let channel = NetUtil.newChannel2(file,
null,
null,
window.document,
null, // aLoadingPrincipal
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
channel.contentType = "text/plain";
NetUtil.asyncFetch(channel, (inputStream, status) => {
NetUtil.asyncFetch2(channel, (inputStream, status) => {
if (!Components.isSuccessCode(status)) {
deferred.reject(new Error("Could not import recording data file."));
return;

View File

@ -1133,12 +1133,19 @@ var Scratchpad = {
importFromFile: function SP_importFromFile(aFile, aSilentError, aCallback)
{
// Prevent file type detection.
let channel = NetUtil.newChannel(aFile);
let channel = NetUtil.newChannel2(aFile,
null,
null,
window.document,
null, // aLoadingPrincipal
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
channel.contentType = "application/javascript";
this.notificationBox.removeAllNotifications(false);
NetUtil.asyncFetch(channel, (aInputStream, aStatus) => {
NetUtil.asyncFetch2(channel, (aInputStream, aStatus) => {
let content = null;
if (Components.isSuccessCode(aStatus)) {

View File

@ -185,7 +185,14 @@ AppCacheUtils.prototype = {
.createInstance(Ci.nsIScriptableInputStream);
let deferred = promise.defer();
let buffer = "";
let channel = Services.io.newChannel(uri, null, null);
let channel = Services.io.newChannel2(uri,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
// Avoid the cache:
channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;

View File

@ -339,7 +339,7 @@ StyleEditorUI.prototype = {
// nothing selected
return;
}
NetUtil.asyncFetch(file, (stream, status) => {
NetUtil.asyncFetch2(file, (stream, status) => {
if (!Components.isSuccessCode(status)) {
this.emit("error", { key: LOAD_ERROR });
return;
@ -350,8 +350,12 @@ StyleEditorUI.prototype = {
this._debuggee.addStyleSheet(source).then((styleSheet) => {
this._onStyleSheetCreated(styleSheet, file);
});
});
},
this._window.document,
null, // aLoadingPrincipal
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
};
showFilePicker(file, false, parentWindow, onFileSelected);