browser/components/customizableui/test/browser_967000_button_feeds.js

branch
TOR_BUG_3246
changeset 6
8bccb770b82d
equal deleted inserted replaced
-1:000000000000 0:26846f9c7f74
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 "use strict";
6
7 const TEST_PAGE = "http://mochi.test:8888/browser/browser/components/customizableui/test/support/feeds_test_page.html";
8 const TEST_FEED = "http://mochi.test:8888/browser/browser/components/customizableui/test/support/test-feed.xml"
9
10 let newTab = null;
11 let initialLocation = gBrowser.currentURI.spec;
12
13 add_task(function() {
14 info("Check Subscribe button functionality");
15
16 // add the Subscribe button to the panel
17 CustomizableUI.addWidgetToArea("feed-button",
18 CustomizableUI.AREA_PANEL);
19
20 // check the button's functionality
21 yield PanelUI.show();
22
23 let feedButton = document.getElementById("feed-button");
24 ok(feedButton, "The Subscribe button was added to the Panel Menu");
25 is(feedButton.getAttribute("disabled"), "true", "The Subscribe button is initially disabled");
26
27 let panelHidePromise = promisePanelHidden(window);
28 PanelUI.hide();
29 yield panelHidePromise;
30
31 newTab = gBrowser.selectedTab;
32 yield promiseTabLoadEvent(newTab, TEST_PAGE);
33
34 yield PanelUI.show();
35
36 yield waitForCondition(function() !feedButton.hasAttribute("disabled"));
37 ok(!feedButton.hasAttribute("disabled"), "The Subscribe button gets enabled");
38
39 feedButton.click();
40 yield promiseTabLoadEvent(newTab, TEST_FEED);
41
42 is(gBrowser.currentURI.spec, TEST_FEED, "Subscribe page opened");
43 ok(!isPanelUIOpen(), "Panel is closed");
44
45 if(isPanelUIOpen()) {
46 panelHidePromise = promisePanelHidden(window);
47 PanelUI.hide();
48 yield panelHidePromise;
49 }
50 });
51
52 add_task(function asyncCleanup() {
53 // reset the panel UI to the default state
54 yield resetCustomization();
55 ok(CustomizableUI.inDefaultState, "The UI is in default state again.");
56
57 // restore the initial location
58 gBrowser.addTab(initialLocation);
59 gBrowser.removeTab(newTab);
60 });

mercurial