gecko-dev/browser/base/content/test/siteIdentity/browser_identityBlock_flicker.js
Johann Hofmann ae0eba57ce Bug 1570751 - Avoid identity block flickering. r=Ehsan
The security UI receives an about:blank load when navigating to or from
about: pages, which causes it to try and render security indicators before
showing the "real" security indicators for the next site. It shouldn't do that.

The solution is a bit cheap, we simply ignore all about:blank and other loads
that will receive a pageproxystate="invalid" state in the URL bar and thus
hide the identity block. This takes care of our problem and also avoids
some work when loading the home page.

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

--HG--
extra : moz-landing-system : lando
2019-08-07 09:03:13 +00:00

52 lines
1.3 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* Tests that the identity icons don't flicker when navigating,
* i.e. the box should show no intermediate identity state. */
add_task(async function test() {
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"about:robots",
true
);
let identityBox = document.getElementById("identity-box");
is(
identityBox.className,
"unknownIdentity",
"identity box has the correct class"
);
let observerOptions = {
attributes: true,
attributeFilter: ["class"],
};
let classChanges = 0;
let observer = new MutationObserver(function(mutations) {
for (let mutation of mutations) {
is(mutation.type, "attributes");
is(mutation.attributeName, "class");
classChanges++;
is(
identityBox.className,
"verifiedDomain",
"identity box class changed correctly"
);
}
});
observer.observe(identityBox, observerOptions);
let loaded = BrowserTestUtils.browserLoaded(
tab.linkedBrowser,
false,
"https://example.com/"
);
BrowserTestUtils.loadURI(tab.linkedBrowser, "https://example.com");
await loaded;
is(classChanges, 1, "Changed the className once");
observer.disconnect();
BrowserTestUtils.removeTab(tab);
});