Merge mozilla-central and fx-team
authorEd Morley <emorley@mozilla.com>
Thu, 12 Sep 2013 12:11:01 +0100
changeset 159694 29a87d8049b0279f630a958e49bebeecac199740
parent 159687 ca8fd217b83639254d906e0184d68c6efcd79a6a (current diff)
parent 159693 9df00be7eb58450852fa7073ff89b1ebf632e1ff (diff)
child 159695 e97b405792013e43461a7f625d49e39289e83b1c
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone26.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
Merge mozilla-central and fx-team
mobile/android/base/tests/testWebContentContextMenu.java.in
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -165,16 +165,20 @@ let gInitialPages = [
 #endif
 
 #ifdef MOZ_SERVICES_SYNC
 #include browser-syncui.js
 #endif
 
 XPCOMUtils.defineLazyGetter(this, "Win7Features", function () {
 #ifdef XP_WIN
+  // Bug 666808 - AeroPeek support for e10s
+  if (gMultiProcessBrowser)
+    return null;
+
   const WINTASKBAR_CONTRACTID = "@mozilla.org/windows-taskbar;1";
   if (WINTASKBAR_CONTRACTID in Cc &&
       Cc[WINTASKBAR_CONTRACTID].getService(Ci.nsIWinTaskbar).available) {
     let AeroPeek = Cu.import("resource:///modules/WindowsPreviewPerTab.jsm", {}).AeroPeek;
     return {
       onOpenWindow: function () {
         AeroPeek.onOpenWindow(window);
       },
@@ -1130,21 +1134,18 @@ var gBrowserInit = {
     placesContext.addEventListener("popupshowing", updateEditUIVisibility, false);
     placesContext.addEventListener("popuphiding", updateEditUIVisibility, false);
 #endif
 
     gBrowser.mPanelContainer.addEventListener("InstallBrowserTheme", LightWeightThemeWebInstaller, false, true);
     gBrowser.mPanelContainer.addEventListener("PreviewBrowserTheme", LightWeightThemeWebInstaller, false, true);
     gBrowser.mPanelContainer.addEventListener("ResetBrowserThemePreview", LightWeightThemeWebInstaller, false, true);
 
-    // Bug 666808 - AeroPeek support for e10s
-    if (!gMultiProcessBrowser) {
-      if (Win7Features)
-        Win7Features.onOpenWindow();
-    }
+    if (Win7Features)
+      Win7Features.onOpenWindow();
 
    // called when we go into full screen, even if initiated by a web page script
     window.addEventListener("fullscreen", onFullScreen, true);
 
     // Called when we enter DOM full-screen mode. Note we can already be in browser
     // full-screen mode when we enter DOM full-screen mode.
     window.addEventListener("MozEnteredDomFullscreen", onMozEnteredDomFullscreen, true);
 
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/tests/ContentContextMenuTest.java.in
@@ -0,0 +1,93 @@
+#filter substitution
+package @ANDROID_PACKAGE_NAME@.tests;
+
+import @ANDROID_PACKAGE_NAME@.*;
+import android.content.ContentResolver;
+import android.util.DisplayMetrics;
+
+import java.lang.reflect.Method;
+
+/**
+ * This class covers interactions with the context menu opened from web content
+ */
+abstract class ContentContextMenuTest extends AboutHomeTest {
+    private static final int MAX_TEST_TIMEOUT = 10000;
+
+    // This method opens the context menu of any web content. It assumes that the page is already loaded
+    protected void openWebContentContextMenu(String waitText) {
+        DisplayMetrics dm = new DisplayMetrics();
+        getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
+
+        // The web content we are trying to open the context menu for should be positioned at the top of the page, at least 60px heigh and aligned to the middle
+        float top = mDriver.getGeckoTop() + 30 * dm.density;
+        float left = mDriver.getGeckoLeft() + mDriver.getGeckoWidth() / 2;
+
+        mAsserter.dumpLog("long-clicking at "+left+", "+top);
+        mSolo.clickLongOnScreen(left, top);
+        waitForText(waitText);
+    }
+
+    protected void verifyContextMenuItems(String[] items) {
+        // Test that the menu items are displayed
+        openWebContentContextMenu(items[0]);
+        for (String option:items) {
+            mAsserter.ok(mSolo.searchText(option), "Checking that the option: " + option + " is available", "The option is available");
+        }
+    }
+
+    protected void openTabFromContextMenu(String contextMenuOption, int expectedTabCount) {
+        if (!mSolo.searchText(contextMenuOption)) {
+            openWebContentContextMenu(contextMenuOption); // Open the context menu if it is not already
+        }
+        Actions.EventExpecter tabEventExpecter = mActions.expectGeckoEvent("Tab:Added");
+        mSolo.clickOnText(contextMenuOption);
+        tabEventExpecter.blockForEvent();
+        tabEventExpecter.unregisterListener();
+        verifyTabCount(expectedTabCount);
+    }
+
+    protected void verifyCopyOption(String copyOption, final String copiedText) {
+        if (!mSolo.searchText(copyOption)) {
+            openWebContentContextMenu(copyOption); // Open the context menu if it is not already
+        }
+        mSolo.clickOnText(copyOption);
+        boolean correctText = waitForTest(new BooleanTest() {
+            @Override
+            public boolean test() {
+                try {
+                    ContentResolver resolver = getActivity().getContentResolver();
+                    ClassLoader classLoader = getActivity().getClassLoader();
+                    Class Clipboard = classLoader.loadClass("org.mozilla.gecko.util.Clipboard");
+                    Method getText = Clipboard.getMethod("getText");
+                    String clipboardText = (String)getText.invoke(null);
+                    mAsserter.dumpLog("Clipboard text = " + clipboardText + " , expected text = " + copiedText);
+                    return clipboardText.contains(copiedText);
+                } catch (Exception e) {
+                    mAsserter.ok(false, "Exception getting the clipboard text ", e.toString()); // Fail before returning
+                    return false;
+                }
+            }
+        }, MAX_TEST_TIMEOUT);
+        mAsserter.ok(correctText, "Checking if the text is correctly copied", "The text was correctly copied");
+    }
+
+
+
+    protected void verifyShareOption(String shareOption, String pageTitle) {
+        waitForText(pageTitle);
+        openWebContentContextMenu(shareOption);
+        mSolo.clickOnText(shareOption);
+        mAsserter.ok(waitForText("Share via"), "Checking that the share pop-up is displayed", "The pop-up has been displayed");
+
+        // Close the Share Link option menu and wait for the page to be focused again
+        mActions.sendSpecialKey(Actions.SpecialKey.BACK);
+        waitForText(pageTitle);
+    }
+
+    protected void verifyBookmarkLinkOption(String bookmarkOption, String link) {
+        openWebContentContextMenu(bookmarkOption);
+        mSolo.clickOnText(bookmarkOption);
+        mAsserter.ok(waitForText("Bookmark added"), "Waiting for the Bookmark added toaster notification", "The notification has been displayed");
+        mAsserter.ok(isBookmark(link), "Checking if the link has been added as a bookmark", "The link has been bookmarked");
+    }
+}
--- a/mobile/android/base/tests/robocop.ini
+++ b/mobile/android/base/tests/robocop.ini
@@ -10,17 +10,19 @@
 [testOrderedBroadcast]
 [testPrefsObserver]
 # [testPanCorrectness] # see bug 851861
 # [test_bug720538] # disabled on fig - bug 897072
 # [testFlingCorrectness] # see bug 851861
 # [testOverscroll] # see bug 851861
 # [testAxisLocking] # see bug 851861
 [testAboutPage]
-# [testWebContentContextMenu] # see bug 862493
+[testLinkContextMenu]
+[testMailToContextMenu]
+[testPictureLinkContextMenu]
 [testPasswordProvider]
 # [testPasswordEncrypt] # see bug 824067
 [testFormHistory]
 [testBrowserProvider]
 [testSearchSuggestions]
 [testSharedPreferences]
 # [testThumbnails] # see bug 813107
 [testAddonManager]
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/tests/testLinkContextMenu.java.in
@@ -0,0 +1,40 @@
+#filter substitution
+package @ANDROID_PACKAGE_NAME@.tests;
+
+import @ANDROID_PACKAGE_NAME@.*;
+
+public class testLinkContextMenu extends ContentContextMenuTest {
+
+    // Test website strings
+    private static String LINK_PAGE_URL;
+    private static String BLANK_PAGE_URL;
+    private static final String LINK_PAGE_TITLE = "Big Link";
+    private static final String linkMenuItems [] = { "Open Link in New Tab", "Open Link in Private Tab", "Copy Link", "Share Link", "Bookmark Link"};
+
+    @Override
+    protected int getTestType() {
+        return TEST_MOCHITEST;
+    }
+
+    public void testLinkContextMenu() {
+        blockForGeckoReady();
+
+        LINK_PAGE_URL=getAbsoluteUrl("/robocop/robocop_big_link.html");
+        BLANK_PAGE_URL=getAbsoluteUrl("/robocop/robocop_blank_01.html");
+        inputAndLoadUrl(LINK_PAGE_URL);
+        waitForText(LINK_PAGE_TITLE);
+
+        verifyContextMenuItems(linkMenuItems); // Verify context menu items are correct
+        openTabFromContextMenu(linkMenuItems[0],2); // Test the "Open in New Tab" option - expecting 2 tabs: the original and the new one
+        openTabFromContextMenu(linkMenuItems[1],2); // Test the "Open in Private Tab" option - expecting only 2 tabs in normal mode
+        verifyCopyOption(linkMenuItems[2], BLANK_PAGE_URL); // Test the "Copy Link" option
+        verifyShareOption(linkMenuItems[3], LINK_PAGE_TITLE); // Test the "Share Link" option
+        verifyBookmarkLinkOption(linkMenuItems[4], BLANK_PAGE_URL); // Test the "Bookmark Link" option
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        deleteBookmark(BLANK_PAGE_URL);
+        super.tearDown();
+    }
+}
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/tests/testMailToContextMenu.java.in
@@ -0,0 +1,29 @@
+#filter substitution
+package @ANDROID_PACKAGE_NAME@.tests;
+
+import @ANDROID_PACKAGE_NAME@.*;
+
+public class testMailToContextMenu extends ContentContextMenuTest {
+
+    // Test website strings
+    private static String MAILTO_PAGE_URL;
+    private static final String MAILTO_PAGE_TITLE = "Big Mailto";
+    private static final String mailtoMenuItems [] = {"Copy Email Address", "Share Email Address"};
+
+    @Override
+    protected int getTestType() {
+        return TEST_MOCHITEST;
+    }
+
+    public void testMailToContextMenu() {
+        blockForGeckoReady();
+
+        MAILTO_PAGE_URL=getAbsoluteUrl("/robocop/robocop_big_mailto.html");
+        inputAndLoadUrl(MAILTO_PAGE_URL);
+        waitForText(MAILTO_PAGE_TITLE);
+
+        verifyContextMenuItems(mailtoMenuItems);
+        verifyCopyOption(mailtoMenuItems[0], "foo.bar@example.com"); // Test the "Copy Email Address" option
+        verifyShareOption(mailtoMenuItems[1], MAILTO_PAGE_TITLE); // Test the "Share Email Address" option
+    }
+}
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/tests/testPictureLinkContextMenu.java.in
@@ -0,0 +1,36 @@
+#filter substitution
+package @ANDROID_PACKAGE_NAME@.tests;
+
+import @ANDROID_PACKAGE_NAME@.*;
+
+public class testPictureLinkContextMenu extends ContentContextMenuTest {
+
+    // Test website strings
+    private static String PICTURE_PAGE_URL;
+    private static String BLANK_PAGE_URL;
+    private static final String PICTURE_PAGE_TITLE = "Picture Link";
+    private static final String photoMenuItems [] = { "Copy Image Location", "Share Image", "Set Image As", "Save Image", "Open Link in New Tab", "Open Link in Private Tab", "Copy Link", "Share Link", "Bookmark Link"};
+
+    @Override
+    protected int getTestType() {
+        return TEST_MOCHITEST;
+    }
+
+    public void testPictureLinkContextMenu() {
+        blockForGeckoReady();
+
+        PICTURE_PAGE_URL=getAbsoluteUrl("/robocop/robocop_picture_link.html");
+        BLANK_PAGE_URL=getAbsoluteUrl("/robocop/robocop_blank_02.html");
+        inputAndLoadUrl(PICTURE_PAGE_URL);
+        waitForText(PICTURE_PAGE_TITLE);
+
+        verifyContextMenuItems(photoMenuItems);
+        verifyCopyOption(photoMenuItems[0], "Firefox.jpg"); // Test the "Copy Image Location" option
+        verifyShareOption(photoMenuItems[1], PICTURE_PAGE_TITLE); // Test the "Share Image" option
+        openTabFromContextMenu(photoMenuItems[4],2); // Test the "Open in New Tab" option - expecting 2 tabs: the original and the new one
+        openTabFromContextMenu(photoMenuItems[5],2); // Test the "Open in Private Tab" option - expecting only 2 tabs in normal mode
+        verifyCopyOption(photoMenuItems[6], BLANK_PAGE_URL); // Test the "Copy Link" option
+        verifyShareOption(photoMenuItems[7], PICTURE_PAGE_TITLE); // Test the "Share Link" option
+        verifyBookmarkLinkOption(photoMenuItems[8],BLANK_PAGE_URL); // Test the "Bookmark Link" option
+    }
+}
deleted file mode 100644
--- a/mobile/android/base/tests/testWebContentContextMenu.java.in
+++ /dev/null
@@ -1,210 +0,0 @@
-#filter substitution
-package @ANDROID_PACKAGE_NAME@.tests;
-
-import @ANDROID_PACKAGE_NAME@.*;
-import android.util.DisplayMetrics;
-
-/* Test the context menu on web content: Long click on a link,
- * verify that the context menu is shown and verify that some
- * of the menu actions work.
- */
-
-public class testWebContentContextMenu extends PixelTest {
-
-    @Override
-    protected int getTestType() {
-        return TEST_MOCHITEST;
-
-    }
-
-    public void testWebContentContextMenu() {
-        blockForGeckoReady();
-
-        String urls [] = { "/robocop/robocop_big_link.html", "/robocop/robocop_big_mailto.html", "/robocop/robocop_picture_link.html"};
-        String linkMenuItems [] = { "Open Link in New Tab", "Open Link in Private Tab", "Copy Link", "Share Link", "Bookmark Link"};
-        String mailtoMenuItems [] = { "Open With an App", "Copy Email Address", "Share Email Address"};
-        String photoMenuItems [] = { "Copy Image Location", "Share Image", "Set Image As", "Save Image"};
-
-        verfyLinkContextMenu(linkMenuItems, urls);
-        verfyMailtoContextMenu(mailtoMenuItems, urls);
-        verfyPhotoContextMenu(photoMenuItems, urls);
-
-    }
-
-    public void openContextMenu(int i, String urls []) {
-        DisplayMetrics dm = new DisplayMetrics();
-        getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
-
-        // The link has a 60px height, so let's try to hit the middle
-        float top = mDriver.getGeckoTop() + 30 * dm.density;
-        float left = mDriver.getGeckoLeft() + mDriver.getGeckoWidth() / 2;
-
-        String url = getAbsoluteUrl(urls [i]);
-        getInstrumentation().waitForIdleSync();
-        loadAndPaint(url);
-        mAsserter.dumpLog("long-clicking at "+left+", "+top);
-        mSolo.clickLongOnScreen(left, top);
-    }
-
-    public void accessSection(int i, String opt, String urls []) {
-        openContextMenu(i, urls);
-        mAsserter.ok(mSolo.waitForText(opt), "Waiting for  " + opt + "  option", "The " + opt + "  option is present");
-        mSolo.clickOnText(opt);
-    }
-
-    public void verfyLinkContextMenu(String items [], String urls []) {
-        for (String opt:items) {
-            if (opt.equals("Open Link in New Tab")) {
-                openContextMenu(0, urls);
-                mAsserter.ok(mSolo.waitForText(opt), "Waiting for  " + opt + "  option", "The " + opt + "  option is present");
-                Actions.EventExpecter tabEventExpecter = mActions.expectGeckoEvent("Tab:Added");
-                Actions.EventExpecter contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded");
-                mSolo.clickOnText(opt);
-
-                // Wait for the new tab and page to load
-                tabEventExpecter.blockForEvent();
-                contentEventExpecter.blockForEvent();
-                tabEventExpecter.unregisterListener();
-                contentEventExpecter.unregisterListener();
-
-                // See tab count
-                Element tabCount = mDriver.findElement(getActivity(), "tabs_count");
-                String tabCountText = null;
-                if (tabCount != null) {
-                    tabCountText = tabCount.getText();
-                }
-                mAsserter.is(tabCountText, "2", "Number of tabs has increased");
-            }
-            else {
-                if (opt.equals("Open Link in Private Tab")) {
-                    accessSection(2, opt, urls);
-                    mAsserter.ok(mSolo.waitForText("New private tab opened"), "Waiting for private tab to open", "The private tab is opened");
-
-                    // Verifying if the private data is not listed in Awesomescreen
-                    focusUrlBar();
-                    mSolo.clickOnText("History");
-                    mAsserter.ok(mSolo.waitForText("Browser Blank Page 01"), "Looking in History for the page loaded in the normal tab", "Fount it");
-                    mAsserter.ok(mSolo.waitForText("Browser Blank Page 02") == false, "Looking in History for the page loaded in the private tab", "Page is not present in History");
-                }
-                else {
-                    if (opt.equals("Copy Link")) {
-                        accessSection(0, opt, urls);
-
-                        // Verifying if the link was copied
-                        mSolo.clickLongOnText("Big Link");
-                        mAsserter.ok(mSolo.waitForText("^Paste$"), "Verify if the 'Paste' option is present", "The 'Paste' option is present");
-                        mSolo.clickOnText("^Paste$");
-                        mAsserter.ok(mSolo.waitForText("robocop_blank_01.html"), "Verify link", "The link was properly copied");
-                    }
-                    else {
-                        if (opt.equals("Share Link")) {
-                            accessSection(0, opt, urls);
-
-                            // Verifying if the Share Link option menu is opened
-                            mAsserter.ok(mSolo.waitForText("Share via"), "Waiting for the Share Link option menu to open", "The Share Link option menu is opened");
-                            mActions.sendSpecialKey(Actions.SpecialKey.BACK);// Close the Share Link option menu
-                            mSolo.waitForText("Big Link");
-                        }
-                        else {
-                            if (opt.equals("Bookmark Link")) {
-                                Navigation nav = new Navigation(mDevice);
-
-                                accessSection(0, opt, urls);
-                                mAsserter.is(mSolo.waitForText("Bookmark added"), true, "Bookmark added verified");
-
-                                // This waitForIdleSync improves reliability of the following loadUrl.
-                                // TODO: understand why!
-                                getInstrumentation().waitForIdleSync();
-
-                                // We know that the link test page points to robocop_blank_01.html, so lets
-                                // load it and see if the page is bookmarked
-                                String url = getAbsoluteUrl("/robocop/robocop_blank_01.html");
-                                loadAndPaint(url);
-
-                                // Pause briefly, to ensure that the bookmark addition, above, updates database tables and
-                                // completes before checking that the bookmark exists.
-                                // TODO: Find a better way to wait for completion of bookmark operations.
-                                try { Thread.sleep(2000); } catch(Exception e) {}
-
-                                // TODO: This doesn't work for some reason. We got a 'Bookmark added' and
-                                // will check for 'Bookmark removed'
-                                mAsserter.todo_is(mSolo.isTextChecked("Bookmark"), true, "Page is bookmarked");
-
-                                nav.bookmark();
-                                mAsserter.is(mSolo.waitForText("Bookmark removed"), true, "Bookmark removal verified");
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    public void verfyMailtoContextMenu(String items [], String urls []) {
-        for (String opt:items) {
-            if (opt.equals("Copy Email Address")) {
-                openContextMenu(1, urls);
-                mAsserter.ok(mSolo.waitForText(opt), "Waiting for  " + opt + "  option", "The " + opt + "  option is present");
-                mSolo.clickOnText(opt);
-
-                // Verifying if the email address was copied
-                mSolo.clickLongOnText("Big Mailto");
-                mAsserter.ok(mSolo.waitForText("^Paste$"), "Verify if the 'Paste' option is present", "The 'Paste' option is present");
-                mSolo.clickOnText("^Paste$");
-                mAsserter.ok(mSolo.waitForText("foo.bar@example.com"), "Verify email address", "The email address was properly copied");
-            }
-            else {
-                if (opt.equals("Share Email Address")) {
-                    accessSection(1, opt, urls);
-
-                    // Verifying if the Share email address option menu is opened
-                    mAsserter.ok(mSolo.waitForText("Share via"), "Waiting for the Share email address option menu to open", "The Share email address option menu is opened");
-                }
-            }
-        }
-        mActions.sendSpecialKey(Actions.SpecialKey.BACK); // Close the Share email address option menu
-        mSolo.waitForText("Big Mailto");
-    }
-
-    // Load a picture test page and test for allowed menu actions
-    public void verfyPhotoContextMenu(String items [], String urls []) {
-        for (String opt:items) {
-            if (opt.equals("Copy Image Location")) {
-
-                // This waitForIdleSync improves reliability of the following loadUrl.
-                // TODO: understand why!
-                getInstrumentation().waitForIdleSync();
-                accessSection(2, opt, urls);
-
-                // Verifying if the photo's link was copied
-                mSolo.clickLongOnText("Picture Link");
-                mAsserter.ok(mSolo.waitForText("^Paste$"), "Verify if the 'Paste' option is present", "The 'Paste' option is present");
-                mSolo.clickOnText("^Paste$");
-                mAsserter.ok(mSolo.waitForText("Firefox.jpg"), "Verify link", "The photo's link was properly copied");
-            }
-            else {
-                if (opt.equals("Share Image")) {
-                    accessSection(2, opt, urls);
-
-                    // Verifying if the Share Image option menu is opened
-                    mAsserter.ok(mSolo.waitForText("Share via"), "Waiting for the Share Image option menu to open", "The Share Image option menu is opened");
-                    mActions.sendSpecialKey(Actions.SpecialKey.BACK); // Close the Share Image option menu
-                    mSolo.waitForText("Picture Link");
-                }
-                else {
-                    if (opt.equals("Set Image As")) {
-                        openContextMenu(2, urls);
-                        mAsserter.ok(mSolo.waitForText(opt), "Waiting for  " + opt + "  option", "The " + opt + "  option is present");
-                    }
-                    else {
-                        if (opt.equals("Save Image")) {
-                            mSolo.clickOnText(opt);
-                            mAsserter.ok(mSolo.waitForText("Download started"), "Verify that the download started", "The download started");
-                            mSolo.waitForText("Picture Link");
-                        }
-                    }
-                }
-            }
-        }
-    }
-}