Bug 1322385 Part 2: Add a test that RDM content triggers typeahead find correctly. r=gl
authorBrad Werth <bwerth@mozilla.com>
Thu, 16 May 2019 18:12:37 +0000
changeset 474233 b38eabe183170953e88e5a91d367ca2eb044e62f
parent 474232 c3954692e846bb23528d8838ff736977e0e678f5
child 474234 1256739720ca8dca77a035c72d8e62977d90a990
push id113144
push usershindli@mozilla.com
push dateFri, 17 May 2019 16:44:55 +0000
treeherdermozilla-inbound@f4c4b796f845 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl
bugs1322385
milestone68.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 1322385 Part 2: Add a test that RDM content triggers typeahead find correctly. r=gl Differential Revision: https://phabricator.services.mozilla.com/D29085
devtools/client/responsive.html/test/browser/browser.ini
devtools/client/responsive.html/test/browser/browser_typeahead_find.js
--- a/devtools/client/responsive.html/test/browser/browser.ini
+++ b/devtools/client/responsive.html/test/browser/browser.ini
@@ -69,15 +69,17 @@ skip-if = true # Bug 1413765
 [browser_toolbox_rule_view.js]
 [browser_toolbox_rule_view_reload.js]
 skip-if = os == "linux" || os == "mac" # Bug 1498336
 [browser_toolbox_swap_browsers.js]
 [browser_toolbox_swap_inspector.js]
 [browser_touch_device.js]
 [browser_touch_does_not_trigger_hover_states.js]
 [browser_touch_simulation.js]
+[browser_typeahead_find.js]
+fail-if = true # Bug 1547783
 [browser_user_agent_input.js]
 [browser_viewport_basics.js]
 [browser_viewport_resizing_fixed_width.js]
 [browser_viewport_resizing_fixed_width_and_zoom.js]
 [browser_viewport_resizing_scrollbar.js]
 fail-if = true # Bug 1547101
 [browser_window_close.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/responsive.html/test/browser/browser_typeahead_find.js
@@ -0,0 +1,75 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+/**
+ * This test attempts to exercise automatic triggering of typeaheadfind
+ * within RDM content. It does this by simulating keystrokes while
+ * various elements in the RDM content are focused.
+
+ * The test currently does not work due to two reasons:
+ * 1) The simulated key events do not behave the same as real key events.
+ *    Specifically, when this test is run on an un-patched build, it
+ *    fails to trigger typeaheadfind when the input element is focused.
+ * 2) In order to test that typeahead find has or has not occurred, this
+ *    test checks the values held by the findBar associated with the
+ *    tab that contains the RDM pane. That findBar has no values, though
+ *    they appear correctly when the steps are run interactively. This
+ *    indicates that some other findBar is receiving the typeaheadfind
+ *    characters.
+ */
+
+const TEST_URL = "data:text/html;charset=utf-8," +
+  "<body id=\"body\"><input id=\"input\" type=\"text\"/><p>text</body>";
+
+addRDMTask(TEST_URL, async function({ ui, manager }) {
+  // Turn on the pref that allows meta viewport support.
+  await pushPref("accessibility.typeaheadfind", true);
+
+  const store = ui.toolWindow.store;
+
+  // Wait until the viewport has been added.
+  await waitUntilState(store, state => state.viewports.length == 1);
+
+  const browser = ui.getViewportBrowser();
+
+  info("--- Starting test output ---");
+
+  const expected = [
+    {
+      id: "body",
+      findTriggered: true,
+    },
+    {
+      id: "input",
+      findTriggered: false,
+    },
+  ];
+
+  for (const e of expected) {
+    await ContentTask.spawn(browser, { e }, async function(args) {
+      const { e: values } = args;
+      const element = content.document.getElementById(values.id);
+
+      // Set focus on the desired element.
+      element.focus();
+    });
+
+    // Press the 'T' key and see if find is triggered.
+    await BrowserTestUtils.synthesizeKey("t", {}, browser);
+
+    const findBar = await gBrowser.getFindBar();
+
+    const findIsTriggered = (findBar._findField.value == "t");
+    is(findIsTriggered, e.findTriggered, "Text input with focused element " + e.id +
+      " should " + (e.findTriggered ? "" : "not ") + "trigger find.");
+    findBar._findField.value = "";
+
+    await ContentTask.spawn(browser, {}, async function() {
+      // Clear focus.
+      content.document.activeElement.blur();
+    });
+  }
+});