Bug 1691623 - Wait for text attr change event that precedes misspelled attribute. r=morgan.
authorEitan Isaacson <eitan@monotonous.org>
Wed, 10 Feb 2021 20:04:41 +0000
changeset 566874 1ec6b59582191930543cf910b06cc4a3f4ac8f29
parent 566873 814173dab881adcd65f669e57155899392c90c7e
child 566875 8fe0f90430d40537a327faf0f8e732f0c1c3bd9e
push id38191
push userbtara@mozilla.com
push dateThu, 11 Feb 2021 05:02:45 +0000
treeherdermozilla-central@5cbcb80f72bd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmorgan
bugs1691623
milestone87.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 1691623 - Wait for text attr change event that precedes misspelled attribute. r=morgan. Differential Revision: https://phabricator.services.mozilla.com/D104727
accessible/tests/browser/mac/browser_attributed_text.js
--- a/accessible/tests/browser/mac/browser_attributed_text.js
+++ b/accessible/tests/browser/mac/browser_attributed_text.js
@@ -66,21 +66,32 @@ addAccessibleTask(
 
 // Test misspelling in text area
 addAccessibleTask(
   `<textarea id="t">hello worlf</textarea>`,
   async (browser, accDoc) => {
     let textArea = getNativeInterface(accDoc, "t");
     let spellDone = waitForEvent(EVENT_TEXT_ATTRIBUTE_CHANGED, "t");
     textArea.setAttributeValue("AXFocused", true);
-    await spellDone;
+
+    let attributedText = [];
 
-    let range = textArea.getAttributeValue("AXVisibleCharacterRange");
+    // For some internal reason we get several text attribute change events
+    // before the attributed text returned provides the misspelling attributes.
+    while (true) {
+      await spellDone;
 
-    let attributedText = textArea.getParameterizedAttributeValue(
-      "AXAttributedStringForRange",
-      NSRange(...range)
-    );
+      let range = textArea.getAttributeValue("AXVisibleCharacterRange");
+      attributedText = textArea.getParameterizedAttributeValue(
+        "AXAttributedStringForRange",
+        NSRange(...range)
+      );
 
-    is(attributedText.length, 2);
+      if (attributedText.length != 2) {
+        spellDone = waitForEvent(EVENT_TEXT_ATTRIBUTE_CHANGED, "t");
+      } else {
+        break;
+      }
+    }
+
     ok(attributedText[1].AXMarkedMisspelled);
   }
 );