Bug 1570630 - Removes query parameters in site identity panel header.r=johannh

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Carolina 2019-08-12 13:35:51 +00:00
Родитель 714a88a315
Коммит e33e344c35
2 изменённых файлов: 35 добавлений и 16 удалений

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

@ -626,6 +626,14 @@ var gIdentityHandler = {
// Some URIs might have no hosts.
}
if (this._uri.schemeIs("about")) {
// For example in about:certificate the original URL is
// about:certificate?cert=<large base64 encoded data>&cert=<large base64 encoded data>&cert=...
// So, instead of showing that large string in the identity panel header, we are just showing
// about:certificate now. For the other about pages we are just showing about:<page>
host = "about:" + this._uri.filePath;
}
let readerStrippedURI = ReaderMode.getOriginalUrlObjectForDisplay(
this._uri.displaySpec
);

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

@ -1,4 +1,4 @@
/* Tests for correct behaviour of getEffectiveHost on identity handler */
/* Tests for correct behaviour of getHostForDisplay on identity handler */
requestLongerTimeout(2);
@ -9,42 +9,53 @@ var tests = [
{
name: "normal domain",
location: "http://test1.example.org/",
effectiveHost: "test1.example.org",
hostForDisplay: "test1.example.org",
},
{
name: "view-source",
location: "view-source:http://example.com/",
effectiveHost: null,
hostForDisplay: null,
},
{
name: "normal HTTPS",
location: "https://example.com/",
effectiveHost: "example.com",
hostForDisplay: "example.com",
},
{
name: "IDN subdomain",
location: "http://sub1.xn--hxajbheg2az3al.xn--jxalpdlp/",
effectiveHost: "sub1." + idnDomain,
hostForDisplay: "sub1." + idnDomain,
},
{
name: "subdomain with port",
location: "http://sub1.test1.example.org:8000/",
effectiveHost: "sub1.test1.example.org",
hostForDisplay: "sub1.test1.example.org",
},
{
name: "subdomain HTTPS",
location: "https://test1.example.com/",
effectiveHost: "test1.example.com",
hostForDisplay: "test1.example.com",
},
{
name: "view-source HTTPS",
location: "view-source:https://example.com/",
effectiveHost: null,
hostForDisplay: null,
},
{
name: "IP address",
location: "http://127.0.0.1:8888/",
effectiveHost: "127.0.0.1",
hostForDisplay: "127.0.0.1",
},
{
name: "about:certificate",
location:
"about:certificate?cert=MIIHQjCCBiqgAwIBAgIQCgYwQn9bvO&cert=1pVzllk7ZFHzANBgkqhkiG9w0BAQ",
hostForDisplay: "about:certificate",
},
{
name: "about:reader",
location: "about:reader?url=http://example.com",
hostForDisplay: "example.com",
},
];
@ -97,18 +108,18 @@ async function runTest(i, forward) {
"Control Center is hidden"
);
// Sanity check other values, and the value of gIdentityHandler.getEffectiveHost()
// Sanity check other values, and the value of gIdentityHandler.getHostForDisplay()
is(
gIdentityHandler._uri.spec,
currentTest.location,
"location matches for test " + testDesc
);
// getEffectiveHost can't be called for all modes
if (currentTest.effectiveHost !== null) {
// getHostForDisplay can't be called for all modes
if (currentTest.hostForDisplay !== null) {
is(
gIdentityHandler.getEffectiveHost(),
currentTest.effectiveHost,
"effectiveHost matches for test " + testDesc
gIdentityHandler.getHostForDisplay(),
currentTest.hostForDisplay,
"hostForDisplay matches for test " + testDesc
);
}
@ -124,7 +135,7 @@ async function runTest(i, forward) {
!BrowserTestUtils.is_hidden(gIdentityHandler._identityPopup),
"Control Center is visible"
);
let displayedHost = currentTest.effectiveHost || currentTest.location;
let displayedHost = currentTest.hostForDisplay || currentTest.location;
ok(
gIdentityHandler._identityPopupMainViewHeaderLabel.textContent.includes(
displayedHost