From 34c2c0e7036c49640727c62e1a7feace7cd4f112 Mon Sep 17 00:00:00 2001 From: Jim Mathies Date: Wed, 17 Jul 2013 13:43:26 -0500 Subject: [PATCH] Bug 881463 - Fix for intermittent browser_selection_textarea.js. r=rsilveira --- .../mochitest/browser_selection_textarea.html | 13 +---- .../mochitest/browser_selection_textarea.js | 57 ++++--------------- 2 files changed, 12 insertions(+), 58 deletions(-) diff --git a/browser/metro/base/tests/mochitest/browser_selection_textarea.html b/browser/metro/base/tests/mochitest/browser_selection_textarea.html index deb9b1bca6f..8864e2fbcb3 100644 --- a/browser/metro/base/tests/mochitest/browser_selection_textarea.html +++ b/browser/metro/base/tests/mochitest/browser_selection_textarea.html @@ -5,17 +5,8 @@
- +
diff --git a/browser/metro/base/tests/mochitest/browser_selection_textarea.js b/browser/metro/base/tests/mochitest/browser_selection_textarea.js index 6085129c3ae..97bd563e983 100644 --- a/browser/metro/base/tests/mochitest/browser_selection_textarea.js +++ b/browser/metro/base/tests/mochitest/browser_selection_textarea.js @@ -48,41 +48,7 @@ gTests.push({ }); 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() { @@ -90,9 +56,10 @@ gTests.push({ 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", @@ -111,8 +78,8 @@ gTests.push({ }, 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; @@ -120,15 +87,15 @@ gTests.push({ // 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; @@ -137,10 +104,6 @@ gTests.push({ 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"); }, });