Bug 895284 - Fix plus tests for caret and selection monocles appearing at the same time after a urlbar tap. r=jwilde
authorJim Mathies <jmathies@mozilla.com>
Fri, 19 Jul 2013 08:55:21 -0500
changeset 139245 d0d492aa6e63206302fe27f2e74855d0db704fed
parent 139244 c2b8067fd55c31f57cf8ef9cf00ee3f6f1e9b197
child 139246 ecd1ef725d293ac5b9dc55488b40ce18ec54e2a3
push id1890
push userryanvm@gmail.com
push dateFri, 19 Jul 2013 17:44:21 +0000
treeherderfx-team@20848adc9980 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwilde
bugs895284
milestone25.0a1
Bug 895284 - Fix plus tests for caret and selection monocles appearing at the same time after a urlbar tap. r=jwilde
browser/metro/base/content/helperui/SelectionHelperUI.js
browser/metro/base/tests/mochitest/browser_selection_urlbar.js
--- a/browser/metro/base/content/helperui/SelectionHelperUI.js
+++ b/browser/metro/base/content/helperui/SelectionHelperUI.js
@@ -839,20 +839,17 @@ var SelectionHelperUI = {
       // another input, we'll get a attachToCaret call soonish on the
       // new input.
       this.closeEditSession(false);
       return;
     }
 
     if (this._hitTestSelection(aEvent) && this._targetIsEditable) {
       // Attach to the newly placed caret position
-      this._sendAsyncMessage("Browser:CaretAttach", {
-        xPos: aEvent.clientX,
-        yPos: aEvent.clientY
-      });
+      this.attachToCaret(this._msgTarget, aEvent.clientX, aEvent.clientY);
       return;
     }
 
     // A tap within an editable but outside active selection, clear the
     // selection and flip back to caret mode.
     if (this.startMark.visible && pointInTargetElement &&
         this._targetIsEditable) {
       this._transitionFromSelectionToCaret(clientCoords.x, clientCoords.y);
--- a/browser/metro/base/tests/mochitest/browser_selection_urlbar.js
+++ b/browser/metro/base/tests/mochitest/browser_selection_urlbar.js
@@ -83,16 +83,47 @@ gTests.push({
 
     ok(ContextMenuUI._menuPopup._visible, "is visible");
     let paste = document.getElementById("context-paste");
     ok(!paste.hidden, "paste item is visible");
 
     sendElementTap(window, paste);
     ok(edit.popup.popupOpen, "bug: popup should be showing");
 
+    clearSelection(edit);
+    delete window.r;
+  }
+});
+
+gTests.push({
+  desc: "bug 895284 - tap selection",
+  run: function bug887120_test() {
+    gWindow = window;
+
+    yield showNavBar();
+    let edit = document.getElementById("urlbar-edit");
+    edit.value = "wikipedia.org";
+    edit.select();
+
+    let editCoords = logicalCoordsForElement(edit);
+    SelectionHelperUI.attachEditSession(ChromeSelectionHandler, editCoords.x, editCoords.y);
+
+    ok(SelectionHelperUI.isSelectionUIVisible, "selection enabled");
+
+    let selection = edit.QueryInterface(Components.interfaces.nsIDOMXULTextBoxElement)
+                        .editor.selection;
+    let rects = selection.getRangeAt(0).getClientRects();
+    let midX = Math.ceil(((rects[0].right - rects[0].left) * .5) + rects[0].left);
+    let midY = Math.ceil(((rects[0].bottom - rects[0].top) * .5) + rects[0].top);
+
+    sendTap(window, midX, midY);
+
+    ok(SelectionHelperUI.isCaretUIVisible, "caret browsing enabled");
+
+    clearSelection(edit);
     delete window.r;
   }
 });
 
 function test() {
   if (!isLandscapeMode()) {
     todo(false, "browser_selection_tests need landscape mode to run.");
     return;