mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1129957 - RemoteWebNavigation doesn't accept postdata or headers. r=Mossop
This commit is contained in:
parent
a4c110b65d
commit
1170dbe319
@ -879,7 +879,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++;
|
||||
@ -893,13 +893,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) {
|
||||
@ -909,7 +914,7 @@ function _loadURIWithFlags(browser, uri, params) {
|
||||
// when the homepage is a non-remote page.
|
||||
gBrowser.updateBrowserRemotenessByURL(browser, uri);
|
||||
browser.webNavigation.loadURIWithOptions(uri, flags, referrer, referrerPolicy,
|
||||
postdata, null, null);
|
||||
postData, null, null);
|
||||
} finally {
|
||||
if (browser.userTypedClear) {
|
||||
browser.userTypedClear--;
|
||||
|
@ -357,6 +357,7 @@ skip-if = buildapp == 'mulet'
|
||||
[browser_remoteTroubleshoot.js]
|
||||
support-files =
|
||||
test_remoteTroubleshoot.html
|
||||
[browser_remoteWebNavigation_postdata.js]
|
||||
[browser_removeTabsToTheEnd.js]
|
||||
[browser_removeUnsafeProtocolsFromURLBarPaste.js]
|
||||
[browser_restore_isAppTab.js]
|
||||
|
@ -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,
|
||||
});
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user