Bug 1570678 - Replace (i) icon for a file icon on potentially trustworthy pages. r=johannh,nhnt11

Differential Revision: https://phabricator.services.mozilla.com/D70932
This commit is contained in:
Krystle Salazar 2020-06-03 08:36:35 +00:00
parent 1975b4203f
commit 3f7916e8a6
10 changed files with 96 additions and 46 deletions

View File

@ -131,6 +131,23 @@ var gIdentityHandler = {
); );
}, },
get _isAboutNetErrorPage() {
return (
gBrowser.selectedBrowser.documentURI &&
gBrowser.selectedBrowser.documentURI.scheme == "about" &&
gBrowser.selectedBrowser.documentURI.pathQueryRef.startsWith("neterror")
);
},
get _isPotentiallyTrustworthy() {
return (
!this._isBrokenConnection &&
(this._isSecureContext ||
(gBrowser.selectedBrowser.documentURI &&
gBrowser.selectedBrowser.documentURI.scheme == "chrome"))
);
},
// smart getters // smart getters
get _identityPopup() { get _identityPopup() {
delete this._identityPopup; delete this._identityPopup;
@ -707,14 +724,12 @@ var gIdentityHandler = {
} else if (this._isAboutCertErrorPage) { } else if (this._isAboutCertErrorPage) {
// We show a warning lock icon for 'about:certerror' page. // We show a warning lock icon for 'about:certerror' page.
this._identityBox.className = "certErrorPage"; this._identityBox.className = "certErrorPage";
} else if ( } else if (this._isAboutNetErrorPage) {
this._isSecureContext || // Network errors get a more neutral icon
(gBrowser.selectedBrowser.documentURI &&
(gBrowser.selectedBrowser.documentURI.scheme == "about" ||
gBrowser.selectedBrowser.documentURI.scheme == "chrome"))
) {
// This is a local resource (and shouldn't be marked insecure).
this._identityBox.className = "unknownIdentity"; this._identityBox.className = "unknownIdentity";
} else if (this._isPotentiallyTrustworthy) {
// This is a local resource (and shouldn't be marked insecure).
this._identityBox.className = "localResource";
} else { } else {
// This is an insecure connection. // This is an insecure connection.
let warnOnInsecure = let warnOnInsecure =
@ -893,6 +908,10 @@ var gIdentityHandler = {
customRoot = this._hasCustomRoot(); customRoot = this._hasCustomRoot();
} else if (this._isAboutCertErrorPage) { } else if (this._isAboutCertErrorPage) {
connection = "cert-error-page"; connection = "cert-error-page";
} else if (this._isAboutNetErrorPage) {
connection = "not-secure";
} else if (this._isPotentiallyTrustworthy) {
connection = "file";
} }
// Determine the mixed content state. // Determine the mixed content state.

View File

@ -61,7 +61,7 @@ async function webpageTest(secureCheck) {
} }
gBrowser.selectedTab = oldTab; gBrowser.selectedTab = oldTab;
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); is(getIdentityMode(), "localResource", "Identity should be localResource");
gBrowser.selectedTab = newTab; gBrowser.selectedTab = newTab;
if (secureCheck) { if (secureCheck) {
@ -96,7 +96,7 @@ async function webpageTestTextWarning(secureCheck) {
} }
gBrowser.selectedTab = oldTab; gBrowser.selectedTab = oldTab;
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); is(getIdentityMode(), "localResource", "Identity should be localResource");
gBrowser.selectedTab = newTab; gBrowser.selectedTab = newTab;
if (secureCheck) { if (secureCheck) {
@ -180,7 +180,7 @@ async function blankPageTest(secureCheck) {
"valid", "valid",
"pageproxystate should be valid" "pageproxystate should be valid"
); );
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); is(getIdentityMode(), "localResource", "Identity should be localResource");
gBrowser.selectedTab = newTab; gBrowser.selectedTab = newTab;
is( is(
@ -207,7 +207,7 @@ async function secureTest(secureCheck) {
is(getIdentityMode(), "verifiedDomain", "Identity should be verified"); is(getIdentityMode(), "verifiedDomain", "Identity should be verified");
gBrowser.selectedTab = oldTab; gBrowser.selectedTab = oldTab;
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); is(getIdentityMode(), "localResource", "Identity should be localResource");
gBrowser.selectedTab = newTab; gBrowser.selectedTab = newTab;
is(getIdentityMode(), "verifiedDomain", "Identity should be verified"); is(getIdentityMode(), "verifiedDomain", "Identity should be verified");
@ -257,7 +257,7 @@ async function insecureTest(secureCheck) {
} }
gBrowser.selectedTab = oldTab; gBrowser.selectedTab = oldTab;
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); is(getIdentityMode(), "localResource", "Identity should be localResource");
gBrowser.selectedTab = newTab; gBrowser.selectedTab = newTab;
if (secureCheck) { if (secureCheck) {
@ -290,7 +290,7 @@ async function addonsTest(secureCheck) {
is(getIdentityMode(), "chromeUI", "Identity should be chrome"); is(getIdentityMode(), "chromeUI", "Identity should be chrome");
gBrowser.selectedTab = oldTab; gBrowser.selectedTab = oldTab;
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); is(getIdentityMode(), "localResource", "Identity should be localResource");
gBrowser.selectedTab = newTab; gBrowser.selectedTab = newTab;
is(getIdentityMode(), "chromeUI", "Identity should be chrome"); is(getIdentityMode(), "chromeUI", "Identity should be chrome");
@ -315,7 +315,7 @@ async function fileTest(secureCheck) {
is(getConnectionState(), "file", "Connection should be file"); is(getConnectionState(), "file", "Connection should be file");
gBrowser.selectedTab = oldTab; gBrowser.selectedTab = oldTab;
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); is(getIdentityMode(), "localResource", "Identity should be localResource");
gBrowser.selectedTab = newTab; gBrowser.selectedTab = newTab;
is(getConnectionState(), "file", "Connection should be file"); is(getConnectionState(), "file", "Connection should be file");
@ -341,7 +341,11 @@ async function resourceUriTest(secureCheck) {
is(getConnectionState(), "file", "Connection should be file"); is(getConnectionState(), "file", "Connection should be file");
gBrowser.selectedTab = oldTab; gBrowser.selectedTab = oldTab;
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); is(
getIdentityMode(),
"localResource",
"Identity should be a local a resource"
);
gBrowser.selectedTab = newTab; gBrowser.selectedTab = newTab;
is(getConnectionState(), "file", "Connection should be file"); is(getConnectionState(), "file", "Connection should be file");
@ -378,7 +382,7 @@ async function noCertErrorTest(secureCheck) {
); );
gBrowser.selectedTab = oldTab; gBrowser.selectedTab = oldTab;
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); is(getIdentityMode(), "localResource", "Identity should be localResource");
gBrowser.selectedTab = newTab; gBrowser.selectedTab = newTab;
is( is(
@ -471,7 +475,7 @@ async function aboutUriTest(secureCheck) {
is(getConnectionState(), "file", "Connection should be file"); is(getConnectionState(), "file", "Connection should be file");
gBrowser.selectedTab = oldTab; gBrowser.selectedTab = oldTab;
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); is(getIdentityMode(), "localResource", "Identity should be localResource");
gBrowser.selectedTab = newTab; gBrowser.selectedTab = newTab;
is(getConnectionState(), "file", "Connection should be file"); is(getConnectionState(), "file", "Connection should be file");
@ -522,7 +526,7 @@ async function dataUriTest(secureCheck) {
} }
gBrowser.selectedTab = oldTab; gBrowser.selectedTab = oldTab;
is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); is(getIdentityMode(), "localResource", "Identity should be localResource");
gBrowser.selectedTab = newTab; gBrowser.selectedTab = newTab;
if (secureCheck) { if (secureCheck) {
@ -574,8 +578,8 @@ async function pbModeTest(prefs, secureCheck) {
privateWin.gBrowser.selectedTab = oldTab; privateWin.gBrowser.selectedTab = oldTab;
is( is(
getIdentityMode(privateWin), getIdentityMode(privateWin),
"unknownIdentity", "localResource",
"Identity should be unknown" "Identity should be localResource"
); );
privateWin.gBrowser.selectedTab = newTab; privateWin.gBrowser.selectedTab = newTab;

View File

@ -14,10 +14,29 @@ function getIdentityMode(aWindow = window) {
return aWindow.document.getElementById("identity-box").className; return aWindow.document.getElementById("identity-box").className;
} }
function openIdentityPopup() {
let mainView = document.getElementById("identity-popup-mainView");
let viewShown = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
gIdentityHandler._identityBox.click();
return viewShown;
}
function closeIdentityPopup() {
let promise = BrowserTestUtils.waitForEvent(
gIdentityHandler._identityPopup,
"popuphidden"
);
gIdentityHandler._identityPopup.hidePopup();
return promise;
}
async function checkConnectionState(state) {
await openIdentityPopup();
is(getConnectionState(), state, "connectionState should be " + state);
await closeIdentityPopup();
}
function getConnectionState() { function getConnectionState() {
// Prevents items that are being lazy loaded causing issues
document.getElementById("identity-box").click();
gIdentityHandler.refreshIdentityPopup();
return document.getElementById("identity-popup").getAttribute("connection"); return document.getElementById("identity-popup").getAttribute("connection");
} }
@ -42,11 +61,7 @@ add_task(async function() {
"unknownIdentity weakCipher", "unknownIdentity weakCipher",
"Identity should be unknownIdentity" "Identity should be unknownIdentity"
); );
is( await checkConnectionState("not-secure");
getConnectionState(),
"not-secure",
"connectionState should be not-secure"
);
await BrowserTestUtils.loadURI(browser, HTTPS_TLS1_1); await BrowserTestUtils.loadURI(browser, HTTPS_TLS1_1);
await BrowserTestUtils.browserLoaded(browser); await BrowserTestUtils.browserLoaded(browser);
@ -56,18 +71,14 @@ add_task(async function() {
"unknownIdentity weakCipher", "unknownIdentity weakCipher",
"Identity should be unknownIdentity" "Identity should be unknownIdentity"
); );
is( await checkConnectionState("not-secure");
getConnectionState(),
"not-secure",
"connectionState should be not-secure"
);
// Transition to secure // Transition to secure
await BrowserTestUtils.loadURI(browser, HTTPS_TLS1_2); await BrowserTestUtils.loadURI(browser, HTTPS_TLS1_2);
await BrowserTestUtils.browserLoaded(browser); await BrowserTestUtils.browserLoaded(browser);
isSecurityState(browser, "secure"); isSecurityState(browser, "secure");
is(getIdentityMode(), "verifiedDomain", "Identity should be verified"); is(getIdentityMode(), "verifiedDomain", "Identity should be verified");
is(getConnectionState(), "secure", "connectionState should be secure"); await checkConnectionState("secure");
// Transition back to broken // Transition back to broken
await BrowserTestUtils.loadURI(browser, HTTPS_TLS1_1); await BrowserTestUtils.loadURI(browser, HTTPS_TLS1_1);
@ -78,17 +89,13 @@ add_task(async function() {
"unknownIdentity weakCipher", "unknownIdentity weakCipher",
"Identity should be unknownIdentity" "Identity should be unknownIdentity"
); );
is( await checkConnectionState("not-secure");
getConnectionState(),
"not-secure",
"connectionState should be not-secure"
);
// TLS1.3 for completeness // TLS1.3 for completeness
await BrowserTestUtils.loadURI(browser, HTTPS_TLS1_3); await BrowserTestUtils.loadURI(browser, HTTPS_TLS1_3);
await BrowserTestUtils.browserLoaded(browser); await BrowserTestUtils.browserLoaded(browser);
isSecurityState(browser, "secure"); isSecurityState(browser, "secure");
is(getIdentityMode(), "verifiedDomain", "Identity should be verified"); is(getIdentityMode(), "verifiedDomain", "Identity should be verified");
is(getConnectionState(), "secure", "connectionState should be secure"); await checkConnectionState("secure");
}); });
}); });

View File

@ -14,7 +14,7 @@ add_task(async function test() {
is( is(
identityBox.className, identityBox.className,
"unknownIdentity", "localResource",
"identity box has the correct class" "identity box has the correct class"
); );

View File

@ -30,7 +30,7 @@ const TEST_CASES = [
{ {
type: "non-chrome about page", type: "non-chrome about page",
testURL: "about:about", testURL: "about:about",
img_url: `url("chrome://global/skin/icons/identity-icon.svg")`, img_url: `url("chrome://global/skin/icons/document.svg")`,
}, },
{ {
type: "chrome about page", type: "chrome about page",
@ -40,7 +40,12 @@ const TEST_CASES = [
{ {
type: "file", type: "file",
testURL: "dummy_page.html", testURL: "dummy_page.html",
img_url: `url("chrome://global/skin/icons/identity-icon.svg")`, img_url: `url("chrome://global/skin/icons/document.svg")`,
},
{
type: "resource",
testURL: "resource://gre/modules/Log.jsm",
img_url: `url("chrome://global/skin/icons/document.svg")`,
}, },
{ {
type: "mixedPassiveContent", type: "mixedPassiveContent",
@ -60,12 +65,12 @@ const TEST_CASES = [
{ {
type: "localhost", type: "localhost",
testURL: "http://127.0.0.1", testURL: "http://127.0.0.1",
img_url: `url("chrome://global/skin/icons/identity-icon.svg")`, img_url: `url("chrome://global/skin/icons/document.svg")`,
}, },
{ {
type: "localhost + http frame", type: "localhost + http frame",
testURL: kBaseURILocalhost + "file_csp_block_all_mixedcontent.html", testURL: kBaseURILocalhost + "file_csp_block_all_mixedcontent.html",
img_url: `url("chrome://global/skin/icons/identity-icon.svg")`, img_url: `url("chrome://global/skin/icons/document.svg")`,
}, },
{ {
type: "data URI", type: "data URI",

View File

@ -26,7 +26,7 @@ add_task(async function() {
}); });
await BrowserTestUtils.browserLoaded(browser); await BrowserTestUtils.browserLoaded(browser);
let identityMode = window.document.getElementById("identity-box").className; let identityMode = window.document.getElementById("identity-box").className;
is(identityMode, "unknownIdentity", "identity should be 'unknown'"); is(identityMode, "localResource", "identity should be 'localResource'");
}); });
}); });

View File

@ -369,6 +369,10 @@
background-image: url(chrome://branding/content/icon48.png); background-image: url(chrome://branding/content/icon48.png);
} }
#identity-popup[connection=file] .identity-popup-security-connection {
background-image: url(chrome://global/skin/icons/document.svg);
}
#identity-popup[connection^=secure] .identity-popup-security-connection { #identity-popup[connection^=secure] .identity-popup-security-connection {
background-image: url(chrome://browser/skin/connection-secure.svg); background-image: url(chrome://browser/skin/connection-secure.svg);
-moz-context-properties: fill; -moz-context-properties: fill;

View File

@ -124,6 +124,10 @@
list-style-image: url(chrome://branding/content/identity-icons-brand.svg); list-style-image: url(chrome://branding/content/identity-icons-brand.svg);
} }
#identity-box[pageproxystate="valid"].localResource > #identity-icon {
list-style-image: url(chrome://global/skin/icons/document.svg);
}
#urlbar:not(.searchButton) > #urlbar-input-container > #identity-box[pageproxystate="invalid"] > #identity-icon { #urlbar:not(.searchButton) > #urlbar-input-container > #identity-box[pageproxystate="invalid"] > #identity-icon {
list-style-image: url(chrome://browser/skin/search-glass.svg); list-style-image: url(chrome://browser/skin/search-glass.svg);
fill-opacity: .4; fill-opacity: .4;

View File

@ -0,0 +1,6 @@
<!-- 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/. -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<path fill="context-fill" fill-opacity="context-fill-opacity" d="M14.12 3.71l-2.83-2.83A3 3 0 0 0 9.17 0H4a3 3 0 0 0-3 3v10a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3V5.83a3 3 0 0 0-0.88-2.12zM12.59 5H10V2.41zM12 14H4a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h5v3a1 1 0 0 0 1 1h3v7a1 1 0 0 1-1 1z"/>
</svg>

After

Width:  |  Height:  |  Size: 557 B

View File

@ -40,6 +40,7 @@ toolkit.jar:
skin/classic/global/pictureinpicture/close-pip.svg (../../shared/pictureinpicture/close-pip.svg) skin/classic/global/pictureinpicture/close-pip.svg (../../shared/pictureinpicture/close-pip.svg)
skin/classic/global/icons/columnpicker.svg (../../shared/icons/columnpicker.svg) skin/classic/global/icons/columnpicker.svg (../../shared/icons/columnpicker.svg)
skin/classic/global/icons/delete.svg (../../shared/icons/delete.svg) skin/classic/global/icons/delete.svg (../../shared/icons/delete.svg)
skin/classic/global/icons/document.svg (../../shared/icons/document.svg)
skin/classic/global/icons/error.svg (../../shared/icons/error.svg) skin/classic/global/icons/error.svg (../../shared/icons/error.svg)
skin/classic/global/icons/find-previous-arrow.svg (../../shared/icons/find-previous-arrow.svg) skin/classic/global/icons/find-previous-arrow.svg (../../shared/icons/find-previous-arrow.svg)
skin/classic/global/icons/find-next-arrow.svg (../../shared/icons/find-next-arrow.svg) skin/classic/global/icons/find-next-arrow.svg (../../shared/icons/find-next-arrow.svg)