Bug 1598516 - Remove isLocalAboutURI since all about: URIs are local. r=Gijs

With DocumentChannel, the 'URI' of the channel that we proxy for RemoteWebProgress doesn't have the resolved URI, and reports the about: version instead.

All about: URIs are local these days, so we can just check for that scheme directly, and simplify the code.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matt Woodrow 2019-12-03 20:43:59 +00:00
Родитель 9d6d1cef54
Коммит c10f854a76
5 изменённых файлов: 4 добавлений и 95 удалений

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

@ -853,38 +853,6 @@
return rv;
},
/**
* Determine if a URI is an about: page pointing to a local resource.
*/
isLocalAboutURI(aURI, aResolvedURI) {
if (!aURI.schemeIs("about")) {
return false;
}
// Specially handle about:blank as local
if (aURI.pathQueryRef === "blank") {
return true;
}
try {
// Use the passed in resolvedURI if we have one
const resolvedURI =
aResolvedURI ||
Services.io.newChannelFromURI(
aURI,
null, // loadingNode
Services.scriptSecurityManager.getSystemPrincipal(), // loadingPrincipal
null, // triggeringPrincipal
Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, // securityFlags
Ci.nsIContentPolicy.TYPE_OTHER // contentPolicyType
).URI;
return resolvedURI.schemeIs("jar") || resolvedURI.schemeIs("file");
} catch (ex) {
// aURI might be invalid.
return false;
}
},
/**
* Sets an icon for the tab if the URI is defined in FAVICON_DEFAULTS.
*/
@ -5567,7 +5535,7 @@
// pointing to local resources.
if (
aRequest instanceof Ci.nsIChannel &&
gBrowser.isLocalAboutURI(aRequest.originalURI, aRequest.URI)
aRequest.originalURI.schemeIs("about")
) {
return false;
}

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

@ -24,7 +24,6 @@ tags = audiochannel
skip-if = (verify && debug && (os == 'linux'))
support-files =
test_bug1358314.html
[browser_isLocalAboutURI.js]
[browser_e10s_about_page_triggeringprincipal.js]
skip-if = verify
support-files =

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

@ -1,56 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Unit tests for tabbrowser.isLocalAboutURI to make sure it returns the
* appropriate values for various URIs as well as optional resolved URI.
*/
add_task(function test_URI() {
const check = (spec, expect, description) => {
const URI = Services.io.newURI(spec);
try {
is(gBrowser.isLocalAboutURI(URI), expect, description);
} catch (ex) {
ok(false, "isLocalAboutURI should not throw");
}
};
check("https://www.mozilla.org/", false, "https is not about");
check("http://www.mozilla.org/", false, "http is not about");
check("about:blank", true, "about:blank is local");
check("about:about", true, "about:about is local");
check("about:newtab", true, "about:newtab is local");
check(
"about:random-invalid-uri",
false,
"about:random-invalid-uri is invalid but should not throw"
);
});
add_task(function test_URI_with_resolved() {
const check = (spec, resolvedSpec, expect, description) => {
const URI = Services.io.newURI(spec);
const resolvedURI = Services.io.newURI(resolvedSpec);
is(gBrowser.isLocalAboutURI(URI, resolvedURI), expect, description);
};
check(
"about:newtab",
"jar:file:///Applications/Firefox.app/Contents/Resources/browser/omni.ja!/chrome/browser/res/activity-stream/prerendered/en-US/activity-stream.html",
true,
"about:newtab with jar is local"
);
check(
"about:newtab",
"file:///mozilla-central/browser/base/content/newtab/newTab.xhtml",
true,
"about:newtab with file is local"
);
check(
"about:newtab",
"https://www.mozilla.org/newtab",
false,
"about:newtab with https is not local"
);
});

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

@ -2978,7 +2978,7 @@ var SessionStoreInternal = {
// waiting for data from the frame script. This throbber is disabled
// if the URI is a local about: URI.
let uriObj = aTab.linkedBrowser.currentURI;
if (!uriObj || (uriObj && !aWindow.gBrowser.isLocalAboutURI(uriObj))) {
if (!uriObj || (uriObj && !uriObj.schemeIs("about"))) {
newTab.setAttribute("busy", "true");
}
@ -3662,7 +3662,7 @@ var SessionStoreInternal = {
// Start the throbber to pretend we're doing something while actually
// waiting for data from the frame script. This throbber is disabled
// if the URI is a local about: URI.
if (!uriObj || (uriObj && !window.gBrowser.isLocalAboutURI(uriObj))) {
if (!uriObj || (uriObj && !uriObj.schemeIs("about"))) {
tab.setAttribute("busy", "true");
}

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

@ -374,9 +374,7 @@ class AsyncTabSwitcher {
// determined by the busy state on the tab element and checking
// if the loaded URI is local.
let isBusy = this.requestedTab.hasAttribute("busy");
let isLocalAbout = this.tabbrowser.isLocalAboutURI(
requestedBrowser.currentURI
);
let isLocalAbout = requestedBrowser.currentURI.schemeIs("about");
let hasSufficientlyLoaded = !isBusy && !isLocalAbout;
let fl = requestedBrowser.frameLoader;