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