Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

M-C to Github Uplifts #1849

Merged
merged 3 commits into from Jan 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion app-extension/bootstrap.js
Expand Up @@ -50,7 +50,15 @@ function setResourceSubstitution(domain, uri) {
function readURI(uri) {
let ioservice = Cc['@mozilla.org/network/io-service;1'].
getService(Ci.nsIIOService);
let channel = ioservice.newChannel(uri, 'UTF-8', null);

let channel = ioservice.newChannel2(uri,
'UTF-8',
null,
null, // aLoadingNode
systemPrincipal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let stream = channel.open();

let cstream = Cc['@mozilla.org/intl/converter-input-stream;1'].
Expand Down
3 changes: 2 additions & 1 deletion lib/sdk/content/sandbox.js
Expand Up @@ -193,7 +193,8 @@ const WorkerSandbox = Class({
// `addon` in document is equivalent to `self` in content script.
if (requiresAddonGlobal(worker)) {
Object.defineProperty(getUnsafeWindow(window), 'addon', {
value: content.self
value: content.self,
configurable: true
}
);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/sdk/deprecated/traits-worker.js
Expand Up @@ -238,7 +238,8 @@ const WorkerSandbox = EventEmitter.compose({
if (worker._injectInDocument) {
let win = window.wrappedJSObject ? window.wrappedJSObject : window;
Object.defineProperty(win, "addon", {
value: content.self
value: content.self,
configurable: true
}
);
}
Expand Down
10 changes: 9 additions & 1 deletion lib/sdk/io/data.js
Expand Up @@ -15,6 +15,7 @@ const IOService = Cc["@mozilla.org/network/io-service;1"].

const { deprecateFunction } = require('../util/deprecate');
const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm");
const { Services } = Cu.import("resource://gre/modules/Services.jsm");
const FaviconService = Cc["@mozilla.org/browser/favicon-service;1"].
getService(Ci.nsIFaviconService);

Expand Down Expand Up @@ -51,7 +52,14 @@ exports.getFaviconURIForLocation = getFaviconURIForLocation;
* @returns {String}
*/
function getChromeURIContent(chromeURI) {
let channel = IOService.newChannel(chromeURI, null, null);
let channel = IOService.newChannel2(chromeURI,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let input = channel.open();
let stream = Cc["@mozilla.org/binaryinputstream;1"].
createInstance(Ci.nsIBinaryInputStream);
Expand Down
24 changes: 20 additions & 4 deletions lib/sdk/net/url.js
Expand Up @@ -8,11 +8,13 @@ module.metadata = {
"stability": "experimental"
};

const { Cu, components } = require("chrome");
const { Ci, Cu, components } = require("chrome");

const { defer } = require("../core/promise");
const { merge } = require("../util/object");

const { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});

/**
* Reads a URI and returns a promise.
Expand All @@ -33,12 +35,19 @@ function readURI(uri, options) {
options = options || {};
let charset = options.charset || 'UTF-8';

let channel = NetUtil.newChannel(uri, charset, null);
let channel = NetUtil.newChannel2(uri,
charset,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);

let { promise, resolve, reject } = defer();

try {
NetUtil.asyncFetch(channel, function (stream, result) {
NetUtil.asyncFetch2(channel, function (stream, result) {
if (components.isSuccessCode(result)) {
let count = stream.available();
let data = NetUtil.readInputStreamToString(stream, count, { charset : charset });
Expand Down Expand Up @@ -74,7 +83,14 @@ exports.readURI = readURI;
function readURISync(uri, charset) {
charset = typeof charset === "string" ? charset : "UTF-8";

let channel = NetUtil.newChannel(uri, charset, null);
let channel = NetUtil.newChannel2(uri,
charset,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let stream = channel.open();

let count = stream.available();
Expand Down
13 changes: 11 additions & 2 deletions lib/sdk/test/tmp-file.js
Expand Up @@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

const { Cc, Ci } = require("chrome");
const { Cc, Ci, Cu } = require("chrome");

const system = require("sdk/system");
const file = require("sdk/io/file");
Expand All @@ -12,6 +12,8 @@ const unload = require("sdk/system/unload");
// Retrieve the path to the OS temporary directory:
const tmpDir = require("sdk/system").pathFor("TmpD");

const { Services } = Cu.import("resource://gre/modules/Services.jsm");

// List of all tmp file created
let files = [];

Expand All @@ -33,7 +35,14 @@ unload.when(function () {
// `uri` and returns content string. Read in binary mode.
function readBinaryURI(uri) {
let ioservice = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
let channel = ioservice.newChannel(uri, "UTF-8", null);
let channel = ioservice.newChannel2(uri,
"UTF-8",
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let stream = Cc["@mozilla.org/binaryinputstream;1"].
createInstance(Ci.nsIBinaryInputStream);
stream.setInputStream(channel.open());
Expand Down
11 changes: 9 additions & 2 deletions lib/sdk/url.js
Expand Up @@ -7,7 +7,7 @@ module.metadata = {
"stability": "experimental"
};

const { Cc, Ci, Cr } = require("chrome");
const { Cc, Ci, Cr, Cu } = require("chrome");

const { Class } = require("./core/heritage");
const base64 = require("./base64");
Expand All @@ -23,6 +23,8 @@ var resProt = ios.getProtocolHandler("resource")
var URLParser = Cc["@mozilla.org/network/url-parser;1?auth=no"]
.getService(Ci.nsIURLParser);

const { Services } = Cu.import("resource://gre/modules/Services.jsm");

function newURI(uriStr, base) {
try {
let baseURI = base ? ios.newURI(base, null, null) : null;
Expand Down Expand Up @@ -64,7 +66,12 @@ let toFilename = exports.toFilename = function toFilename(url) {
if (uri.scheme == "resource")
uri = newURI(resolveResourceURI(uri));
if (uri.scheme == "chrome") {
var channel = ios.newChannelFromURI(uri);
var channel = ios.newChannelFromURI2(uri,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
try {
channel = channel.QueryInterface(Ci.nsIFileChannel);
return channel.file.path;
Expand Down
9 changes: 8 additions & 1 deletion lib/toolkit/loader.js
Expand Up @@ -172,7 +172,14 @@ function serializeStack(frames) {
exports.serializeStack = serializeStack;

function readURI(uri) {
let stream = NetUtil.newChannel(uri, 'UTF-8', null).open();
let stream = NetUtil.newChannel2(uri,
'UTF-8',
null,
null, // aLoadingNode
systemPrincipal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER).open();
let count = stream.available();
let data = NetUtil.readInputStreamToString(stream, count, {
charset: 'UTF-8'
Expand Down
10 changes: 9 additions & 1 deletion test/addons/l10n-properties/app-extension/bootstrap.js
Expand Up @@ -26,6 +26,7 @@ const appInfo = Cc["@mozilla.org/xre/app-info;1"].
const vc = Cc["@mozilla.org/xpcom/version-comparator;1"].
getService(Ci.nsIVersionComparator);

const { Services } = Cu.import("resource://gre/modules/Services.jsm");

const REASON = [ 'unknown', 'startup', 'shutdown', 'enable', 'disable',
'install', 'uninstall', 'upgrade', 'downgrade' ];
Expand All @@ -42,7 +43,14 @@ let nukeTimer = null;
function readURI(uri) {
let ioservice = Cc['@mozilla.org/network/io-service;1'].
getService(Ci.nsIIOService);
let channel = ioservice.newChannel(uri, 'UTF-8', null);
let channel = ioservice.newChannel2(uri,
'UTF-8',
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let stream = channel.open();

let cstream = Cc['@mozilla.org/intl/converter-input-stream;1'].
Expand Down
10 changes: 9 additions & 1 deletion test/addons/simple-prefs-regression/app-extension/bootstrap.js
Expand Up @@ -26,6 +26,7 @@ const appInfo = Cc["@mozilla.org/xre/app-info;1"].
const vc = Cc["@mozilla.org/xpcom/version-comparator;1"].
getService(Ci.nsIVersionComparator);

const { Services } = Cu.import("resource://gre/modules/Services.jsm");

const REASON = [ 'unknown', 'startup', 'shutdown', 'enable', 'disable',
'install', 'uninstall', 'upgrade', 'downgrade' ];
Expand All @@ -42,7 +43,14 @@ let nukeTimer = null;
function readURI(uri) {
let ioservice = Cc['@mozilla.org/network/io-service;1'].
getService(Ci.nsIIOService);
let channel = ioservice.newChannel(uri, 'UTF-8', null);
let channel = ioservice.newChannel2(uri,
'UTF-8',
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let stream = channel.open();

let cstream = Cc['@mozilla.org/intl/converter-input-stream;1'].
Expand Down
9 changes: 8 additions & 1 deletion test/test-private-browsing.js
Expand Up @@ -66,7 +66,14 @@ exports.testIsPrivateBrowsingFalseDefault = function(assert) {
};

exports.testNSIPrivateBrowsingChannel = function(assert) {
let channel = Services.io.newChannel("about:blank", null, null);
let channel = Services.io.newChannel2("about:blank",
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
channel.QueryInterface(Ci.nsIPrivateBrowsingChannel);
assert.equal(isPrivate(channel), false, 'isPrivate detects non-private channels');
channel.setPrivate(true);
Expand Down
16 changes: 13 additions & 3 deletions test/test-xpcom.js
Expand Up @@ -132,10 +132,15 @@ function testRegister(assert, text) {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);

var channel = ios.newChannel(
var channel = ios.newChannel2(
"data:text/plain;charset=utf-8," + text,
null,
null
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER
);

channel.originalURI = aURI;
Expand All @@ -162,7 +167,12 @@ function testRegister(assert, text) {
);

var aboutURI = ios.newURI("about:boop", null, null);
var channel = ios.newChannelFromURI(aboutURI);
var channel = ios.newChannelFromURI2(aboutURI,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var iStream = channel.open();
var siStream = Cc['@mozilla.org/scriptableinputstream;1']
.createInstance(Ci.nsIScriptableInputStream);
Expand Down