From 743afc816ba05a119e392b64912f9cb39b6a7721 Mon Sep 17 00:00:00 2001 From: Mihaela Velimiroviciu Date: Wed, 29 Oct 2014 15:19:01 +0200 Subject: [PATCH] Bug 1087303 - Add test for the functionality of remaining Panel Menu buttons in Australis (fullscreen, preferences). r=Gijs --- .../customizableui/test/browser.ini | 3 + .../test/browser_1087303_button_fullscreen.js | 46 +++++++++++++++ .../browser_1087303_button_preferences.js | 57 +++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 browser/components/customizableui/test/browser_1087303_button_fullscreen.js create mode 100644 browser/components/customizableui/test/browser_1087303_button_preferences.js diff --git a/browser/components/customizableui/test/browser.ini b/browser/components/customizableui/test/browser.ini index e8200e4da19..468a89361ec 100644 --- a/browser/components/customizableui/test/browser.ini +++ b/browser/components/customizableui/test/browser.ini @@ -148,6 +148,9 @@ skip-if = e10s # Bug 1088710 [browser_1008559_anchor_undo_restore.js] [browser_1042100_default_placements_update.js] [browser_1058573_showToolbarsDropdown.js] +[browser_1087303_button_fullscreen.js] +skip-if = os == "mac" +[browser_1087303_button_preferences.js] [browser_bootstrapped_custom_toolbar.js] [browser_panel_toggle.js] [browser_1089591_still_customizable_after_reset.js] diff --git a/browser/components/customizableui/test/browser_1087303_button_fullscreen.js b/browser/components/customizableui/test/browser_1087303_button_fullscreen.js new file mode 100644 index 00000000000..7d03b044443 --- /dev/null +++ b/browser/components/customizableui/test/browser_1087303_button_fullscreen.js @@ -0,0 +1,46 @@ +/* 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/. */ + +"use strict"; + +add_task(function() { + info("Check fullscreen button existence and functionality"); + + yield PanelUI.show(); + + let fullscreenButton = document.getElementById("fullscreen-button"); + ok(fullscreenButton, "Fullscreen button appears in Panel Menu"); + + let fullscreenPromise = promiseFullscreenChange(); + fullscreenButton.click(); + yield fullscreenPromise; + + ok(window.fullScreen, "Fullscreen mode was opened"); + + // exit full screen mode + fullscreenPromise = promiseFullscreenChange(); + window.fullScreen = !window.fullScreen; + yield fullscreenPromise; + + ok(!window.fullScreen, "Successfully exited fullscreen"); +}); + +function promiseFullscreenChange() { + let deferred = Promise.defer(); + info("Wait for fullscreen change"); + + let timeoutId = setTimeout(() => { + window.removeEventListener("fullscreen", onFullscreenChange, true); + deferred.reject("Fullscreen change did not happen within " + 20000 + "ms"); + }, 20000); + + function onFullscreenChange(event) { + clearTimeout(timeoutId); + window.removeEventListener("fullscreen", onFullscreenChange, true); + info("Fullscreen event received"); + deferred.resolve(); + } + window.addEventListener("fullscreen", onFullscreenChange, true); + return deferred.promise; +} diff --git a/browser/components/customizableui/test/browser_1087303_button_preferences.js b/browser/components/customizableui/test/browser_1087303_button_preferences.js new file mode 100644 index 00000000000..9c6f702461e --- /dev/null +++ b/browser/components/customizableui/test/browser_1087303_button_preferences.js @@ -0,0 +1,57 @@ +/* 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/. */ + +"use strict"; + +const PREF_INCONTENT = "browser.preferences.inContent"; + +let newTab = null; + +add_task(function() { + info("Check preferences button existence and functionality"); + + Services.prefs.setBoolPref(PREF_INCONTENT, true); + + yield PanelUI.show(); + info("Menu panel was opened"); + + let preferencesButton = document.getElementById("preferences-button"); + ok(preferencesButton, "Preferences button exists in Panel Menu"); + preferencesButton.click(); + + newTab = gBrowser.selectedTab; + yield waitForPageLoad(newTab); + + let openedPage = gBrowser.currentURI.spec; + is(openedPage, "about:preferences", "Preferences page was opened"); +}); + +add_task(function asyncCleanup() { + if (gBrowser.tabs.length == 1) + gBrowser.addTab("about:blank"); + + gBrowser.removeTab(gBrowser.selectedTab); + info("Tabs were restored"); + + // restore the browser.preferences.inContent preference + Services.prefs.clearUserPref(PREF_INCONTENT); +}); + +function waitForPageLoad(aTab) { + let deferred = Promise.defer(); + + let timeoutId = setTimeout(() => { + aTab.linkedBrowser.removeEventListener("load", onTabLoad, true); + deferred.reject("Page didn't load within " + 20000 + "ms"); + }, 20000); + + function onTabLoad(event) { + clearTimeout(timeoutId); + aTab.linkedBrowser.removeEventListener("load", onTabLoad, true); + info("Tab event received: " + "load"); + deferred.resolve(); + } + aTab.linkedBrowser.addEventListener("load", onTabLoad, true, true); + return deferred.promise; +}