Bug 1445455 - Test that it's possible to show the same StatusPanel value twice in a row. r?dao
MozReview-Commit-ID: 17U8JHVO2PN
--- a/browser/base/content/moz.build
+++ b/browser/base/content/moz.build
@@ -66,16 +66,19 @@ with Files("test/siteIdentity/**"):
BUG_COMPONENT = ("Firefox", "Site Identity and Permission Panels")
with Files("test/sidebar/**"):
BUG_COMPONENT = ("Firefox", "General")
with Files("test/static/**"):
BUG_COMPONENT = ("Firefox", "General")
+with Files("test/statuspanel/**"):
+ BUG_COMPONENT = ("Firefox", "Tabbed Browser")
+
with Files("test/sync/**"):
BUG_COMPONENT = ("Firefox", "Sync")
with Files("test/tabPrompts/**"):
BUG_COMPONENT = ("Firefox", "Tabbed Browser")
with Files("test/tabcrashed/**"):
BUG_COMPONENT = ("Firefox", "Tabbed Browser")
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -4593,17 +4593,17 @@ class TabProgressListener {
aIID.equals(Ci.nsIWebProgressListener2) ||
aIID.equals(Ci.nsISupportsWeakReference) ||
aIID.equals(Ci.nsISupports))
return this;
throw Cr.NS_NOINTERFACE;
}
}
-let StatusPanel = {
+var StatusPanel = {
get panel() {
window.addEventListener("resize", this);
delete this.panel;
return this.panel = document.getElementById("statuspanel");
},
get isVisible() {
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/statuspanel/.eslintrc.js
@@ -0,0 +1,7 @@
+"use strict";
+
+module.exports = {
+ "extends": [
+ "plugin:mozilla/browser-test"
+ ]
+};
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/statuspanel/browser.ini
@@ -0,0 +1,5 @@
+[DEFAULT]
+support-files =
+ head.js
+
+[browser_show_statuspanel_twice.js]
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/statuspanel/browser_show_statuspanel_twice.js
@@ -0,0 +1,28 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const TEST_URL = "http://example.com";
+
+/**
+ * Test that if the StatusPanel is shown for a link, and then
+ * hidden, that it can be shown again for that same link.
+ * (Bug 1445455).
+ */
+add_task(async function test_show_statuspanel_twice() {
+ let win = await BrowserTestUtils.openNewBrowserWindow();
+ win.XULBrowserWindow.overLink = TEST_URL;
+ win.StatusPanel.update();
+ await promiseStatusPanelShown(win, TEST_URL);
+
+ win.XULBrowserWindow.overLink = "";
+ win.StatusPanel.update();
+ await promiseStatusPanelHidden(win);
+
+ win.XULBrowserWindow.overLink = TEST_URL;
+ win.StatusPanel.update();
+ await promiseStatusPanelShown(win, TEST_URL);
+
+ await BrowserTestUtils.closeWindow(win);
+});
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/statuspanel/head.js
@@ -0,0 +1,38 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Returns a Promise that resolves when a StatusPanel for a
+ * window has finished being shown. Also asserts that the
+ * text content of the StatusPanel matches a value.
+ *
+ * @param win (browser window)
+ * The window that the StatusPanel belongs to.
+ * @param value (string)
+ * The value that the StatusPanel should show.
+ * @returns Promise
+ */
+async function promiseStatusPanelShown(win, value) {
+ let panel = win.StatusPanel.panel;
+ await BrowserTestUtils.waitForEvent(panel, "transitionend", (e) => {
+ return e.propertyName === "opacity" &&
+ win.getComputedStyle(e.target).opacity == "1";
+ });
+
+ Assert.equal(win.StatusPanel._labelElement.value, value);
+}
+
+/**
+ * Returns a Promise that resolves when a StatusPanel for a
+ * window has finished being hidden.
+ *
+ * @param win (browser window)
+ * The window that the StatusPanel belongs to.
+ */
+async function promiseStatusPanelHidden(win) {
+ let panel = win.StatusPanel.panel;
+ await BrowserTestUtils.waitForEvent(panel, "transitionend", (e) => {
+ return e.propertyName === "opacity" &&
+ win.getComputedStyle(e.target).opacity == "0";
+ });
+}
--- a/browser/base/moz.build
+++ b/browser/base/moz.build
@@ -38,16 +38,17 @@ BROWSER_CHROME_MANIFESTS += [
'content/test/plugins/browser.ini',
'content/test/popupNotifications/browser.ini',
'content/test/popups/browser.ini',
'content/test/referrer/browser.ini',
'content/test/sanitize/browser.ini',
'content/test/sidebar/browser.ini',
'content/test/siteIdentity/browser.ini',
'content/test/static/browser.ini',
+ 'content/test/statuspanel/browser.ini',
'content/test/sync/browser.ini',
'content/test/tabcrashed/browser.ini',
'content/test/tabPrompts/browser.ini',
'content/test/tabs/browser.ini',
'content/test/touch/browser.ini',
'content/test/urlbar/browser.ini',
'content/test/webextensions/browser.ini',
'content/test/webrtc/browser.ini',