Bug 1436248 - Don't use selectionchange event in browser-chrome test since it's not standardized yet whether it should be fired on <input> and <textarea> r?enndeakin+6102 draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 07 Feb 2018 14:44:09 +0900
changeset 751949 bac2a418dddd392a827188ad02923043ccd6ff3c
parent 751948 3c9e125c6b58d71c241aa7aaf3e249ca14064e18
child 751950 8062ae3f6cb917d3933502ed9cc872a79d0d5a7c
child 751952 3c16304e05c72d01172a9306074882d45e097e3e
push id98100
push usermasayuki@d-toybox.com
push dateWed, 07 Feb 2018 07:33:08 +0000
reviewersenndeakin
bugs1436248
milestone60.0a1
Bug 1436248 - Don't use selectionchange event in browser-chrome test since it's not standardized yet whether it should be fired on <input> and <textarea> r?enndeakin+6102 In current draft, selectionchange event should be fired when Selection is changed in Document. However, selection of <input> and <textarea> is different from Selection in web standards (although our implementation uses Selection). So, we should check it with SimpleText.executeSoon() for now since it might be possible that selectionchange event in <input> and <textarea> would be removed completely. MozReview-Commit-ID: APvMwbysDzs
dom/events/test/browser_shortcutkey_modifier_conflicts_with_content_accesskey_modifier.js
--- a/dom/events/test/browser_shortcutkey_modifier_conflicts_with_content_accesskey_modifier.js
+++ b/dom/events/test/browser_shortcutkey_modifier_conflicts_with_content_accesskey_modifier.js
@@ -41,22 +41,27 @@ add_task(async function() {
                gURLBar.inputField.selectionEnd === gURLBar.inputField.value.length;
       }
       if (isAllTextSelected()) {
         ok(true, "All text of the URL bar is already selected");
         isnot(gURLBar.inputField.value, "", "The URL bar should have non-empty text");
         resolve();
         return;
       }
-      info("Waiting selectionchange event...");
-      gURLBar.addEventListener("selectionchange", () => {
-        ok(isAllTextSelected(), "All text of the URL bar should be selected");
+      info("Waiting selection changes...");
+      function tryToCheckItLater() {
+        if (!isAllTextSelected()) {
+          SimpleTest.executeSoon(tryToCheckItLater);
+          return;
+        }
+        ok(true, "All text of the URL bar should be selected");
         isnot(gURLBar.inputField.value, "", "The URL bar should have non-empty text");
         resolve();
-      }, {once: true});
+      }
+      SimpleTest.executeSoon(tryToCheckItLater);
     });
   }
 
   // Alt + D is a shortcut key to move focus to the URL bar and selects its text.
   info("Pressing Alt + D in the search bar...");
   EventUtils.synthesizeKey("d", {code: "KeyD", altKey: true});
 
   await promiseURLBarHasFocus();