Bug 1411725 - have XHR responseURL use the final channel URL so the expected URLs for substituted protocols like web-extension: are returned; r=mayhemer

have XHR responseURL use the final channel URL so the expected URLs for substituted protocols like web-extension: are returned

Differential Revision: https://phabricator.services.mozilla.com/D23811

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Thomas Wisniewski 2019-03-31 01:31:12 +00:00
Родитель 920c719ba8
Коммит e1236ec692
3 изменённых файлов: 25 добавлений и 3 удалений

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

@ -783,9 +783,7 @@ void XMLHttpRequestMainThread::GetResponseURL(nsAString& aUrl) {
}
nsCOMPtr<nsIURI> responseUrl;
mChannel->GetURI(getter_AddRefs(responseUrl));
if (!responseUrl) {
if (NS_FAILED(NS_GetFinalChannelURI(mChannel, getter_AddRefs(responseUrl)))) {
return;
}

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

@ -3,5 +3,6 @@ support-files =
browser_xhr_onchange_leak.html
[browser_blobFromFile.js]
[browser_xhr_onchange_leak.js]
[browser_xhr_substituted_protocol_responseURL.js]
[browser_temporaryFile.js]
support-files = temporaryFileBlob.sjs

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

@ -0,0 +1,23 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// Bug 1411725 - An XHR using a SubstitutingProtocolHandler channel
// (web-extension:, resource:, etc) should return the original URL,
// not the jar/file it was actually substituted for.
const TEST_URL = "resource://gre/modules/XPCOMUtils.jsm";
add_task(async function test() {
await new Promise(resolve => {
const xhr = new XMLHttpRequest();
xhr.responseType = "text";
xhr.open("get", TEST_URL);
xhr.addEventListener("loadend", () => {
is(xhr.responseURL, TEST_URL, "original URL is given instead of substitution");
resolve();
});
xhr.send();
});
});