Bug 973641 - Add test for the functionality of addon button in Australis. r=Gijs
authorMihaela Velimiroviciu <mihaela.velimiroviciu@softvisioninc.eu>
Thu, 02 Oct 2014 09:19:55 +0300
changeset 231939 cd771a5cdfde6ba37fda34df970040cd9f765feb
parent 231938 9f9ab384033475ccde26d520bd1c049a767c4ba7
child 231940 313954ccec641545aba109fab543d358a704f5fa
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs973641
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 973641 - Add test for the functionality of addon button in Australis. r=Gijs
browser/components/customizableui/test/browser.ini
browser/components/customizableui/test/browser_973641_button_addon.js
--- a/browser/components/customizableui/test/browser.ini
+++ b/browser/components/customizableui/test/browser.ini
@@ -108,16 +108,17 @@ skip-if = e10s # Bug ?????? - test uses 
 [browser_967000_button_tabView.js]
 [browser_968447_bookmarks_toolbar_items_in_panel.js]
 skip-if = os == "linux" # Intemittent failures - bug 979207
 [browser_968565_insert_before_hidden_items.js]
 [browser_969427_recreate_destroyed_widget_after_reset.js]
 [browser_969661_character_encoding_navbar_disabled.js]
 [browser_970511_undo_restore_default.js]
 [browser_972267_customizationchange_events.js]
+[browser_973641_button_addon.js]
 [browser_973932_addonbar_currentset.js]
 [browser_975719_customtoolbars_behaviour.js]
 
 [browser_976792_insertNodeInWindow.js]
 skip-if = os == "linux"
 
 [browser_978084_dragEnd_after_move.js]
 [browser_980155_add_overflow_toolbar.js]
new file mode 100755
--- /dev/null
+++ b/browser/components/customizableui/test/browser_973641_button_addon.js
@@ -0,0 +1,72 @@
+/* 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 kButton = "test_button_for_addon";
+let initialLocation = gBrowser.currentURI.spec;
+
+add_task(function() {
+  info("Check addon button functionality");
+
+  // create mocked addon button on the navigation bar
+  let widgetSpec = {
+    id: kButton,
+    type: 'button',
+    onClick: function() {
+      gBrowser.selectedTab = gBrowser.addTab("about:addons");
+    }
+  };
+  CustomizableUI.createWidget(widgetSpec);
+  CustomizableUI.addWidgetToArea(kButton, CustomizableUI.AREA_NAVBAR);
+
+  // check the button's functionality in navigation bar
+  let addonButton = document.getElementById(kButton);
+  let navBar = document.getElementById("nav-bar");
+  ok(addonButton, "Addon button exists");
+  ok(navBar.contains(addonButton), "Addon button is in the navbar");
+  yield checkButtonFunctionality(addonButton);
+
+  resetTabs();
+
+  //move the add-on button in the Panel Menu
+  CustomizableUI.addWidgetToArea(kButton, CustomizableUI.AREA_PANEL);
+  let addonButtonInNavbar = navBar.getElementsByAttribute("id", kButton);
+  ok(!navBar.contains(addonButton), "Addon button was removed from the browser bar");
+
+  // check the addon button's functionality in the Panel Menu
+  yield PanelUI.show();
+  var panelMenu = document.getElementById("PanelUI-mainView");
+  let addonButtonInPanel = panelMenu.getElementsByAttribute("id", kButton);
+  ok(panelMenu.contains(addonButton), "Addon button was added to the Panel Menu");
+  yield checkButtonFunctionality(addonButtonInPanel[0]);
+});
+
+add_task(function asyncCleanup() {
+  resetTabs();
+
+  // reset the UI to the default state
+  yield resetCustomization();
+  ok(CustomizableUI.inDefaultState, "The UI is in default state again.");
+
+  // destroy the widget
+  CustomizableUI.destroyWidget(kButton);
+});
+
+function resetTabs() {
+  //close all opened tabs
+  while(gBrowser.tabs.length > 1) {
+    gBrowser.removeTab(gBrowser.selectedTab);
+  }
+
+  //restore the initial tab
+  gBrowser.addTab(initialLocation);
+  gBrowser.removeTab(gBrowser.selectedTab);
+}
+
+function checkButtonFunctionality(aButton) {
+  aButton.click();
+  yield waitForCondition(() => gBrowser.currentURI &&
+                               gBrowser.currentURI.spec == "about:addons");
+}