Bug 881463 - Fix for intermittent browser_selection_textarea.js. r=rsilveira
authorJim Mathies <jmathies@mozilla.com>
Wed, 17 Jul 2013 13:43:26 -0500
changeset 138946 563493c995b38f3ad93cfb2e4349258ab505d3d6
parent 138945 0acd7501dc409c430cac7367f4f6660c5dcbad9a
child 138947 27857f7ab7d75ccb04abc970cf7cd8455c060e18
push id24977
push userryanvm@gmail.com
push dateFri, 19 Jul 2013 00:35:38 +0000
treeherdermozilla-central@0d0263a58f06 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrsilveira
bugs881463
milestone25.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
Bug 881463 - Fix for intermittent browser_selection_textarea.js. r=rsilveira
browser/metro/base/tests/mochitest/browser_selection_textarea.html
browser/metro/base/tests/mochitest/browser_selection_textarea.js
--- a/browser/metro/base/tests/mochitest/browser_selection_textarea.html
+++ b/browser/metro/base/tests/mochitest/browser_selection_textarea.html
@@ -1,21 +1,12 @@
 <!DOCTYPE html>
 <html>
   <head>
   </head>
 <body>
 <form action="texarea.html">
 <div style="margin-left: 250px;">
-<textarea wrap="on" style="width:800px; height:100px; overflow:scroll;" id="inputtext">
-Alice was beginning to get very tired of sitting by her sister on the bank, and of having
-nothing to do: once or twice she had peeped into the book her sister was reading, but it
-had no pictures or conversations in it, `and what is the use of a book,' thought Alice
-`without pictures or conversation?'
-
-Either the well was very deep, or she fell very slowly, for she had plenty of time as she
-went down to look about her and to wonder what was going to happen next. First, she tried
-to look down and make out what she was coming to, but it was too dark to see anything;
-then she looked at the sides of the well, and noticed that they were filled with cupboards
-and book-shelves;(end)</textarea>
+<textarea wrap="on" style="width:400px; height:75px; overflow:scroll;" id="inputtext">
+Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, `and what is the use of a book,' thought Alice `without pictures or conversation?'(end)</textarea>
 </div>
 </body>
 </html>
--- a/browser/metro/base/tests/mochitest/browser_selection_textarea.js
+++ b/browser/metro/base/tests/mochitest/browser_selection_textarea.js
@@ -43,61 +43,28 @@ gTests.push({
 
     yield hideContextUI();
 
     gWindow = Browser.selectedTab.browser.contentWindow;
   },
 });
 
 gTests.push({
-  desc: "textarea basic selection",
-  setUp: setUpAndTearDown,
-  tearDown: setUpAndTearDown,
-  run: function test() {
-    let textarea = gWindow.document.getElementById("inputtext");
-    textarea.focus();
-
-    let promise = waitForEvent(document, "popupshown");
-    sendContextMenuClick(355, 50);
-    yield promise;
-
-    checkContextUIMenuItemVisibility(["context-select",
-                                      "context-select-all"]);
-
-    let menuItem = document.getElementById("context-select");
-    ok(menuItem, "menu item exists");
-    ok(!menuItem.hidden, "menu item visible");
-    let popupPromise = waitForEvent(document, "popuphidden");
-    sendElementTap(gWindow, menuItem);
-    yield popupPromise;
-    ok(popupPromise && !(popupPromise instanceof Error), "promise error");
-
-    yield waitForCondition(function () {
-        return SelectionHelperUI.isSelectionUIVisible;
-      }, kCommonWaitMs, kCommonPollMs);
-
-    // check text selection
-    is(getTrimmedSelection(textarea).toString(), "pictures", "selection test");
-
-    clearSelection(textarea);
-  },
-});
-
-gTests.push({
-  desc: "textarea complex drag selection",
+  desc: "textarea selection and drag",
   setUp: setUpAndTearDown,
   tearDown: setUpAndTearDown,
   run: function test() {
     // work around for buggy context menu display
     yield waitForMs(100);
 
     let textarea = gWindow.document.getElementById("inputtext");
+    textarea.focus();
 
     let promise = waitForEvent(document, "popupshown");
-    sendContextMenuClick(355, 50);
+    sendContextMenuClickToElement(gWindow, textarea, 20, 10);
     yield promise;
 
     checkContextUIMenuItemVisibility(["context-select",
                                       "context-select-all"]);
 
     let menuItem = document.getElementById("context-select");
     ok(menuItem, "menu item exists");
     ok(!menuItem.hidden, "menu item visible");
@@ -106,46 +73,42 @@ gTests.push({
     yield popupPromise;
     ok(popupPromise && !(popupPromise instanceof Error), "promise error");
 
     yield waitForCondition(function () {
         return SelectionHelperUI.isSelectionUIVisible;
       }, kCommonWaitMs, kCommonPollMs);
 
     is(SelectionHelperUI.isActive, true, "selection active");
-    is(getTrimmedSelection(textarea).toString(), "pictures", "selection test");
-
+    is(getTrimmedSelection(textarea).toString(), "Alice", "selection test");
+
     let xpos = SelectionHelperUI.endMark.xPos;
     let ypos = SelectionHelperUI.endMark.yPos + 10;
 
     var touchdrag = new TouchDragAndHold();
 
     // end marker and off the text area to the right
     yield touchdrag.start(gWindow, xpos, ypos, 1200, 400);
-    let textLength = getTrimmedSelection(textarea).toString().length;
+    let token = "(end)";
     yield waitForCondition(function () {
-      let newTextLength = getTrimmedSelection(textarea).toString().length;
-      if (textLength != newTextLength) {
-        textLength = newTextLength;
+      let selection = getTrimmedSelection(textarea).toString();
+      if (selection.length < token.length ||
+          selection.substring(selection.length - token.length) != token) {
         return false;
       }
       return true;
-    }, 45000, 1000);
+    }, 5000, 100);
 
     touchdrag.end();
     touchdrag = null;
 
     yield waitForCondition(function () {
         return !SelectionHelperUI.hasActiveDrag;
       }, kCommonWaitMs, kCommonPollMs);
     yield SelectionHelperUI.pingSelectionHandler();
-
-    let text = getTrimmedSelection(textarea).toString();
-    let end = text.substring(text.length - "(end)".length);
-    is(end, "(end)", "selection test");
   },
 });
 
 function test() {
   if (!isLandscapeMode()) {
     todo(false, "browser_selection_tests need landscape mode to run.");
     return;
   }