Bug 1376892 - Don't show stop button for local url loads. r=jaws

This commit is contained in:
Perry Jiang 2017-07-10 13:17:06 -07:00
Родитель 7a3eb41821
Коммит b3ffa2a697
5 изменённых файлов: 115 добавлений и 2 удалений

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

@ -4992,7 +4992,7 @@ var CombinedStopReload = {
},
switchToStop(aRequest, aWebProgress) {
if (!this._initialized)
if (!this._initialized || !this._shouldSwitch(aRequest))
return;
let shouldAnimate = AppConstants.MOZ_PHOTON_ANIMATIONS &&
@ -5010,7 +5010,8 @@ var CombinedStopReload = {
},
switchToReload(aRequest, aWebProgress) {
if (!this._initialized)
if (!this._initialized || !this._shouldSwitch(aRequest) ||
!this.reload.hasAttribute("displaystop"))
return;
let shouldAnimate = AppConstants.MOZ_PHOTON_ANIMATIONS &&
@ -5047,6 +5048,19 @@ var CombinedStopReload = {
}, 650, this);
},
_shouldSwitch(aRequest) {
if (!aRequest ||
!aRequest.originalURI ||
aRequest.originalURI.spec.startsWith("about:reader"))
return true;
if (aRequest.originalURI.schemeIs("chrome") ||
aRequest.originalURI.schemeIs("about"))
return false;
return true;
},
_cancelTransition() {
if (this._timer) {
clearTimeout(this._timer);

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

@ -0,0 +1,7 @@
"use strict";
module.exports = {
"extends": [
"plugin:mozilla/browser-test"
]
};

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

@ -0,0 +1 @@
[browser_aboutStopReload.js]

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

@ -0,0 +1,90 @@
async function waitForNoAnimation(elt) {
return BrowserTestUtils.waitForCondition(() => !elt.hasAttribute("animate"));
}
async function getAnimatePromise(elt) {
return BrowserTestUtils.waitForAttribute("animate", elt)
.then(() => Assert.ok(true, `${elt.id} should animate`));
}
function stopReloadMutationCallback() {
Assert.ok(false, "stop-reload's animate attribute should not have been mutated");
}
add_task(async function checkDontShowStopOnNewTab() {
let stopReloadContainer = document.getElementById("stop-reload-button");
let stopReloadContainerObserver = new MutationObserver(stopReloadMutationCallback);
await waitForNoAnimation(stopReloadContainer);
stopReloadContainerObserver.observe(stopReloadContainer, { attributeFilter: ["animate"]});
let tab = await BrowserTestUtils.openNewForegroundTab({gBrowser,
opening: "about:robots",
waitForStateStop: true});
await BrowserTestUtils.removeTab(tab);
Assert.ok(true, "Test finished: stop-reload does not animate when navigating to local URI on new tab");
stopReloadContainerObserver.disconnect();
});
add_task(async function checkDontShowStopFromLocalURI() {
let stopReloadContainer = document.getElementById("stop-reload-button");
let stopReloadContainerObserver = new MutationObserver(stopReloadMutationCallback);
let tab = await BrowserTestUtils.openNewForegroundTab({gBrowser,
opening: "about:robots",
waitForStateStop: true});
await waitForNoAnimation(stopReloadContainer);
stopReloadContainerObserver.observe(stopReloadContainer, { attributeFilter: ["animate"]});
await BrowserTestUtils.loadURI(tab.linkedBrowser, "about:mozilla");
await BrowserTestUtils.removeTab(tab);
Assert.ok(true, "Test finished: stop-reload does not animate when navigating between local URIs");
stopReloadContainerObserver.disconnect();
});
add_task(async function checkDontShowStopFromNonLocalURI() {
let stopReloadContainer = document.getElementById("stop-reload-button");
let stopReloadContainerObserver = new MutationObserver(stopReloadMutationCallback);
let tab = await BrowserTestUtils.openNewForegroundTab({gBrowser,
opening: "https://example.com",
waitForStateStop: true});
await waitForNoAnimation(stopReloadContainer);
stopReloadContainerObserver.observe(stopReloadContainer, { attributeFilter: ["animate"]});
await BrowserTestUtils.loadURI(tab.linkedBrowser, "about:mozilla");
await BrowserTestUtils.removeTab(tab);
Assert.ok(true, "Test finished: stop-reload does not animate when navigating to local URI from non-local URI");
stopReloadContainerObserver.disconnect();
});
add_task(async function checkDoShowStopOnNewTab() {
let stopReloadContainer = document.getElementById("stop-reload-button");
let animatePromise = getAnimatePromise(stopReloadContainer);
await waitForNoAnimation(stopReloadContainer);
let tab = await BrowserTestUtils.openNewForegroundTab({gBrowser,
opening: "https://example.com",
waitForStateStop: true});
await animatePromise;
await waitForNoAnimation(stopReloadContainer);
await BrowserTestUtils.removeTab(tab);
info("Test finished: stop-reload animates when navigating to non-local URI on new tab");
});
add_task(async function checkDoShowStopFromLocalURI() {
let stopReloadContainer = document.getElementById("stop-reload-button");
await waitForNoAnimation(stopReloadContainer);
let tab = await BrowserTestUtils.openNewForegroundTab({gBrowser,
opening: "about:robots",
waitForStateStop: true});
let animatePromise = getAnimatePromise(stopReloadContainer);
await BrowserTestUtils.loadURI(tab.linkedBrowser, "https://example.com");
await animatePromise;
await waitForNoAnimation(stopReloadContainer);
await BrowserTestUtils.removeTab(tab);
info("Test finished: stop-reload animates when navigating to non-local URI from local URI");
});

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

@ -15,6 +15,7 @@ MOCHITEST_CHROME_MANIFESTS += [
]
BROWSER_CHROME_MANIFESTS += [
'content/test/about/browser.ini',
'content/test/alerts/browser.ini',
'content/test/captivePortal/browser.ini',
'content/test/contextMenu/browser.ini',