Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 package org.mozilla.gecko.tests;
3 import org.mozilla.gecko.Actions;
5 /** This patch tests the System Pages first by loading system pages from
6 * the awesome bar and then from Firefox menu
7 */
8 public class testSystemPages extends PixelTest {
9 final int mExpectedTabCount = 1;
10 private static final int AFTER_BACK_SLEEP_MS = 500;
12 public void testSystemPages() {
13 blockForGeckoReady();
15 String urls [] = { "about:firefox", "about:rights", "about:addons", "about:downloads", "about:buildconfig", "about:feedback", "about:healthreport", "about:" };
16 // Pages to be tested from the menu and their expected urls. This if of the form { {{ <path to item> }, { <expected url> }}* }
17 String menuItems [][][] = {{{ "Apps" }, { "about:apps" }},
18 {{ "Downloads" }, { "about:downloads" }},
19 {{ "Add-ons" }, { "about:addons" }},
20 {{ "Settings", "Mozilla", "About (Fennec|Nightly|Aurora|Firefox|Firefox Beta)" }, { "about:" }},
21 {{ "Settings", "Mozilla", "Give feedback" }, { "about:feedback" }},
22 {{ "Settings", "Mozilla", "View my Health Report" }, { "about:healthreport" }}};
24 /* Load system pages from url and check that the pages are loaded in the same tab */
25 checkUrl(urls);
27 /* Verify that the search field is not in the focus by pressing back. That will load the previous
28 about: page if there is no the keyboard to dismiss, meaning that the search field was not in focus */
29 loadAndPaint("about:about");
31 // Press back to verify if the keyboard is dismissed or the previous about: page loads
32 mActions.sendSpecialKey(Actions.SpecialKey.BACK);
33 // may not get a paint on Back...pause briefly to make sure it completes
34 mSolo.sleep(AFTER_BACK_SLEEP_MS);
36 // We will use the "about:" page as our reference page.
37 loadAndPaint("about:");
38 verifyUrl("about:"); // Verify that the previous about: page is loaded, meaning no keyboard was present
40 // Load system pages by navigating through the UI.
41 loadItemsByLevel(menuItems);
42 }
44 // Load from Url the about: pages,verify the Url and the tabs number
45 public void checkUrl(String urls []) {
46 for (String url:urls) {
47 loadAndPaint(url);
48 verifyTabCount(mExpectedTabCount);
49 verifyUrl(url);
50 }
51 }
53 public void loadItemsByLevel(String[][][] menuItems) {
54 Actions.EventExpecter tabEventExpecter;
55 Actions.EventExpecter contentEventExpecter;
56 Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint();
57 int expectedTabCount = mExpectedTabCount;
58 // There's some special casing for about: because it's our starting page.
59 for (String[][] item : menuItems) {
60 String [] pathToItem = item[0];
61 String expectedUrl = item[1][0];
63 expectedTabCount++;
65 // Set up listeners to catch the page load we're about to do
66 tabEventExpecter = mActions.expectGeckoEvent("Tab:Added");
67 contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded");
68 selectMenuItemByPath(pathToItem);
70 // Wait for the new tab and page to load
71 if ("about:".equals(expectedUrl)) {
72 waitForPaint(paintExpecter); // Waiting for the page to load
73 paintExpecter.unregisterListener();
74 } else {
75 tabEventExpecter.blockForEvent();
76 contentEventExpecter.blockForEvent();
77 }
78 tabEventExpecter.unregisterListener();
79 contentEventExpecter.unregisterListener();
81 verifyUrl(expectedUrl);
82 if ("about:".equals(expectedUrl)) {
83 // Decreasing because we do not expect this to be in a different tab.
84 expectedTabCount--;
85 }
86 verifyTabCount(expectedTabCount);
87 }
88 }
89 }