Bug 1367079 - 6. Fix testAccessibleCarets; r=me
authorJim Chen <nchen@mozilla.com>
Thu, 14 Sep 2017 17:50:58 -0400
changeset 665160 69521f759e299849c0ae9ab0f7f11ea322730aea
parent 665159 5dae173f8fe8567970e9f97143ab635b8de8acea
child 665161 9e895d32653b939602552eb859c319b50457afba
push id79943
push userbmo:tchiovoloni@mozilla.com
push dateThu, 14 Sep 2017 23:59:48 +0000
reviewersme
bugs1367079
milestone57.0a1
Bug 1367079 - 6. Fix testAccessibleCarets; r=me Fix testAccessibleCarets and enable it for non-Nightly builds. r=me for test changes. MozReview-Commit-ID: EjNwzb5bETy
mobile/android/components/BrowserCLH.js
mobile/android/components/MobileComponents.manifest
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAccessibleCarets.java
mobile/android/tests/browser/robocop/testAccessibleCarets.js
--- a/mobile/android/components/BrowserCLH.js
+++ b/mobile/android/components/BrowserCLH.js
@@ -18,17 +18,19 @@ var Strings = {};
 
 XPCOMUtils.defineLazyGetter(Strings, "brand", _ =>
         Services.strings.createBundle("chrome://branding/locale/brand.properties"));
 XPCOMUtils.defineLazyGetter(Strings, "browser", _ =>
         Services.strings.createBundle("chrome://browser/locale/browser.properties"));
 XPCOMUtils.defineLazyGetter(Strings, "reader", _ =>
         Services.strings.createBundle("chrome://global/locale/aboutReader.properties"));
 
-function BrowserCLH() {}
+function BrowserCLH() {
+  this.wrappedJSObject = this;
+}
 
 BrowserCLH.prototype = {
   /**
    * Register resource://android as the APK root.
    *
    * Consumers can access Android assets using resource://android/assets/FILENAME.
    */
   setResourceSubstitutions: function() {
--- a/mobile/android/components/MobileComponents.manifest
+++ b/mobile/android/components/MobileComponents.manifest
@@ -61,17 +61,17 @@ contract @mozilla.org/addons/web-install
 
 # HelperAppDialog.js
 component {e9d277a0-268a-4ec2-bb8c-10fdf3e44611} HelperAppDialog.js
 contract @mozilla.org/helperapplauncherdialog;1 {e9d277a0-268a-4ec2-bb8c-10fdf3e44611}
 
 # BrowserCLH.js
 component {be623d20-d305-11de-8a39-0800200c9a66} BrowserCLH.js application={aa3c5121-dab2-40e2-81ca-7ea25febc110}
 contract @mozilla.org/browser/browser-clh;1 {be623d20-d305-11de-8a39-0800200c9a66}
-category app-startup BrowserCLH @mozilla.org/browser/browser-clh;1
+category app-startup BrowserCLH service,@mozilla.org/browser/browser-clh;1
 
 # ContentDispatchChooser.js
 component {5a072a22-1e66-4100-afc1-07aed8b62fc5} ContentDispatchChooser.js
 contract @mozilla.org/content-dispatch-chooser;1 {5a072a22-1e66-4100-afc1-07aed8b62fc5}
 
 # AddonUpdateService.js
 component {93c8824c-9b87-45ae-bc90-5b82a1e4d877} AddonUpdateService.js
 contract @mozilla.org/browser/addon-update-service;1 {93c8824c-9b87-45ae-bc90-5b82a1e4d877}
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAccessibleCarets.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAccessibleCarets.java
@@ -34,26 +34,16 @@ public class testAccessibleCarets extend
 
     @Override
     public void tearDown() throws Exception {
         Tabs.unregisterOnTabsChangedListener(tabsListener);
 
         super.tearDown();
     }
 
-    @Override
-    public void testJavascript() throws Exception {
-        // This feature is currently only available in Nightly.
-        if (!AppConstants.NIGHTLY_BUILD) {
-            mAsserter.dumpLog(LOGTAG + " is disabled on non-Nightly builds: returning");
-            return;
-        }
-        super.testJavascript();
-    }
-
     /**
      * Observes tab change events to broadcast to the test script.
      */
     private class TabsListener implements Tabs.OnTabsChangedListener {
         @Override
         public void onTabChanged(Tab tab, Tabs.TabEvents msg, String data) {
             switch (msg) {
                 case STOP:
--- a/mobile/android/tests/browser/robocop/testAccessibleCarets.js
+++ b/mobile/android/tests/browser/robocop/testAccessibleCarets.js
@@ -13,16 +13,18 @@ const ACCESSIBLECARET_PREF = "layout.acc
 const BASE_TEST_URL = "http://mochi.test:8888/tests/robocop/testAccessibleCarets.html";
 const DESIGNMODE_TEST_URL = "http://mochi.test:8888/tests/robocop/testAccessibleCarets2.html";
 
 // Ensures Tabs are completely loaded, viewport and zoom constraints updated, etc.
 const TAB_CHANGE_EVENT = "testAccessibleCarets:TabChange";
 const TAB_STOP_EVENT = "STOP";
 
 const gChromeWin = Services.wm.getMostRecentWindow("navigator:browser");
+const gActionBarHandler = Cc["@mozilla.org/browser/browser-clh;1"]
+    .getService().wrappedJSObject.ActionBarHandler;
 
 /**
  * Wait for and return, when an expected tab change event occurs.
  *
  * @param tabId, The id of the target tab we're observing.
  * @param eventType, The event type we expect.
  * @return {Promise}
  * @resolves The tab change object, including the matched tab id and event.
@@ -110,43 +112,42 @@ function getLongPressResult(browser, mid
   // AccessibleCarets expect longtap between touchstart/end.
   domWinUtils.sendTouchEventToWindow("touchstart", [0], [midPoint.x], [midPoint.y],
                                      [1], [1], [0], [1], 1, 0);
   domWinUtils.sendMouseEventToWindow("mouselongtap", midPoint.x, midPoint.y,
                                      0, 1, 0);
   domWinUtils.sendTouchEventToWindow("touchend", [0], [midPoint.x], [midPoint.y],
                                      [1], [1], [0], [1], 1, 0);
 
-  let ActionBarHandler = gChromeWin.ActionBarHandler;
-  return { focusedElement: ActionBarHandler._targetElement,
-           text: ActionBarHandler._getSelectedText(),
-           selectionID: ActionBarHandler._selectionID,
+  return { focusedElement: gActionBarHandler._targetElement,
+           text: gActionBarHandler._getSelectedText(),
+           selectionID: gActionBarHandler._selectionID,
   };
 }
 
 /**
  * Checks the Selection UI (ActionBar or FloatingToolbar)
  * for the availability of an expected action.
  *
  * @param expectedActionID, The Selection UI action we expect to be available.
  * @return Result boolean.
  */
 function UIhasActionByID(expectedActionID) {
-  let actions = gChromeWin.ActionBarHandler._actionBarActions;
+  let actions = gActionBarHandler._actionBarActions;
   return actions.some(action => {
     return action.id === expectedActionID;
   });
 }
 
 /**
  * Messages the ActionBarHandler to close the Selection UI.
  */
 function closeSelectionUI() {
   gChromeWin.WindowEventDispatcher.dispatch("TextSelection:End",
-    {selectionID: gChromeWin.ActionBarHandler._selectionID});
+    {selectionID: gActionBarHandler._selectionID});
 }
 
 /**
  * Main test method.
  */
 add_task(function* testAccessibleCarets() {
   // Wait to start loading our test page until after the initial browser tab is
   // completely loaded. This allows each tab to complete its layer initialization,