Bug 1129957 - RemoteWebNavigation doesn't accept postdata or headers. r=Mossop

This commit is contained in:
Neil Rashbrook 2015-06-10 11:17:35 -03:00
Родитель b9cdd3a7bc
Коммит 425dec4244
5 изменённых файлов: 42 добавлений и 9 удалений

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

@ -876,7 +876,7 @@ function _loadURIWithFlags(browser, uri, params) {
let referrerPolicy = ('referrerPolicy' in params ? params.referrerPolicy :
Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT);
let charset = params.charset;
let postdata = params.postData;
let postData = params.postData;
if (!(flags & browser.webNavigation.LOAD_FLAGS_FROM_EXTERNAL)) {
browser.userTypedClear++;
@ -890,13 +890,18 @@ function _loadURIWithFlags(browser, uri, params) {
if (!mustChangeProcess) {
browser.webNavigation.loadURIWithOptions(uri, flags,
referrer, referrerPolicy,
postdata, null, null);
postData, null, null);
} else {
if (postData) {
postData = NetUtil.readInputStreamToString(postData, postData.available());
}
LoadInOtherProcess(browser, {
uri: uri,
flags: flags,
referrer: referrer ? referrer.spec : null,
referrerPolicy: referrerPolicy,
postData: postData,
});
}
} catch (e) {

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

@ -202,9 +202,11 @@ ContentRestoreInternal.prototype = {
let referrerPolicy = ('referrerPolicy' in loadArguments
? loadArguments.referrerPolicy
: Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT);
let postData = loadArguments.postData ?
Utils.makeInputStream(loadArguments.postData) : null;
webNavigation.loadURIWithOptions(loadArguments.uri, loadArguments.flags,
referrer, referrerPolicy, null, null,
null);
referrer, referrerPolicy, postData,
null, null);
} else if (tabData.userTypedValue && tabData.userTypedClear) {
// If the user typed a URL into the URL bar and hit enter right before
// we crashed, we want to start loading that page again. A non-zero

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

@ -7,6 +7,8 @@
this.EXPORTED_SYMBOLS = ["Utils"];
const Cu = Components.utils;
const Cc = Components.classes;
const Ci = Components.interfaces;
Cu.import("resource://gre/modules/Services.jsm", this);
@ -15,6 +17,13 @@ this.Utils = Object.freeze({
return Services.io.newURI(url, null, null);
},
makeInputStream: function (aString) {
let stream = Cc["@mozilla.org/io/string-input-stream;1"].
createInstance(Ci.nsISupportsCString);
stream.data = aString;
return stream; // XPConnect will QI this to nsIInputStream for us.
},
/**
* Returns true if the |url| passed in is part of the given root |domain|.
* For example, if |url| is "www.mozilla.org", and we pass in |domain| as

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

@ -21,6 +21,13 @@ if (AppConstants.MOZ_CRASHREPORTER) {
"nsICrashReporter");
}
function makeInputStream(aString) {
let stream = Cc["@mozilla.org/io/string-input-stream;1"].
createInstance(Ci.nsISupportsCString);
stream.data = aString;
return stream; // XPConnect will QI this to nsIInputStream for us.
}
let WebProgressListener = {
init: function() {
this._filter = Cc["@mozilla.org/appshell/component/browser-status-filter;1"]
@ -243,6 +250,7 @@ let WebNavigation = {
case "WebNavigation:LoadURI":
this.loadURI(message.data.uri, message.data.flags,
message.data.referrer, message.data.referrerPolicy,
message.data.postData, message.data.headers,
message.data.baseURI);
break;
case "WebNavigation:Reload":
@ -269,7 +277,7 @@ let WebNavigation = {
this.webNavigation.gotoIndex(index);
},
loadURI: function(uri, flags, referrer, referrerPolicy, baseURI) {
loadURI: function(uri, flags, referrer, referrerPolicy, postData, headers, baseURI) {
if (AppConstants.MOZ_CRASHREPORTER && CrashReporter.enabled) {
let annotation = uri;
try {
@ -283,10 +291,14 @@ let WebNavigation = {
}
if (referrer)
referrer = Services.io.newURI(referrer, null, null);
if (postData)
postData = makeInputStream(postData);
if (headers)
headers = makeInputStream(headers);
if (baseURI)
baseURI = Services.io.newURI(baseURI, null, null);
this.webNavigation.loadURIWithOptions(uri, flags, referrer, referrerPolicy,
null, null, baseURI);
postData, headers, baseURI);
},
reload: function(flags) {

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

@ -16,6 +16,12 @@ function makeURI(url)
newURI(url, null, null);
}
function readInputStreamToString(aStream)
{
Cu.import("resource://gre/modules/NetUtil.jsm");
return NetUtil.readInputStreamToString(aStream, aStream.available());
}
function RemoteWebNavigation(browser)
{
this.swapBrowser(browser);
@ -73,14 +79,13 @@ RemoteWebNavigation.prototype = {
},
loadURIWithOptions: function(aURI, aLoadFlags, aReferrer, aReferrerPolicy,
aPostData, aHeaders, aBaseURI) {
if (aPostData || aHeaders)
throw Components.Exception("RemoteWebNavigation doesn't accept postdata or headers.", Cr.NS_ERROR_INVALID_ARGS);
this._sendMessage("WebNavigation:LoadURI", {
uri: aURI,
flags: aLoadFlags,
referrer: aReferrer ? aReferrer.spec : null,
referrerPolicy: aReferrerPolicy,
postData: aPostData ? readInputStreamToString(aPostData) : null,
headers: aHeaders ? readInputStreamToString(aHeaders) : null,
baseURI: aBaseURI ? aBaseURI.spec : null,
});
},