From cf83ee7bb48cc7183371231f83f991e1c6d09fca Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Thu, 15 Feb 2018 04:15:39 +0900 Subject: [PATCH] Bug 1438157 - part 2: Remove unnecessary second argument of EventUtils.synthesizeKey() r=smaug Note that this patch also replaces legacy VK_* with KEY_*, and replaces synthesizeKey() for inputting some characters with sendString() because it's better and clearer what it does and it sets shiftKey state properly. MozReview-Commit-ID: De4enbjux3T --HG-- extra : rebase_source : 2296b84bff8e22f01eeb48cd8614fac5db11136a --- .../browser/general/browser_test_urlbar.js | 2 +- accessible/tests/mochitest/events.js | 8 +- .../mochitest/events/test_contextmenu.html | 4 +- .../events/test_focus_autocomplete.xul | 6 +- .../mochitest/events/test_fromUserInput.html | 4 +- .../tests/mochitest/events/test_menu.xul | 12 +- .../tests/mochitest/events/test_text.html | 6 +- .../tests/mochitest/states/test_inputs.html | 2 +- .../mochitest/treeupdate/test_contextmenu.xul | 8 +- .../mochitest/treeupdate/test_menubutton.xul | 2 +- .../content/test/forms/browser_selectpopup.js | 32 +- .../test/forms/browser_selectpopup_colors.js | 2 +- .../content/test/general/browser_bug432599.js | 10 +- .../content/test/general/browser_bug553455.js | 2 +- .../content/test/general/browser_bug555767.js | 2 +- .../browser_domFullscreen_fullscreenMode.js | 4 +- .../test/general/browser_focusonkeydown.js | 2 +- .../general/browser_keywordBookmarklets.js | 2 +- .../test/general/browser_keywordSearch.js | 2 +- .../general/browser_keywordSearch_postData.js | 2 +- .../test/general/browser_printpreview.js | 6 +- .../content/test/general/browser_tabfocus.js | 6 +- .../general/browser_visibleFindSelection.js | 12 +- .../test/general/browser_zbug569342.js | 6 +- .../content/test/general/contentSearchUI.js | 8 +- .../test/newtab/browser_newtab_focus.js | 2 +- .../test/newtab/browser_newtab_search.js | 6 +- .../test/permissions/browser_reservedkey.js | 18 +- .../browser_popupNotification_keyboard.js | 12 +- .../browser_popupNotification_no_anchors.js | 18 +- .../content/test/popupNotifications/head.js | 8 +- .../browser_identityPopup_focus.js | 2 +- .../browser_action_searchengine_alias.js | 2 +- .../urlbar/browser_autocomplete_autoselect.js | 18 +- .../urlbar/browser_autocomplete_cursor.js | 2 +- .../browser_autocomplete_edit_completed.js | 6 +- .../urlbar/browser_autocomplete_enter_race.js | 18 +- .../browser_bug1003461-switchtab-override.js | 10 +- ...er_bug1024133-switchtab-override-keynav.js | 10 +- .../content/test/urlbar/browser_bug1070778.js | 8 +- .../browser_bug1104165-switchtab-decodeuri.js | 4 +- .../urlbar/browser_bug1225194-remotetab.js | 2 +- .../content/test/urlbar/browser_bug304198.js | 2 +- .../test/urlbar/browser_canonizeURL.js | 4 +- .../test/urlbar/browser_locationBarCommand.js | 6 +- .../urlbar/browser_locationBarExternalLoad.js | 7 +- .../urlbar/browser_urlbarAutoFillTrimURLs.js | 4 +- .../test/urlbar/browser_urlbarDelete.js | 6 +- .../test/urlbar/browser_urlbarEnter.js | 4 +- .../browser_urlbarEnterAfterMouseOver.js | 6 +- .../test/urlbar/browser_urlbarOneOffs.js | 44 +-- ...browser_urlbarOneOffs_searchSuggestions.js | 20 +- .../test/urlbar/browser_urlbarRevert.js | 2 +- .../urlbar/browser_urlbarSearchSuggestions.js | 8 +- ...browser_urlbarSearchSuggestions_opt-out.js | 4 +- .../browser_urlbar_autoFill_backspaced.js | 24 +- .../browser_urlbar_canonize_on_autofill.js | 12 +- ...r_urlbar_locationchange_urlbar_edit_dos.js | 2 +- .../urlbar/browser_urlbar_remove_match.js | 4 +- .../urlbar/browser_urlbar_searchsettings.js | 2 +- .../test/browser_901207_searchbar_in_panel.js | 10 +- ...ser_940307_panel_click_closure_handling.js | 2 +- ...wser_984455_bookmarks_items_reparenting.js | 2 +- ...browser_panelUINotifications_fullscreen.js | 4 +- ...ifications_fullscreen_noAutoHideToolbar.js | 4 +- .../test/browser_panel_keyboard_navigation.js | 38 +-- .../test/browser/browser_ext_omnibox.js | 38 +-- .../browser/browser_bookmarklet_windowOpen.js | 2 +- .../tests/browser/browser_stayopenmenu.js | 4 +- .../browser_toolbarbutton_menu_context.js | 2 +- .../test_editBookmarkOverlay_keywords.xul | 4 +- ...vent_scrolling_when_preferences_flipped.js | 14 +- .../tests/browser_cookies_dialog.js | 4 +- .../tests/browser_password_management.js | 4 +- .../tests/browser_site_login_exceptions.js | 4 +- .../components/search/test/browser_426329.js | 6 +- .../search/test/browser_google_behavior.js | 8 +- .../search/test/browser_healthreport.js | 2 +- .../test/browser_hiddenOneOffs_diacritics.js | 2 +- .../search/test/browser_oneOffContextMenu.js | 2 +- .../browser_oneOffContextMenu_setDefault.js | 4 +- .../search/test/browser_oneOffHeader.js | 2 +- .../test/browser_searchEngine_behaviors.js | 8 +- .../browser_searchbar_keyboard_navigation.js | 86 +++--- .../test/browser_searchbar_openpopup.js | 32 +- ...earchbar_smallpanel_keyboard_navigation.js | 60 ++-- .../test/browser_tooManyEnginesOffered.js | 8 +- .../sessionstore/test/browser_522545.js | 2 +- .../test/mochitest/formautofill_common.js | 6 +- .../test/mochitest/test_autofocus_form.html | 2 +- .../test_basic_autocomplete_form.html | 26 +- ...st_basic_creditcard_autocomplete_form.html | 24 +- .../test/mochitest/test_clear_form.html | 10 +- .../test_creditcard_autocomplete_off.html | 8 +- .../test/mochitest/test_form_changes.html | 6 +- .../test_formautofill_preview_highlight.html | 8 +- .../test_multi_locale_CA_address_form.html | 18 +- .../test/mochitest/test_multiple_forms.html | 6 +- .../mochitest/test_on_address_submission.html | 8 +- .../browser_UsageTelemetry_searchbar.js | 16 +- .../browser/browser_UsageTelemetry_urlbar.js | 18 +- .../formValidation/browser_form_validation.js | 8 +- ..._dbg_instruments-pane-collapse_keyboard.js | 8 +- .../browser_dbg_paused-keybindings.js | 5 +- .../browser_dbg_split-console-keypress.js | 20 +- ...rowser_dbg_variables-view-accessibility.js | 154 +++++----- .../browser_dbg_variables-view-popup-17.js | 2 +- .../client/framework/test/browser_menu_api.js | 8 +- .../browser_toolbox_keyboard_navigation.js | 22 +- .../test/browser_boxmodel_navigation.js | 30 +- .../test/browser_computed_keybindings_02.js | 8 +- .../test/browser_markup_keybindings_04.js | 4 +- .../markup/test/browser_markup_load_01.js | 2 +- .../markup/test/browser_markup_navigation.js | 160 +++++----- .../browser_rules_add-property-cancel_03.js | 2 +- .../browser_rules_add-rule-edit-selector.js | 2 +- ...es_add-rule-then-property-edit-selector.js | 2 +- .../test/browser_rules_add-rule-with-menu.js | 2 +- .../browser_rules_edit-property-computed.js | 2 +- .../test/browser_rules_edit-property_08.js | 2 +- ..._rules_edit-selector-click-on-scrollbar.js | 2 +- .../test/browser_rules_edit-selector_01.js | 2 +- .../test/browser_rules_edit-selector_02.js | 2 +- .../test/browser_rules_edit-selector_03.js | 2 +- .../test/browser_rules_edit-selector_04.js | 2 +- .../test/browser_rules_edit-selector_05.js | 2 +- .../test/browser_rules_edit-selector_06.js | 4 +- .../test/browser_rules_edit-selector_07.js | 2 +- .../test/browser_rules_edit-selector_08.js | 4 +- .../test/browser_rules_edit-selector_09.js | 8 +- .../test/browser_rules_edit-selector_10.js | 4 +- .../test/browser_rules_edit-selector_11.js | 4 +- .../test/browser_rules_edit-selector_12.js | 4 +- .../browser_rules_editable-field-focus_01.js | 6 +- .../rules/test/browser_rules_livepreview.js | 4 +- .../test/browser_rules_mark_overridden_06.js | 2 +- ...er_rules_search-filter-computed-list_04.js | 2 +- .../test/browser_rules_search-filter_07.js | 4 +- .../test/browser_rules_search-filter_08.js | 2 +- devtools/client/inspector/rules/test/head.js | 2 +- ...yleinspector_context-menu-copy-color_02.js | 2 +- ...rowser_inspector_breadcrumbs_keybinding.js | 14 +- ...owser_inspector_delete-selected-node-02.js | 4 +- ...pector_highlighter-eyedropper-clipboard.js | 2 +- .../browser_inspector_keyboard-shortcuts.js | 14 +- ...owser_inspector_menu-05-attribute-items.js | 10 +- .../test/browser_net_filter-autocomplete.js | 24 +- .../test/browser/browser_device_width.js | 6 +- .../test/browser/browser_toolbox_rule_view.js | 2 +- .../test_searchbox-with-autocomplete.html | 28 +- .../webpack/shims/test/test_clipboard.html | 2 +- .../browser_storage_cookies_edit_keyboard.js | 14 +- devtools/client/storage/test/head.js | 6 +- .../browser_styleeditor_syncEditSelector.js | 2 +- .../mochitest/browser_jsterm_accessibility.js | 2 +- ...wser_jsterm_add_edited_input_to_history.js | 16 +- ...wser_jsterm_autocomplete_array_no_index.js | 4 +- ..._jsterm_autocomplete_crossdomain_iframe.js | 4 +- .../browser_jsterm_autocomplete_escape_key.js | 4 +- ...browser_jsterm_autocomplete_inside_text.js | 6 +- ...wser_jsterm_autocomplete_native_getters.js | 6 +- ...ser_jsterm_autocomplete_nav_and_tab_key.js | 20 +- .../browser_jsterm_autocomplete_return_key.js | 11 +- ...rm_autocomplete_return_key_no_selection.js | 8 +- .../mochitest/browser_jsterm_ctrl_key_nav.js | 26 +- .../mochitest/browser_jsterm_history_nav.js | 4 +- .../browser_jsterm_history_persist.js | 2 +- .../browser_jsterm_input_expansion.js | 4 +- ..._no_autocompletion_on_defined_variables.js | 9 +- ...ser_jsterm_no_input_and_tab_key_pressed.js | 4 +- ...erm_no_input_change_and_tab_key_pressed.js | 10 +- ...rowser_jsterm_popup_close_on_tab_switch.js | 2 +- .../test/mochitest/browser_jsterm_selfxss.js | 2 +- .../browser_webconsole_close_sidebar.js | 2 +- .../browser_webconsole_filter_scroll.js | 8 +- .../browser_webconsole_history_arrow_keys.js | 32 +- ...owser_webconsole_keyboard_accessibility.js | 8 +- ..._865871_variables_view_close_on_esc_key.js | 4 +- .../test/browser_console_history_persist.js | 2 +- .../browser_console_keyboard_accessibility.js | 14 +- ...r_webconsole_autocomplete_accessibility.js | 2 +- ...ser_webconsole_autocomplete_and_selfxss.js | 2 +- ...console_autocomplete_crossdomain_iframe.js | 4 +- ..._autocomplete_popup_close_on_tab_switch.js | 2 +- ...bug_583816_No_input_and_Tab_key_pressed.js | 4 +- ...webconsole_bug_585991_autocomplete_keys.js | 61 ++-- ...r_webconsole_bug_588967_input_expansion.js | 4 +- ...ebconsole_bug_594497_history_arrow_keys.js | 60 ++-- ...r_webconsole_bug_613642_maintain_scroll.js | 4 +- ...e_bug_651501_document_body_autocomplete.js | 6 +- ...owser_webconsole_bug_660806_history_nav.js | 4 +- .../test/browser_webconsole_bug_704295.js | 9 +- ...061_No_input_change_and_Tab_key_pressed.js | 10 +- ...wser_webconsole_bug_804845_ctrl_key_nav.js | 76 ++--- ..._bug_817834_add_edited_input_to_history.js | 16 +- .../browser_webconsole_js_input_expansion.js | 6 +- .../browser/browser_uriFixupIntegration.js | 2 +- dom/events/test/bug299673.js | 4 +- dom/events/test/test_bug1305458.html | 4 +- dom/events/test/test_bug450876.html | 2 +- dom/events/test/test_dom_keyboard_event.html | 2 +- dom/events/test/window_bug1369072.html | 4 +- dom/html/test/browser_fullscreen-api-keys.js | 18 +- .../browser_fullscreen-contextmenu-esc.js | 4 +- dom/html/test/file_fullscreen-denied.html | 2 +- .../test/file_fullscreen-esc-exit-inner.html | 2 +- dom/html/test/file_fullscreen-selector.html | 2 +- dom/html/test/forms/test_bug1283915.html | 12 +- dom/html/test/forms/test_bug1286509.html | 8 +- dom/html/test/forms/test_change_event.html | 77 +++-- .../test/forms/test_formaction_attribute.html | 8 +- .../forms/test_formnovalidate_attribute.html | 2 +- .../test/forms/test_input_date_bad_input.html | 6 +- .../forms/test_input_date_key_events.html | 40 +-- ...test_input_datetime_focus_blur_events.html | 8 +- ...st_input_datetime_input_change_events.html | 5 +- .../forms/test_input_datetime_tabindex.html | 8 +- dom/html/test/forms/test_input_event.html | 24 +- .../test/forms/test_input_file_picker.html | 2 +- .../forms/test_input_number_key_events.html | 22 +- .../test_input_number_placeholder_shown.html | 2 +- .../forms/test_input_number_rounding.html | 16 +- .../forms/test_input_range_key_events.html | 48 +-- ...st_input_range_mouse_and_touch_events.html | 10 +- .../test/forms/test_input_range_rounding.html | 16 +- ...st_input_textarea_set_value_no_scroll.html | 2 +- .../forms/test_input_time_key_events.html | 46 +-- .../test_input_time_sec_millisec_field.html | 2 +- .../test/forms/test_maxlength_attribute.html | 4 +- .../test/forms/test_minlength_attribute.html | 4 +- .../test/forms/test_novalidate_attribute.html | 2 +- dom/html/test/forms/test_radio_in_label.html | 4 +- .../test/forms/test_select_change_event.html | 8 +- .../forms/test_select_input_change_event.html | 26 +- dom/html/test/test_bug1045270.html | 4 +- dom/html/test/test_bug1230665.html | 4 +- dom/html/test/test_bug386996.html | 2 +- dom/html/test/test_bug406596.html | 8 +- dom/html/test/test_bug460568.html | 2 +- dom/html/test/test_bug535043.html | 2 +- dom/html/test/test_bug556645.html | 4 +- dom/html/test/test_bug557087-4.html | 2 +- dom/html/test/test_bug558788-1.html | 28 +- dom/html/test/test_bug558788-2.html | 4 +- dom/html/test/test_bug561636.html | 2 +- dom/html/test/test_bug566046.html | 8 +- dom/html/test/test_bug582412-1.html | 12 +- dom/html/test/test_bug582412-2.html | 12 +- dom/html/test/test_bug605124-2.html | 8 +- dom/html/test/test_bug605125-2.html | 12 +- dom/html/test/test_bug613019.html | 8 +- dom/html/test/test_bug613979.html | 4 +- dom/html/test/test_bug615833.html | 6 +- dom/html/test/test_bug618948.html | 2 +- dom/html/test/test_bug619278.html | 2 +- dom/html/test/test_bug622597.html | 2 +- dom/html/test/test_bug633058.html | 16 +- dom/html/test/test_bug651956.html | 2 +- dom/html/test/test_ignoreuserfocus.html | 2 +- dom/html/test/test_object_plugin_nav.html | 4 +- dom/indexedDB/test/head.js | 2 +- .../test/mochitest/browser_pluginscroll.js | 8 +- dom/svg/test/test_tabindex.html | 10 +- .../browser_cancel_keydown_keypress_event.js | 2 +- dom/tests/mochitest/bugs/test_bug265203.html | 30 +- dom/tests/mochitest/chrome/window_focus.xul | 52 ++-- .../mochitest/chrome/window_focus_docnav.xul | 4 +- .../general/test_bug1012662_common.js | 8 +- .../mochitest/general/test_bug1170911.html | 4 +- .../general/test_focus_scrollchildframe.html | 2 +- .../mochitest/general/test_focusrings.xul | 2 +- .../mochitest/pointerlock/file_escapeKey.html | 2 +- editor/libeditor/tests/browser_bug527935.js | 2 +- editor/libeditor/tests/test_backspace_vs.html | 12 +- editor/libeditor/tests/test_bug1094000.html | 18 +- editor/libeditor/tests/test_bug1100966.html | 6 +- editor/libeditor/tests/test_bug1109465.html | 12 +- editor/libeditor/tests/test_bug1140105.html | 2 +- editor/libeditor/tests/test_bug1154791.html | 8 +- editor/libeditor/tests/test_bug1162952.html | 2 +- editor/libeditor/tests/test_bug1248128.html | 2 +- editor/libeditor/tests/test_bug1250010.html | 18 +- editor/libeditor/tests/test_bug1257363.html | 44 +-- editor/libeditor/tests/test_bug1258085.html | 24 +- editor/libeditor/tests/test_bug1270235.html | 2 +- editor/libeditor/tests/test_bug1314790.html | 12 +- editor/libeditor/tests/test_bug1315065.html | 4 +- editor/libeditor/tests/test_bug1316302.html | 4 +- editor/libeditor/tests/test_bug1318312.html | 12 +- editor/libeditor/tests/test_bug1328023.html | 19 +- editor/libeditor/tests/test_bug1330796.html | 4 +- editor/libeditor/tests/test_bug1352799.html | 22 +- editor/libeditor/tests/test_bug1361008.html | 10 +- editor/libeditor/tests/test_bug1368544.html | 19 +- editor/libeditor/tests/test_bug1385905.html | 10 +- editor/libeditor/tests/test_bug1390562.html | 4 +- editor/libeditor/tests/test_bug1394758.html | 12 +- editor/libeditor/tests/test_bug1397412.xul | 4 +- editor/libeditor/tests/test_bug1399722.html | 8 +- editor/libeditor/tests/test_bug318065.html | 6 +- editor/libeditor/tests/test_bug332636.html | 10 +- editor/libeditor/tests/test_bug414526.html | 32 +- editor/libeditor/tests/test_bug430392.html | 20 +- editor/libeditor/tests/test_bug439808.html | 4 +- editor/libeditor/tests/test_bug449243.html | 2 +- editor/libeditor/tests/test_bug483651.html | 4 +- editor/libeditor/tests/test_bug484181.html | 5 +- editor/libeditor/tests/test_bug514156.html | 10 +- editor/libeditor/tests/test_bug537046.html | 4 +- editor/libeditor/tests/test_bug550434.html | 2 +- editor/libeditor/tests/test_bug551704.html | 13 +- editor/libeditor/tests/test_bug567213.html | 4 +- editor/libeditor/tests/test_bug570144.html | 4 +- editor/libeditor/tests/test_bug586662.html | 2 +- editor/libeditor/tests/test_bug590554.html | 4 +- editor/libeditor/tests/test_bug592592.html | 6 +- editor/libeditor/tests/test_bug596333.html | 5 +- editor/libeditor/tests/test_bug596506.html | 21 +- editor/libeditor/tests/test_bug597331.html | 2 +- editor/libeditor/tests/test_bug600570.html | 2 +- editor/libeditor/tests/test_bug604532.html | 4 +- editor/libeditor/tests/test_bug607584.html | 2 +- editor/libeditor/tests/test_bug611182.html | 2 +- editor/libeditor/tests/test_bug612447.html | 4 +- editor/libeditor/tests/test_bug625452.html | 2 +- editor/libeditor/tests/test_bug638596.html | 5 +- editor/libeditor/tests/test_bug641466.html | 5 +- editor/libeditor/tests/test_bug668599.html | 6 +- editor/libeditor/tests/test_bug674861.html | 4 +- editor/libeditor/tests/test_bug686203.html | 2 +- editor/libeditor/tests/test_bug740784.html | 6 +- editor/libeditor/tests/test_bug772796.html | 16 +- editor/libeditor/tests/test_bug790475.html | 2 +- editor/libeditor/tests/test_bug795785.html | 27 +- editor/libeditor/tests/test_bug850043.html | 14 +- ...t_contenteditable_text_input_handling.html | 10 +- .../test_dom_input_event_on_texteditor.html | 18 +- .../test_htmleditor_keyevent_handling.html | 132 ++++----- .../tests/test_inline_style_cache.html | 111 ++----- .../test_texteditor_keyevent_handling.html | 78 ++--- .../apz/test/mochitest/helper_key_scroll.html | 10 +- layout/base/tests/bug1109968-1.html | 2 +- layout/base/tests/bug1109968-2.html | 2 +- layout/base/tests/bug1123067-1.html | 4 +- layout/base/tests/bug1123067-2.html | 4 +- layout/base/tests/bug1123067-3.html | 4 +- layout/base/tests/bug1123067-ref.html | 4 +- layout/base/tests/bug1237236-1-ref.html | 2 +- layout/base/tests/bug1237236-1.html | 4 +- layout/base/tests/bug1237236-2-ref.html | 5 +- layout/base/tests/bug1258308-1-ref.html | 4 +- layout/base/tests/bug1258308-1.html | 10 +- layout/base/tests/bug1258308-2-ref.html | 9 +- layout/base/tests/bug1259949-1-ref.html | 2 +- layout/base/tests/bug1259949-1.html | 10 +- layout/base/tests/bug1259949-2-ref.html | 8 +- layout/base/tests/bug1263288.html | 2 +- layout/base/tests/bug1263357-1.html | 4 +- layout/base/tests/bug1263357-2.html | 4 +- layout/base/tests/bug1423331-2-ref.html | 4 +- layout/base/tests/bug1423331-2.html | 4 +- layout/base/tests/bug1423331-4.html | 4 +- layout/base/tests/bug597519-1.html | 7 +- layout/base/tests/bug632215-1.html | 4 +- layout/base/tests/bug632215-2.html | 4 +- layout/base/tests/bug633044-1.html | 2 +- layout/base/tests/bug634406-1.html | 6 +- layout/base/tests/bug644428-1.html | 4 +- layout/base/tests/bug646382-1.html | 6 +- layout/base/tests/bug646382-2.html | 6 +- layout/base/tests/bug664087-1-ref.html | 4 +- layout/base/tests/bug664087-1.html | 12 +- layout/base/tests/bug664087-2-ref.html | 4 +- layout/base/tests/bug664087-2.html | 12 +- layout/base/tests/bug682712-1.html | 2 +- layout/base/tests/bug746993-1.html | 2 +- layout/base/tests/bug989012-1.html | 2 +- layout/base/tests/bug989012-2.html | 2 +- layout/base/tests/bug989012-3.html | 2 +- layout/base/tests/chrome/test_bug551434.html | 4 +- .../tests/input-maxlength-invalid-change.html | 2 +- .../input-maxlength-ui-invalid-change.html | 2 +- .../input-maxlength-ui-valid-change.html | 4 +- .../tests/input-maxlength-valid-change.html | 4 +- .../tests/input-minlength-invalid-change.html | 2 +- .../input-minlength-ui-invalid-change.html | 2 +- .../input-minlength-ui-valid-change.html | 4 +- .../tests/input-minlength-valid-change.html | 4 +- layout/base/tests/test_bug332655-1.html | 11 +- layout/base/tests/test_bug332655-2.html | 32 +- layout/base/tests/test_bug370436.html | 18 +- layout/base/tests/test_bug423523.html | 8 +- layout/base/tests/test_bug499538-1.html | 21 +- layout/base/tests/test_bug582181-1.html | 8 +- layout/base/tests/test_bug582181-2.html | 12 +- layout/base/tests/test_bug644768.html | 10 +- layout/base/tests/test_bug667512.html | 4 +- layout/base/tests/test_scroll_snapping.html | 90 +++--- .../textarea-maxlength-invalid-change.html | 2 +- .../textarea-maxlength-ui-invalid-change.html | 2 +- .../textarea-maxlength-ui-valid-change.html | 4 +- .../textarea-maxlength-valid-change.html | 4 +- .../textarea-minlength-invalid-change.html | 2 +- .../textarea-minlength-ui-invalid-change.html | 2 +- .../textarea-minlength-ui-valid-change.html | 4 +- .../textarea-minlength-valid-change.html | 4 +- layout/forms/test/test_bug1305282.html | 8 +- layout/forms/test/test_bug1327129.html | 18 +- layout/forms/test/test_bug346043.html | 4 +- layout/forms/test/test_bug411236.html | 2 +- layout/forms/test/test_bug534785.html | 4 +- layout/forms/test/test_bug571352.html | 8 +- layout/forms/test/test_bug672810.html | 26 +- layout/forms/test/test_bug903715.html | 6 +- layout/forms/test/test_bug935876.html | 96 +++--- .../forms/test/test_listcontrol_search.html | 2 +- layout/generic/test/test_bug240933.html | 10 +- layout/generic/test/test_bug288789.html | 4 +- layout/generic/test/test_bug404872.html | 4 +- layout/generic/test/test_bug424627.html | 2 +- layout/generic/test/test_bug448860.html | 6 +- layout/generic/test/test_bug468167.html | 2 +- layout/generic/test/test_bug597333.html | 2 +- layout/generic/test/test_bug632379.xul | 6 +- layout/generic/test/test_bug756984.html | 25 +- layout/generic/test/test_bug784410.html | 2 +- layout/generic/test/test_bug791616.html | 2 +- layout/generic/test/test_bug904810.html | 20 +- layout/generic/test/test_bug970363.html | 6 +- .../test/test_movement_by_characters.html | 4 +- .../style/test/chrome/test_display_mode.html | 4 +- .../test/chrome/test_display_mode_reflow.html | 4 +- .../style/test/test_flexbox_focus_order.html | 2 +- layout/xul/test/browser_bug1163304.js | 6 +- .../tests/Harness_sanity/test_sanity.html | 4 +- .../Harness_sanity/test_sanityEventUtils.html | 2 +- .../browser/browser_formless_submit_chrome.js | 8 +- .../test/browser/browser_notifications_2.js | 4 +- .../test/chrome/subtst_privbrowsing_4.html | 6 +- .../test_autocomplete_https_upgrade.html | 32 +- .../test/mochitest/test_autofocus_js.html | 4 +- .../test_basic_form_autocomplete.html | 226 +++++++------- .../test/mochitest/test_case_differences.html | 28 +- ...test_insecure_form_field_autocomplete.html | 274 ++++++++--------- ...st_insecure_form_field_no_saved_login.html | 6 +- .../test_password_field_autocomplete.html | 24 +- .../satchel/test/test_bug_511615.html | 4 +- .../test/test_datalist_with_caching.html | 12 +- .../satchel/test/test_form_autocomplete.html | 278 +++++++++--------- .../test_form_autocomplete_with_list.html | 159 +++++----- .../test/test_password_autocomplete.html | 11 +- .../satchel/test/test_popup_direction.html | 2 +- .../satchel/test/test_popup_enter_event.html | 8 +- .../browser_bug295977_autoscroll_overflow.js | 2 +- .../content/tests/chrome/findbar_window.xul | 4 +- toolkit/content/tests/chrome/popup_trigger.js | 56 ++-- .../content/tests/chrome/test_arrowpanel.xul | 2 +- .../tests/chrome/test_autocomplete2.xul | 2 +- .../tests/chrome/test_autocomplete3.xul | 6 +- .../tests/chrome/test_autocomplete4.xul | 36 ++- .../tests/chrome/test_autocomplete5.xul | 8 +- .../chrome/test_autocomplete_emphasis.xul | 2 +- ...t_autocomplete_placehold_last_complete.xul | 45 ++- ...utocomplete_with_composition_on_input.html | 2 +- .../content/tests/chrome/test_bug418874.xul | 4 +- .../content/tests/chrome/test_bug792324.xul | 2 +- toolkit/content/tests/chrome/test_button.xul | 10 +- .../tests/chrome/test_closemenu_attribute.xul | 4 +- .../tests/chrome/test_colorpicker_popup.xul | 28 +- .../content/tests/chrome/test_dialogfocus.xul | 2 +- .../content/tests/chrome/test_focus_anons.xul | 12 +- .../tests/chrome/test_menulist_keynav.xul | 38 +-- .../tests/chrome/test_panelfrommenu.xul | 8 +- .../content/tests/chrome/test_popup_keys.xul | 6 +- .../content/tests/chrome/test_tabindex.xul | 2 +- .../tests/chrome/test_textbox_number.xul | 12 +- .../tests/chrome/test_textbox_search.xul | 15 +- .../tests/chrome/window_panel_focus.xul | 48 +-- .../content/tests/chrome/window_tooltip.xul | 10 +- .../test_autocomplete_change_after_focus.html | 6 +- .../tests/mochitest/test_bug1407085.html | 2 +- .../widgets/test_contextmenu_menugroup.xul | 12 +- .../tests/widgets/test_videocontrols.html | 14 +- .../test_videocontrols_keyhandler.html | 10 +- .../content/tests/widgets/window_menubar.xul | 92 +++--- .../test/browser/browser_bug562797.js | 4 +- .../browser_file_xpi_no_process_switch.js | 2 +- .../test_input_events_on_deactive_window.xul | 8 +- .../window_composition_text_querycontent.xul | 64 +--- 489 files changed, 2931 insertions(+), 3227 deletions(-) diff --git a/accessible/tests/browser/general/browser_test_urlbar.js b/accessible/tests/browser/general/browser_test_urlbar.js index 409be7078108..d02a166206d4 100644 --- a/accessible/tests/browser/general/browser_test_urlbar.js +++ b/accessible/tests/browser/general/browser_test_urlbar.js @@ -15,7 +15,7 @@ add_task(async function testAutocompleteRichResult() { urlbar.focus(); let urlbarPopup = document.getElementById("PopupAutoCompleteRichResult"); let shown = BrowserTestUtils.waitForEvent(urlbarPopup, "popupshown"); - EventUtils.synthesizeKey("a", {}); + EventUtils.sendString("a"); await shown; info("Waiting for accessibility to be created for the richlistbox"); diff --git a/accessible/tests/mochitest/events.js b/accessible/tests/mochitest/events.js index 92a802f03a8c..39e76689d047 100644 --- a/accessible/tests/mochitest/events.js +++ b/accessible/tests/mochitest/events.js @@ -1405,7 +1405,7 @@ function closeCombobox(aComboboxID) { ]; this.invoke = function closeCombobox_invoke() { - synthesizeKey("VK_ESCAPE", { }); + synthesizeKey("KEY_Escape"); }; this.getID = function closeCombobox_getID() { @@ -1459,12 +1459,12 @@ function moveToPrevLineEnd(aID, aCaretOffset) { this.__proto__ = new synthAction(aID, new caretMoveChecker(aCaretOffset, aID)); this.invoke = function moveToPrevLineEnd_invoke() { - synthesizeKey("VK_UP", { }); + synthesizeKey("KEY_ArrowUp"); if (MAC) - synthesizeKey("VK_RIGHT", { metaKey: true }); + synthesizeKey("Key_ArrowRight", {metaKey: true}); else - synthesizeKey("VK_END", { }); + synthesizeKey("KEY_End"); }; this.getID = function moveToPrevLineEnd_getID() { diff --git a/accessible/tests/mochitest/events/test_contextmenu.html b/accessible/tests/mochitest/events/test_contextmenu.html index c6d631cfff55..71f5ab62c468 100644 --- a/accessible/tests/mochitest/events/test_contextmenu.html +++ b/accessible/tests/mochitest/events/test_contextmenu.html @@ -46,7 +46,7 @@ ]; this.invoke = function selectMenuItem_invoke() { - synthesizeKey("VK_DOWN", { }); + synthesizeKey("KEY_ArrowDown"); }; this.getID = function selectMenuItem_getID() { @@ -61,7 +61,7 @@ ]; this.invoke = function closeContextMenu_invoke() { - synthesizeKey("VK_ESCAPE", { }); + synthesizeKey("KEY_Escape"); }; this.getID = function closeContextMenu_getID() { diff --git a/accessible/tests/mochitest/events/test_focus_autocomplete.xul b/accessible/tests/mochitest/events/test_focus_autocomplete.xul index 944b4b2cd96b..b6beced59de4 100644 --- a/accessible/tests/mochitest/events/test_focus_autocomplete.xul +++ b/accessible/tests/mochitest/events/test_focus_autocomplete.xul @@ -127,8 +127,8 @@ this.invoke = function removeChar_invoke() { - synthesizeKey("VK_LEFT", { shiftKey: true }); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_ArrowLeft", {shiftKey: true}); + synthesizeKey("KEY_Delete"); } this.getID = function removeChar_getID() @@ -144,7 +144,7 @@ this.invoke = function replaceOnChar_invoke() { this.DOMNode.select(); - synthesizeKey(aChar, {}); + sendString(aChar); } this.getID = function replaceOnChar_getID() diff --git a/accessible/tests/mochitest/events/test_fromUserInput.html b/accessible/tests/mochitest/events/test_fromUserInput.html index 49f4a54d4cb8..9dce7162b2df 100644 --- a/accessible/tests/mochitest/events/test_fromUserInput.html +++ b/accessible/tests/mochitest/events/test_fromUserInput.html @@ -32,7 +32,7 @@ this.DOMNode.focus(); this.DOMNode.setSelectionRange(aStart, aEnd); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Delete"); }; this.getID = function removeTextFromInput_getID() { @@ -60,7 +60,7 @@ range.setEnd(this.textNode, aEnd); selection.addRange(range); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Delete"); }; this.getID = function removeTextFromContentEditable_getID() { diff --git a/accessible/tests/mochitest/events/test_menu.xul b/accessible/tests/mochitest/events/test_menu.xul index bae36fb71239..1ba109f6d13a 100644 --- a/accessible/tests/mochitest/events/test_menu.xul +++ b/accessible/tests/mochitest/events/test_menu.xul @@ -27,7 +27,7 @@ this.invoke = function openFileMenu_invoke() { - synthesizeKey("F", { altKey: true, shiftKey: true }); + synthesizeKey("F", {altKey: true, shiftKey: true}); } this.getID = function openFileMenu_getID() @@ -46,7 +46,7 @@ this.invoke = function openEditMenu_invoke() { - synthesizeKey("VK_RIGHT", { }); + synthesizeKey("KEY_ArrowRight"); } this.getID = function openEditMenu_getID() @@ -65,7 +65,7 @@ this.invoke = function closeEditMenu_invoke() { - synthesizeKey("VK_ESCAPE", { }); + synthesizeKey("KEY_Escape"); } this.getID = function closeEditMenu_getID() @@ -83,7 +83,7 @@ this.invoke = function focusFileMenu_invoke() { - synthesizeKey("VK_ALT", { }); + synthesizeKey("KEY_Alt"); } this.getID = function focusFileMenu_getID() @@ -100,7 +100,7 @@ this.invoke = function focusEditMenu_invoke() { - synthesizeKey("VK_RIGHT", { }); + synthesizeKey("KEY_ArrowRight"); } this.getID = function focusEditMenu_getID() @@ -118,7 +118,7 @@ this.invoke = function leaveMenubar_invoke() { - synthesizeKey("VK_ESCAPE", { }); + synthesizeKey("KEY_Escape"); } this.getID = function leaveMenubar_getID() diff --git a/accessible/tests/mochitest/events/test_text.html b/accessible/tests/mochitest/events/test_text.html index cde1ed7eea60..5e1c08e3a2de 100644 --- a/accessible/tests/mochitest/events/test_text.html +++ b/accessible/tests/mochitest/events/test_text.html @@ -169,7 +169,7 @@ this.DOMNode.focus(); this.DOMNode.setSelectionRange(aStart, aEnd); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Delete"); }; this.getID = function removeTextFromInput_getID() { @@ -189,7 +189,7 @@ this.invoke = function insertTextIntoInput_invoke() { this.DOMNode.focus(); - synthesizeKey("a", {}); + sendString("a"); }; this.getID = function insertTextIntoInput_getID() { @@ -212,7 +212,7 @@ range.setEnd(this.textNode, aEnd); selection.addRange(range); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Delete"); }; this.getID = function removeTextFromEditable_getID() { diff --git a/accessible/tests/mochitest/states/test_inputs.html b/accessible/tests/mochitest/states/test_inputs.html index 3c522d9d2f06..f65cc764cbc7 100644 --- a/accessible/tests/mochitest/states/test_inputs.html +++ b/accessible/tests/mochitest/states/test_inputs.html @@ -107,7 +107,7 @@ var mininp = document.getElementById("minlength"); mininp.focus(); mininp.setSelectionRange(mininp.value.length, mininp.value.length); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); ok(!mininp.validity.valid, "input should be invalid after interactive edits"); testStates(mininp, STATE_INVALID); diff --git a/accessible/tests/mochitest/treeupdate/test_contextmenu.xul b/accessible/tests/mochitest/treeupdate/test_contextmenu.xul index 5b31e0136359..00f6870396b5 100644 --- a/accessible/tests/mochitest/treeupdate/test_contextmenu.xul +++ b/accessible/tests/mochitest/treeupdate/test_contextmenu.xul @@ -52,7 +52,7 @@ this.invoke = function selectMenuItem_invoke() { - synthesizeKey("VK_DOWN", { }); + synthesizeKey("KEY_ArrowDown"); } this.getID = function selectMenuItem_getID() @@ -69,7 +69,7 @@ this.invoke = function openSubMenu_invoke() { - synthesizeKey("VK_RETURN", { }); + synthesizeKey("KEY_Enter"); } this.finalCheck = function openSubMenu_finalCheck(aEvent) @@ -91,7 +91,7 @@ this.invoke = function closeSubMenu_invoke() { - synthesizeKey("VK_ESCAPE", { }); + synthesizeKey("KEY_Escape"); } this.getID = function closeSubMenu_getID() @@ -108,7 +108,7 @@ this.invoke = function closeMenu_invoke() { - synthesizeKey("VK_ESCAPE", { }); + synthesizeKey("KEY_Escape"); } this.getID = function closeMenu_getID() diff --git a/accessible/tests/mochitest/treeupdate/test_menubutton.xul b/accessible/tests/mochitest/treeupdate/test_menubutton.xul index 4821a265bdbf..26781f6b743e 100644 --- a/accessible/tests/mochitest/treeupdate/test_menubutton.xul +++ b/accessible/tests/mochitest/treeupdate/test_menubutton.xul @@ -55,7 +55,7 @@ ] }; testAccessibleTree(this.button, tree); - synthesizeKey("VK_ESCAPE", { }); + synthesizeKey("KEY_Escape"); } this.getID = function openMenu_getID() diff --git a/browser/base/content/test/forms/browser_selectpopup.js b/browser/base/content/test/forms/browser_selectpopup.js index e0285f5d18af..24cc5f2a2fcf 100644 --- a/browser/base/content/test/forms/browser_selectpopup.js +++ b/browser/base/content/test/forms/browser_selectpopup.js @@ -144,15 +144,15 @@ async function doSelectTests(contentType, content) { is(selectPopup.childNodes[1].localName, "menuitem", "option is menuitem"); is(selectPopup.childNodes[1].getAttribute("label"), "One", "option label"); - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(menulist.menuBoxObject.activeChild, menulist.getItemAtIndex(2), "Select item 2"); is(menulist.selectedIndex, isWindows ? 2 : 1, "Select item 2 selectedIndex"); - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(menulist.menuBoxObject.activeChild, menulist.getItemAtIndex(3), "Select item 3"); is(menulist.selectedIndex, isWindows ? 3 : 1, "Select item 3 selectedIndex"); - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); // On Windows, one can navigate on disabled menuitems is(menulist.menuBoxObject.activeChild, menulist.getItemAtIndex(9), @@ -163,7 +163,7 @@ async function doSelectTests(contentType, content) { is(menulist.getItemAtIndex(i).disabled, i >= 4 && i <= 7, "item " + i + " disabled"); } - EventUtils.synthesizeKey("KEY_ArrowUp", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(menulist.menuBoxObject.activeChild, menulist.getItemAtIndex(3), "Select item 3 again"); is(menulist.selectedIndex, isWindows ? 3 : 1, "Select item 3 selectedIndex"); @@ -182,7 +182,7 @@ async function doSelectTests(contentType, content) { ok(false, "Should not get keypress event"); }; window.addEventListener("keypress", handleKeyPress); - EventUtils.synthesizeKey("VK_BACK_SPACE", { }); + EventUtils.synthesizeKey("KEY_Backspace"); window.removeEventListener("keypress", handleKeyPress); await hideSelectPopup(selectPopup); @@ -198,20 +198,20 @@ async function doSelectTests(contentType, content) { is((await getInputEvents()), 1, "Open and close with no change - number of input events"); is((await getChangeEvents()), 1, "Open and close with no change - number of change events"); is((await getClickEvents()), 1, "Open and close with no change - number of click events"); - EventUtils.synthesizeKey("VK_TAB", { }); - EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }); + EventUtils.synthesizeKey("KEY_Tab"); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); is((await getInputEvents()), 1, "Tab away from select with no change - number of input events"); is((await getChangeEvents()), 1, "Tab away from select with no change - number of change events"); is((await getClickEvents()), 1, "Tab away from select with no change - number of click events"); await openSelectPopup(selectPopup, "click"); - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); await hideSelectPopup(selectPopup, "escape"); is((await getInputEvents()), isWindows ? 2 : 1, "Open and close with change - number of input events"); is((await getChangeEvents()), isWindows ? 2 : 1, "Open and close with change - number of change events"); is((await getClickEvents()), 2, "Open and close with change - number of click events"); - EventUtils.synthesizeKey("VK_TAB", { }); - EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }); + EventUtils.synthesizeKey("KEY_Tab"); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); is((await getInputEvents()), isWindows ? 2 : 1, "Tab away from select with change - number of input events"); is((await getChangeEvents()), isWindows ? 2 : 1, "Tab away from select with change - number of change events"); is((await getClickEvents()), 2, "Tab away from select with change - number of click events"); @@ -435,7 +435,7 @@ add_task(async function test_event_order() { }); }); - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); await hideSelectPopup(selectPopup, mode); await eventsPromise; } @@ -637,22 +637,22 @@ async function performSelectSearchTests(win) { is(selectPopup.childNodes[4].hidden, true, "Third option should be hidden"); is(selectPopup.childNodes[1].hidden, true, "First group header should be hidden"); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}, win); + EventUtils.synthesizeKey("KEY_Backspace", {}, win); is(selectPopup.childNodes[4].hidden, false, "Third option should be visible"); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}, win); + EventUtils.synthesizeKey("KEY_Backspace", {}, win); is(selectPopup.childNodes[5].hidden, false, "Second group header should be visible"); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}, win); + EventUtils.synthesizeKey("KEY_Backspace", {}, win); EventUtils.synthesizeKey("O", {}, win); EventUtils.synthesizeKey("5", {}, win); is(selectPopup.childNodes[5].hidden, false, "Second group header should be visible"); is(selectPopup.childNodes[1].hidden, true, "First group header should be hidden"); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}, win); + EventUtils.synthesizeKey("KEY_Backspace", {}, win); is(selectPopup.childNodes[1].hidden, false, "First group header should be shown"); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}, win); + EventUtils.synthesizeKey("KEY_Backspace", {}, win); is(selectPopup.childNodes[8].hidden, true, "Option hidden by content should remain hidden"); await hideSelectPopup(selectPopup, "escape", win); diff --git a/browser/base/content/test/forms/browser_selectpopup_colors.js b/browser/base/content/test/forms/browser_selectpopup_colors.js index 8049419b8853..ed3c7a5c2936 100644 --- a/browser/base/content/test/forms/browser_selectpopup_colors.js +++ b/browser/base/content/test/forms/browser_selectpopup_colors.js @@ -203,7 +203,7 @@ function testOptionColors(index, item, menulist) { // Press Down to move the selected item to the next item in the // list and check the colors of this item when it's not selected. - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); if (expected.end) { return; diff --git a/browser/base/content/test/general/browser_bug432599.js b/browser/base/content/test/general/browser_bug432599.js index ee92798a6ffa..ac5d15f8ad8d 100644 --- a/browser/base/content/test/general/browser_bug432599.js +++ b/browser/base/content/test/general/browser_bug432599.js @@ -2,15 +2,15 @@ function invokeUsingCtrlD(phase) { switch (phase) { case 1: - EventUtils.synthesizeKey("d", { accelKey: true }); + EventUtils.synthesizeKey("d", {accelKey: true}); break; case 2: case 4: - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); break; case 3: - EventUtils.synthesizeKey("d", { accelKey: true }); - EventUtils.synthesizeKey("d", { accelKey: true }); + EventUtils.synthesizeKey("d", {accelKey: true}); + EventUtils.synthesizeKey("d", {accelKey: true}); break; } } @@ -22,7 +22,7 @@ function invokeUsingStarButton(phase) { break; case 2: case 4: - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); break; case 3: EventUtils.synthesizeMouseAtCenter(BookmarkingUI.star, diff --git a/browser/base/content/test/general/browser_bug553455.js b/browser/base/content/test/general/browser_bug553455.js index c547f4234085..b67a17d545b1 100644 --- a/browser/base/content/test/general/browser_bug553455.js +++ b/browser/base/content/test/general/browser_bug553455.js @@ -694,7 +694,7 @@ async function test_urlBar() { await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); gURLBar.value = TESTROOT + "amosigned.xpi"; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await progressPromise; let installDialog = await dialogPromise; diff --git a/browser/base/content/test/general/browser_bug555767.js b/browser/base/content/test/general/browser_bug555767.js index 4c7a60cea7c3..ed3771e7c04c 100644 --- a/browser/base/content/test/general/browser_bug555767.js +++ b/browser/base/content/test/general/browser_bug555767.js @@ -49,5 +49,5 @@ gBrowser.tabContainer.addEventListener("TabSelect", onTabSelect); // Press enter! - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); }); diff --git a/browser/base/content/test/general/browser_domFullscreen_fullscreenMode.js b/browser/base/content/test/general/browser_domFullscreen_fullscreenMode.js index 05859ba3ed45..774b39df2891 100644 --- a/browser/base/content/test/general/browser_domFullscreen_fullscreenMode.js +++ b/browser/base/content/test/general/browser_domFullscreen_fullscreenMode.js @@ -128,14 +128,14 @@ var gTests = [ desc: "escape key", affectsFullscreenMode: false, exitFunc: () => { - executeSoon(() => EventUtils.synthesizeKey("VK_ESCAPE", {})); + executeSoon(() => EventUtils.synthesizeKey("KEY_Escape")); } }, { desc: "F11 key", affectsFullscreenMode: true, exitFunc() { - executeSoon(() => EventUtils.synthesizeKey("VK_F11", {})); + executeSoon(() => EventUtils.synthesizeKey("KEY_F11")); } } ]; diff --git a/browser/base/content/test/general/browser_focusonkeydown.js b/browser/base/content/test/general/browser_focusonkeydown.js index 344aa7358f94..1cbeb74a4e58 100644 --- a/browser/base/content/test/general/browser_focusonkeydown.js +++ b/browser/base/content/test/general/browser_focusonkeydown.js @@ -15,7 +15,7 @@ add_task(async function() { gBrowser.selectedBrowser.focus(); }, {capture: true, once: true}); - EventUtils.synthesizeKey("v", { }); + EventUtils.sendString("v"); is(keyUps, 1, "Key up fired at url bar"); diff --git a/browser/base/content/test/general/browser_keywordBookmarklets.js b/browser/base/content/test/general/browser_keywordBookmarklets.js index 03f424a3da5a..6dac2c78ecbe 100644 --- a/browser/base/content/test/general/browser_keywordBookmarklets.js +++ b/browser/base/content/test/general/browser_keywordBookmarklets.js @@ -24,7 +24,7 @@ add_task(async function test_keyword_bookmarklet() { // Enter bookmarklet keyword in the URL bar gURLBar.value = "bm"; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "pageshow"); diff --git a/browser/base/content/test/general/browser_keywordSearch.js b/browser/base/content/test/general/browser_keywordSearch.js index 5aca2357f6f5..a8272cacac98 100644 --- a/browser/base/content/test/general/browser_keywordSearch.js +++ b/browser/base/content/test/general/browser_keywordSearch.js @@ -119,5 +119,5 @@ function doTest() { // Simulate a user entering search terms gURLBar.value = gCurrTest.testText; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } diff --git a/browser/base/content/test/general/browser_keywordSearch_postData.js b/browser/base/content/test/general/browser_keywordSearch_postData.js index 13c453ee719e..da189103e602 100644 --- a/browser/base/content/test/general/browser_keywordSearch_postData.js +++ b/browser/base/content/test/general/browser_keywordSearch_postData.js @@ -78,7 +78,7 @@ function doTest() { // Simulate a user entering search terms gURLBar.value = gCurrTest.testText; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } diff --git a/browser/base/content/test/general/browser_printpreview.js b/browser/base/content/test/general/browser_printpreview.js index 7337228b7342..784c4ec71cfc 100644 --- a/browser/base/content/test/general/browser_printpreview.js +++ b/browser/base/content/test/general/browser_printpreview.js @@ -21,7 +21,7 @@ function tidyUp() { } function testClosePrintPreviewWithAccessKey() { - EventUtils.synthesizeKey("c", { altKey: true }); + EventUtils.synthesizeKey("c", {altKey: true}); checkPrintPreviewClosed(function(aSucceeded) { ok(aSucceeded, "print preview mode should be finished by access key"); @@ -30,7 +30,7 @@ function testClosePrintPreviewWithAccessKey() { } function testClosePrintPreviewWithEscKey() { - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); checkPrintPreviewClosed(function(aSucceeded) { ok(aSucceeded, "print preview mode should be finished by Esc key press"); @@ -39,7 +39,7 @@ function testClosePrintPreviewWithEscKey() { } function testClosePrintPreviewWithClosingWindowShortcutKey() { - EventUtils.synthesizeKey("w", { accelKey: true }); + EventUtils.synthesizeKey("w", {accelKey: true}); checkPrintPreviewClosed(function(aSucceeded) { ok(aSucceeded, "print preview mode should be finished by closing window shortcut key"); diff --git a/browser/base/content/test/general/browser_tabfocus.js b/browser/base/content/test/general/browser_tabfocus.js index 313e95dcca1a..a456d600c65f 100644 --- a/browser/base/content/test/general/browser_tabfocus.js +++ b/browser/base/content/test/general/browser_tabfocus.js @@ -344,16 +344,16 @@ add_task(async function() { _lastfocus = "urlbar"; _lastfocuswindow = "main-window"; - await expectFocusShift(() => EventUtils.synthesizeKey("VK_F6", { }), + await expectFocusShift(() => EventUtils.synthesizeKey("KEY_F6"), "window1", "html1", true, "switch document forward with f6"); - EventUtils.synthesizeKey("VK_F6", { }); + EventUtils.synthesizeKey("KEY_F6"); is(fm.focusedWindow, window, "switch document forward again with f6"); browser1.style.MozUserFocus = "ignore"; browser1.clientWidth; - EventUtils.synthesizeKey("VK_F6", { }); + EventUtils.synthesizeKey("KEY_F6"); is(fm.focusedWindow, window, "switch document forward again with f6 when browser non-focusable"); browser1.style.MozUserFocus = "normal"; diff --git a/browser/base/content/test/general/browser_visibleFindSelection.js b/browser/base/content/test/general/browser_visibleFindSelection.js index 34c019457df1..fa630a67e293 100644 --- a/browser/base/content/test/general/browser_visibleFindSelection.js +++ b/browser/base/content/test/general/browser_visibleFindSelection.js @@ -11,7 +11,7 @@ add_task(async function() { let remote = gBrowser.selectedBrowser.isRemoteBrowser; let findBarOpenPromise = promiseWaitForEvent(gBrowser, "findbaropen"); - EventUtils.synthesizeKey("f", { accelKey: true }); + EventUtils.synthesizeKey("f", {accelKey: true}); await findBarOpenPromise; ok(gFindBarInitialized, "find bar is now initialized"); @@ -20,9 +20,7 @@ add_task(async function() { let scrollPromise = remote ? BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "scroll") : BrowserTestUtils.waitForEvent(gBrowser, "scroll"); - EventUtils.synthesizeKey("d", {}); - EventUtils.synthesizeKey("i", {}); - EventUtils.synthesizeKey("v", {}); + EventUtils.sendString("div"); await scrollPromise; // Wait for one paint to ensure we've processed the previous key events and scrolling. @@ -40,7 +38,7 @@ add_task(async function() { scrollPromise = remote ? BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "scroll") : BrowserTestUtils.waitForEvent(gBrowser, "scroll"); - EventUtils.synthesizeKey("g", { accelKey: true }); + EventUtils.synthesizeKey("g", {accelKey: true}); await scrollPromise; await ContentTask.spawn(gBrowser.selectedBrowser, null, async function() { @@ -49,8 +47,8 @@ add_task(async function() { }); // clear the find bar - EventUtils.synthesizeKey("a", { accelKey: true }); - EventUtils.synthesizeKey("VK_DELETE", { }); + EventUtils.synthesizeKey("a", {accelKey: true}); + EventUtils.synthesizeKey("KEY_Delete"); gFindBar.close(); gBrowser.removeCurrentTab(); diff --git a/browser/base/content/test/general/browser_zbug569342.js b/browser/base/content/test/general/browser_zbug569342.js index 22df449210ad..05c6bbdad4bd 100644 --- a/browser/base/content/test/general/browser_zbug569342.js +++ b/browser/base/content/test/general/browser_zbug569342.js @@ -41,7 +41,7 @@ function nextTest() { } else { // Make sure the find bar is re-enabled after disabled page is closed. testFindEnabled("about:blank", function() { - EventUtils.synthesizeKey("VK_ESCAPE", { }); + EventUtils.synthesizeKey("KEY_Escape"); ok(gFindBar.hidden, "Find bar should now be hidden"); finish(); }); @@ -53,7 +53,7 @@ function testFindDisabled(url, cb) { ok(gFindBar.hidden, "Find bar should not be visible"); EventUtils.synthesizeKey("/", {}, gTab.linkedBrowser.contentWindow); ok(gFindBar.hidden, "Find bar should not be visible"); - EventUtils.synthesizeKey("f", { accelKey: true }); + EventUtils.synthesizeKey("f", {accelKey: true}); ok(gFindBar.hidden, "Find bar should not be visible"); ok(document.getElementById("cmd_find").getAttribute("disabled"), "Find command should be disabled"); @@ -71,7 +71,7 @@ function testFindEnabled(url, cb) { // Open Find bar and then close it. EventUtils.synthesizeKey("f", { accelKey: true }); ok(!gFindBar.hidden, "Find bar should be visible again"); - EventUtils.synthesizeKey("VK_ESCAPE", { }); + EventUtils.synthesizeKey("KEY_Escape"); ok(gFindBar.hidden, "Find bar should now be hidden"); gBrowser.removeTab(gTab); diff --git a/browser/base/content/test/general/contentSearchUI.js b/browser/base/content/test/general/contentSearchUI.js index 4adf7a61454c..b4a0f96204d0 100644 --- a/browser/base/content/test/general/contentSearchUI.js +++ b/browser/base/content/test/general/contentSearchUI.js @@ -33,7 +33,7 @@ var messageHandlers = { key(arg) { let keyName = typeof(arg) == "string" ? arg : arg.key; - content.synthesizeKey(keyName, arg.modifiers || {}); + content.synthesizeKey(keyName, arg.modifiers); let wait = arg.waitForSuggestions ? waitForSuggestions : cb => cb(); wait(ack.bind(null, "key")); }, @@ -143,9 +143,9 @@ var messageHandlers = { // no text entered, this won't have any effect, so also escape to ensure the // suggestions table is closed. gController.input.focus(); - content.synthesizeKey("a", { accelKey: true }); - content.synthesizeKey("VK_DELETE", {}); - content.synthesizeKey("VK_ESCAPE", {}); + content.synthesizeKey("a", {accelKey: true}); + content.synthesizeKey("KEY_Delete"); + content.synthesizeKey("KEY_Escape"); ack("reset"); }, }; diff --git a/browser/base/content/test/newtab/browser_newtab_focus.js b/browser/base/content/test/newtab/browser_newtab_focus.js index ffc4999fa92f..5c2f423d0b4d 100644 --- a/browser/base/content/test/newtab/browser_newtab_focus.js +++ b/browser/base/content/test/newtab/browser_newtab_focus.js @@ -50,7 +50,7 @@ add_task(async function() { function countFocus(aExpectedCount) { let focusCount = 0; do { - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); if (document.activeElement == gBrowser.selectedBrowser) { focusCount++; } diff --git a/browser/base/content/test/newtab/browser_newtab_search.js b/browser/base/content/test/newtab/browser_newtab_search.js index 4800d05f37c1..0a0e0387d884 100644 --- a/browser/base/content/test/newtab/browser_newtab_search.js +++ b/browser/base/content/test/newtab/browser_newtab_search.js @@ -156,7 +156,7 @@ add_task(async function() { let suggestionsPromise = promiseSearchEvents(["Suggestions"]); - EventUtils.synthesizeKey("x", {}); + EventUtils.sendString("x"); // Wait for the search suggestions to become visible and for the Suggestions // message. @@ -164,8 +164,8 @@ add_task(async function() { await suggestionsPromise; // Empty the search input, causing the suggestions to be hidden. - EventUtils.synthesizeKey("a", { accelKey: true }); - EventUtils.synthesizeKey("VK_DELETE", {}); + EventUtils.synthesizeKey("a", {accelKey: true}); + EventUtils.synthesizeKey("KEY_Delete"); await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() { Assert.ok(content.document.getElementById("searchSuggestionTable").hidden, diff --git a/browser/base/content/test/permissions/browser_reservedkey.js b/browser/base/content/test/permissions/browser_reservedkey.js index e43c389a3dcb..64867dee2b39 100644 --- a/browser/base/content/test/permissions/browser_reservedkey.js +++ b/browser/base/content/test/permissions/browser_reservedkey.js @@ -17,9 +17,7 @@ add_task(async function test_reserved_shortcuts() { const pageUrl = "data:text/html,
Test
"; let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, pageUrl); - EventUtils.synthesizeKey("O", { shiftKey: true }); - EventUtils.synthesizeKey("P", { shiftKey: true }); - EventUtils.synthesizeKey("Q", { shiftKey: true }); + EventUtils.sendString("OPQ"); is(document.getElementById("kt_reserved").getAttribute("count"), "1", "reserved='true' with preference off"); is(document.getElementById("kt_notreserved").getAttribute("count"), "0", "reserved='false' with preference off"); @@ -30,9 +28,7 @@ add_task(async function test_reserved_shortcuts() { SpecialPowers.pushPrefEnv({"set": [["permissions.default.shortcuts", 2]]}, resolve); }); - EventUtils.synthesizeKey("O", { shiftKey: true }); - EventUtils.synthesizeKey("P", { shiftKey: true }); - EventUtils.synthesizeKey("Q", { shiftKey: true }); + EventUtils.sendString("OPQ"); is(document.getElementById("kt_reserved").getAttribute("count"), "2", "reserved='true' with preference on"); is(document.getElementById("kt_notreserved").getAttribute("count"), "0", "reserved='false' with preference on"); @@ -56,9 +52,9 @@ if (!navigator.platform.includes("Mac")) { // Pressing Alt+H should open the Help menu. let helpPopup = document.getElementById("menu_HelpPopup"); let popupShown = BrowserTestUtils.waitForEvent(helpPopup, "popupshown"); - EventUtils.synthesizeKey("VK_ALT", { type: "keydown" }); - EventUtils.synthesizeKey("H", { altKey: true }); - EventUtils.synthesizeKey("VK_ALT", { type: "keyup" }); + EventUtils.synthesizeKey("KEY_Alt", {type: "keydown"}); + EventUtils.synthesizeKey("h", {altKey: true}); + EventUtils.synthesizeKey("KEY_Alt", {type: "keyup"}); await popupShown; ok(true, "Help menu opened"); @@ -71,13 +67,13 @@ if (!navigator.platform.includes("Mac")) { // pressing Down will open the file menu. let menubar = document.getElementById("main-menubar"); let menubarActive = BrowserTestUtils.waitForEvent(menubar, "DOMMenuBarActive"); - EventUtils.sendKey("F10"); + EventUtils.synthesizeKey("KEY_F10"); await menubarActive; let filePopup = document.getElementById("menu_FilePopup"); popupShown = BrowserTestUtils.waitForEvent(filePopup, "popupshown"); if (navigator.platform.includes("Win")) { - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); } await popupShown; diff --git a/browser/base/content/test/popupNotifications/browser_popupNotification_keyboard.js b/browser/base/content/test/popupNotifications/browser_popupNotification_keyboard.js index ee18baa9283a..be6c48cff774 100644 --- a/browser/base/content/test/popupNotifications/browser_popupNotification_keyboard.js +++ b/browser/base/content/test/popupNotifications/browser_popupNotification_keyboard.js @@ -23,7 +23,7 @@ var tests = [ }, onShown(popup) { checkPopup(popup, this.notifyObj); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); }, onHidden(popup) { ok(!this.notifyObj.mainActionClicked, "mainAction was not clicked"); @@ -41,7 +41,7 @@ var tests = [ }, onShown(popup) { checkPopup(popup, this.notifyObj); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); }, onHidden(popup) { ok(!this.notifyObj.mainActionClicked, "mainAction was not clicked"); @@ -66,7 +66,7 @@ var tests = [ let anchor = document.getElementById(this.notifyObj.anchorID); anchor.focus(); is(document.activeElement, anchor); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); is(document.activeElement, popup.childNodes[0].closebutton); this.notification.remove(); }, @@ -108,7 +108,7 @@ var tests = [ anchor.focus(); is(document.activeElement, anchor); opened = waitForNotificationPanel(); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); popup = await opened; checkPopup(popup, notifyObj1); @@ -119,7 +119,7 @@ var tests = [ anchor.focus(); is(document.activeElement, anchor); opened = waitForNotificationPanel(); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); popup = await opened; checkPopup(popup, notifyObj2); @@ -147,7 +147,7 @@ var tests = [ // can not be focused, next tab focus will be inside the panel. is(Services.focus.focusedElement, null); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(Services.focus.focusedElement, popup.childNodes[0].closebutton); dismissNotification(popup); }, diff --git a/browser/base/content/test/popupNotifications/browser_popupNotification_no_anchors.js b/browser/base/content/test/popupNotifications/browser_popupNotification_no_anchors.js index 5cee73509e96..f007d1d4dbde 100644 --- a/browser/base/content/test/popupNotifications/browser_popupNotification_no_anchors.js +++ b/browser/base/content/test/popupNotifications/browser_popupNotification_no_anchors.js @@ -120,7 +120,7 @@ var tests = [ // Typing in the location bar should hide the notification. let hidden = waitForNotificationPanelHidden(); gURLBar.select(); - EventUtils.synthesizeKey("*", {}); + EventUtils.sendString("*"); await hidden; is(document.getElementById("geo-notification-icon").boxObject.width, 0, @@ -130,8 +130,8 @@ var tests = [ // anchored to the identity icon. We clear the URL bar before moving the // focus so that the awesomebar popup doesn't get in the way. shown = waitForNotificationPanel(); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Backspace"); + EventUtils.synthesizeKey("KEY_Tab"); await shown; is(PopupNotifications.panel.anchorNode.id, "identity-icon", @@ -139,12 +139,12 @@ var tests = [ // Moving focus to the location bar should hide the notification again. hidden = waitForNotificationPanelHidden(); - EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); await hidden; // Reverting the URL should show the notification again. shown = waitForNotificationPanel(); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await shown; checkPopup(PopupNotifications.panel, this.notifyObj); @@ -163,8 +163,8 @@ var tests = [ for (let persistent of [false, true]) { // Start editing the URL, ensuring that the awesomebar popup is hidden. gURLBar.select(); - EventUtils.synthesizeKey("*", {}); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.sendString("*"); + EventUtils.synthesizeKey("KEY_Backspace"); // Trying to show a notification should display nothing. let notShowing = promiseTopicObserved("PopupNotifications-updateNotShowing"); @@ -176,7 +176,7 @@ var tests = [ // Reverting the URL should show the notification. let shown = waitForNotificationPanel(); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await shown; checkPopup(PopupNotifications.panel, this.notifyObj); @@ -210,7 +210,7 @@ var tests = [ // Start editing the URL. gURLBar.select(); - EventUtils.synthesizeKey("*", {}); + EventUtils.sendString("*"); // Switching to the old tab should show the notification again. shown = waitForNotificationPanel(); diff --git a/browser/base/content/test/popupNotifications/head.js b/browser/base/content/test/popupNotifications/head.js index 0ef461061e51..d6ca051d65e5 100644 --- a/browser/base/content/test/popupNotifications/head.js +++ b/browser/base/content/test/popupNotifications/head.js @@ -123,7 +123,7 @@ function showNotification(notifyObj) { function dismissNotification(popup) { info("Dismissing notification " + popup.childNodes[0].id); - executeSoon(() => EventUtils.synthesizeKey("VK_ESCAPE", {})); + executeSoon(() => EventUtils.synthesizeKey("KEY_Escape")); } function BasicNotification(testId) { @@ -309,13 +309,13 @@ function triggerSecondaryCommand(popup, index) { // Press down until the desired command is selected. Decrease index by one // since the secondary action was handled above. for (let i = 0; i <= index - 1; i++) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); } // Activate - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); }, {once: true}); // One down event to open the popup info("Open the popup to trigger secondary command for notification " + notification.id); - EventUtils.synthesizeKey("VK_DOWN", { altKey: !navigator.platform.includes("Mac") }); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: !navigator.platform.includes("Mac")}); } diff --git a/browser/base/content/test/siteIdentity/browser_identityPopup_focus.js b/browser/base/content/test/siteIdentity/browser_identityPopup_focus.js index 54e2eeed7901..c3fa50ca16a3 100644 --- a/browser/base/content/test/siteIdentity/browser_identityPopup_focus.js +++ b/browser/base/content/test/siteIdentity/browser_identityPopup_focus.js @@ -19,7 +19,7 @@ add_task(async function testIdentityPopupFocusKeyboard() { gIdentityHandler._identityBox.focus(); await focused; let shown = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "popupshown"); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); await shown; is(Services.focus.focusedElement, document.getElementById("identity-popup-security-expander")); }); diff --git a/browser/base/content/test/urlbar/browser_action_searchengine_alias.js b/browser/base/content/test/urlbar/browser_action_searchengine_alias.js index 9824b2d09dc7..7f764eab4679 100644 --- a/browser/base/content/test/urlbar/browser_action_searchengine_alias.js +++ b/browser/base/content/test/urlbar/browser_action_searchengine_alias.js @@ -27,7 +27,7 @@ add_task(async function() { "Image attribute should have the search engine's icon"); let tabPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - EventUtils.synthesizeKey("VK_RETURN", { }); + EventUtils.synthesizeKey("KEY_Enter"); await tabPromise; is(gBrowser.selectedBrowser.currentURI.spec, "http://example.com/?q=open+a+search"); diff --git a/browser/base/content/test/urlbar/browser_autocomplete_autoselect.js b/browser/base/content/test/urlbar/browser_autocomplete_autoselect.js index c1ce6fdae63c..100a6a2b49e8 100644 --- a/browser/base/content/test/urlbar/browser_autocomplete_autoselect.js +++ b/browser/base/content/test/urlbar/browser_autocomplete_autoselect.js @@ -56,40 +56,40 @@ add_task(async function() { is_selected(0); info("Key Down to select the next item"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is_selected(1); info("Key Down maxResults-1 times should select the first one-off"); - repeat(maxResults - 1, () => EventUtils.synthesizeKey("VK_DOWN", {})); + repeat(maxResults - 1, () => EventUtils.synthesizeKey("KEY_ArrowDown")); is_selected_one_off(0); info("Key Down numButtons-1 should select the last one-off"); let numButtons = gURLBar.popup.oneOffSearchButtons.getSelectableButtons(true).length; - repeat(numButtons - 1, () => EventUtils.synthesizeKey("VK_DOWN", {})); + repeat(numButtons - 1, () => EventUtils.synthesizeKey("KEY_ArrowDown")); is_selected_one_off(numButtons - 1); info("Key Down twice more should select the second result"); - repeat(2, () => EventUtils.synthesizeKey("VK_DOWN", {})); + repeat(2, () => EventUtils.synthesizeKey("KEY_ArrowDown")); is_selected(1); info("Key Down maxResults + numButtons times should wrap around"); repeat(maxResults + numButtons, - () => EventUtils.synthesizeKey("VK_DOWN", {})); + () => EventUtils.synthesizeKey("KEY_ArrowDown")); is_selected(1); info("Key Up maxResults + numButtons times should wrap around the other way"); - repeat(maxResults + numButtons, () => EventUtils.synthesizeKey("VK_UP", {})); + repeat(maxResults + numButtons, () => EventUtils.synthesizeKey("KEY_ArrowUp")); is_selected(1); info("Page Up will go up the list, but not wrap"); - EventUtils.synthesizeKey("VK_PAGE_UP", {}); + EventUtils.synthesizeKey("KEY_PageUp"); is_selected(0); info("Page Up again will wrap around to the end of the list"); - EventUtils.synthesizeKey("VK_PAGE_UP", {}); + EventUtils.synthesizeKey("KEY_PageUp"); is_selected(maxResults - 1); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promisePopupHidden(gURLBar.popup); }); diff --git a/browser/base/content/test/urlbar/browser_autocomplete_cursor.js b/browser/base/content/test/urlbar/browser_autocomplete_cursor.js index 7cf9da9f3b70..4cba0476b3e1 100644 --- a/browser/base/content/test/urlbar/browser_autocomplete_cursor.js +++ b/browser/base/content/test/urlbar/browser_autocomplete_cursor.js @@ -10,7 +10,7 @@ add_task(async function() { is(gURLBar.popup.state, "open", "Popup should be open"); is(gURLBar.popup.richlistbox.selectedIndex, 0, "Should have selected something"); - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); await promisePopupHidden(gURLBar.popup); is(gURLBar.selectionStart, 5, "Should have moved the cursor"); diff --git a/browser/base/content/test/urlbar/browser_autocomplete_edit_completed.js b/browser/base/content/test/urlbar/browser_autocomplete_edit_completed.js index 27834623cef0..8391fe1f50a1 100644 --- a/browser/base/content/test/urlbar/browser_autocomplete_edit_completed.js +++ b/browser/base/content/test/urlbar/browser_autocomplete_edit_completed.js @@ -20,7 +20,7 @@ add_task(async function() { let initialIndex = list.selectedIndex; info("Key Down to select the next item."); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); let nextIndex = initialIndex + 1; let nextValue = gURLBar.controller.getFinalCompleteValueAt(nextIndex); @@ -28,7 +28,7 @@ add_task(async function() { is(gURLBar.value, nextValue, "The selected URL is completed."); info("Press backspace"); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); await promiseSearchComplete(); let editedValue = gURLBar.textValue; @@ -38,7 +38,7 @@ add_task(async function() { let docLoad = waitForDocLoadAndStopIt("http://" + editedValue); info("Press return to load edited URL."); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await Promise.all([ promisePopupHidden(gURLBar.popup), docLoad, diff --git a/browser/base/content/test/urlbar/browser_autocomplete_enter_race.js b/browser/base/content/test/urlbar/browser_autocomplete_enter_race.js index 0fbb85142201..b76e7a75110c 100644 --- a/browser/base/content/test/urlbar/browser_autocomplete_enter_race.js +++ b/browser/base/content/test/urlbar/browser_autocomplete_enter_race.js @@ -20,8 +20,8 @@ add_task(async function setup() { add_task(async function test_keyword() { await promiseAutocompleteResultPopup("keyword bear"); gURLBar.focus(); - EventUtils.synthesizeKey("d", {}); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.sendString("d"); + EventUtils.synthesizeKey("KEY_Enter"); info("wait for the page to load"); await BrowserTestUtils.browserLoaded(gBrowser.selectedTab.linkedBrowser, false, "http://example.com/?q=beard"); @@ -37,7 +37,7 @@ add_task(async function test_sametext() { let event = document.createEvent("Events"); event.initEvent("input", true, true); gURLBar.dispatchEvent(event); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); info("wait for the page to load"); await BrowserTestUtils.browserLoaded(gBrowser.selectedTab.linkedBrowser, @@ -49,8 +49,8 @@ add_task(async function test_after_empty_search() { gURLBar.focus(); // Add www. to avoid a switch-to-tab. gURLBar.value = "www.e"; - EventUtils.synthesizeKey("x", {}); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("x"); + EventUtils.synthesizeKey("KEY_Enter"); info("wait for the page to load"); await BrowserTestUtils.browserLoaded(gBrowser.selectedTab.linkedBrowser, @@ -87,8 +87,8 @@ add_task(async function test_disabled_ac() { gURLBar.focus(); gURLBar.value = "e"; - EventUtils.synthesizeKey("x", {}); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.sendString("x"); + EventUtils.synthesizeKey("KEY_Enter"); info("wait for the page to load"); await BrowserTestUtils.browserLoaded(gBrowser.selectedTab.linkedBrowser, @@ -115,8 +115,8 @@ add_task(async function test_delay() { gURLBar.closePopup(); gURLBar.focus(); gURLBar.value = "e"; - EventUtils.synthesizeKey("x", {}); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.sendString("x"); + EventUtils.synthesizeKey("KEY_Enter"); info("wait for the page to load"); await BrowserTestUtils.browserLoaded(gBrowser.selectedTab.linkedBrowser, false, "http://example.com/"); diff --git a/browser/base/content/test/urlbar/browser_bug1003461-switchtab-override.js b/browser/base/content/test/urlbar/browser_bug1003461-switchtab-override.js index 4bf4e9501b3b..dc71ced0bf08 100644 --- a/browser/base/content/test/urlbar/browser_bug1003461-switchtab-override.js +++ b/browser/base/content/test/urlbar/browser_bug1003461-switchtab-override.js @@ -31,11 +31,11 @@ add_task(async function test_switchtab_override() { gURLBar.focus(); gURLBar.value = "dummy_pag"; - EventUtils.synthesizeKey("e", {}); + EventUtils.sendString("e"); await deferred.promise; info("Select second autocomplete popup entry"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); ok(/moz-action:switchtab/.test(gURLBar.value), "switch to tab entry found"); info("Override switch-to-tab"); @@ -51,10 +51,10 @@ add_task(async function test_switchtab_override() { // Otherwise it would load the page. BrowserTestUtils.browserLoaded(secondTab.linkedBrowser).then(deferred.resolve); - EventUtils.synthesizeKey("VK_SHIFT", { type: "keydown" }); - EventUtils.synthesizeKey("VK_RETURN", { }); + EventUtils.synthesizeKey("KEY_Shift", {type: "keydown"}); + EventUtils.synthesizeKey("KEY_Enter"); info(`gURLBar.value = ${gURLBar.value}`); - EventUtils.synthesizeKey("VK_SHIFT", { type: "keyup" }); + EventUtils.synthesizeKey("KEY_Shift", {type: "keyup"}); await deferred.promise; await PlacesUtils.history.clear(); diff --git a/browser/base/content/test/urlbar/browser_bug1024133-switchtab-override-keynav.js b/browser/base/content/test/urlbar/browser_bug1024133-switchtab-override-keynav.js index f2127906b9c0..a05ef1834db5 100644 --- a/browser/base/content/test/urlbar/browser_bug1024133-switchtab-override-keynav.js +++ b/browser/base/content/test/urlbar/browser_bug1024133-switchtab-override-keynav.js @@ -20,18 +20,18 @@ add_task(async function test_switchtab_override_keynav() { gURLBar.focus(); gURLBar.value = "dummy_pag"; - EventUtils.synthesizeKey("e", {}); + EventUtils.sendString("e"); await promiseSearchComplete(); info("Select second autocomplete popup entry"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); ok(/moz-action:switchtab/.test(gURLBar.value), "switch to tab entry found"); info("Shift+left on switch-to-tab entry"); - EventUtils.synthesizeKey("VK_SHIFT", { type: "keydown" }); - EventUtils.synthesizeKey("VK_LEFT", { shiftKey: true }); - EventUtils.synthesizeKey("VK_SHIFT", { type: "keyup" }); + EventUtils.synthesizeKey("KEY_Shift", {type: "keydown"}); + EventUtils.synthesizeKey("KEY_ArrowLeft", {shiftKey: true}); + EventUtils.synthesizeKey("KEY_Shift", {type: "keyup"}); ok(!/moz-action:switchtab/.test(gURLBar.inputField.value), "switch to tab should be hidden"); }); diff --git a/browser/base/content/test/urlbar/browser_bug1070778.js b/browser/base/content/test/urlbar/browser_bug1070778.js index 8100a34e8e1a..3fbf83a37e71 100644 --- a/browser/base/content/test/urlbar/browser_bug1070778.js +++ b/browser/base/content/test/urlbar/browser_bug1070778.js @@ -34,13 +34,13 @@ add_task(async function() { // First item should already be selected is_selected(0); // Select next one (important!) - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is_selected(1); // Re-select keyword item - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is_selected(0); - EventUtils.synthesizeKey("b", {}); + EventUtils.sendString("b"); await promiseSearchComplete(); is(gURLBar.textValue, "keyword ab", "urlbar should have expected input"); @@ -49,7 +49,7 @@ add_task(async function() { let uri = NetUtil.newURI(result.getAttribute("url")); is(uri.spec, PlacesUtils.mozActionURI("keyword", {url: "http://example.com/?q=ab", input: "keyword ab"}), "Expect correct url"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promisePopupHidden(gURLBar.popup); gBrowser.removeTab(tab); }); diff --git a/browser/base/content/test/urlbar/browser_bug1104165-switchtab-decodeuri.js b/browser/base/content/test/urlbar/browser_bug1104165-switchtab-decodeuri.js index 8920abf10305..118ea7ce05ee 100644 --- a/browser/base/content/test/urlbar/browser_bug1104165-switchtab-decodeuri.js +++ b/browser/base/content/test/urlbar/browser_bug1104165-switchtab-decodeuri.js @@ -10,7 +10,7 @@ add_task(async function test_switchtab_decodeuri() { await promiseAutocompleteResultPopup("dummy_page"); info("Select autocomplete popup entry"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); ok(gURLBar.value.startsWith("moz-action:switchtab"), "switch to tab entry found"); info("switch-to-tab"); @@ -20,7 +20,7 @@ add_task(async function test_switchtab_decodeuri() { is(gBrowser.selectedTab, tab, "Should have switched to the right tab"); resolve(); }, {once: true}); - EventUtils.synthesizeKey("VK_RETURN", { }); + EventUtils.synthesizeKey("KEY_Enter"); }); gBrowser.removeCurrentTab(); diff --git a/browser/base/content/test/urlbar/browser_bug1225194-remotetab.js b/browser/base/content/test/urlbar/browser_bug1225194-remotetab.js index e1e44a68bc50..a8056eab7a97 100644 --- a/browser/base/content/test/urlbar/browser_bug1225194-remotetab.js +++ b/browser/base/content/test/urlbar/browser_bug1225194-remotetab.js @@ -8,7 +8,7 @@ add_task(async function test_remotetab_opens() { // The URL is going to open in the current tab as it is currently about:blank let promiseTabLoaded = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await promiseTabLoaded; Assert.equal(gBrowser.selectedTab.linkedBrowser.currentURI.spec, url, "correct URL loaded"); diff --git a/browser/base/content/test/urlbar/browser_bug304198.js b/browser/base/content/test/urlbar/browser_bug304198.js index 4400e31af023..b72a7f2318c7 100644 --- a/browser/base/content/test/urlbar/browser_bug304198.js +++ b/browser/base/content/test/urlbar/browser_bug304198.js @@ -51,7 +51,7 @@ add_task(async function() { if (gURLBar.selectionStart == gURLBar.selectionEnd) { gURLBar.selectionStart = gURLBar.selectionEnd = gURLBar.textValue.length; } - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); }); } diff --git a/browser/base/content/test/urlbar/browser_canonizeURL.js b/browser/base/content/test/urlbar/browser_canonizeURL.js index 224cfbb138a4..0b848e36cb9e 100644 --- a/browser/base/content/test/urlbar/browser_canonizeURL.js +++ b/browser/base/content/test/urlbar/browser_canonizeURL.js @@ -32,11 +32,11 @@ add_task(async function() { gURLBar.selectionStart = gURLBar.selectionEnd = gURLBar.inputField.value.length; gURLBar.inputField.value = inputValue.slice(0, -1); - EventUtils.synthesizeKey(inputValue.slice(-1), {}); + EventUtils.sendString(inputValue.slice(-1)); } else { gURLBar.textValue = inputValue; } - EventUtils.synthesizeKey("VK_RETURN", options); + EventUtils.synthesizeKey("KEY_Enter", options); await promiseLoad; } }); diff --git a/browser/base/content/test/urlbar/browser_locationBarCommand.js b/browser/base/content/test/urlbar/browser_locationBarCommand.js index c76aa31d9b22..867d9aabdae1 100644 --- a/browser/base/content/test/urlbar/browser_locationBarCommand.js +++ b/browser/base/content/test/urlbar/browser_locationBarCommand.js @@ -159,9 +159,7 @@ add_task(async function load_in_new_tab_test() { function triggerCommand(shouldClick, event) { gURLBar.focus(); gURLBar.value = ""; - for (let c of TEST_VALUE) { - EventUtils.synthesizeKey(c, {}); - } + EventUtils.sendString(TEST_VALUE); if (shouldClick) { ok(gURLBar.hasAttribute("usertyping"), @@ -169,7 +167,7 @@ function triggerCommand(shouldClick, event) { EventUtils.synthesizeMouseAtCenter(gURLBar.goButton, event); } else { - EventUtils.synthesizeKey("VK_RETURN", event); + EventUtils.synthesizeKey("KEY_Enter", event); } } diff --git a/browser/base/content/test/urlbar/browser_locationBarExternalLoad.js b/browser/base/content/test/urlbar/browser_locationBarExternalLoad.js index c11893199250..e96a469ee3c4 100644 --- a/browser/base/content/test/urlbar/browser_locationBarExternalLoad.js +++ b/browser/base/content/test/urlbar/browser_locationBarExternalLoad.js @@ -13,16 +13,13 @@ add_task(async function() { function urlEnter(url) { gURLBar.value = url; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } function urlClick(url) { gURLBar.focus(); gURLBar.value = ""; - for (let c of url) { - EventUtils.synthesizeKey(c, {}); - } - + EventUtils.sendString(url); EventUtils.synthesizeMouseAtCenter(gURLBar.goButton, {}); } diff --git a/browser/base/content/test/urlbar/browser_urlbarAutoFillTrimURLs.js b/browser/base/content/test/urlbar/browser_urlbarAutoFillTrimURLs.js index 62ddc3462a08..c5ca48f8da48 100644 --- a/browser/base/content/test/urlbar/browser_urlbarAutoFillTrimURLs.js +++ b/browser/base/content/test/urlbar/browser_urlbarAutoFillTrimURLs.js @@ -27,7 +27,7 @@ add_task(async function setup() { async function promiseSearch(searchtext) { gURLBar.focus(); gURLBar.inputField.value = searchtext.substr(0, searchtext.length - 1); - EventUtils.synthesizeKey(searchtext.substr(-1, 1), {}); + EventUtils.sendString(searchtext.substr(-1, 1)); await promiseSearchComplete(); } @@ -111,6 +111,6 @@ add_task(async function autofill_complete_domain() { // Now ensure selecting from the popup correctly trims. is(gURLBar.controller.matchCount, 2, "Found the expected number of matches"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(gURLBar.inputField.value, "www.autofilltrimurl.com/whatever", "trim was applied correctly"); }); diff --git a/browser/base/content/test/urlbar/browser_urlbarDelete.js b/browser/base/content/test/urlbar/browser_urlbarDelete.js index 7f43a0dcb7c5..fec50431b078 100644 --- a/browser/base/content/test/urlbar/browser_urlbarDelete.js +++ b/browser/base/content/test/urlbar/browser_urlbarDelete.js @@ -13,14 +13,14 @@ add_task(async function() { function sendHome() { // unclear why VK_HOME doesn't work on Mac, but it doesn't... if (Services.appinfo.OS == "Darwin") { - EventUtils.synthesizeKey("VK_LEFT", { altKey: true }); + EventUtils.synthesizeKey("KEY_ArrowLeft", {altKey: true}); } else { - EventUtils.synthesizeKey("VK_HOME", {}); + EventUtils.synthesizeKey("KEY_Home"); } } function sendDelete() { - EventUtils.synthesizeKey("VK_DELETE", {}); + EventUtils.synthesizeKey("KEY_Delete"); } async function testDelete() { diff --git a/browser/base/content/test/urlbar/browser_urlbarEnter.js b/browser/base/content/test/urlbar/browser_urlbarEnter.js index cf0c91156a03..38be905ace5f 100644 --- a/browser/base/content/test/urlbar/browser_urlbarEnter.js +++ b/browser/base/content/test/urlbar/browser_urlbarEnter.js @@ -11,7 +11,7 @@ add_task(async function() { let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, START_VALUE); gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); // Check url bar and selected tab. @@ -30,7 +30,7 @@ add_task(async function() { let tabOpenPromise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen"); gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {altKey: true}); + EventUtils.synthesizeKey("KEY_Enter", {altKey: true}); // wait for the new tab to appear. await tabOpenPromise; diff --git a/browser/base/content/test/urlbar/browser_urlbarEnterAfterMouseOver.js b/browser/base/content/test/urlbar/browser_urlbarEnterAfterMouseOver.js index d324f562c586..521cd397e026 100644 --- a/browser/base/content/test/urlbar/browser_urlbarEnterAfterMouseOver.js +++ b/browser/base/content/test/urlbar/browser_urlbarEnterAfterMouseOver.js @@ -7,7 +7,7 @@ function repeat(limit, func) { async function promiseAutoComplete(inputText) { gURLBar.focus(); gURLBar.value = inputText.slice(0, -1); - EventUtils.synthesizeKey(inputText.slice(-1), {}); + EventUtils.sendString(inputText.slice(-1)); await promiseSearchComplete(); } @@ -45,7 +45,7 @@ add_task(async function() { let initiallySelected = gURLBar.popup.richlistbox.selectedIndex; info("Key Down to select the next item"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is_selected(initiallySelected + 1); let expectedURL = gURLBar.controller.getFinalCompleteValueAt(initiallySelected + 1); @@ -62,7 +62,7 @@ add_task(async function() { let autocompletePopupHidden = promisePopupHidden(gURLBar.popup); let openedExpectedPage = waitForDocLoadAndStopIt(expectedURL); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await Promise.all([autocompletePopupHidden, openedExpectedPage]); gBrowser.removeCurrentTab(); diff --git a/browser/base/content/test/urlbar/browser_urlbarOneOffs.js b/browser/base/content/test/urlbar/browser_urlbarOneOffs.js index ce8d39d4fb6d..bf7fe9013704 100644 --- a/browser/base/content/test/urlbar/browser_urlbarOneOffs.js +++ b/browser/base/content/test/urlbar/browser_urlbarOneOffs.js @@ -34,7 +34,7 @@ add_task(async function init() { // there's no text in the textbox. add_task(async function history() { gURLBar.focus(); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); await promisePopupShown(gURLBar.popup); await waitForAutocompleteResultAt(gMaxResults - 1); @@ -42,7 +42,7 @@ add_task(async function history() { // Key down through each result. for (let i = 0; i < gMaxResults; i++) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(i, -1, "example.com/browser_urlbarOneOffs.js/?" + (gMaxResults - i - 1)); } @@ -51,50 +51,50 @@ add_task(async function history() { let numButtons = gURLBar.popup.oneOffSearchButtons.getSelectableButtons(true).length; for (let i = 0; i < numButtons; i++) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(-1, i, ""); } // Key down once more. Nothing should be selected. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(-1, -1, ""); // Once more. The first result should be selected. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(0, -1, "example.com/browser_urlbarOneOffs.js/?" + (gMaxResults - 1)); // Now key up. Nothing should be selected again. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); assertState(-1, -1, ""); // Key up through each one-off. for (let i = numButtons - 1; i >= 0; i--) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); assertState(-1, i, ""); } // Key right through each one-off. for (let i = 1; i < numButtons; i++) { - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); assertState(-1, i, ""); } // Key left through each one-off. for (let i = numButtons - 2; i >= 0; i--) { - EventUtils.synthesizeKey("VK_LEFT", {}); + EventUtils.synthesizeKey("KEY_ArrowLeft"); assertState(-1, i, ""); } // Key up through each result. for (let i = gMaxResults - 1; i >= 0; i--) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); assertState(i, -1, "example.com/browser_urlbarOneOffs.js/?" + (gMaxResults - i - 1)); } // Key up once more. Nothing should be selected. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); assertState(-1, -1, ""); await hidePopup(); @@ -113,7 +113,7 @@ add_task(async function() { // Key down through each result. The first result is already selected, which // is why gMaxResults - 1 is the correct number of times to do this. for (let i = 0; i < gMaxResults - 1; i++) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); // i starts at zero so that the textValue passed to assertState is correct. // But that means that i + 1 is the expected selected index, since initially // (when this loop starts) the first result is selected. @@ -125,30 +125,30 @@ add_task(async function() { let numButtons = gURLBar.popup.oneOffSearchButtons.getSelectableButtons(true).length; for (let i = 0; i < numButtons; i++) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(-1, i, typedValue); } // Key down once more. The selection should wrap around to the first result. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(0, -1, typedValue); // Now key up. The selection should wrap back around to the one-offs. Key // up through all the one-offs. for (let i = numButtons - 1; i >= 0; i--) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); assertState(-1, i, typedValue); } // Key up through each non-heuristic result. for (let i = gMaxResults - 2; i >= 0; i--) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); assertState(i + 1, -1, "example.com/browser_urlbarOneOffs.js/?" + (gMaxResults - i - 1)); } // Key up once more. The heuristic result should be selected. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); assertState(0, -1, typedValue); await hidePopup(); @@ -169,7 +169,7 @@ add_task(async function searchWith() { // Alt+Down to the first one-off. Now the first result and the first one-off // should both be selected. - EventUtils.synthesizeKey("VK_DOWN", { altKey: true }); + EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true }); assertState(0, 0, typedValue); let engineName = gURLBar.popup.oneOffSearchButtons.selectedButton.engine.name; @@ -216,13 +216,13 @@ add_task(async function oneOffReturn() { assertState(0, -1, typedValue); // Alt+Down to select the first one-off. - EventUtils.synthesizeKey("VK_DOWN", { altKey: true }); + EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true }); assertState(0, 0, typedValue); let resultsPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, "http://mochi.test:8888/?terms=foo.bar"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await resultsPromise; gBrowser.removeTab(gBrowser.selectedTab); @@ -243,7 +243,7 @@ add_task(async function collapsedOneOffs() { assertState(0, -1); Assert.ok(gURLBar.popup.oneOffSearchButtons.buttons.collapsed, "The one-off buttons should be collapsed"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); assertState(1, -1); await hidePopup(); }); @@ -259,6 +259,6 @@ function assertState(result, oneOff, textValue = undefined) { } async function hidePopup() { - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promisePopupHidden(gURLBar.popup); } diff --git a/browser/base/content/test/urlbar/browser_urlbarOneOffs_searchSuggestions.js b/browser/base/content/test/urlbar/browser_urlbarOneOffs_searchSuggestions.js index c426278df1ad..4db2921f02bf 100644 --- a/browser/base/content/test/urlbar/browser_urlbarOneOffs_searchSuggestions.js +++ b/browser/base/content/test/urlbar/browser_urlbarOneOffs_searchSuggestions.js @@ -31,21 +31,21 @@ add_task(async function oneOffReturnAfterSuggestion() { assertState(0, -1, typedValue); // Down to select the first search suggestion. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(1, -1, "foofoo"); // Down to select the next search suggestion. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(2, -1, "foobar"); // Alt+Down to select the first one-off. - EventUtils.synthesizeKey("VK_DOWN", { altKey: true }); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); assertState(2, 0, "foobar"); let resultsPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, `http://mochi.test:8888/?terms=foobar`); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await resultsPromise; await PlacesUtils.history.clear(); @@ -62,11 +62,11 @@ add_task(async function oneOffClickAfterSuggestion() { assertState(0, -1, typedValue); // Down to select the first search suggestion. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(1, -1, "foofoo"); // Down to select the next search suggestion. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(2, -1, "foobar"); let oneOffs = gURLBar.popup.oneOffSearchButtons.getSelectableButtons(true); @@ -87,11 +87,11 @@ add_task(async function overridden_engine_not_reused() { await promiseAutocompleteResultPopup(typedValue, window, true); await promiseSuggestionsPresent(); // Down to select the first search suggestion. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); assertState(1, -1, "foofoo"); // ALT+Down to select the second search engine. - EventUtils.synthesizeKey("VK_DOWN", { altKey: true }); - EventUtils.synthesizeKey("VK_DOWN", { altKey: true }); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); assertState(1, 1, "foofoo"); let label = gURLBar.popup.richlistbox.children[gURLBar.popup.richlistbox.selectedIndex].label; @@ -116,6 +116,6 @@ function assertState(result, oneOff, textValue = undefined) { } async function hidePopup() { - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promisePopupHidden(gURLBar.popup); } diff --git a/browser/base/content/test/urlbar/browser_urlbarRevert.js b/browser/base/content/test/urlbar/browser_urlbarRevert.js index 5394c05038d1..76dcbdd7cb38 100644 --- a/browser/base/content/test/urlbar/browser_urlbarRevert.js +++ b/browser/base/content/test/urlbar/browser_urlbarRevert.js @@ -28,7 +28,7 @@ function checkURLBarRevert() { gURLBar.focus(); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); is(gURLBar.value, originalValue, "ESC reverted the location bar value"); diff --git a/browser/base/content/test/urlbar/browser_urlbarSearchSuggestions.js b/browser/base/content/test/urlbar/browser_urlbarSearchSuggestions.js index ac86779ef4ea..0cfb5b947faf 100644 --- a/browser/base/content/test/urlbar/browser_urlbarSearchSuggestions.js +++ b/browser/base/content/test/urlbar/browser_urlbarSearchSuggestions.js @@ -56,9 +56,9 @@ async function testPressEnterOnSuggestion(expectedUrl = null, keyModifiers = {}) let promiseLoad = waitForDocLoadAndStopIt(expectedUrl); for (let i = 0; i < idx; ++i) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); } - EventUtils.synthesizeKey("VK_RETURN", keyModifiers); + EventUtils.synthesizeKey("KEY_Enter", keyModifiers); await promiseLoad; await BrowserTestUtils.removeTab(tab); @@ -80,13 +80,13 @@ add_task(async function copySuggestionText() { await promiseAutocompleteResultPopup("foo"); let [idx, suggestion] = await promiseFirstSuggestion(); for (let i = 0; i < idx; ++i) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); } gURLBar.select(); await new Promise((resolve, reject) => waitForClipboard(suggestion, function() { goDoCommand("cmd_copy"); }, resolve, reject)); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promisePopupHidden(gURLBar.popup); }); diff --git a/browser/base/content/test/urlbar/browser_urlbarSearchSuggestions_opt-out.js b/browser/base/content/test/urlbar/browser_urlbarSearchSuggestions_opt-out.js index ee0d010d50e9..eeb48be8dc92 100644 --- a/browser/base/content/test/urlbar/browser_urlbarSearchSuggestions_opt-out.js +++ b/browser/base/content/test/urlbar/browser_urlbarSearchSuggestions_opt-out.js @@ -47,9 +47,7 @@ add_task(async function focus() { Assert.equal(gURLBar.popup.matchCount, 0, "popup should have no results"); // Start searching. - EventUtils.synthesizeKey("r", {}); - EventUtils.synthesizeKey("n", {}); - EventUtils.synthesizeKey("d", {}); + EventUtils.sendString("rnd"); await promiseSearchComplete(); Assert.ok(suggestionsPresent()); assertVisible(true); diff --git a/browser/base/content/test/urlbar/browser_urlbar_autoFill_backspaced.js b/browser/base/content/test/urlbar/browser_urlbar_autoFill_backspaced.js index 4f462427ef56..e44d497364a7 100644 --- a/browser/base/content/test/urlbar/browser_urlbar_autoFill_backspaced.js +++ b/browser/base/content/test/urlbar/browser_urlbar_autoFill_backspaced.js @@ -11,7 +11,7 @@ async function test_autocomplete(data) { if (onAutoFill) onAutoFill(); - keys.forEach(key => EventUtils.synthesizeKey(key, {})); + keys.forEach(key => EventUtils.synthesizeKey(key)); is(gURLBar.textValue, modified, "backspaced value is as expected"); @@ -46,14 +46,14 @@ add_task(async function() { typed: "exam", autofilled: "example.com/", modified: "exam", - keys: ["VK_DELETE"], + keys: ["KEY_Delete"], action: "searchengine" }); await test_autocomplete({ desc: "DELETE the final slash should visit", typed: "example.com", autofilled: "example.com/", modified: "example.com", - keys: ["VK_DELETE"], + keys: ["KEY_Delete"], action: "visiturl" }); @@ -61,14 +61,14 @@ add_task(async function() { typed: "exam", autofilled: "example.com/", modified: "exam", - keys: ["VK_BACK_SPACE"], + keys: ["KEY_Backspace"], action: "searchengine" }); await test_autocomplete({ desc: "BACK_SPACE the final slash should visit", typed: "example.com", autofilled: "example.com/", modified: "example.com", - keys: ["VK_BACK_SPACE"], + keys: ["KEY_Backspace"], action: "visiturl" }); @@ -76,14 +76,14 @@ add_task(async function() { typed: "exam", autofilled: "example.com/", modified: "exa", - keys: ["VK_DELETE", "VK_BACK_SPACE"], + keys: ["KEY_Delete", "KEY_Backspace"], action: "searchengine" }); await test_autocomplete({ desc: "DELETE the final slash, then BACK_SPACE, should search", typed: "example.com", autofilled: "example.com/", modified: "example.co", - keys: ["VK_DELETE", "VK_BACK_SPACE"], + keys: ["KEY_Delete", "KEY_Backspace"], action: "visiturl" }); @@ -91,14 +91,14 @@ add_task(async function() { typed: "exam", autofilled: "example.com/", modified: "exa", - keys: ["VK_BACK_SPACE", "VK_BACK_SPACE"], + keys: ["KEY_Backspace", "KEY_Backspace"], action: "searchengine" }); await test_autocomplete({ desc: "BACK_SPACE the final slash, then BACK_SPACE, should search", typed: "example.com", autofilled: "example.com/", modified: "example.co", - keys: ["VK_BACK_SPACE", "VK_BACK_SPACE"], + keys: ["KEY_Backspace", "KEY_Backspace"], action: "visiturl" }); @@ -106,7 +106,7 @@ add_task(async function() { typed: "ex", autofilled: "example.com/", modified: "e", - keys: ["VK_BACK_SPACE"], + keys: ["KEY_Backspace"], action: "searchengine", onAutoFill: () => { gURLBar.blur(); @@ -119,7 +119,7 @@ add_task(async function() { typed: "ex", autofilled: "example.com/", modified: "e", - keys: ["VK_DELETE"], + keys: ["KEY_Delete"], action: "searchengine", onAutoFill: () => { gURLBar.blur(); @@ -132,7 +132,7 @@ add_task(async function() { typed: "ex", autofilled: "example.com/", modified: "e", - keys: ["VK_BACK_SPACE", "VK_BACK_SPACE"], + keys: ["KEY_Backspace", "KEY_Backspace"], action: "searchengine", onAutoFill: () => { gURLBar.blur(); diff --git a/browser/base/content/test/urlbar/browser_urlbar_canonize_on_autofill.js b/browser/base/content/test/urlbar/browser_urlbar_canonize_on_autofill.js index 54fa1490b8d2..4ebb6f226f46 100644 --- a/browser/base/content/test/urlbar/browser_urlbar_canonize_on_autofill.js +++ b/browser/base/content/test/urlbar/browser_urlbar_canonize_on_autofill.js @@ -14,7 +14,7 @@ async function test_autocomplete(data) { let promiseLoad = waitForDocLoadAndStopIt(waitForUrl); - keys.forEach(([key, mods]) => EventUtils.synthesizeKey(key, mods || {})); + keys.forEach(([key, mods]) => EventUtils.synthesizeKey(key, mods)); is(gURLBar.textValue, modified, "value is as expected"); @@ -41,7 +41,7 @@ add_task(async function() { autofilled: "example.com/", modified: "example.com/", waitForUrl: "http://example.com/", - keys: [["VK_RETURN", {}]] + keys: [["KEY_Enter"]] }); await test_autocomplete({ desc: "CTRL+ENTER on the autofilled part should bypass autofill", @@ -49,9 +49,9 @@ add_task(async function() { autofilled: "example.com/", modified: "www.exam.com", waitForUrl: "http://www.exam.com/", - keys: [["VK_RETURN", AppConstants.platform === "macosx" ? - { metaKey: true } : - { ctrlKey: true }]] + keys: [["KEY_Enter", AppConstants.platform === "macosx" ? + {metaKey: true} : + {ctrlKey: true}]] }); await test_autocomplete({ desc: "SHIFT+ENTER on the autofilled part should bypass autofill", @@ -59,6 +59,6 @@ add_task(async function() { autofilled: "example.com/", modified: "www.exam.net", waitForUrl: "http://www.exam.net/", - keys: [["VK_RETURN", { shiftKey: true }]] + keys: [["KEY_Enter", {shiftKey: true}]] }); }); diff --git a/browser/base/content/test/urlbar/browser_urlbar_locationchange_urlbar_edit_dos.js b/browser/base/content/test/urlbar/browser_urlbar_locationchange_urlbar_edit_dos.js index ffd037c31dac..0934fe2bb1fb 100644 --- a/browser/base/content/test/urlbar/browser_urlbar_locationchange_urlbar_edit_dos.js +++ b/browser/base/content/test/urlbar/browser_urlbar_locationchange_urlbar_edit_dos.js @@ -2,7 +2,7 @@ async function checkURLBarValueStays(browser) { gURLBar.select(); - EventUtils.synthesizeKey("a", {}); + EventUtils.sendString("a"); is(gURLBar.value, "a", "URL bar value should match after sending a key"); await new Promise(resolve => { let listener = { diff --git a/browser/base/content/test/urlbar/browser_urlbar_remove_match.js b/browser/base/content/test/urlbar/browser_urlbar_remove_match.js index 6d78cc866891..3745aa4b74cb 100644 --- a/browser/base/content/test/urlbar/browser_urlbar_remove_match.js +++ b/browser/base/content/test/urlbar/browser_urlbar_remove_match.js @@ -17,10 +17,10 @@ add_task(async function test_remove_history() { let result = await waitForAutocompleteResultAt(1); Assert.equal(result.getAttribute("ac-value"), TEST_URL, "Found the expected result"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); Assert.equal(gURLBar.popup.richlistbox.selectedIndex, 1); let options = AppConstants.platform == "macosx" ? { shiftKey: true } : {}; - EventUtils.synthesizeKey("VK_DELETE", options); + EventUtils.synthesizeKey("KEY_Delete", options); await promiseVisitRemoved; await BrowserTestUtils.waitForCondition( () => !gURLBar.popup.richlistbox.children.some(c => !c.collapsed && c.getAttribute("ac-value") == TEST_URL), diff --git a/browser/base/content/test/urlbar/browser_urlbar_searchsettings.js b/browser/base/content/test/urlbar/browser_urlbar_searchsettings.js index 67ef27c8fa54..b3d8916e1b36 100644 --- a/browser/base/content/test/urlbar/browser_urlbar_searchsettings.js +++ b/browser/base/content/test/urlbar/browser_urlbar_searchsettings.js @@ -14,7 +14,7 @@ add_task(async function() { let popupopened = BrowserTestUtils.waitForEvent(gURLBar.popup, "popupshown"); gURLBar.focus(); - EventUtils.synthesizeKey("a", {}); + EventUtils.sendString("a"); await popupopened; // Since the current tab is blank the preferences pane will load there diff --git a/browser/components/customizableui/test/browser_901207_searchbar_in_panel.js b/browser/components/customizableui/test/browser_901207_searchbar_in_panel.js index cf2666a34d54..cfd20bc3d15f 100644 --- a/browser/components/customizableui/test/browser_901207_searchbar_in_panel.js +++ b/browser/components/customizableui/test/browser_901207_searchbar_in_panel.js @@ -26,7 +26,7 @@ add_task(async function() { await waitForSearchBarFocus(); let hiddenPanelPromise = promiseOverflowHidden(window); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await hiddenPanelPromise; CustomizableUI.reset(); }); @@ -43,7 +43,7 @@ add_task(async function() { await waitForSearchBarFocus(); let hiddenPanelPromise = promiseOverflowHidden(window); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await hiddenPanelPromise; CustomizableUI.reset(); }); @@ -71,7 +71,7 @@ add_task(async function() { await waitForSearchBarFocus(); let hiddenPanelPromise = promiseOverflowHidden(window); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await hiddenPanelPromise; Services.prefs.setBoolPref("browser.search.widget.inNavBar", false); @@ -98,9 +98,9 @@ add_task(async function() { function sendWebSearchKeyCommand() { if (Services.appinfo.OS === "Darwin") - EventUtils.synthesizeKey("k", { accelKey: true }); + EventUtils.synthesizeKey("k", {accelKey: true}); else - EventUtils.synthesizeKey("k", { ctrlKey: true }); + EventUtils.synthesizeKey("k", {ctrlKey: true}); } function logActiveElement() { diff --git a/browser/components/customizableui/test/browser_940307_panel_click_closure_handling.js b/browser/components/customizableui/test/browser_940307_panel_click_closure_handling.js index 2bc7b41fdf9a..2e6c90cb058f 100644 --- a/browser/components/customizableui/test/browser_940307_panel_click_closure_handling.js +++ b/browser/components/customizableui/test/browser_940307_panel_click_closure_handling.js @@ -61,7 +61,7 @@ add_task(async function searchbar_in_panel() { ok(isOverflowOpen(), "Panel should still be open"); let hiddenPanelPromise = promiseOverflowHidden(window); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await hiddenPanelPromise; ok(!isOverflowOpen(), "Panel should no longer be open"); diff --git a/browser/components/customizableui/test/browser_984455_bookmarks_items_reparenting.js b/browser/components/customizableui/test/browser_984455_bookmarks_items_reparenting.js index 0bbabe9341ee..410890f2b286 100644 --- a/browser/components/customizableui/test/browser_984455_bookmarks_items_reparenting.js +++ b/browser/components/customizableui/test/browser_984455_bookmarks_items_reparenting.js @@ -103,7 +103,7 @@ function checkSpecialContextMenus() { */ function closePopup(aPopup) { let hiddenPromise = popupHidden(aPopup); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); return hiddenPromise; } diff --git a/browser/components/customizableui/test/browser_panelUINotifications_fullscreen.js b/browser/components/customizableui/test/browser_panelUINotifications_fullscreen.js index c8d5eb42c09d..1decb4e022e8 100644 --- a/browser/components/customizableui/test/browser_panelUINotifications_fullscreen.js +++ b/browser/components/customizableui/test/browser_panelUINotifications_fullscreen.js @@ -19,7 +19,7 @@ add_task(async function testFullscreen() { is(doorhanger.id, "appMenu-update-manual-notification", "PanelUI is displaying the update-manual notification."); let popuphiddenPromise = BrowserTestUtils.waitForEvent(PanelUI.notificationPanel, "popuphidden"); - EventUtils.synthesizeKey("VK_F11", {}); + EventUtils.synthesizeKey("KEY_F11"); await popuphiddenPromise; await new Promise(executeSoon); is(PanelUI.notificationPanel.state, "closed", "update-manual doorhanger is closed."); @@ -28,7 +28,7 @@ add_task(async function testFullscreen() { is(PanelUI.menuButton.getAttribute("badge-status"), "update-manual", "Badge is displaying on PanelUI button."); let popupshownPromise = BrowserTestUtils.waitForEvent(PanelUI.notificationPanel, "popupshown"); - EventUtils.synthesizeKey("VK_F11", {}); + EventUtils.synthesizeKey("KEY_F11"); await popupshownPromise; await new Promise(executeSoon); isnot(PanelUI.notificationPanel.state, "closed", "update-manual doorhanger is showing."); diff --git a/browser/components/customizableui/test/browser_panelUINotifications_fullscreen_noAutoHideToolbar.js b/browser/components/customizableui/test/browser_panelUINotifications_fullscreen_noAutoHideToolbar.js index c38cad430661..690a287c0554 100644 --- a/browser/components/customizableui/test/browser_panelUINotifications_fullscreen_noAutoHideToolbar.js +++ b/browser/components/customizableui/test/browser_panelUINotifications_fullscreen_noAutoHideToolbar.js @@ -50,7 +50,7 @@ add_task(async function testFullscreen() { is(doorhanger.id, "appMenu-update-manual-notification", "PanelUI is displaying the update-manual notification."); let fullscreenPromise = waitForFullscreen(); - EventUtils.synthesizeKey("VK_F11", {}); + EventUtils.synthesizeKey("KEY_F11"); await fullscreenPromise; isnot(PanelUI.notificationPanel.state, "closed", "update-manual doorhanger is still showing after entering fullscreen."); @@ -78,6 +78,6 @@ add_task(async function testFullscreen() { is(PanelUI.menuButton.hasAttribute("badge-status"), false, "Should not have a badge status"); fullscreenPromise = BrowserTestUtils.waitForEvent(window, "fullscreen"); - EventUtils.synthesizeKey("VK_F11", {}); + EventUtils.synthesizeKey("KEY_F11"); await fullscreenPromise; }); diff --git a/browser/components/customizableui/test/browser_panel_keyboard_navigation.js b/browser/components/customizableui/test/browser_panel_keyboard_navigation.js index 25c5e1a0b8a8..bdee8ccd3253 100644 --- a/browser/components/customizableui/test/browser_panel_keyboard_navigation.js +++ b/browser/components/customizableui/test/browser_panel_keyboard_navigation.js @@ -17,12 +17,12 @@ add_task(async function testUpDownKeys() { for (let button of buttons) { if (button.disabled) continue; - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); Assert.equal(document.commandDispatcher.focusedElement, button, "The correct button should be focused after navigating downward"); } - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); Assert.equal(document.commandDispatcher.focusedElement, buttons[0], "Pressing upwards should cycle around and select the first button again"); @@ -30,7 +30,7 @@ add_task(async function testUpDownKeys() { let button = buttons[i]; if (button.disabled) continue; - EventUtils.synthesizeKey("KEY_ArrowUp", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); Assert.equal(document.commandDispatcher.focusedElement, button, "The first button should be focused after navigating upward"); } @@ -48,7 +48,7 @@ add_task(async function testEnterKeyBehaviors() { let buttons = PanelView.forNode(PanelUI.mainView).getNavigableElements(); // Navigate to the 'Help' button, which points to a subview. - EventUtils.synthesizeKey("KEY_ArrowUp", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); let focusedElement = document.commandDispatcher.focusedElement; Assert.equal(focusedElement, buttons[buttons.length - 1], "The last button should be focused after navigating upward"); @@ -56,10 +56,10 @@ add_task(async function testEnterKeyBehaviors() { promise = BrowserTestUtils.waitForEvent(PanelUI.helpView, "ViewShown"); // Make sure the Help button is in focus. while (!focusedElement || !focusedElement.id || focusedElement.id != kHelpButtonId) { - EventUtils.synthesizeKey("KEY_ArrowUp", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); focusedElement = document.commandDispatcher.focusedElement; } - EventUtils.synthesizeKey("KEY_Enter", {}); + EventUtils.synthesizeKey("KEY_Enter"); await promise; let helpButtons = PanelView.forNode(PanelUI.helpView).getNavigableElements(); @@ -71,33 +71,33 @@ add_task(async function testEnterKeyBehaviors() { let button = helpButtons[i]; if (button.disabled) continue; - EventUtils.synthesizeKey("KEY_ArrowUp", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); focusedElement = document.commandDispatcher.focusedElement; Assert.equal(focusedElement, button, "The first button should be focused after navigating upward"); } // Make sure the back button is in focus again. while (focusedElement != helpButtons[0]) { - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); focusedElement = document.commandDispatcher.focusedElement; } // The first button is the back button. Hittin Enter should navigate us back. promise = BrowserTestUtils.waitForEvent(PanelUI.mainView, "ViewShown"); - EventUtils.synthesizeKey("KEY_Enter", {}); + EventUtils.synthesizeKey("KEY_Enter"); await promise; // Let's test a 'normal' command button. focusedElement = document.commandDispatcher.focusedElement; const kFindButtonId = "appMenu-find-button"; while (!focusedElement || !focusedElement.id || focusedElement.id != kFindButtonId) { - EventUtils.synthesizeKey("KEY_ArrowUp", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); focusedElement = document.commandDispatcher.focusedElement; } Assert.equal(focusedElement.id, kFindButtonId, "Find button should be selected"); promise = promisePanelHidden(window); - EventUtils.synthesizeKey("KEY_Enter", {}); + EventUtils.synthesizeKey("KEY_Enter"); await promise; Assert.ok(!gFindBar.hidden, "Findbar should have opened"); @@ -112,7 +112,7 @@ add_task(async function testLeftRightKeys() { // Navigate to the 'Help' button, which points to a subview. let focusedElement = document.commandDispatcher.focusedElement; while (!focusedElement || !focusedElement.id || focusedElement.id != kHelpButtonId) { - EventUtils.synthesizeKey("KEY_ArrowUp", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); focusedElement = document.commandDispatcher.focusedElement; } Assert.equal(focusedElement.id, kHelpButtonId, "The last button should be focused after navigating upward"); @@ -120,12 +120,12 @@ add_task(async function testLeftRightKeys() { // Hitting ArrowRight on a button that points to a subview should navigate us // there. promise = BrowserTestUtils.waitForEvent(PanelUI.helpView, "ViewShown"); - EventUtils.synthesizeKey("KEY_ArrowRight", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); await promise; // Hitting ArrowLeft should navigate us back. promise = BrowserTestUtils.waitForEvent(PanelUI.mainView, "ViewShown"); - EventUtils.synthesizeKey("KEY_ArrowLeft", {}); + EventUtils.synthesizeKey("KEY_ArrowLeft"); await promise; focusedElement = document.commandDispatcher.focusedElement; @@ -147,12 +147,12 @@ add_task(async function testTabKey() { for (let button of buttons) { if (button.disabled) continue; - EventUtils.synthesizeKey("KEY_Tab", {}); + EventUtils.synthesizeKey("KEY_Tab"); Assert.equal(document.commandDispatcher.focusedElement, button, "The correct button should be focused after tabbing"); } - EventUtils.synthesizeKey("KEY_Tab", {}); + EventUtils.synthesizeKey("KEY_Tab"); Assert.equal(document.commandDispatcher.focusedElement, buttons[0], "Pressing tab should cycle around and select the first button again"); @@ -186,9 +186,9 @@ add_task(async function testInterleavedTabAndArrowKeys() { if (button.disabled) continue; if (tab) { - EventUtils.synthesizeKey("KEY_Tab", {}); + EventUtils.synthesizeKey("KEY_Tab"); } else { - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); } tab = !tab; } @@ -212,7 +212,7 @@ add_task(async function testSpaceDownAfterTabNavigation() { for (button of buttons) { if (button.disabled) continue; - EventUtils.synthesizeKey("KEY_Tab", {}); + EventUtils.synthesizeKey("KEY_Tab"); if (button.id == kHelpButtonId) { break; } diff --git a/browser/components/extensions/test/browser/browser_ext_omnibox.js b/browser/components/extensions/test/browser/browser_ext_omnibox.js index 8934017be324..0b68b6ee0165 100644 --- a/browser/components/extensions/test/browser/browser_ext_omnibox.js +++ b/browser/components/extensions/test/browser/browser_ext_omnibox.js @@ -111,12 +111,12 @@ add_task(async function() { async function startInputSession(indexToWaitFor) { gURLBar.focus(); gURLBar.value = keyword; - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); await expectEvent("on-input-started-fired"); // Always use a different input at every invokation, so that // waitForAutocompleteResultAt can distinguish different cases. let char = ((inputSessionSerial++) % 10).toString(); - EventUtils.synthesizeKey(char, {}); + EventUtils.sendString(char); await expectEvent("on-input-changed-fired", {text: char}); // Wait for the autocomplete search. Note that we cannot wait for the search @@ -131,58 +131,52 @@ add_task(async function() { gURLBar.focus(); // Start an input session by typing in . - for (let letter of keyword) { - EventUtils.synthesizeKey(letter, {}); - } - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(keyword + " "); await expectEvent("on-input-started-fired"); // Test canceling the input before any changed events fire. - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); await expectEvent("on-input-cancelled-fired"); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); await expectEvent("on-input-started-fired"); // Test submitting the input before any changed events fire. - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await expectEvent("on-input-entered-fired"); gURLBar.focus(); // Start an input session by typing in . - for (let letter of keyword) { - EventUtils.synthesizeKey(letter, {}); - } - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(keyword + " "); await expectEvent("on-input-started-fired"); // We should expect input changed events now that the keyword is active. - EventUtils.synthesizeKey("b", {}); + EventUtils.sendString("b"); await expectEvent("on-input-changed-fired", {text: "b"}); - EventUtils.synthesizeKey("c", {}); + EventUtils.sendString("c"); await expectEvent("on-input-changed-fired", {text: "bc"}); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); await expectEvent("on-input-changed-fired", {text: "b"}); // Even though the input is We should not expect an // input started event to fire since the keyword is active. - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); await expectEvent("on-input-changed-fired", {text: ""}); // Make the keyword inactive by hitting backspace. - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); await expectEvent("on-input-cancelled-fired"); // Activate the keyword by typing a space. // Expect onInputStarted to fire. - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); await expectEvent("on-input-started-fired"); // onInputChanged should fire even if a space is entered. - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); await expectEvent("on-input-changed-fired", {text: " "}); // The active session should cancel if the input blurs. @@ -222,9 +216,7 @@ add_task(async function() { await startInputSession(suggestionIndex); // Select the suggestion. - for (let i = 0; i < suggestionIndex; i++) { - EventUtils.synthesizeKey("VK_DOWN", {}); - } + EventUtils.synthesizeKey("KEY_ArrowDown", {repeat: suggestionIndex}); let promiseEvent = expectEvent("on-input-entered-fired", { text: expectedText, diff --git a/browser/components/places/tests/browser/browser_bookmarklet_windowOpen.js b/browser/components/places/tests/browser/browser_bookmarklet_windowOpen.js index a184130df372..16b368d620d1 100644 --- a/browser/components/places/tests/browser/browser_bookmarklet_windowOpen.js +++ b/browser/components/places/tests/browser/browser_bookmarklet_windowOpen.js @@ -46,7 +46,7 @@ add_task(async function openKeywordBookmarkWithWindowOpen() { gURLBar.focus(); let tabCreatedPromise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); info("Waiting for tab being created"); let {target: tab} = await tabCreatedPromise; diff --git a/browser/components/places/tests/browser/browser_stayopenmenu.js b/browser/components/places/tests/browser/browser_stayopenmenu.js index b2148c82a7af..c877794dfc4d 100644 --- a/browser/components/places/tests/browser/browser_stayopenmenu.js +++ b/browser/components/places/tests/browser/browser_stayopenmenu.js @@ -22,9 +22,9 @@ async function testContextmenu(menuitem) { EventUtils.synthesizeMouseAtCenter(menuitem, {type: "contextmenu", button: 2}); await promiseEvent; let promiseTabOpened = BrowserTestUtils.waitForNewTab(gBrowser, null); - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); BrowserTestUtils.waitForEvent(menuitem, "DOMMenuItemActive"); - EventUtils.synthesizeKey("KEY_ArrowDown", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); BrowserTestUtils.waitForEvent(menuitem, "DOMMenuItemActive"); EventUtils.sendKey("return"); let newTab = await promiseTabOpened; diff --git a/browser/components/places/tests/browser/browser_toolbarbutton_menu_context.js b/browser/components/places/tests/browser/browser_toolbarbutton_menu_context.js index 52ad796bd4db..9da1a93744a7 100644 --- a/browser/components/places/tests/browser/browser_toolbarbutton_menu_context.js +++ b/browser/components/places/tests/browser/browser_toolbarbutton_menu_context.js @@ -37,7 +37,7 @@ async function checkPopupContextMenu() { await contextMenuHiddenPromise; let popupHiddenPromise = onPopupEvent(BMB_menuPopup, "hidden"); // Can't use synthesizeMouseAtCenter because the dropdown panel is in the way - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); info("Waiting for bookmarks menu to be hidden."); await popupHiddenPromise; } diff --git a/browser/components/places/tests/chrome/test_editBookmarkOverlay_keywords.xul b/browser/components/places/tests/chrome/test_editBookmarkOverlay_keywords.xul index 5bc1ab3ae894..8c0597ad2b1a 100644 --- a/browser/components/places/tests/chrome/test_editBookmarkOverlay_keywords.xul +++ b/browser/components/places/tests/chrome/test_editBookmarkOverlay_keywords.xul @@ -80,8 +80,8 @@ let promise = promiseOnItemChanged(); keywordField.focus(); keywordField.value = "kw"; - synthesizeKey(i.toString(), {}); - synthesizeKey("VK_RETURN", {}); + sendString(i.toString()); + synthesizeKey("KEY_Enter"); keywordField.blur(); let {property, value} = await promise; is(property, "keyword", "The keyword should have been changed"); diff --git a/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js b/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js index 82a463ee795c..0be7a3a3fb52 100644 --- a/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js +++ b/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js @@ -16,13 +16,13 @@ add_task(async function() { // Test button let button = doc.getElementById("button"); button.focus(); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); await checkPageScrolling(container, "button"); // Test checkbox let checkbox = doc.getElementById("checkbox"); checkbox.focus(); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); ok(checkbox.checked, "Checkbox is checked"); await checkPageScrolling(container, "checkbox"); @@ -30,14 +30,14 @@ add_task(async function() { let listbox = doc.getElementById("listbox"); let listitem = doc.getElementById("listitem"); listbox.focus(); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); ok(listitem.selected, "Listitem is selected"); await checkPageScrolling(container, "listbox"); // Test radio let radiogroup = doc.getElementById("radiogroup"); radiogroup.focus(); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); await checkPageScrolling(container, "radio"); }); @@ -49,9 +49,9 @@ add_task(async function() { // Test search let engineList = doc.getElementById("engineList"); engineList.focus(); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); is(engineList.view.selection.currentIndex, 0, "Search engineList is selected"); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); await checkPageScrolling(container, "search engineList"); }); @@ -80,7 +80,7 @@ add_task(async function() { let tabsToggle = doc.getElementById("tabsToggle"); tabsToggle.focus(); - EventUtils.synthesizeKey(" ", {}); + EventUtils.sendString(" "); await checkPageScrolling(doc.documentElement, "session restore"); gBrowser.removeCurrentTab(); diff --git a/browser/components/preferences/in-content/tests/browser_cookies_dialog.js b/browser/components/preferences/in-content/tests/browser_cookies_dialog.js index ec6f96e3ed09..f8c7dfcc5d17 100644 --- a/browser/components/preferences/in-content/tests/browser_cookies_dialog.js +++ b/browser/components/preferences/in-content/tests/browser_cookies_dialog.js @@ -33,9 +33,9 @@ add_task(async function testDeleteCookie() { tree.view.selection.select(0); if (AppConstants.platform == "macosx") { - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); } else { - EventUtils.synthesizeKey("VK_DELETE", {}); + EventUtils.synthesizeKey("KEY_Delete"); } await TestUtils.waitForCondition(() => tree.view.rowCount == 0); diff --git a/browser/components/preferences/in-content/tests/browser_password_management.js b/browser/components/preferences/in-content/tests/browser_password_management.js index 012b81d8ccbe..208dfec8dabe 100644 --- a/browser/components/preferences/in-content/tests/browser_password_management.js +++ b/browser/components/preferences/in-content/tests/browser_password_management.js @@ -59,9 +59,9 @@ add_task(async function test_deletePasswordWithKey() { tree.view.selection.select(0); if (AppConstants.platform == "macosx") { - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); } else { - EventUtils.synthesizeKey("VK_DELETE", {}); + EventUtils.synthesizeKey("KEY_Delete"); } await TestUtils.waitForCondition(() => tree.view.rowCount == 0); diff --git a/browser/components/preferences/in-content/tests/browser_site_login_exceptions.js b/browser/components/preferences/in-content/tests/browser_site_login_exceptions.js index cb577694f424..97455c064317 100644 --- a/browser/components/preferences/in-content/tests/browser_site_login_exceptions.js +++ b/browser/components/preferences/in-content/tests/browser_site_login_exceptions.js @@ -64,9 +64,9 @@ add_task(async function deleteALoginException() { tree.view.selection.select(0); if (AppConstants.platform == "macosx") { - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); } else { - EventUtils.synthesizeKey("VK_DELETE", {}); + EventUtils.synthesizeKey("KEY_Delete"); } await TestUtils.waitForCondition(() => tree.view.rowCount == 0); diff --git a/browser/components/search/test/browser_426329.js b/browser/components/search/test/browser_426329.js index d03f94eda15d..c913d82d98c1 100644 --- a/browser/components/search/test/browser_426329.js +++ b/browser/components/search/test/browser_426329.js @@ -135,7 +135,7 @@ add_task(async function testSetupEngine() { add_task(async function testReturn() { await prepareTest(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); is(gBrowser.tabs.length, preTabNo, "Return key did not open new tab"); @@ -145,7 +145,7 @@ add_task(async function testReturn() { add_task(async function testAltReturn() { await prepareTest(); await BrowserTestUtils.openNewForegroundTab(gBrowser, () => { - EventUtils.synthesizeKey("VK_RETURN", { altKey: true }); + EventUtils.synthesizeKey("KEY_Enter", {altKey: true}); }); is(gBrowser.tabs.length, preTabNo + 1, "Alt+Return key added new tab"); @@ -237,7 +237,7 @@ add_task(async function testClearHistory() { EventUtils.synthesizeMouseAtCenter(textbox, { type: "contextmenu", button: 2 }); await popupShownPromise; // Close the context menu. - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); let controller = searchBar.textbox.controllers.getControllerForCommand("cmd_clearhistory"); ok(controller.isCommandEnabled("cmd_clearhistory"), "Clear history command enabled"); diff --git a/browser/components/search/test/browser_google_behavior.js b/browser/components/search/test/browser_google_behavior.js index 5c24729d2e22..6cd51fe4f999 100644 --- a/browser/components/search/test/browser_google_behavior.js +++ b/browser/components/search/test/browser_google_behavior.js @@ -138,7 +138,7 @@ async function testSearchEngine(engineDetails) { run() { gURLBar.value = "? foo"; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } }, { @@ -147,7 +147,7 @@ async function testSearchEngine(engineDetails) { run() { gURLBar.value = `${engineDetails.alias} foo`; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } }, { @@ -158,7 +158,7 @@ async function testSearchEngine(engineDetails) { let sb = BrowserSearch.searchBar; sb.focus(); sb.value = "foo"; - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); }, postTest() { BrowserSearch.searchBar.value = ""; @@ -181,7 +181,7 @@ async function testSearchEngine(engineDetails) { input.focus(); input.value = "foo"; }); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } } ]; diff --git a/browser/components/search/test/browser_healthreport.js b/browser/components/search/test/browser_healthreport.js index 66190e527f4b..39fcc04e677a 100644 --- a/browser/components/search/test/browser_healthreport.js +++ b/browser/components/search/test/browser_healthreport.js @@ -47,7 +47,7 @@ function test() { Services.search.removeEngine(fooEngine); } - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); executeSoon(() => executeSoon(afterSearch)); } diff --git a/browser/components/search/test/browser_hiddenOneOffs_diacritics.js b/browser/components/search/test/browser_hiddenOneOffs_diacritics.js index 31b3b5f7c7d7..0e49f1542f39 100644 --- a/browser/components/search/test/browser_hiddenOneOffs_diacritics.js +++ b/browser/components/search/test/browser_hiddenOneOffs_diacritics.js @@ -44,7 +44,7 @@ add_task(async function test_hidden() { promise = promiseEvent(searchPopup, "popuphidden"); info("Closing search panel"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promise; }); diff --git a/browser/components/search/test/browser_oneOffContextMenu.js b/browser/components/search/test/browser_oneOffContextMenu.js index b786d56ead96..34db77b4ba9d 100644 --- a/browser/components/search/test/browser_oneOffContextMenu.js +++ b/browser/components/search/test/browser_oneOffContextMenu.js @@ -74,7 +74,7 @@ async function doTest() { // By default the search will open in the background and the popup will stay open: promise = promiseEvent(searchPopup, "popuphidden"); info("Closing search panel"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promise; // Check the loaded tab. diff --git a/browser/components/search/test/browser_oneOffContextMenu_setDefault.js b/browser/components/search/test/browser_oneOffContextMenu_setDefault.js index b1e057deba7a..e5bbb6bb02c0 100644 --- a/browser/components/search/test/browser_oneOffContextMenu_setDefault.js +++ b/browser/components/search/test/browser_oneOffContextMenu_setDefault.js @@ -150,7 +150,7 @@ async function openPopupAndGetEngineButton(isSearch, popup, oneOffBinding, baseI } else { // There's no history at this stage, so we need to press a key. urlbar.focus(); - EventUtils.synthesizeKey("a", {}); + EventUtils.sendString("a"); } await promise; @@ -195,7 +195,7 @@ async function openPopupAndGetEngineButton(isSearch, popup, oneOffBinding, baseI async function promiseClosePopup(popup) { // close the panel using the escape key. let promise = promiseEvent(popup, "popuphidden"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promise; // Move the cursor out of the panel area to avoid messing with other tests. diff --git a/browser/components/search/test/browser_oneOffHeader.js b/browser/components/search/test/browser_oneOffHeader.js index d70ebe566b9e..fa396031f303 100644 --- a/browser/components/search/test/browser_oneOffHeader.js +++ b/browser/components/search/test/browser_oneOffHeader.js @@ -94,7 +94,7 @@ add_task(async function test_notext() { promise = promiseEvent(searchPopup, "popuphidden"); info("Closing search panel"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promise; }); diff --git a/browser/components/search/test/browser_searchEngine_behaviors.js b/browser/components/search/test/browser_searchEngine_behaviors.js index c136ae9f7d6f..b4e3fce6ddd4 100644 --- a/browser/components/search/test/browser_searchEngine_behaviors.js +++ b/browser/components/search/test/browser_searchEngine_behaviors.js @@ -159,7 +159,7 @@ async function testSearchEngine(engineDetails) { run() { gURLBar.value = "? foo"; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } }, { @@ -168,7 +168,7 @@ async function testSearchEngine(engineDetails) { run() { gURLBar.value = `${engineDetails.alias} foo`; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } }, { @@ -181,7 +181,7 @@ async function testSearchEngine(engineDetails) { registerCleanupFunction(function() { sb.value = ""; }); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } }, { @@ -200,7 +200,7 @@ async function testSearchEngine(engineDetails) { input.focus(); input.value = "foo"; }); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } } ]; diff --git a/browser/components/search/test/browser_searchbar_keyboard_navigation.js b/browser/components/search/test/browser_searchbar_keyboard_navigation.js index fdea2956b38b..821f7f63b34f 100644 --- a/browser/components/search/test/browser_searchbar_keyboard_navigation.js +++ b/browser/components/search/test/browser_searchbar_keyboard_navigation.js @@ -92,7 +92,7 @@ add_task(async function test_arrows() { // The down arrow should first go through the suggestions. for (let i = 0; i < kValues.length; ++i) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(searchPopup.selectedIndex, i, "the suggestion at index " + i + " should be selected"); is(textbox.value, kValues[i], @@ -101,7 +101,7 @@ add_task(async function test_arrows() { // Pressing down again should remove suggestion selection and change the text // field value back to what the user typed, and select the first one-off. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, kUserValue, "the textfield value should be back to initial value"); @@ -110,32 +110,32 @@ add_task(async function test_arrows() { for (let i = 0; i < oneOffs.length; ++i) { is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); } is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); // We should now be back to the initial situation. is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); ok(!textbox.selectedButton, "no one-off button should be selected"); info("now test the up arrow key"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); // cycle through the one-off items, the first one is already selected. for (let i = oneOffs.length; i; --i) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton, oneOffs[i - 1], "the one-off button #" + i + " should be selected"); } // Another press on up should clear the one-off selection and select the // last suggestion. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); ok(!textbox.selectedButton, "no one-off button should be selected"); for (let i = kValues.length - 1; i >= 0; --i) { @@ -143,7 +143,7 @@ add_task(async function test_arrows() { "the suggestion at index " + i + " should be selected"); is(textbox.value, kValues[i], "the textfield value should be " + kValues[i]); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); } is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); @@ -156,16 +156,16 @@ add_task(async function test_typing_clears_button_selection() { "the search bar should be focused"); // from the previous test. ok(!textbox.selectedButton, "no button should be selected"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); // Type a character. - EventUtils.synthesizeKey("a", {}); + EventUtils.sendString("a"); ok(!textbox.selectedButton, "the settings item should be de-selected"); // Remove the character. - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); }); add_task(async function test_tab() { @@ -178,7 +178,7 @@ add_task(async function test_tab() { // Pressing tab should select the first one-off without selecting suggestions. // now cycle through the one-off items, the first one is already selected. for (let i = 0; i < oneOffs.length; ++i) { - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); } @@ -186,13 +186,13 @@ add_task(async function test_tab() { is(textbox.value, kUserValue, "the textfield value should be unmodified"); // One more selects the settings button. - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); // Pressing tab again should close the panel... let promise = promiseEvent(searchPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); await promise; // ... and move the focus out of the searchbox. @@ -211,26 +211,26 @@ add_task(async function test_shift_tab() { ok(!textbox.selectedButton, "no one-off button should be selected"); // Press up once to select the last button. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); // Press up again to select the last one-off button. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); // Pressing shift+tab should cycle through the one-off items. for (let i = oneOffs.length - 1; i >= 0; --i) { is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); if (i) - EventUtils.synthesizeKey("VK_TAB", {shiftKey: true}); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); } is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, kUserValue, "the textfield value should be unmodified"); // Pressing shift+tab again should close the panel... promise = promiseEvent(searchPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_TAB", {shiftKey: true}); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); await promise; // ... and move the focus out of the searchbox. @@ -247,12 +247,12 @@ add_task(async function test_alt_down() { // close the panel using the escape key. promise = promiseEvent(searchPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promise; // check that alt+down opens the panel... promise = promiseEvent(searchPopup, "popupshown"); - EventUtils.synthesizeKey("VK_DOWN", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); await promise; // ... and does nothing else. @@ -264,18 +264,18 @@ add_task(async function test_alt_down() { // and cycle through the one-off items. let oneOffs = getOneOffs(); for (let i = 0; i < oneOffs.length; ++i) { - EventUtils.synthesizeKey("VK_DOWN", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); } // One more alt+down keypress and nothing should be selected. - EventUtils.synthesizeKey("VK_DOWN", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); ok(!textbox.selectedButton, "no one-off button should be selected"); // another one and the first one-off should be selected. - EventUtils.synthesizeKey("VK_DOWN", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); is(textbox.selectedButton, oneOffs[0], "the first one-off button should be selected"); }); @@ -283,12 +283,12 @@ add_task(async function test_alt_down() { add_task(async function test_alt_up() { // close the panel using the escape key. let promise = promiseEvent(searchPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promise; // check that alt+up opens the panel... promise = promiseEvent(searchPopup, "popupshown"); - EventUtils.synthesizeKey("VK_UP", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowUp", {altKey: true}); await promise; // ... and does nothing else. @@ -300,26 +300,26 @@ add_task(async function test_alt_up() { // and cycle up through the one-off items. let oneOffs = getOneOffs(); for (let i = oneOffs.length - 1; i >= 0; --i) { - EventUtils.synthesizeKey("VK_UP", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowUp", {altKey: true}); is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); } // One more alt+down keypress and nothing should be selected. - EventUtils.synthesizeKey("VK_UP", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowUp", {altKey: true}); ok(!textbox.selectedButton, "no one-off button should be selected"); // another one and the last one-off should be selected. - EventUtils.synthesizeKey("VK_UP", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowUp", {altKey: true}); is(textbox.selectedButton, oneOffs[oneOffs.length - 1], "the last one-off button should be selected"); // Cleanup for the next test. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); ok(!textbox.selectedButton, "no one-off should be selected anymore"); }); @@ -330,7 +330,7 @@ add_task(async function test_tab_and_arrows() { is(textbox.value, kUserValue, "the textfield value should be unmodified"); // After pressing down, the first sugggestion should be selected. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(searchPopup.selectedIndex, 0, "first suggestion should be selected"); is(textbox.value, kValues[0], "the textfield value should have changed"); ok(!textbox.selectedButton, "no one-off button should be selected"); @@ -338,31 +338,31 @@ add_task(async function test_tab_and_arrows() { // After pressing tab, the first one-off should be selected, // and no suggestion should be selected. let oneOffs = getOneOffs(); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(textbox.selectedButton, oneOffs[0], "the first one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); // After pressing down, the second one-off should be selected. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.selectedButton, oneOffs[1], "the second one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); // After pressing right, the third one-off should be selected. - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); is(textbox.selectedButton, oneOffs[2], "the third one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); // After pressing left, the second one-off should be selected again. - EventUtils.synthesizeKey("VK_LEFT", {}); + EventUtils.synthesizeKey("KEY_ArrowLeft"); is(textbox.selectedButton, oneOffs[1], "the second one-off button should be selected again"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); // After pressing up, the first one-off should be selected again. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton, oneOffs[0], "the first one-off button should be selected again"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); @@ -370,7 +370,7 @@ add_task(async function test_tab_and_arrows() { // After pressing up again, the last suggestion should be selected. // the textfield value back to the user-typed value, and still the first one-off // selected. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(searchPopup.selectedIndex, kValues.length - 1, "last suggestion should be selected"); is(textbox.value, kValues[kValues.length - 1], @@ -379,7 +379,7 @@ add_task(async function test_tab_and_arrows() { "no one-off button should be selected"); // Now pressing down should select the first one-off. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.selectedButton, oneOffs[0], "the first one-off button should be selected"); is(searchPopup.selectedIndex, -1, "there should be no selected suggestion"); @@ -407,13 +407,13 @@ add_task(async function test_open_search() { ok(!textbox.selectedButton, "no button should be selected"); // Pressing up once selects the setting button... - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); // ...and then pressing up selects open search engines. for (let i = engines.length; i; --i) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); let selectedButton = textbox.selectedButton; is(selectedButton, engines[i - 1], "the engine #" + i + " should be selected"); @@ -422,19 +422,19 @@ add_task(async function test_open_search() { } // Pressing up again should select the last one-off button. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton, getOneOffs().pop(), "the last one-off button should be selected"); info("now check that the down key navigates open search items as expected"); for (let i = 0; i < engines.length; ++i) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.selectedButton, engines[i], "the engine #" + (i + 1) + " should be selected"); } // Pressing down on the last engine item selects the settings button. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); diff --git a/browser/components/search/test/browser_searchbar_openpopup.js b/browser/components/search/test/browser_searchbar_openpopup.js index f72249adf6f2..5cd5997334e8 100644 --- a/browser/components/search/test/browser_searchbar_openpopup.js +++ b/browser/components/search/test/browser_searchbar_openpopup.js @@ -246,7 +246,7 @@ add_task(async function focus_change_closes_popup() { promise = promiseEvent(searchPopup, "popuphidden"); let promise2 = promiseEvent(searchbar, "blur"); - EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); await promise; await promise2; @@ -269,7 +269,7 @@ add_task(async function focus_change_closes_small_popup() { promise = promiseEvent(searchPopup, "popuphidden"); let promise2 = promiseEvent(searchbar, "blur"); - EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); await promise; await promise2; }); @@ -289,7 +289,7 @@ add_task(async function escape_closes_popup() { is(textbox.selectionEnd, 3, "Should have selected all of the text"); promise = promiseEvent(searchPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promise; textbox.value = ""; @@ -332,7 +332,7 @@ add_task(async function tab_opens_popup() { textbox.value = "foo"; let promise = promiseEvent(searchPopup, "popupshown"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); await promise; isnot(searchPopup.getAttribute("showonlysettings"), "true", "Should show the full popup"); @@ -352,7 +352,7 @@ add_no_popup_task(function tab_doesnt_open_popup() { gURLBar.focus(); textbox.value = "foo"; - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(Services.focus.focusedElement, textbox.inputField, "Should have focused the search bar"); is(textbox.selectionStart, 0, "Should have selected all of the text"); @@ -404,7 +404,7 @@ add_task(async function refocus_window_doesnt_open_popup_keyboard() { textbox.value = "foo"; let promise = promiseEvent(searchPopup, "popupshown"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); await promise; isnot(searchPopup.getAttribute("showonlysettings"), "true", "Should show the full popup"); @@ -502,45 +502,45 @@ add_task(async function dont_rollup_oncaretmove() { await promise; // Deselect the text - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); is(textbox.selectionStart, 9, "Should have moved the caret (selectionStart after deselect right)"); is(textbox.selectionEnd, 9, "Should have moved the caret (selectionEnd after deselect right)"); is(searchPopup.state, "open", "Popup should still be open"); - EventUtils.synthesizeKey("VK_LEFT", {}); + EventUtils.synthesizeKey("KEY_ArrowLeft"); is(textbox.selectionStart, 8, "Should have moved the caret (selectionStart after left)"); is(textbox.selectionEnd, 8, "Should have moved the caret (selectionEnd after left)"); is(searchPopup.state, "open", "Popup should still be open"); - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); is(textbox.selectionStart, 9, "Should have moved the caret (selectionStart after right)"); is(textbox.selectionEnd, 9, "Should have moved the caret (selectionEnd after right)"); is(searchPopup.state, "open", "Popup should still be open"); // Ensure caret movement works while a suggestion is selected. is(textbox.popup.selectedIndex, -1, "No selected item in list"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.popup.selectedIndex, 0, "Selected item in list"); is(textbox.selectionStart, 9, "Should have moved the caret to the end (selectionStart after selection)"); is(textbox.selectionEnd, 9, "Should have moved the caret to the end (selectionEnd after selection)"); - EventUtils.synthesizeKey("VK_LEFT", {}); + EventUtils.synthesizeKey("KEY_ArrowLeft"); is(textbox.selectionStart, 8, "Should have moved the caret again (selectionStart after left)"); is(textbox.selectionEnd, 8, "Should have moved the caret again (selectionEnd after left)"); is(searchPopup.state, "open", "Popup should still be open"); - EventUtils.synthesizeKey("VK_LEFT", {}); + EventUtils.synthesizeKey("KEY_ArrowLeft"); is(textbox.selectionStart, 7, "Should have moved the caret (selectionStart after left)"); is(textbox.selectionEnd, 7, "Should have moved the caret (selectionEnd after left)"); is(searchPopup.state, "open", "Popup should still be open"); - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); is(textbox.selectionStart, 8, "Should have moved the caret (selectionStart after right)"); is(textbox.selectionEnd, 8, "Should have moved the caret (selectionEnd after right)"); is(searchPopup.state, "open", "Popup should still be open"); if (!navigator.platform.includes("Mac")) { - EventUtils.synthesizeKey("VK_HOME", {}); + EventUtils.synthesizeKey("KEY_Home"); is(textbox.selectionStart, 0, "Should have moved the caret (selectionStart after home)"); is(textbox.selectionEnd, 0, "Should have moved the caret (selectionEnd after home)"); is(searchPopup.state, "open", "Popup should still be open"); @@ -548,7 +548,7 @@ add_task(async function dont_rollup_oncaretmove() { // Close the popup again promise = promiseEvent(searchPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promise; textbox.value = ""; @@ -560,7 +560,7 @@ add_task(async function dont_open_in_customization() { textbox.value = "foo"; let promise = promiseEvent(searchPopup, "popupshown"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); await promise; isnot(searchPopup.getAttribute("showonlysettings"), "true", "Should show the full popup"); diff --git a/browser/components/search/test/browser_searchbar_smallpanel_keyboard_navigation.js b/browser/components/search/test/browser_searchbar_smallpanel_keyboard_navigation.js index 5114b06f4db3..c27c35f9e6d9 100644 --- a/browser/components/search/test/browser_searchbar_smallpanel_keyboard_navigation.js +++ b/browser/components/search/test/browser_searchbar_smallpanel_keyboard_navigation.js @@ -95,7 +95,7 @@ info("textbox.mController.searchString = " + textbox.mController.searchString); ok(!textbox.selectedButton, "no one-off button should be selected"); // Pressing should select the first one-off. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, "", "the textfield value should be unmodified"); @@ -103,31 +103,31 @@ info("textbox.mController.searchString = " + textbox.mController.searchString); for (let i = 0; i < oneOffs.length; ++i) { is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); } is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); // We should now be back to the initial situation. is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); ok(!textbox.selectedButton, "no one-off button should be selected"); info("now test the up arrow key"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); // cycle through the one-off items, the first one is already selected. for (let i = oneOffs.length; i; --i) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton, oneOffs[i - 1], "the one-off button #" + i + " should be selected"); } // Another press on up should clear the one-off selection. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); ok(!textbox.selectedButton, "no one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, "", "the textfield value should be unmodified"); @@ -143,7 +143,7 @@ add_task(async function test_tab() { // Pressing tab should select the first one-off without selecting suggestions. // now cycle through the one-off items, the first one is already selected. for (let i = 0; i < oneOffs.length; ++i) { - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); } @@ -151,13 +151,13 @@ add_task(async function test_tab() { is(textbox.value, "", "the textfield value should be unmodified"); // One more selects the settings button. - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); // Pressing tab again should close the panel... let promise = promiseEvent(searchPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); await promise; // ... and move the focus out of the searchbox. @@ -179,26 +179,26 @@ add_task(async function test_shift_tab() { is(searchPopup.getAttribute("showonlysettings"), "true", "Should show the small popup"); // Press up once to select the last button. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); // Press up again to select the last one-off button. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); // Pressing shift+tab should cycle through the one-off items. for (let i = oneOffs.length - 1; i >= 0; --i) { is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); if (i) - EventUtils.synthesizeKey("VK_TAB", {shiftKey: true}); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); } is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); is(textbox.value, "", "the textfield value should be unmodified"); // Pressing shift+tab again should close the panel... promise = promiseEvent(searchPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_TAB", {shiftKey: true}); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); await promise; // ... and move the focus out of the searchbox. @@ -225,23 +225,23 @@ add_task(async function test_alt_down() { // and cycle through the one-off items. let oneOffs = getOneOffs(); for (let i = 0; i < oneOffs.length; ++i) { - EventUtils.synthesizeKey("VK_DOWN", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); } // One more alt+down keypress and nothing should be selected. - EventUtils.synthesizeKey("VK_DOWN", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); ok(!textbox.selectedButton, "no one-off button should be selected"); // another one and the first one-off should be selected. - EventUtils.synthesizeKey("VK_DOWN", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); is(textbox.selectedButton, oneOffs[0], "the first one-off button should be selected"); // Clear the selection with an alt+up keypress - EventUtils.synthesizeKey("VK_UP", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowUp", {altKey: true}); ok(!textbox.selectedButton, "no one-off button should be selected"); }); @@ -255,26 +255,26 @@ add_task(async function test_alt_up() { // and cycle up through the one-off items. let oneOffs = getOneOffs(); for (let i = oneOffs.length - 1; i >= 0; --i) { - EventUtils.synthesizeKey("VK_UP", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowUp", {altKey: true}); is(textbox.selectedButton, oneOffs[i], "the one-off button #" + (i + 1) + " should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); } // One more alt+down keypress and nothing should be selected. - EventUtils.synthesizeKey("VK_UP", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowUp", {altKey: true}); ok(!textbox.selectedButton, "no one-off button should be selected"); // another one and the last one-off should be selected. - EventUtils.synthesizeKey("VK_UP", {altKey: true}); + EventUtils.synthesizeKey("KEY_ArrowUp", {altKey: true}); is(textbox.selectedButton, oneOffs[oneOffs.length - 1], "the last one-off button should be selected"); // Cleanup for the next test. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); ok(!textbox.selectedButton, "no one-off should be selected anymore"); }); @@ -286,19 +286,19 @@ add_task(async function test_tab_and_arrows() { // After pressing down, the first one-off should be selected. let oneOffs = getOneOffs(); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.selectedButton, oneOffs[0], "the first one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); // After pressing tab, the second one-off should be selected. - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(textbox.selectedButton, oneOffs[1], "the second one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); // After pressing up, the first one-off should be selected again. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton, oneOffs[0], "the first one-off button should be selected"); is(searchPopup.selectedIndex, -1, "no suggestion should be selected"); @@ -327,13 +327,13 @@ add_task(async function test_open_search() { ok(!textbox.selectedButton, "no button should be selected"); // Pressing up once selects the setting button... - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); // ...and then pressing up selects open search engines. for (let i = engines.length; i; --i) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); let selectedButton = textbox.selectedButton; is(selectedButton, engines[i - 1], "the engine #" + i + " should be selected"); @@ -342,19 +342,19 @@ add_task(async function test_open_search() { } // Pressing up again should select the last one-off button. - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(textbox.selectedButton, getOneOffs().pop(), "the last one-off button should be selected"); info("now check that the down key navigates open search items as expected"); for (let i = 0; i < engines.length; ++i) { - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.selectedButton, engines[i], "the engine #" + (i + 1) + " should be selected"); } // Pressing down on the last engine item selects the settings button. - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(textbox.selectedButton.getAttribute("anonid"), "search-settings", "the settings item should be selected"); diff --git a/browser/components/search/test/browser_tooManyEnginesOffered.js b/browser/components/search/test/browser_tooManyEnginesOffered.js index 61e8ed4770f2..a670a952d533 100644 --- a/browser/components/search/test/browser_tooManyEnginesOffered.js +++ b/browser/components/search/test/browser_tooManyEnginesOffered.js @@ -24,7 +24,7 @@ add_task(async function test() { let promise = promiseEvent(searchPopup, "popupshown"); info("Opening search panel"); searchbar.focus(); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); await promise; // Make sure it has only one add-engine menu button item. @@ -60,19 +60,19 @@ add_task(async function test() { for (let button = null; button != menuButton; button = searchbar.textbox.popup.oneOffButtons.selectedButton) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); } // Press the Right arrow key. The submenu should open. promise = promiseEvent(buttonPopup, "popupshown"); - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); await promise; Assert.ok(menuButton.open, "Submenu should be open"); // Press the Esc key. The submenu should close. promise = promiseEvent(buttonPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await promise; Assert.ok(!menuButton.open, "Submenu should be closed"); diff --git a/browser/components/sessionstore/test/browser_522545.js b/browser/components/sessionstore/test/browser_522545.js index 79cde61258f4..f4c3ca3887b4 100644 --- a/browser/components/sessionstore/test/browser_522545.js +++ b/browser/components/sessionstore/test/browser_522545.js @@ -231,7 +231,7 @@ function test() { let inputText = "example.org"; gURLBar.focus(); gURLBar.value = inputText.slice(0, -1); - EventUtils.synthesizeKey(inputText.slice(-1), {}); + EventUtils.sendString(inputText.slice(-1)); executeSoon(function() { is(browser.userTypedValue, "example.org", diff --git a/browser/extensions/formautofill/test/mochitest/formautofill_common.js b/browser/extensions/formautofill/test/mochitest/formautofill_common.js index 44954cd5f0dc..d40cd2e91d41 100644 --- a/browser/extensions/formautofill/test/mochitest/formautofill_common.js +++ b/browser/extensions/formautofill/test/mochitest/formautofill_common.js @@ -119,7 +119,7 @@ function triggerAutofillAndCheckProfile(profile) { promises.push(checkFieldAutofilled); } // Press Enter key and trigger form autofill. - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); return Promise.all(promises); } @@ -243,10 +243,10 @@ function initPopupListener() { async function triggerPopupAndHoverItem(fieldSelector, selectIndex) { await focusAndWaitForFieldsIdentified(fieldSelector); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); for (let i = 0; i <= selectIndex; i++) { - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); } await notifySelectedIndex(selectIndex); } diff --git a/browser/extensions/formautofill/test/mochitest/test_autofocus_form.html b/browser/extensions/formautofill/test/mochitest/test_autofocus_form.html index d7ca916ebacf..401d151b6979 100644 --- a/browser/extensions/formautofill/test/mochitest/test_autofocus_form.html +++ b/browser/extensions/formautofill/test/mochitest/test_autofocus_form.html @@ -39,7 +39,7 @@ async function setupAddressStorage() { add_task(async function check_autocomplete_on_autofocus_field() { await setupAddressStorage(); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({primary: address.organization, secondary: address["street-address"]}) diff --git a/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html b/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html index 7623b53be84d..759d2382aef3 100644 --- a/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html +++ b/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html @@ -54,7 +54,7 @@ add_task(async function history_only_menu_checking() { await setupFormHistory(); await setInput("#tel", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["+1234567890"], false); }); @@ -67,7 +67,7 @@ add_task(async function all_saved_fields_less_than_threshold() { }); await setInput("#email", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["foo@mozilla.com"], false); @@ -79,7 +79,7 @@ add_task(async function check_menu_when_both_existed() { await setupAddressStorage(); await setInput("#organization", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({ @@ -89,7 +89,7 @@ add_task(async function check_menu_when_both_existed() { )); await setInput("#street-address", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({ @@ -99,7 +99,7 @@ add_task(async function check_menu_when_both_existed() { )); await setInput("#tel", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({ @@ -109,7 +109,7 @@ add_task(async function check_menu_when_both_existed() { )); await setInput("#address-line1", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({ @@ -122,7 +122,7 @@ add_task(async function check_menu_when_both_existed() { // Display history search result if no matched data in addresses. add_task(async function check_fallback_for_mismatched_field() { await setInput("#email", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["foo@mozilla.com"], false); }); @@ -134,7 +134,7 @@ add_task(async function check_search_result_for_pref_off() { }); await setInput("#tel", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["+1234567890"], false); @@ -144,7 +144,7 @@ add_task(async function check_search_result_for_pref_off() { // Autofill the address from dropdown menu. add_task(async function check_fields_after_form_autofill() { const focusedInput = await setInput("#organization", "Moz"); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({ @@ -152,16 +152,16 @@ add_task(async function check_fields_after_form_autofill() { secondary: FormAutofillUtils.toOneLineAddress(address["street-address"]), }) ).slice(1)); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await triggerAutofillAndCheckProfile(MOCK_STORAGE[1]); - synthesizeKey("KEY_Escape", {}); + synthesizeKey("KEY_Escape"); is(focusedInput.value, "Mozilla", "Filled field shouldn't be reverted by ESC key"); }); // Fallback to history search after autofill address. add_task(async function check_fallback_after_form_autofill() { await setInput("#tel", "", true); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["+1234567890"], false); }); @@ -171,7 +171,7 @@ add_task(async function check_form_autofill_resume() { document.querySelector("#tel").blur(); document.querySelector("#form1").reset(); await setInput("#tel", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({ diff --git a/browser/extensions/formautofill/test/mochitest/test_basic_creditcard_autocomplete_form.html b/browser/extensions/formautofill/test/mochitest/test_basic_creditcard_autocomplete_form.html index 9ae808a08b3e..bca4b3525e2f 100644 --- a/browser/extensions/formautofill/test/mochitest/test_basic_creditcard_autocomplete_form.html +++ b/browser/extensions/formautofill/test/mochitest/test_basic_creditcard_autocomplete_form.html @@ -62,7 +62,7 @@ add_task(async function history_only_menu_checking() { await setupFormHistory(); await setInput("#cc-exp-year", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["2023"], false); }); @@ -72,7 +72,7 @@ add_task(async function all_saved_fields_less_than_threshold() { await addCreditCard(reducedMockRecord); await setInput("#cc-name", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries([reducedMockRecord].map(patchRecordCCNumber).map(cc => JSON.stringify({ primary: cc["cc-name"], @@ -87,7 +87,7 @@ add_task(async function check_menu_when_both_existed() { await setupCreditCardStorage(); await setInput("#cc-number", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(cc => JSON.stringify({ primaryAffix: cc.ccNumberFmt.affix, @@ -96,7 +96,7 @@ add_task(async function check_menu_when_both_existed() { }))); await setInput("#cc-name", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(cc => JSON.stringify({ primary: cc["cc-name"], @@ -104,7 +104,7 @@ add_task(async function check_menu_when_both_existed() { }))); await setInput("#cc-exp-year", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(cc => JSON.stringify({ primary: cc["cc-exp-year"], @@ -112,7 +112,7 @@ add_task(async function check_menu_when_both_existed() { }))); await setInput("#cc-exp-month", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(cc => JSON.stringify({ primary: cc["cc-exp-month"], @@ -127,7 +127,7 @@ add_task(async function check_fallback_for_mismatched_field() { await addCreditCard(reducedMockRecord); await setInput("#cc-exp-year", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["2023"], false); @@ -143,7 +143,7 @@ add_task(async function check_search_result_for_pref_off() { }); await setInput("#cc-name", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["John Smith"], false); @@ -154,21 +154,21 @@ add_task(async function check_search_result_for_pref_off() { add_task(async function check_fields_after_form_autofill() { await setInput("#cc-exp-year", 202); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.slice(1).map(patchRecordCCNumber).map(cc => JSON.stringify({ primary: cc["cc-exp-year"], secondary: cc.ccNumberFmt.affix + cc.ccNumberFmt.label, }))); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await triggerAutofillAndCheckProfile(MOCK_STORAGE[1]); }); // Fallback to history search after autofill address. add_task(async function check_fallback_after_form_autofill() { await setInput("#cc-name", "", true); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["John Smith"], false); }); @@ -179,7 +179,7 @@ add_task(async function check_form_autofill_resume() { document.querySelector("#form1").reset(); await setInput("#cc-name", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(cc => JSON.stringify({ primary: cc["cc-name"], diff --git a/browser/extensions/formautofill/test/mochitest/test_clear_form.html b/browser/extensions/formautofill/test/mochitest/test_clear_form.html index 4aa3a848049a..6e3da2b4aa42 100644 --- a/browser/extensions/formautofill/test/mochitest/test_clear_form.html +++ b/browser/extensions/formautofill/test/mochitest/test_clear_form.html @@ -71,7 +71,7 @@ add_task(async function simple_clear() { await triggerAutofillAndCheckProfile(MOCK_ADDR_STORAGE[0]); await triggerPopupAndHoverItem("#tel", 0); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); checkIsFormCleared(); }); @@ -80,7 +80,7 @@ add_task(async function clear_adapted_record() { await triggerAutofillAndCheckProfile(MOCK_ADDR_STORAGE[0]); await triggerPopupAndHoverItem("#street-address", 0); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); checkIsFormCleared(); }); @@ -91,7 +91,7 @@ add_task(async function clear_modified_form() { await setInput("#tel", "+1111111111", true); await triggerPopupAndHoverItem("#street-address", 0); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); checkIsFormCleared({tel: "+1111111111"}); }); @@ -103,7 +103,7 @@ add_task(async function clear_distinct_section() { await triggerPopupAndHoverItem("#organization", 0); await triggerAutofillAndCheckProfile(MOCK_ADDR_STORAGE[0]); await triggerPopupAndHoverItem("#street-address", 0); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); for (const [id, val] of Object.entries(MOCK_CC_STORAGE[0])) { const element = document.getElementById(id); @@ -115,7 +115,7 @@ add_task(async function clear_distinct_section() { } await triggerPopupAndHoverItem("#cc-name", 0); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); checkIsFormCleared(); }); diff --git a/browser/extensions/formautofill/test/mochitest/test_creditcard_autocomplete_off.html b/browser/extensions/formautofill/test/mochitest/test_creditcard_autocomplete_off.html index 7a46fae7b1b7..04b8d2b7d7fa 100644 --- a/browser/extensions/formautofill/test/mochitest/test_creditcard_autocomplete_off.html +++ b/browser/extensions/formautofill/test/mochitest/test_creditcard_autocomplete_off.html @@ -51,12 +51,12 @@ add_task(async function history_only_menu_checking() { await setupFormHistory(); await setInput("#cc-number", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(["1234000056780000"], false); await setInput("#cc-name", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await notExpectPopup(); }); @@ -65,7 +65,7 @@ add_task(async function check_menu_when_both_with_autocomplete_off() { await setupCreditCardStorage(); await setInput("#cc-number", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(cc => JSON.stringify({ primaryAffix: cc.ccNumberFmt.affix, @@ -74,7 +74,7 @@ add_task(async function check_menu_when_both_with_autocomplete_off() { }))); await setInput("#cc-name", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(cc => JSON.stringify({ primary: cc["cc-name"], diff --git a/browser/extensions/formautofill/test/mochitest/test_form_changes.html b/browser/extensions/formautofill/test/mochitest/test_form_changes.html index e68ce6eb022c..3d3a7fa6b5bb 100644 --- a/browser/extensions/formautofill/test/mochitest/test_form_changes.html +++ b/browser/extensions/formautofill/test/mochitest/test_form_changes.html @@ -50,7 +50,7 @@ function addInputField(form, className) { async function checkFormChangeHappened(formId) { info("expecting form changed"); await focusAndWaitForFieldsIdentified(`#${formId} input[name=tel]`); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({primary: address.tel, secondary: address.name}) @@ -60,7 +60,7 @@ async function checkFormChangeHappened(formId) { addInputField(document.querySelector(`#${formId}`), "address-level2"); await focusAndWaitForFieldsIdentified(`#${formId} input[name=name]`); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({primary: address.name, secondary: address["address-level2"]}) @@ -71,7 +71,7 @@ async function checkFormChangeHappened(formId) { addInputField(document.querySelector(`#${formId}`), "address-level2"); await focusAndWaitForFieldsIdentified(`#${formId} input[name=address-level2]`, true); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(MOCK_STORAGE.map(address => JSON.stringify({primary: address["address-level2"], secondary: address.name}) diff --git a/browser/extensions/formautofill/test/mochitest/test_formautofill_preview_highlight.html b/browser/extensions/formautofill/test/mochitest/test_formautofill_preview_highlight.html index ad467f9186d6..9749832b1df6 100644 --- a/browser/extensions/formautofill/test/mochitest/test_formautofill_preview_highlight.html +++ b/browser/extensions/formautofill/test/mochitest/test_formautofill_preview_highlight.html @@ -55,22 +55,22 @@ add_task(async function setup_storage() { add_task(async function check_preview() { const focusedInput = await setInput("#organization", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkFormFieldsStyle(null); for (let i = 0; i < MOCK_STORAGE.length; i++) { - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await notifySelectedIndex(i); checkFormFieldsStyle(MOCK_STORAGE[i]); } // Navigate to the footer - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await notifySelectedIndex(MOCK_STORAGE.length); checkFormFieldsStyle(null); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await notifySelectedIndex(-1); checkFormFieldsStyle(null); diff --git a/browser/extensions/formautofill/test/mochitest/test_multi_locale_CA_address_form.html b/browser/extensions/formautofill/test/mochitest/test_multi_locale_CA_address_form.html index 3f8aec65f189..9a26ef609250 100644 --- a/browser/extensions/formautofill/test/mochitest/test_multi_locale_CA_address_form.html +++ b/browser/extensions/formautofill/test/mochitest/test_multi_locale_CA_address_form.html @@ -89,7 +89,7 @@ function checkFormFilled(selector, address) { promises.push(...checkElementFilled(element, converted)); } } - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); return Promise.all(promises); } @@ -112,19 +112,19 @@ add_task(async function setup() { // Autofill the address with address level 1 code. add_task(async function autofill_with_level1_code() { await setInput("#organization-en", "Mozilla Toronto"); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); // Replace address level 1 code with full name in English for test result let result = Object.assign({}, MOCK_STORAGE[1], {"address-level1": "Ontario"}); await checkFormFilled("#form-en", result); await setInput("#organization-fr", "Mozilla Vancouver"); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); // Replace address level 1 code with full name in French for test result result = Object.assign({}, MOCK_STORAGE[0], {"address-level1": "Colombie-Britannique"}); await checkFormFilled("#form-fr", result); @@ -135,19 +135,19 @@ add_task(async function autofill_with_level1_code() { // Autofill the address with address level 1 full name. add_task(async function autofill_with_level1_full_name() { await setInput("#organization-en", "ExpoCité"); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); // Replace address level 1 code with full name in French for test result let result = Object.assign({}, MOCK_STORAGE[3], {"address-level1": "Quebec"}); await checkFormFilled("#form-en", result); await setInput("#organization-fr", "Prince of Wales Northern Heritage"); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); // Replace address level 1 code with full name in English for test result result = Object.assign({}, MOCK_STORAGE[2], {"address-level1": "Territoires du Nord-Ouest"}); await checkFormFilled("#form-fr", result); diff --git a/browser/extensions/formautofill/test/mochitest/test_multiple_forms.html b/browser/extensions/formautofill/test/mochitest/test_multiple_forms.html index 205da65281a2..08a024785ea6 100644 --- a/browser/extensions/formautofill/test/mochitest/test_multiple_forms.html +++ b/browser/extensions/formautofill/test/mochitest/test_multiple_forms.html @@ -33,19 +33,19 @@ add_task(async function setupStorage() { add_task(async function check_switch_form_popup() { await setInput("#additional-name", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); // We need an intentional wait here before switching form. await sleep(); await setInput("#organization", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); const {open: popupOpen} = await getPopupState(); is(popupOpen, false); await sleep(); await setInput("#given-name", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); }); diff --git a/browser/extensions/formautofill/test/mochitest/test_on_address_submission.html b/browser/extensions/formautofill/test/mochitest/test_on_address_submission.html index 3f33df659975..d0786446afc3 100644 --- a/browser/extensions/formautofill/test/mochitest/test_on_address_submission.html +++ b/browser/extensions/formautofill/test/mochitest/test_on_address_submission.html @@ -75,7 +75,7 @@ add_task(async function check_storage_after_another_address_submitted() { ok(matching, "New address saved as expected"); await setInput("#organization", ""); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); checkMenuEntries(addressesInMenu.map(address => JSON.stringify({primary: address.organization, secondary: address["street-address"]}) @@ -110,10 +110,10 @@ add_task(async function check_storage_after_form_submitted() { TEST_ADDRESSES[1].country = "US"; await setInput("#organization", "Moz"); - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); await expectPopup(); - synthesizeKey("KEY_ArrowDown", {}); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_ArrowDown"); + synthesizeKey("KEY_Enter"); clickOnElement("input[type=submit]"); let expectedAddresses = TEST_ADDRESSES.slice(0); diff --git a/browser/modules/test/browser/browser_UsageTelemetry_searchbar.js b/browser/modules/test/browser/browser_UsageTelemetry_searchbar.js index 0f888b6647c8..f251595b5484 100644 --- a/browser/modules/test/browser/browser_UsageTelemetry_searchbar.js +++ b/browser/modules/test/browser/browser_UsageTelemetry_searchbar.js @@ -101,7 +101,7 @@ add_task(async function test_plainQuery() { info("Simulate entering a simple search."); let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser); await searchInSearchbar("simple query"); - EventUtils.sendKey("return"); + EventUtils.synthesizeKey("KEY_Enter"); await p; // Check if the scalars contain the expected values. @@ -143,8 +143,8 @@ add_task(async function test_oneOff_enter() { await searchInSearchbar("query"); info("Pressing Alt+Down to highlight the first one off engine."); - EventUtils.synthesizeKey("VK_DOWN", { altKey: true }); - EventUtils.sendKey("return"); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); + EventUtils.synthesizeKey("KEY_Enter"); await p; // Check if the scalars contain the expected values. @@ -198,9 +198,9 @@ add_task(async function test_oneOff_enterSelection() { await searchInSearchbar("query"); info("Select the second result, press Alt+Down to take us to the first one-off engine."); - EventUtils.synthesizeKey("VK_DOWN", {}); - EventUtils.synthesizeKey("VK_DOWN", { altKey: true }); - EventUtils.sendKey("return"); + EventUtils.synthesizeKey("KEY_ArrowDown"); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); + EventUtils.synthesizeKey("KEY_Enter"); await p; let resultMethods = resultMethodHist.snapshot(); @@ -322,8 +322,8 @@ add_task(async function test_suggestion_enterSelection() { let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser); await searchInSearchbar("query"); info("Select the second result and press Return."); - EventUtils.synthesizeKey("VK_DOWN", {}); - EventUtils.sendKey("return"); + EventUtils.synthesizeKey("KEY_ArrowDown"); + EventUtils.synthesizeKey("KEY_Enter"); await p; let resultMethods = resultMethodHist.snapshot(); diff --git a/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js b/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js index e0164c99ff8b..9107b473eb58 100644 --- a/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js +++ b/browser/modules/test/browser/browser_UsageTelemetry_urlbar.js @@ -135,7 +135,7 @@ add_task(async function test_simpleQuery() { info("Simulate entering a simple search."); let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser); await searchInAwesomebar("simple query"); - EventUtils.sendKey("return"); + EventUtils.synthesizeKey("KEY_Enter"); await p; // Check if the scalars contain the expected values. @@ -190,7 +190,7 @@ add_task(async function test_searchAlias() { info("Search using a search alias."); let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser); await searchInAwesomebar("mozalias query"); - EventUtils.sendKey("return"); + EventUtils.synthesizeKey("KEY_Enter"); await p; // Check if the scalars contain the expected values. @@ -249,8 +249,8 @@ add_task(async function test_oneOff_enter() { await searchInAwesomebar("query"); info("Pressing Alt+Down to take us to the first one-off engine."); - EventUtils.synthesizeKey("VK_DOWN", { altKey: true }); - EventUtils.sendKey("return"); + EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true }); + EventUtils.synthesizeKey("KEY_Enter"); await p; // Check if the scalars contain the expected values. @@ -318,9 +318,9 @@ add_task(async function test_oneOff_enterSelection() { await searchInAwesomebar("query"); info("Select the second result, press Alt+Down to take us to the first one-off engine."); - EventUtils.synthesizeKey("VK_DOWN", {}); - EventUtils.synthesizeKey("VK_DOWN", { altKey: true }); - EventUtils.sendKey("return"); + EventUtils.synthesizeKey("KEY_ArrowDown"); + EventUtils.synthesizeKey("KEY_ArrowDown", {altKey: true}); + EventUtils.synthesizeKey("KEY_Enter"); await p; let resultMethods = resultMethodHist.snapshot(); @@ -460,8 +460,8 @@ add_task(async function test_suggestion_enterSelection() { let p = BrowserTestUtils.browserLoaded(tab.linkedBrowser); await searchInAwesomebar("query"); info("Select the second result and press Return."); - EventUtils.synthesizeKey("VK_DOWN", {}); - EventUtils.sendKey("return"); + EventUtils.synthesizeKey("KEY_ArrowDown"); + EventUtils.synthesizeKey("KEY_Enter"); await p; let resultMethods = resultMethodHist.snapshot(); diff --git a/browser/modules/test/browser/formValidation/browser_form_validation.js b/browser/modules/test/browser/formValidation/browser_form_validation.js index 21c73919a439..d3a311d644f0 100644 --- a/browser/modules/test/browser/formValidation/browser_form_validation.js +++ b/browser/modules/test/browser/formValidation/browser_form_validation.js @@ -188,7 +188,7 @@ add_task(async function() { await checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent); let popupHiddenPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popuphidden"); - EventUtils.synthesizeKey("a", {}); + EventUtils.sendString("a"); await popupHiddenPromise; gBrowser.removeCurrentTab(); @@ -211,7 +211,7 @@ add_task(async function() { await checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent); await new Promise((resolve, reject) => { - EventUtils.synthesizeKey("a", {}); + EventUtils.sendString("a"); executeSoon(function() { checkPopupShow(); resolve(); @@ -260,7 +260,7 @@ add_task(async function() { await checkChildFocus(browser, gInvalidFormPopup.firstChild.textContent); let popupHiddenPromise = BrowserTestUtils.waitForEvent(gInvalidFormPopup, "popuphidden"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); await popupHiddenPromise; gBrowser.removeCurrentTab(); @@ -394,7 +394,7 @@ add_task(async function() { // eslint-disable-next-line mozilla/no-cpows-in-tests let inputPromise = BrowserTestUtils.waitForEvent(gBrowser.contentDocument.getElementById("i"), "input"); - EventUtils.synthesizeKey("f", {}); + EventUtils.sendString("f"); await inputPromise; // Now, the element suffers from another error, the message should have diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_instruments-pane-collapse_keyboard.js b/devtools/client/debugger/test/mochitest/browser_dbg_instruments-pane-collapse_keyboard.js index 4e77ff57ac65..13ab5c04d00d 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg_instruments-pane-collapse_keyboard.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg_instruments-pane-collapse_keyboard.js @@ -18,22 +18,22 @@ async function test() { ok(panel.classList.contains("pane-collapsed"), "The instruments panel is initially in collapsed state"); - await togglePane(button, "Press on the toggle button to expand", panel, "VK_RETURN"); + await togglePane(button, "Press on the toggle button to expand", panel, "KEY_Enter"); ok(!panel.classList.contains("pane-collapsed"), "The instruments panel is in the expanded state"); - await togglePane(button, "Press on the toggle button to collapse", panel, "VK_SPACE"); + await togglePane(button, "Press on the toggle button to collapse", panel, " "); ok(panel.classList.contains("pane-collapsed"), "The instruments panel is in the collapsed state"); closeDebuggerAndFinish(aPanel); } -async function togglePane(button, message, pane, keycode) { +async function togglePane(button, message, pane, key) { let onTransitionEnd = once(pane, "transitionend"); info(message); button.focus(); - EventUtils.synthesizeKey(keycode, {}); + EventUtils.synthesizeKey(key); await onTransitionEnd; // Wait for the next event tick to make sure all transitionend event diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_paused-keybindings.js b/devtools/client/debugger/test/mochitest/browser_dbg_paused-keybindings.js index d0487a6613df..e7e97d25c350 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg_paused-keybindings.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg_paused-keybindings.js @@ -37,9 +37,8 @@ function test() { let caretMove = ensureCaretAt(panel, 15, 1, true); // Wait a tick for the editor focus event to occur first. executeSoon(function () { - EventUtils.synthesizeKey("l", { accelKey: true }); - EventUtils.synthesizeKey("1", {}); - EventUtils.synthesizeKey("5", {}); + EventUtils.synthesizeKey("l", {accelKey: true}); + EventUtils.sendString("15"); }); yield caretMove; diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_split-console-keypress.js b/devtools/client/debugger/test/mochitest/browser_dbg_split-console-keypress.js index 5bfe0a61e43d..29d971d4c683 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg_split-console-keypress.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg_split-console-keypress.js @@ -45,15 +45,15 @@ function test() { // Information for sub-tests. When 'key' is synthesized 'keyRepeat' times, // cursor should be at 'caretLine' of this test.. let stepTests = [ - {key: "VK_F11", keyRepeat: 1, caretLine: 16}, - {key: "VK_F11", keyRepeat: 2, caretLine: 18}, - {key: "VK_F11", keyRepeat: 2, caretLine: 27}, - {key: "VK_F10", keyRepeat: 1, caretLine: 27}, - {key: "VK_F11", keyRepeat: 1, caretLine: 18}, - {key: "VK_F11", keyRepeat: 5, caretLine: 32}, - {key: "VK_F11", modifier:"Shift", keyRepeat: 1, caretLine: 29}, - {key: "VK_F11", modifier:"Shift", keyRepeat: 2, caretLine: 34}, - {key: "VK_F11", modifier:"Shift", keyRepeat: 2, caretLine: 34} + {key: "KEY_F11", keyRepeat: 1, caretLine: 16}, + {key: "KEY_F11", keyRepeat: 2, caretLine: 18}, + {key: "KEY_F11", keyRepeat: 2, caretLine: 27}, + {key: "KEY_F10", keyRepeat: 1, caretLine: 27}, + {key: "KEY_F11", keyRepeat: 1, caretLine: 18}, + {key: "KEY_F11", keyRepeat: 5, caretLine: 32}, + {key: "KEY_F11", modifier:"Shift", keyRepeat: 1, caretLine: 29}, + {key: "KEY_F11", modifier:"Shift", keyRepeat: 2, caretLine: 34}, + {key: "KEY_F11", modifier:"Shift", keyRepeat: 2, caretLine: 34} ]; // Trigger script that stops at debugger statement executeSoon(() => generateMouseClickInTab(gTab, @@ -92,7 +92,7 @@ function test() { is(consoleLostFocus, false, "Console input should not lose focus"); // We're done with the tests in the stepTests array // Last key we test is "resume" - executeSoon(() => EventUtils.synthesizeKey("VK_F8", {})); + executeSoon(() => EventUtils.synthesizeKey("KEY_F8")); // We reset the variable tracking loss of focus to test the resume case consoleLostFocus = false; diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-accessibility.js b/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-accessibility.js index 8a3fe14886af..a35ffefb9d97 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-accessibility.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-accessibility.js @@ -83,176 +83,176 @@ function performTest() { // Part 1: Make sure that UP/DOWN keys don't scroll the variables view. - yield synthesizeKeyAndWaitForTick("VK_DOWN", {}); + yield synthesizeKeyAndWaitForTick("KEY_ArrowDown"); is(gVariablesView._parent.scrollTop, 0, "The 'variables' view shouldn't scroll when pressing the DOWN key."); - yield synthesizeKeyAndWaitForTick("VK_UP", {}); + yield synthesizeKeyAndWaitForTick("KEY_ArrowUp"); is(gVariablesView._parent.scrollTop, 0, "The 'variables' view shouldn't scroll when pressing the UP key."); // Part 2: Make sure that RETURN/ESCAPE toggle input elements. - yield synthesizeKeyAndWaitForElement("VK_RETURN", {}, ".element-value-input", true); - yield synthesizeKeyAndWaitForElement("VK_ESCAPE", {}, ".element-value-input", false); - yield synthesizeKeyAndWaitForElement("VK_RETURN", { shiftKey: true }, ".element-name-input", true); - yield synthesizeKeyAndWaitForElement("VK_ESCAPE", {}, ".element-name-input", false); + yield synthesizeKeyAndWaitForElement("KEY_Enter", {}, ".element-value-input", true); + yield synthesizeKeyAndWaitForElement("KEY_Escape", {}, ".element-value-input", false); + yield synthesizeKeyAndWaitForElement("KEY_Enter", {shiftKey: true}, ".element-name-input", true); + yield synthesizeKeyAndWaitForElement("KEY_Escape", {}, ".element-name-input", false); // Part 3: Test simple navigation. - EventUtils.sendKey("DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp1", "The 'someProp1' item should be focused."); - EventUtils.sendKey("UP", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp0", "The 'someProp0' item should be focused."); - EventUtils.sendKey("PAGE_DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp5", "The 'someProp5' item should be focused."); - EventUtils.sendKey("PAGE_UP", gDebugger); + EventUtils.synthesizeKey("KEY_PageUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp0", "The 'someProp0' item should be focused."); - EventUtils.sendKey("END", gDebugger); + EventUtils.synthesizeKey("KEY_End", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "__proto__", "The '__proto__' item should be focused."); - EventUtils.sendKey("HOME", gDebugger); + EventUtils.synthesizeKey("KEY_Home", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp0", "The 'someProp0' item should be focused."); // Part 4: Test if pressing the same navigation key twice works as expected. - EventUtils.sendKey("DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp1", "The 'someProp1' item should be focused."); - EventUtils.sendKey("DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp2", "The 'someProp2' item should be focused."); - EventUtils.sendKey("UP", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp1", "The 'someProp1' item should be focused."); - EventUtils.sendKey("UP", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp0", "The 'someProp0' item should be focused."); - EventUtils.sendKey("PAGE_DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp5", "The 'someProp5' item should be focused."); - EventUtils.sendKey("PAGE_DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "__proto__", "The '__proto__' item should be focused."); - EventUtils.sendKey("PAGE_UP", gDebugger); + EventUtils.synthesizeKey("KEY_PageUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp5", "The 'someProp5' item should be focused."); - EventUtils.sendKey("PAGE_UP", gDebugger); + EventUtils.synthesizeKey("KEY_PageUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp0", "The 'someProp0' item should be focused."); // Part 5: Test that HOME/PAGE_UP/PAGE_DOWN are symmetrical. - EventUtils.sendKey("HOME", gDebugger); + EventUtils.synthesizeKey("KEY_Home", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp0", "The 'someProp0' item should be focused."); - EventUtils.sendKey("HOME", gDebugger); + EventUtils.synthesizeKey("KEY_Home", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp0", "The 'someProp0' item should be focused."); - EventUtils.sendKey("PAGE_UP", gDebugger); + EventUtils.synthesizeKey("KEY_PageUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp0", "The 'someProp0' item should be focused."); - EventUtils.sendKey("HOME", gDebugger); + EventUtils.synthesizeKey("KEY_Home", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp0", "The 'someProp0' item should be focused."); - EventUtils.sendKey("END", gDebugger); + EventUtils.synthesizeKey("KEY_End", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "__proto__", "The '__proto__' item should be focused."); - EventUtils.sendKey("END", gDebugger); + EventUtils.synthesizeKey("KEY_End", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "__proto__", "The '__proto__' item should be focused."); - EventUtils.sendKey("PAGE_DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "__proto__", "The '__proto__' item should be focused."); - EventUtils.sendKey("END", gDebugger); + EventUtils.synthesizeKey("KEY_End", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "__proto__", "The '__proto__' item should be focused."); // Part 6: Test that focus doesn't leave the variables view. - EventUtils.sendKey("PAGE_UP", gDebugger); + EventUtils.synthesizeKey("KEY_PageUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp5", "The 'someProp5' item should be focused."); - EventUtils.sendKey("PAGE_UP", gDebugger); + EventUtils.synthesizeKey("KEY_PageUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp0", "The 'someProp0' item should be focused."); - EventUtils.sendKey("UP", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp0", "The 'someProp0' item should be focused."); - EventUtils.sendKey("UP", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp0", "The 'someProp0' item should be focused."); - EventUtils.sendKey("PAGE_DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp5", "The 'someProp5' item should be focused."); - EventUtils.sendKey("PAGE_DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "__proto__", "The '__proto__' item should be focused."); - EventUtils.sendKey("PAGE_DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "__proto__", "The '__proto__' item should be focused."); - EventUtils.sendKey("PAGE_DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "__proto__", "The '__proto__' item should be focused."); // Part 7: Test that random offsets don't occur in tandem with HOME/END. - EventUtils.sendKey("HOME", gDebugger); + EventUtils.synthesizeKey("KEY_Home", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp0", "The 'someProp0' item should be focused."); - EventUtils.sendKey("DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp1", "The 'someProp1' item should be focused."); - EventUtils.sendKey("END", gDebugger); + EventUtils.synthesizeKey("KEY_End", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "__proto__", "The '__proto__' item should be focused."); - EventUtils.sendKey("DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "__proto__", "The '__proto__' item should be focused."); // Part 8: Test that the RIGHT key expands elements as intended. - EventUtils.sendKey("PAGE_UP", gDebugger); + EventUtils.synthesizeKey("KEY_PageUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp5", "The 'someProp5' item should be focused."); is(gVariablesView.getFocusedItem().expanded, false, "The 'someProp5' item should not be expanded yet."); - yield synthesizeKeyAndWaitForTick("VK_RIGHT", {}); + yield synthesizeKeyAndWaitForTick("KEY_ArrowRight"); is(gVariablesView.getFocusedItem().name, "someProp5", "The 'someProp5' item should be focused."); is(gVariablesView.getFocusedItem().expanded, true, @@ -267,21 +267,21 @@ function performTest() { yield waitForChildNodes(gVariablesView.getFocusedItem()._enum, 7); yield waitForChildNodes(gVariablesView.getFocusedItem()._nonenum, 2); - EventUtils.sendKey("RIGHT", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowRight", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "0", "The '0' item should be focused."); - EventUtils.sendKey("RIGHT", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowRight", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "0", "The '0' item should still be focused."); - EventUtils.sendKey("PAGE_DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "5", "The '5' item should be focused."); is(gVariablesView.getFocusedItem().expanded, false, "The '5' item should not be expanded yet."); - yield synthesizeKeyAndWaitForTick("VK_RIGHT", {}); + yield synthesizeKeyAndWaitForTick("KEY_ArrowRight"); is(gVariablesView.getFocusedItem().name, "5", "The '5' item should be focused."); is(gVariablesView.getFocusedItem().expanded, true, @@ -296,21 +296,21 @@ function performTest() { yield waitForChildNodes(gVariablesView.getFocusedItem()._enum, 3); yield waitForChildNodes(gVariablesView.getFocusedItem()._nonenum, 2); - EventUtils.sendKey("RIGHT", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowRight", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "0", "The '0' item should be focused."); - EventUtils.sendKey("RIGHT", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowRight", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "0", "The '0' item should still be focused."); - EventUtils.sendKey("PAGE_DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "6", "The '6' item should be focused."); is(gVariablesView.getFocusedItem().expanded, false, "The '6' item should not be expanded yet."); - yield synthesizeKeyAndWaitForTick("VK_RIGHT", {}); + yield synthesizeKeyAndWaitForTick("KEY_ArrowRight"); is(gVariablesView.getFocusedItem().name, "6", "The '6' item should be focused."); is(gVariablesView.getFocusedItem().expanded, true, @@ -325,15 +325,15 @@ function performTest() { yield waitForChildNodes(gVariablesView.getFocusedItem()._enum, 2); yield waitForChildNodes(gVariablesView.getFocusedItem()._nonenum, 1); - EventUtils.sendKey("RIGHT", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowRight", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "prop1", "The 'prop1' item should be focused."); - EventUtils.sendKey("RIGHT", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowRight", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "prop1", "The 'prop1' item should still be focused."); - EventUtils.sendKey("PAGE_DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp6", "The 'someProp6' item should be focused."); is(gVariablesView.getFocusedItem().expanded, false, @@ -341,83 +341,83 @@ function performTest() { // Part 9: Test that the RIGHT key collapses elements as intended. - EventUtils.sendKey("LEFT", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowLeft", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp6", "The 'someProp6' item should be focused."); - EventUtils.sendKey("UP", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "__proto__", "The '__proto__' item should be focused."); - EventUtils.sendKey("LEFT", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowLeft", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp5", "The 'someProp5' item should be focused."); is(gVariablesView.getFocusedItem().expanded, true, "The '6' item should still be expanded."); - EventUtils.sendKey("LEFT", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowLeft", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp5", "The 'someProp5' item should still be focused."); is(gVariablesView.getFocusedItem().expanded, false, "The '6' item should still not be expanded anymore."); - EventUtils.sendKey("LEFT", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowLeft", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp5", "The 'someProp5' item should still be focused."); // Part 9: Test continuous navigation. - EventUtils.sendKey("UP", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp4", "The 'someProp4' item should be focused."); - EventUtils.sendKey("UP", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp3", "The 'someProp3' item should be focused."); - EventUtils.sendKey("UP", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp2", "The 'someProp2' item should be focused."); - EventUtils.sendKey("UP", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp1", "The 'someProp1' item should be focused."); - EventUtils.sendKey("UP", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp0", "The 'someProp0' item should be focused."); - EventUtils.sendKey("PAGE_UP", gDebugger); + EventUtils.synthesizeKey("KEY_PageUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp0", "The 'someProp0' item should be focused."); - EventUtils.sendKey("PAGE_DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_PageDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp5", "The 'someProp5' item should be focused."); - EventUtils.sendKey("DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp6", "The 'someProp6' item should be focused."); - EventUtils.sendKey("DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp7", "The 'someProp7' item should be focused."); - EventUtils.sendKey("DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "get", "The 'get' item should be focused."); - EventUtils.sendKey("DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "set", "The 'set' item should be focused."); - EventUtils.sendKey("DOWN", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowDown", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "__proto__", "The '__proto__' item should be focused."); // Part 10: Test that BACKSPACE deletes items in the variables view. - EventUtils.sendKey("BACK_SPACE", gDebugger); + EventUtils.synthesizeKey("KEY_Backspace", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "__proto__", "The '__proto__' variable should still be focused."); is(gVariablesView.getFocusedItem().value, "[object Object]", @@ -425,7 +425,7 @@ function performTest() { is(gVariablesView.getFocusedItem().visible, false, "The '__proto__' variable should be hidden."); - EventUtils.sendKey("UP", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "set", "The 'set' item should be focused."); is(gVariablesView.getFocusedItem().value, "[object Object]", @@ -433,7 +433,7 @@ function performTest() { is(gVariablesView.getFocusedItem().visible, true, "The 'set' item should be visible."); - EventUtils.sendKey("BACK_SPACE", gDebugger); + EventUtils.synthesizeKey("KEY_Backspace", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "set", "The 'set' item should still be focused."); is(gVariablesView.getFocusedItem().value, "[object Object]", @@ -443,7 +443,7 @@ function performTest() { is(gVariablesView.getFocusedItem().twisty, false, "The 'set' item should be disabled and have a hidden twisty."); - EventUtils.sendKey("UP", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "get", "The 'get' item should be focused."); is(gVariablesView.getFocusedItem().value, "[object Object]", @@ -451,7 +451,7 @@ function performTest() { is(gVariablesView.getFocusedItem().visible, true, "The 'get' item should be visible."); - EventUtils.sendKey("BACK_SPACE", gDebugger); + EventUtils.synthesizeKey("KEY_Backspace", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "get", "The 'get' item should still be focused."); is(gVariablesView.getFocusedItem().value, "[object Object]", @@ -461,7 +461,7 @@ function performTest() { is(gVariablesView.getFocusedItem().twisty, false, "The 'get' item should be disabled and have a hidden twisty."); - EventUtils.sendKey("UP", gDebugger); + EventUtils.synthesizeKey("KEY_ArrowUp", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp7", "The 'someProp7' item should be focused."); is(gVariablesView.getFocusedItem().value, undefined, @@ -469,7 +469,7 @@ function performTest() { is(gVariablesView.getFocusedItem().visible, true, "The 'someProp7' variable should be visible."); - EventUtils.sendKey("BACK_SPACE", gDebugger); + EventUtils.synthesizeKey("KEY_Backspace", {}, gDebugger); is(gVariablesView.getFocusedItem().name, "someProp7", "The 'someProp7' variable should still be focused."); is(gVariablesView.getFocusedItem().value, undefined, diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-popup-17.js b/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-popup-17.js index f11517b665d3..7b4f98b3e497 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-popup-17.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg_variables-view-popup-17.js @@ -34,7 +34,7 @@ function test() { "The popup should be open with a simple text entry"); // Now we're stopped at a breakpoint with an open popup // we'll send a keypress and check if the popup closes - executeSoon(() => EventUtils.synthesizeKey("VK_F11", {})); + executeSoon(() => EventUtils.synthesizeKey("KEY_F11")); // The keypress should cause one resumed event and one paused event yield waitForThreadEvents(gPanel, "resumed"); yield waitForThreadEvents(gPanel, "paused"); diff --git a/devtools/client/framework/test/browser_menu_api.js b/devtools/client/framework/test/browser_menu_api.js index cf634ff6fa98..5eb52109242c 100644 --- a/devtools/client/framework/test/browser_menu_api.js +++ b/devtools/client/framework/test/browser_menu_api.js @@ -161,16 +161,16 @@ function* testSubmenu(toolbox) { info("Using keyboard navigation to open, close, and reopen the submenu"); let shown = once(menus[0], "popupshown"); - EventUtils.synthesizeKey("VK_DOWN", {}); - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); + EventUtils.synthesizeKey("KEY_ArrowRight"); yield shown; let hidden = once(menus[0], "popuphidden"); - EventUtils.synthesizeKey("VK_LEFT", {}); + EventUtils.synthesizeKey("KEY_ArrowLeft"); yield hidden; shown = once(menus[0], "popupshown"); - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); yield shown; info("Clicking the submenu item"); diff --git a/devtools/client/framework/test/browser_toolbox_keyboard_navigation.js b/devtools/client/framework/test/browser_toolbox_keyboard_navigation.js index a22f87064fb8..94eac68225eb 100644 --- a/devtools/client/framework/test/browser_toolbox_keyboard_navigation.js +++ b/devtools/client/framework/test/browser_toolbox_keyboard_navigation.js @@ -35,47 +35,49 @@ add_task(function* () { ok(containsFocus(doc, toolbar), "Focus is within the toolbar"); // Move the focus away from toolbar to a next focusable element. - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); ok(!containsFocus(doc, toolbar), "Focus is outside of the toolbar"); // Move the focus back to the toolbar. - EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); ok(containsFocus(doc, toolbar), "Focus is within the toolbar again"); // Move through the toolbar forward using the right arrow key. for (let i = 0; i < toolbarControls.length; ++i) { is(doc.activeElement.id, toolbarControls[i].id, "New control is focused"); if (i < toolbarControls.length - 1) { - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); } } // Move the focus away from toolbar to a next focusable element. - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); ok(!containsFocus(doc, toolbar), "Focus is outside of the toolbar"); // Move the focus back to the toolbar. - EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); ok(containsFocus(doc, toolbar), "Focus is within the toolbar again"); // Move through the toolbar backward using the left arrow key. for (let i = toolbarControls.length - 1; i >= 0; --i) { is(doc.activeElement.id, toolbarControls[i].id, "New control is focused"); - if (i > 0) { EventUtils.synthesizeKey("VK_LEFT", {}); } + if (i > 0) { + EventUtils.synthesizeKey("KEY_ArrowLeft"); + } } // Move focus to the 3rd (non-first) toolbar control. let expectedFocusedControl = toolbarControls[2]; - EventUtils.synthesizeKey("VK_RIGHT", {}); - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); + EventUtils.synthesizeKey("KEY_ArrowRight"); is(doc.activeElement.id, expectedFocusedControl.id, "New control is focused"); // Move the focus away from toolbar to a next focusable element. - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); ok(!containsFocus(doc, toolbar), "Focus is outside of the toolbar"); // Move the focus back to the toolbar, ensure we land on the last active // descendant control. - EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); is(doc.activeElement.id, expectedFocusedControl.id, "New control is focused"); }); diff --git a/devtools/client/inspector/boxmodel/test/browser_boxmodel_navigation.js b/devtools/client/inspector/boxmodel/test/browser_boxmodel_navigation.js index 869a6a31eb07..5f50d6596926 100644 --- a/devtools/client/inspector/boxmodel/test/browser_boxmodel_navigation.js +++ b/devtools/client/inspector/boxmodel/test/browser_boxmodel_navigation.js @@ -31,7 +31,7 @@ function* testInitialFocus(inspector, view) { let viewdoc = view.document; let boxmodel = viewdoc.querySelector(".boxmodel-container"); boxmodel.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); is(boxmodel.getAttribute("activedescendant"), "boxmodel-main devtools-monospace", "Should be set to the position layout."); @@ -42,38 +42,38 @@ function* testChangingLevels(inspector, view) { let viewdoc = view.document; let boxmodel = viewdoc.querySelector(".boxmodel-container"); boxmodel.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Enter"); + EventUtils.synthesizeKey("KEY_Escape"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(boxmodel.getAttribute("activedescendant"), "boxmodel-margins", "Should be set to the margin layout."); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(boxmodel.getAttribute("activedescendant"), "boxmodel-borders", "Should be set to the border layout."); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(boxmodel.getAttribute("activedescendant"), "boxmodel-paddings", "Should be set to the padding layout."); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(boxmodel.getAttribute("activedescendant"), "boxmodel-contents", "Should be set to the content layout."); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(boxmodel.getAttribute("activedescendant"), "boxmodel-paddings", "Should be set to the padding layout."); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(boxmodel.getAttribute("activedescendant"), "boxmodel-borders", "Should be set to the border layout."); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(boxmodel.getAttribute("activedescendant"), "boxmodel-margins", "Should be set to the margin layout."); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(boxmodel.getAttribute("activedescendant"), "boxmodel-main devtools-monospace", "Should be set to the position layout."); } @@ -83,20 +83,20 @@ function* testTabbingWrapAround(inspector, view) { let viewdoc = view.document; let boxmodel = viewdoc.querySelector(".boxmodel-container"); boxmodel.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); let editLevel = boxmodel.getAttribute("activedescendant").split(" ")[0]; let dataLevel = viewdoc.querySelector(`.${editLevel}`).getAttribute("data-box"); let editBoxes = [...viewdoc.querySelectorAll( `[data-box="${dataLevel}"].boxmodel-editable`)]; - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); editBoxes[3].focus(); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(editBoxes[0], viewdoc.activeElement, "Top edit box should have focus."); editBoxes[0].focus(); - EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); is(editBoxes[3], viewdoc.activeElement, "Left edit box should have focus."); } diff --git a/devtools/client/inspector/computed/test/browser_computed_keybindings_02.js b/devtools/client/inspector/computed/test/browser_computed_keybindings_02.js index f93fcf844c1b..b18d8bdec19d 100644 --- a/devtools/client/inspector/computed/test/browser_computed_keybindings_02.js +++ b/devtools/client/inspector/computed/test/browser_computed_keybindings_02.js @@ -44,8 +44,8 @@ add_task(function* () { info("Tab to select the 2nd style and press return"); let onExpanded = inspector.once("computed-view-property-expanded"); - EventUtils.synthesizeKey("VK_TAB", {}); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Tab"); + EventUtils.synthesizeKey("KEY_Enter"); yield onExpanded; info("Verify the 2nd style has been expanded"); @@ -55,8 +55,8 @@ add_task(function* () { info("Tab back up and test the same thing, with space"); onExpanded = inspector.once("computed-view-property-expanded"); - EventUtils.synthesizeKey("VK_TAB", {shiftKey: true}); - EventUtils.synthesizeKey("VK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); + EventUtils.synthesizeKey(" "); yield onExpanded; info("Verify the 1st style has been expanded too"); diff --git a/devtools/client/inspector/markup/test/browser_markup_keybindings_04.js b/devtools/client/inspector/markup/test/browser_markup_keybindings_04.js index 3b6f8bfb3729..12d54c018851 100644 --- a/devtools/client/inspector/markup/test/browser_markup_keybindings_04.js +++ b/devtools/client/inspector/markup/test/browser_markup_keybindings_04.js @@ -42,7 +42,7 @@ function assertNodeSelected(inspector, tagName) { function selectPreviousNodeWithArrowUp(inspector) { let onNodeHighlighted = inspector.toolbox.once("node-highlight"); let onUpdated = inspector.once("inspector-updated"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); return Promise.all([onUpdated, onNodeHighlighted]); } @@ -53,6 +53,6 @@ function* selectWithElementPicker(inspector, testActor) { type: "mousemove", }, gBrowser.selectedBrowser); - yield testActor.synthesizeKey({key: "VK_RETURN", options: {}}); + yield testActor.synthesizeKey({key: "KEY_Enter", options: {}}); yield inspector.once("inspector-updated"); } diff --git a/devtools/client/inspector/markup/test/browser_markup_load_01.js b/devtools/client/inspector/markup/test/browser_markup_load_01.js index ad5cf8313816..da9351d89a1d 100644 --- a/devtools/client/inspector/markup/test/browser_markup_load_01.js +++ b/devtools/client/inspector/markup/test/browser_markup_load_01.js @@ -70,7 +70,7 @@ function* chooseWithInspectElementContextMenu(selector, tab) { button: 2 }, tab.linkedBrowser); - yield EventUtils.synthesizeKey("Q", {}); + yield EventUtils.sendString("Q"); } function waitForLinkedBrowserEvent(tab, event) { diff --git a/devtools/client/inspector/markup/test/browser_markup_navigation.js b/devtools/client/inspector/markup/test/browser_markup_navigation.js index 5bfd9719fbee..01712a327c1b 100644 --- a/devtools/client/inspector/markup/test/browser_markup_navigation.js +++ b/devtools/client/inspector/markup/test/browser_markup_navigation.js @@ -8,72 +8,72 @@ const TEST_URL = URL_ROOT + "doc_markup_navigation.html"; const TEST_DATA = [ - ["pageup", "*doctype*"], - ["down", "html"], - ["down", "head"], - ["down", "body"], - ["down", "node0"], - ["right", "node0"], - ["down", "node1"], - ["down", "node2"], - ["down", "node3"], - ["down", "*comment*"], - ["down", "node4"], - ["right", "node4"], - ["down", "*text*"], - ["down", "node5"], - ["down", "*text*"], - ["down", "node6"], - ["down", "*text*"], - ["down", "*comment*"], - ["down", "node7"], - ["right", "node7"], - ["down", "*text*"], - ["down", "node8"], - ["left", "node7"], - ["left", "node7"], - ["right", "node7"], - ["right", "*text*"], - ["down", "node8"], - ["down", "*text*"], - ["down", "node9"], - ["down", "*text*"], - ["down", "node10"], - ["down", "*text*"], - ["down", "node11"], - ["down", "*text*"], - ["down", "node12"], - ["right", "node12"], - ["down", "*text*"], - ["down", "node13"], - ["down", "node14"], - ["down", "node15"], - ["down", "node15"], - ["down", "node15"], - ["up", "node14"], - ["up", "node13"], - ["up", "*text*"], - ["up", "node12"], - ["left", "node12"], - ["down", "node14"], - ["home", "*doctype*"], - ["pagedown", "*text*"], - ["down", "node5"], - ["down", "*text*"], - ["down", "node6"], - ["down", "*text*"], - ["down", "*comment*"], - ["down", "node7"], - ["left", "node7"], - ["down", "*text*"], - ["down", "node9"], - ["down", "*text*"], - ["down", "node10"], - ["pageup", "*text*"], - ["pageup", "*doctype*"], - ["down", "html"], - ["left", "html"], - ["down", "head"] + ["KEY_PageUp", "*doctype*"], + ["KEY_ArrowDown", "html"], + ["KEY_ArrowDown", "head"], + ["KEY_ArrowDown", "body"], + ["KEY_ArrowDown", "node0"], + ["KEY_ArrowRight", "node0"], + ["KEY_ArrowDown", "node1"], + ["KEY_ArrowDown", "node2"], + ["KEY_ArrowDown", "node3"], + ["KEY_ArrowDown", "*comment*"], + ["KEY_ArrowDown", "node4"], + ["KEY_ArrowRight", "node4"], + ["KEY_ArrowDown", "*text*"], + ["KEY_ArrowDown", "node5"], + ["KEY_ArrowDown", "*text*"], + ["KEY_ArrowDown", "node6"], + ["KEY_ArrowDown", "*text*"], + ["KEY_ArrowDown", "*comment*"], + ["KEY_ArrowDown", "node7"], + ["KEY_ArrowRight", "node7"], + ["KEY_ArrowDown", "*text*"], + ["KEY_ArrowDown", "node8"], + ["KEY_ArrowLeft", "node7"], + ["KEY_ArrowLeft", "node7"], + ["KEY_ArrowRight", "node7"], + ["KEY_ArrowRight", "*text*"], + ["KEY_ArrowDown", "node8"], + ["KEY_ArrowDown", "*text*"], + ["KEY_ArrowDown", "node9"], + ["KEY_ArrowDown", "*text*"], + ["KEY_ArrowDown", "node10"], + ["KEY_ArrowDown", "*text*"], + ["KEY_ArrowDown", "node11"], + ["KEY_ArrowDown", "*text*"], + ["KEY_ArrowDown", "node12"], + ["KEY_ArrowRight", "node12"], + ["KEY_ArrowDown", "*text*"], + ["KEY_ArrowDown", "node13"], + ["KEY_ArrowDown", "node14"], + ["KEY_ArrowDown", "node15"], + ["KEY_ArrowDown", "node15"], + ["KEY_ArrowDown", "node15"], + ["KEY_ArrowUp", "node14"], + ["KEY_ArrowUp", "node13"], + ["KEY_ArrowUp", "*text*"], + ["KEY_ArrowUp", "node12"], + ["KEY_ArrowLeft", "node12"], + ["KEY_ArrowDown", "node14"], + ["KEY_Home", "*doctype*"], + ["KEY_PageDown", "*text*"], + ["KEY_ArrowDown", "node5"], + ["KEY_ArrowDown", "*text*"], + ["KEY_ArrowDown", "node6"], + ["KEY_ArrowDown", "*text*"], + ["KEY_ArrowDown", "*comment*"], + ["KEY_ArrowDown", "node7"], + ["KEY_ArrowLeft", "node7"], + ["KEY_ArrowDown", "*text*"], + ["KEY_ArrowDown", "node9"], + ["KEY_ArrowDown", "*text*"], + ["KEY_ArrowDown", "node10"], + ["KEY_PageUp", "*text*"], + ["KEY_PageUp", "*doctype*"], + ["KEY_ArrowDown", "html"], + ["KEY_ArrowLeft", "html"], + ["KEY_ArrowDown", "head"] ]; add_task(function* () { @@ -85,7 +85,7 @@ add_task(function* () { info("Starting to iterate through the test data"); for (let [key, className] of TEST_DATA) { info("Testing step: " + key + " to navigate to " + className); - pressKey(key); + EventUtils.synthesizeKey(key); info("Making sure markup-view children get updated"); yield waitForChildrenUpdated(inspector); @@ -102,32 +102,6 @@ add_task(function* () { yield inspector.once("inspector-updated"); }); -function pressKey(key) { - switch (key) { - case "right": - EventUtils.synthesizeKey("VK_RIGHT", {}); - break; - case "down": - EventUtils.synthesizeKey("VK_DOWN", {}); - break; - case "left": - EventUtils.synthesizeKey("VK_LEFT", {}); - break; - case "up": - EventUtils.synthesizeKey("VK_UP", {}); - break; - case "pageup": - EventUtils.synthesizeKey("VK_PAGE_UP", {}); - break; - case "pagedown": - EventUtils.synthesizeKey("VK_PAGE_DOWN", {}); - break; - case "home": - EventUtils.synthesizeKey("VK_HOME", {}); - break; - } -} - function checkSelectedNode(key, className, inspector) { let node = inspector.selection.nodeFront; diff --git a/devtools/client/inspector/rules/test/browser_rules_add-property-cancel_03.js b/devtools/client/inspector/rules/test/browser_rules_add-property-cancel_03.js index 4f8b42009ff0..2a9dc9d99a08 100644 --- a/devtools/client/inspector/rules/test/browser_rules_add-property-cancel_03.js +++ b/devtools/client/inspector/rules/test/browser_rules_add-property-cancel_03.js @@ -33,7 +33,7 @@ add_task(function* () { EventUtils.sendString("background", view.styleWindow); let onBlur = once(editor.input, "blur"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); yield onBlur; is(elementRuleEditor.rule.textProps.length, 1, diff --git a/devtools/client/inspector/rules/test/browser_rules_add-rule-edit-selector.js b/devtools/client/inspector/rules/test/browser_rules_add-rule-edit-selector.js index b59f317a5bb5..50865c32d973 100644 --- a/devtools/client/inspector/rules/test/browser_rules_add-rule-edit-selector.js +++ b/devtools/client/inspector/rules/test/browser_rules_add-rule-edit-selector.js @@ -42,7 +42,7 @@ function* testEditSelector(view, name) { let onRuleViewChanged = once(view, "ruleview-changed"); info("Entering the commit key"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; is(view._elementStyle.rules.length, 3, "Should have 3 rules."); diff --git a/devtools/client/inspector/rules/test/browser_rules_add-rule-then-property-edit-selector.js b/devtools/client/inspector/rules/test/browser_rules_add-rule-then-property-edit-selector.js index 294eb67e43f9..4afc6bfaf158 100644 --- a/devtools/client/inspector/rules/test/browser_rules_add-rule-then-property-edit-selector.js +++ b/devtools/client/inspector/rules/test/browser_rules_add-rule-then-property-edit-selector.js @@ -62,7 +62,7 @@ function* testEditSelector(view, name) { let onRuleViewChanged = once(view, "ruleview-changed"); info("Entering the commit key"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; is(view._elementStyle.rules.length, 3, "Should have 3 rules."); diff --git a/devtools/client/inspector/rules/test/browser_rules_add-rule-with-menu.js b/devtools/client/inspector/rules/test/browser_rules_add-rule-with-menu.js index 976fc964399b..e5ea99cc4911 100644 --- a/devtools/client/inspector/rules/test/browser_rules_add-rule-with-menu.js +++ b/devtools/client/inspector/rules/test/browser_rules_add-rule-with-menu.js @@ -38,5 +38,5 @@ function* testNewRule(view) { is(editor.value, "#testid", "Selector editor value is as expected"); info("Escaping from the selector field the change"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); } diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property-computed.js b/devtools/client/inspector/rules/test/browser_rules_edit-property-computed.js index d9a4a8728782..49572653d1eb 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property-computed.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property-computed.js @@ -53,7 +53,7 @@ function* editAndCheck(view) { let onBlur = once(editor.input, "blur"); info("Entering the commit key and finishing edit"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); info("Waiting for blur on the field"); yield onBlur; diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-property_08.js b/devtools/client/inspector/rules/test/browser_rules_edit-property_08.js index 1becd40d9c27..6ede974e95ba 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-property_08.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-property_08.js @@ -51,7 +51,7 @@ add_task(function* () { // The value field is still focused. Blur it now and wait for the // ruleview-changed event to avoid pending requests. onRuleViewChanged = view.once("ruleview-changed"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); yield onRuleViewChanged; }); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector-click-on-scrollbar.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector-click-on-scrollbar.js index 1846df60d826..dc6ae438b16d 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector-click-on-scrollbar.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector-click-on-scrollbar.js @@ -70,7 +70,7 @@ add_task(function* () { info("Enter new value and commit."); editor.input.value = newValue; - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; ok(getRuleViewRule(view, newValue), "Rule with '" + newValue + " 'exists."); }); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_01.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_01.js index af228094bde0..85e1476bd850 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_01.js @@ -47,7 +47,7 @@ function* testEditSelector(view, name) { let onRuleViewChanged = once(view, "ruleview-changed"); info("Entering the commit key"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; is(view._elementStyle.rules.length, 2, "Should have 2 rules."); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_02.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_02.js index 503f91efaf9e..907d3d68ebd1 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_02.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_02.js @@ -70,7 +70,7 @@ function* testEditSelector(view, name) { let onRuleViewChanged = once(view, "ruleview-changed"); info("Entering the commit key"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; is(view._elementStyle.rules.length, 2, "Should have 2 rule."); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_03.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_03.js index c6834f6ee659..a6bf0703ea63 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_03.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_03.js @@ -37,7 +37,7 @@ function* testEditSelector(view, name) { info("Entering a new selector name and committing"); editor.input.value = name; let onRuleViewChanged = once(view, "ruleview-invalid-selector"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; is(view._elementStyle.rules.length, 2, "Should have 2 rules."); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_04.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_04.js index 873d16760914..05a052d1f853 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_04.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_04.js @@ -59,7 +59,7 @@ function* testEditSelector(view, name) { info("Entering a new selector name and committing"); editor.input.value = name; - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); let isVisible = yield onToggled; diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_05.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_05.js index cd996b4b0399..f7d2734abf7d 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_05.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_05.js @@ -50,7 +50,7 @@ function* testEditSelector(view, name) { let onRuleViewChanged = once(view, "ruleview-changed"); info("Entering the commit key"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; is(view._elementStyle.rules.length, 2, "Should have 2 rules."); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_06.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_06.js index 7d782a309f35..0d72d7b602a9 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_06.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_06.js @@ -32,7 +32,7 @@ function* testEditClassSelector(view) { editor.input.value = "body"; let onRuleViewChanged = once(view, "ruleview-changed"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; // Get the new rule editor that replaced the original @@ -57,7 +57,7 @@ function* testEditDivSelector(view) { editor.input.value = "asdf"; let onRuleViewChanged = once(view, "ruleview-changed"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; // Get the new rule editor that replaced the original diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_07.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_07.js index 81c7aad7205d..94ecf03a28d2 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_07.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_07.js @@ -46,7 +46,7 @@ function* testEditSelector(view, name) { info("Entering the commit key"); let onRuleViewChanged = once(view, "ruleview-changed"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; // Get the new rule editor that replaced the original diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_08.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_08.js index 33382e0de7f1..40b163d158a8 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_08.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_08.js @@ -40,7 +40,7 @@ add_task(function* () { let onRuleViewChanged = once(view, "ruleview-changed"); info("Entering the commit key"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; info("Re-focusing the selector name in the rule-view"); @@ -61,7 +61,7 @@ add_task(function* () { onRuleViewChanged = once(view, "ruleview-changed"); info("Entering the commit key"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; is(view._elementStyle.rules.length, 2, "Should have 2 rules."); diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_09.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_09.js index a18ddc5efb32..c0f655647035 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_09.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_09.js @@ -51,7 +51,7 @@ function* testEditSelector(view, name) { let onRuleViewChanged = once(view, "ruleview-changed"); info("Entering the commit key"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; ok(getRuleViewRule(view, name), "Rule with " + name + " selector exists."); @@ -60,7 +60,7 @@ function* testEditSelector(view, name) { // Escape the new property editor after editing the selector let onBlur = once(view.styleDocument.activeElement, "blur"); - EventUtils.synthesizeKey("VK_ESCAPE", {}, view.styleWindow); + EventUtils.synthesizeKey("KEY_Escape", {}, view.styleWindow); yield onBlur; } @@ -97,7 +97,7 @@ function* testAddMatchedRule(view, name) { let onRuleViewChanged = once(view, "ruleview-changed"); info("Entering the commit key"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; is(getRuleViewRuleEditor(view, 1).element.getAttribute("unmatched"), "false", @@ -105,6 +105,6 @@ function* testAddMatchedRule(view, name) { // Escape the new property editor after editing the selector let onBlur = once(view.styleDocument.activeElement, "blur"); - EventUtils.synthesizeKey("VK_ESCAPE", {}, view.styleWindow); + EventUtils.synthesizeKey("KEY_Escape", {}, view.styleWindow); yield onBlur; } diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_10.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_10.js index d878dd5163f7..200dd9a1adb9 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_10.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_10.js @@ -36,12 +36,12 @@ function* testEditSelector(view) { editor.input.value = "#testid span"; let onRuleViewChanged = once(view, "ruleview-changed"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; // Escape the new property editor after editing the selector let onBlur = once(view.styleDocument.activeElement, "blur"); - EventUtils.synthesizeKey("VK_ESCAPE", {}, view.styleWindow); + EventUtils.synthesizeKey("KEY_Escape", {}, view.styleWindow); yield onBlur; // Get the new rule editor that replaced the original diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_11.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_11.js index 9a1bdc8fa86e..1f9591954f3f 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_11.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_11.js @@ -39,12 +39,12 @@ function* testEditSelector(view) { editor.input.value = ".pickme"; let onRuleViewChanged = once(view, "ruleview-changed"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; // Escape the new property editor after editing the selector let onBlur = once(view.styleDocument.activeElement, "blur"); - EventUtils.synthesizeKey("VK_ESCAPE", {}, view.styleWindow); + EventUtils.synthesizeKey("KEY_Escape", {}, view.styleWindow); yield onBlur; // Get the new rule editor that replaced the original diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector_12.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector_12.js index 35b88c4f709e..31ab679d9a1a 100644 --- a/devtools/client/inspector/rules/test/browser_rules_edit-selector_12.js +++ b/devtools/client/inspector/rules/test/browser_rules_edit-selector_12.js @@ -21,12 +21,12 @@ add_task(function* () { info("Change the selector to something else"); editor.input.value = "div"; let onRuleViewChanged = once(view, "ruleview-changed"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; info("Escape the new property editor after editing the selector"); let onBlur = once(view.styleDocument.activeElement, "blur"); - EventUtils.synthesizeKey("VK_ESCAPE", {}, view.styleWindow); + EventUtils.synthesizeKey("KEY_Escape", {}, view.styleWindow); yield onBlur; info("Check the rules are still displayed correctly"); diff --git a/devtools/client/inspector/rules/test/browser_rules_editable-field-focus_01.js b/devtools/client/inspector/rules/test/browser_rules_editable-field-focus_01.js index c9c7cd3d24ab..6e8d62131c79 100644 --- a/devtools/client/inspector/rules/test/browser_rules_editable-field-focus_01.js +++ b/devtools/client/inspector/rules/test/browser_rules_editable-field-focus_01.js @@ -26,8 +26,8 @@ add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); let {inspector, view} = yield openRuleView(); yield selectNode("#testid", inspector); - yield testEditableFieldFocus(inspector, view, "VK_RETURN"); - yield testEditableFieldFocus(inspector, view, "VK_TAB"); + yield testEditableFieldFocus(inspector, view, "KEY_Enter"); + yield testEditableFieldFocus(inspector, view, "KEY_Tab"); }); function* testEditableFieldFocus(inspector, view, commitKey) { @@ -79,7 +79,7 @@ function* testEditableFieldFocus(inspector, view, commitKey) { "Focus should have moved to the next rule selector"); info("Blur the selector field"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); } function* focusNextEditableField(view, ruleEditor, commitKey) { diff --git a/devtools/client/inspector/rules/test/browser_rules_livepreview.js b/devtools/client/inspector/rules/test/browser_rules_livepreview.js index a811cdb204ba..992a166867af 100644 --- a/devtools/client/inspector/rules/test/browser_rules_livepreview.js +++ b/devtools/client/inspector/rules/test/browser_rules_livepreview.js @@ -58,9 +58,9 @@ function* testLivePreviewData(data, ruleView, selector) { let onValueDone = ruleView.once("ruleview-changed"); if (data.escape) { - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); } else { - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); } yield onValueDone; diff --git a/devtools/client/inspector/rules/test/browser_rules_mark_overridden_06.js b/devtools/client/inspector/rules/test/browser_rules_mark_overridden_06.js index c2e71fe49d95..9006bc2f50a7 100644 --- a/devtools/client/inspector/rules/test/browser_rules_mark_overridden_06.js +++ b/devtools/client/inspector/rules/test/browser_rules_mark_overridden_06.js @@ -38,7 +38,7 @@ function* testMarkOverridden(inspector, view) { let onRuleViewChanged = once(view, "ruleview-changed"); info("Entering the commit key"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; view.searchField.focus(); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_04.js b/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_04.js index 05b8b01eb9ae..e3ba03c9cbfd 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_04.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter-computed-list_04.js @@ -45,7 +45,7 @@ function* testModifyPropertyValueFilter(inspector, view) { let onBlur = once(editor.input, "blur"); let onModification = view.once("ruleview-changed"); EventUtils.sendString("4px 0px", view.styleWindow); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onBlur; yield onModification; diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter_07.js b/devtools/client/inspector/rules/test/browser_rules_search-filter_07.js index 16b047d8d391..d22d50e12cc5 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter_07.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter_07.js @@ -47,7 +47,7 @@ add_task(function* () { info("Submit the change"); let onRuleViewChanged = view.once("ruleview-changed"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; ok(propEditor.container.classList.contains("ruleview-highlight"), @@ -57,6 +57,6 @@ add_task(function* () { // automatically. Blur it now and wait for the rule-view to refresh to avoid // pending requests. onRuleViewChanged = view.once("ruleview-changed"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); yield onRuleViewChanged; }); diff --git a/devtools/client/inspector/rules/test/browser_rules_search-filter_08.js b/devtools/client/inspector/rules/test/browser_rules_search-filter_08.js index 1a3c0de59d07..d86cac4ac645 100644 --- a/devtools/client/inspector/rules/test/browser_rules_search-filter_08.js +++ b/devtools/client/inspector/rules/test/browser_rules_search-filter_08.js @@ -45,7 +45,7 @@ add_task(function* () { info("Change the height property value to 100%"); let onRuleViewChanged = view.once("ruleview-changed"); EventUtils.sendString("100%", view.styleWindow); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; ok(propEditor.container.classList.contains("ruleview-highlight"), diff --git a/devtools/client/inspector/rules/test/head.js b/devtools/client/inspector/rules/test/head.js index 7b3be8c49481..90ee2bec723e 100644 --- a/devtools/client/inspector/rules/test/head.js +++ b/devtools/client/inspector/rules/test/head.js @@ -444,7 +444,7 @@ function* addNewRuleAndDismissEditor(inspector, view, expectedSelector, expected "The editor for the new selector has the correct value: " + expectedSelector); info("Pressing escape to leave the editor"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); is(ruleEditor.selectorText.textContent, expectedSelector, "The new selector has the correct text: " + expectedSelector); diff --git a/devtools/client/inspector/shared/test/browser_styleinspector_context-menu-copy-color_02.js b/devtools/client/inspector/shared/test/browser_styleinspector_context-menu-copy-color_02.js index a7a073879190..923509499c09 100644 --- a/devtools/client/inspector/shared/test/browser_styleinspector_context-menu-copy-color_02.js +++ b/devtools/client/inspector/shared/test/browser_styleinspector_context-menu-copy-color_02.js @@ -42,7 +42,7 @@ function* testCopyToClipboard(inspector, view) { yield waitForClipboardPromise(() => menuitemCopyColor.click(), "#123ABC"); - EventUtils.synthesizeKey("VK_ESCAPE", { }); + EventUtils.synthesizeKey("KEY_Escape"); } function* testManualEdit(inspector, view) { diff --git a/devtools/client/inspector/test/browser_inspector_breadcrumbs_keybinding.js b/devtools/client/inspector/test/browser_inspector_breadcrumbs_keybinding.js index 8e72a8babce6..273a86f570da 100644 --- a/devtools/client/inspector/test/browser_inspector_breadcrumbs_keybinding.js +++ b/devtools/client/inspector/test/browser_inspector_breadcrumbs_keybinding.js @@ -8,27 +8,27 @@ const TEST_URI = URL_ROOT + "doc_inspector_breadcrumbs.html"; const TEST_DATA = [{ desc: "Pressing left should select the parent ", - key: "VK_LEFT", + key: "KEY_ArrowLeft", newSelection: "body" }, { desc: "Pressing left again should select the parent ", - key: "VK_LEFT", + key: "KEY_ArrowLeft", newSelection: "html" }, { desc: "Pressing left again should stay on , it's the first element", - key: "VK_LEFT", + key: "KEY_ArrowLeft", newSelection: "html" }, { desc: "Pressing right should go to ", - key: "VK_RIGHT", + key: "KEY_ArrowRight", newSelection: "body" }, { desc: "Pressing right again should go to #i2", - key: "VK_RIGHT", + key: "KEY_ArrowRight", newSelection: "#i2" }, { desc: "Pressing right again should stay on #i2, it's the last element", - key: "VK_RIGHT", + key: "KEY_ArrowRight", newSelection: "#i2" }]; @@ -56,7 +56,7 @@ add_task(function* () { onUpdated = inspector.once("breadcrumbs-updated"); } - EventUtils.synthesizeKey(key, {}); + EventUtils.synthesizeKey(key); yield onUpdated; let newNodeFront = yield getNodeFront(newSelection, inspector); diff --git a/devtools/client/inspector/test/browser_inspector_delete-selected-node-02.js b/devtools/client/inspector/test/browser_inspector_delete-selected-node-02.js index fbd008a89fb4..31f809d5dc29 100644 --- a/devtools/client/inspector/test/browser_inspector_delete-selected-node-02.js +++ b/devtools/client/inspector/test/browser_inspector_delete-selected-node-02.js @@ -83,7 +83,7 @@ add_task(function* () { // Delete node with key, as cannot delete text node with // context menu at this time. inspector.markup._frame.focus(); - EventUtils.synthesizeKey("VK_DELETE", {}); + EventUtils.synthesizeKey("KEY_Delete"); yield inspector.once("inspector-updated"); expectedCrumbs = ["html", "body", "div#deleteToMakeSingleTextNode"]; @@ -108,7 +108,7 @@ add_task(function* () { menuItem.click(); // close the open context menu - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); info("Waiting for inspector to update."); yield inspector.once("inspector-updated"); diff --git a/devtools/client/inspector/test/browser_inspector_highlighter-eyedropper-clipboard.js b/devtools/client/inspector/test/browser_inspector_highlighter-eyedropper-clipboard.js index 2c6aca310f8b..183dae238b3e 100644 --- a/devtools/client/inspector/test/browser_inspector_highlighter-eyedropper-clipboard.js +++ b/devtools/client/inspector/test/browser_inspector_highlighter-eyedropper-clipboard.js @@ -25,7 +25,7 @@ add_task(function* () { yield waitForClipboardPromise(() => { info("Activate the eyedropper so the background color is copied"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); }, "#ff0000"); ok(true, "The clipboard contains the right value"); diff --git a/devtools/client/inspector/test/browser_inspector_keyboard-shortcuts.js b/devtools/client/inspector/test/browser_inspector_keyboard-shortcuts.js index f03a33fd1184..c08452346a82 100644 --- a/devtools/client/inspector/test/browser_inspector_keyboard-shortcuts.js +++ b/devtools/client/inspector/test/browser_inspector_keyboard-shortcuts.js @@ -12,12 +12,12 @@ const TEST_URI = "data:text/html;charset=utf-8," + " I come in peace.

"; const TEST_DATA = [ - { key: "VK_LEFT", selectedNode: "p" }, - { key: "VK_LEFT", selectedNode: "body" }, - { key: "VK_LEFT", selectedNode: "html" }, - { key: "VK_RIGHT", selectedNode: "body" }, - { key: "VK_RIGHT", selectedNode: "p" }, - { key: "VK_RIGHT", selectedNode: "strong" }, + { key: "KEY_ArrowLeft", selectedNode: "p" }, + { key: "KEY_ArrowLeft", selectedNode: "body" }, + { key: "KEY_ArrowLeft", selectedNode: "html" }, + { key: "KEY_ArrowRight", selectedNode: "body" }, + { key: "KEY_ArrowRight", selectedNode: "p" }, + { key: "KEY_ArrowRight", selectedNode: "strong" }, ]; add_task(function* () { @@ -38,7 +38,7 @@ add_task(function* () { info("Pressing " + key + " to select " + selectedNode); let updated = inspector.once("inspector-updated"); - EventUtils.synthesizeKey(key, {}); + EventUtils.synthesizeKey(key); yield updated; let selectedNodeFront = yield getNodeFront(selectedNode, inspector); diff --git a/devtools/client/inspector/test/browser_inspector_menu-05-attribute-items.js b/devtools/client/inspector/test/browser_inspector_menu-05-attribute-items.js index 05c4051f3d16..cb58ca25f533 100644 --- a/devtools/client/inspector/test/browser_inspector_menu-05-attribute-items.js +++ b/devtools/client/inspector/test/browser_inspector_menu-05-attribute-items.js @@ -22,9 +22,9 @@ add_task(function* () { let addAttribute = getMenuItem("node-menu-add-attribute"); addAttribute.click(); - EventUtils.synthesizeKey('class="u-hidden"', {}); + EventUtils.sendString('class="u-hidden"'); let onMutation = inspector.once("markupmutation"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onMutation; let hasAttribute = testActor.hasNode("#attributes.u-hidden"); @@ -72,9 +72,9 @@ add_task(function* () { name: "data-edit" }; editAttribute.click(); - EventUtils.synthesizeKey("data-edit='edited'", {}); + EventUtils.sendString("data-edit='edited'"); let onMutation = inspector.once("markupmutation"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onMutation; let isAttributeChanged = @@ -106,7 +106,7 @@ add_task(function* () { let menuItem = allMenuItems.find(i => i.id === id); ok(menuItem, "Menu item '" + id + "' found"); // Close the menu so synthesizing future keys won't select menu items. - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); return menuItem; } }); diff --git a/devtools/client/netmonitor/test/browser_net_filter-autocomplete.js b/devtools/client/netmonitor/test/browser_net_filter-autocomplete.js index 347eae041d66..ddd0bdef37b4 100644 --- a/devtools/client/netmonitor/test/browser_net_filter-autocomplete.js +++ b/devtools/client/netmonitor/test/browser_net_filter-autocomplete.js @@ -58,7 +58,7 @@ add_task(async function () { document.querySelector(".devtools-filterinput").focus(); // Typing a char should invoke a autocomplete - EventUtils.synthesizeKey("s", {}); + EventUtils.sendString("s"); ok(document.querySelector(".devtools-autocomplete-popup"), "Autocomplete Popup Created"); testAutocompleteContents([ @@ -70,15 +70,15 @@ add_task(async function () { "status-code:", ], document); - EventUtils.synthesizeKey("c", {}); + EventUtils.sendString("c"); testAutocompleteContents(["scheme:"], document); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); // Tab selection should hide autocomplete ok(document.querySelector(".devtools-autocomplete-popup"), "Autocomplete Popup alive with content values"); testAutocompleteContents(["scheme:http"], document); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); is(document.querySelector(".devtools-filterinput").value, "scheme:http", "Value correctly set after Enter"); ok(!document.querySelector(".devtools-autocomplete-popup"), @@ -86,29 +86,29 @@ add_task(async function () { // Space separated tokens // The last token where autocomplete is availabe shall generate the popup - EventUtils.synthesizeKey(" p", {}); + EventUtils.sendString(" p"); testAutocompleteContents(["protocol:"], document); // The new value of the text box should be previousTokens + latest value selected // First return selects "protocol:" - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); // Second return selects "protocol:HTTP/1.1" - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); is(document.querySelector(".devtools-filterinput").value, "scheme:http protocol:HTTP/1.1", "Tokenized click generates correct value in input box"); // Explicitly type in `flag:` renders autocomplete with values - EventUtils.synthesizeKey(" status-code:", {}); + EventUtils.sendString(" status-code:"); testAutocompleteContents(["status-code:200", "status-code:304"], document); // Typing the exact value closes autocomplete - EventUtils.synthesizeKey("304", {}); + EventUtils.sendString("304"); ok(!document.querySelector(".devtools-autocomplete-popup"), "Typing the exact value closes autocomplete"); // Check if mime-type has been correctly parsed out and values also get autocomplete - EventUtils.synthesizeKey(" mime-type:text", {}); + EventUtils.sendString(" mime-type:text"); testAutocompleteContents([ "mime-type:text/css", "mime-type:text/html", @@ -116,7 +116,7 @@ add_task(async function () { ], document); // The negative filter flags - EventUtils.synthesizeKey(" -", {}); + EventUtils.sendString(" -"); testAutocompleteContents([ "-cause:", "-domain:", @@ -139,7 +139,7 @@ add_task(async function () { ], document); // Autocomplete for negative filtering - EventUtils.synthesizeKey("is:", {}); + EventUtils.sendString("is:"); testAutocompleteContents(["-is:cached", "-is:from-cache", "-is:running"], document); await teardown(monitor); diff --git a/devtools/client/responsive.html/test/browser/browser_device_width.js b/devtools/client/responsive.html/test/browser/browser_device_width.js index 8a1119963222..16c8027b3553 100644 --- a/devtools/client/responsive.html/test/browser/browser_device_width.js +++ b/devtools/client/responsive.html/test/browser/browser_device_width.js @@ -45,7 +45,7 @@ async function setViewportSizeWithInputKeys(ui) { resized = waitForViewportResizeTo(ui, 420, height); dimensions[0].focus(); for (let i = 1; i <= 100; i++) { - EventUtils.synthesizeKey("KEY_ArrowUp", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); } await resized; @@ -60,13 +60,13 @@ async function setViewportSizeWithInputKeys(ui) { // Increase height value to 600 by using `PageUp + Shift` key resized = waitForViewportResizeTo(ui, width, 600); dimensions[1].focus(); - EventUtils.synthesizeKey("VK_PAGE_UP", {shiftKey: true}); + EventUtils.synthesizeKey("KEY_PageUp", {shiftKey: true}); await resized; // Resetting height value back to 500 by using `PageDown + Shift` key resized = waitForViewportResizeTo(ui, width, height); dimensions[1].focus(); - EventUtils.synthesizeKey("VK_PAGE_DOWN", {shiftKey: true}); + EventUtils.synthesizeKey("KEY_PageDown", {shiftKey: true}); await resized; } diff --git a/devtools/client/responsive.html/test/browser/browser_toolbox_rule_view.js b/devtools/client/responsive.html/test/browser/browser_toolbox_rule_view.js index 4450fb7d2f08..d8f30a7d18d3 100644 --- a/devtools/client/responsive.html/test/browser/browser_toolbox_rule_view.js +++ b/devtools/client/responsive.html/test/browser/browser_toolbox_rule_view.js @@ -63,7 +63,7 @@ async function testEscapeOpensSplitConsole(inspector) { info("Press escape"); let onSplit = inspector._toolbox.once("split-console"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await onSplit; ok(inspector._toolbox._splitConsole, "Console is split after pressing ESC."); diff --git a/devtools/client/shared/components/test/mochitest/test_searchbox-with-autocomplete.html b/devtools/client/shared/components/test/mochitest/test_searchbox-with-autocomplete.html index 8508faf334b3..95a896ff659b 100644 --- a/devtools/client/shared/components/test/mochitest/test_searchbox-with-autocomplete.html +++ b/devtools/client/shared/components/test/mochitest/test_searchbox-with-autocomplete.html @@ -119,7 +119,7 @@ window.onload = async function () { $(".devtools-searchinput").focus(); // ArrowDown - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); await forceRender(component); is(refs.autocomplete.state.selectedIndex, 0, "selectedIndex is 0"); ok($(".devtools-autocomplete-listbox .autocomplete-item:nth-child(1)") @@ -127,56 +127,56 @@ window.onload = async function () { "Selection class applied"); // ArrowUp should roll back to the bottom of the list - synthesizeKey("VK_UP", {}); + synthesizeKey("KEY_ArrowUp"); await forceRender(component); is(refs.autocomplete.state.selectedIndex, 6, "ArrowUp works"); // PageDown should take -5 places up - synthesizeKey("VK_PAGE_UP", {}); + synthesizeKey("KEY_PageUp"); await forceRender(component); is(refs.autocomplete.state.selectedIndex, 1, "PageUp works"); // PageDown should take +5 places down - synthesizeKey("VK_PAGE_DOWN", {}); + synthesizeKey("KEY_PageDown"); await forceRender(component); is(refs.autocomplete.state.selectedIndex, 6, "PageDown works"); // Home should take to the top of the list - synthesizeKey("VK_HOME", {}); + synthesizeKey("KEY_Home"); await forceRender(component); is(refs.autocomplete.state.selectedIndex, 0, "Home works"); // End should take to the bottom of the list - synthesizeKey("VK_END", {}); + synthesizeKey("KEY_End"); await forceRender(component); is(refs.autocomplete.state.selectedIndex, 6, "End works"); // Key down in existing state should rollover to the top - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); await forceRender(component); // Tab should select the component and hide popup - synthesizeKey("VK_TAB", {}); + synthesizeKey("KEY_Tab"); await forceRender(component); is(component.state.value, "ABC", "Tab hit selects the item"); ok(!$(".devtools-autocomplete-popup"), "Tab hit hides the popup"); // Activate popup by removing a key - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); await forceRender(component); ok($(".devtools-autocomplete-popup"), "Popup is up"); compareAutocompleteList($(".devtools-autocomplete-listbox"), ["ABC", "abc"]); // Enter key selection - synthesizeKey("VK_UP", {}); + synthesizeKey("KEY_ArrowUp"); await forceRender(component); - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); is(component.state.value, "abc", "Enter selection"); ok(!$(".devtools-autocomplete-popup"), "Enter/Return hides the popup"); // Escape should remove the autocomplete component - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); await forceRender(component); - synthesizeKey("VK_ESCAPE", {}); + synthesizeKey("KEY_Escape"); await forceRender(component); ok(!$(".devtools-autocomplete-popup"), "Autocomplete list removed from DOM on Escape"); @@ -191,7 +191,7 @@ window.onload = async function () { await forceRender(component); // ArrowDown - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); await forceRender(component); synthesizeMouseAtCenter($(".devtools-searchinput"), {}, window); await forceRender(component); diff --git a/devtools/client/shared/webpack/shims/test/test_clipboard.html b/devtools/client/shared/webpack/shims/test/test_clipboard.html index 90aa9e49d4d8..a964bc85d354 100644 --- a/devtools/client/shared/webpack/shims/test/test_clipboard.html +++ b/devtools/client/shared/webpack/shims/test/test_clipboard.html @@ -54,7 +54,7 @@ function do_tests() { SpecialPowers.clipboardCopyString("snowy owl"); elt.focus(); - synthesizeKey("x", {}); + sendString("x"); is(SpecialPowers.getClipboardData("text/unicode"), RESULT, "clipboard copying worked"); diff --git a/devtools/client/storage/test/browser_storage_cookies_edit_keyboard.js b/devtools/client/storage/test/browser_storage_cookies_edit_keyboard.js index f657d3d1b29b..4d1f3b3aaba2 100644 --- a/devtools/client/storage/test/browser_storage_cookies_edit_keyboard.js +++ b/devtools/client/storage/test/browser_storage_cookies_edit_keyboard.js @@ -13,13 +13,13 @@ add_task(function* () { let id = getCookieId("test4", "test1.example.org", "/browser"); yield startCellEdit(id, "name"); - yield typeWithTerminator("test6", "VK_TAB"); - yield typeWithTerminator(".example.org", "VK_TAB"); - yield typeWithTerminator("/", "VK_TAB"); - yield typeWithTerminator("Tue, 25 Dec 2040 12:00:00 GMT", "VK_TAB"); - yield typeWithTerminator("test6value", "VK_TAB"); - yield typeWithTerminator("false", "VK_TAB"); - yield typeWithTerminator("false", "VK_TAB"); + yield typeWithTerminator("test6", "KEY_Tab"); + yield typeWithTerminator(".example.org", "KEY_Tab"); + yield typeWithTerminator("/", "KEY_Tab"); + yield typeWithTerminator("Tue, 25 Dec 2040 12:00:00 GMT", "KEY_Tab"); + yield typeWithTerminator("test6value", "KEY_Tab"); + yield typeWithTerminator("false", "KEY_Tab"); + yield typeWithTerminator("false", "KEY_Tab"); yield finishTests(); }); diff --git a/devtools/client/storage/test/head.js b/devtools/client/storage/test/head.js index 2fdb96ccab0a..6803fe898ad8 100644 --- a/devtools/client/storage/test/head.js +++ b/devtools/client/storage/test/head.js @@ -709,7 +709,7 @@ function* editCell(id, column, newValue, validate = true) { editableFieldsEngine.edit(row[column]); - yield typeWithTerminator(newValue, "VK_RETURN", validate); + yield typeWithTerminator(newValue, "KEY_Enter", validate); } /** @@ -808,7 +808,7 @@ function showAllColumns(state) { * @param {String} str * The string to type. * @param {String} terminator - * The terminating key e.g. VK_RETURN or VK_TAB + * The terminating key e.g. KEY_Enter or KEY_Tab * @param {Boolean} validate * Validate result? Default true. */ @@ -827,7 +827,7 @@ function* typeWithTerminator(str, terminator, validate = true) { EventUtils.sendString(str); info("Pressing " + terminator); - EventUtils.synthesizeKey(terminator, {}); + EventUtils.synthesizeKey(terminator); if (validate) { info("Validating results... waiting for ROW_EDIT event."); diff --git a/devtools/client/styleeditor/test/browser_styleeditor_syncEditSelector.js b/devtools/client/styleeditor/test/browser_styleeditor_syncEditSelector.js index ea7d7515dbd6..0725d574039e 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_syncEditSelector.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_syncEditSelector.js @@ -28,7 +28,7 @@ add_task(function* () { let editor = yield focusEditableField(view, ruleEditor.selectorText); editor.input.value = "#testid, span"; let onRuleViewChanged = once(view, "ruleview-changed"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield onRuleViewChanged; let { ui } = yield openStyleEditor(); diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_accessibility.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_accessibility.js index 033d2d7f6df8..8d4c3ef43af9 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_accessibility.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_accessibility.js @@ -37,7 +37,7 @@ add_task(async function () { info("Close the autocomplete popup by simulating a TAB key event"); let onPopupClosed = jsterm.autocompletePopup.once("popup-closed"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); info("Wait for the autocomplete popup to be closed"); await onPopupClosed; diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_add_edited_input_to_history.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_add_edited_input_to_history.js index c93734a97d84..5994c54ad517 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_add_edited_input_to_history.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_add_edited_input_to_history.js @@ -25,31 +25,31 @@ function testEditedInputHistory(hud) { is(inputNode.selectionEnd, 0); jsterm.setInputValue('"first item"'); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), '"first item"', "null test history up"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), '"first item"', "null test history down"); jsterm.execute(); is(jsterm.getInputValue(), "", "cleared input line after submit"); jsterm.setInputValue('"editing input 1"'); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), '"first item"', "test history up"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), '"editing input 1"', "test history down restores in-progress input"); jsterm.setInputValue('"second item"'); jsterm.execute(); jsterm.setInputValue('"editing input 2"'); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), '"second item"', "test history up"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), '"first item"', "test history up"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), '"second item"', "test history down"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), '"editing input 2"', "test history down restores new in-progress input again"); } diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_array_no_index.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_array_no_index.js index 18ac8d223d44..63f9908a8bb1 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_array_no_index.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_array_no_index.js @@ -28,7 +28,7 @@ add_task(async function () { info("wait for popup to show"); jsterm.setInputValue("foo"); - EventUtils.synthesizeKey(".", {}); + EventUtils.sendString("."); await onPopUpOpen; @@ -37,7 +37,7 @@ add_task(async function () { info("press Escape to close the popup"); const onPopupClose = popup.once("popup-closed"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await onPopupClose; }); diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_crossdomain_iframe.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_crossdomain_iframe.js index bd5adbad8ad2..364427ebc793 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_crossdomain_iframe.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_crossdomain_iframe.js @@ -20,12 +20,12 @@ add_task(async function () { // Make sure we don't throw when trying to autocomplete let autocompleteUpdated = hud.jsterm.once("autocomplete-updated"); jsterm.setInputValue("window[0].document"); - EventUtils.synthesizeKey(".", {}); + EventUtils.sendString("."); await autocompleteUpdated; hud.jsterm.setInputValue("window[0].document.title"); const onPermissionDeniedMessage = waitForMessage(hud, "Permission denied"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); const permissionDenied = await onPermissionDeniedMessage; ok(permissionDenied.node.classList.contains("error"), "A message error is shown when trying to inspect window[0]"); diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_escape_key.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_escape_key.js index d5f61ef9c8d8..db1c84396f56 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_escape_key.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_escape_key.js @@ -36,7 +36,7 @@ add_task(async function () { info("wait for completion: window.foo."); jsterm.setInputValue("window.foo"); - EventUtils.synthesizeKey(".", {}); + EventUtils.sendString("."); await onPopUpOpen; @@ -45,7 +45,7 @@ add_task(async function () { info("press Escape to close the popup"); const onPopupClose = popup.once("popup-closed"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await onPopupClose; diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_inside_text.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_inside_text.js index 41e25f177f5c..05c21110af4e 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_inside_text.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_inside_text.js @@ -31,14 +31,14 @@ add_task(async function () { const dumpString = "dump(window.testBu)"; jsterm.setInputValue(dumpString); inputNode.selectionStart = inputNode.selectionEnd = dumpString.indexOf(")"); - EventUtils.synthesizeKey("g", {}); + EventUtils.sendString("g"); await onPopUpOpen; ok(popup.isOpen, "popup is open"); is(popup.itemCount, 2, "popup.itemCount is correct"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(popup.selectedIndex, 0, "popup.selectedIndex is correct"); ok(!completeNode.value, "completeNode.value is empty"); @@ -48,7 +48,7 @@ add_task(async function () { info("press Tab and wait for popup to hide"); const onPopupClose = popup.once("popup-closed"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); await onPopupClose; diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_native_getters.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_native_getters.js index e77dba69a0a3..b54f99c763b7 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_native_getters.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_native_getters.js @@ -22,7 +22,7 @@ add_task(async function () { let onPopupOpen = popup.once("popup-opened"); jsterm.setInputValue("document.body"); - EventUtils.synthesizeKey(".", {}); + EventUtils.sendString("."); await onPopupOpen; @@ -36,7 +36,7 @@ add_task(async function () { "ATTRIBUTE_NODE is in the list of suggestions"); let onPopupClose = popup.once("popup-closed"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await onPopupClose; @@ -44,7 +44,7 @@ add_task(async function () { let onAutoCompleteUpdated = jsterm.once("autocomplete-updated"); let inputStr = "document.b"; jsterm.setInputValue(inputStr); - EventUtils.synthesizeKey("o", {}); + EventUtils.sendString("o"); await onAutoCompleteUpdated; diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_nav_and_tab_key.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_nav_and_tab_key.js index a26563796f58..663698ee84ce 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_nav_and_tab_key.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_nav_and_tab_key.js @@ -40,7 +40,7 @@ add_task(async function () { jsterm.setInputValue("window.foo"); // Shows the popup - EventUtils.synthesizeKey(".", {}); + EventUtils.sendString("."); await onPopUpOpen; ok(popup.isOpen, "popup is open"); @@ -59,20 +59,20 @@ add_task(async function () { is(popup.selectedIndex, expectedPopupItems.length - 1, "Index of the first item from bottom is selected."); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); let prefix = jsterm.getInputValue().replace(/[\S]/g, " "); is(popup.selectedIndex, 0, "index 0 is selected"); is(popup.selectedItem.label, "item3", "item3 is selected"); is(completeNode.value, prefix + "item3", "completeNode.value holds item3"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(popup.selectedIndex, 1, "index 1 is selected"); is(popup.selectedItem.label, "item2", "item2 is selected"); is(completeNode.value, prefix + "item2", "completeNode.value holds item2"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(popup.selectedIndex, 0, "index 0 is selected"); is(popup.selectedItem.label, "item3", "item3 is selected"); @@ -80,30 +80,30 @@ add_task(async function () { let currentSelectionIndex = popup.selectedIndex; - EventUtils.synthesizeKey("VK_PAGE_DOWN", {}); + EventUtils.synthesizeKey("KEY_PageDown"); ok(popup.selectedIndex > currentSelectionIndex, "Index is greater after PGDN"); currentSelectionIndex = popup.selectedIndex; - EventUtils.synthesizeKey("VK_PAGE_UP", {}); + EventUtils.synthesizeKey("KEY_PageUp"); ok(popup.selectedIndex < currentSelectionIndex, "Index is less after Page UP"); - EventUtils.synthesizeKey("VK_END", {}); + EventUtils.synthesizeKey("KEY_End"); is(popup.selectedIndex, expectedPopupItems.length - 1, "index is last after End"); - EventUtils.synthesizeKey("VK_HOME", {}); + EventUtils.synthesizeKey("KEY_Home"); is(popup.selectedIndex, 0, "index is first after Home"); info("press Tab and wait for popup to hide"); const onPopupClose = popup.once("popup-closed"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); await onPopupClose; // At this point the completion suggestion should be accepted. ok(!popup.isOpen, "popup is not open"); is(jsterm.getInputValue(), "window.foo.item3", - "completion was successful after VK_TAB"); + "completion was successful after KEY_Tab"); ok(!completeNode.value, "completeNode is empty"); }); diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_return_key.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_return_key.js index b3c267ce3e64..f3a12f43ac24 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_return_key.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_return_key.js @@ -42,8 +42,7 @@ add_task(async function () { info("wait for completion suggestions: window.foobar."); jsterm.setInputValue("window.fooba"); - EventUtils.synthesizeKey("r", {}); - EventUtils.synthesizeKey(".", {}); + EventUtils.sendString("r."); await onPopUpOpen; @@ -59,7 +58,7 @@ add_task(async function () { is(popup.selectedIndex, expectedPopupItems.length - 1, "First index from bottom is selected"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(popup.selectedIndex, 0, "index 0 is selected"); is(popup.selectedItem.label, "item3", "item3 is selected"); @@ -68,13 +67,13 @@ add_task(async function () { info("press Return to accept suggestion. wait for popup to hide"); const onPopupClose = popup.once("popup-closed"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await onPopupClose; - ok(!popup.isOpen, "popup is not open after VK_RETURN"); + ok(!popup.isOpen, "popup is not open after KEY_Enter"); is(jsterm.getInputValue(), "window.foobar.item3", - "completion was successful after VK_RETURN"); + "completion was successful after KEY_Enter"); ok(!completeNode.value, "completeNode is empty"); Services.prefs.clearUserPref(PREF_AUTO_MULTILINE); diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_return_key_no_selection.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_return_key_no_selection.js index 7de4b32260e3..a2d0aaef6c7a 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_return_key_no_selection.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_autocomplete_return_key_no_selection.js @@ -28,7 +28,7 @@ add_task(async function () { info("wait for popup to show"); jsterm.setInputValue("window.testBu"); - EventUtils.synthesizeKey("g", {}); + EventUtils.sendString("g"); await onPopUpOpen; @@ -38,11 +38,11 @@ add_task(async function () { info("press Return and wait for popup to hide"); const onPopUpClose = popup.once("popup-closed"); - executeSoon(() => EventUtils.synthesizeKey("VK_RETURN", {})); + executeSoon(() => EventUtils.synthesizeKey("KEY_Enter")); await onPopUpClose; - ok(!popup.isOpen, "popup is not open after VK_RETURN"); - is(jsterm.getInputValue(), "", "inputNode is empty after VK_RETURN"); + ok(!popup.isOpen, "popup is not open after KEY_Enter"); + is(jsterm.getInputValue(), "", "inputNode is empty after KEY_Enter"); is(completeNode.value, "", "completeNode is empty"); is(jsterm.history[jsterm.history.length - 1], "window.testBug", "jsterm history is correct"); diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_ctrl_key_nav.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_ctrl_key_nav.js index 1a0a2da0dfa3..48de7c3e3210 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_ctrl_key_nav.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_ctrl_key_nav.js @@ -29,7 +29,7 @@ add_task(async function () { function testSingleLineInputNavNoHistory(jsterm) { let inputNode = jsterm.inputNode; // Single char input - EventUtils.synthesizeKey("1", {}); + EventUtils.sendString("1"); is(inputNode.selectionStart, 1, "caret location after single char input"); // nav to start/end with ctrl-a and ctrl-e; @@ -42,14 +42,14 @@ function testSingleLineInputNavNoHistory(jsterm) { "caret location after single char input and ctrl-e"); // Second char input - EventUtils.synthesizeKey("2", {}); + EventUtils.sendString("2"); // nav to start/end with up/down keys; verify behaviour using ctrl-p/ctrl-n - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(inputNode.selectionStart, 0, - "caret location after two char input and VK_UP"); - EventUtils.synthesizeKey("VK_DOWN", {}); + "caret location after two char input and KEY_ArrowUp"); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(inputNode.selectionStart, 2, - "caret location after two char input and VK_DOWN"); + "caret location after two char input and KEY_ArrowDown"); synthesizeLineStartKey(); is(inputNode.selectionStart, 0, @@ -85,7 +85,7 @@ function testMultiLineInputNavNoHistory(jsterm) { // simulate shift-return for (let i = 0; i < lineValues.length; i++) { jsterm.setInputValue(jsterm.getInputValue() + lineValues[i]); - EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true }); + EventUtils.synthesizeKey("KEY_Enter", {shiftKey: true}); } let inputValue = jsterm.getInputValue(); is(inputNode.selectionStart, inputNode.selectionEnd); @@ -97,12 +97,12 @@ function testMultiLineInputNavNoHistory(jsterm) { let newlineString = inputValue.match(/(\r\n?|\n\r?)$/)[0]; // Ok, test navigating within the multi-line string! - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); let expectedStringAfterCarat = lineValues[5] + newlineString; is(jsterm.getInputValue().slice(inputNode.selectionStart), expectedStringAfterCarat, "up arrow from end of multiline"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue().slice(inputNode.selectionStart), "", "down arrow from within multiline"); @@ -226,17 +226,17 @@ function testNavWithHistory(jsterm) { } function synthesizeLineStartKey() { - EventUtils.synthesizeKey("a", { ctrlKey: true }); + EventUtils.synthesizeKey("a", {ctrlKey: true}); } function synthesizeLineEndKey() { - EventUtils.synthesizeKey("e", { ctrlKey: true }); + EventUtils.synthesizeKey("e", {ctrlKey: true}); } function synthesizeLineUpKey() { - EventUtils.synthesizeKey("p", { ctrlKey: true }); + EventUtils.synthesizeKey("p", {ctrlKey: true}); } function synthesizeLineDownKey() { - EventUtils.synthesizeKey("n", { ctrlKey: true }); + EventUtils.synthesizeKey("n", {ctrlKey: true}); } diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_history_nav.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_history_nav.js index 255af0cc58a5..586cd91c5381 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_history_nav.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_history_nav.js @@ -34,10 +34,10 @@ add_task(async function () { is(jsterm.lastInputValue, "window.foobarBug660806.location", "lastInputValue is correct"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); let onSetInputValue = jsterm.once("set-input-value"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); await onSetInputValue; // We don't have an explicit event to wait for here, so we just wait for the next tick diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_history_persist.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_history_persist.js index 42de2ef4a1ff..71e0f41d3e32 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_history_persist.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_history_persist.js @@ -106,7 +106,7 @@ function testNavigatingHistoryInUI(hud) { // Count backwards from original input and make sure that pressing up // restores this. for (let i = INPUT_HISTORY_COUNT - 1; i >= 0; i--) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), i, "Pressing up restores last input"); } } diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_input_expansion.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_input_expansion.js index 8293ce0ee0e6..41b3c371c313 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_input_expansion.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_input_expansion.js @@ -28,11 +28,11 @@ add_task(async function () { input.selectionStart = length; info("Type 'd' in jsterm to trigger height change for the input"); - EventUtils.synthesizeKey("d", {}); + EventUtils.sendString("d"); ok(input.clientHeight > ordinaryHeight, "the input expanded"); info("Erase the value and test if the inputNode shrinks again"); input.value = ""; - EventUtils.synthesizeKey("d", {}); + EventUtils.sendString("d"); is(input.clientHeight, ordinaryHeight, "the input's height is normal again"); }); diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_autocompletion_on_defined_variables.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_autocompletion_on_defined_variables.js index 250bfa240a50..da5a294ea9f6 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_autocompletion_on_defined_variables.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_autocompletion_on_defined_variables.js @@ -21,18 +21,17 @@ function testCompletion(hud) { // Test typing 'var d = 5;' and press RETURN jsterm.setInputValue("var d = "); - EventUtils.synthesizeKey("5", {}); - EventUtils.synthesizeKey(";", {}); + EventUtils.sendString("5;"); is(input.value, "var d = 5;", "var d = 5;"); is(jsterm.completeNode.value, "", "no completion"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); is(jsterm.completeNode.value, "", "clear completion on execute()"); // Test typing 'var a = d' and press RETURN jsterm.setInputValue("var a = "); - EventUtils.synthesizeKey("d", {}); + EventUtils.sendString("d"); is(input.value, "var a = d", "var a = d"); is(jsterm.completeNode.value, "", "no completion"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); is(jsterm.completeNode.value, "", "clear completion on execute()"); } diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_input_and_tab_key_pressed.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_input_and_tab_key_pressed.js index a1efc3a1b263..17420a49b7fa 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_input_and_tab_key_pressed.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_input_and_tab_key_pressed.js @@ -19,14 +19,14 @@ function testCompletion(hud) { let input = jsterm.inputNode; jsterm.setInputValue(""); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(jsterm.completeNode.value, "<- no result", "<- no result - matched"); is(input.value, "", "inputnode is empty - matched"); ok(hasFocus(input), "input is still focused"); // Any thing which is not in property autocompleter jsterm.setInputValue("window.Bug583816"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(jsterm.completeNode.value, " <- no result", "completenode content - matched"); is(input.value, "window.Bug583816", "inputnode content - matched"); diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_input_change_and_tab_key_pressed.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_input_change_and_tab_key_pressed.js index 866379aabfb6..fd13f63a206e 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_input_change_and_tab_key_pressed.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_no_input_change_and_tab_key_pressed.js @@ -15,19 +15,19 @@ add_task(async function() { let input = jsterm.inputNode; is(hasFocus(input), true, "input has focus"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(hasFocus(input), false, "focus moved away"); // Test user changed something input.focus(); - EventUtils.synthesizeKey("A", {}); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.sendString("A"); + EventUtils.synthesizeKey("KEY_Tab"); is(hasFocus(input), true, "input is still focused"); // Test non empty input but not changed since last focus input.blur(); input.focus(); - EventUtils.synthesizeKey("VK_RIGHT", {}); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); + EventUtils.synthesizeKey("KEY_Tab"); is(hasFocus(input), false, "focus moved away"); }); diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_popup_close_on_tab_switch.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_popup_close_on_tab_switch.js index 94de4698d940..8a9b6e1a5eb1 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_popup_close_on_tab_switch.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_popup_close_on_tab_switch.js @@ -17,7 +17,7 @@ add_task(async function () { let popupShown = once(popup, "popup-opened"); hud.jsterm.setInputValue("sc"); - EventUtils.synthesizeKey("r", {}); + EventUtils.sendString("r"); await popupShown; diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_selfxss.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_selfxss.js index 284926df6957..f928895be6b0 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_selfxss.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_selfxss.js @@ -25,7 +25,7 @@ add_task(async function () { info("wait for completion value after typing 'docu'"); let onAutocompleteUpdated = jsterm.once("autocomplete-updated"); - EventUtils.synthesizeKey("u", {}); + EventUtils.sendString("u"); await onAutocompleteUpdated; const completionValue = jsterm.completeNode.value; diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_close_sidebar.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_close_sidebar.js index 0232438cb4f8..7035f8271667 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_close_sidebar.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_close_sidebar.js @@ -65,7 +65,7 @@ add_task(async function () { info("Send escape to hide sidebar"); onSidebarShown = waitForNodeMutation(wrapper, { childList: true }); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await onSidebarShown; sidebar = hud.ui.document.querySelector(".sidebar"); ok(!sidebar, "Sidebar hidden after sending esc"); diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_filter_scroll.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_filter_scroll.js index 9ec64a856ffb..d8327cc4ea61 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_filter_scroll.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_filter_scroll.js @@ -30,7 +30,7 @@ add_task(async function () { filterInput.value = "init-"; filterInput.focus(); let onMessagesFiltered = waitFor(() => !findMessage(hud, "init-1"), null, 200); - EventUtils.synthesizeKey("9", {}); + EventUtils.sendString("9"); await onMessagesFiltered; ok(isScrolledToBottom(outputContainer), "The console is still scrolled to the bottom after filtering"); @@ -38,7 +38,7 @@ add_task(async function () { info("Clear the text filter and check that the scroll position is not impacted"); let onMessagesUnFiltered = waitFor(() => findMessage(hud, "init-1"), null, 200); filterInput.select(); - EventUtils.synthesizeKey("VK_DELETE", {}); + EventUtils.synthesizeKey("KEY_Delete"); await onMessagesUnFiltered; ok(isScrolledToBottom(outputContainer), "The console is still scrolled to the bottom after clearing the filter"); @@ -49,7 +49,7 @@ add_task(async function () { filterInput.value = "init-"; filterInput.focus(); onMessagesFiltered = waitFor(() => !findMessage(hud, "init-1"), null, 200); - EventUtils.synthesizeKey("9", {}); + EventUtils.sendString("9"); await onMessagesFiltered; is(outputContainer.scrollTop, 0, "The console is still scrolled to the top after filtering"); @@ -57,7 +57,7 @@ add_task(async function () { info("Clear the text filter and check that the scroll position is not impacted"); onMessagesUnFiltered = waitFor(() => findMessage(hud, "init-1"), null, 200); filterInput.select(); - EventUtils.synthesizeKey("VK_DELETE", {}); + EventUtils.synthesizeKey("KEY_Delete"); await onMessagesUnFiltered; is(outputContainer.scrollTop, 0, "The console is still scrolled to the top after clearing the filter"); diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_history_arrow_keys.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_history_arrow_keys.js index 9d243673b280..825ca608c4c5 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_history_arrow_keys.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_history_arrow_keys.js @@ -38,7 +38,7 @@ function performTests(jsterm) { let { inputNode } = jsterm; let values = TEST_VALUES; - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), values[4], "VK_UP: jsterm.getInputValue() #4 is correct"); @@ -47,7 +47,7 @@ function performTests(jsterm) { inputNode.selectionStart == inputNode.selectionEnd, "caret location is correct"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), values[3], "VK_UP: jsterm.getInputValue() #3 is correct"); @@ -58,8 +58,8 @@ function performTests(jsterm) { inputNode.setSelectionRange(values[3].length - 2, values[3].length - 2); - EventUtils.synthesizeKey("VK_UP", {}); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), values[3], "VK_UP two times: jsterm.getInputValue() #3 is correct"); @@ -68,7 +68,7 @@ function performTests(jsterm) { inputNode.selectionStart == inputNode.selectionEnd, "caret location is correct"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), values[3], "VK_UP again: jsterm.getInputValue() #3 is correct"); @@ -77,17 +77,17 @@ function performTests(jsterm) { inputNode.selectionStart == inputNode.selectionEnd, "caret location is correct"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), values[2], "VK_UP: jsterm.getInputValue() #2 is correct"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), values[1], "VK_UP: jsterm.getInputValue() #1 is correct"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), values[0], "VK_UP: jsterm.getInputValue() #0 is correct"); @@ -96,7 +96,7 @@ function performTests(jsterm) { inputNode.selectionStart == inputNode.selectionEnd, "caret location is correct"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), values[1], "VK_DOWN: jsterm.getInputValue() #1 is correct"); @@ -105,12 +105,12 @@ function performTests(jsterm) { inputNode.selectionStart == inputNode.selectionEnd, "caret location is correct"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), values[2], "VK_DOWN: jsterm.getInputValue() #2 is correct"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), values[3], "VK_DOWN: jsterm.getInputValue() #3 is correct"); @@ -121,8 +121,8 @@ function performTests(jsterm) { inputNode.setSelectionRange(2, 2); - EventUtils.synthesizeKey("VK_DOWN", {}); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), values[3], "VK_DOWN two times: jsterm.getInputValue() #3 is correct"); @@ -131,7 +131,7 @@ function performTests(jsterm) { inputNode.selectionStart == inputNode.selectionEnd, "caret location is correct"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), values[3], "VK_DOWN again: jsterm.getInputValue() #3 is correct"); @@ -140,12 +140,12 @@ function performTests(jsterm) { inputNode.selectionStart == inputNode.selectionEnd, "caret location is correct"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), values[4], "VK_DOWN: jsterm.getInputValue() #4 is correct"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); ok(!jsterm.getInputValue(), "VK_DOWN: jsterm.getInputValue() is empty"); diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_keyboard_accessibility.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_keyboard_accessibility.js index f13ca384aa4e..dc9829662774 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_keyboard_accessibility.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_keyboard_accessibility.js @@ -25,21 +25,21 @@ add_task(async function () { const bottom = currentPosition; hud.jsterm.inputNode.focus(); // Page up. - EventUtils.synthesizeKey("VK_PAGE_UP", {}); + EventUtils.synthesizeKey("KEY_PageUp"); isnot(outputScroller.scrollTop, currentPosition, "scroll position changed after page up"); // Page down. currentPosition = outputScroller.scrollTop; - EventUtils.synthesizeKey("VK_PAGE_DOWN", {}); + EventUtils.synthesizeKey("KEY_PageDown"); ok(outputScroller.scrollTop > currentPosition, "scroll position now at bottom"); // Home - EventUtils.synthesizeKey("VK_HOME", {}); + EventUtils.synthesizeKey("KEY_Home"); is(outputScroller.scrollTop, 0, "scroll position now at top"); // End - EventUtils.synthesizeKey("VK_END", {}); + EventUtils.synthesizeKey("KEY_End"); let scrollTop = outputScroller.scrollTop; ok(scrollTop > 0 && Math.abs(scrollTop - bottom) <= 5, "scroll position now at bottom"); diff --git a/devtools/client/webconsole/test/browser_bug_865871_variables_view_close_on_esc_key.js b/devtools/client/webconsole/test/browser_bug_865871_variables_view_close_on_esc_key.js index 044525b28f70..6b6d52607717 100644 --- a/devtools/client/webconsole/test/browser_bug_865871_variables_view_close_on_esc_key.js +++ b/devtools/client/webconsole/test/browser_bug_865871_variables_view_close_on_esc_key.js @@ -34,7 +34,7 @@ function test() { vview.window.focus(); let sidebarClosed = jsterm.once("sidebar-closed"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); yield sidebarClosed; jsterm.clearOutput(); @@ -47,7 +47,7 @@ function test() { msg.scrollIntoView(); sidebarClosed = jsterm.once("sidebar-closed"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); yield sidebarClosed; function* openSidebar(objName, expectedText, expectedObj) { diff --git a/devtools/client/webconsole/test/browser_console_history_persist.js b/devtools/client/webconsole/test/browser_console_history_persist.js index 61c4cbf4dfbc..3516155c2991 100644 --- a/devtools/client/webconsole/test/browser_console_history_persist.js +++ b/devtools/client/webconsole/test/browser_console_history_persist.js @@ -113,7 +113,7 @@ function* testNaviatingHistoryInUI(hud) { // Count backwards from original input and make sure that pressing up // restores this. for (let i = INPUT_HISTORY_COUNT - 1; i >= 0; i--) { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), i, "Pressing up restores last input"); } } diff --git a/devtools/client/webconsole/test/browser_console_keyboard_accessibility.js b/devtools/client/webconsole/test/browser_console_keyboard_accessibility.js index a330ad052396..7718128dea13 100644 --- a/devtools/client/webconsole/test/browser_console_keyboard_accessibility.js +++ b/devtools/client/webconsole/test/browser_console_keyboard_accessibility.js @@ -33,19 +33,19 @@ add_task(async function () { let currentPosition = hud.ui.outputWrapper.scrollTop; let bottom = currentPosition; - EventUtils.synthesizeKey("VK_PAGE_UP", {}); + EventUtils.synthesizeKey("KEY_PageUp"); isnot(hud.ui.outputWrapper.scrollTop, currentPosition, "scroll position changed after page up"); currentPosition = hud.ui.outputWrapper.scrollTop; - EventUtils.synthesizeKey("VK_PAGE_DOWN", {}); + EventUtils.synthesizeKey("KEY_PageDown"); ok(hud.ui.outputWrapper.scrollTop > currentPosition, "scroll position now at bottom"); - EventUtils.synthesizeKey("VK_HOME", {}); + EventUtils.synthesizeKey("KEY_Home"); is(hud.ui.outputWrapper.scrollTop, 0, "scroll position now at top"); - EventUtils.synthesizeKey("VK_END", {}); + EventUtils.synthesizeKey("KEY_End"); let scrollTop = hud.ui.outputWrapper.scrollTop; ok(scrollTop > 0 && Math.abs(scrollTop - bottom) <= 5, @@ -80,12 +80,12 @@ add_task(async function () { if (Services.appinfo.OS == "Darwin") { ok(hud.ui.getFilterState("network"), "network category is enabled"); - EventUtils.synthesizeKey("t", { ctrlKey: true }); + EventUtils.synthesizeKey("t", {ctrlKey: true}); ok(!hud.ui.getFilterState("network"), "accesskey for Network works"); - EventUtils.synthesizeKey("t", { ctrlKey: true }); + EventUtils.synthesizeKey("t", {ctrlKey: true}); ok(hud.ui.getFilterState("network"), "accesskey for Network works (again)"); } else { - EventUtils.synthesizeKey("N", { altKey: true }); + EventUtils.synthesizeKey("n", {altKey: true}); let net = hud.ui.document.querySelector("toolbarbutton[category=net]"); is(hud.ui.document.activeElement, net, "accesskey for Network category focuses the Net button"); diff --git a/devtools/client/webconsole/test/browser_webconsole_autocomplete_accessibility.js b/devtools/client/webconsole/test/browser_webconsole_autocomplete_accessibility.js index bcd2e22d0fb8..2f8c5c44e1a4 100644 --- a/devtools/client/webconsole/test/browser_webconsole_autocomplete_accessibility.js +++ b/devtools/client/webconsole/test/browser_webconsole_autocomplete_accessibility.js @@ -39,7 +39,7 @@ add_task(function* () { info("Close the autocomplete popup by simulating a TAB key event"); let onPopupClosed = jsterm.autocompletePopup.once("popup-closed"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); info("Wait for the autocomplete popup to be closed"); yield onPopupClosed; diff --git a/devtools/client/webconsole/test/browser_webconsole_autocomplete_and_selfxss.js b/devtools/client/webconsole/test/browser_webconsole_autocomplete_and_selfxss.js index 37c86ef16345..b08b0400f73f 100644 --- a/devtools/client/webconsole/test/browser_webconsole_autocomplete_and_selfxss.js +++ b/devtools/client/webconsole/test/browser_webconsole_autocomplete_and_selfxss.js @@ -124,7 +124,7 @@ function consoleOpened(HUD) { info("wait for completion value after typing 'docu'"); jsterm.once("autocomplete-updated", onCompletionValue); - EventUtils.synthesizeKey("u", {}); + EventUtils.sendString("u"); return deferred.promise; } diff --git a/devtools/client/webconsole/test/browser_webconsole_autocomplete_crossdomain_iframe.js b/devtools/client/webconsole/test/browser_webconsole_autocomplete_crossdomain_iframe.js index b4471bd6bc1f..0e507e838f44 100644 --- a/devtools/client/webconsole/test/browser_webconsole_autocomplete_crossdomain_iframe.js +++ b/devtools/client/webconsole/test/browser_webconsole_autocomplete_crossdomain_iframe.js @@ -32,13 +32,13 @@ function test() { hud.jsterm.setInputValue("window[0].document"); executeSoon(() => { - EventUtils.synthesizeKey(".", {}); + EventUtils.sendString("."); }); yield autocompleteUpdated; hud.jsterm.setInputValue("window[0].document.title"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); yield waitForMessages({ webconsole: hud, diff --git a/devtools/client/webconsole/test/browser_webconsole_autocomplete_popup_close_on_tab_switch.js b/devtools/client/webconsole/test/browser_webconsole_autocomplete_popup_close_on_tab_switch.js index afa3dd55d1be..69bb9d6af64d 100644 --- a/devtools/client/webconsole/test/browser_webconsole_autocomplete_popup_close_on_tab_switch.js +++ b/devtools/client/webconsole/test/browser_webconsole_autocomplete_popup_close_on_tab_switch.js @@ -17,7 +17,7 @@ add_task(function* () { let popupShown = once(popup, "popup-opened"); hud.jsterm.setInputValue("sc"); - EventUtils.synthesizeKey("r", {}); + EventUtils.sendString("r"); yield popupShown; diff --git a/devtools/client/webconsole/test/browser_webconsole_bug_583816_No_input_and_Tab_key_pressed.js b/devtools/client/webconsole/test/browser_webconsole_bug_583816_No_input_and_Tab_key_pressed.js index 7dd27138806d..e0e4f2bdda41 100644 --- a/devtools/client/webconsole/test/browser_webconsole_bug_583816_No_input_and_Tab_key_pressed.js +++ b/devtools/client/webconsole/test/browser_webconsole_bug_583816_No_input_and_Tab_key_pressed.js @@ -20,14 +20,14 @@ function testCompletion(hud) { let input = jsterm.inputNode; jsterm.setInputValue(""); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(jsterm.completeNode.value, "<- no result", "<- no result - matched"); is(input.value, "", "inputnode is empty - matched"); is(input.getAttribute("focused"), "true", "input is still focused"); // Any thing which is not in property autocompleter jsterm.setInputValue("window.Bug583816"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(jsterm.completeNode.value, " <- no result", "completenode content - matched"); is(input.value, "window.Bug583816", "inputnode content - matched"); diff --git a/devtools/client/webconsole/test/browser_webconsole_bug_585991_autocomplete_keys.js b/devtools/client/webconsole/test/browser_webconsole_bug_585991_autocomplete_keys.js index 6530d6a67d39..41c96fba004f 100644 --- a/devtools/client/webconsole/test/browser_webconsole_bug_585991_autocomplete_keys.js +++ b/devtools/client/webconsole/test/browser_webconsole_bug_585991_autocomplete_keys.js @@ -88,7 +88,7 @@ var consoleOpened = Task.async(function* (hud) { is(popup.selectedIndex, 16, "Index of the first item from bottom is selected."); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); let prefix = jsterm.getInputValue().replace(/[\S]/g, " "); @@ -97,14 +97,14 @@ var consoleOpened = Task.async(function* (hud) { is(completeNode.value, prefix + "valueOf", "completeNode.value holds valueOf"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(popup.selectedIndex, 1, "index 1 is selected"); is(popup.selectedItem.label, "toString", "toString is selected"); is(completeNode.value, prefix + "toString", "completeNode.value holds toString"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(popup.selectedIndex, 0, "index 0 is selected"); is(popup.selectedItem.label, "valueOf", "valueOf is selected"); @@ -113,32 +113,32 @@ var consoleOpened = Task.async(function* (hud) { let currentSelectionIndex = popup.selectedIndex; - EventUtils.synthesizeKey("VK_PAGE_DOWN", {}); + EventUtils.synthesizeKey("KEY_PageDown"); ok(popup.selectedIndex > currentSelectionIndex, "Index is greater after PGDN"); currentSelectionIndex = popup.selectedIndex; - EventUtils.synthesizeKey("VK_PAGE_UP", {}); + EventUtils.synthesizeKey("KEY_PageUp"); ok(popup.selectedIndex < currentSelectionIndex, "Index is less after Page UP"); - EventUtils.synthesizeKey("VK_END", {}); + EventUtils.synthesizeKey("KEY_End"); is(popup.selectedIndex, 16, "index is last after End"); - EventUtils.synthesizeKey("VK_HOME", {}); + EventUtils.synthesizeKey("KEY_Home"); is(popup.selectedIndex, 0, "index is first after Home"); info("press Tab and wait for popup to hide"); popup.once("popup-closed", () => { deferred.resolve(); }); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); }); jsterm.setInputValue("window.foobarBug585991"); - EventUtils.synthesizeKey(".", {}); + EventUtils.sendString("."); return deferred.promise; }); @@ -150,7 +150,7 @@ function popupHideAfterTab() { ok(!popup.isOpen, "popup is not open"); is(jsterm.getInputValue(), "window.foobarBug585991.valueOf", - "completion was successful after VK_TAB"); + "completion was successful after KEY_Tab"); ok(!completeNode.value, "completeNode is empty"); @@ -160,7 +160,7 @@ function popupHideAfterTab() { is(popup.itemCount, 17, "popup.itemCount is correct"); is(popup.selectedIndex, 16, "First index from bottom is selected"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); let prefix = jsterm.getInputValue().replace(/[\S]/g, " "); @@ -170,7 +170,7 @@ function popupHideAfterTab() { "completeNode.value holds valueOf"); popup.once("popup-closed", function onHidden() { - ok(!popup.isOpen, "popup is not open after VK_ESCAPE"); + ok(!popup.isOpen, "popup is not open after KEY_Escape"); is(jsterm.getInputValue(), "window.foobarBug585991.", "completion was cancelled"); @@ -182,14 +182,14 @@ function popupHideAfterTab() { info("press Escape to close the popup"); executeSoon(function () { - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); }); }, false); info("wait for completion: window.foobarBug585991."); executeSoon(function () { jsterm.setInputValue("window.foobarBug585991"); - EventUtils.synthesizeKey(".", {}); + EventUtils.sendString("."); }); return deferred.promise; @@ -204,7 +204,7 @@ function testReturnKey() { is(popup.itemCount, 17, "popup.itemCount is correct"); is(popup.selectedIndex, 16, "First index from bottom is selected"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); let prefix = jsterm.getInputValue().replace(/[\S]/g, " "); @@ -213,7 +213,7 @@ function testReturnKey() { is(completeNode.value, prefix + "valueOf", "completeNode.value holds valueOf"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(popup.selectedIndex, 1, "index 1 is selected"); is(popup.selectedItem.label, "toString", "toString is selected"); @@ -221,10 +221,10 @@ function testReturnKey() { "completeNode.value holds toString"); popup.once("popup-closed", function onHidden() { - ok(!popup.isOpen, "popup is not open after VK_RETURN"); + ok(!popup.isOpen, "popup is not open after KEY_Enter"); is(jsterm.getInputValue(), "window.foobarBug585991.toString", - "completion was successful after VK_RETURN"); + "completion was successful after KEY_Enter"); ok(!completeNode.value, "completeNode is empty"); @@ -233,15 +233,14 @@ function testReturnKey() { info("press Return to accept suggestion. wait for popup to hide"); - executeSoon(() => EventUtils.synthesizeKey("VK_RETURN", {})); + executeSoon(() => EventUtils.synthesizeKey("KEY_Enter")); }, false); info("wait for completion suggestions: window.foobarBug585991."); executeSoon(function () { jsterm.setInputValue("window.foobarBug58599"); - EventUtils.synthesizeKey("1", {}); - EventUtils.synthesizeKey(".", {}); + EventUtils.sendString("1."); }); return deferred.promise; @@ -271,13 +270,13 @@ function* dontShowArrayNumbers() { }, false); info("wait for popup to hide"); - executeSoon(() => EventUtils.synthesizeKey("VK_ESCAPE", {})); + executeSoon(() => EventUtils.synthesizeKey("KEY_Escape")); }, false); info("wait for popup to show"); executeSoon(() => { jsterm.setInputValue("window.foobarBug585991"); - EventUtils.synthesizeKey(".", {}); + EventUtils.sendString("."); }); return deferred.promise; @@ -297,22 +296,22 @@ function testReturnWithNoSelection() { popup.once("popup-closed", function popupHidden() { deferred.resolve(); }); - executeSoon(() => EventUtils.synthesizeKey("VK_RETURN", {})); + executeSoon(() => EventUtils.synthesizeKey("KEY_Enter")); }); executeSoon(() => { info("wait for popup to show"); jsterm.setInputValue("window.testBu"); - EventUtils.synthesizeKey("g", {}); + EventUtils.sendString("g"); }); return deferred.promise; } function popupHideAfterReturnWithNoSelection() { - ok(!popup.isOpen, "popup is not open after VK_RETURN"); + ok(!popup.isOpen, "popup is not open after KEY_Enter"); - is(jsterm.getInputValue(), "", "inputNode is empty after VK_RETURN"); + is(jsterm.getInputValue(), "", "inputNode is empty after KEY_Enter"); is(completeNode.value, "", "completeNode is empty"); is(jsterm.history[jsterm.history.length - 1], "window.testBug", "jsterm history is correct"); @@ -329,7 +328,7 @@ function testCompletionInText() { ok(popup.isOpen, "popup is open"); is(popup.itemCount, 2, "popup.itemCount is correct"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(popup.selectedIndex, 0, "popup.selectedIndex is correct"); ok(!completeNode.value, "completeNode.value is empty"); @@ -342,12 +341,12 @@ function testCompletionInText() { popup.once("popup-closed", function popupHidden() { deferred.resolve(); }); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); }); jsterm.setInputValue("dump(window.testBu)"); inputNode.selectionStart = inputNode.selectionEnd = 18; - EventUtils.synthesizeKey("g", {}); + EventUtils.sendString("g"); return deferred.promise; } @@ -355,7 +354,7 @@ function popupHideAfterCompletionInText() { // At this point the completion suggestion should be accepted. ok(!popup.isOpen, "popup is not open"); is(jsterm.getInputValue(), "dump(window.testBug873250b)", - "completion was successful after VK_TAB"); + "completion was successful after KEY_Tab"); is(inputNode.selectionStart, 26, "cursor location is correct"); is(inputNode.selectionStart, inputNode.selectionEnd, "cursor location (confirmed)"); diff --git a/devtools/client/webconsole/test/browser_webconsole_bug_588967_input_expansion.js b/devtools/client/webconsole/test/browser_webconsole_bug_588967_input_expansion.js index c590495c4a75..36a9db4c1813 100644 --- a/devtools/client/webconsole/test/browser_webconsole_bug_588967_input_expansion.js +++ b/devtools/client/webconsole/test/browser_webconsole_bug_588967_input_expansion.js @@ -32,12 +32,12 @@ function testInputExpansion(hud) { input.selectionStart = length; // Performs an "d". This will trigger/test for the input event that should // change the height of the inputNode. - EventUtils.synthesizeKey("d", {}); + EventUtils.sendString("d"); ok(input.clientHeight > ordinaryHeight, "the input expanded"); // Test if the inputNode shrinks again. input.value = ""; - EventUtils.synthesizeKey("d", {}); + EventUtils.sendString("d"); is(input.clientHeight, ordinaryHeight, "the input's height is normal again"); input = length = null; diff --git a/devtools/client/webconsole/test/browser_webconsole_bug_594497_history_arrow_keys.js b/devtools/client/webconsole/test/browser_webconsole_bug_594497_history_arrow_keys.js index 514f875c0c43..d9b127367b39 100644 --- a/devtools/client/webconsole/test/browser_webconsole_bug_594497_history_arrow_keys.js +++ b/devtools/client/webconsole/test/browser_webconsole_bug_594497_history_arrow_keys.js @@ -40,20 +40,20 @@ function setup(HUD) { } function performTests() { - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), values[4], - "VK_UP: jsterm.getInputValue() #4 is correct"); + "KEY_ArrowUp: jsterm.getInputValue() #4 is correct"); ok(inputNode.selectionStart == values[4].length && inputNode.selectionStart == inputNode.selectionEnd, "caret location is correct"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), values[3], - "VK_UP: jsterm.getInputValue() #3 is correct"); + "KEY_ArrowUp: jsterm.getInputValue() #3 is correct"); ok(inputNode.selectionStart == values[3].length && inputNode.selectionStart == inputNode.selectionEnd, @@ -61,62 +61,62 @@ function performTests() { inputNode.setSelectionRange(values[3].length - 2, values[3].length - 2); - EventUtils.synthesizeKey("VK_UP", {}); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), values[3], - "VK_UP two times: jsterm.getInputValue() #3 is correct"); + "KEY_ArrowUp two times: jsterm.getInputValue() #3 is correct"); ok(inputNode.selectionStart == jsterm.getInputValue().indexOf("\n") && inputNode.selectionStart == inputNode.selectionEnd, "caret location is correct"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), values[3], - "VK_UP again: jsterm.getInputValue() #3 is correct"); + "KEY_ArrowUp again: jsterm.getInputValue() #3 is correct"); ok(inputNode.selectionStart == 0 && inputNode.selectionStart == inputNode.selectionEnd, "caret location is correct"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), values[2], - "VK_UP: jsterm.getInputValue() #2 is correct"); + "KEY_ArrowUp: jsterm.getInputValue() #2 is correct"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), values[1], - "VK_UP: jsterm.getInputValue() #1 is correct"); + "KEY_ArrowUp: jsterm.getInputValue() #1 is correct"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), values[0], - "VK_UP: jsterm.getInputValue() #0 is correct"); + "KEY_ArrowUp: jsterm.getInputValue() #0 is correct"); ok(inputNode.selectionStart == values[0].length && inputNode.selectionStart == inputNode.selectionEnd, "caret location is correct"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), values[1], - "VK_DOWN: jsterm.getInputValue() #1 is correct"); + "KEY_ArrowDown: jsterm.getInputValue() #1 is correct"); ok(inputNode.selectionStart == values[1].length && inputNode.selectionStart == inputNode.selectionEnd, "caret location is correct"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), values[2], - "VK_DOWN: jsterm.getInputValue() #2 is correct"); + "KEY_ArrowDown: jsterm.getInputValue() #2 is correct"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), values[3], - "VK_DOWN: jsterm.getInputValue() #3 is correct"); + "KEY_ArrowDown: jsterm.getInputValue() #3 is correct"); ok(inputNode.selectionStart == values[3].length && inputNode.selectionStart == inputNode.selectionEnd, @@ -124,32 +124,32 @@ function performTests() { inputNode.setSelectionRange(2, 2); - EventUtils.synthesizeKey("VK_DOWN", {}); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), values[3], - "VK_DOWN two times: jsterm.getInputValue() #3 is correct"); + "KEY_ArrowDown two times: jsterm.getInputValue() #3 is correct"); ok(inputNode.selectionStart > jsterm.getInputValue().lastIndexOf("\n") && inputNode.selectionStart == inputNode.selectionEnd, "caret location is correct"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), values[3], - "VK_DOWN again: jsterm.getInputValue() #3 is correct"); + "KEY_ArrowDown again: jsterm.getInputValue() #3 is correct"); ok(inputNode.selectionStart == values[3].length && inputNode.selectionStart == inputNode.selectionEnd, "caret location is correct"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), values[4], - "VK_DOWN: jsterm.getInputValue() #4 is correct"); + "KEY_ArrowDown: jsterm.getInputValue() #4 is correct"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); ok(!jsterm.getInputValue(), - "VK_DOWN: jsterm.getInputValue() is empty"); + "KEY_ArrowDown: jsterm.getInputValue() is empty"); } diff --git a/devtools/client/webconsole/test/browser_webconsole_bug_613642_maintain_scroll.js b/devtools/client/webconsole/test/browser_webconsole_bug_613642_maintain_scroll.js index 67352e90a9d9..d637780af1c7 100644 --- a/devtools/client/webconsole/test/browser_webconsole_bug_613642_maintain_scroll.js +++ b/devtools/client/webconsole/test/browser_webconsole_bug_613642_maintain_scroll.js @@ -49,7 +49,7 @@ add_task(function* () { is(scrollBox.scrollTop, 0, "scroll location updated (moved to top)"); scrolled.resolve(); }; - EventUtils.synthesizeKey("VK_HOME", {}, hud.iframeWindow); + EventUtils.synthesizeKey("KEY_Home", {}, hud.iframeWindow); yield scrolled.promise; @@ -96,7 +96,7 @@ add_task(function* () { isnot(scrollBox.scrollTop, 0, "scroll location updated (moved to bottom)"); scrolled.resolve(); }; - EventUtils.synthesizeKey("VK_END", {}); + EventUtils.synthesizeKey("KEY_End"); yield scrolled.promise; let oldScrollTop = scrollBox.scrollTop; diff --git a/devtools/client/webconsole/test/browser_webconsole_bug_651501_document_body_autocomplete.js b/devtools/client/webconsole/test/browser_webconsole_bug_651501_document_body_autocomplete.js index 39cbe6d1f101..c36b69e4f3a0 100644 --- a/devtools/client/webconsole/test/browser_webconsole_bug_651501_document_body_autocomplete.js +++ b/devtools/client/webconsole/test/browser_webconsole_bug_651501_document_body_autocomplete.js @@ -48,11 +48,11 @@ function consoleOpened() { popup.once("popup-closed", () => { deferred.resolve(); }); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); }); jsterm.setInputValue("document.body"); - EventUtils.synthesizeKey(".", {}); + EventUtils.sendString("."); return deferred.promise; } @@ -73,7 +73,7 @@ function autocompletePopupHidden() { let inputStr = "document.b"; jsterm.setInputValue(inputStr); - EventUtils.synthesizeKey("o", {}); + EventUtils.sendString("o"); let testStr = inputStr.replace(/./g, " ") + " "; return deferred.promise; diff --git a/devtools/client/webconsole/test/browser_webconsole_bug_660806_history_nav.js b/devtools/client/webconsole/test/browser_webconsole_bug_660806_history_nav.js index bcf883f50727..0a3dc694e23d 100644 --- a/devtools/client/webconsole/test/browser_webconsole_bug_660806_history_nav.js +++ b/devtools/client/webconsole/test/browser_webconsole_bug_660806_history_nav.js @@ -39,8 +39,8 @@ function consoleOpened(HUD) { is(jsterm.lastInputValue, "window.foobarBug660806.location", "lastInputValue is correct"); - EventUtils.synthesizeKey("VK_RETURN", {}); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_Enter"); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.lastInputValue, "window.foobarBug660806.location", "lastInputValue is correct, again"); diff --git a/devtools/client/webconsole/test/browser_webconsole_bug_704295.js b/devtools/client/webconsole/test/browser_webconsole_bug_704295.js index df21232cf6d8..f0ef1e2a6e0b 100644 --- a/devtools/client/webconsole/test/browser_webconsole_bug_704295.js +++ b/devtools/client/webconsole/test/browser_webconsole_bug_704295.js @@ -24,18 +24,17 @@ function testCompletion(hud) { // Test typing 'var d = 5;' and press RETURN jsterm.setInputValue("var d = "); - EventUtils.synthesizeKey("5", {}); - EventUtils.synthesizeKey(";", {}); + EventUtils.sendString("5;"); is(input.value, "var d = 5;", "var d = 5;"); is(jsterm.completeNode.value, "", "no completion"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); is(jsterm.completeNode.value, "", "clear completion on execute()"); // Test typing 'var a = d' and press RETURN jsterm.setInputValue("var a = "); - EventUtils.synthesizeKey("d", {}); + EventUtils.sendString("d"); is(input.value, "var a = d", "var a = d"); is(jsterm.completeNode.value, "", "no completion"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); is(jsterm.completeNode.value, "", "clear completion on execute()"); } diff --git a/devtools/client/webconsole/test/browser_webconsole_bug_734061_No_input_change_and_Tab_key_pressed.js b/devtools/client/webconsole/test/browser_webconsole_bug_734061_No_input_change_and_Tab_key_pressed.js index af9e172c82c2..25b4de36ab70 100644 --- a/devtools/client/webconsole/test/browser_webconsole_bug_734061_No_input_change_and_Tab_key_pressed.js +++ b/devtools/client/webconsole/test/browser_webconsole_bug_734061_No_input_change_and_Tab_key_pressed.js @@ -17,19 +17,19 @@ add_task(function* () { let input = jsterm.inputNode; is(input.getAttribute("focused"), "true", "input has focus"); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_Tab"); is(input.getAttribute("focused"), "", "focus moved away"); // Test user changed something input.focus(); - EventUtils.synthesizeKey("A", {}); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.sendString("a"); + EventUtils.synthesizeKey("KEY_Tab"); is(input.getAttribute("focused"), "true", "input is still focused"); // Test non empty input but not changed since last focus input.blur(); input.focus(); - EventUtils.synthesizeKey("VK_RIGHT", {}); - EventUtils.synthesizeKey("VK_TAB", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); + EventUtils.synthesizeKey("KEY_Tab"); is(input.getAttribute("focused"), "", "input moved away"); }); diff --git a/devtools/client/webconsole/test/browser_webconsole_bug_804845_ctrl_key_nav.js b/devtools/client/webconsole/test/browser_webconsole_bug_804845_ctrl_key_nav.js index b040e63144e8..f2962554857d 100644 --- a/devtools/client/webconsole/test/browser_webconsole_bug_804845_ctrl_key_nav.js +++ b/devtools/client/webconsole/test/browser_webconsole_bug_804845_ctrl_key_nav.js @@ -36,52 +36,52 @@ function doTests(HUD) { function testSingleLineInputNavNoHistory() { // Single char input - EventUtils.synthesizeKey("1", {}); + EventUtils.sendString("1"); is(inputNode.selectionStart, 1, "caret location after single char input"); // nav to start/end with ctrl-a and ctrl-e; - EventUtils.synthesizeKey("a", { ctrlKey: true }); + EventUtils.synthesizeKey("a", {ctrlKey: true}); is(inputNode.selectionStart, 0, "caret location after single char input and ctrl-a"); - EventUtils.synthesizeKey("e", { ctrlKey: true }); + EventUtils.synthesizeKey("e", {ctrlKey: true}); is(inputNode.selectionStart, 1, "caret location after single char input and ctrl-e"); // Second char input - EventUtils.synthesizeKey("2", {}); + EventUtils.sendString("2"); // nav to start/end with up/down keys; verify behaviour using ctrl-p/ctrl-n - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(inputNode.selectionStart, 0, - "caret location after two char input and VK_UP"); - EventUtils.synthesizeKey("VK_DOWN", {}); + "caret location after two char input and KEY_ArrowUp"); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(inputNode.selectionStart, 2, - "caret location after two char input and VK_DOWN"); + "caret location after two char input and KEY_ArrowDown"); - EventUtils.synthesizeKey("a", { ctrlKey: true }); + EventUtils.synthesizeKey("a", {ctrlKey: true}); is(inputNode.selectionStart, 0, "move caret to beginning of 2 char input with ctrl-a"); - EventUtils.synthesizeKey("a", { ctrlKey: true }); + EventUtils.synthesizeKey("a", {ctrlKey: true}); is(inputNode.selectionStart, 0, "no change of caret location on repeat ctrl-a"); - EventUtils.synthesizeKey("p", { ctrlKey: true }); + EventUtils.synthesizeKey("p", {ctrlKey: true}); is(inputNode.selectionStart, 0, "no change of caret location on ctrl-p from beginning of line"); - EventUtils.synthesizeKey("e", { ctrlKey: true }); + EventUtils.synthesizeKey("e", {ctrlKey: true}); is(inputNode.selectionStart, 2, "move caret to end of 2 char input with ctrl-e"); - EventUtils.synthesizeKey("e", { ctrlKey: true }); + EventUtils.synthesizeKey("e", {ctrlKey: true}); is(inputNode.selectionStart, 2, "no change of caret location on repeat ctrl-e"); - EventUtils.synthesizeKey("n", { ctrlKey: true }); + EventUtils.synthesizeKey("n", {ctrlKey: true}); is(inputNode.selectionStart, 2, "no change of caret location on ctrl-n from end of line"); - EventUtils.synthesizeKey("p", { ctrlKey: true }); + EventUtils.synthesizeKey("p", {ctrlKey: true}); is(inputNode.selectionStart, 0, "ctrl-p moves to start of line"); - EventUtils.synthesizeKey("n", { ctrlKey: true }); + EventUtils.synthesizeKey("n", {ctrlKey: true}); is(inputNode.selectionStart, 2, "ctrl-n moves to end of line"); } @@ -91,7 +91,7 @@ function testMultiLineInputNavNoHistory() { // simulate shift-return for (let i = 0; i < lineValues.length; i++) { jsterm.setInputValue(jsterm.getInputValue() + lineValues[i]); - EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true }); + EventUtils.synthesizeKey("KEY_Enter", {shiftKey: true}); } let inputValue = jsterm.getInputValue(); is(inputNode.selectionStart, inputNode.selectionEnd); @@ -103,53 +103,53 @@ function testMultiLineInputNavNoHistory() { let newlineString = inputValue.match(/(\r\n?|\n\r?)$/)[0]; // Ok, test navigating within the multi-line string! - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); let expectedStringAfterCarat = lineValues[5] + newlineString; is(jsterm.getInputValue().slice(inputNode.selectionStart), expectedStringAfterCarat, "up arrow from end of multiline"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue().slice(inputNode.selectionStart), "", "down arrow from within multiline"); // navigate up through input lines - EventUtils.synthesizeKey("p", { ctrlKey: true }); + EventUtils.synthesizeKey("p", {ctrlKey: true}); is(jsterm.getInputValue().slice(inputNode.selectionStart), expectedStringAfterCarat, "ctrl-p from end of multiline"); for (let i = 4; i >= 0; i--) { - EventUtils.synthesizeKey("p", { ctrlKey: true }); + EventUtils.synthesizeKey("p", {ctrlKey: true}); expectedStringAfterCarat = lineValues[i] + newlineString + expectedStringAfterCarat; is(jsterm.getInputValue().slice(inputNode.selectionStart), expectedStringAfterCarat, "ctrl-p from within line " + i + " of multiline input"); } - EventUtils.synthesizeKey("p", { ctrlKey: true }); + EventUtils.synthesizeKey("p", {ctrlKey: true}); is(inputNode.selectionStart, 0, "reached start of input"); is(jsterm.getInputValue(), inputValue, "no change to multiline input on ctrl-p from beginning of multiline"); // navigate to end of first line - EventUtils.synthesizeKey("e", { ctrlKey: true }); + EventUtils.synthesizeKey("e", {ctrlKey: true}); let caretPos = inputNode.selectionStart; let expectedStringBeforeCarat = lineValues[0]; is(jsterm.getInputValue().slice(0, caretPos), expectedStringBeforeCarat, "ctrl-e into multiline input"); - EventUtils.synthesizeKey("e", { ctrlKey: true }); + EventUtils.synthesizeKey("e", {ctrlKey: true}); is(inputNode.selectionStart, caretPos, "repeat ctrl-e doesn't change caret position in multiline input"); // navigate down one line; ctrl-a to the beginning; ctrl-e to end for (let i = 1; i < lineValues.length; i++) { - EventUtils.synthesizeKey("n", { ctrlKey: true }); - EventUtils.synthesizeKey("a", { ctrlKey: true }); + EventUtils.synthesizeKey("n", {ctrlKey: true}); + EventUtils.synthesizeKey("a", {ctrlKey: true}); caretPos = inputNode.selectionStart; expectedStringBeforeCarat += newlineString; is(jsterm.getInputValue().slice(0, caretPos), expectedStringBeforeCarat, "ctrl-a to beginning of line " + (i + 1) + " in multiline input"); - EventUtils.synthesizeKey("e", { ctrlKey: true }); + EventUtils.synthesizeKey("e", {ctrlKey: true}); caretPos = inputNode.selectionStart; expectedStringBeforeCarat += lineValues[i]; is(jsterm.getInputValue().slice(0, caretPos), expectedStringBeforeCarat, @@ -171,7 +171,7 @@ function testNavWithHistory() { } is(inputNode.selectionStart, 0, "caret location at start of empty line"); - EventUtils.synthesizeKey("p", { ctrlKey: true }); + EventUtils.synthesizeKey("p", {ctrlKey: true}); is(inputNode.selectionStart, values[values.length - 1].length, "caret location correct at end of last history input"); @@ -180,20 +180,20 @@ function testNavWithHistory() { let match = values[i].match(/(\n)/g); if (match) { // multi-line inputs won't update from history unless caret at beginning - EventUtils.synthesizeKey("a", { ctrlKey: true }); + EventUtils.synthesizeKey("a", {ctrlKey: true}); for (let j = 0; j < match.length; j++) { - EventUtils.synthesizeKey("p", { ctrlKey: true }); + EventUtils.synthesizeKey("p", {ctrlKey: true}); } - EventUtils.synthesizeKey("p", { ctrlKey: true }); + EventUtils.synthesizeKey("p", {ctrlKey: true}); } else { // single-line inputs will update from history from end of line - EventUtils.synthesizeKey("p", { ctrlKey: true }); + EventUtils.synthesizeKey("p", {ctrlKey: true}); } is(jsterm.getInputValue(), values[i - 1], "ctrl-p updates inputNode from backwards history values[" + i - 1 + "]"); } let inputValue = jsterm.getInputValue(); - EventUtils.synthesizeKey("p", { ctrlKey: true }); + EventUtils.synthesizeKey("p", {ctrlKey: true}); is(inputNode.selectionStart, 0, "ctrl-p at beginning of history moves caret location to beginning " + "of line"); @@ -202,13 +202,13 @@ function testNavWithHistory() { // Navigate forwards history with ctrl-n for (let i = 1; i < values.length; i++) { - EventUtils.synthesizeKey("n", { ctrlKey: true }); + EventUtils.synthesizeKey("n", {ctrlKey: true}); is(jsterm.getInputValue(), values[i], "ctrl-n updates inputNode from forwards history values[" + i + "]"); is(inputNode.selectionStart, values[i].length, "caret location correct at end of history input for values[" + i + "]"); } - EventUtils.synthesizeKey("n", { ctrlKey: true }); + EventUtils.synthesizeKey("n", {ctrlKey: true}); ok(!jsterm.getInputValue(), "ctrl-n at end of history updates to empty input"); // Simulate editing multi-line @@ -216,12 +216,12 @@ function testNavWithHistory() { jsterm.setInputValue(inputValue); // Attempt nav within input - EventUtils.synthesizeKey("p", { ctrlKey: true }); + EventUtils.synthesizeKey("p", {ctrlKey: true}); is(jsterm.getInputValue(), inputValue, "ctrl-p from end of multi-line does not trigger history"); - EventUtils.synthesizeKey("a", { ctrlKey: true }); - EventUtils.synthesizeKey("p", { ctrlKey: true }); + EventUtils.synthesizeKey("a", {ctrlKey: true}); + EventUtils.synthesizeKey("p", {ctrlKey: true}); is(jsterm.getInputValue(), values[values.length - 1], "ctrl-p from start of multi-line triggers history"); } diff --git a/devtools/client/webconsole/test/browser_webconsole_bug_817834_add_edited_input_to_history.js b/devtools/client/webconsole/test/browser_webconsole_bug_817834_add_edited_input_to_history.js index ccbcb3bf3031..ad8be27e05a7 100644 --- a/devtools/client/webconsole/test/browser_webconsole_bug_817834_add_edited_input_to_history.js +++ b/devtools/client/webconsole/test/browser_webconsole_bug_817834_add_edited_input_to_history.js @@ -27,31 +27,31 @@ function testEditedInputHistory(HUD) { is(inputNode.selectionEnd, 0); jsterm.setInputValue('"first item"'); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), '"first item"', "null test history up"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), '"first item"', "null test history down"); jsterm.execute(); is(jsterm.getInputValue(), "", "cleared input line after submit"); jsterm.setInputValue('"editing input 1"'); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), '"first item"', "test history up"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), '"editing input 1"', "test history down restores in-progress input"); jsterm.setInputValue('"second item"'); jsterm.execute(); jsterm.setInputValue('"editing input 2"'); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), '"second item"', "test history up"); - EventUtils.synthesizeKey("VK_UP", {}); + EventUtils.synthesizeKey("KEY_ArrowUp"); is(jsterm.getInputValue(), '"first item"', "test history up"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), '"second item"', "test history down"); - EventUtils.synthesizeKey("VK_DOWN", {}); + EventUtils.synthesizeKey("KEY_ArrowDown"); is(jsterm.getInputValue(), '"editing input 2"', "test history down restores new in-progress input again"); } diff --git a/devtools/client/webconsole/test/browser_webconsole_js_input_expansion.js b/devtools/client/webconsole/test/browser_webconsole_js_input_expansion.js index 7d45059fc740..de8c53b2852a 100644 --- a/devtools/client/webconsole/test/browser_webconsole_js_input_expansion.js +++ b/devtools/client/webconsole/test/browser_webconsole_js_input_expansion.js @@ -30,7 +30,7 @@ add_task(function* () { let initialHeight = getHeight(); // Performs an "d". This will trigger/test for the input event that should // change the "row" attribute of the inputNode. - EventUtils.synthesizeKey("d", {}); + EventUtils.sendString("d"); let newHeight = getHeight(); ok(initialHeight < newHeight, "Height changed: " + newHeight); @@ -39,14 +39,14 @@ add_task(function* () { length = input.value.length; input.selectionEnd = length; input.selectionStart = length; - EventUtils.synthesizeKey("d", {}); + EventUtils.sendString("d"); let newerHeight = getHeight(); ok(newerHeight > newHeight, "height changed: " + newerHeight); // Test if the inputNode shrinks again. input.value = ""; - EventUtils.synthesizeKey("d", {}); + EventUtils.sendString("d"); let height = getHeight(); info("height: " + height); info("initialHeight: " + initialHeight); diff --git a/docshell/test/browser/browser_uriFixupIntegration.js b/docshell/test/browser/browser_uriFixupIntegration.js index 469c9028f3f8..d7c6289f8f6f 100644 --- a/docshell/test/browser/browser_uriFixupIntegration.js +++ b/docshell/test/browser/browser_uriFixupIntegration.js @@ -36,7 +36,7 @@ add_task(async function test() { // Enter search terms and start a search. gURLBar.value = searchParams; gURLBar.focus(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); // Check that we arrived at the correct URL. diff --git a/dom/events/test/bug299673.js b/dom/events/test/bug299673.js index f426ffda3435..a3eb7ecc0f34 100644 --- a/dom/events/test/bug299673.js +++ b/dom/events/test/bug299673.js @@ -83,8 +83,8 @@ function doTest1(expectedEventLog,focusAfterCloseId) { var select1 = document.getElementById('Select1'); select1.focus(); is(document.activeElement, select1, "select element should be focused"); - synthesizeKey("VK_DOWN",{}); - synthesizeKey("VK_TAB", {}); + synthesizeKey("KEY_ArrowDown"); + synthesizeKey("KEY_Tab"); SimpleTest.waitForFocus(function () { doTest1_rest1(expectedEventLog,focusAfterCloseId); }, popup); } catch(e) { diff --git a/dom/events/test/test_bug1305458.html b/dom/events/test/test_bug1305458.html index 0993f88f043f..37dbe35d78f0 100644 --- a/dom/events/test/test_bug1305458.html +++ b/dom/events/test/test_bug1305458.html @@ -34,13 +34,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1305458 // mouse hover input.focus(); synthesizeMouse(input, 1, 1, {type: "mousemove"}); - synthesizeKey("1", {}); + sendString("1"); input.blur(); is(change_count, 1, "input should fire change when blur"); input.focus(); synthesizeMouse(div, 1, 1, {type: "mousemove"}); - synthesizeKey("1", {}); + sendString("1"); input.blur(); is(change_count, 2, "input should fire change when blur"); SimpleTest.finish(); diff --git a/dom/events/test/test_bug450876.html b/dom/events/test/test_bug450876.html index e6641a753118..30319145adf6 100644 --- a/dom/events/test/test_bug450876.html +++ b/dom/events/test/test_bug450876.html @@ -25,7 +25,7 @@ function doTest() { document.getElementById('a').focus(); is(document.activeElement, document.getElementById('a'), "link should have focus"); is(document.hasFocus(), true, "document should be focused"); - synthesizeKey("KEY_Tab", {}); + synthesizeKey("KEY_Tab"); is(document.activeElement, document.getElementById('a'), "body element should be focused"); is(document.hasFocus(), false, "document should not be focused"); diff --git a/dom/events/test/test_dom_keyboard_event.html b/dom/events/test/test_dom_keyboard_event.html index 5b00e67e8ec4..c6133c033d1b 100644 --- a/dom/events/test/test_dom_keyboard_event.html +++ b/dom/events/test/test_dom_keyboard_event.html @@ -419,7 +419,7 @@ function testEnterKeyPressEvent() target.focus(); reset(); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); is(keydownFired, true, kDescription + "keydown event should be fired when Enter key is pressed"); is(keypressFired, true, diff --git a/dom/events/test/window_bug1369072.html b/dom/events/test/window_bug1369072.html index dc7e874cb8b9..f06b44b13d25 100644 --- a/dom/events/test/window_bug1369072.html +++ b/dom/events/test/window_bug1369072.html @@ -84,9 +84,9 @@ async function runTests() iframe.contentWindow.addEventListener("scroll", onScroll, { once: true }); if (aVertical) { - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); } else { - synthesizeKey("KEY_ArrowRight", {}); + synthesizeKey("KEY_ArrowRight"); } }); } diff --git a/dom/html/test/browser_fullscreen-api-keys.js b/dom/html/test/browser_fullscreen-api-keys.js index 6a953c250293..198fd8961c54 100644 --- a/dom/html/test/browser_fullscreen-api-keys.js +++ b/dom/html/test/browser_fullscreen-api-keys.js @@ -4,8 +4,8 @@ // List of key codes which should exit full-screen mode. const kKeyList = [ - { code: "VK_ESCAPE", suppressed: true}, - { code: "VK_F11", suppressed: false}, + { key: "Escape", keyCode: "VK_ESCAPE", suppressed: true}, + { key: "F11", keyCode: "VK_F11", suppressed: false}, ]; const kStrictKeyPressEvents = @@ -136,9 +136,9 @@ add_task(async function() { "Test:KeyReceived", captureUnexpectedKeyEvent); }); - for (let {code, suppressed} of kKeyList) { - var keyCode = KeyEvent["DOM_" + code]; - info(`Test keycode ${code} (${keyCode})`); + for (let {key, keyCode, suppressed} of kKeyList) { + let keyCodeValue = KeyEvent["DOM_" + keyCode]; + info(`Test keycode ${key} (${keyCodeValue})`); info("Enter fullscreen"); await temporaryRemoveUnexpectedFullscreenChangeCapture(async function() { @@ -151,8 +151,8 @@ add_task(async function() { info("Dispatch untrusted key events from content"); await temporaryRemoveUnexpectedKeyEventCapture(async function() { - let promiseExpectedKeyEvents = receiveExpectedKeyEvents(keyCode, false); - gMessageManager.sendAsyncMessage("Test:DispatchUntrustedKeyEvents", code); + let promiseExpectedKeyEvents = receiveExpectedKeyEvents(keyCodeValue, false); + gMessageManager.sendAsyncMessage("Test:DispatchUntrustedKeyEvents", keyCode); await promiseExpectedKeyEvents; }); @@ -160,8 +160,8 @@ add_task(async function() { await temporaryRemoveUnexpectedFullscreenChangeCapture(async function() { await temporaryRemoveUnexpectedKeyEventCapture(async function() { let promiseExpectedKeyEvents = suppressed ? - Promise.resolve() : receiveExpectedKeyEvents(keyCode, true); - EventUtils.synthesizeKey(code, {}); + Promise.resolve() : receiveExpectedKeyEvents(keyCodeValue, true); + EventUtils.synthesizeKey("KEY_" + key); await promiseExpectedKeyEvents; let state = await promiseOneMessage("Test:FullscreenChanged"); ok(!state, "The content should have exited fullscreen"); diff --git a/dom/html/test/browser_fullscreen-contextmenu-esc.js b/dom/html/test/browser_fullscreen-contextmenu-esc.js index f5d108e58837..8ea45a62186f 100644 --- a/dom/html/test/browser_fullscreen-contextmenu-esc.js +++ b/dom/html/test/browser_fullscreen-contextmenu-esc.js @@ -84,7 +84,7 @@ add_task(async function() { info("Send the first escape"); let popupHidePromise = promiseWaitForEvent(window, "popuphidden"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); await popupHidePromise; is(contextMenu.state, "closed", "Should have closed context menu"); @@ -100,7 +100,7 @@ add_task(async function() { gMessageManager.removeMessageListener( "Test:FullscreenChanged", captureUnexpectedFullscreenChange); let fullscreenExitPromise = promiseOneMessage("Test:FullscreenChanged"); - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); state = await fullscreenExitPromise; ok(!state, "The content should have exited fullscreen"); ok(!document.fullscreenElement, "The chrome should have exited fullscreen"); diff --git a/dom/html/test/file_fullscreen-denied.html b/dom/html/test/file_fullscreen-denied.html index 322723083a53..50c1ceceb340 100644 --- a/dom/html/test/file_fullscreen-denied.html +++ b/dom/html/test/file_fullscreen-denied.html @@ -117,7 +117,7 @@ function testLongRunningEventHandler() { SpecialPowers.popPrefEnv(finish); }); window.addEventListener("keypress", longRunningHandler); - synthesizeKey("VK_A", {}); + sendString("a"); } function finish() { diff --git a/dom/html/test/file_fullscreen-esc-exit-inner.html b/dom/html/test/file_fullscreen-esc-exit-inner.html index 9836558f0986..2b0aea96368e 100644 --- a/dom/html/test/file_fullscreen-esc-exit-inner.html +++ b/dom/html/test/file_fullscreen-esc-exit-inner.html @@ -48,7 +48,7 @@ function startTest() { ok(parent.document.fullscreenElement, "Parent should be in full-screen mode"); escKeySent = true; window.focus(); - synthesizeKey("VK_ESCAPE", {}); + synthesizeKey("KEY_Escape"); } diff --git a/dom/html/test/file_fullscreen-selector.html b/dom/html/test/file_fullscreen-selector.html index 9aceb659e51d..fb8d1ce19fd2 100644 --- a/dom/html/test/file_fullscreen-selector.html +++ b/dom/html/test/file_fullscreen-selector.html @@ -158,7 +158,7 @@ function enterAll() { checkFullscreenStates([true, true, true]); info("Fully-exiting fullscreen"); addFullscreenChangeContinuation("exit", exitAll); - synthesizeKey("VK_ESCAPE", {}); + synthesizeKey("KEY_Escape"); } function exitAll() { diff --git a/dom/html/test/forms/test_bug1283915.html b/dom/html/test/forms/test_bug1283915.html index 0b0ac5f13a47..6ca1b401c2b6 100644 --- a/dom/html/test/forms/test_bug1283915.html +++ b/dom/html/test/forms/test_bug1283915.html @@ -24,30 +24,30 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1283915 var tField = document.getElementById("textField"); tField.focus(); - synthesizeKey("a", {}); + sendString("a"); is(tField.value, "a"); isCursorAtEnd(tField); document.body.offsetWidth; // frame must be created after type change - synthesizeKey("b", {}); + sendString("b"); is(tField.value, "ab"); isCursorAtEnd(tField); - synthesizeKey("c", {}); + sendString("c"); is(tField.value, "abc"); isCursorAtEnd(tField); var nField = document.getElementById("numField"); nField.focus(); - synthesizeKey("1", {}); + sendString("1"); is(nField.value, "1"); document.body.offsetWidth; - synthesizeKey("2", {}); + sendString("2"); is(nField.value, "12"); - synthesizeKey("3", {}); + sendString("3"); is(nField.value, "123"); SimpleTest.finish(); diff --git a/dom/html/test/forms/test_bug1286509.html b/dom/html/test/forms/test_bug1286509.html index 380699da6019..1ea4bf27a49b 100644 --- a/dom/html/test/forms/test_bug1286509.html +++ b/dom/html/test/forms/test_bug1286509.html @@ -35,10 +35,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1286509 expectedEventIdx = (expectedEventIdx + 1) % 3; }); }); - synthesizeKey("VK_UP", {}); - synthesizeKey("VK_DOWN", {}); - synthesizeKey("VK_LEFT", {}); - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowUp"); + synthesizeKey("KEY_ArrowDown"); + synthesizeKey("KEY_ArrowLeft"); + synthesizeKey("KEY_ArrowRight"); is(eventCounts['change'], 4, "Expect key up/down/left/right should trigger range input to fire change events"); SimpleTest.finish(); } diff --git a/dom/html/test/forms/test_change_event.html b/dom/html/test/forms/test_change_event.html index 9ba9526a2932..ca4f0d7be06d 100644 --- a/dom/html/test/forms/test_change_event.html +++ b/dom/html/test/forms/test_change_event.html @@ -104,18 +104,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=722599 for (var i = 0; i < textInputTypes.length; ++i) { input = document.getElementById("input_" + textInputTypes[i]); input.focus(); - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); is(textInputChange[i], 0, "Change event shouldn't be dispatched on " + textInputTypes[i] + " input element"); - synthesizeKey("m", {}); - synthesizeKey("VK_RETURN", {}); + sendString("m"); + synthesizeKey("KEY_Enter"); is(textInputChange[i], 1, textInputTypes[i] + " input element should have dispatched change event."); } //focus and blur text input input = document.getElementById("input_text"); input.focus(); - synthesizeKey("f", {}); + sendString("f"); input.blur(); is(textInputChange[0], 2, "text input element should have dispatched change event (2)."); @@ -127,7 +127,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=722599 // value being set while focused after being modified manually input.focus(); - synthesizeKey("f", {}); + sendString("f"); input.value = 'bar'; input.blur(); is(textInputChange[0], 3, "text input element should have dispatched change event (3)."); @@ -135,7 +135,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=722599 //focus and blur textarea var textarea = document.getElementById("textarea"); textarea.focus(); - synthesizeKey("f", {}); + sendString("f"); textarea.blur(); is(textareaChange, 1, "Textarea element should have dispatched change event."); @@ -147,7 +147,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=722599 // value being set while focused after being modified manually textarea.focus(); - synthesizeKey("f", {}); + sendString("f"); textarea.value = 'bar'; textarea.blur(); is(textareaChange, 2, "textearea should have dispatched change event (2)."); @@ -186,13 +186,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=722599 // Special case type=number var number = document.getElementById("input_number"); number.focus(); - synthesizeKey("a", {}); + sendString("a"); number.blur(); is(numberChange, 0, "Change event shouldn't be dispatched on number input element for key changes that don't change its value"); number.value = ""; number.focus(); - synthesizeKey("1", {}); - synthesizeKey("2", {}); + sendString("12"); is(numberChange, 0, "Change event shouldn't be dispatched on number input element for keyboard input until it loses focus"); number.blur(); is(numberChange, 1, "Change event should be dispatched on number input element on blur"); @@ -200,9 +199,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=722599 if (isDesktop) { // up/down arrow keys not supported on android/b2g number.value = ""; number.focus(); - synthesizeKey("VK_UP", {}); - synthesizeKey("VK_UP", {}); - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowUp"); + synthesizeKey("KEY_ArrowUp"); + synthesizeKey("KEY_ArrowDown"); is(numberChange, 4, "Change event should be dispatched on number input element for up/down arrow keys (a special case)"); is(number.value, "1", "Sanity check that number and arrow keys were actually handled"); } @@ -210,11 +209,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=722599 // Special case type=range var range = document.getElementById("input_range"); range.focus(); - synthesizeKey("a", {}); + sendString("a"); range.blur(); is(rangeChange, 0, "Change event shouldn't be dispatched on range input element for key changes that don't change its value"); range.focus(); - synthesizeKey("VK_HOME", {}); + synthesizeKey("VK_HOME"); is(rangeChange, 1, "Change event should be dispatched on range input element for key changes"); range.blur(); is(rangeChange, 1, "Change event shouldn't be dispatched on range input element on blur"); @@ -234,30 +233,30 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=722599 is(rangeChange, 3, "Change event should be dispatched on range input element for a click that gives the range focus"); if (isDesktop) { // up/down arrow keys not supported on android/b2g - synthesizeKey("VK_UP", {}); - is(rangeChange, 4, "Change event should be dispatched on range input element for key changes that change its value (VK_UP)"); - synthesizeKey("VK_DOWN", {}); - is(rangeChange, 5, "Change event should be dispatched on range input element for key changes that change its value (VK_DOWN)"); - synthesizeKey("VK_RIGHT", {}); - is(rangeChange, 6, "Change event should be dispatched on range input element for key changes that change its value (VK_RIGHT)"); - synthesizeKey("VK_LEFT", {}); - is(rangeChange, 7, "Change event should be dispatched on range input element for key changes that change its value (VK_LEFT)"); - synthesizeKey("VK_UP", {shiftKey: true}); - is(rangeChange, 8, "Change event should be dispatched on range input element for key changes that change its value (Shift+VK_UP)"); - synthesizeKey("VK_DOWN", {shiftKey: true}); - is(rangeChange, 9, "Change event should be dispatched on range input element for key changes that change its value (Shift+VK_DOWN)"); - synthesizeKey("VK_RIGHT", {shiftKey: true}); - is(rangeChange, 10, "Change event should be dispatched on range input element for key changes that change its value (Shift+VK_RIGHT)"); - synthesizeKey("VK_LEFT", {shiftKey: true}); - is(rangeChange, 11, "Change event should be dispatched on range input element for key changes that change its value (Shift+VK_LEFT)"); - synthesizeKey("VK_PAGE_UP", {}); - is(rangeChange, 12, "Change event should be dispatched on range input element for key changes that change its value (VK_PAGE_UP)"); - synthesizeKey("VK_PAGE_DOWN", {}); - is(rangeChange, 13, "Change event should be dispatched on range input element for key changes that change its value (VK_PAGE_DOWN"); - synthesizeKey("VK_RIGHT", {shiftKey: true}); - is(rangeChange, 14, "Change event should be dispatched on range input element for key changes that change its value (Shift+VK_PAGE_UP)"); - synthesizeKey("VK_LEFT", {shiftKey: true}); - is(rangeChange, 15, "Change event should be dispatched on range input element for key changes that change its value (Shift+VK_PAGE_DOWN)"); + synthesizeKey("KEY_ArrowUp"); + is(rangeChange, 4, "Change event should be dispatched on range input element for key changes that change its value (KEY_ArrowUp)"); + synthesizeKey("KEY_ArrowDown"); + is(rangeChange, 5, "Change event should be dispatched on range input element for key changes that change its value (KEY_ArrowDown)"); + synthesizeKey("KEY_ArrowRight"); + is(rangeChange, 6, "Change event should be dispatched on range input element for key changes that change its value (KEY_ArrowRight)"); + synthesizeKey("KEY_ArrowLeft"); + is(rangeChange, 7, "Change event should be dispatched on range input element for key changes that change its value (KEY_ArrowLeft)"); + synthesizeKey("KEY_ArrowUp", {shiftKey: true}); + is(rangeChange, 8, "Change event should be dispatched on range input element for key changes that change its value (Shift+KEY_ArrowUp)"); + synthesizeKey("KEY_ArrowDown", {shiftKey: true}); + is(rangeChange, 9, "Change event should be dispatched on range input element for key changes that change its value (Shift+KEY_ArrowDown)"); + synthesizeKey("KEY_ArrowRight", {shiftKey: true}); + is(rangeChange, 10, "Change event should be dispatched on range input element for key changes that change its value (Shift+KEY_ArrowRight)"); + synthesizeKey("KEY_ArrowLeft", {shiftKey: true}); + is(rangeChange, 11, "Change event should be dispatched on range input element for key changes that change its value (Shift+KEY_ArrowLeft)"); + synthesizeKey("KEY_PageUp"); + is(rangeChange, 12, "Change event should be dispatched on range input element for key changes that change its value (KEY_PageUp)"); + synthesizeKey("KEY_PageDown"); + is(rangeChange, 13, "Change event should be dispatched on range input element for key changes that change its value (KEY_PageDown"); + synthesizeKey("KEY_ArrowRight", {shiftKey: true}); + is(rangeChange, 14, "Change event should be dispatched on range input element for key changes that change its value (Shift+KEY_PageUp)"); + synthesizeKey("KEY_ArrowLeft", {shiftKey: true}); + is(rangeChange, 15, "Change event should be dispatched on range input element for key changes that change its value (Shift+KEY_PageDown)"); } //Input type change test. input = document.getElementById("input_checkbox"); diff --git a/dom/html/test/forms/test_formaction_attribute.html b/dom/html/test/forms/test_formaction_attribute.html index b6ca592c5baf..00f9ce3b328f 100644 --- a/dom/html/test/forms/test_formaction_attribute.html +++ b/dom/html/test/forms/test_formaction_attribute.html @@ -132,22 +132,22 @@ function runTests() }, {once: true}); document.getElementById('is2').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); document.getElementById('ii2').focus(); }, {once: true}); document.getElementById('ii2').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); document.getElementById('bs2').focus(); }, {once: true}); document.getElementById('bs2').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); document.getElementById('enter').focus(); }, {once: true}); document.getElementById('enter').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); }, {once: true}); document.getElementById('is').focus(); diff --git a/dom/html/test/forms/test_formnovalidate_attribute.html b/dom/html/test/forms/test_formnovalidate_attribute.html index 183674dffa76..2d4c2b4c3132 100644 --- a/dom/html/test/forms/test_formnovalidate_attribute.html +++ b/dom/html/test/forms/test_formnovalidate_attribute.html @@ -73,7 +73,7 @@ if (observers.hasMoreElements()) { "control used for the submission"); var c = document.getElementById('c'); c.focus(); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); }); document.getElementById('c').addEventListener("invalid", function(aEvent) { diff --git a/dom/html/test/forms/test_input_date_bad_input.html b/dom/html/test/forms/test_input_date_bad_input.html index 60e4a1d10fe0..03ceda08eb14 100644 --- a/dom/html/test/forms/test_input_date_bad_input.html +++ b/dom/html/test/forms/test_input_date_bad_input.html @@ -53,8 +53,8 @@ function checkValidity(aElement, aIsBadInput) { } function sendKeys(aKey) { - if (aKey.startsWith("VK")) { - synthesizeKey(aKey, {}); + if (aKey.startsWith("KEY_")) { + synthesizeKey(aKey); } else { sendString(aKey); } @@ -85,7 +85,7 @@ function test() { // Removing any of the fields makes the input valid again. elem.focus(); - sendKeys("VK_BACK_SPACE"); + sendKeys("KEY_Backspace"); elem.blur(); checkValidity(elem, false); diff --git a/dom/html/test/forms/test_input_date_key_events.html b/dom/html/test/forms/test_input_date_key_events.html index f502d6a4d661..f94a49ccf17a 100644 --- a/dom/html/test/forms/test_input_date_key_events.html +++ b/dom/html/test/forms/test_input_date_key_events.html @@ -89,109 +89,109 @@ var testData = [ }, { // Advance to year field and decrement. - keys: ["VK_TAB", "VK_TAB", "VK_DOWN"], + keys: ["KEY_Tab", "KEY_Tab", "KEY_ArrowDown"], initialVal: "2016-11-25", expectedVal: "2015-11-25" }, { // Right key should do the same thing as TAB key. - keys: ["VK_RIGHT", "VK_RIGHT", "VK_DOWN"], + keys: ["KEY_ArrowRight", "KEY_ArrowRight", "KEY_ArrowDown"], initialVal: "2016-11-25", expectedVal: "2015-11-25" }, { // Advance to day field then back to month field and decrement. - keys: ["VK_RIGHT", "VK_LEFT", "VK_DOWN"], + keys: ["KEY_ArrowRight", "KEY_ArrowLeft", "KEY_ArrowDown"], initialVal: "2000-05-01", expectedVal: "2000-04-01" }, { // Focus starts on the first field, month in this case, and increment. - keys: ["VK_UP"], + keys: ["KEY_ArrowUp"], initialVal: "2000-03-01", expectedVal: "2000-04-01" }, { // Advance to day field and decrement. - keys: ["VK_TAB", "VK_DOWN"], + keys: ["KEY_Tab", "KEY_ArrowDown"], initialVal: "1234-01-01", expectedVal: "1234-01-31" }, { // Advance to day field and increment. - keys: ["VK_TAB", "VK_UP"], + keys: ["KEY_Tab", "KEY_ArrowUp"], initialVal: "1234-01-01", expectedVal: "1234-01-02" }, { // PageUp on month field increments month by 3. - keys: ["VK_PAGE_UP"], + keys: ["KEY_PageUp"], initialVal: "1999-01-01", expectedVal: "1999-04-01" }, { // PageDown on month field decrements month by 3. - keys: ["VK_PAGE_DOWN"], + keys: ["KEY_PageDown"], initialVal: "1999-01-01", expectedVal: "1999-10-01" }, { // PageUp on day field increments day by 7. - keys: ["VK_TAB", "VK_PAGE_UP"], + keys: ["KEY_Tab", "KEY_PageUp"], initialVal: "1999-01-01", expectedVal: "1999-01-08" }, { // PageDown on day field decrements day by 7. - keys: ["VK_TAB", "VK_PAGE_DOWN"], + keys: ["KEY_Tab", "KEY_PageDown"], initialVal: "1999-01-01", expectedVal: "1999-01-25" }, { // PageUp on year field increments year by 10. - keys: ["VK_TAB", "VK_TAB", "VK_PAGE_UP"], + keys: ["KEY_Tab", "KEY_Tab", "KEY_PageUp"], initialVal: "1999-01-01", expectedVal: "2009-01-01" }, { // PageDown on year field decrements year by 10. - keys: ["VK_TAB", "VK_TAB", "VK_PAGE_DOWN"], + keys: ["KEY_Tab", "KEY_Tab", "KEY_PageDown"], initialVal: "1999-01-01", expectedVal: "1989-01-01" }, { // Home key on month field sets it to the minimum month, which is 01. - keys: ["VK_HOME"], + keys: ["KEY_Home"], initialVal: "2016-06-01", expectedVal: "2016-01-01" }, { // End key on month field sets it to the maximum month, which is 12. - keys: ["VK_END"], + keys: ["KEY_End"], initialVal: "2016-06-01", expectedVal: "2016-12-01" }, { // Home key on day field sets it to the minimum day, which is 01. - keys: ["VK_TAB", "VK_HOME"], + keys: ["KEY_Tab", "KEY_Home"], initialVal: "2016-01-10", expectedVal: "2016-01-01" }, { // End key on day field sets it to the maximum day, which is 31. - keys: ["VK_TAB", "VK_END"], + keys: ["KEY_Tab", "KEY_End"], initialVal: "2016-01-10", expectedVal: "2016-01-31" }, { // Home key should have no effect on year field. - keys: ["VK_TAB", "VK_TAB", "VK_HOME"], + keys: ["KEY_Tab", "KEY_Tab", "KEY_Home"], initialVal: "2016-01-01", expectedVal: "2016-01-01" }, { // End key should have no effect on year field. - keys: ["VK_TAB", "VK_TAB", "VK_END"], + keys: ["KEY_Tab", "KEY_Tab", "KEY_End"], initialVal: "2016-01-01", expectedVal: "2016-01-01" }, @@ -200,8 +200,8 @@ var testData = [ function sendKeys(aKeys) { for (let i = 0; i < aKeys.length; i++) { let key = aKeys[i]; - if (key.startsWith("VK")) { - synthesizeKey(key, {}); + if (key.startsWith("KEY_")) { + synthesizeKey(key); } else { sendString(key); } diff --git a/dom/html/test/forms/test_input_datetime_focus_blur_events.html b/dom/html/test/forms/test_input_datetime_focus_blur_events.html index 873dda627d09..8a3beac2282a 100644 --- a/dom/html/test/forms/test_input_datetime_focus_blur_events.html +++ b/dom/html/test/forms/test_input_datetime_focus_blur_events.html @@ -52,25 +52,25 @@ function test() { is(blurEvents[i], 0, inputTypes[i] + " input element should not have dispatched blur event."); // Move around inside the input element's input box. - synthesizeKey("VK_TAB", {}); + synthesizeKey("KEY_Tab"); is(focusEvents[i], 1, inputTypes[i] + " input element should not have dispatched focus event."); is(focusInEvents[i], 1, inputTypes[i] + " input element should not have dispatched focusin event."); is(focusOutEvents[i], 0, inputTypes[i] + " input element should not have dispatched focusout event."); is(blurEvents[i], 0, inputTypes[i] + " time input element should not have dispatched blur event."); - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowRight"); is(focusEvents[i], 1, inputTypes[i] + " input element should not have dispatched focus event."); is(focusInEvents[i], 1, inputTypes[i] + " input element should not have dispatched focusin event."); is(focusOutEvents[i], 0, inputTypes[i] + " input element should not have dispatched focusout event."); is(blurEvents[i], 0, inputTypes[i] + " input element should not have dispatched blur event."); - synthesizeKey("VK_LEFT", {}); + synthesizeKey("KEY_ArrowLeft"); is(focusEvents[i], 1,inputTypes[i] + " input element should not have dispatched focus event."); is(focusInEvents[i], 1, inputTypes[i] + " input element should not have dispatched focusin event."); is(focusOutEvents[i], 0, inputTypes[i] + " input element should not have dispatched focusout event."); is(blurEvents[i], 0, inputTypes[i] + " input element should not have dispatched blur event."); - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowRight"); is(focusEvents[i], 1, inputTypes[i] + " input element should not have dispatched focus event."); is(focusInEvents[i], 1, inputTypes[i] + " input element should not have dispatched focusin event."); is(focusOutEvents[i], 0, inputTypes[i] + " input element should not have dispatched focusout event."); diff --git a/dom/html/test/forms/test_input_datetime_input_change_events.html b/dom/html/test/forms/test_input_datetime_input_change_events.html index 4ab02444dda5..8f4aec4bcfa8 100644 --- a/dom/html/test/forms/test_input_datetime_input_change_events.html +++ b/dom/html/test/forms/test_input_datetime_input_change_events.html @@ -62,15 +62,14 @@ function test() { // Test that change and input events are fired when changing the value using // up/down keys. input.focus(); - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); is(input.value, expectedValues[i][0], "Check that value was set correctly (1)."); is(changeEvents[i], 1, "Change event should be dispatched (1)."); is(inputEvents[i], 1, "Input event should ne dispatched (1)."); // Test that change and input events are fired when changing the value with // the keyboard. - synthesizeKey("0", {}); - synthesizeKey("1", {}); + sendString("01"); is(input.value, expectedValues[i][1], "Check that value was set correctly (2)."); is(changeEvents[i], 2, "Change event should be dispatched (2)."); is(inputEvents[i], 2, "Input event should be dispatched (2)."); diff --git a/dom/html/test/forms/test_input_datetime_tabindex.html b/dom/html/test/forms/test_input_datetime_tabindex.html index 8023ccf9be6d..26b9b268105d 100644 --- a/dom/html/test/forms/test_input_datetime_tabindex.html +++ b/dom/html/test/forms/test_input_datetime_tabindex.html @@ -44,17 +44,17 @@ function testTabindex(type) { "input element with tabindex=0 is focusable"); // Advance to next inner field - synthesizeKey("VK_TAB", {}); + synthesizeKey("KEY_Tab"); is(document.activeElement, input1, "input element with tabindex=0 is tabbable"); // Advance to next inner field - synthesizeKey("VK_TAB", {}); + synthesizeKey("KEY_Tab"); is(document.activeElement, input1, "input element with tabindex=0 is tabbable"); // Advance to next element - synthesizeKey("VK_TAB", {}); + synthesizeKey("KEY_Tab"); is(document.activeElement, input3, "input element with tabindex=-1 is not tabbable"); @@ -64,7 +64,7 @@ function testTabindex(type) { // Changing the tabindex attribute dynamically. input3.setAttribute("tabindex", "-1"); - synthesizeKey("VK_TAB", {}); // need only one TAB since input2 is not tabbable + synthesizeKey("KEY_Tab"); // need only one TAB since input2 is not tabbable isnot(document.activeElement, input3, "element with tabindex changed to -1 should not be tabbable"); } diff --git a/dom/html/test/forms/test_input_event.html b/dom/html/test/forms/test_input_event.html index 965f29981178..7c8b861d4583 100644 --- a/dom/html/test/forms/test_input_event.html +++ b/dom/html/test/forms/test_input_event.html @@ -77,22 +77,22 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=851780 for (var i = 0; i < textTypes.length; ++i) { input = document.getElementById("input_" + textTypes[i]); input.focus(); - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); is(textInput[i], 0, "input event shouldn't be dispatched on " + textTypes[i] + " input element"); - synthesizeKey("m", {}); + sendString("m"); is(textInput[i], 1, textTypes[i] + " input element should have dispatched input event."); - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); is(textInput[i], 1, "input event shouldn't be dispatched on " + textTypes[i] + " input element"); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); is(textInput[i], 2, textTypes[i] + " input element should have dispatched input event."); } // Some scenarios of value changing from script and from user input. input = document.getElementById("input_text"); input.focus(); - synthesizeKey("f", {}); + sendString("f"); is(textInput[0], 3, "input event should have been dispatched"); input.blur(); is(textInput[0], 3, "input event should not have been dispatched"); @@ -104,7 +104,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=851780 is(textInput[0], 3, "input event should not have been dispatched"); input.focus(); - synthesizeKey("f", {}); + sendString("f"); is(textInput[0], 4, "input event should have been dispatched"); input.value = 'bar'; is(textInput[0], 4, "input event should not have been dispatched"); @@ -114,7 +114,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=851780 // Same for textarea. var textarea = document.getElementById("textarea"); textarea.focus(); - synthesizeKey("f", {}); + sendString("f"); is(textareaInput, 1, "input event should have been dispatched"); textarea.blur(); is(textareaInput, 1, "input event should not have been dispatched"); @@ -126,11 +126,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=851780 is(textareaInput, 1, "input event should not have been dispatched"); textarea.focus(); - synthesizeKey("f", {}); + sendString("f"); is(textareaInput, 2, "input event should have been dispatched"); textarea.value = 'bar'; is(textareaInput, 2, "input event should not have been dispatched"); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); is(textareaInput, 3, "input event should have been dispatched"); textarea.blur(); is(textareaInput, 3, "input event should not have been dispatched"); @@ -180,13 +180,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=851780 var range = document.getElementById("input_range"); range.focus(); - synthesizeKey("a", {}); + sendString("a"); range.blur(); is(rangeInput, 0, "input event shouldn't be dispatched on range input " + "element for key changes that don't change its value"); range.focus(); - synthesizeKey("VK_HOME", {}); + synthesizeKey("KEY_Home"); is(rangeInput, 1, "input event should be dispatched for key changes"); range.blur(); is(rangeInput, 1, "input event shouldn't be dispatched on blur"); @@ -210,7 +210,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=851780 if (isDesktop) { // up/down arrow keys not supported on android/b2g number.value = ""; number.focus(); - synthesizeKey("KEY_ArrowUp", {}); + synthesizeKey("KEY_ArrowUp"); is(numberInput, 1, "input event should be dispatched for up/down arrow key keypress"); is(number.value, "1", "sanity check value of number control after keypress"); diff --git a/dom/html/test/forms/test_input_file_picker.html b/dom/html/test/forms/test_input_file_picker.html index 967049c16a6d..529cafe03758 100644 --- a/dom/html/test/forms/test_input_file_picker.html +++ b/dom/html/test/forms/test_input_file_picker.html @@ -199,7 +199,7 @@ function launchNextTest() { testData[currentTest][0] == 'link-click') { synthesizeMouseAtCenter(document.getElementById(testData[currentTest][0]), {}); } else if (testData[currentTest][0] == 'div-keydown') { - synthesizeKey("a", {}); + sendString("a"); } else { document.getElementById(testData[currentTest][0]).click(); } diff --git a/dom/html/test/forms/test_input_number_key_events.html b/dom/html/test/forms/test_input_number_key_events.html index c40c8f66175b..16fd9e2609af 100644 --- a/dom/html/test/forms/test_input_number_key_events.html +++ b/dom/html/test/forms/test_input_number_key_events.html @@ -160,34 +160,34 @@ function test() { // Start at middle: oldVal = elem.value = -1; expectedVal = expectedValAfterKeyEvent(key, elem); - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, String(expectedVal), "Test " + key + " for number control with value set between min/max (" + oldVal + ")"); // Same again: expectedVal = expectedValAfterKeyEvent(key, elem); - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, String(expectedVal), "Test repeat of " + key + " for number control"); // Start at maximum: oldVal = elem.value = elem.max; expectedVal = expectedValAfterKeyEvent(key, elem); - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, String(expectedVal), "Test " + key + " for number control with value set to the maximum (" + oldVal + ")"); // Same again: expectedVal = expectedValAfterKeyEvent(key, elem); - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, String(expectedVal), "Test repeat of " + key + " for number control"); // Start at minimum: oldVal = elem.value = elem.min; expectedVal = expectedValAfterKeyEvent(key, elem); - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, String(expectedVal), "Test " + key + " for number control with value set to the minimum (" + oldVal + ")"); // Same again: expectedVal = expectedValAfterKeyEvent(key, elem); - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, String(expectedVal), "Test repeat of " + key + " for number control"); // Test preventDefault(): @@ -196,7 +196,7 @@ function test() { }, {once: true}); oldVal = elem.value = 0; expectedVal = 0; - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, String(expectedVal), "Test " + key + " for number control where scripted preventDefault() should prevent the value changing"); // Test step="any" behavior: @@ -204,7 +204,7 @@ function test() { elem.step = "any"; oldVal = elem.value = 0; expectedVal = expectedValAfterKeyEvent(key, elem); - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, String(expectedVal), "Test " + key + " for number control with value set to the midpoint and step='any' (" + oldVal + ")"); elem.step = oldStep; // restore @@ -212,7 +212,7 @@ function test() { oldVal = elem.value = ""; elem.select(); sendString("abc"); - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, "", "Test " + key + " does nothing when the input is invalid"); // Test that no value does not block UI initiated stepping: @@ -220,12 +220,12 @@ function test() { elem.setAttribute("required", "required"); elem.select(); expectedVal = expectedValAfterKeyEvent(key, elem); - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, String(expectedVal), "Test " + key + " for number control with value set to the empty string and with the 'required' attribute set"); // Same again: expectedVal = expectedValAfterKeyEvent(key, elem); - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, String(expectedVal), "Test repeat of " + key + " for number control"); // Reset 'required' attribute: diff --git a/dom/html/test/forms/test_input_number_placeholder_shown.html b/dom/html/test/forms/test_input_number_placeholder_shown.html index a515576c9160..c9c2a7f515b4 100644 --- a/dom/html/test/forms/test_input_number_placeholder_shown.html +++ b/dom/html/test/forms/test_input_number_placeholder_shown.html @@ -23,7 +23,7 @@ input:placeholder-shown { input.focus(); is(getComputedStyle(input).borderLeftColor, "rgb(0, 0, 255)", ":placeholder-shown should apply") - synthesizeKey('x', {}); + sendString("x"); isnot(getComputedStyle(input).borderLeftColor, "rgb(0, 0, 255)", ":placeholder-shown should not apply, even though the value is invalid") } diff --git a/dom/html/test/forms/test_input_number_rounding.html b/dom/html/test/forms/test_input_number_rounding.html index 16bc8ec52fe2..332b8640bb78 100644 --- a/dom/html/test/forms/test_input_number_rounding.html +++ b/dom/html/test/forms/test_input_number_rounding.html @@ -73,31 +73,31 @@ function test() { Seems like it might be nice though. for (var i = 1; i < pgUpDnVals.length; ++i) { - synthesizeKey("VK_PAGE_UP", {}); - todo_is(elem.value, pgUpDnVals[i], "Test VK_PAGE_UP"); + synthesizeKey("KEY_PageUp"); + todo_is(elem.value, pgUpDnVals[i], "Test KEY_PageUp"); is(elem.validity.valid, true, "Check element is valid for value " + pgUpDnVals[i]); } for (var i = pgUpDnVals.length - 2; i >= 0; --i) { - synthesizeKey("VK_PAGE_DOWN", {}); + synthesizeKey("KEY_PageDown"); // TODO: this condition is there because the todo_is() below would pass otherwise. if (stepVals[i] == 0) { continue; } - todo_is(elem.value, pgUpDnVals[i], "Test VK_PAGE_DOWN"); + todo_is(elem.value, pgUpDnVals[i], "Test KEY_PageDown"); is(elem.validity.valid, true, "Check element is valid for value " + pgUpDnVals[i]); } */ for (var i = 1; i < stepVals.length; ++i) { - synthesizeKey("VK_UP", {}); - is(elem.value, stepVals[i], "Test VK_UP"); + synthesizeKey("KEY_ArrowUp"); + is(elem.value, stepVals[i], "Test KEY_ArrowUp"); is(elem.validity.valid, true, "Check element is valid for value " + stepVals[i]); } for (var i = stepVals.length - 2; i >= 0; --i) { - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); // TODO: this condition is there because the todo_is() below would pass otherwise. if (stepVals[i] == 0) { continue; } - is(elem.value, stepVals[i], "Test VK_DOWN"); + is(elem.value, stepVals[i], "Test KEY_ArrowDown"); is(elem.validity.valid, true, "Check element is valid for value " + stepVals[i]); } diff --git a/dom/html/test/forms/test_input_range_key_events.html b/dom/html/test/forms/test_input_range_key_events.html index efb1f7e4bf0c..420821b2664a 100644 --- a/dom/html/test/forms/test_input_range_key_events.html +++ b/dom/html/test/forms/test_input_range_key_events.html @@ -120,22 +120,22 @@ const LTR = "ltr"; const RTL = "rtl"; var testTable = [ - ["VK_LEFT", LTR, valueMinusStep], - ["VK_LEFT", RTL, valuePlusStep], - ["VK_RIGHT", LTR, valuePlusStep], - ["VK_RIGHT", RTL, valueMinusStep], - ["VK_UP", LTR, valuePlusStep], - ["VK_UP", RTL, valuePlusStep], - ["VK_DOWN", LTR, valueMinusStep], - ["VK_DOWN", RTL, valueMinusStep], - ["VK_PAGE_UP", LTR, valuePlusTenPctOrStep], - ["VK_PAGE_UP", RTL, valuePlusTenPctOrStep], - ["VK_PAGE_DOWN", LTR, valueMinusTenPctOrStep], - ["VK_PAGE_DOWN", RTL, valueMinusTenPctOrStep], - ["VK_HOME", LTR, minimum], - ["VK_HOME", RTL, minimum], - ["VK_END", LTR, maximum], - ["VK_END", RTL, maximum], + ["KEY_ArrowLeft", LTR, valueMinusStep], + ["KEY_ArrowLeft", RTL, valuePlusStep], + ["KEY_ArrowRight", LTR, valuePlusStep], + ["KEY_ArrowRight", RTL, valueMinusStep], + ["KEY_ArrowUp", LTR, valuePlusStep], + ["KEY_ArrowUp", RTL, valuePlusStep], + ["KEY_ArrowDown", LTR, valueMinusStep], + ["KEY_ArrowDown", RTL, valueMinusStep], + ["KEY_PageUp", LTR, valuePlusTenPctOrStep], + ["KEY_PageUp", RTL, valuePlusTenPctOrStep], + ["KEY_PageDown", LTR, valueMinusTenPctOrStep], + ["KEY_PageDown", RTL, valueMinusTenPctOrStep], + ["KEY_Home", LTR, minimum], + ["KEY_Home", RTL, minimum], + ["KEY_End", LTR, maximum], + ["KEY_End", RTL, maximum], ] function test() { @@ -157,46 +157,46 @@ function test() { // Start at middle: elem.value = oldVal = defaultValue(elem); expectedVal = expectedFunc(elem); - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, String(expectedVal), "Test " + key + " for " + dir + " range with value set to the midpoint (" + oldVal + ")"); // Same again: expectedVal = expectedFunc(elem); - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, String(expectedVal), "Test repeat of " + key + " for " + dir + " range"); // Start at maximum: elem.value = oldVal = maximum(elem); expectedVal = expectedFunc(elem); - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, String(expectedVal), "Test " + key + " for " + dir + " range with value set to the maximum (" + oldVal + ")"); // Same again: expectedVal = expectedFunc(elem); - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, String(expectedVal), "Test repeat of " + key + " for " + dir + " range"); // Start at minimum: elem.value = oldVal = minimum(elem); expectedVal = expectedFunc(elem); - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, String(expectedVal), "Test " + key + " for " + dir + " range with value set to the minimum (" + oldVal + ")"); // Same again: expectedVal = expectedFunc(elem); - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, String(expectedVal), "Test repeat of " + key + " for " + dir + " range"); // Test for a step value that is greater than 10% of the range: elem.step = 20; elem.value = 60; expectedVal = expectedFunc(elem); - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, String(expectedVal), "Test " + key + " for " + dir + " range with a step that is greater than 10% of the range (step=" + elem.step + ")"); // Same again: expectedVal = expectedFunc(elem); - synthesizeKey(key, {}); + synthesizeKey(key); is(elem.value, String(expectedVal), "Test repeat of " + key + " for " + dir + " range"); // reset step: diff --git a/dom/html/test/forms/test_input_range_mouse_and_touch_events.html b/dom/html/test/forms/test_input_range_mouse_and_touch_events.html index b8d661fb41af..aaa1efa56f6a 100644 --- a/dom/html/test/forms/test_input_range_mouse_and_touch_events.html +++ b/dom/html/test/forms/test_input_range_mouse_and_touch_events.html @@ -180,15 +180,15 @@ function test(synthesizeFunc, clickOrTap, startName, moveName, endName) { elem.value = QUARTER_OF_RANGE; synthesizeFunc(elem, midX, midY, { type: startName }); is(elem.value, MIDDLE_OF_RANGE, "Test " + startName + " in middle of range"); - synthesizeKey("VK_HOME", {}); - // The VK_HOME tests are disabled until I can figure out why they fail on Android -jwatt - //is(elem.value, MINIMUM_OF_RANGE, "Test VK_HOME during a drag sets the value to the minimum of the range"); + synthesizeKey("KEY_Home"); + // The KEY_Home tests are disabled until I can figure out why they fail on Android -jwatt + //is(elem.value, MINIMUM_OF_RANGE, "Test KEY_Home during a drag sets the value to the minimum of the range"); synthesizeFunc(elem, midX+100, midY, { type: moveName }); is(elem.value, MAXIMUM_OF_RANGE, "Test " + moveName + " outside range after key press that occurred during a drag changes the value"); synthesizeFunc(elem, midX, midY, { type: moveName }); is(elem.value, MIDDLE_OF_RANGE, "Test " + moveName + " in middle of range"); - synthesizeKey("VK_HOME", {}); - //is(elem.value, MINIMUM_OF_RANGE, "Test VK_HOME during a drag sets the value to the minimum of the range (second time)"); + synthesizeKey("KEY_Home"); + //is(elem.value, MINIMUM_OF_RANGE, "Test KEY_Home during a drag sets the value to the minimum of the range (second time)"); synthesizeFunc(elem, maxX+100, midY, { type: endName }); is(elem.value, MAXIMUM_OF_RANGE, "Test " + endName + " outside range after key press that occurred during a drag changes the value"); } diff --git a/dom/html/test/forms/test_input_range_rounding.html b/dom/html/test/forms/test_input_range_rounding.html index dfbca36ce870..d8d577be4c1f 100644 --- a/dom/html/test/forms/test_input_range_rounding.html +++ b/dom/html/test/forms/test_input_range_rounding.html @@ -64,26 +64,26 @@ function test() { elem.focus(); for (var i = 1; i < pgUpDnVals.length; ++i) { - synthesizeKey("VK_PAGE_UP", {}); - is(elem.value, pgUpDnVals[i], "Test VK_PAGE_UP"); + synthesizeKey("KEY_PageUp"); + is(elem.value, pgUpDnVals[i], "Test KEY_PageUp"); is(elem.validity.valid, true, "Check element is valid for value " + pgUpDnVals[i]); } for (var i = pgUpDnVals.length - 2; i >= 0; --i) { - synthesizeKey("VK_PAGE_DOWN", {}); - is(elem.value, pgUpDnVals[i], "Test VK_PAGE_DOWN"); + synthesizeKey("KEY_PageDown"); + is(elem.value, pgUpDnVals[i], "Test KEY_PageDown"); is(elem.validity.valid, true, "Check element is valid for value " + pgUpDnVals[i]); } for (var i = 1; i < stepVals.length; ++i) { - synthesizeKey("VK_UP", {}); - is(elem.value, stepVals[i], "Test VK_UP"); + synthesizeKey("KEY_ArrowUp"); + is(elem.value, stepVals[i], "Test KEY_ArrowUp"); is(elem.validity.valid, true, "Check element is valid for value " + stepVals[i]); } for (var i = stepVals.length - 2; i >= 0; --i) { - synthesizeKey("VK_DOWN", {}); - is(elem.value, stepVals[i], "Test VK_DOWN"); + synthesizeKey("KEY_ArrowDown"); + is(elem.value, stepVals[i], "Test KEY_ArrowDown"); is(elem.validity.valid, true, "Check element is valid for value " + stepVals[i]); } diff --git a/dom/html/test/forms/test_input_textarea_set_value_no_scroll.html b/dom/html/test/forms/test_input_textarea_set_value_no_scroll.html index 7dfbddb1a73f..7998cac3ea64 100644 --- a/dom/html/test/forms/test_input_textarea_set_value_no_scroll.html +++ b/dom/html/test/forms/test_input_textarea_set_value_no_scroll.html @@ -37,7 +37,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=829606 element.selectionStart = element.selectionEnd = element.value.length; setTimeout(function() { - synthesizeKey('f', {}); + sendString('f'); requestAnimationFrame(function() { var selectionAtTheEndSnapshot = snapshotWindow(window); diff --git a/dom/html/test/forms/test_input_time_key_events.html b/dom/html/test/forms/test_input_time_key_events.html index 755db38ffc38..26332c0d7460 100644 --- a/dom/html/test/forms/test_input_time_key_events.html +++ b/dom/html/test/forms/test_input_time_key_events.html @@ -36,131 +36,131 @@ var testData = [ */ { // Type 1030 and select AM. - keys: ["1030", "VK_DOWN"], + keys: ["1030", "KEY_ArrowDown"], initialVal: "", expectedVal: "10:30" }, { // Type 3 in the hour field will automatically advance to the minute field. - keys: ["330", "VK_DOWN"], + keys: ["330", "KEY_ArrowDown"], initialVal: "", expectedVal: "03:30" }, { // Type 5 in the hour field will automatically advance to the minute field. // Type 7 in the minute field will automatically advance to the AM/PM field. - keys: ["57", "VK_DOWN"], + keys: ["57", "KEY_ArrowDown"], initialVal: "", expectedVal: "05:07" }, { // Advance to AM/PM field and change to PM. - keys: ["VK_TAB", "VK_TAB", "VK_DOWN"], + keys: ["KEY_Tab", "KEY_Tab", "KEY_ArrowDown"], initialVal: "10:30", expectedVal: "22:30" }, { // Right key should do the same thing as TAB key. - keys: ["VK_RIGHT", "VK_RIGHT", "VK_DOWN"], + keys: ["KEY_ArrowRight", "KEY_ArrowRight", "KEY_ArrowDown"], initialVal: "10:30", expectedVal: "22:30" }, { // Advance to minute field then back to hour field and decrement. - keys: ["VK_RIGHT", "VK_LEFT", "VK_DOWN"], + keys: ["KEY_ArrowRight", "KEY_ArrowLeft", "KEY_ArrowDown"], initialVal: "10:30", expectedVal: "09:30" }, { // Focus starts on the first field, hour in this case, and increment. - keys: ["VK_UP"], + keys: ["KEY_ArrowUp"], initialVal: "16:00", expectedVal: "17:00" }, { // Advance to minute field and decrement. - keys: ["VK_TAB", "VK_DOWN"], + keys: ["KEY_Tab", "KEY_ArrowDown"], initialVal: "16:00", expectedVal: "16:59" }, { // Advance to minute field and increment. - keys: ["VK_TAB", "VK_UP"], + keys: ["KEY_Tab", "KEY_ArrowUp"], initialVal: "16:59", expectedVal: "16:00" }, { // PageUp on hour field increments hour by 3. - keys: ["VK_PAGE_UP"], + keys: ["KEY_PageUp"], initialVal: "05:00", expectedVal: "08:00" }, { // PageDown on hour field decrements hour by 3. - keys: ["VK_PAGE_DOWN"], + keys: ["KEY_PageDown"], initialVal: "05:00", expectedVal: "02:00" }, { // PageUp on minute field increments minute by 10. - keys: ["VK_TAB", "VK_PAGE_UP"], + keys: ["KEY_Tab", "KEY_PageUp"], initialVal: "14:00", expectedVal: "14:10" }, { // PageDown on minute field decrements minute by 10. - keys: ["VK_TAB", "VK_PAGE_DOWN"], + keys: ["KEY_Tab", "KEY_PageDown"], initialVal: "14:00", expectedVal: "14:50" }, { // Home key on hour field sets it to the minimum hour, which is 1 in 12-hour // clock. - keys: ["VK_HOME"], + keys: ["KEY_Home"], initialVal: "03:10", expectedVal: "01:10" }, { // End key on hour field sets it to the maximum hour, which is 12 in 12-hour // clock. - keys: ["VK_END"], + keys: ["KEY_End"], initialVal: "03:10", expectedVal: "00:10" }, { // Home key on minute field sets it to the minimum minute, which is 0. - keys: ["VK_TAB", "VK_HOME"], + keys: ["KEY_Tab", "KEY_Home"], initialVal: "19:30", expectedVal: "19:00" }, { // End key on minute field sets it to the minimum minute, which is 59. - keys: ["VK_TAB", "VK_END"], + keys: ["KEY_Tab", "KEY_End"], initialVal: "19:30", expectedVal: "19:59" }, // Second field will show up when needed. { // PageUp on second field increments second by 10. - keys: ["VK_TAB", "VK_TAB", "VK_PAGE_UP"], + keys: ["KEY_Tab", "KEY_Tab", "KEY_PageUp"], initialVal: "08:10:10", expectedVal: "08:10:20" }, { // PageDown on second field increments second by 10. - keys: ["VK_TAB", "VK_TAB", "VK_PAGE_DOWN"], + keys: ["KEY_Tab", "KEY_Tab", "KEY_PageDown"], initialVal: "08:10:10", expectedVal: "08:10:00" }, { // Home key on second field sets it to the minimum second, which is 0. - keys: ["VK_TAB", "VK_TAB", "VK_HOME"], + keys: ["KEY_Tab", "KEY_Tab", "KEY_Home"], initialVal: "16:00:30", expectedVal: "16:00:00" }, { // End key on second field sets it to the minimum second, which is 59. - keys: ["VK_TAB", "VK_TAB", "VK_END"], + keys: ["KEY_Tab", "KEY_Tab", "KEY_End"], initialVal: "16:00:30", expectedVal: "16:00:59" }, @@ -169,8 +169,8 @@ var testData = [ function sendKeys(aKeys) { for (let i = 0; i < aKeys.length; i++) { let key = aKeys[i]; - if (key.startsWith("VK")) { - synthesizeKey(key, {}); + if (key.startsWith("KEY_")) { + synthesizeKey(key); } else { sendString(key); } diff --git a/dom/html/test/forms/test_input_time_sec_millisec_field.html b/dom/html/test/forms/test_input_time_sec_millisec_field.html index f3a6aa3b34b0..0c172fa58116 100644 --- a/dom/html/test/forms/test_input_time_sec_millisec_field.html +++ b/dom/html/test/forms/test_input_time_sec_millisec_field.html @@ -54,7 +54,7 @@ function countNumberOfFields(aElement) { let n = 0; while (document.activeElement == aElement) { n++; - synthesizeKey("VK_TAB", {}); + synthesizeKey("KEY_Tab"); } return n; diff --git a/dom/html/test/forms/test_maxlength_attribute.html b/dom/html/test/forms/test_maxlength_attribute.html index 4a8128d23459..a158bb08bceb 100644 --- a/dom/html/test/forms/test_maxlength_attribute.html +++ b/dom/html/test/forms/test_maxlength_attribute.html @@ -51,7 +51,7 @@ function checkTooLongValidity(element) element.focus(); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); is(element.value, "fo", "value should have changed"); ok(element.validity.tooLong, "Element should be too long after a user edit that does not make it short enough"); @@ -63,7 +63,7 @@ function checkTooLongValidity(element) "Please shorten this text to 1 characters or less (you are currently using 2 characters).", "The validation message text is not correct"); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); is(element.value, "f", "value should have changed"); ok(!element.validity.tooLong, "Element should not be too long after a user edit makes it short enough"); diff --git a/dom/html/test/forms/test_minlength_attribute.html b/dom/html/test/forms/test_minlength_attribute.html index bbec2201d3de..cfa16e0b3397 100644 --- a/dom/html/test/forms/test_minlength_attribute.html +++ b/dom/html/test/forms/test_minlength_attribute.html @@ -51,7 +51,7 @@ function checkTooShortValidity(element) element.focus(); - synthesizeKey("o", {}); + sendString("o"); is(element.value, "fooo", "value should have changed"); ok(element.validity.tooShort, "Element should be too short after a user edit that does not make it short enough"); @@ -63,7 +63,7 @@ function checkTooShortValidity(element) "Please use at least 5 characters (you are currently using 4 characters).", "The validation message text is not correct"); - synthesizeKey("o", {}); + sendString("o"); is(element.value, "foooo", "value should have changed"); ok(!element.validity.tooShort, "Element should not be too short after a user edit makes it long enough"); diff --git a/dom/html/test/forms/test_novalidate_attribute.html b/dom/html/test/forms/test_novalidate_attribute.html index e8c89993973e..197e168f4742 100644 --- a/dom/html/test/forms/test_novalidate_attribute.html +++ b/dom/html/test/forms/test_novalidate_attribute.html @@ -47,7 +47,7 @@ document.forms[1].addEventListener("submit", function(aEvent) { ok(true, "novalidate has been correctly used for second form"); var c = document.getElementById('c'); c.focus(); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); }, {once: true}); document.forms[2].addEventListener("submit", function(aEvent) { diff --git a/dom/html/test/forms/test_radio_in_label.html b/dom/html/test/forms/test_radio_in_label.html index 1676c9819bab..2630de2b94ef 100644 --- a/dom/html/test/forms/test_radio_in_label.html +++ b/dom/html/test/forms/test_radio_in_label.html @@ -40,10 +40,10 @@ function startTest() { "The first radio input element should be checked by clicking other element"); r1.focus(); - synthesizeKey("VK_LEFT", {}); + synthesizeKey("KEY_ArrowLeft"); ok(r2.checked, "The second radio input element should be checked by key"); - synthesizeKey("VK_LEFT", {}); + synthesizeKey("KEY_ArrowLeft"); ok(r1.checked, "The first radio input element should be checked by key"); SimpleTest.finish(); diff --git a/dom/html/test/forms/test_select_change_event.html b/dom/html/test/forms/test_select_change_event.html index 80d3cd09dbfb..7787f5fe007e 100644 --- a/dom/html/test/forms/test_select_change_event.html +++ b/dom/html/test/forms/test_select_change_event.html @@ -29,23 +29,23 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1265968 select.focus(); for (var i = 1; i < select.length; i++) { - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); is(select.options[i].selected, true, "Option should be selected"); is(selectChange, ++expectedChange, "Down key should fire change event."); } // We are at the end of the list, going down should not fire change event. - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); is(selectChange, expectedChange, "Down key should not fire change event when reaching end of the list."); for (var i = select.length - 2; i >= 0; i--) { - synthesizeKey("VK_UP", {}); + synthesizeKey("KEY_ArrowUp"); is(select.options[i].selected, true, "Option should be selected"); is(selectChange, ++expectedChange, "Up key should fire change event."); } // We are at the top of the list, going up should not fire change event. - synthesizeKey("VK_UP", {}); + synthesizeKey("KEY_ArrowUp"); is(selectChange, expectedChange, "Up key should not fire change event when reaching top of the list."); diff --git a/dom/html/test/forms/test_select_input_change_event.html b/dom/html/test/forms/test_select_input_change_event.html index fa1b24b41e10..e77329946791 100644 --- a/dom/html/test/forms/test_select_input_change_event.html +++ b/dom/html/test/forms/test_select_input_change_event.html @@ -41,17 +41,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1265968 var expectedInput = 0; selectSingleOneItem.focus(); - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); is(selectInput, expectedInput, "Down key should not fire input event when reaching end of the list."); is(selectChange, expectedChange, "Down key should not fire change event when reaching end of the list."); - synthesizeKey("VK_UP", {}); + synthesizeKey("KEY_ArrowUp"); is(selectInput, expectedInput, "Up key should not fire input event when reaching top of the list."); is(selectChange, expectedChange, "Up key should not fire change event when reaching top of the list."); selectSingle.focus(); for (var i = 1; i < selectSingle.length; i++) { - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); is(selectSingle.options[i].selected, true, "Option should be selected"); is(selectInput, ++expectedInput, "Down key should fire input event."); @@ -59,12 +59,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1265968 } // We are at the end of the list, going down should not fire change event. - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); is(selectInput, expectedInput, "Down key should not fire input event when reaching end of the list."); is(selectChange, expectedChange, "Down key should not fire change event when reaching end of the list."); for (var i = selectSingle.length - 2; i >= 0; i--) { - synthesizeKey("VK_UP", {}); + synthesizeKey("KEY_ArrowUp"); is(selectSingle.options[i].selected, true, "Option should be selected"); is(selectInput, ++expectedInput, "Up key should fire input event."); @@ -72,26 +72,26 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1265968 } // We are at the top of the list, going up should not fire change event. - synthesizeKey("VK_UP", {}); + synthesizeKey("KEY_ArrowUp"); is(selectInput, expectedInput, "Up key should not fire input event when reaching top of the list."); is(selectChange, expectedChange, "Up key should not fire change event when reaching top of the list."); selectMultipleOneItem.focus(); - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); is(selectInput, ++expectedInput, "Down key should fire input event when reaching end of the list."); is(selectChange, ++expectedChange, "Down key should fire change event when reaching end of the list."); - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); is(selectInput, expectedInput, "Down key should not fire input event when reaching end of the list."); is(selectChange, expectedChange, "Down key should not fire change event when reaching end of the list."); - synthesizeKey("VK_UP", {}); + synthesizeKey("KEY_ArrowUp"); is(selectInput, expectedInput, "Up key should not fire input event when reaching top of the list."); is(selectChange, expectedChange, "Up key should not fire change event when reaching top of the list."); selectMultiple.focus(); for (var i = 0; i < selectMultiple.length; i++) { - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); is(selectMultiple.options[i].selected, true, "Option should be selected"); is(selectInput, ++expectedInput, "Down key should fire input event."); @@ -99,12 +99,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1265968 } // We are at the end of the list, going down should not fire change event. - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); is(selectInput, expectedInput, "Down key should not fire input event when reaching end of the list."); is(selectChange, expectedChange, "Down key should not fire change event when reaching end of the list."); for (var i = selectMultiple.length - 2; i >= 0; i--) { - synthesizeKey("VK_UP", {}); + synthesizeKey("KEY_ArrowUp"); is(selectMultiple.options[i].selected, true, "Option should be selected"); is(selectInput, ++expectedInput, "Up key should fire input event."); @@ -112,7 +112,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1265968 } // We are at the top of the list, going up should not fire change event. - synthesizeKey("VK_UP", {}); + synthesizeKey("KEY_ArrowUp"); is(selectInput, expectedInput, "Up key should not fire input event when reaching top of the list."); is(selectChange, expectedChange, "Up key should not fire change event when reaching top of the list."); diff --git a/dom/html/test/test_bug1045270.html b/dom/html/test/test_bug1045270.html index 1d2733363bd6..1ff8984f4484 100644 --- a/dom/html/test/test_bug1045270.html +++ b/dom/html/test/test_bug1045270.html @@ -30,9 +30,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1045270 document.body.style.display = ""; document.body.offsetLeft; // flush }); - synthesizeKey("1", {}); + sendString("1"); SimpleTest.executeSoon(function() { - synthesizeKey("2", {}); + sendString("2"); SimpleTest.executeSoon(function() { is(input.value, "12", "Reframe should restore focus and selection properly"); SimpleTest.finish(); diff --git a/dom/html/test/test_bug1230665.html b/dom/html/test/test_bug1230665.html index 2bad51cdb782..fa66b002d2f3 100644 --- a/dom/html/test/test_bug1230665.html +++ b/dom/html/test/test_bug1230665.html @@ -11,12 +11,12 @@ SimpleTest.waitForExplicitFinish(); SimpleTest.waitForFocus(function() { document.getElementById("flexbutton1").focus(); - synthesizeKey("VK_TAB", { }); + synthesizeKey("KEY_Tab"); var e = document.getElementById("flexbutton2"); is(document.activeElement, e, "focus in flexbutton2 after TAB"); document.getElementById("gridbutton1").focus(); - synthesizeKey("VK_TAB", { }); + synthesizeKey("KEY_Tab"); e = document.getElementById("gridbutton2"); is(document.activeElement, e, "focus in gridbutton2 after TAB"); diff --git a/dom/html/test/test_bug386996.html b/dom/html/test/test_bug386996.html index 4f667281f4a7..7d643f7709df 100644 --- a/dom/html/test/test_bug386996.html +++ b/dom/html/test/test_bug386996.html @@ -28,7 +28,7 @@ function testContentEditable() { document.getElementById("input2").onfocus = function() { focusedElement = this }; document.getElementById("input1").focus(); - synthesizeKey("VK_TAB", {}); + synthesizeKey("KEY_Tab"); is(focusedElement.id, "input2"); } diff --git a/dom/html/test/test_bug406596.html b/dom/html/test/test_bug406596.html index adc6380525a1..eea0c4ebb792 100644 --- a/dom/html/test/test_bug406596.html +++ b/dom/html/test/test_bug406596.html @@ -43,10 +43,10 @@ function testTabbing(click, focus, selectionOffset) { var focusedElement = document.activeElement; is(focusedElement, document.getElementById(focus), "clicking should move focus to the contentEditable node"); - synthesizeKey("VK_TAB", {}); - synthesizeKey("VK_TAB", {}); - synthesizeKey("VK_TAB", { shiftKey: true }); - synthesizeKey("VK_TAB", { shiftKey: true }); + synthesizeKey("KEY_Tab"); + synthesizeKey("KEY_Tab"); + synthesizeKey("KEY_Tab", {shiftKey: true}); + synthesizeKey("KEY_Tab", {shiftKey: true}); is(document.activeElement, focusedElement, "tab/shift-tab should move focus back to the contentEditable node"); if (selectionOffset) { diff --git a/dom/html/test/test_bug460568.html b/dom/html/test/test_bug460568.html index 14bcbbc7899f..9bfef1e39d79 100644 --- a/dom/html/test/test_bug460568.html +++ b/dom/html/test/test_bug460568.html @@ -46,7 +46,7 @@ function runTest() .QueryInterface(SpecialPowers.Ci.nsISelectionController); var sel = controller.getSelection(controller.SELECTION_NORMAL); sel.collapse(anchorInEditor, 0); - synthesizeKey('a', {}); + sendString("a"); range.selectNodeContents(editor); return prevStr != range.toString(); } diff --git a/dom/html/test/test_bug535043.html b/dom/html/test/test_bug535043.html index 0123c4c2f1f2..e11e78343a92 100644 --- a/dom/html/test/test_bug535043.html +++ b/dom/html/test/test_bug535043.html @@ -26,7 +26,7 @@ function checkTextArea(textArea) { textArea.value = ''; textArea.focus(); for (var j = 0; j < 3; j++) { - synthesizeKey('x', {}); + sendString("x"); } var htmlMaxLength = textArea.getAttribute('maxlength'); var domMaxLength = textArea.maxLength; diff --git a/dom/html/test/test_bug556645.html b/dom/html/test/test_bug556645.html index 3602963175cc..83868065d4d1 100644 --- a/dom/html/test/test_bug556645.html +++ b/dom/html/test/test_bug556645.html @@ -28,11 +28,11 @@ function runTest() var pbutton = document.getElementById("pbutton"); pbutton.focus(); - synthesizeKey("VK_TAB", { }); + synthesizeKey("KEY_Tab"); is(document.activeElement, obj, "focus in parent after tab"); is(childDoc.activeElement, childDoc.documentElement, "focus in child after tab"); - synthesizeKey("VK_TAB", { }); + synthesizeKey("KEY_Tab"); is(document.activeElement, obj, "focus in parent after tab 2"); is(childDoc.activeElement, button, "focus in child after tab 2"); diff --git a/dom/html/test/test_bug557087-4.html b/dom/html/test/test_bug557087-4.html index 9b2a96246420..dbc7ffc6633e 100644 --- a/dom/html/test/test_bug557087-4.html +++ b/dom/html/test/test_bug557087-4.html @@ -57,7 +57,7 @@ function doSubmit() { for (e of inputs) { e.focus(); - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); } } diff --git a/dom/html/test/test_bug558788-1.html b/dom/html/test/test_bug558788-1.html index f418d9438c2d..d090159012f4 100644 --- a/dom/html/test/test_bug558788-1.html +++ b/dom/html/test/test_bug558788-1.html @@ -59,10 +59,10 @@ function checkMissing(elementName) element.focus(); - synthesizeKey("a", {}); + sendString("a"); checkValidApplies(element); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); checkInvalidApplies(element); gContent.removeChild(element); @@ -78,7 +78,7 @@ function checkTooLong(elementName) element.focus(); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); checkValidApplies(element); gContent.removeChild(element); } @@ -118,13 +118,13 @@ function checkInputEmail() element.focus(); - synthesizeKey("a", {}); + sendString("a"); checkInvalidApplies(element); sendString("@b.c"); checkValidApplies(element); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); for (var i=0; i<4; ++i) { if (i == 1) { // a@b is a valid value. @@ -132,7 +132,7 @@ function checkInputEmail() } else { checkInvalidApplies(element); } - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); } checkValidApplies(element); @@ -148,22 +148,22 @@ function checkInputURL() element.focus(); - synthesizeKey("h", {}); + sendString("h"); checkInvalidApplies(element); sendString("ttp://mozilla.org"); checkValidApplies(element); for (var i=0; i<10; ++i) { - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); checkValidApplies(element); } - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); // "http://" is now invalid for (var i=0; i<7; ++i) { checkInvalidApplies(element); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); } checkValidApplies(element); @@ -179,16 +179,16 @@ function checkInputPattern() element.focus(); - synthesizeKey("0", {}); + sendString("0"); checkValidApplies(element); - synthesizeKey("a", {}); + sendString("a"); checkInvalidApplies(element); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); checkValidApplies(element); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); checkValidApplies(element); gContent.removeChild(element); diff --git a/dom/html/test/test_bug558788-2.html b/dom/html/test/test_bug558788-2.html index dcf5db00d69a..7b5bf9c3cf66 100644 --- a/dom/html/test/test_bug558788-2.html +++ b/dom/html/test/test_bug558788-2.html @@ -133,10 +133,10 @@ function makeMinMaxLengthElementsActuallyInvalid(aInvalidElements, var e = aInvalidElements[i]; if (aInvalidElementsDesc[i][5]) { // maxlength e.focus(); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); } else if (aInvalidElementsDesc[i][6]) { // minlength e.focus(); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); } } } diff --git a/dom/html/test/test_bug561636.html b/dom/html/test/test_bug561636.html index 3b2e49d802c0..12525aecaeac 100644 --- a/dom/html/test/test_bug561636.html +++ b/dom/html/test/test_bug561636.html @@ -101,7 +101,7 @@ function runTest() document.getElementById('b').click(); var c = document.getElementById('c'); c.focus(); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); document.getElementById('s2').click(); } diff --git a/dom/html/test/test_bug566046.html b/dom/html/test/test_bug566046.html index ca697d409a10..f514c3baf2ec 100644 --- a/dom/html/test/test_bug566046.html +++ b/dom/html/test/test_bug566046.html @@ -162,22 +162,22 @@ function runTests() }, {once: true}); document.getElementById('is2').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); document.getElementById('ii2').focus(); }, {once: true}); document.getElementById('ii2').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); document.getElementById('bs2').focus(); }, {once: true}); document.getElementById('bs2').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); document.getElementById('enter').focus(); }, {once: true}); document.getElementById('enter').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); }, {once: true}); document.getElementById('is').focus(); diff --git a/dom/html/test/test_bug582412-1.html b/dom/html/test/test_bug582412-1.html index d9eb14553c57..c5eef5821f5a 100644 --- a/dom/html/test/test_bug582412-1.html +++ b/dom/html/test/test_bug582412-1.html @@ -153,32 +153,32 @@ function runTests() }, {once: true}); document.getElementById('is2').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); document.getElementById('ii2').focus(); }, {once: true}); document.getElementById('ii2').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); document.getElementById('bs2').focus(); }, {once: true}); document.getElementById('bs2').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); document.getElementById('enter').focus(); }, {once: true}); document.getElementById('enter').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); document.getElementById('i8').focus(); }, {once: true}); document.getElementById('i8').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); document.getElementById('i9').focus(); }, {once: true}); document.getElementById('i9').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); }, {once: true}); document.getElementById('is').focus(); diff --git a/dom/html/test/test_bug582412-2.html b/dom/html/test/test_bug582412-2.html index c1160067628d..683e48781a3b 100644 --- a/dom/html/test/test_bug582412-2.html +++ b/dom/html/test/test_bug582412-2.html @@ -152,32 +152,32 @@ function runTests() }, {once: true}); document.getElementById('is2').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); document.getElementById('ii2').focus(); }, {once: true}); document.getElementById('ii2').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); document.getElementById('bs2').focus(); }, {once: true}); document.getElementById('bs2').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); document.getElementById('enter').focus(); }, {once: true}); document.getElementById('enter').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); document.getElementById('i8').focus(); }, {once: true}); document.getElementById('i8').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); document.getElementById('i9').focus(); }, {once: true}); document.getElementById('i9').addEventListener('focus', function(aEvent) { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); }, {once: true}); document.getElementById('is').focus(); diff --git a/dom/html/test/test_bug605124-2.html b/dom/html/test/test_bug605124-2.html index e09c60fb0b7f..3f6a284cb7bd 100644 --- a/dom/html/test/test_bug605124-2.html +++ b/dom/html/test/test_bug605124-2.html @@ -44,9 +44,9 @@ function checkElement(aElement) aElement.focus(); checkPseudoClass(aElement, false); // with keys - synthesizeKey('f', {}); + sendString("f"); checkPseudoClass(aElement, false); - synthesizeKey('VK_BACK_SPACE', {}); + synthesizeKey("KEY_Backspace"); checkPseudoClass(aElement, false); // with .value aElement.value = 'f'; @@ -62,9 +62,9 @@ function checkElement(aElement) aElement.focus(); checkPseudoClass(aElement, true); // with keys - synthesizeKey('f', {}); + sendString("f"); checkPseudoClass(aElement, false); - synthesizeKey('VK_BACK_SPACE', {}); + synthesizeKey("KEY_Backspace"); checkPseudoClass(aElement, true); // with .value aElement.value = 'f'; diff --git a/dom/html/test/test_bug605125-2.html b/dom/html/test/test_bug605125-2.html index 974b7eca65b1..a2664d3ea55c 100644 --- a/dom/html/test/test_bug605125-2.html +++ b/dom/html/test/test_bug605125-2.html @@ -44,9 +44,9 @@ function checkElement(aElement) aElement.focus(); checkPseudoClass(aElement, false); // with keys - synthesizeKey('f', {}); + sendString("f"); checkPseudoClass(aElement, false); - synthesizeKey('VK_BACK_SPACE', {}); + synthesizeKey("KEY_Backspace"); checkPseudoClass(aElement, false); // with .value aElement.value = 'f'; @@ -62,9 +62,9 @@ function checkElement(aElement) aElement.focus(); checkPseudoClass(aElement, true); // with keys - synthesizeKey('f', {}); + sendString("f"); checkPseudoClass(aElement, true); - synthesizeKey('VK_BACK_SPACE', {}); + synthesizeKey("KEY_Backspace"); checkPseudoClass(aElement, true); // with .value aElement.value = 'f'; @@ -81,9 +81,9 @@ function checkElement(aElement) aElement.focus(); checkPseudoClass(aElement, false); // with keys - synthesizeKey('f', {}); + sendString("f"); checkPseudoClass(aElement, true); - synthesizeKey('VK_BACK_SPACE', {}); + synthesizeKey("KEY_Backspace"); checkPseudoClass(aElement, false); // with .value aElement.value = 'f'; diff --git a/dom/html/test/test_bug613019.html b/dom/html/test/test_bug613019.html index bb28d108a1e8..910d9ad25425 100644 --- a/dom/html/test/test_bug613019.html +++ b/dom/html/test/test_bug613019.html @@ -30,11 +30,11 @@ function testInteractivityOfMaxLength(elem) { elem.setSelectionRange(elem.value.length, elem.value.length) elem.focus(); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); is(elem.value, "Tes", "Element value was not changed correctly."); is(elem.validity.tooLong, true, "Element should still be tooLong."); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); is(elem.value, "Te", "Element value was not changed correctly."); is(elem.validity.tooLong, false, "Element should no longer be tooLong."); @@ -51,11 +51,11 @@ function testInteractivityOfMinLength(elem) { elem.setSelectionRange(elem.value.length, elem.value.length) elem.focus(); - synthesizeKey("e", {}); + sendString("e"); is(elem.value, "Teste", "Element value was not changed correctly."); is(elem.validity.tooShort, true, "Element should still be tooShort."); - synthesizeKey("d", {}); + sendString("d"); is(elem.value, "Tested", "Element value was not changed correctly."); is(elem.validity.tooShort, false, "Element should no longer be tooShort."); diff --git a/dom/html/test/test_bug613979.html b/dom/html/test/test_bug613979.html index 360b7d47af12..261cb232ae7a 100644 --- a/dom/html/test/test_bug613979.html +++ b/dom/html/test/test_bug613979.html @@ -28,7 +28,7 @@ input.addEventListener("input", function() { ok(input.validity.valid, "input should be valid"); testNum++; SimpleTest.executeSoon(function() { - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); }); } else if (testNum == 1) { ok(!input.validity.valid, "input should not be valid"); @@ -41,7 +41,7 @@ SimpleTest.waitForExplicitFinish(); SimpleTest.waitForFocus(function() { input.focus(); - synthesizeKey("a", {}); + sendString("a"); }); diff --git a/dom/html/test/test_bug615833.html b/dom/html/test/test_bug615833.html index 6d3177a195d1..1921bd8c8b4a 100644 --- a/dom/html/test/test_bug615833.html +++ b/dom/html/test/test_bug615833.html @@ -74,7 +74,7 @@ select.addEventListener("keyup", function() { select.addEventListener("focus", function() { SimpleTest.executeSoon(function () { - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); }); }, {once: true}); @@ -111,7 +111,7 @@ textarea.addEventListener("input", function() { textarea.addEventListener("focus", function() { SimpleTest.executeSoon(function () { - synthesizeKey('f', {}); + sendString("f"); }); }, {once: true}); @@ -126,7 +126,7 @@ input.addEventListener("input", function() { input.addEventListener("focus", function() { SimpleTest.executeSoon(function () { - synthesizeKey('f', {}); + sendString("f"); }); }, {once: true}); diff --git a/dom/html/test/test_bug618948.html b/dom/html/test/test_bug618948.html index 258041bdb50d..2053aa967eca 100644 --- a/dom/html/test/test_bug618948.html +++ b/dom/html/test/test_bug618948.html @@ -56,7 +56,7 @@ var b = document.getElementsByTagName('button')[0]; i.onfocus = function(event) { eventHandler(event); - synthesizeKey('f', {}); + sendString("f"); i.onfocus = null; }; diff --git a/dom/html/test/test_bug619278.html b/dom/html/test/test_bug619278.html index 49814e20a94f..cd5a1bc8bcb2 100644 --- a/dom/html/test/test_bug619278.html +++ b/dom/html/test/test_bug619278.html @@ -41,7 +41,7 @@ e.addEventListener("invalid", function(event) { e.addEventListener("focus", function() { SimpleTest.executeSoon(function() { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); }); }, {once: true}); diff --git a/dom/html/test/test_bug622597.html b/dom/html/test/test_bug622597.html index 3adb63ae4327..a31aca7a0de8 100644 --- a/dom/html/test/test_bug622597.html +++ b/dom/html/test/test_bug622597.html @@ -90,7 +90,7 @@ input.addEventListener("invalid", function() { button.addEventListener("focus", function() { SimpleTest.executeSoon(function() { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); }); }, {once: true}); diff --git a/dom/html/test/test_bug633058.html b/dom/html/test/test_bug633058.html index a0facce95171..fb6a19bcbeb1 100644 --- a/dom/html/test/test_bug633058.html +++ b/dom/html/test/test_bug633058.html @@ -47,14 +47,14 @@ function startTest() { input.addEventListener('focus', function() { SimpleTest.executeSoon(() => { - synthesizeKey('KEY_ArrowUp', {}); - synthesizeKey('KEY_ArrowLeft', {}); - synthesizeKey('KEY_ArrowRight', {}); - synthesizeKey('KEY_ArrowDown', {}); - synthesizeKey('KEY_Backspace', {}); - synthesizeKey('KEY_Delete', {}); - synthesizeKey('KEY_Escape', {}); - synthesizeKey('KEY_Enter', {}); // Will dispatch keypress event even in strict behavior. + synthesizeKey('KEY_ArrowUp'); + synthesizeKey('KEY_ArrowLeft'); + synthesizeKey('KEY_ArrowRight'); + synthesizeKey('KEY_ArrowDown'); + synthesizeKey('KEY_Backspace'); + synthesizeKey('KEY_Delete'); + synthesizeKey('KEY_Escape'); + synthesizeKey('KEY_Enter'); // Will dispatch keypress event even in strict behavior. is(inputGotKeyDown, nbExpectedKeyDown, "input got all keydown events"); is(inputGotKeyPress, nbExpectedKeyPress, "input got all keypress events"); diff --git a/dom/html/test/test_bug651956.html b/dom/html/test/test_bug651956.html index 7ea1d7c8aa60..6bd80d496128 100644 --- a/dom/html/test/test_bug651956.html +++ b/dom/html/test/test_bug651956.html @@ -29,7 +29,7 @@ input.addEventListener("input", function() { }, {once: true}); input.addEventListener("focus", function() { - synthesizeKey("VK_ESCAPE", {}); + synthesizeKey("KEY_Escape"); setTimeout(function() { ok(!gotInputEvent, "No input event should have been sent."); diff --git a/dom/html/test/test_ignoreuserfocus.html b/dom/html/test/test_ignoreuserfocus.html index a48fc23ac81a..7e610cbe768e 100644 --- a/dom/html/test/test_ignoreuserfocus.html +++ b/dom/html/test/test_ignoreuserfocus.html @@ -116,7 +116,7 @@ // Test tabindex witness.focus(); is(document.activeElement, witness, "witness should have the focus"); - synthesizeKey("VK_TAB", {}); + synthesizeKey("KEY_Tab"); isnot(document.activeElement, iframe, "[synthesize tab key] iframe should not have the focus"); is(document.activeElement, witness2, "witness2 should have the focus"); diff --git a/dom/html/test/test_object_plugin_nav.html b/dom/html/test/test_object_plugin_nav.html index 91590e51afa4..47963eeede7c 100644 --- a/dom/html/test/test_object_plugin_nav.html +++ b/dom/html/test/test_object_plugin_nav.html @@ -70,7 +70,7 @@ function doTest() { checkFocus(); if (gFocusCount != gFocusNb) { - synthesizeKey("VK_TAB", {}); + synthesizeKey("KEY_Tab"); return; } @@ -85,7 +85,7 @@ function doTest() { o.focus(); }, true); - synthesizeKey("VK_TAB", {}); + synthesizeKey("KEY_Tab"); } SimpleTest.waitForFocus(function () { diff --git a/dom/indexedDB/test/head.js b/dom/indexedDB/test/head.js index dc55e062fc4c..8960728043fe 100644 --- a/dom/indexedDB/test/head.js +++ b/dom/indexedDB/test/head.js @@ -72,7 +72,7 @@ function dismissNotification(popup) { info("dismissing notification"); executeSoon(function() { - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); }); } diff --git a/dom/plugins/test/mochitest/browser_pluginscroll.js b/dom/plugins/test/mochitest/browser_pluginscroll.js index ade3a7d4a566..cbb65ce1d68b 100644 --- a/dom/plugins/test/mochitest/browser_pluginscroll.js +++ b/dom/plugins/test/mochitest/browser_pluginscroll.js @@ -200,7 +200,7 @@ add_task(async function() { }); is(result, true, "plugin is visible"); - EventUtils.synthesizeKey("VK_END", {}); + EventUtils.synthesizeKey("KEY_End"); await waitScrollStart(gBrowser.selectedBrowser); @@ -220,7 +220,7 @@ add_task(async function() { }); is(result, false, "plugin is hidden"); - EventUtils.synthesizeKey("VK_HOME", {}); + EventUtils.synthesizeKey("KEY_Home"); await waitScrollFinish(gBrowser.selectedBrowser); @@ -265,7 +265,7 @@ add_task(async function() { }); is(result, true, "plugin is visible"); - EventUtils.synthesizeKey("VK_END", {}); + EventUtils.synthesizeKey("KEY_End"); await waitScrollStart(gBrowser.selectedBrowser); @@ -285,7 +285,7 @@ add_task(async function() { }); is(result, false, "plugin is hidden"); - EventUtils.synthesizeKey("VK_HOME", {}); + EventUtils.synthesizeKey("KEY_Home"); await waitScrollFinish(gBrowser.selectedBrowser); diff --git a/dom/svg/test/test_tabindex.html b/dom/svg/test/test_tabindex.html index fdc9731c6428..91674bca3659 100644 --- a/dom/svg/test/test_tabindex.html +++ b/dom/svg/test/test_tabindex.html @@ -65,16 +65,16 @@ function main() // Step 2: Checking by triggering TAB event is(document.activeElement.tabIndex, -1, "In the beginning, the active element tabindex is -1"); - synthesizeKey("VK_TAB", {}); + synthesizeKey("KEY_Tab"); is(document.activeElement.tabIndex, 1, "The active element tabindex is 1"); - synthesizeKey("VK_TAB", {}); + synthesizeKey("KEY_Tab"); is(document.activeElement.tabIndex, 2, "The active element tabindex is 2"); - synthesizeKey("VK_TAB", {}); + synthesizeKey("KEY_Tab"); is(document.activeElement.tabIndex, 3, "The active element tabindex is 3"); - synthesizeKey("VK_TAB", {}); + synthesizeKey("KEY_Tab"); // On Mac, SVG link elements should not be focused. if (isMac) { is(document.activeElement.tabIndex, 6, "The active element tabindex is 6"); @@ -82,7 +82,7 @@ function main() is(document.activeElement.tabIndex, 4, "The active element tabindex is 4"); } - synthesizeKey("VK_TAB", {}); + synthesizeKey("KEY_Tab"); // On Mac, SVG link elements should not be focused. if (isMac) { is(document.activeElement.tabIndex, 7, "The active element tabindex is 7"); diff --git a/dom/tests/browser/browser_cancel_keydown_keypress_event.js b/dom/tests/browser/browser_cancel_keydown_keypress_event.js index c9b161978035..963d3dcf84ee 100644 --- a/dom/tests/browser/browser_cancel_keydown_keypress_event.js +++ b/dom/tests/browser/browser_cancel_keydown_keypress_event.js @@ -27,7 +27,7 @@ add_task(async function() { // Send return key (cross process) to submit the form implicitly. let dialogShown = awaitAndCloseAlertDialog(); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await dialogShown; // Check that the form should not have been submitted. diff --git a/dom/tests/mochitest/bugs/test_bug265203.html b/dom/tests/mochitest/bugs/test_bug265203.html index e5fe713f572c..b5a061f18426 100644 --- a/dom/tests/mochitest/bugs/test_bug265203.html +++ b/dom/tests/mochitest/bugs/test_bug265203.html @@ -62,13 +62,13 @@ function test0() { testFocus(); } function test1() { - synthesizeKey("VK_RIGHT", { }); - synthesizeKey("VK_RIGHT", { }); - synthesizeKey("VK_RIGHT", { }); - synthesizeKey("VK_RIGHT", { }); - synthesizeKey("VK_RIGHT", { }); - synthesizeKey("VK_RIGHT", { }); - synthesizeKey("VK_RIGHT", { }); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); expectedResult = [ $("a1").firstChild, 7, $("a2") ] nextTest = test2; testFocus(); @@ -80,13 +80,13 @@ function test2() { testFocus(); } function test3() { - synthesizeKey("VK_RIGHT", { }); - synthesizeKey("VK_RIGHT", { }); - synthesizeKey("VK_RIGHT", { }); - synthesizeKey("VK_RIGHT", { }); - synthesizeKey("VK_RIGHT", { }); - synthesizeKey("VK_RIGHT", { }); - synthesizeKey("VK_RIGHT", { }); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); expectedResult = [ $("a3").firstChild, 7, $("a3") ] nextTest = SimpleTest.finish; testFocus(); @@ -96,7 +96,7 @@ function startTest() { if (gTestStarted) return; gTestStarted = true; - // Turn off spatial navigation because it hijacks VK_RIGHT and VK_LEFT keydown + // Turn off spatial navigation because it hijacks KEY_ArrowRight and KEY_ArrowLeft keydown // events SpecialPowers.pushPrefEnv({"set": [["accessibility.browsewithcaret", true], ["snav.enabled", false]]}, test0); } diff --git a/dom/tests/mochitest/chrome/window_focus.xul b/dom/tests/mochitest/chrome/window_focus.xul index fe137b5b8a0c..a932ef901107 100644 --- a/dom/tests/mochitest/chrome/window_focus.xul +++ b/dom/tests/mochitest/chrome/window_focus.xul @@ -333,7 +333,7 @@ function done() opener.wrappedJSObject.SimpleTest.finish(); } -var pressTab = () => synthesizeKey("VK_TAB", { }); +var pressTab = () => synthesizeKey("KEY_Tab"); function setFocusTo(id, fwindow) { @@ -400,10 +400,10 @@ function startTest() } setFocusTo("last", window); expectFocusShift(pressTab, null, getById(partialTabList[0]), true, "partial tab key wrap to start"); - expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }), + expectFocusShift(() => synthesizeKey("KEY_Tab", {shiftKey: true}), null, getById("last"), true, "partial shift tab key wrap to end"); for (var idx = partialTabList.length - 1; idx >= 0; idx--) { - expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }), + expectFocusShift(() => synthesizeKey("KEY_Tab", {shiftKey: true}), null, getById(partialTabList[idx]), true, "partial tab key " + partialTabList[idx]); } } @@ -416,13 +416,13 @@ function startTest() // wrapping around at end with TAB key setFocusTo("last", window); expectFocusShift(pressTab, null, getById("t1"), true, "tab key wrap to start"); - expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }), + expectFocusShift(() => synthesizeKey("KEY_Tab", {shiftKey: true}), null, getById("last"), true, "shift tab key wrap to end"); // Shift+TAB key setFocusTo("o5", window); for (idx = kTabbableSteps; idx > 0; idx--) { - expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }), + expectFocusShift(() => synthesizeKey("KEY_Tab", {shiftKey: true}), null, getById("t" + idx), true, "shift tab key t" + idx); } } @@ -807,7 +807,7 @@ function startTest() expectFocusShift(() => textbox2.focus(), null, textbox2.inputField, true, "focus on textbox"); gLastFocusMethod = fm.FLAG_BYKEY; - expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }), + expectFocusShift(() => synthesizeKey("KEY_Tab", {shiftKey: true}), null, textbox1.inputField, true, "shift+tab on textbox"); textbox1.tabIndex = 2; @@ -816,7 +816,7 @@ function startTest() expectFocusShift(() => textbox2.focus(), null, textbox2.inputField, true, "focus on textbox with tabindex set"); gLastFocusMethod = fm.FLAG_BYKEY; - expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }), + expectFocusShift(() => synthesizeKey("KEY_Tab", {shiftKey: true}), null, textbox1.inputField, true, "shift+tab on textbox with tabindex set"); // ---- test for bug 618907 which ensures that canceling the mousedown event still focuses the @@ -1030,11 +1030,11 @@ function testMoveFocus() getService(Components.interfaces.nsIPrefBranch); prefs.setBoolPref("accessibility.browsewithcaret", true); - synthesizeKey("VK_LEFT", { }, gChildWindow); - synthesizeKey("VK_LEFT", { }, gChildWindow); + synthesizeKey("KEY_ArrowLeft", {}, gChildWindow); + synthesizeKey("KEY_ArrowLeft", {}, gChildWindow); is(fm.focusedElement, null, "move caret away from link"); - synthesizeKey("VK_LEFT", { }, gChildWindow); + synthesizeKey("KEY_ArrowLeft", {}, gChildWindow); is(fm.focusedElement, getById("t24"), "move caret away onto link"); prefs.setBoolPref("accessibility.browsewithcaret", false); @@ -1049,18 +1049,18 @@ function testMoveFocus() gLastFocusMethod = fm.FLAG_BYKEY; selection.selectAllChildren(getById("hiddenspan")); - expectFocusShift(() => synthesizeKey("VK_TAB", { }), + expectFocusShift(() => synthesizeKey("KEY_Tab"), gChildWindow, getById("t26"), true, "tab with selection on hidden content"); setFocusTo($("o15"), window); $("o15").hidden = true; document.documentElement.getBoundingClientRect(); // flush after hiding - expectFocusShift(() => synthesizeKey("VK_TAB", { }), + expectFocusShift(() => synthesizeKey("KEY_Tab"), window, $("o17"), true, "tab with focus on hidden content"); $("o17").hidden = true; document.documentElement.getBoundingClientRect(); - expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }), + expectFocusShift(() => synthesizeKey("KEY_Tab", {shiftKey: true}), window, $("o13"), true, "shift+tab with focus on hidden content"); } @@ -1157,7 +1157,7 @@ function modalWindowOpened(modalWindow) if (gPartialTabbing) elem.focus(); else - synthesizeKey("VK_TAB", { }, modalWindow); + synthesizeKey("KEY_Tab", {}, modalWindow); is(fm.activeWindow, modalWindow, "modal activeWindow"); is(fm.focusedElement, elem, "modal focusedElement"); @@ -1187,43 +1187,43 @@ function framesetWindowLoaded(framesetWindow) gNewExpectedWindow = framesetWindow.frames[(idx - 1) >> 1]; if (idx % 2) initEvents(gNewExpectedWindow); - expectFocusShift(() => synthesizeKey("VK_TAB", { }, framesetWindow), + expectFocusShift(() => synthesizeKey("KEY_Tab", {}, framesetWindow), gNewExpectedWindow, getById("f" + idx), true, "frameset tab key f" + idx); gMoveToFocusFrame = false; gOldExpectedWindow = gNewExpectedWindow; } gNewExpectedWindow = framesetWindow.frames[0]; - expectFocusShift(() => synthesizeKey("VK_TAB", { }, framesetWindow), + expectFocusShift(() => synthesizeKey("KEY_Tab", {}, framesetWindow), gNewExpectedWindow, getById("f1"), true, "frameset tab key wrap to start"); gOldExpectedWindow = gNewExpectedWindow; gNewExpectedWindow = framesetWindow.frames[3]; - expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }, framesetWindow), + expectFocusShift(() => synthesizeKey("KEY_Tab", {shiftKey: true}, framesetWindow), gNewExpectedWindow, getById("f8"), true, "frameset shift tab key wrap to end"); for (idx = 7; idx >= 1; idx--) { gOldExpectedWindow = gNewExpectedWindow; gNewExpectedWindow = framesetWindow.frames[(idx - 1) >> 1]; - expectFocusShift(() => synthesizeKey("VK_TAB", { shiftKey: true }, framesetWindow), + expectFocusShift(() => synthesizeKey("KEY_Tab", {shiftKey: true}, framesetWindow), gNewExpectedWindow, getById("f" + idx), true, "frameset shift tab key f" + idx); } // document shifting // XXXndeakin P3 ctrl+tab doesn't seem to be testable currently for some reason gNewExpectedWindow = framesetWindow.frames[1]; - expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true }, framesetWindow), + expectFocusShift(() => synthesizeKey("KEY_F6", {ctrlKey: true}, framesetWindow), gNewExpectedWindow, getById("f3"), true, "switch document forward with f6"); gOldExpectedWindow = gNewExpectedWindow; gNewExpectedWindow = framesetWindow.frames[2]; - expectFocusShift(() => synthesizeKey("VK_F6", { }, framesetWindow), + expectFocusShift(() => synthesizeKey("KEY_F6", {}, framesetWindow), gNewExpectedWindow, getById("f5"), true, "switch document forward with ctrl+tab"); gOldExpectedWindow = gNewExpectedWindow; gNewExpectedWindow = framesetWindow.frames[3]; - expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true }, framesetWindow), + expectFocusShift(() => synthesizeKey("KEY_F6", {ctrlKey: true}, framesetWindow), gNewExpectedWindow, getById("f7"), true, "switch document forward with ctrl+f6"); gOldExpectedWindow = gNewExpectedWindow; gNewExpectedWindow = framesetWindow.frames[0]; - expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true }, framesetWindow), + expectFocusShift(() => synthesizeKey("KEY_F6", {ctrlKey: true}, framesetWindow), gNewExpectedWindow, getById("f1"), true, "switch document forward and wrap"); // going backwards by document and wrapping doesn't currently work, but didn't work @@ -1232,7 +1232,7 @@ function framesetWindowLoaded(framesetWindow) /* gOldExpectedWindow = gNewExpectedWindow; gNewExpectedWindow = framesetWindow.frames[3]; - expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow), + expectFocusShift(() => synthesizeKey("KEY_F6", { ctrlKey: true, shiftKey: true }, framesetWindow), gNewExpectedWindow, getById("f7"), true, "switch document backward and wrap"); */ @@ -1241,15 +1241,15 @@ function framesetWindowLoaded(framesetWindow) gOldExpectedWindow = gNewExpectedWindow; gNewExpectedWindow = framesetWindow.frames[2]; - expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow), + expectFocusShift(() => synthesizeKey("KEY_F6", {ctrlKey: true, shiftKey: true}, framesetWindow), gNewExpectedWindow, getById("f5"), true, "switch document backward with f6"); gOldExpectedWindow = gNewExpectedWindow; gNewExpectedWindow = framesetWindow.frames[1]; - expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow), + expectFocusShift(() => synthesizeKey("KEY_F6", {ctrlKey: true, shiftKey: true}, framesetWindow), gNewExpectedWindow, getById("f3"), true, "switch document backward with ctrl+tab"); gOldExpectedWindow = gNewExpectedWindow; gNewExpectedWindow = framesetWindow.frames[0]; - expectFocusShift(() => synthesizeKey("VK_F6", { ctrlKey: true, shiftKey: true }, framesetWindow), + expectFocusShift(() => synthesizeKey("KEY_F6", {ctrlKey: true, shiftKey: true}, framesetWindow), gNewExpectedWindow, getById("f1"), true, "switch document backward with ctrl+f6"); // skip the window switching tests for now on Linux, as raising and lowering diff --git a/dom/tests/mochitest/chrome/window_focus_docnav.xul b/dom/tests/mochitest/chrome/window_focus_docnav.xul index 7d2b59d1ccf7..2b9b62fcef2e 100644 --- a/dom/tests/mochitest/chrome/window_focus_docnav.xul +++ b/dom/tests/mochitest/chrome/window_focus_docnav.xul @@ -59,14 +59,14 @@ function done() function previous(expectedWindow, expectedElement, desc) { - synthesizeKey("VK_F6", { shiftKey: true }); + synthesizeKey("KEY_F6", {shiftKey: true}); is(fm.focusedWindow, expectedWindow, desc); is(fm.focusedElement, expectedElement, desc + " element"); } function next(expectedWindow, expectedElement, desc) { - synthesizeKey("VK_F6", { }); + synthesizeKey("KEY_F6"); is(fm.focusedWindow, expectedWindow, desc); is(fm.focusedElement, expectedElement, desc + " element" + "::" + (fm.focusedElement ? fm.focusedElement.parentNode.id : "")); } diff --git a/dom/tests/mochitest/general/test_bug1012662_common.js b/dom/tests/mochitest/general/test_bug1012662_common.js index 0d1ba29631a5..e4440802b060 100644 --- a/dom/tests/mochitest/general/test_bug1012662_common.js +++ b/dom/tests/mochitest/general/test_bug1012662_common.js @@ -272,9 +272,9 @@ function allMechanisms(aCb, aClipOverride, aNegateAll) { case 0: // Keyboard issued cutCopyAll(function docut(aSucc) { - synthesizeKey("X", {accelKey: true}); + synthesizeKey("x", {accelKey: true}); }, function docopy(aSucc) { - synthesizeKey("C", {accelKey: true}); + synthesizeKey("c", {accelKey: true}); }, function done() { testStep(n + 1); }, false, aClipOverride, aNegateAll); return; @@ -282,10 +282,10 @@ function allMechanisms(aCb, aClipOverride, aNegateAll) { // Button issued cutCopyAll(function docut(aSucc) { document.addEventListener('keydown', execCut(aSucc)); - synthesizeKey("Q", {}); + sendString("Q"); }, function docopy(aSucc) { document.addEventListener('keydown', execCopy(aSucc)); - synthesizeKey("Q", {}); + sendString("Q"); }, function done() { testStep(n + 1); }, false, aClipOverride, aNegateAll); return; diff --git a/dom/tests/mochitest/general/test_bug1170911.html b/dom/tests/mochitest/general/test_bug1170911.html index e739a0f32b4b..51b1ecaead68 100644 --- a/dom/tests/mochitest/general/test_bug1170911.html +++ b/dom/tests/mochitest/general/test_bug1170911.html @@ -30,7 +30,7 @@ function doTest() { "Cut support should have been disabled"); document.addEventListener("keydown", tryCopy); - synthesizeKey("Q", {}); + sendString("Q"); } function tryCopy(evt) { @@ -51,7 +51,7 @@ function tryCopy(evt) { /* success fn */ SimpleTest.finish, /* failure fn */ function () { document.addEventListener("keydown", tryCut); - synthesizeKey("Q", {}); + sendString("Q"); }, /* flavor */ undefined, /* timeout */ undefined, diff --git a/dom/tests/mochitest/general/test_focus_scrollchildframe.html b/dom/tests/mochitest/general/test_focus_scrollchildframe.html index 4c1b56c45889..4ab518537742 100644 --- a/dom/tests/mochitest/general/test_focus_scrollchildframe.html +++ b/dom/tests/mochitest/general/test_focus_scrollchildframe.html @@ -13,7 +13,7 @@ function doTest() { document.getElementById("button").focus(); is(window.scrollY, 0, "Scrolled position initially 0"); - synthesizeKey("VK_TAB", { }), + synthesizeKey("KEY_Tab"), ok(window.scrollY > 200, "Scrolled child frame into view"); SimpleTest.finish(); } diff --git a/dom/tests/mochitest/general/test_focusrings.xul b/dom/tests/mochitest/general/test_focusrings.xul index 2d3b08013b80..a4c4673092ac 100644 --- a/dom/tests/mochitest/general/test_focusrings.xul +++ b/dom/tests/mochitest/general/test_focusrings.xul @@ -86,7 +86,7 @@ function runTest() // after a key is pressed, the focus ring will always be visible $("l2").focus(); - synthesizeKey("VK_TAB", { }); + synthesizeKey("KEY_Tab"); checkFocus($("l3"), true, "appearance on list after tab focus"); if (isMac) { diff --git a/dom/tests/mochitest/pointerlock/file_escapeKey.html b/dom/tests/mochitest/pointerlock/file_escapeKey.html index 73715cabc392..023f1d0baff1 100644 --- a/dom/tests/mochitest/pointerlock/file_escapeKey.html +++ b/dom/tests/mochitest/pointerlock/file_escapeKey.html @@ -45,7 +45,7 @@ is(document.pointerLockElement, div, "Pointer should have been locked on #div"); document.addEventListener("pointerlockchange", unlockedPointer); addFullscreenChangeContinuation("exit", leavedFullscreen); - SimpleTest.executeSoon(() => synthesizeKey("VK_ESCAPE", {})); + SimpleTest.executeSoon(() => synthesizeKey("KEY_Escape")); } var pointerUnlocked = false; diff --git a/editor/libeditor/tests/browser_bug527935.js b/editor/libeditor/tests/browser_bug527935.js index 53f62c395d56..fa1017c36fc0 100644 --- a/editor/libeditor/tests/browser_bug527935.js +++ b/editor/libeditor/tests/browser_bug527935.js @@ -26,7 +26,7 @@ add_task(async function() { initValue.value = "foo"; }); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await ContentTask.spawn(aBrowser, {}, async function() { var window = content.window.wrappedJSObject; diff --git a/editor/libeditor/tests/test_backspace_vs.html b/editor/libeditor/tests/test_backspace_vs.html index 1ee754c95e2c..28d7ae9ef03b 100644 --- a/editor/libeditor/tests/test_backspace_vs.html +++ b/editor/libeditor/tests/test_backspace_vs.html @@ -52,7 +52,7 @@ function test(edit, bsCount) { var sel = window.getSelection(); sel.collapse(edit.childNodes[0], edit.textContent.length - 1); for (i = 0; i < bsCount; ++i) { - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); } is(edit.textContent, "ab", "The backspace key should delete the characters correctly"); } @@ -63,13 +63,11 @@ function testWithMove(edit, offset, bsCount) { sel.collapse(edit.childNodes[0], 0); var i; for (i = 0; i < offset; ++i) { - synthesizeKey("VK_RIGHT", {}); - synthesizeKey("VK_LEFT", {}); - synthesizeKey("VK_RIGHT", {}); - } - for (i = 0; i < bsCount; ++i) { - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowLeft"); + synthesizeKey("KEY_ArrowRight"); } + synthesizeKey("KEY_Backspace", {repeat: bsCount}); is(edit.textContent, "ab", "The backspace key should delete the characters correctly"); } diff --git a/editor/libeditor/tests/test_bug1094000.html b/editor/libeditor/tests/test_bug1094000.html index cc27cc67533f..0315024120f7 100644 --- a/editor/libeditor/tests/test_bug1094000.html +++ b/editor/libeditor/tests/test_bug1094000.html @@ -46,16 +46,16 @@ function runTests() "an editor having only a
element and an editor having \"a\" should be same height"); editor2.focus(); - synthesizeKey("VK_RIGHT", {}); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_Backspace"); is(editor2.innerHTML, "
", "an editor which had \"a\" should have only
element after Backspace keypress"); ok(Math.abs(editor2.getBoundingClientRect().height - editor1.getBoundingClientRect().height) <= 1, "an editor whose content was removed by Backspace key should have a place to put a caret"); editor3.focus(); - synthesizeKey("VK_LEFT", {}); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_ArrowLeft"); + synthesizeKey("KEY_Delete"); is(editor3.innerHTML, "
", "an editor which had \"b\" should have only
element after Delete keypress"); ok(Math.abs(editor3.getBoundingClientRect().height - editor1.getBoundingClientRect().height) <= 1, @@ -63,7 +63,7 @@ function runTests() editor4.focus(); window.getSelection().selectAllChildren(editor4); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); is(editor4.innerHTML, "
", "an editor which had \"c\" should have only
element after removing selected text with Backspace key"); ok(Math.abs(editor4.getBoundingClientRect().height - editor1.getBoundingClientRect().height) <= 1, @@ -71,7 +71,7 @@ function runTests() editor5.focus(); window.getSelection().selectAllChildren(editor5); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Delete"); is(editor5.innerHTML, "
", "an editor which had \"d\" should have only
element after removing selected text with Delete key"); ok(Math.abs(editor5.getBoundingClientRect().height - editor1.getBoundingClientRect().height) <= 1, @@ -79,17 +79,17 @@ function runTests() editor6.focus(); window.getSelection().selectAllChildren(editor6); - synthesizeKey("x", { accelKey: true }); + synthesizeKey("x", {accelKey: true}); is(editor6.innerHTML, "
", "an editor which had \"e\" should have only
element after removing selected text by \"Cut\""); ok(Math.abs(editor6.getBoundingClientRect().height - editor1.getBoundingClientRect().height) <= 1, "an editor whose content was selected and removed by \"Cut\" should have a place to put a caret"); editor0.focus(); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); is(editor0.innerHTML, "", "an empty editor should keep being empty even if Backspace key is pressed"); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Delete"); is(editor0.innerHTML, "", "an empty editor should keep being empty even if Delete key is pressed"); diff --git a/editor/libeditor/tests/test_bug1100966.html b/editor/libeditor/tests/test_bug1100966.html index a6ae1bbe7436..b873032f918a 100644 --- a/editor/libeditor/tests/test_bug1100966.html +++ b/editor/libeditor/tests/test_bug1100966.html @@ -33,11 +33,11 @@ SimpleTest.waitForFocus(function() { synthesizeMouseAtCenter(div, {}); getSpellChecker().UpdateCurrentDictionary(() => { - synthesizeKey(" ", {}); + sendString(" "); setTimeout(function() { - synthesizeKey("a", {}); + sendString("a"); setTimeout(function() { - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); onSpellCheck(div, function() { var sel = getSpellCheckSelection(); diff --git a/editor/libeditor/tests/test_bug1109465.html b/editor/libeditor/tests/test_bug1109465.html index dc31e9bf0378..fb80b310f1f1 100644 --- a/editor/libeditor/tests/test_bug1109465.html +++ b/editor/libeditor/tests/test_bug1109465.html @@ -28,14 +28,10 @@ SimpleTest.waitForFocus(function() { t.focus(); // Type foo\nbar and place the caret at the end of the last line - synthesizeKey("f", {}); - synthesizeKey("o", {}); - synthesizeKey("o", {}); - synthesizeKey("VK_RETURN", {}); - synthesizeKey("b", {}); - synthesizeKey("a", {}); - synthesizeKey("r", {}); - synthesizeKey("VK_UP", {}); + sendString("foo"); + synthesizeKey("KEY_Enter"); + sendString("bar"); + synthesizeKey("KEY_ArrowUp"); is(t.selectionStart, 3, "Correct start of selection"); is(t.selectionEnd, 3, "Correct end of selection"); diff --git a/editor/libeditor/tests/test_bug1140105.html b/editor/libeditor/tests/test_bug1140105.html index 4f66e6a5bf26..646e33fcf3ab 100644 --- a/editor/libeditor/tests/test_bug1140105.html +++ b/editor/libeditor/tests/test_bug1140105.html @@ -26,7 +26,7 @@ SimpleTest.waitForFocus(function() { var div = document.getElementById("content"); div.focus(); synthesizeMouseAtCenter(div, {}); - synthesizeKey("VK_LEFT", {}); + synthesizeKey("KEY_ArrowLeft"); var sel = window.getSelection(); var selRange = sel.getRangeAt(0); diff --git a/editor/libeditor/tests/test_bug1154791.html b/editor/libeditor/tests/test_bug1154791.html index 54b10dfc0c60..213d63100bc6 100644 --- a/editor/libeditor/tests/test_bug1154791.html +++ b/editor/libeditor/tests/test_bug1154791.html @@ -31,13 +31,13 @@ SimpleTest.waitForFocus(function() { div.focus(); getSpellChecker().UpdateCurrentDictionary(() => { synthesizeMouseAtCenter(div, {}); - synthesizeKey("VK_LEFT", {}); - synthesizeKey("VK_LEFT", {}); + synthesizeKey("KEY_ArrowLeft"); + synthesizeKey("KEY_ArrowLeft"); setTimeout(function() { - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); setTimeout(function() { - synthesizeKey(" ", {}); + sendString(" "); onSpellCheck(div, function() { var sel = getSpellCheckSelection(); diff --git a/editor/libeditor/tests/test_bug1162952.html b/editor/libeditor/tests/test_bug1162952.html index ad119de872a4..557f08dfb8ea 100644 --- a/editor/libeditor/tests/test_bug1162952.html +++ b/editor/libeditor/tests/test_bug1162952.html @@ -33,7 +33,7 @@ is(false, document.queryCommandEnabled('cut')); is(false, document.queryCommandEnabled('copy')); // Fire a user callback -synthesizeKey('A', {}); +sendString('A'); ok(userCallbackRun, "User callback should've been run"); diff --git a/editor/libeditor/tests/test_bug1248128.html b/editor/libeditor/tests/test_bug1248128.html index 08b0139c9c37..30c39bcff899 100644 --- a/editor/libeditor/tests/test_bug1248128.html +++ b/editor/libeditor/tests/test_bug1248128.html @@ -34,7 +34,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1248128 "scroll is unchanged: got " + outer.scrollTop + ", expected " + scroll); // Make sure cmd_moveLeft isn't failing for some unrelated reason - synthesizeKey("a", {}); + sendString("a"); is(input.selectionStart, 1, "selectionStart after typing"); SpecialPowers.doCommand(window, "cmd_moveLeft"); is(input.selectionStart, 0, "selectionStart after move left"); diff --git a/editor/libeditor/tests/test_bug1250010.html b/editor/libeditor/tests/test_bug1250010.html index d1e0154dc9eb..cd4ab438b2a9 100644 --- a/editor/libeditor/tests/test_bug1250010.html +++ b/editor/libeditor/tests/test_bug1250010.html @@ -40,11 +40,11 @@ SimpleTest.waitForFocus(function() { is(selRange.endContainer.nodeName, "#text", "selection should be at the end of text node"); is(selRange.endOffset, 10, "offset should be 10"); - synthesizeKey("VK_RETURN", {}); - synthesizeKey("VK_RETURN", {}); - synthesizeKey("b", {}); - synthesizeKey("VK_UP", {}); - synthesizeKey("a", {}); + synthesizeKey("KEY_Enter"); + synthesizeKey("KEY_Enter"); + sendString("b"); + synthesizeKey("KEY_ArrowUp"); + sendString("a"); is(div.innerHTML, "

1234567890

" + "

a

" + @@ -63,10 +63,10 @@ SimpleTest.waitForFocus(function() { // Move behind the image and press enter, insert an "A". // That should insert a new empty paragraph with the "A" after what we have. - synthesizeKey("VK_RIGHT", {}); - synthesizeKey("VK_RIGHT", {}); - synthesizeKey("VK_RETURN", {}); - synthesizeKey("A", {}); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_Enter"); + sendString("A"); // The resulting HTML is sadly less than optimal: // A
gets inserted after the image and the "A" is followed by an empty . diff --git a/editor/libeditor/tests/test_bug1257363.html b/editor/libeditor/tests/test_bug1257363.html index c1610494f25b..5dc822b35581 100644 --- a/editor/libeditor/tests/test_bug1257363.html +++ b/editor/libeditor/tests/test_bug1257363.html @@ -38,22 +38,22 @@ SimpleTest.waitForFocus(function() { is(selRange.endOffset, 5, "offset should be 5"); // Return and backspace should take us to where we started. - synthesizeKey("VK_RETURN", {}); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Enter"); + synthesizeKey("KEY_Backspace"); selRange = sel.getRangeAt(0); is(selRange.endContainer.nodeName, "#text", "selection should be at the end of text node"); is(selRange.endOffset, 5, "offset should be 5"); // Add an "a" to the end of the paragraph. - synthesizeKey("a", {}); + sendString("a"); // Return and forward delete should take us to the following line. - synthesizeKey("VK_RETURN", {}); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Enter"); + synthesizeKey("KEY_Delete"); // Add a "b" to the start. - synthesizeKey("b", {}); + sendString("b"); is(div.innerHTML, "

12345a

b67", "unexpected HTML"); @@ -70,22 +70,22 @@ SimpleTest.waitForFocus(function() { is(selRange.endOffset, 5, "offset should be 5"); // Return and backspace should take us to where we started. - synthesizeKey("VK_RETURN", {}); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Enter"); + synthesizeKey("KEY_Backspace"); selRange = sel.getRangeAt(0); is(selRange.endContainer.nodeName, "#text", "selection should be at the end of text node"); is(selRange.endOffset, 5, "offset should be 5"); // Add an "a" to the end of the paragraph. - synthesizeKey("a", {}); + sendString("a"); // Return and forward delete should take us to the following line. - synthesizeKey("VK_RETURN", {}); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Enter"); + synthesizeKey("KEY_Delete"); // Add a "b" to the start. - synthesizeKey("b", {}); + sendString("b"); // Here we get a somewhat ugly result since the red sticks. is(div.innerHTML, "

12345a

b67", @@ -103,8 +103,8 @@ SimpleTest.waitForFocus(function() { // left, enter should create a new empty paragraph before // but leave the selection at the start of the existing paragraph. - synthesizeKey("VK_LEFT", {}); - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_ArrowLeft"); + synthesizeKey("KEY_Enter"); selRange = sel.getRangeAt(0); is(selRange.endContainer.nodeName, "#text", "selection should be at the start of text node"); @@ -112,21 +112,21 @@ SimpleTest.waitForFocus(function() { is(selRange.endContainer.nodeValue, "x", "we should be in the text node with the x"); // Now moving up into the new empty paragraph. - synthesizeKey("VK_UP", {}); + synthesizeKey("KEY_ArrowUp"); selRange = sel.getRangeAt(0); is(selRange.endContainer.nodeName, "P", "selection should be the new empty paragraph"); is(selRange.endOffset, 0, "offset should be 0"); // Forward delete should now take us to where we started. - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Delete"); selRange = sel.getRangeAt(0); is(selRange.endContainer.nodeName, "#text", "selection should be at the start of text node"); is(selRange.endOffset, 0, "offset should be 0"); // Add an "a" to the start of the paragraph. - synthesizeKey("a", {}); + sendString("a"); is(div.innerHTML, "

ax

", "unexpected HTML"); @@ -143,8 +143,8 @@ SimpleTest.waitForFocus(function() { // left, enter should create a new empty paragraph before // but leave the selection at the start of the existing paragraph. - synthesizeKey("VK_LEFT", {}); - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_ArrowLeft"); + synthesizeKey("KEY_Enter"); selRange = sel.getRangeAt(0); is(selRange.endContainer.nodeName, "#text", "selection should be at the start of text node"); @@ -152,7 +152,7 @@ SimpleTest.waitForFocus(function() { is(selRange.endContainer.nodeValue, "y", "we should be in the text node with the y"); // Now moving up into the new empty paragraph. - synthesizeKey("VK_UP", {}); + synthesizeKey("KEY_ArrowUp"); selRange = sel.getRangeAt(0); is(selRange.endContainer.nodeName, "FONT", "selection should be the font tag"); @@ -160,14 +160,14 @@ SimpleTest.waitForFocus(function() { is(selRange.endContainer.parentNode.nodeName, "P", "the parent of the font should be a paragraph"); // Forward delete should now take us to where we started. - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Delete"); selRange = sel.getRangeAt(0); is(selRange.endContainer.nodeName, "#text", "selection should be at the start of text node"); is(selRange.endOffset, 0, "offset should be 0"); // Add an "a" to the start of the paragraph. - synthesizeKey("a", {}); + sendString("a"); is(div.innerHTML, "

ay

", "unexpected HTML"); diff --git a/editor/libeditor/tests/test_bug1258085.html b/editor/libeditor/tests/test_bug1258085.html index 342f068ee253..91a54078fff3 100644 --- a/editor/libeditor/tests/test_bug1258085.html +++ b/editor/libeditor/tests/test_bug1258085.html @@ -10,7 +10,7 @@ var div = document.querySelector("div"); function reset() { div.innerHTML = "x
y"; div.focus(); - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); } function checks(msg) { @@ -27,34 +27,34 @@ SimpleTest.waitForExplicitFinish(); SimpleTest.waitForFocus(function() { // Put selection after the "y" and backspace reset(); - synthesizeKey("VK_RIGHT", {}); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_Backspace"); checks("Collapsed backspace"); // Now do the same with delete reset(); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Delete"); checks("Collapsed delete"); // Forward selection reset(); - synthesizeKey("VK_RIGHT", {shiftKey: true}); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_ArrowRight", {shiftKey: true}); + synthesizeKey("KEY_Backspace"); checks("Forward-selected backspace"); // Backward selection reset(); - synthesizeKey("VK_RIGHT", {}); - synthesizeKey("VK_LEFT", {shiftKey: true}); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowLeft", {shiftKey: true}); + synthesizeKey("KEY_Backspace"); checks("Backward-selected backspace"); // Make sure we're not deleting if the whitespace isn't actually collapsed div.style.whiteSpace = "pre-wrap"; reset(); - synthesizeKey("VK_RIGHT", {}); - synthesizeKey("VK_RIGHT", {}); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_Backspace"); if (div.innerHTML, "x
", "pre-wrap: Don't delete uncollapsed space"); ok(getSelection().isCollapsed, "pre-wrap: Selection must be collapsed"); is(getSelection().focusNode, div.lastChild, diff --git a/editor/libeditor/tests/test_bug1270235.html b/editor/libeditor/tests/test_bug1270235.html index da7fd4e7acb4..f60232e95671 100644 --- a/editor/libeditor/tests/test_bug1270235.html +++ b/editor/libeditor/tests/test_bug1270235.html @@ -37,7 +37,7 @@ SimpleTest.waitForFocus(()=>{ ok(selection.isCollapsed, 'isCollapsed must be true'); // Don't crash by user input - synthesizeKey("X", {}); + sendString("X"); SimpleTest.finish(); }); diff --git a/editor/libeditor/tests/test_bug1314790.html b/editor/libeditor/tests/test_bug1314790.html index ff1487244b1c..83ff58ef5965 100644 --- a/editor/libeditor/tests/test_bug1314790.html +++ b/editor/libeditor/tests/test_bug1314790.html @@ -29,16 +29,8 @@ SimpleTest.waitForFocus(function() { SpecialPowers.doCommand(window, "cmd_wordNext"); SpecialPowers.doCommand(window, "cmd_wordNext"); - synthesizeKey("VK_RETURN", {}); - synthesizeKey("a", {}); - synthesizeKey("p", {}); - synthesizeKey("p", {}); - synthesizeKey("l", {}); - synthesizeKey("e", {}); - synthesizeKey(" ", {}); - synthesizeKey("p", {}); - synthesizeKey("e", {}); - synthesizeKey("n", {}); + synthesizeKey("KEY_Enter"); + sendString("apple pen"); is(elm.childNodes[0].textContent, "pen pineapple", "'pen pineapple' is first elment"); diff --git a/editor/libeditor/tests/test_bug1315065.html b/editor/libeditor/tests/test_bug1315065.html index 4e26a7003c36..661b02f25a1b 100644 --- a/editor/libeditor/tests/test_bug1315065.html +++ b/editor/libeditor/tests/test_bug1315065.html @@ -60,7 +60,7 @@ SimpleTest.waitForFocus(()=>{ "Backspace from " + i + "th empty text node"; editor.focus(); initForBackspace(i); - synthesizeKey("KEY_Backspace", {}); + synthesizeKey("KEY_Backspace"); var p = document.getElementById("p"); ok(p, kDescription + ":

element shouldn't be removed by Backspace key press"); is(p.tagName.toLowerCase(), "p", kDescription + ":

element shouldn't be removed by Backspace key press"); @@ -117,7 +117,7 @@ SimpleTest.waitForFocus(()=>{ "Delete from " + i + "th empty text node"; editor.focus(); initForDelete(i); - synthesizeKey("KEY_Delete", {}); + synthesizeKey("KEY_Delete"); var p = document.getElementById("p"); ok(p, kDescription + ":

element shouldn't be removed by Delete key press"); is(p.tagName.toLowerCase(), "p", kDescription + ":

element shouldn't be removed by Delete key press"); diff --git a/editor/libeditor/tests/test_bug1316302.html b/editor/libeditor/tests/test_bug1316302.html index 3476a8301b21..b6f70a42d2f0 100644 --- a/editor/libeditor/tests/test_bug1316302.html +++ b/editor/libeditor/tests/test_bug1316302.html @@ -31,7 +31,7 @@ SimpleTest.waitForFocus(()=>{ ok(range.collapsed, "range should be collapsed at the end of

"); is(range.startContainer, blockquote, "range should be collapsed in the
"); is(range.startOffset, blockquote.childNodes.length, "range should be collapsed at the end"); - synthesizeKey("KEY_Backspace", {}); + synthesizeKey("KEY_Backspace"); is(blockquote.innerHTML, "

ab

", "Pressing Backspace key at the end of
should remove the last character in the

"); // Try to remove the first character from the start of the

@@ -40,7 +40,7 @@ SimpleTest.waitForFocus(()=>{ ok(range.collapsed, "range should be collapsed at the start of
"); is(range.startContainer, blockquote, "range should be collapsed in the
"); is(range.startOffset, 0, "range should be collapsed at the start"); - synthesizeKey("KEY_Delete", {}); + synthesizeKey("KEY_Delete"); is(blockquote.innerHTML, "

b

", "Pressing Delete key at the start of
should remove the first character in the

"); SimpleTest.finish(); diff --git a/editor/libeditor/tests/test_bug1318312.html b/editor/libeditor/tests/test_bug1318312.html index 7b8ef9ee91ab..9e560ac30223 100644 --- a/editor/libeditor/tests/test_bug1318312.html +++ b/editor/libeditor/tests/test_bug1318312.html @@ -29,7 +29,7 @@ function runTests() // at least for now because user can move focus with ArrowUp key even from // innerEditor to outerEditor but we don't allow such navigation. // FYI: Edge behaves same as us. - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); is(document.activeElement, outerEditor, "outerEditor should still have focus because focus shouldn't be moved by moving caret"); is(document.getSelection().focusNode, document.getElementById("innerEditor").firstChild.firstChild, @@ -37,7 +37,7 @@ function runTests() is(document.getSelection().focusOffset, 0, "focus offset of selection should be 0"); - synthesizeKey("a", {}); + sendString("a"); is(document.activeElement, outerEditor, "outerEditor should still have focus because focus shouldn't be moved by typing a character"); is(document.getSelection().focusNode, document.getElementById("innerEditor").firstChild.firstChild, @@ -45,7 +45,7 @@ function runTests() is(document.getSelection().focusOffset, 1, "focus offset of selection should be 1"); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); is(document.activeElement, outerEditor, "outerEditor should still have focus because focus shouldn't be moved by typing Enter"); is(document.getSelection().focusNode, document.getElementById("innerEditor").childNodes.item(1).firstChild, @@ -53,7 +53,7 @@ function runTests() is(document.getSelection().focusOffset, 0, "focus offset of selection should be 0"); - synthesizeKey("KEY_Backspace", {}); + synthesizeKey("KEY_Backspace"); is(document.activeElement, outerEditor, "outerEditor should still have focus because focus shouldn't be moved by typing Backspace (removing the line breaker)"); is(document.getSelection().focusNode, document.getElementById("innerEditor").firstChild.firstChild, @@ -73,7 +73,7 @@ function runTests() is(document.getSelection().anchorOffset, 1, "anchor offset of selection should be 1"); - synthesizeKey("KEY_Delete", {}); + synthesizeKey("KEY_Delete"); is(document.activeElement, outerEditor, "outerEditor should still have focus because focus shouldn't be moved by typing Delete (removing the 'a')"); is(document.getSelection().focusNode, document.getElementById("innerEditor").firstChild.firstChild, @@ -81,7 +81,7 @@ function runTests() is(document.getSelection().focusOffset, 0, "focus offset of selection should be 0"); - synthesizeKey("KEY_ArrowUp", {}); + synthesizeKey("KEY_ArrowUp"); is(document.activeElement, outerEditor, "outerEditor should still have focus because focus shouldn't be moved by moving caret from innerEditor to outerEditor"); is(document.getSelection().focusNode, document.getElementById("outerEditor").firstChild.firstChild, diff --git a/editor/libeditor/tests/test_bug1328023.html b/editor/libeditor/tests/test_bug1328023.html index 1b7fb7bf5618..e0643124d9aa 100644 --- a/editor/libeditor/tests/test_bug1328023.html +++ b/editor/libeditor/tests/test_bug1328023.html @@ -25,26 +25,23 @@ SimpleTest.waitForFocus(function() { let elm = document.getElementById("input1"); elm.focus(); - synthesizeKey("A", {}); - synthesizeKey("B", {}); + sendString("AB"); is(elm.value, "AB", "AB is input.value now"); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); is(elm.value, "A", "A is input.value now"); synthesizeKey("Z", { accelKey: true }); is(elm.value, "AB", "AB is input.value now"); - synthesizeKey("C", {}); + sendString("C"); is(elm.value, "ABC", "ABC is input.value now"); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); + synthesizeKey("KEY_Backspace"); + synthesizeKey("KEY_Backspace"); - synthesizeKey("A", {}); - synthesizeKey("B", {}); - synthesizeKey("C", {}); + sendString("ABC"); is(elm.value, "ABC", "ABC is input.value now"); synthesizeKey("Z", { accelKey: true }); @@ -53,7 +50,7 @@ SimpleTest.waitForFocus(function() { synthesizeKey("Z", { accelKey: true, shiftKey: true }); is(elm.value, "ABC", "ABC is input.value now"); - synthesizeKey("D", {}); + sendString("D"); is(elm.value, "ABCD", "ABCD is input.value now"); SimpleTest.finish(); diff --git a/editor/libeditor/tests/test_bug1330796.html b/editor/libeditor/tests/test_bug1330796.html index def2372357f6..a6ed950be297 100644 --- a/editor/libeditor/tests/test_bug1330796.html +++ b/editor/libeditor/tests/test_bug1330796.html @@ -75,8 +75,8 @@ SimpleTest.waitForFocus(function() { // Position set at the beginning , middle and end of the text. sel.collapse(theText, tests[i][1]); - synthesizeKey("KEY_Enter", {}); - synthesizeKey("x", {}); + synthesizeKey("KEY_Enter"); + sendString("x"); is(theEdit.innerHTML, tests[i][2], "unexpected HTML for test " + i.toString()); } diff --git a/editor/libeditor/tests/test_bug1352799.html b/editor/libeditor/tests/test_bug1352799.html index ec3b7c241150..18e90f5a097e 100644 --- a/editor/libeditor/tests/test_bug1352799.html +++ b/editor/libeditor/tests/test_bug1352799.html @@ -31,9 +31,7 @@ SimpleTest.waitForFocus(() => { input.focus(); - synthesizeKey('1', {}); - synthesizeKey('2', {}); - synthesizeKey('3', {}); + sendString("123"); is(input.value, '12', 'value should be 12 with maxlength = 2'); @@ -46,11 +44,7 @@ SimpleTest.waitForFocus(() => { input.focus(); - synthesizeKey('4', {}); - synthesizeKey('5', {}); - synthesizeKey('6', {}); - synthesizeKey('7', {}); - synthesizeKey('8', {}); + sendString("45678"); is(input.value, '4567', 'value should be 4567 with maxlength = 4'); @@ -62,8 +56,7 @@ SimpleTest.waitForFocus(() => { input.focus(); - synthesizeKey('1', {}); - synthesizeKey('2', {}); + sendString("12"); todo_is(input.value, '45', 'value should be 45 with maxlength = 2'); @@ -76,14 +69,7 @@ SimpleTest.waitForFocus(() => { input.focus(); - synthesizeKey('1', {}); - synthesizeKey('2', {}); - synthesizeKey('3', {}); - synthesizeKey('4', {}); - synthesizeKey('5', {}); - synthesizeKey('6', {}); - synthesizeKey('7', {}); - synthesizeKey('8', {}); + sendString("12345678"); is(input.value, '12345678', 'value should be 12345678 without maxlength'); diff --git a/editor/libeditor/tests/test_bug1361008.html b/editor/libeditor/tests/test_bug1361008.html index 407254a85971..c2391d12c7fc 100644 --- a/editor/libeditor/tests/test_bug1361008.html +++ b/editor/libeditor/tests/test_bug1361008.html @@ -28,9 +28,8 @@ SimpleTest.waitForFocus(() => { let selection = window.getSelection(); // Insert text before BR element selection.collapse(edit1, 0); - synthesizeKey("A", {}); - synthesizeKey("B", {}); - synthesizeKey("VK_RETURN", {}); + sendString("AB"); + synthesizeKey("KEY_Enter"); // count

element into contenteidable is(edit1.getElementsByTagName('div').length, 2, "DIV element should be 2 children"); @@ -44,9 +43,8 @@ SimpleTest.waitForFocus(() => { edit2.focus(); selection.collapse(edit2, 0); // Insert text before BR element - synthesizeKey("A", {}); - synthesizeKey("B", {}); - synthesizeKey("VK_RETURN", {}); + sendString("AB"); + synthesizeKey("KEY_Enter"); is(edit2.getElementsByTagName('p').length, 2, "P element should be 2 children"); diff --git a/editor/libeditor/tests/test_bug1368544.html b/editor/libeditor/tests/test_bug1368544.html index 23e1915d83bf..7d3173c612ba 100644 --- a/editor/libeditor/tests/test_bug1368544.html +++ b/editor/libeditor/tests/test_bug1368544.html @@ -36,7 +36,7 @@ SimpleTest.waitForFocus(() => { textarea.value = "ABC"; ok(editor.rootElement.hasChildNodes(), "editor of textarea has child nodes"); - synthesizeKey("D", {}); + sendString("D"); is(textarea.value, "ABCD", "D is last character"); ok(editor.rootElement.hasChildNodes(), "editor of textarea has child nodes"); @@ -44,12 +44,8 @@ SimpleTest.waitForFocus(() => { ok(editor.rootElement.hasChildNodes(), "editor of textarea has child node even if value is empty"); - synthesizeKey("A", {}); - synthesizeKey("A", {}); - synthesizeKey("A", {}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); + sendString("AAA"); + synthesizeKey("KEY_Backspace", {repeat: 3}); is(textarea.value, "", "value is empty"); ok(editor.rootElement.hasChildNodes(), "editor of textarea has child node even if value is empty"); @@ -60,15 +56,12 @@ SimpleTest.waitForFocus(() => { "editor of textarea has child node even if value is empty"); textarea.value = "ABC"; - synthesizeKey("VK_RETURN", {}); - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter", {repeat: 2}); textarea.value = ""; ok(editor.rootElement.hasChildNodes(), "editor of textarea has child node even if value is empty"); - synthesizeKey("A", {}); - synthesizeKey("A", {}); - synthesizeKey("A", {}); + sendString("AAA"); is(textarea.value, "AAA", "value is AAA"); textarea.addEventListener("keyup", (e) => { if (e.key == "Enter") { @@ -79,7 +72,7 @@ SimpleTest.waitForFocus(() => { } }); - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); }); }); }); diff --git a/editor/libeditor/tests/test_bug1385905.html b/editor/libeditor/tests/test_bug1385905.html index 33e85e060c0e..f9fdff31894d 100644 --- a/editor/libeditor/tests/test_bug1385905.html +++ b/editor/libeditor/tests/test_bug1385905.html @@ -28,19 +28,19 @@ SimpleTest.waitForFocus(() => { var editor = document.getElementById("editor"); // Click the left blank area of the first line to set cursor to the start of "contents". synthesizeMouse(editor, 3, 10, {}); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); is(editor.innerHTML, "

contents
", "Typing Enter at start of the
element should split the
element"); - synthesizeKey("KEY_ArrowUp", {}); - synthesizeKey("x", {}); + synthesizeKey("KEY_ArrowUp"); + sendString("x"); is(editor.innerHTML, "
x
contents
", "Typing 'x' at the empty
element should just insert 'x' into the
element"); ensureNoMozBR(); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); is(editor.innerHTML, "
x

contents
", "Typing Enter next to 'x' in the first
element should split the
element and inserts
element to a new
element"); ensureNoMozBR(); - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); is(editor.innerHTML, "
x


contents
", "Typing Enter in the empty
should split the
element and inserts
element to a new
element"); ensureNoMozBR(); diff --git a/editor/libeditor/tests/test_bug1390562.html b/editor/libeditor/tests/test_bug1390562.html index 743906b53b25..57187798b7be 100644 --- a/editor/libeditor/tests/test_bug1390562.html +++ b/editor/libeditor/tests/test_bug1390562.html @@ -37,7 +37,7 @@ SimpleTest.waitForFocus(function() { // This is necessary for backward compatibility. When we change default // value of "defaultParagraphSeparator" to "div" or "p", it may be possible // to remove this hack. - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); is(editor.innerHTML, "
abc


def", @@ -53,7 +53,7 @@ SimpleTest.waitForFocus(function() { //
element next to the caret position. // This is not consistent with
container, but this is better behavior // and keep using this behavior. - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); is(editor.innerHTML, "

abc


def", diff --git a/editor/libeditor/tests/test_bug1394758.html b/editor/libeditor/tests/test_bug1394758.html index d201af43708c..bd72a6de99dc 100644 --- a/editor/libeditor/tests/test_bug1394758.html +++ b/editor/libeditor/tests/test_bug1394758.html @@ -33,18 +33,18 @@ SimpleTest.waitForFocus(function() { editable.focus(); window.getSelection().collapse(span.nextSibling, 0); - synthesizeKey("KEY_ArrowRight", {}); - synthesizeKey("KEY_ArrowRight", {}); - synthesizeKey("KEY_ArrowRight", {}); - synthesizeKey("KEY_Backspace", {}); - synthesizeKey("KEY_Backspace", {}); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_Backspace"); + synthesizeKey("KEY_Backspace"); is(span.textContent, beforeSpan, "VK_BACK_SPACE should not modify non-editable area"); is(span.nextSibling.textContent.trim(), "rld", "VK_BACK_SPACE should delete first 2 characters"); - synthesizeKey("KEY_Delete", {}); + synthesizeKey("KEY_Delete"); is(span.textContent, beforeSpan, "VK_DELETE should not modify non-editable area"); diff --git a/editor/libeditor/tests/test_bug1397412.xul b/editor/libeditor/tests/test_bug1397412.xul index 1964e04dd91d..7fe0c336408e 100644 --- a/editor/libeditor/tests/test_bug1397412.xul +++ b/editor/libeditor/tests/test_bug1397412.xul @@ -49,14 +49,14 @@ function runTest() { // Test 1. body.innerHTML = initialHTML1; selection.collapse(body, 2); - synthesizeKey("t", {}); + sendString("t"); var actualHTML = body.innerHTML; is(actualHTML, expectedHTML1, "'t' should be inserted between
s"); // Test 2. body.innerHTML = initialHTML2; selection.collapse(body, 2); - synthesizeKey("t", {}); + sendString("t"); actualHTML = body.innerHTML; is(actualHTML, expectedHTML2, "'t' should be inserted between
s"); diff --git a/editor/libeditor/tests/test_bug1399722.html b/editor/libeditor/tests/test_bug1399722.html index 3d4805718575..2ccec0b8d29f 100644 --- a/editor/libeditor/tests/test_bug1399722.html +++ b/editor/libeditor/tests/test_bug1399722.html @@ -25,11 +25,9 @@ SimpleTest.waitForFocus(function() { let elm = document.querySelector("input"); elm.focus(); - synthesizeKey("A", {}); - synthesizeKey("B", {}); - synthesizeKey("KEY_Enter", {}); - synthesizeKey("C", {}); - synthesizeKey("D", {}); + sendString("AB"); + synthesizeKey("KEY_Enter"); + sendString("CD"); is(elm.value, "CD", "Can type into the textbox successfully after the onkeypress handler deleting the value"); SimpleTest.finish(); diff --git a/editor/libeditor/tests/test_bug318065.html b/editor/libeditor/tests/test_bug318065.html index f3f4445a1d1b..e734106f7c89 100644 --- a/editor/libeditor/tests/test_bug318065.html +++ b/editor/libeditor/tests/test_bug318065.html @@ -53,8 +53,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=318065 input.focus(); // Tests 0 + 1: Input letter and delete it again - synthesizeKey("A", {}); - synthesizeKey("VK_BACK_SPACE", {}); + sendString("A"); + synthesizeKey("KEY_Backspace"); // Test 2: Undo deletion. Value of input should be "A" synthesizeKey("Z", {accelKey: true}); @@ -65,7 +65,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=318065 input2.focus(); // Test 4: Input letter - synthesizeKey("A", {}); + sendString("A"); // Test 5: Undo typing. Value of input should be "" synthesizeKey("Z", {accelKey: true}); diff --git a/editor/libeditor/tests/test_bug332636.html b/editor/libeditor/tests/test_bug332636.html index 5df386ac4b08..de5d57f1cf74 100644 --- a/editor/libeditor/tests/test_bug332636.html +++ b/editor/libeditor/tests/test_bug332636.html @@ -35,7 +35,7 @@ function test(edit) { edit.focus(); var sel = window.getSelection(); sel.collapse(edit.childNodes[0], edit.textContent.length - 1); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); is(edit.textContent, "ab", "The backspace key should delete the UTF-16 surrogate pair correctly"); } @@ -45,11 +45,11 @@ function testWithMove(edit, offset) { sel.collapse(edit.childNodes[0], 0); var i; for (i = 0; i < offset; ++i) { - synthesizeKey("VK_RIGHT", {}); - synthesizeKey("VK_LEFT", {}); - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowLeft"); + synthesizeKey("KEY_ArrowRight"); } - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); is(edit.textContent, "ab", "The backspace key should delete the UTF-16 surrogate pair correctly"); } diff --git a/editor/libeditor/tests/test_bug414526.html b/editor/libeditor/tests/test_bug414526.html index 67b2c4aae835..af063325d823 100644 --- a/editor/libeditor/tests/test_bug414526.html +++ b/editor/libeditor/tests/test_bug414526.html @@ -80,28 +80,28 @@ function runTests() */ editor2.focus(); moveCaretToStartOf(editor2); - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_Backspace"); is(container.innerHTML, kTestCase1, "Pressing backspace key at start of editor2 changes the content"); reset(); editor3.focus(); moveCaretToStartOf(editor3); - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_Backspace"); is(container.innerHTML, kTestCase1, "Pressing backspace key at start of editor3 changes the content"); reset(); editor4.focus(); moveCaretToStartOf(editor4); - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_Backspace"); is(container.innerHTML, kTestCase1, "Pressing backspace key at start of editor4 changes the content"); reset(); editor5.focus(); moveCaretToStartOf(editor5); - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_Backspace"); is(container.innerHTML, kTestCase1, "Pressing backspace key at start of editor5 changes the content"); reset(); @@ -111,28 +111,28 @@ function runTests() */ editor1.focus(); moveCaretToEndOf(editor1); - synthesizeKey("VK_DELETE", { }); + synthesizeKey("KEY_Delete"); is(container.innerHTML, kTestCase1, "Pressing delete key at end of editor1 changes the content"); reset(); editor2.focus(); moveCaretToEndOf(editor2); - synthesizeKey("VK_DELETE", { }); + synthesizeKey("KEY_Delete"); is(container.innerHTML, kTestCase1, "Pressing delete key at end of editor2 changes the content"); reset(); editor3.focus(); moveCaretToEndOf(editor3); - synthesizeKey("VK_DELETE", { }); + synthesizeKey("KEY_Delete"); is(container.innerHTML, kTestCase1, "Pressing delete key at end of editor3 changes the content"); reset(); editor4.focus(); moveCaretToEndOf(editor4); - synthesizeKey("VK_DELETE", { }); + synthesizeKey("KEY_Delete"); is(container.innerHTML, kTestCase1, "Pressing delete key at end of editor4 changes the content"); reset(); @@ -144,7 +144,7 @@ function runTests() */ editor3.focus(); moveCaretToStartOf(editor3); - synthesizeKey("VK_DELETE", { }); + synthesizeKey("KEY_Delete"); is(container.innerHTML, kTestCase1_editor3_deleteAtStart, "Pressing delete key at start of editor3 changes adjacent elements" + " and/or does not remove the first character."); @@ -152,7 +152,7 @@ function runTests() editor3.focus(); moveCaretToEndOf(editor3); - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_Backspace"); is(container.innerHTML, kTestCase1_editor3_backspaceAtEnd, "Pressing backspace key at end of editor3 changes adjacent elements" + " and/or does not remove the last character."); @@ -170,14 +170,14 @@ function runTests() editor2.focus(); moveCaretToStartOf(editor2); - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_Backspace"); is(container.innerHTML, kTestCase2, "Pressing backspace key at the start of editor2 changes the content for kTestCase2"); reset(); editor1.focus(); moveCaretToEndOf(editor1); - synthesizeKey("VK_DELETE", { }); + synthesizeKey("KEY_Delete"); is(container.innerHTML, kTestCase2, "Pressing delete key at the end of editor1 changes the content for kTestCase2"); reset(); @@ -194,14 +194,14 @@ function runTests() editor2.focus(); moveCaretToStartOf(editor2); - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_Backspace"); is(container.innerHTML, kTestCase3, "Pressing backspace key at the start of editor2 changes the content for kTestCase3"); reset(); editor1.focus(); moveCaretToEndOf(editor1); - synthesizeKey("VK_DELETE", { }); + synthesizeKey("KEY_Delete"); is(container.innerHTML, kTestCase3, "Pressing delete key at the end of editor1 changes the content for kTestCase3"); reset(); @@ -218,14 +218,14 @@ function runTests() editor2.focus(); moveCaretToStartOf(editor2); - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_Backspace"); is(container.innerHTML, kTestCase4, "Pressing backspace key at the start of editor2 changes the content for kTestCase4"); reset(); editor1.focus(); moveCaretToEndOf(editor1); - synthesizeKey("VK_DELETE", { }); + synthesizeKey("KEY_Delete"); is(container.innerHTML, kTestCase4, "Pressing delete key at the end of editor1 changes the content for kTestCase4"); reset(); diff --git a/editor/libeditor/tests/test_bug430392.html b/editor/libeditor/tests/test_bug430392.html index 4e45586ab09b..7697912c94a9 100644 --- a/editor/libeditor/tests/test_bug430392.html +++ b/editor/libeditor/tests/test_bug430392.html @@ -33,21 +33,21 @@ function test() { // it's neither the original value nor expectedValue. var tests = [["adding returns", () => { getSelection().collapse(edit.firstChild, 0); - synthesizeKey("VK_RIGHT", {}); - synthesizeKey("VK_RETURN", {}); - synthesizeKey("VK_RETURN", {}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_Enter"); + synthesizeKey("KEY_Enter"); + synthesizeKey("KEY_Backspace"); + synthesizeKey("KEY_Backspace"); // For some reason this test fails if the separator is not "br" }, () => document.queryCommandValue("defaultParagraphSeparator") == "br" ? undefined : " A; B ; C "], ["adding shift-returns", () => { getSelection().collapse(edit.firstChild, 0); - synthesizeKey("VK_RIGHT", {}); - synthesizeKey("VK_RETURN", {shiftKey: true}); - synthesizeKey("VK_RETURN", {shiftKey: true}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_Enter", {shiftKey: true}); + synthesizeKey("KEY_Enter", {shiftKey: true}); + synthesizeKey("KEY_Backspace"); + synthesizeKey("KEY_Backspace"); }, "A ; B ; C "]]; [ "insertorderedlist", diff --git a/editor/libeditor/tests/test_bug439808.html b/editor/libeditor/tests/test_bug439808.html index a04d1d4d47cb..46ae2ce5cdfc 100644 --- a/editor/libeditor/tests/test_bug439808.html +++ b/editor/libeditor/tests/test_bug439808.html @@ -24,9 +24,9 @@ SimpleTest.waitForFocus(function() { var e = document.getElementById("e"); e.focus(); getSelection().collapse(e.firstChild, 1); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Delete"); is(e.textContent, "test", "Delete key worked"); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); is(e.textContent, "est", "Backspace key worked"); SimpleTest.finish(); }); diff --git a/editor/libeditor/tests/test_bug449243.html b/editor/libeditor/tests/test_bug449243.html index b29dfac094a0..ff225b56ff37 100644 --- a/editor/libeditor/tests/test_bug449243.html +++ b/editor/libeditor/tests/test_bug449243.html @@ -55,7 +55,7 @@ function split(element, caretPos, nbKeyPresses) { // simulates a [Return] keypress for (var i = 0; i < nbKeyPresses; i++) - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); } function undo(nbKeyPresses) { diff --git a/editor/libeditor/tests/test_bug483651.html b/editor/libeditor/tests/test_bug483651.html index 52555d53aa82..dfd12e11b024 100644 --- a/editor/libeditor/tests/test_bug483651.html +++ b/editor/libeditor/tests/test_bug483651.html @@ -33,8 +33,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=483651 ok(editor, "able to get editor for the element"); t1.focus(); - synthesizeKey("A", {}); - synthesizeKey("VK_BACK_SPACE", {}); + sendString("A"); + synthesizeKey("KEY_Backspace"); try { // Was the trailing br removed? diff --git a/editor/libeditor/tests/test_bug484181.html b/editor/libeditor/tests/test_bug484181.html index 81ffa6418ef7..bb107612e348 100644 --- a/editor/libeditor/tests/test_bug484181.html +++ b/editor/libeditor/tests/test_bug484181.html @@ -42,10 +42,7 @@ function append(str) { var sel = editor.selection; sel.selectAllChildren(edit); sel.collapseToEnd(); - - for (var i = 0; i < str.length; ++i) { - synthesizeKey(str[i], {}); - } + sendString(str); } function runTest() { diff --git a/editor/libeditor/tests/test_bug514156.html b/editor/libeditor/tests/test_bug514156.html index 3594d1c8d8b3..515bed70406c 100644 --- a/editor/libeditor/tests/test_bug514156.html +++ b/editor/libeditor/tests/test_bug514156.html @@ -27,17 +27,13 @@ SimpleTest.waitForExplicitFinish(); function test() { var input1 = $("input1"); input1.focus(); - synthesizeKey("\u200e", { }); - synthesizeKey("\u05d0", { }); - synthesizeKey("\u05d1", { }); + sendString("\u200e\u05d0\u05d1"); is(escape(input1.value), escape("\u200e\u05d0\u05d1"), "non-spacing character and direction change shouldn't change content"); var input2 = $("input2"); input2.focus(); - synthesizeKey("\u05b6", { }); - synthesizeKey("a", { }); - synthesizeKey("b", { }); - synthesizeKey("c", { }); + sendString("\u05b6"); + sendString("abc"); is(escape(input2.value), escape("\u05b6abc"), "non-spacing character and direction change shouldn't change content"); SimpleTest.finish(); diff --git a/editor/libeditor/tests/test_bug537046.html b/editor/libeditor/tests/test_bug537046.html index 0d3141d80525..ab49df9810b5 100644 --- a/editor/libeditor/tests/test_bug537046.html +++ b/editor/libeditor/tests/test_bug537046.html @@ -36,8 +36,8 @@ addLoadEvent(function() { // Simulate pressing Enter twice ed.focus(); - synthesizeKey("VK_RETURN", {}); - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); + synthesizeKey("KEY_Enter"); ok(true, "Didn't crash!"); SimpleTest.finish(); diff --git a/editor/libeditor/tests/test_bug550434.html b/editor/libeditor/tests/test_bug550434.html index 0fa3ad15906b..f6b99a226811 100644 --- a/editor/libeditor/tests/test_bug550434.html +++ b/editor/libeditor/tests/test_bug550434.html @@ -29,7 +29,7 @@ SimpleTest.waitForFocus(function() { synthesizeMouse(ed, 10, 10, {}); synthesizeMouse(ed, 50, 50, {}); setTimeout(function() { - synthesizeKey("x", {}); + sendString("x"); is(ed.innerHTML, "x", "Editor should work after being clicked twice"); SimpleTest.finish(); diff --git a/editor/libeditor/tests/test_bug551704.html b/editor/libeditor/tests/test_bug551704.html index d42d541bfd30..1672a408504c 100644 --- a/editor/libeditor/tests/test_bug551704.html +++ b/editor/libeditor/tests/test_bug551704.html @@ -54,22 +54,19 @@ function testLineBreak(div, type, expectedText, expectedHTML, callback) } function typeABCDEF() { - synthesizeKey("a", {}); + sendString("a"); typeBCDEF_chars(); } function typeBCDEF() { - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowRight"); typeBCDEF_chars(); } function typeBCDEF_chars() { - synthesizeKey("b", {}); - synthesizeKey("c", {}); - synthesizeKey("VK_RETURN", {}); - synthesizeKey("d", {}); - synthesizeKey("e", {}); - synthesizeKey("f", {}); + sendString("bc"); + synthesizeKey("KEY_Enter"); + sendString("def"); } /** Test for Bug 551704 **/ diff --git a/editor/libeditor/tests/test_bug567213.html b/editor/libeditor/tests/test_bug567213.html index 22418f9e2521..32adce00947f 100644 --- a/editor/libeditor/tests/test_bug567213.html +++ b/editor/libeditor/tests/test_bug567213.html @@ -37,7 +37,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=567213 target.focus(); // press some key - synthesizeKey("X", {}); + sendString("X"); is(target.textContent, "X", "Text input should work (sanity check)"); // select the contents of the editable area again @@ -46,7 +46,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=567213 thief.focus(); // press some key with the thief having focus - synthesizeKey("Y", {}); + sendString("Y"); is(target.textContent, "X", "Text entry should not work with another element focused"); SimpleTest.finish(); diff --git a/editor/libeditor/tests/test_bug570144.html b/editor/libeditor/tests/test_bug570144.html index e3b98b8d62d9..cc3178b0060a 100644 --- a/editor/libeditor/tests/test_bug570144.html +++ b/editor/libeditor/tests/test_bug570144.html @@ -72,8 +72,8 @@ function try2split(list) { else selection.selectAllChildren(editor.querySelector("p")); selection.collapseToEnd(); - // simulate a [Return] keypress - synthesizeKey("VK_RETURN", {}); + // simulate a [Enter] keypress + synthesizeKey("KEY_Enter"); } function testSection(element, context, shouldCreateLI, shouldCreateP) { diff --git a/editor/libeditor/tests/test_bug586662.html b/editor/libeditor/tests/test_bug586662.html index a3039f4d6bd2..066b428c8655 100644 --- a/editor/libeditor/tests/test_bug586662.html +++ b/editor/libeditor/tests/test_bug586662.html @@ -24,7 +24,7 @@ SimpleTest.waitForExplicitFinish(); SimpleTest.waitForFocus(function() { var t = document.querySelector("textarea"); t.focus(); - synthesizeKey("a", {}); + sendString("a"); is(getComputedStyle(t, null).overflow, "hidden", "The event handler should be executed"); is(t.value, "a", "The key entry should result in a character being added to the field"); diff --git a/editor/libeditor/tests/test_bug590554.html b/editor/libeditor/tests/test_bug590554.html index bc98503ed031..d6743aadf2aa 100644 --- a/editor/libeditor/tests/test_bug590554.html +++ b/editor/libeditor/tests/test_bug590554.html @@ -22,9 +22,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=590554 SimpleTest.waitForFocus(function() { var t = document.querySelector("textarea"); t.focus(); - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); is(t.value, "\n", "Pressing enter should work the first time"); - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); is(t.value, "\n", "Pressing enter should not work the second time"); SimpleTest.finish(); }); diff --git a/editor/libeditor/tests/test_bug592592.html b/editor/libeditor/tests/test_bug592592.html index 834ecbe1d04c..69c9aaa5cfcc 100644 --- a/editor/libeditor/tests/test_bug592592.html +++ b/editor/libeditor/tests/test_bug592592.html @@ -30,7 +30,7 @@ SimpleTest.waitForFocus(function() { window.getSelection().collapse(ed.firstChild, 1); // Press space - synthesizeKey(" ", {}); + sendString(" "); // Make sure we haven't added an nbsp is(ed.innerHTML, "a b", "We should not be adding an   for preformatted text"); @@ -46,7 +46,7 @@ SimpleTest.waitForFocus(function() { window.getSelection().collapse(ed.firstChild, 1); // Press space - synthesizeKey(" ", {}); + sendString(" "); // Make sure that we have added an nbsp is(ed.innerHTML, "a  b", "We should add an   for non-preformatted text"); @@ -58,7 +58,7 @@ SimpleTest.waitForFocus(function() { window.getSelection().collapse(ed.firstChild, 3); // Press the back-space key - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); // Make sure that we've only deleted a single space is(ed.innerHTML, "a b", "We should only be deleting a single space"); diff --git a/editor/libeditor/tests/test_bug596333.html b/editor/libeditor/tests/test_bug596333.html index 49ce1f3e1fc0..a96d8202e0c8 100644 --- a/editor/libeditor/tests/test_bug596333.html +++ b/editor/libeditor/tests/test_bug596333.html @@ -36,10 +36,7 @@ function append(str) { edit.focus(); edit.selectionStart = edit.selectionEnd = edit.value.length; var editor = getEditor(); - - for (var i = 0; i < str.length; ++i) { - synthesizeKey(str[i], {}); - } + sendString(str); } function getLoadContext() { diff --git a/editor/libeditor/tests/test_bug596506.html b/editor/libeditor/tests/test_bug596506.html index 0fc1adabf48a..c889e4f6df95 100644 --- a/editor/libeditor/tests/test_bug596506.html +++ b/editor/libeditor/tests/test_bug596506.html @@ -25,27 +25,22 @@ SimpleTest.waitForFocus(runTest); const kIsMac = navigator.platform.indexOf("Mac") == 0; -function append(str) { - for (var i = 0; i < str.length; ++i) { - synthesizeKey(str[i], {}); - } -} function runTest() { var edit = document.getElementById("edit"); edit.focus(); - append("First"); - synthesizeKey("VK_RETURN", {}); - append("Second"); - synthesizeKey("VK_UP", {}); - synthesizeKey("VK_UP", {}); + sendString("First"); + synthesizeKey("KEY_Enter", {}); + sendString("Second"); + synthesizeKey("KEY_ArrowUp", {}); + synthesizeKey("KEY_ArrowUp", {}); if (kIsMac) { - synthesizeKey("VK_RIGHT", {accelKey: true}); + synthesizeKey("KEY_ArrowRight", {accelKey: true}); } else { - synthesizeKey("VK_END", {}); + synthesizeKey("KEY_End", {}); } - append("ly"); + sendString("ly"); is(edit.value, "Firstly\nSecond", "Pressing end should position the cursor before the terminating newline"); SimpleTest.finish(); diff --git a/editor/libeditor/tests/test_bug597331.html b/editor/libeditor/tests/test_bug597331.html index cdecce990221..77ccb6a48c59 100644 --- a/editor/libeditor/tests/test_bug597331.html +++ b/editor/libeditor/tests/test_bug597331.html @@ -59,7 +59,7 @@ addLoadEvent(function() { SimpleTest.finish(); }); }, {once: true}); - synthesizeKey("VK_LEFT", {}); + synthesizeKey("KEY_ArrowLeft"); }); }); }); diff --git a/editor/libeditor/tests/test_bug600570.html b/editor/libeditor/tests/test_bug600570.html index 9a3dcb237c52..9d73a1cd3b79 100644 --- a/editor/libeditor/tests/test_bug600570.html +++ b/editor/libeditor/tests/test_bug600570.html @@ -62,7 +62,7 @@ SimpleTest.waitForFocus(function() { SimpleTest.finish(); }, 0); }, {once: true}); - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowRight"); synthesizeKey("V", {accelKey: true}); }, function() { diff --git a/editor/libeditor/tests/test_bug604532.html b/editor/libeditor/tests/test_bug604532.html index 519a179b153d..d047ccf3d2bc 100644 --- a/editor/libeditor/tests/test_bug604532.html +++ b/editor/libeditor/tests/test_bug604532.html @@ -27,8 +27,8 @@ SimpleTest.waitForFocus(function() { synthesizeKey("A", {accelKey: true}); is(i.selectionStart, 0, "Selection should start at 0 before appending"); is(i.selectionEnd, 3, "Selection should end at 3 before appending"); - synthesizeKey("VK_RIGHT", {}); - synthesizeKey("x", {}); + synthesizeKey("KEY_ArrowRight"); + sendString("x"); is(i.value, "foox", "The text should be appended correctly"); synthesizeKey("A", {accelKey: true}); is(i.selectionStart, 0, "Selection should start at 0 after appending"); diff --git a/editor/libeditor/tests/test_bug607584.html b/editor/libeditor/tests/test_bug607584.html index aa22b6f30868..1c692ceae461 100644 --- a/editor/libeditor/tests/test_bug607584.html +++ b/editor/libeditor/tests/test_bug607584.html @@ -25,7 +25,7 @@ SimpleTest.waitForFocus(function() { content.focus(); var sel = getSelection(); sel.collapse(document.getElementById("foo").firstChild, 5); - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); var paragraphs = content.querySelectorAll("p"); is(paragraphs.length, 2, "The paragraph should be split in two"); is(paragraphs[0].textContent, "Hello", "The first paragraph should have the correct content"); diff --git a/editor/libeditor/tests/test_bug611182.html b/editor/libeditor/tests/test_bug611182.html index 1a2565b512a7..7088c8802269 100644 --- a/editor/libeditor/tests/test_bug611182.html +++ b/editor/libeditor/tests/test_bug611182.html @@ -65,7 +65,7 @@ SimpleTest.waitForFocus(function() { var textNode = findTextNode(doc); var sel = win.getSelection(); sel.collapse(textNode, 4); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); is(textNode.textContent, "foo bar", "Backspace should work correctly"); var snapshot = snapshotWindow(win, false); diff --git a/editor/libeditor/tests/test_bug612447.html b/editor/libeditor/tests/test_bug612447.html index cdb9b22f1e1a..91204f92afa0 100644 --- a/editor/libeditor/tests/test_bug612447.html +++ b/editor/libeditor/tests/test_bug612447.html @@ -40,7 +40,7 @@ SimpleTest.waitForFocus(function() { i.focus(); b.focus(); var beforeA = snapshotWindow(win, true); - synthesizeKey("X", {}); + sendString("X"); var beforeB = snapshotWindow(win, true); is(b.textContent, "X", "Typing should work"); while (b.firstChild) { @@ -54,7 +54,7 @@ SimpleTest.waitForFocus(function() { i.focus(); b.focus(); var afterA = snapshotWindow(win, true); - synthesizeKey("X", {}); + sendString("X"); var afterB = snapshotWindow(win, true); is(b.textContent, "X", "Typing should work"); while (b.firstChild) { diff --git a/editor/libeditor/tests/test_bug625452.html b/editor/libeditor/tests/test_bug625452.html index 3e4072a75695..aba9ce8c79d7 100644 --- a/editor/libeditor/tests/test_bug625452.html +++ b/editor/libeditor/tests/test_bug625452.html @@ -47,7 +47,7 @@ addLoadEvent(function() { // test delete i.selectionStart = 0; i.selectionEnd = 2; - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Delete"); is(i.value, "r", "Delete should work correctly"); is(inputCount, 4, "input event should be raised correctly"); diff --git a/editor/libeditor/tests/test_bug638596.html b/editor/libeditor/tests/test_bug638596.html index 62ef103f0f5c..03aef3931885 100644 --- a/editor/libeditor/tests/test_bug638596.html +++ b/editor/libeditor/tests/test_bug638596.html @@ -23,10 +23,7 @@ SimpleTest.waitForExplicitFinish(); SimpleTest.waitForFocus(function() { var i = document.querySelector("input"); i.focus(); - synthesizeKey("t", {}); - synthesizeKey("e", {}); - synthesizeKey("s", {}); - synthesizeKey("t", {}); + sendString("test"); is(i.value, "test", "The correct value should be stored in the field"); SimpleTest.finish(); }); diff --git a/editor/libeditor/tests/test_bug641466.html b/editor/libeditor/tests/test_bug641466.html index 4a77b0b8962f..847aaf5dda4c 100644 --- a/editor/libeditor/tests/test_bug641466.html +++ b/editor/libeditor/tests/test_bug641466.html @@ -26,10 +26,7 @@ SimpleTest.waitForFocus(function() { element.focus(); element.selectionStart = 4; element.selectionEnd = 4; - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace", {repeat: 4}); ok(element.value, "", "4 backspaces should delete all of the characters in the " + element.localName); } diff --git a/editor/libeditor/tests/test_bug668599.html b/editor/libeditor/tests/test_bug668599.html index 8405d08ab499..24516cdf6cca 100644 --- a/editor/libeditor/tests/test_bug668599.html +++ b/editor/libeditor/tests/test_bug668599.html @@ -46,20 +46,20 @@ function runTests() { // editable => the *content* should be deleted select(span); span.focus(); - synthesizeKey("x", {}); + sendString("x"); is(span.textContent, "x", "The content should have been replaced by 'x'."); // same thing, but using [Del] instead of typing some text document.execCommand("Undo", false, null); select(span); span.focus(); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Delete"); is(span.textContent, "", "The content should have been deleted."); // in editable block => the *element* should be deleted select(document.querySelector("#test2 span")); document.querySelector("#test2 [contenteditable]").focus(); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Delete"); is(document.querySelector("#test2 span"), null, "The element should have been deleted."); diff --git a/editor/libeditor/tests/test_bug674861.html b/editor/libeditor/tests/test_bug674861.html index 48b4a1efda7c..8879ae93511c 100644 --- a/editor/libeditor/tests/test_bug674861.html +++ b/editor/libeditor/tests/test_bug674861.html @@ -105,8 +105,8 @@ function try2split(element, caretPos) { sel.addRange(range); // simulates two [Return] keypresses - synthesizeKey("VK_RETURN", {}); - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); + synthesizeKey("KEY_Enter"); } function runTests() { diff --git a/editor/libeditor/tests/test_bug686203.html b/editor/libeditor/tests/test_bug686203.html index c1a856aaed0f..3947ed7f9745 100644 --- a/editor/libeditor/tests/test_bug686203.html +++ b/editor/libeditor/tests/test_bug686203.html @@ -33,7 +33,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=686203 var eventDetails = { button : 2 }; synthesizeMouseAtCenter(input, eventDetails); - synthesizeKey("Z", {}); + sendString("Z"); /* check values */ is(input.value, "Z", "input correctly focused after right-click"); diff --git a/editor/libeditor/tests/test_bug740784.html b/editor/libeditor/tests/test_bug740784.html index cce0a01e9efe..e9eaf1d91419 100644 --- a/editor/libeditor/tests/test_bug740784.html +++ b/editor/libeditor/tests/test_bug740784.html @@ -30,9 +30,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=740784 var t1 = $("t1"); t1.focus(); - synthesizeKey("VK_END", {}); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("Z", {accelKey: true}); + synthesizeKey("KEY_End"); + synthesizeKey("KEY_Backspace"); + synthesizeKey("z", {accelKey: true}); // Was the former bogus node changed to a mozBR? is(t1.value, "a", "trailing
correctly ignored"); diff --git a/editor/libeditor/tests/test_bug772796.html b/editor/libeditor/tests/test_bug772796.html index 4afef7062334..ea52bb025d6a 100644 --- a/editor/libeditor/tests/test_bug772796.html +++ b/editor/libeditor/tests/test_bug772796.html @@ -163,7 +163,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=772796 synthesizeMouse(theDiv, 100, 2, {}); /* click behind and down */ /** First round: Forward delete. **/ - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_Delete"); is(theDiv.innerHTML, tests[i][1], "delete(collapsed): inner HTML for " + testName); /* Set up the selection. */ @@ -174,8 +174,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=772796 synthesizeMouse(theDiv, 100, 2, {}); /* click behind and down */ /** Second round: Backspace. **/ - synthesizeKey("VK_RIGHT", {}); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_Backspace"); if (tests[i].length == 2) { is(theDiv.innerHTML, tests[i][1], "backspace: inner HTML for " + testName); } else { @@ -195,12 +195,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=772796 // This test doesn't work, since we can't select only one newline using the right arrow key. continue; } - synthesizeKey("VK_LEFT", {}); + synthesizeKey("KEY_ArrowLeft"); /* Strangely enough we need to hit "right arrow" three times to select two characters. */ - synthesizeKey("VK_RIGHT", {shiftKey:true}); - synthesizeKey("VK_RIGHT", {shiftKey:true}); - synthesizeKey("VK_RIGHT", {shiftKey:true}); - synthesizeKey("VK_DELETE", {}); + synthesizeKey("KEY_ArrowRight", {shiftKey:true}); + synthesizeKey("KEY_ArrowRight", {shiftKey:true}); + synthesizeKey("KEY_ArrowRight", {shiftKey:true}); + synthesizeKey("KEY_Delete"); /* We always expect to the delete the "tf" in "testfoo". */ var expected = tests[i][1].replace("testfoo", "tesoo") diff --git a/editor/libeditor/tests/test_bug790475.html b/editor/libeditor/tests/test_bug790475.html index d7685458baf4..fa235f834d40 100644 --- a/editor/libeditor/tests/test_bug790475.html +++ b/editor/libeditor/tests/test_bug790475.html @@ -57,7 +57,7 @@ function runTest() { var editor = getEditor(); var sel = editor.selection; sel.collapse(newTextNode, newTextNode.textContent.length); - synthesizeKey("!", {}); + sendString("!"); edit.blur(); diff --git a/editor/libeditor/tests/test_bug795785.html b/editor/libeditor/tests/test_bug795785.html index 3e5f355ee278..8acd2cb61e0b 100644 --- a/editor/libeditor/tests/test_bug795785.html +++ b/editor/libeditor/tests/test_bug795785.html @@ -51,29 +51,16 @@ function doKeyEventTest(aElement, aElementDescription, aCallback) hitEventLoop(function () { is(aElement.scrollTop, 0, aElementDescription + "'s scrollTop isn't 0"); - synthesizeKey("VK_RETURN", { shiftKey: true }); - synthesizeKey("VK_RETURN", { shiftKey: true }); - synthesizeKey("VK_RETURN", { shiftKey: true }); - synthesizeKey("VK_RETURN", { shiftKey: true }); - synthesizeKey("VK_RETURN", { shiftKey: true }); - synthesizeKey("VK_RETURN", { shiftKey: true }); + synthesizeKey("KEY_Enter", {shiftKey: true, repeat: 6}); hitEventLoop(function () { isnot(aElement.scrollTop, 0, aElementDescription + " was not scrolled by inserting line breaks"); var scrollTop = aElement.scrollTop; - synthesizeKey("VK_UP", { }); - synthesizeKey("VK_UP", { }); - synthesizeKey("VK_UP", { }); - synthesizeKey("VK_UP", { }); - synthesizeKey("VK_UP", { }); + synthesizeKey("KEY_ArrowUp", {repeat: 5}); hitEventLoop(function () { isnot(aElement.scrollTop, scrollTop, aElementDescription + " was not scrolled by up key events"); - synthesizeKey("VK_DOWN", { }); - synthesizeKey("VK_DOWN", { }); - synthesizeKey("VK_DOWN", { }); - synthesizeKey("VK_DOWN", { }); - synthesizeKey("VK_DOWN", { }); + synthesizeKey("KEY_ArrowDown", {repeat: 5}); hitEventLoop(function () { is(aElement.scrollTop, scrollTop, aElementDescription + " was not scrolled by down key events"); @@ -84,15 +71,11 @@ function doKeyEventTest(aElement, aElementDescription, aCallback) aElementDescription + " was not scrolled by typing long word"); var scrollLeft = aElement.scrollLeft; var i; - for (i = 0; i < longWord.length; i++) { - synthesizeKey("VK_LEFT", { }); - } + synthesizeKey("KEY_ArrowLeft", {repeat: longWord.length}); hitEventLoop(function () { isnot(aElement.scrollLeft, scrollLeft, aElementDescription + " was not scrolled by left key events"); - for (i = 0; i < longWord.length; i++) { - synthesizeKey("VK_RIGHT", { }); - } + synthesizeKey("KEY_ArrowRight", {repeat: longWord.length}); hitEventLoop(function () { is(aElement.scrollLeft, scrollLeft, aElementDescription + " was not scrolled by right key events"); diff --git a/editor/libeditor/tests/test_bug850043.html b/editor/libeditor/tests/test_bug850043.html index 2a2c3cf8a3ff..ef3ac25f8907 100644 --- a/editor/libeditor/tests/test_bug850043.html +++ b/editor/libeditor/tests/test_bug850043.html @@ -33,13 +33,11 @@ SimpleTest.waitForFocus(() => { element.focus(); is(SpecialPowers.unwrap(fm.focusedElement), element, "failed to move focus"); - synthesizeKey("VK_END", { }); - synthesizeKey("a", { }); + synthesizeKey("KEY_End"); + sendString("a"); is(element.value, "b\u{9080}\u{e010f}\u{8fba}\u{e0101}a", "a isn't last character"); - synthesizeKey("VK_BACK_SPACE", { }); - synthesizeKey("VK_BACK_SPACE", { }); - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_Backspace", {repeat: 3}); is(element.value, 'b', "cannot remove all IVS characters"); element = document.getElementById("edit"); @@ -49,12 +47,10 @@ SimpleTest.waitForFocus(() => { let sel = window.getSelection(); sel.collapse(element.childNodes[0], element.textContent.length); - synthesizeKey("a", { }); + sendString("a"); is(element.textContent, "b\u{9080}\u{e010f}\u{8fba}\u{e0101}a", "a isn't last character"); - synthesizeKey("VK_BACK_SPACE", { }); - synthesizeKey("VK_BACK_SPACE", { }); - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_Backspace", {repeat: 3}); is(element.textContent, 'b', "cannot remove all IVS characters"); SimpleTest.finish(); diff --git a/editor/libeditor/tests/test_contenteditable_text_input_handling.html b/editor/libeditor/tests/test_contenteditable_text_input_handling.html index 35c24336f453..5b2613a5199b 100644 --- a/editor/libeditor/tests/test_contenteditable_text_input_handling.html +++ b/editor/libeditor/tests/test_contenteditable_text_input_handling.html @@ -136,9 +136,7 @@ function runTests() } if (aFocus && aFocus._isFocusable) { - synthesizeKey("A", { }); - synthesizeKey("B", { }); - synthesizeKey("C", { }); + sendString("ABC"); checkValue(staticContent, "ABC"); checkValue(inputInStatic, "ABC"); checkValue(textareaInStatic, "ABC"); @@ -147,9 +145,7 @@ function runTests() checkValue(textareaInEditor, "ABC"); if (aFocus._isEditable) { - synthesizeKey("VK_BACK_SPACE", { }); - synthesizeKey("VK_BACK_SPACE", { }); - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_Backspace", {repeat: 3}); checkValue(staticContent, ""); checkValue(inputInStatic, ""); checkValue(textareaInStatic, ""); @@ -302,7 +298,7 @@ function runTests() checkValue(inputInEditor, "\u3089"); checkValue(textareaInEditor, "\u3089"); - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_Backspace"); checkValue(staticContent, ""); checkValue(inputInStatic, ""); checkValue(textareaInStatic, ""); diff --git a/editor/libeditor/tests/test_dom_input_event_on_texteditor.html b/editor/libeditor/tests/test_dom_input_event_on_texteditor.html index b1395e99c619..b9aebd06c7f0 100644 --- a/editor/libeditor/tests/test_dom_input_event_on_texteditor.html +++ b/editor/libeditor/tests/test_dom_input_event_on_texteditor.html @@ -62,20 +62,20 @@ function runTests() aElement.addEventListener("input", handler, true); inputEvent = null; - synthesizeKey("a", { }); + sendString("a"); is(aElement.value, "a", aDescription + "'a' key didn't change the value"); ok(inputEvent, aDescription + "input event wasn't fired by 'a' key"); ok(inputEvent.isTrusted, aDescription + "input event by 'a' key wasn't trusted event"); inputEvent = null; - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_Backspace"); is(aElement.value, "", aDescription + "BackSpace key didn't remove the value"); ok(inputEvent, aDescription + "input event wasn't fired by BackSpace key"); ok(inputEvent.isTrusted, aDescription + "input event by BackSpace key wasn't trusted event"); if (aIsTextarea) { inputEvent = null; - synthesizeKey("VK_RETURN", { }); + synthesizeKey("KEY_Enter"); is(aElement.value, "\n", aDescription + "Enter key didn't change the value"); ok(inputEvent, aDescription + "input event wasn't fired by Enter key"); ok(inputEvent.isTrusted, aDescription + "input event by Enter key wasn't trusted event"); @@ -92,35 +92,35 @@ function runTests() ok(!inputEvent, aDescription + "input event was fired by setting empty value"); inputEvent = null; - synthesizeKey(" ", { }); + sendString(" "); is(aElement.value, " ", aDescription + "Space key didn't change the value"); ok(inputEvent, aDescription + "input event wasn't fired by Space key"); ok(inputEvent.isTrusted, aDescription + "input event by Space key wasn't trusted event"); inputEvent = null; - synthesizeKey("VK_DELETE", { }); + synthesizeKey("KEY_Delete"); is(aElement.value, " ", aDescription + "Delete key removed the value"); ok(!inputEvent, aDescription + "input event was fired by Delete key at the end"); inputEvent = null; - synthesizeKey("VK_LEFT", { }); + synthesizeKey("KEY_ArrowLeft"); is(aElement.value, " ", aDescription + "Left key removed the value"); ok(!inputEvent, aDescription + "input event was fired by Left key"); inputEvent = null; - synthesizeKey("VK_DELETE", { }); + synthesizeKey("KEY_Delete"); is(aElement.value, "", aDescription + "Delete key didn't remove the value"); ok(inputEvent, aDescription + "input event wasn't fired by Delete key at the start"); ok(inputEvent.isTrusted, aDescription + "input event by Delete key wasn't trusted event"); inputEvent = null; - synthesizeKey("z", { accelKey: true }); + synthesizeKey("z", {accelKey: true}); is(aElement.value, " ", aDescription + "Accel+Z key didn't undo the value"); ok(inputEvent, aDescription + "input event wasn't fired by Undo"); ok(inputEvent.isTrusted, aDescription + "input event by Undo wasn't trusted event"); inputEvent = null; - synthesizeKey("z", { accelKey: true, shiftKey: true }); + synthesizeKey("Z", {accelKey: true, shiftKey: true}); is(aElement.value, "", aDescription + "Accel+Y key didn't redo the value"); ok(inputEvent, aDescription + "input event wasn't fired by Redo"); ok(inputEvent.isTrusted, aDescription + "input event by Redo wasn't trusted event"); diff --git a/editor/libeditor/tests/test_htmleditor_keyevent_handling.html b/editor/libeditor/tests/test_htmleditor_keyevent_handling.html index 55551825956e..3a629e054d56 100644 --- a/editor/libeditor/tests/test_htmleditor_keyevent_handling.html +++ b/editor/libeditor/tests/test_htmleditor_keyevent_handling.html @@ -133,27 +133,27 @@ function runTests() // If editor is editable, it consumes backspace and shift+backspace. // Otherwise, editor doesn't consume the event. reset(""); - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_Backspace"); check(aDescription + "Backspace", true, true, true); reset(""); - synthesizeKey("VK_BACK_SPACE", { shiftKey: true }); + synthesizeKey("KEY_Backspace", {shiftKey: true}); check(aDescription + "Shift+Backspace", true, true, true); reset(""); - synthesizeKey("VK_BACK_SPACE", { ctrlKey: true }); + synthesizeKey("KEY_Backspace", {ctrlKey: true}); check(aDescription + "Ctrl+Backspace", true, true, aIsReadonly); reset(""); - synthesizeKey("VK_BACK_SPACE", { altKey: true }); + synthesizeKey("KEY_Backspace", {altKey: true}); check(aDescription + "Alt+Backspace", true, true, aIsReadonly || kIsMac); reset(""); - synthesizeKey("VK_BACK_SPACE", { metaKey: true }); + synthesizeKey("KEY_Backspace", {metaKey: true}); check(aDescription + "Meta+Backspace", true, true, aIsReadonly); reset(""); - synthesizeKey("VK_BACK_SPACE", { osKey: true }); + synthesizeKey("KEY_Backspace", {osKey: true}); check(aDescription + "OS+Backspace", true, true, aIsReadonly); // Delete key: @@ -161,27 +161,27 @@ function runTests() // If editor is editable, delete is consumed. // Otherwise, editor doesn't consume the event. reset(""); - synthesizeKey("VK_DELETE", { }); + synthesizeKey("KEY_Delete"); check(aDescription + "Delete", true, true, !aIsReadonly || kIsMac); reset(""); - synthesizeKey("VK_DELETE", { shiftKey: true }); + synthesizeKey("KEY_Delete", {shiftKey: true}); check(aDescription + "Shift+Delete", true, true, kIsMac); reset(""); - synthesizeKey("VK_DELETE", { ctrlKey: true }); + synthesizeKey("KEY_Delete", {ctrlKey: true}); check(aDescription + "Ctrl+Delete", true, true, false); reset(""); - synthesizeKey("VK_DELETE", { altKey: true }); + synthesizeKey("KEY_Delete", {altKey: true}); check(aDescription + "Alt+Delete", true, true, kIsMac); reset(""); - synthesizeKey("VK_DELETE", { metaKey: true }); + synthesizeKey("KEY_Delete", {metaKey: true}); check(aDescription + "Meta+Delete", true, true, false); reset(""); - synthesizeKey("VK_DELETE", { osKey: true }); + synthesizeKey("KEY_Delete", {osKey: true}); check(aDescription + "OS+Delete", true, true, false); // Return key: @@ -190,36 +190,36 @@ function runTests() // and Shift+Return. // Otherwise, editor doesn't consume the event. reset("a"); - synthesizeKey("VK_RETURN", { }); + synthesizeKey("KEY_Enter"); check(aDescription + "Return", true, true, !aIsReadonly); is(aElement.innerHTML, aIsReadonly ? "a" : "
a

", aDescription + "Return"); reset("a"); - synthesizeKey("VK_RETURN", { shiftKey: true }); + synthesizeKey("KEY_Enter", {shiftKey: true}); check(aDescription + "Shift+Return", true, true, !aIsReadonly); is(aElement.innerHTML, aIsReadonly ? "a" : "a

", aDescription + "Shift+Return"); reset("a"); - synthesizeKey("VK_RETURN", { ctrlKey: true }); + synthesizeKey("KEY_Enter", {ctrlKey: true}); check(aDescription + "Ctrl+Return", true, true, false); is(aElement.innerHTML, "a", aDescription + "Ctrl+Return"); reset("a"); - synthesizeKey("VK_RETURN", { altKey: true }); + synthesizeKey("KEY_Enter", {altKey: true}); check(aDescription + "Alt+Return", true, true, false); is(aElement.innerHTML, "a", aDescription + "Alt+Return"); reset("a"); - synthesizeKey("VK_RETURN", { metaKey: true }); + synthesizeKey("KEY_Enter", {metaKey: true}); check(aDescription + "Meta+Return", true, true, false); is(aElement.innerHTML, "a", aDescription + "Meta+Return"); reset("a"); - synthesizeKey("VK_RETURN", { osKey: true }); + synthesizeKey("KEY_Enter", {osKey: true}); check(aDescription + "OS+Return", true, true, false); is(aElement.innerHTML, "a", aDescription + "OS+Return"); @@ -227,7 +227,7 @@ function runTests() // If editor is tabbable, editor doesn't consume all tab key events. // Otherwise, editor consumes tab key event without any modifier keys. reset("a"); - synthesizeKey("VK_TAB", { }); + synthesizeKey("KEY_Tab"); check(aDescription + "Tab", true, true, !aIsTabbable && !aIsReadonly); is(aElement.innerHTML, @@ -238,7 +238,7 @@ function runTests() aDescription + "focus moved unexpectedly (Tab)"); reset("a"); - synthesizeKey("VK_TAB", { shiftKey: true }); + synthesizeKey("KEY_Tab", {shiftKey: true}); check(aDescription + "Shift+Tab", true, true, false); is(aElement.innerHTML, "a", aDescription + "Shift+Tab"); is(SpecialPowers.unwrap(fm.focusedElement), aElement, @@ -247,28 +247,28 @@ function runTests() // Ctrl+Tab should be consumed by tabbrowser at keydown, so, keypress // event should never be fired. reset("a"); - synthesizeKey("VK_TAB", { ctrlKey: true }); + synthesizeKey("KEY_Tab", {ctrlKey: true}); check(aDescription + "Ctrl+Tab", false, false, false); is(aElement.innerHTML, "a", aDescription + "Ctrl+Tab"); is(SpecialPowers.unwrap(fm.focusedElement), aElement, aDescription + "focus moved unexpectedly (Ctrl+Tab)"); reset("a"); - synthesizeKey("VK_TAB", { altKey: true }); + synthesizeKey("KEY_Tab", {altKey: true}); check(aDescription + "Alt+Tab", true, true, false); is(aElement.innerHTML, "a", aDescription + "Alt+Tab"); is(SpecialPowers.unwrap(fm.focusedElement), aElement, aDescription + "focus moved unexpectedly (Alt+Tab)"); reset("a"); - synthesizeKey("VK_TAB", { metaKey: true }); + synthesizeKey("KEY_Tab", {metaKey: true}); check(aDescription + "Meta+Tab", true, true, false); is(aElement.innerHTML, "a", aDescription + "Meta+Tab"); is(SpecialPowers.unwrap(fm.focusedElement), aElement, aDescription + "focus moved unexpectedly (Meta+Tab)"); reset("a"); - synthesizeKey("VK_TAB", { osKey: true }); + synthesizeKey("KEY_Tab", {osKey: true}); check(aDescription + "OS+Tab", true, true, false); is(aElement.innerHTML, "a", aDescription + "OS+Tab"); is(SpecialPowers.unwrap(fm.focusedElement), aElement, @@ -277,7 +277,7 @@ function runTests() // Indent/Outdent tests: // UL resetForIndent("
  • ul list item
"); - synthesizeKey("VK_TAB", { }); + synthesizeKey("KEY_Tab"); check(aDescription + "Tab on UL", true, true, !aIsTabbable && !aIsReadonly); is(aElement.innerHTML, @@ -288,7 +288,7 @@ function runTests() aDescription + "Tab on UL"); is(SpecialPowers.unwrap(fm.focusedElement), aElement, aDescription + "focus moved unexpectedly (Tab on UL)"); - synthesizeKey("VK_TAB", { shiftKey: true }); + synthesizeKey("KEY_Tab", {shiftKey: true}); check(aDescription + "Shift+Tab after Tab on UL", true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext); is(aElement.innerHTML, @@ -300,7 +300,7 @@ function runTests() aDescription + "focus moved unexpectedly (Shift+Tab after Tab on UL)"); resetForIndent("
  • ul list item
"); - synthesizeKey("VK_TAB", { shiftKey: true }); + synthesizeKey("KEY_Tab", {shiftKey: true}); check(aDescription + "Shift+Tab on UL", true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext); is(aElement.innerHTML, @@ -313,7 +313,7 @@ function runTests() // Ctrl+Tab should be consumed by tabbrowser at keydown, so, keypress // event should never be fired. resetForIndent("
  • ul list item
"); - synthesizeKey("VK_TAB", { ctrlKey: true }); + synthesizeKey("KEY_Tab", {ctrlKey: true}); check(aDescription + "Ctrl+Tab on UL", false, false, false); is(aElement.innerHTML, "
  • ul list item
", aDescription + "Ctrl+Tab on UL"); @@ -321,7 +321,7 @@ function runTests() aDescription + "focus moved unexpectedly (Ctrl+Tab on UL)"); resetForIndent("
  • ul list item
"); - synthesizeKey("VK_TAB", { altKey: true }); + synthesizeKey("KEY_Tab", {altKey: true}); check(aDescription + "Alt+Tab on UL", true, true, false); is(aElement.innerHTML, "
  • ul list item
", aDescription + "Alt+Tab on UL"); @@ -329,7 +329,7 @@ function runTests() aDescription + "focus moved unexpectedly (Alt+Tab on UL)"); resetForIndent("
  • ul list item
"); - synthesizeKey("VK_TAB", { metaKey: true }); + synthesizeKey("KEY_Tab", {metaKey: true}); check(aDescription + "Meta+Tab on UL", true, true, false); is(aElement.innerHTML, "
  • ul list item
", aDescription + "Meta+Tab on UL"); @@ -337,7 +337,7 @@ function runTests() aDescription + "focus moved unexpectedly (Meta+Tab on UL)"); resetForIndent("
  • ul list item
"); - synthesizeKey("VK_TAB", { osKey: true }); + synthesizeKey("KEY_Tab", {osKey: true}); check(aDescription + "OS+Tab on UL", true, true, false); is(aElement.innerHTML, "
  • ul list item
", aDescription + "OS+Tab on UL"); @@ -346,7 +346,7 @@ function runTests() // OL resetForIndent("
  1. ol list item
"); - synthesizeKey("VK_TAB", { }); + synthesizeKey("KEY_Tab"); check(aDescription + "Tab on OL", true, true, !aIsTabbable && !aIsReadonly); is(aElement.innerHTML, @@ -357,7 +357,7 @@ function runTests() aDescription + "Tab on OL"); is(SpecialPowers.unwrap(fm.focusedElement), aElement, aDescription + "focus moved unexpectedly (Tab on OL)"); - synthesizeKey("VK_TAB", { shiftKey: true }); + synthesizeKey("KEY_Tab", {shiftKey: true}); check(aDescription + "Shift+Tab after Tab on OL", true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext); is(aElement.innerHTML, @@ -369,7 +369,7 @@ function runTests() aDescription + "focus moved unexpectedly (Shift+Tab after Tab on OL)"); resetForIndent("
  1. ol list item
"); - synthesizeKey("VK_TAB", { shiftKey: true }); + synthesizeKey("KEY_Tab", {shiftKey: true}); check(aDescription + "Shift+Tab on OL", true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext); is(aElement.innerHTML, @@ -382,7 +382,7 @@ function runTests() // Ctrl+Tab should be consumed by tabbrowser at keydown, so, keypress // event should never be fired. resetForIndent("
  1. ol list item
"); - synthesizeKey("VK_TAB", { ctrlKey: true }); + synthesizeKey("KEY_Tab", {ctrlKey: true}); check(aDescription + "Ctrl+Tab on OL", false, false, false); is(aElement.innerHTML, "
  1. ol list item
", aDescription + "Ctrl+Tab on OL"); @@ -390,7 +390,7 @@ function runTests() aDescription + "focus moved unexpectedly (Ctrl+Tab on OL)"); resetForIndent("
  1. ol list item
"); - synthesizeKey("VK_TAB", { altKey: true }); + synthesizeKey("KEY_Tab", {altKey: true}); check(aDescription + "Alt+Tab on OL", true, true, false); is(aElement.innerHTML, "
  1. ol list item
", aDescription + "Alt+Tab on OL"); @@ -398,7 +398,7 @@ function runTests() aDescription + "focus moved unexpectedly (Alt+Tab on OL)"); resetForIndent("
  1. ol list item
"); - synthesizeKey("VK_TAB", { metaKey: true }); + synthesizeKey("KEY_Tab", {metaKey: true}); check(aDescription + "Meta+Tab on OL", true, true, false); is(aElement.innerHTML, "
  1. ol list item
", aDescription + "Meta+Tab on OL"); @@ -406,7 +406,7 @@ function runTests() aDescription + "focus moved unexpectedly (Meta+Tab on OL)"); resetForIndent("
  1. ol list item
"); - synthesizeKey("VK_TAB", { osKey: true }); + synthesizeKey("KEY_Tab", {osKey: true}); check(aDescription + "OS+Tab on OL", true, true, false); is(aElement.innerHTML, "
  1. ol list item
", aDescription + "OS+Tab on OL"); @@ -415,7 +415,7 @@ function runTests() // TD resetForIndent("
td
"); - synthesizeKey("VK_TAB", { }); + synthesizeKey("KEY_Tab"); check(aDescription + "Tab on TD", true, true, !aIsTabbable && !aIsReadonly); is(aElement.innerHTML, @@ -426,7 +426,7 @@ function runTests() aDescription + "Tab on TD"); is(SpecialPowers.unwrap(fm.focusedElement), aElement, aDescription + "focus moved unexpectedly (Tab on TD)"); - synthesizeKey("VK_TAB", { shiftKey: true }); + synthesizeKey("KEY_Tab", {shiftKey: true}); check(aDescription + "Shift+Tab after Tab on TD", true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext); is(aElement.innerHTML, @@ -439,7 +439,7 @@ function runTests() aDescription + "focus moved unexpectedly (Shift+Tab after Tab on TD)"); resetForIndent("
td
"); - synthesizeKey("VK_TAB", { shiftKey: true }); + synthesizeKey("KEY_Tab", {shiftKey: true}); check(aDescription + "Shift+Tab on TD", true, true, false); is(aElement.innerHTML, "
td
", @@ -450,7 +450,7 @@ function runTests() // Ctrl+Tab should be consumed by tabbrowser at keydown, so, keypress // event should never be fired. resetForIndent("
td
"); - synthesizeKey("VK_TAB", { ctrlKey: true }); + synthesizeKey("KEY_Tab", {ctrlKey: true}); check(aDescription + "Ctrl+Tab on TD", false, false, false); is(aElement.innerHTML, "
td
", @@ -459,7 +459,7 @@ function runTests() aDescription + "focus moved unexpectedly (Ctrl+Tab on TD)"); resetForIndent("
td
"); - synthesizeKey("VK_TAB", { altKey: true }); + synthesizeKey("KEY_Tab", {altKey: true}); check(aDescription + "Alt+Tab on TD", true, true, false); is(aElement.innerHTML, "
td
", @@ -468,7 +468,7 @@ function runTests() aDescription + "focus moved unexpectedly (Alt+Tab on TD)"); resetForIndent("
td
"); - synthesizeKey("VK_TAB", { metaKey: true }); + synthesizeKey("KEY_Tab", {metaKey: true}); check(aDescription + "Meta+Tab on TD", true, true, false); is(aElement.innerHTML, "
td
", @@ -477,7 +477,7 @@ function runTests() aDescription + "focus moved unexpectedly (Meta+Tab on TD)"); resetForIndent("
td
"); - synthesizeKey("VK_TAB", { osKey: true }); + synthesizeKey("KEY_Tab", {osKey: true}); check(aDescription + "OS+Tab on TD", true, true, false); is(aElement.innerHTML, "
td
", @@ -487,7 +487,7 @@ function runTests() // TH resetForIndent("
th
"); - synthesizeKey("VK_TAB", { }); + synthesizeKey("KEY_Tab"); check(aDescription + "Tab on TH", true, true, !aIsTabbable && !aIsReadonly); is(aElement.innerHTML, @@ -498,7 +498,7 @@ function runTests() aDescription + "Tab on TH"); is(SpecialPowers.unwrap(fm.focusedElement), aElement, aDescription + "focus moved unexpectedly (Tab on TH)"); - synthesizeKey("VK_TAB", { shiftKey: true }); + synthesizeKey("KEY_Tab", {shiftKey: true}); check(aDescription + "Shift+Tab after Tab on TH", true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext); is(aElement.innerHTML, @@ -511,7 +511,7 @@ function runTests() aDescription + "focus moved unexpectedly (Shift+Tab after Tab on TH)"); resetForIndent("
th
"); - synthesizeKey("VK_TAB", { shiftKey: true }); + synthesizeKey("KEY_Tab", {shiftKey: true}); check(aDescription + "Shift+Tab on TH", true, true, false); is(aElement.innerHTML, "
th
", @@ -522,7 +522,7 @@ function runTests() // Ctrl+Tab should be consumed by tabbrowser at keydown, so, keypress // event should never be fired. resetForIndent("
th
"); - synthesizeKey("VK_TAB", { ctrlKey: true }); + synthesizeKey("KEY_Tab", {ctrlKey: true}); check(aDescription + "Ctrl+Tab on TH", false, false, false); is(aElement.innerHTML, "
th
", @@ -531,7 +531,7 @@ function runTests() aDescription + "focus moved unexpectedly (Ctrl+Tab on TH)"); resetForIndent("
th
"); - synthesizeKey("VK_TAB", { altKey: true }); + synthesizeKey("KEY_Tab", {altKey: true}); check(aDescription + "Alt+Tab on TH", true, true, false); is(aElement.innerHTML, "
th
", @@ -540,7 +540,7 @@ function runTests() aDescription + "focus moved unexpectedly (Alt+Tab on TH)"); resetForIndent("
th
"); - synthesizeKey("VK_TAB", { metaKey: true }); + synthesizeKey("KEY_Tab", {metaKey: true}); check(aDescription + "Meta+Tab on TH", true, true, false); is(aElement.innerHTML, "
th
", @@ -549,7 +549,7 @@ function runTests() aDescription + "focus moved unexpectedly (Meta+Tab on TH)"); resetForIndent("
th
"); - synthesizeKey("VK_TAB", { osKey: true }); + synthesizeKey("KEY_Tab", {osKey: true}); check(aDescription + "OS+Tab on TH", true, true, false); is(aElement.innerHTML, "
th
", @@ -560,46 +560,46 @@ function runTests() // Esc key: // In all cases, esc key events are not consumed reset("abc"); - synthesizeKey("VK_ESCAPE", { }); + synthesizeKey("KEY_Escape"); check(aDescription + "Esc", true, true, false); reset("abc"); - synthesizeKey("VK_ESCAPE", { shiftKey: true }); + synthesizeKey("KEY_Escape", {shiftKey: true}); check(aDescription + "Shift+Esc", true, true, false); reset("abc"); - synthesizeKey("VK_ESCAPE", { ctrlKey: true }); + synthesizeKey("KEY_Escape", {ctrlKey: true}); check(aDescription + "Ctrl+Esc", true, true, false); reset("abc"); - synthesizeKey("VK_ESCAPE", { altKey: true }); + synthesizeKey("KEY_Escape", {altKey: true}); check(aDescription + "Alt+Esc", true, true, false); reset("abc"); - synthesizeKey("VK_ESCAPE", { metaKey: true }); + synthesizeKey("KEY_Escape", {metaKey: true}); check(aDescription + "Meta+Esc", true, true, false); reset("abc"); - synthesizeKey("VK_ESCAPE", { osKey: true }); + synthesizeKey("KEY_Escape", {osKey: true}); check(aDescription + "OS+Esc", true, true, false); // typical typing tests: reset(""); - synthesizeKey("M", { shiftKey: true }); + sendString("M"); check(aDescription + "M", true, true, !aIsReadonly); - synthesizeKey("o", { }); + sendString("o"); check(aDescription + "o", true, true, !aIsReadonly); - synthesizeKey("z", { }); + sendString("z"); check(aDescription + "z", true, true, !aIsReadonly); - synthesizeKey("i", { }); + sendString("i"); check(aDescription + "i", true, true, !aIsReadonly); - synthesizeKey("l", { }); + sendString("l"); check(aDescription + "l", true, true, !aIsReadonly); - synthesizeKey("l", { }); + sendString("l"); check(aDescription + "l", true, true, !aIsReadonly); - synthesizeKey("a", { }); + sendString("a"); check(aDescription + "a", true, true, !aIsReadonly); - synthesizeKey(" ", { }); + sendString(" "); check(aDescription + "' '", true, true, !aIsReadonly); is(aElement.innerHTML, aIsReadonly ? "" : aIsPlaintext ? "Mozilla " : "Mozilla
", diff --git a/editor/libeditor/tests/test_inline_style_cache.html b/editor/libeditor/tests/test_inline_style_cache.html index 02821d1ec993..7a75f02b7e36 100644 --- a/editor/libeditor/tests/test_inline_style_cache.html +++ b/editor/libeditor/tests/test_inline_style_cache.html @@ -31,10 +31,7 @@ SimpleTest.waitForFocus(function() { document.execCommand("bold"); document.execCommand("italic"); document.execCommand("strikethrough"); - synthesizeKey("t", {}); - synthesizeKey("e", {}); - synthesizeKey("s", {}); - synthesizeKey("t", {}); + sendString("test"); is(editor.innerHTML, "beforetestafter", "#01-01 At typing something after setting some styles, should cause inserting some nodes to apply the style"); @@ -46,11 +43,8 @@ SimpleTest.waitForFocus(function() { document.execCommand("bold"); document.execCommand("italic"); document.execCommand("strikethrough"); - synthesizeKey("KEY_Delete", {}); - synthesizeKey("t", {}); - synthesizeKey("e", {}); - synthesizeKey("s", {}); - synthesizeKey("t", {}); + synthesizeKey("KEY_Delete"); + sendString("test"); is(editor.innerHTML, "beforetestfter", "#01-02-1 At typing something after Delete after setting style, should cause inserting some nodes to apply the style"); @@ -60,11 +54,8 @@ SimpleTest.waitForFocus(function() { document.execCommand("bold"); document.execCommand("italic"); document.execCommand("strikethrough"); - synthesizeKey("KEY_Backspace", {}); - synthesizeKey("t", {}); - synthesizeKey("e", {}); - synthesizeKey("s", {}); - synthesizeKey("t", {}); + synthesizeKey("KEY_Backspace"); + sendString("test"); is(editor.innerHTML, "befortestafter", "#01-02-2 At typing something after Backspace after setting style, should cause inserting some nodes to apply the style"); @@ -75,11 +66,8 @@ SimpleTest.waitForFocus(function() { document.execCommand("bold"); document.execCommand("italic"); document.execCommand("strikethrough"); - synthesizeKey("KEY_Enter", {}); - synthesizeKey("t", {}); - synthesizeKey("e", {}); - synthesizeKey("s", {}); - synthesizeKey("t", {}); + synthesizeKey("KEY_Enter"); + sendString("test"); is(editor.innerHTML, "
before
testafter
", "#01-03-1 Typing Enter after setting style should not ignore the styles"); @@ -89,11 +77,8 @@ SimpleTest.waitForFocus(function() { document.execCommand("bold"); document.execCommand("italic"); document.execCommand("strikethrough"); - synthesizeKey("KEY_Enter", {}); - synthesizeKey("t", {}); - synthesizeKey("e", {}); - synthesizeKey("s", {}); - synthesizeKey("t", {}); + synthesizeKey("KEY_Enter"); + sendString("test"); is(editor.innerHTML, "

before

testafter

", "#01-03-2 Typing Enter after setting style should not ignore the styles"); @@ -106,10 +91,7 @@ SimpleTest.waitForFocus(function() { document.execCommand("bold"); document.execCommand("italic"); document.execCommand("strikethrough"); - synthesizeKey("t", {}); - synthesizeKey("e", {}); - synthesizeKey("s", {}); - synthesizeKey("t", {}); + sendString("test"); // XXX is not handled correctly in this case. todo_is(editor.innerHTML, "beforetestafter", @@ -126,11 +108,8 @@ SimpleTest.waitForFocus(function() { document.execCommand("bold"); document.execCommand("italic"); document.execCommand("strikethrough"); - synthesizeKey("KEY_Backspace", {}); - synthesizeKey("t", {}); - synthesizeKey("e", {}); - synthesizeKey("s", {}); - synthesizeKey("t", {}); + synthesizeKey("KEY_Backspace"); + sendString("test"); is(editor.innerHTML, "beforetestafter", "#02-02 After removing \"selection\" after setting some styles, should not keep the styles"); @@ -142,11 +121,8 @@ SimpleTest.waitForFocus(function() { document.execCommand("bold"); document.execCommand("italic"); document.execCommand("strikethrough"); - synthesizeKey("KEY_Enter", {}); - synthesizeKey("t", {}); - synthesizeKey("e", {}); - synthesizeKey("s", {}); - synthesizeKey("t", {}); + synthesizeKey("KEY_Enter"); + sendString("test"); // XXX is not handled correctly in this case. todo_is(editor.innerHTML, "
before
testafter
", @@ -161,11 +137,8 @@ SimpleTest.waitForFocus(function() { document.execCommand("bold"); document.execCommand("italic"); document.execCommand("strikethrough"); - synthesizeKey("KEY_Enter", {}); - synthesizeKey("t", {}); - synthesizeKey("e", {}); - synthesizeKey("s", {}); - synthesizeKey("t", {}); + synthesizeKey("KEY_Enter"); + sendString("test"); is(editor.innerHTML, "

before

testafter

", "#02-03-2 Typing Enter after setting style to selected text should keep the styles"); @@ -174,10 +147,7 @@ SimpleTest.waitForFocus(function() { editor.innerHTML = "beforeselectionafter"; selection.collapse(editor.firstChild.firstChild, "before".length); selection.extend(editor.firstChild.firstChild, "beforeselection".length); - synthesizeKey("t", {}); - synthesizeKey("e", {}); - synthesizeKey("s", {}); - synthesizeKey("t", {}); + sendString("test"); is(editor.innerHTML, "beforetestafter", "#03-01 Replacing text in styled inline elements should respect the styles"); @@ -186,11 +156,8 @@ SimpleTest.waitForFocus(function() { editor.innerHTML = "beforeselectionafter"; selection.collapse(editor.firstChild.firstChild, "before".length); selection.extend(editor.firstChild.firstChild, "beforeselection".length); - synthesizeKey("KEY_Backspace", {}); - synthesizeKey("t", {}); - synthesizeKey("e", {}); - synthesizeKey("s", {}); - synthesizeKey("t", {}); + synthesizeKey("KEY_Backspace"); + sendString("test"); is(editor.innerHTML, "beforetestafter", "#03-02 Inserting text after removing text in styled inline elements should respect the styles"); @@ -199,11 +166,8 @@ SimpleTest.waitForFocus(function() { editor.innerHTML = "beforeselectionafter"; selection.collapse(editor.firstChild.firstChild, "before".length); selection.extend(editor.firstChild.firstChild, "beforeselection".length); - synthesizeKey("KEY_Enter", {}); - synthesizeKey("t", {}); - synthesizeKey("e", {}); - synthesizeKey("s", {}); - synthesizeKey("t", {}); + synthesizeKey("KEY_Enter"); + sendString("test"); is(editor.innerHTML, "
before
testafter
", "#03-03-1 Inserting text after typing Enter at selected text in styled inline elements should respect the styles"); @@ -211,11 +175,8 @@ SimpleTest.waitForFocus(function() { editor.innerHTML = "

beforeselectionafter

"; selection.collapse(editor.firstChild.firstChild.firstChild, "before".length); selection.extend(editor.firstChild.firstChild.firstChild, "beforeselection".length); - synthesizeKey("KEY_Enter", {}); - synthesizeKey("t", {}); - synthesizeKey("e", {}); - synthesizeKey("s", {}); - synthesizeKey("t", {}); + synthesizeKey("KEY_Enter"); + sendString("test"); is(editor.innerHTML, "

before

testafter

", "#03-03-2 Inserting text after typing Enter at selected text in styled inline elements should respect the styles"); @@ -224,10 +185,7 @@ SimpleTest.waitForFocus(function() { editor.innerHTML = "beforeselectionafter"; selection.collapse(editor.firstChild.firstChild.firstChild.firstChild, "before".length); selection.extend(editor.firstChild.firstChild.firstChild.firstChild, "beforeselection".length); - synthesizeKey("t", {}); - synthesizeKey("e", {}); - synthesizeKey("s", {}); - synthesizeKey("t", {}); + sendString("test"); is(editor.innerHTML, "beforetestafter", "#04-01 Replacing text in styled inline elements should respect the styles"); @@ -236,11 +194,8 @@ SimpleTest.waitForFocus(function() { editor.innerHTML = "beforeselectionafter"; selection.collapse(editor.firstChild.firstChild.firstChild.firstChild, "before".length); selection.extend(editor.firstChild.firstChild.firstChild.firstChild, "beforeselection".length); - synthesizeKey("KEY_Backspace", {}); - synthesizeKey("t", {}); - synthesizeKey("e", {}); - synthesizeKey("s", {}); - synthesizeKey("t", {}); + synthesizeKey("KEY_Backspace"); + sendString("test"); is(editor.innerHTML, "beforetestafter", "#04-02 Inserting text after removing text in styled inline elements should respect the styles"); @@ -249,11 +204,8 @@ SimpleTest.waitForFocus(function() { editor.innerHTML = "beforeselectionafter"; selection.collapse(editor.firstChild.firstChild.firstChild.firstChild, "before".length); selection.extend(editor.firstChild.firstChild.firstChild.firstChild, "beforeselection".length); - synthesizeKey("KEY_Enter", {}); - synthesizeKey("t", {}); - synthesizeKey("e", {}); - synthesizeKey("s", {}); - synthesizeKey("t", {}); + synthesizeKey("KEY_Enter"); + sendString("test"); is(editor.innerHTML, "
before
testafter
", "#04-03-1 Inserting text after typing Enter at selected text in styled inline elements should respect the styles"); @@ -261,11 +213,8 @@ SimpleTest.waitForFocus(function() { editor.innerHTML = "

beforeselectionafter

"; selection.collapse(editor.firstChild.firstChild.firstChild.firstChild.firstChild, "before".length); selection.extend(editor.firstChild.firstChild.firstChild.firstChild.firstChild, "beforeselection".length); - synthesizeKey("KEY_Enter", {}); - synthesizeKey("t", {}); - synthesizeKey("e", {}); - synthesizeKey("s", {}); - synthesizeKey("t", {}); + synthesizeKey("KEY_Enter"); + sendString("test"); is(editor.innerHTML, "

before

testafter

", "#04-03-2 Inserting text after typing Enter at selected text in styled inline elements should respect the styles"); diff --git a/editor/libeditor/tests/test_texteditor_keyevent_handling.html b/editor/libeditor/tests/test_texteditor_keyevent_handling.html index 5c4a8d1c2a5c..581321e0d931 100644 --- a/editor/libeditor/tests/test_texteditor_keyevent_handling.html +++ b/editor/libeditor/tests/test_texteditor_keyevent_handling.html @@ -119,32 +119,32 @@ function runTests() // Otherwise, editor doesn't consume the event but the native key // bindings on nsTextControlFrame may consume it. reset(""); - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_Backspace"); check(aDescription + "Backspace", true, true, true); reset(""); - synthesizeKey("VK_BACK_SPACE", { shiftKey: true }); + synthesizeKey("KEY_Backspace", {shiftKey: true}); check(aDescription + "Shift+Backspace", true, true, true); reset(""); - synthesizeKey("VK_BACK_SPACE", { ctrlKey: true }); + synthesizeKey("KEY_Backspace", {ctrlKey: true}); // Win: cmd_deleteWordBackward check(aDescription + "Ctrl+Backspace", true, true, aIsReadonly || kIsWin); reset(""); - synthesizeKey("VK_BACK_SPACE", { altKey: true }); + synthesizeKey("KEY_Backspace", {altKey: true}); // Win: cmd_undo // Mac: cmd_deleteWordBackward check(aDescription + "Alt+Backspace", true, true, aIsReadonly || kIsWin || kIsMac); reset(""); - synthesizeKey("VK_BACK_SPACE", { metaKey: true }); + synthesizeKey("KEY_Backspace", {metaKey: true}); check(aDescription + "Meta+Backspace", true, true, aIsReadonly); reset(""); - synthesizeKey("VK_BACK_SPACE", { osKey: true }); + synthesizeKey("KEY_Backspace", {osKey: true}); check(aDescription + "OS+Backspace", true, true, aIsReadonly); // Delete key: @@ -153,7 +153,7 @@ function runTests() // Otherwise, editor doesn't consume the event but the native key // bindings on nsTextControlFrame may consume it. reset(""); - synthesizeKey("VK_DELETE", { }); + synthesizeKey("KEY_Delete"); // Linux: native handler // Mac: cmd_deleteCharForward check(aDescription + "Delete", @@ -163,31 +163,31 @@ function runTests() // Win: cmd_cutOrDelete // Linux: cmd_cut // Mac: cmd_deleteCharForward - synthesizeKey("VK_DELETE", { shiftKey: true }); + synthesizeKey("KEY_Delete", {shiftKey: true}); check(aDescription + "Shift+Delete", true, true, true); reset(""); - synthesizeKey("VK_DELETE", { ctrlKey: true }); + synthesizeKey("KEY_Delete", {ctrlKey: true}); // Win: cmd_deleteWordForward // Linux: cmd_copy check(aDescription + "Ctrl+Delete", true, true, kIsWin || kIsLinux); reset(""); - synthesizeKey("VK_DELETE", { altKey: true }); + synthesizeKey("KEY_Delete", {altKey: true}); // Mac: cmd_deleteWordForward check(aDescription + "Alt+Delete", true, true, kIsMac); reset(""); - synthesizeKey("VK_DELETE", { metaKey: true }); + synthesizeKey("KEY_Delete", {metaKey: true}); // Linux: native handler consumed. check(aDescription + "Meta+Delete", true, true, kIsLinux); reset(""); - synthesizeKey("VK_DELETE", { osKey: true }); + synthesizeKey("KEY_Delete", {osKey: true}); check(aDescription + "OS+Delete", true, true, false); @@ -200,36 +200,36 @@ function runTests() // and Shift+Return. // Otherwise, editor doesn't consume the event. reset("a"); - synthesizeKey("VK_RETURN", { }); + synthesizeKey("KEY_Enter"); check(aDescription + "Return", true, true, !aIsSingleLine && !aIsReadonly); is(aElement.value, !aIsSingleLine && !aIsReadonly ? "a\n" : "a", aDescription + "Return"); reset("a"); - synthesizeKey("VK_RETURN", { shiftKey: true }); + synthesizeKey("KEY_Enter", {shiftKey: true}); check(aDescription + "Shift+Return", true, true, !aIsSingleLine && !aIsReadonly); is(aElement.value, !aIsSingleLine && !aIsReadonly ? "a\n" : "a", aDescription + "Shift+Return"); reset("a"); - synthesizeKey("VK_RETURN", { ctrlKey: true }); + synthesizeKey("KEY_Enter", {ctrlKey: true}); check(aDescription + "Ctrl+Return", true, true, false); is(aElement.value, "a", aDescription + "Ctrl+Return"); reset("a"); - synthesizeKey("VK_RETURN", { altKey: true }); + synthesizeKey("KEY_Enter", {altKey: true}); check(aDescription + "Alt+Return", true, true, false); is(aElement.value, "a", aDescription + "Alt+Return"); reset("a"); - synthesizeKey("VK_RETURN", { metaKey: true }); + synthesizeKey("KEY_Enter", {metaKey: true}); check(aDescription + "Meta+Return", true, true, false); is(aElement.value, "a", aDescription + "Meta+Return"); reset("a"); - synthesizeKey("VK_RETURN", { osKey: true }); + synthesizeKey("KEY_Enter", {osKey: true}); check(aDescription + "OS+Return", true, true, false); is(aElement.value, "a", aDescription + "OS+Return"); @@ -237,7 +237,7 @@ function runTests() // If editor is tabbable, editor doesn't consume all tab key events. // Otherwise, editor consumes tab key event without any modifier keys. reset("a"); - synthesizeKey("VK_TAB", { }); + synthesizeKey("KEY_Tab"); check(aDescription + "Tab", true, true, !aIsTabbable && !aIsReadonly); is(aElement.value, !aIsTabbable && !aIsReadonly ? "a\t" : "a", @@ -249,7 +249,7 @@ function runTests() // even if it's empty. if (!aIsTabbable && !aIsReadonly) { reset(""); - synthesizeKey("VK_TAB", {}); + synthesizeKey("KEY_Tab"); check(aDescription + "Tab on empty textarea", true, true, !aIsReadonly); is(aElement.value, "\t", aDescription + "Tab on empty textarea"); @@ -258,7 +258,7 @@ function runTests() } reset("a"); - synthesizeKey("VK_TAB", { shiftKey: true }); + synthesizeKey("KEY_Tab", {shiftKey: true}); check(aDescription + "Shift+Tab", true, true, false); is(aElement.value, "a", aDescription + "Shift+Tab"); is(SpecialPowers.unwrap(fm.focusedElement), aElement, @@ -267,28 +267,28 @@ function runTests() // Ctrl+Tab should be consumed by tabbrowser at keydown, so, keypress // event should never be fired. reset("a"); - synthesizeKey("VK_TAB", { ctrlKey: true }); + synthesizeKey("KEY_Tab", {ctrlKey: true}); check(aDescription + "Ctrl+Tab", false, false, false); is(aElement.value, "a", aDescription + "Ctrl+Tab"); is(SpecialPowers.unwrap(fm.focusedElement), aElement, aDescription + "focus moved unexpectedly (Ctrl+Tab)"); reset("a"); - synthesizeKey("VK_TAB", { altKey: true }); + synthesizeKey("KEY_Tab", {altKey: true}); check(aDescription + "Alt+Tab", true, true, false); is(aElement.value, "a", aDescription + "Alt+Tab"); is(SpecialPowers.unwrap(fm.focusedElement), aElement, aDescription + "focus moved unexpectedly (Alt+Tab)"); reset("a"); - synthesizeKey("VK_TAB", { metaKey: true }); + synthesizeKey("KEY_Tab", {metaKey: true}); check(aDescription + "Meta+Tab", true, true, false); is(aElement.value, "a", aDescription + "Meta+Tab"); is(SpecialPowers.unwrap(fm.focusedElement), aElement, aDescription + "focus moved unexpectedly (Meta+Tab)"); reset("a"); - synthesizeKey("VK_TAB", { osKey: true }); + synthesizeKey("KEY_Tab", {osKey: true}); check(aDescription + "OS+Tab", true, true, false); is(aElement.value, "a", aDescription + "OS+Tab"); is(SpecialPowers.unwrap(fm.focusedElement), aElement, @@ -297,46 +297,46 @@ function runTests() // Esc key: // In all cases, esc key events are not consumed reset("abc"); - synthesizeKey("VK_ESCAPE", { }); + synthesizeKey("KEY_Escape"); check(aDescription + "Esc", true, true, false); reset("abc"); - synthesizeKey("VK_ESCAPE", { shiftKey: true }); + synthesizeKey("KEY_Escape", {shiftKey: true}); check(aDescription + "Shift+Esc", true, true, false); reset("abc"); - synthesizeKey("VK_ESCAPE", { ctrlKey: true }); + synthesizeKey("KEY_Escape", {ctrlKey: true}); check(aDescription + "Ctrl+Esc", true, true, false); reset("abc"); - synthesizeKey("VK_ESCAPE", { altKey: true }); + synthesizeKey("KEY_Escape", {altKey: true}); check(aDescription + "Alt+Esc", true, true, false); reset("abc"); - synthesizeKey("VK_ESCAPE", { metaKey: true }); + synthesizeKey("KEY_Escape", {metaKey: true}); check(aDescription + "Meta+Esc", true, true, false); reset("abc"); - synthesizeKey("VK_ESCAPE", { osKey: true }); + synthesizeKey("KEY_Escape", {osKey: true}); check(aDescription + "OS+Esc", true, true, false); // typical typing tests: reset(""); - synthesizeKey("M", { shiftKey: true }); + sendString("M"); check(aDescription + "M", true, true, !aIsReadonly); - synthesizeKey("o", { }); + sendString("o"); check(aDescription + "o", true, true, !aIsReadonly); - synthesizeKey("z", { }); + sendString("z"); check(aDescription + "z", true, true, !aIsReadonly); - synthesizeKey("i", { }); + sendString("i"); check(aDescription + "i", true, true, !aIsReadonly); - synthesizeKey("l", { }); + sendString("l"); check(aDescription + "l", true, true, !aIsReadonly); - synthesizeKey("l", { }); + sendString("l"); check(aDescription + "l", true, true, !aIsReadonly); - synthesizeKey("a", { }); + sendString("a"); check(aDescription + "a", true, true, !aIsReadonly); - synthesizeKey(" ", { }); + sendString(" "); check(aDescription + "' '", true, true, !aIsReadonly); is(aElement.value, !aIsReadonly ? "Mozilla " : "", aDescription + "typed \"Mozilla \""); diff --git a/gfx/layers/apz/test/mochitest/helper_key_scroll.html b/gfx/layers/apz/test/mochitest/helper_key_scroll.html index 2b377eb7b8a0..65031cfad6ea 100644 --- a/gfx/layers/apz/test/mochitest/helper_key_scroll.html +++ b/gfx/layers/apz/test/mochitest/helper_key_scroll.html @@ -36,14 +36,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1383365 // page. This scroll is done synchronously because APZ doesn't have // current focus state at page load. window.addEventListener("scroll", waitForScrollBottom); - window.synthesizeKey("VK_END", {}); + window.synthesizeKey("KEY_End"); }; function waitForScrollBottom() { if (window.scrollY < window.scrollYMax) { return; } - SimpleTest.info("Reached final scroll position of sync VK_END scroll"); + SimpleTest.info("Reached final scroll position of sync KEY_End scroll"); window.removeEventListener("scroll", waitForScrollBottom); // Spin the refresh driver a few times, so that the AsyncScroll instance @@ -58,11 +58,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1383365 // Wait for the APZ to reach a stable state as well, before dispatching // the next key input or the default action won't occur. waitForApzFlushedRepaints(function () { - SimpleTest.is(checkHasAsyncKeyScrolled(false), false, "expected no async key scrolling before VK_HOME dispatch"); + SimpleTest.is(checkHasAsyncKeyScrolled(false), false, "expected no async key scrolling before KEY_Home dispatch"); // This scroll should be asynchronous now that the focus state is up to date. window.addEventListener("scroll", waitForScrollTop); - window.synthesizeKey("VK_HOME", {}); + window.synthesizeKey("KEY_Home"); }); }; @@ -70,7 +70,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1383365 if (window.scrollY > 0) { return; } - SimpleTest.info("Reached final scroll position of async VK_HOME scroll"); + SimpleTest.info("Reached final scroll position of async KEY_Home scroll"); window.removeEventListener("scroll", waitForScrollTop); // Wait for APZ to settle and then check that async scrolling happened. diff --git a/layout/base/tests/bug1109968-1.html b/layout/base/tests/bug1109968-1.html index a8d0d216fa89..6196af37c15a 100644 --- a/layout/base/tests/bug1109968-1.html +++ b/layout/base/tests/bug1109968-1.html @@ -14,7 +14,7 @@ sel.collapse(div, 0); // Press Right four times to set the caret right before "baz" for (var i = 0; i < 5; ++i) { - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowRight"); } document.documentElement.removeAttribute("class"); } diff --git a/layout/base/tests/bug1109968-2.html b/layout/base/tests/bug1109968-2.html index 159311ad39ac..66d3c0e5886a 100644 --- a/layout/base/tests/bug1109968-2.html +++ b/layout/base/tests/bug1109968-2.html @@ -14,7 +14,7 @@ sel.collapse(div, 0); // Press Right four times to set the caret right before "bar" for (var i = 0; i < 6; ++i) { - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowRight"); } document.documentElement.removeAttribute("class"); } diff --git a/layout/base/tests/bug1123067-1.html b/layout/base/tests/bug1123067-1.html index 86c8357ff095..5a167e2c7797 100644 --- a/layout/base/tests/bug1123067-1.html +++ b/layout/base/tests/bug1123067-1.html @@ -13,9 +13,9 @@ } function test() { for (var i = 0; i < 5; ++i) { - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowRight"); } - synthesizeKey("VK_LEFT", {}); + synthesizeKey("KEY_ArrowLeft"); document.documentElement.removeAttribute("class"); } function runTests() { diff --git a/layout/base/tests/bug1123067-2.html b/layout/base/tests/bug1123067-2.html index 0139e7ac7290..0b8960a58bcf 100644 --- a/layout/base/tests/bug1123067-2.html +++ b/layout/base/tests/bug1123067-2.html @@ -8,9 +8,9 @@ diff --git a/layout/base/tests/bug1423331-2.html b/layout/base/tests/bug1423331-2.html index 4df19a3a953d..28ec34f993cf 100644 --- a/layout/base/tests/bug1423331-2.html +++ b/layout/base/tests/bug1423331-2.html @@ -20,9 +20,7 @@ SimpleTest.waitForFocus(function() { let div = document.getElementById("editable"); synthesizeMouseAtCenter(div, {}); synthesizeMouseAtCenter(div, {}); - synthesizeKey("x", {}); - synthesizeKey("x", {}); - synthesizeKey("x", {}); + sendString("xxx"); document.documentElement.className = ""; }); diff --git a/layout/base/tests/bug1423331-4.html b/layout/base/tests/bug1423331-4.html index 0566168b7d41..c1a61d41c6c7 100644 --- a/layout/base/tests/bug1423331-4.html +++ b/layout/base/tests/bug1423331-4.html @@ -20,9 +20,7 @@ SimpleTest.waitForFocus(function() { let div = document.getElementById("editable"); synthesizeMouse(div, 2, 2, {}); synthesizeMouse(div, 2, 2, {}); - synthesizeKey("x", {}); - synthesizeKey("x", {}); - synthesizeKey("x", {}); + sendString("xxx"); document.documentElement.className = ""; }); diff --git a/layout/base/tests/bug597519-1.html b/layout/base/tests/bug597519-1.html index a33084f153d6..3f012a722768 100644 --- a/layout/base/tests/bug597519-1.html +++ b/layout/base/tests/bug597519-1.html @@ -7,10 +7,9 @@ var t = document.querySelector("textarea"); t.focus(); - synthesizeKey("a", {}); - synthesizeKey("b", {}); - synthesizeKey("VK_RETURN", {}); - synthesizeKey("c", {}); + sendString("ab"); + synthesizeKey("KEY_Enter"); + sendString("c"); diff --git a/layout/base/tests/bug632215-1.html b/layout/base/tests/bug632215-1.html index 43f3be482009..cfe7cb1b6e07 100644 --- a/layout/base/tests/bug632215-1.html +++ b/layout/base/tests/bug632215-1.html @@ -17,9 +17,9 @@ d.designMode = "off"; d.designMode = "on"; d.body.focus(); - synthesizeKey("x", {}); + sendString("x"); s.collapse(d.body.firstChild, 1); - synthesizeKey("x", {}); + sendString("x"); setTimeout(function() { document.documentElement.removeAttribute("class"); }, 0); diff --git a/layout/base/tests/bug632215-2.html b/layout/base/tests/bug632215-2.html index 70d1ce2b78c9..b82232fcfebb 100644 --- a/layout/base/tests/bug632215-2.html +++ b/layout/base/tests/bug632215-2.html @@ -16,9 +16,9 @@ d.designMode = "off"; d.designMode = "on"; d.body.focus(); - synthesizeKey("x", {}); + sendString("x"); s.collapse(d.body.firstChild, 1); - synthesizeKey("x", {}); + sendString("x"); setTimeout(function() { document.documentElement.removeAttribute("class"); }, 0); diff --git a/layout/base/tests/bug633044-1.html b/layout/base/tests/bug633044-1.html index 1fc585404a41..9449050e9b29 100644 --- a/layout/base/tests/bug633044-1.html +++ b/layout/base/tests/bug633044-1.html @@ -16,7 +16,7 @@ range.insertNode(el); el.remove(); - synthesizeKey("VK_UP", {}); + synthesizeKey("KEY_ArrowUp"); } diff --git a/layout/base/tests/bug634406-1.html b/layout/base/tests/bug634406-1.html index 141198b59ef4..a14a9d05ecf7 100644 --- a/layout/base/tests/bug634406-1.html +++ b/layout/base/tests/bug634406-1.html @@ -7,10 +7,10 @@ var t = document.querySelector("textarea"); t.focus(); - synthesizeKey("a", {}); + sendString("a"); synthesizeKey("A", {accelKey: true}); - synthesizeKey("VK_RIGHT", {}); - synthesizeKey("b", {}); + synthesizeKey("KEY_ArrowRight"); + sendString("b"); diff --git a/layout/base/tests/bug644428-1.html b/layout/base/tests/bug644428-1.html index 9fe4d17fea5d..c5e2396bf10c 100644 --- a/layout/base/tests/bug644428-1.html +++ b/layout/base/tests/bug644428-1.html @@ -11,8 +11,8 @@ div.focus(); var sel = window.getSelection(); sel.collapse(div, 3); - synthesizeKey("VK_BACK_SPACE", {}); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); + synthesizeKey("KEY_Backspace"); } diff --git a/layout/base/tests/bug646382-1.html b/layout/base/tests/bug646382-1.html index 06335befab1c..afe8ed045713 100644 --- a/layout/base/tests/bug646382-1.html +++ b/layout/base/tests/bug646382-1.html @@ -11,9 +11,9 @@ } function typeIntoMe() { setTimeout(function() { - synthesizeKey("س", {}); - synthesizeKey("VK_DOWN", {}); - synthesizeKey("VK_DOWN", {}); + sendString("س"); + synthesizeKey("KEY_ArrowDown"); + synthesizeKey("KEY_ArrowDown"); document.documentElement.removeAttribute("class"); }, 0); } diff --git a/layout/base/tests/bug646382-2.html b/layout/base/tests/bug646382-2.html index 4852b85632d5..2ae2631fa340 100644 --- a/layout/base/tests/bug646382-2.html +++ b/layout/base/tests/bug646382-2.html @@ -10,9 +10,9 @@ } function typeIntoMe() { setTimeout(function() { - synthesizeKey("s", {}); - synthesizeKey("VK_DOWN", {}); - synthesizeKey("VK_DOWN", {}); + sendString("s"); + synthesizeKey("KEY_ArrowDown"); + synthesizeKey("KEY_ArrowDown"); document.documentElement.removeAttribute("class"); }, 0); } diff --git a/layout/base/tests/bug664087-1-ref.html b/layout/base/tests/bug664087-1-ref.html index 77de000b03e4..b804e402c500 100644 --- a/layout/base/tests/bug664087-1-ref.html +++ b/layout/base/tests/bug664087-1-ref.html @@ -12,8 +12,8 @@ textarea.focus(); } function done() { - synthesizeKey("VK_LEFT", {}); - synthesizeKey("VK_LEFT", {}); + synthesizeKey("KEY_ArrowLeft"); + synthesizeKey("KEY_ArrowLeft"); document.documentElement.removeAttribute("class"); } diff --git a/layout/base/tests/bug664087-1.html b/layout/base/tests/bug664087-1.html index ea12bcaadf16..7b85dee80d86 100644 --- a/layout/base/tests/bug664087-1.html +++ b/layout/base/tests/bug664087-1.html @@ -11,12 +11,12 @@ } function typeIntoMe() { setTimeout(function() { - synthesizeKey("א", {}); - synthesizeKey("VK_RETURN", {}); - synthesizeKey("ג", {}); - synthesizeKey("VK_UP", {}); - synthesizeKey("VK_END", {}); - synthesizeKey("ב", {}); + sendString("א"); + synthesizeKey("KEY_Enter"); + sendString("ג"); + synthesizeKey("KEY_ArrowUp"); + synthesizeKey("KEY_End"); + sendString("ב"); document.documentElement.removeAttribute("class"); }, 0); } diff --git a/layout/base/tests/bug664087-2-ref.html b/layout/base/tests/bug664087-2-ref.html index 52749fe44505..c2c0a138e014 100644 --- a/layout/base/tests/bug664087-2-ref.html +++ b/layout/base/tests/bug664087-2-ref.html @@ -12,8 +12,8 @@ c textarea.focus(); } function done() { - synthesizeKey("VK_RIGHT", {}); - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowRight"); + synthesizeKey("KEY_ArrowRight"); document.documentElement.removeAttribute("class"); } diff --git a/layout/base/tests/bug664087-2.html b/layout/base/tests/bug664087-2.html index 3baf2b165b05..803c3f3050ef 100644 --- a/layout/base/tests/bug664087-2.html +++ b/layout/base/tests/bug664087-2.html @@ -11,12 +11,12 @@ } function typeIntoMe() { setTimeout(function() { - synthesizeKey("a", {}); - synthesizeKey("VK_RETURN", {}); - synthesizeKey("c", {}); - synthesizeKey("VK_UP", {}); - synthesizeKey("VK_END", {}); - synthesizeKey("b", {}); + sendString("a"); + synthesizeKey("KEY_Enter"); + sendString("c"); + synthesizeKey("KEY_ArrowUp"); + synthesizeKey("KEY_End"); + sendString("b"); document.documentElement.removeAttribute("class"); }, 0); } diff --git a/layout/base/tests/bug682712-1.html b/layout/base/tests/bug682712-1.html index edc36b0677ea..706898b17575 100644 --- a/layout/base/tests/bug682712-1.html +++ b/layout/base/tests/bug682712-1.html @@ -22,7 +22,7 @@ // Now try to move the caret win.getSelection().collapse(doc.body.firstChild, 0); - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowRight"); document.documentElement.removeAttribute("class"); }, 0); diff --git a/layout/base/tests/bug746993-1.html b/layout/base/tests/bug746993-1.html index 761360c6d2be..c0b5399d0f1f 100644 --- a/layout/base/tests/bug746993-1.html +++ b/layout/base/tests/bug746993-1.html @@ -14,7 +14,7 @@ doc.body.focus(); win.getSelection().collapse(doc.body, 0); sendString("Here's some text."); - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); document.documentElement.removeAttribute("class"); } diff --git a/layout/base/tests/bug989012-1.html b/layout/base/tests/bug989012-1.html index 5bc9a2061be6..dac0cc35218a 100644 --- a/layout/base/tests/bug989012-1.html +++ b/layout/base/tests/bug989012-1.html @@ -15,7 +15,7 @@ sel.collapse(div, 0); // Press Right four times to set the caret right before "bar" for (var i = 0; i < 4; ++i) { - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowRight"); } document.documentElement.removeAttribute("class"); } diff --git a/layout/base/tests/bug989012-2.html b/layout/base/tests/bug989012-2.html index 32b43418e5d2..6a303bd17f20 100644 --- a/layout/base/tests/bug989012-2.html +++ b/layout/base/tests/bug989012-2.html @@ -20,7 +20,7 @@ sel.collapse(div, 0); // Press Right four times to set the caret right before "bar" for (var i = 0; i < 4; ++i) { - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowRight"); } document.documentElement.removeAttribute("class"); } diff --git a/layout/base/tests/bug989012-3.html b/layout/base/tests/bug989012-3.html index 6510e7d621e2..2be8657e8ad8 100644 --- a/layout/base/tests/bug989012-3.html +++ b/layout/base/tests/bug989012-3.html @@ -22,7 +22,7 @@ sel.collapse(div, 0); // Press Right four times to set the caret right before "bar" for (var i = 0; i < 4; ++i) { - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowRight"); } document.documentElement.removeAttribute("class"); } diff --git a/layout/base/tests/chrome/test_bug551434.html b/layout/base/tests/chrome/test_bug551434.html index 117613a2b982..5a18c801bc9c 100644 --- a/layout/base/tests/chrome/test_bug551434.html +++ b/layout/base/tests/chrome/test_bug551434.html @@ -52,7 +52,7 @@ function runTest() var childWinObj = frames[0].wrappedJSObject; - synthesizeKey("b", {}); + sendString("b"); is(gKeyDown3, 1, "keydown on input 3"); is(gKeyPress3, 1, "keypress on input 3"); is(gKeyUp3, 1, "keyup on input 3"); @@ -71,7 +71,7 @@ function runTest() // element in a chrome document from a content document. i4.addEventListener("keydown", () => $("i3").focus()); - synthesizeKey("c", {}); + sendString("c"); is(gKeyDown3, 1, "keydown on input 3"); is(gKeyPress3, 1, "keypress on input 3"); diff --git a/layout/base/tests/input-maxlength-invalid-change.html b/layout/base/tests/input-maxlength-invalid-change.html index 4056682a4758..c0c8208d6d71 100644 --- a/layout/base/tests/input-maxlength-invalid-change.html +++ b/layout/base/tests/input-maxlength-invalid-change.html @@ -13,7 +13,7 @@ var input = document.getElementById('input'); input.setSelectionRange(input.value.length, input.value.length) input.focus(); - synthesizeKey('VK_BACK_SPACE', {}); + synthesizeKey("KEY_Backspace"); input.blur(); // to hide the caret document.documentElement.className=''; } diff --git a/layout/base/tests/input-maxlength-ui-invalid-change.html b/layout/base/tests/input-maxlength-ui-invalid-change.html index 609838f16b01..571a270e1e94 100644 --- a/layout/base/tests/input-maxlength-ui-invalid-change.html +++ b/layout/base/tests/input-maxlength-ui-invalid-change.html @@ -13,7 +13,7 @@ var input = document.getElementById('input'); input.setSelectionRange(input.value.length, input.value.length) input.focus(); - synthesizeKey('VK_BACK_SPACE', {}); + synthesizeKey("KEY_Backspace"); input.blur(); // to hide the caret document.documentElement.className=''; } diff --git a/layout/base/tests/input-maxlength-ui-valid-change.html b/layout/base/tests/input-maxlength-ui-valid-change.html index 4cd3321829e7..399ec28c0a73 100644 --- a/layout/base/tests/input-maxlength-ui-valid-change.html +++ b/layout/base/tests/input-maxlength-ui-valid-change.html @@ -13,10 +13,10 @@ var input = document.getElementById('input'); input.setSelectionRange(input.value.length, input.value.length) input.focus(); - synthesizeKey('VK_BACK_SPACE', {}); // so that it becomes invalid first + synthesizeKey("KEY_Backspace"); // so that it becomes invalid first input.blur(); input.focus(); - synthesizeKey('VK_BACK_SPACE', {}); + synthesizeKey("KEY_Backspace"); input.blur(); // to hide the caret document.documentElement.className=''; } diff --git a/layout/base/tests/input-maxlength-valid-change.html b/layout/base/tests/input-maxlength-valid-change.html index bf02a804032f..58dd55bca9ed 100644 --- a/layout/base/tests/input-maxlength-valid-change.html +++ b/layout/base/tests/input-maxlength-valid-change.html @@ -13,10 +13,10 @@ var input = document.getElementById('input'); input.setSelectionRange(input.value.length, input.value.length) input.focus(); - synthesizeKey('VK_BACK_SPACE', {}); // so that it becomes invalid first + synthesizeKey("KEY_Backspace"); // so that it becomes invalid first input.blur(); input.focus(); - synthesizeKey('VK_BACK_SPACE', {}); + synthesizeKey("KEY_Backspace"); input.blur(); // to hide the caret document.documentElement.className=''; } diff --git a/layout/base/tests/input-minlength-invalid-change.html b/layout/base/tests/input-minlength-invalid-change.html index cc2107e3d62e..033082013681 100644 --- a/layout/base/tests/input-minlength-invalid-change.html +++ b/layout/base/tests/input-minlength-invalid-change.html @@ -13,7 +13,7 @@ var input = document.getElementById('input'); input.setSelectionRange(input.value.length, input.value.length) input.focus(); - synthesizeKey('o', {}); + sendString("o"); input.blur(); // to hide the caret document.documentElement.className=''; } diff --git a/layout/base/tests/input-minlength-ui-invalid-change.html b/layout/base/tests/input-minlength-ui-invalid-change.html index cf00703ad8bd..29859e5c1da0 100644 --- a/layout/base/tests/input-minlength-ui-invalid-change.html +++ b/layout/base/tests/input-minlength-ui-invalid-change.html @@ -13,7 +13,7 @@ var input = document.getElementById('input'); input.setSelectionRange(input.value.length, input.value.length) input.focus(); - synthesizeKey('o', {}); + sendString("o"); input.blur(); // to hide the caret document.documentElement.className=''; } diff --git a/layout/base/tests/input-minlength-ui-valid-change.html b/layout/base/tests/input-minlength-ui-valid-change.html index 830c4acfa7f2..18656e4d179c 100644 --- a/layout/base/tests/input-minlength-ui-valid-change.html +++ b/layout/base/tests/input-minlength-ui-valid-change.html @@ -13,10 +13,10 @@ var input = document.getElementById('input'); input.setSelectionRange(input.value.length, input.value.length) input.focus(); - synthesizeKey('o', {}); // so that it becomes invalid first + sendString("o"); // so that it becomes invalid first input.blur(); input.focus(); - synthesizeKey('o', {}); + sendString("o"); input.blur(); // to hide the caret document.documentElement.className=''; } diff --git a/layout/base/tests/input-minlength-valid-change.html b/layout/base/tests/input-minlength-valid-change.html index 40a282682c6d..dd14178b33fd 100644 --- a/layout/base/tests/input-minlength-valid-change.html +++ b/layout/base/tests/input-minlength-valid-change.html @@ -13,10 +13,10 @@ var input = document.getElementById('input'); input.setSelectionRange(input.value.length, input.value.length) input.focus(); - synthesizeKey('o', {}); // so that it becomes invalid first + sendString("o"); // so that it becomes invalid first input.blur(); input.focus(); - synthesizeKey('o', {}); + sendString("o"); input.blur(); // to hide the caret document.documentElement.className=''; } diff --git a/layout/base/tests/test_bug332655-1.html b/layout/base/tests/test_bug332655-1.html index 8110cbfd3646..11817ebdaa49 100644 --- a/layout/base/tests/test_bug332655-1.html +++ b/layout/base/tests/test_bug332655-1.html @@ -29,21 +29,18 @@ function test() { var s1, s2, s3, equal, str1, str2; textInput.focus(); - synthesizeKey("a", { }); - synthesizeKey("b", { }); - synthesizeKey(" ", { }); - synthesizeKey("\u05d0", { }); - synthesizeKey("\u05d1", { }); + sendString("ab "); + sendString("\u05d0\u05d1"); s1 = snapshotWindow(window); - synthesizeKey(" ", { }); + sendString(" "); s2 = snapshotWindow(window); [equal, str1, str2] = compareSnapshots(s1, s2, true); ok(equal, "space after LTR + RTL shouldn't change direction: expected " + str1 + " but got " + str2); - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_Backspace"); s3 = snapshotWindow(window); [equal, str1, str2] = compareSnapshots(s1, s3, true); diff --git a/layout/base/tests/test_bug332655-2.html b/layout/base/tests/test_bug332655-2.html index b4dac3691b9c..f4fc0e383920 100644 --- a/layout/base/tests/test_bug332655-2.html +++ b/layout/base/tests/test_bug332655-2.html @@ -24,29 +24,20 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=332655 SimpleTest.waitForExplicitFinish(); -function repeatKey(key, repetitions) { - for (var i = 0; i < 4; ++i) { - synthesizeKey(key, {}); - } -} - function test() { var textInput = $("testInput"); var s1, s2, s3, equal, str1, str2; textInput.focus(); - synthesizeKey("\u05d0", { }); - synthesizeKey("a", { }); - synthesizeKey("b", { }); - synthesizeKey(" ", { }); - synthesizeKey("\u05d1", { }); - synthesizeKey("\u05d2", { }); + sendString("\u05d0"); + sendString("ab "); + sendString("\u05d1\u05d2"); s1 = snapshotWindow(window); // 4 LEFT to get to the beginning of the line: HOME doesn't work on OS X - repeatKey("VK_LEFT", 4); - synthesizeKey("VK_BACK_SPACE", { }); - synthesizeKey("\u05d0", { }); + synthesizeKey("KEY_ArrowLeft", {repeat: 4}); + synthesizeKey("KEY_Backspace"); + sendString("\u05d0"); s2 = snapshotWindow(window); [equal, str1, str2] = compareSnapshots(s1, s2, true); @@ -54,14 +45,11 @@ function test() { str1 + " but got " + str2); textInput.select(); - synthesizeKey("a", { }); - synthesizeKey("b", { }); - synthesizeKey(" ", { }); - synthesizeKey("\u05d1", { }); - synthesizeKey("\u05d2", { }); + sendString("ab "); + sendString("\u05d1\u05d2"); // 4 LEFT to get to the beginning of the line: HOME doesn't work on OS X - repeatKey("VK_LEFT", 4); - synthesizeKey("\u05d0", { }); + synthesizeKey("KEY_ArrowLeft", {repeat: 4}); + sendString("\u05d0"); s3 = snapshotWindow(window); diff --git a/layout/base/tests/test_bug370436.html b/layout/base/tests/test_bug370436.html index a3e8471bb7f5..b2b19896eed3 100644 --- a/layout/base/tests/test_bug370436.html +++ b/layout/base/tests/test_bug370436.html @@ -45,25 +45,25 @@ function startTest() var mouseParams = { type: 'contextmenu', button: 0 }; /* Put cursor at start and middle of "sheep" */ - synthesizeKey("VK_UP", {}) + synthesizeKey("KEY_ArrowUp") synthesizeMouse(ta, 0, 0, mouseParams); - synthesizeKey("VK_RIGHT", {}) + synthesizeKey("KEY_ArrowRight") synthesizeMouse(ta, 0, 0, mouseParams); - synthesizeKey("VK_RIGHT", {}) + synthesizeKey("KEY_ArrowRight") synthesizeMouse(ta, 0, 0, mouseParams); /* Put cursor at the end of "hello" */ - synthesizeKey("VK_UP", {}) + synthesizeKey("KEY_ArrowUp") synthesizeMouse(ta, 0, 0, mouseParams); - synthesizeKey("VK_RIGHT", {}) - synthesizeKey("VK_RIGHT", {}) - synthesizeKey("VK_RIGHT", {}) + synthesizeKey("KEY_ArrowRight") + synthesizeKey("KEY_ArrowRight") + synthesizeKey("KEY_ArrowRight") synthesizeMouse(ta, 0, 0, mouseParams); - synthesizeKey("VK_RIGHT", {}) + synthesizeKey("KEY_ArrowRight") synthesizeMouse(ta, 0, 0, mouseParams); /* Put cursor on "welcome" */ - synthesizeKey("VK_UP", {}) + synthesizeKey("KEY_ArrowUp") synthesizeMouse(ta, 0, 0, mouseParams); is(words.pop(), "welcome", "Word 1 selected correctly"); diff --git a/layout/base/tests/test_bug423523.html b/layout/base/tests/test_bug423523.html index c1fedf9aed52..3333bae0e9a0 100644 --- a/layout/base/tests/test_bug423523.html +++ b/layout/base/tests/test_bug423523.html @@ -71,15 +71,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=423523 ok(divIsFocused(), "Div should be focused [1]."); ok(selectionOffsetIs(0), "Caret should be at offset 0"); - synthesizeKey("VK_LEFT", { }); + synthesizeKey("KEY_ArrowLeft"); ok(divIsFocused(), "Div should be focused [2]."); ok(selectionOffsetIs(0), "Caret should be at offset 0"); - synthesizeKey("VK_RIGHT", { }); + synthesizeKey("KEY_ArrowRight"); ok(divIsFocused(), "Div should be focused [3]."); ok(selectionOffsetIs(1), "Caret should be at offset 1"); - synthesizeKey("VK_LEFT", { }); + synthesizeKey("KEY_ArrowLeft"); ok(divIsFocused(), "Div should be focused [4]."); ok(selectionOffsetIs(0), "Caret should be at offset 0"); @@ -89,7 +89,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=423523 ok(divIsFocused(), "Div should be focused [6]."); ok(selectionOffsetIs(0), "Caret should be at offset 0"); - synthesizeKey("VK_LEFT", { }); + synthesizeKey("KEY_ArrowLeft"); ok(divIsFocused(), "Div should be focused [7]."); ok(selectionOffsetIs(0), "Caret should be at offset 0"); diff --git a/layout/base/tests/test_bug499538-1.html b/layout/base/tests/test_bug499538-1.html index 054ce726ee2b..c46766ba1e09 100644 --- a/layout/base/tests/test_bug499538-1.html +++ b/layout/base/tests/test_bug499538-1.html @@ -28,23 +28,16 @@ function test() { var s1, s2, s3, equal, str1, str2; textInput.focus(); - synthesizeKey("a", { }); - synthesizeKey(" ", { }); - synthesizeKey("\u0639", { }); - synthesizeKey("\u063A", { }); - synthesizeKey(" ", { }); - synthesizeKey("b", { }); + sendString("a "); + sendString("\u0639\u063A"); + sendString(" b"); s1 = snapshotWindow(window); textInput.select(); - synthesizeKey("a", { }); - synthesizeKey(" ", { }); - synthesizeKey(" ", { }); - synthesizeKey("b", { }); - synthesizeKey("VK_LEFT", { }); - synthesizeKey("VK_LEFT", { }); - synthesizeKey("\u0639", { }); - synthesizeKey("\u063A", { }); + sendString("a b"); + synthesizeKey("KEY_ArrowLeft"); + synthesizeKey("KEY_ArrowLeft"); + sendString("\u0639\u063A"); s2 = snapshotWindow(window); [equal, str1, str2] = compareSnapshots(s1, s2, true); diff --git a/layout/base/tests/test_bug582181-1.html b/layout/base/tests/test_bug582181-1.html index c2cd399bddb4..b6c0f9442b98 100644 --- a/layout/base/tests/test_bug582181-1.html +++ b/layout/base/tests/test_bug582181-1.html @@ -32,9 +32,9 @@ function test() { s1 = snapshotWindow(window); textInput.focus(); - synthesizeKey("VK_DOWN", { }); - synthesizeKey("VK_DOWN", { }); - synthesizeKey("VK_RETURN", { }); + synthesizeKey("KEY_ArrowDown"); + synthesizeKey("KEY_ArrowDown"); + synthesizeKey("KEY_Enter"); textInput.blur(); s2 = snapshotWindow(window); @@ -43,7 +43,7 @@ function test() { str1 + " but got " + str2); textInput.focus(); - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_Backspace"); textInput.blur(); s3 = snapshotWindow(window); diff --git a/layout/base/tests/test_bug582181-2.html b/layout/base/tests/test_bug582181-2.html index 9577991ae741..65220e1f994f 100644 --- a/layout/base/tests/test_bug582181-2.html +++ b/layout/base/tests/test_bug582181-2.html @@ -34,11 +34,11 @@ function test() { s1 = snapshotWindow(window); textInput.focus(); - synthesizeKey("VK_DOWN", { }); - synthesizeKey("VK_DOWN", { }); - synthesizeKey("VK_DOWN", { }); - synthesizeKey("VK_DOWN", { }); - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_ArrowDown"); + synthesizeKey("KEY_ArrowDown"); + synthesizeKey("KEY_ArrowDown"); + synthesizeKey("KEY_ArrowDown"); + synthesizeKey("KEY_Backspace"); textInput.blur(); s2 = snapshotWindow(window); @@ -46,7 +46,7 @@ function test() { ok(unequal, "backspace after text should change rendering: got " + str2); textInput.focus(); - synthesizeKey(">", { }); + sendString(">"); textInput.blur(); s3 = snapshotWindow(window); diff --git a/layout/base/tests/test_bug644768.html b/layout/base/tests/test_bug644768.html index 297cd1c3b85f..b9965c6a6a93 100644 --- a/layout/base/tests/test_bug644768.html +++ b/layout/base/tests/test_bug644768.html @@ -41,11 +41,11 @@ textInput.focus(); s1 = snapshotWindow(window); - synthesizeKey("VK_UP", { }); - synthesizeKey("VK_UP", { }); - synthesizeKey("VK_UP", { }); - synthesizeKey("VK_DELETE", { }); - synthesizeKey("VK_RETURN", { }); + synthesizeKey("KEY_ArrowUp"); + synthesizeKey("KEY_ArrowUp"); + synthesizeKey("KEY_ArrowUp"); + synthesizeKey("KEY_Delete"); + synthesizeKey("KEY_Enter"); // Bug 1016184: Touch caret will hide due to key event. s2 = snapshotWindow(window); diff --git a/layout/base/tests/test_bug667512.html b/layout/base/tests/test_bug667512.html index 7bd89997a69c..3d13599a8ae2 100644 --- a/layout/base/tests/test_bug667512.html +++ b/layout/base/tests/test_bug667512.html @@ -25,8 +25,8 @@ function appendElements() { var x=document.getElementById('b'); x.remove(); - synthesizeKey("VK_LEFT", {}); - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowLeft"); + synthesizeKey("KEY_ArrowRight"); ok(true, "Should not crash!"); SimpleTest.finish(); diff --git a/layout/base/tests/test_scroll_snapping.html b/layout/base/tests/test_scroll_snapping.html index 1ba862ee1ca5..59f0cf861a42 100644 --- a/layout/base/tests/test_scroll_snapping.html +++ b/layout/base/tests/test_scroll_snapping.html @@ -26,7 +26,7 @@ var testCases = [ "scrollSnapCoordinate" : "525px 500px", "initialX" : 500, "initialY" : 500, - "key" : "VK_RIGHT", + "key" : "KEY_ArrowRight", "expectedX" : 525, "expectedY" : 500, "notExpected" : false @@ -41,7 +41,7 @@ var testCases = [ "scrollSnapCoordinate" : "475px 500px", "initialX" : 500, "initialY" : 500, - "key" : "VK_LEFT", + "key" : "KEY_ArrowLeft", "expectedX" : 475, "expectedY" : 500, "notExpected" : false @@ -56,7 +56,7 @@ var testCases = [ "scrollSnapCoordinate" : "500px 475px", "initialX" : 500, "initialY" : 500, - "key" : "VK_UP", + "key" : "KEY_ArrowUp", "expectedX" : 500, "expectedY" : 475, "notExpected" : false @@ -71,7 +71,7 @@ var testCases = [ "scrollSnapCoordinate" : "500px 525px", "initialX" : 500, "initialY" : 500, - "key" : "VK_DOWN", + "key" : "KEY_ArrowDown", "expectedX" : 500, "expectedY" : 525, "notExpected" : false @@ -86,7 +86,7 @@ var testCases = [ "scrollSnapCoordinate" : "700px 500px", "initialX" : 500, "initialY" : 500, - "key" : "VK_RIGHT", + "key" : "KEY_ArrowRight", "expectedX" : 700, "expectedY" : 500, "notExpected" : true @@ -101,7 +101,7 @@ var testCases = [ "scrollSnapCoordinate" : "300px 500px", "initialX" : 500, "initialY" : 500, - "key" : "VK_LEFT", + "key" : "KEY_ArrowLeft", "expectedX" : 300, "expectedY" : 500, "notExpected" : true @@ -116,7 +116,7 @@ var testCases = [ "scrollSnapCoordinate" : "500px 300px", "initialX" : 500, "initialY" : 500, - "key" : "VK_UP", + "key" : "KEY_ArrowUp", "expectedX" : 500, "expectedY" : 300, "notExpected" : true @@ -131,7 +131,7 @@ var testCases = [ "scrollSnapCoordinate" : "500px 700px", "initialX" : 500, "initialY" : 500, - "key" : "VK_DOWN", + "key" : "KEY_ArrowDown", "expectedX" : 500, "expectedY" : 700, "notExpected" : true @@ -146,7 +146,7 @@ var testCases = [ "scrollSnapCoordinate" : "700px 500px", "initialX" : 500, "initialY" : 500, - "key" : "VK_RIGHT", + "key" : "KEY_ArrowRight", "expectedX" : 700, "expectedY" : 500, "notExpected" : false @@ -161,7 +161,7 @@ var testCases = [ "scrollSnapCoordinate" : "300px 500px", "initialX" : 500, "initialY" : 500, - "key" : "VK_LEFT", + "key" : "KEY_ArrowLeft", "expectedX" : 300, "expectedY" : 500, "notExpected" : false @@ -176,7 +176,7 @@ var testCases = [ "scrollSnapCoordinate" : "500px 300px", "initialX" : 500, "initialY" : 500, - "key" : "VK_UP", + "key" : "KEY_ArrowUp", "expectedX" : 500, "expectedY" : 300, "notExpected" : false @@ -191,7 +191,7 @@ var testCases = [ "scrollSnapCoordinate" : "500px 700px", "initialX" : 500, "initialY" : 500, - "key" : "VK_DOWN", + "key" : "KEY_ArrowDown", "expectedX" : 500, "expectedY" : 700, "notExpected" : false @@ -206,7 +206,7 @@ var testCases = [ "scrollSnapCoordinate" : "none", "initialX" : 500, "initialY" : 500, - "key" : "VK_LEFT", + "key" : "KEY_ArrowLeft", "expectedX" : 500, "expectedY" : 500, "notExpected" : false @@ -221,7 +221,7 @@ var testCases = [ "scrollSnapCoordinate" : "none", "initialX" : 500, "initialY" : 500, - "key" : "VK_RIGHT", + "key" : "KEY_ArrowRight", "expectedX" : 500, "expectedY" : 500, "notExpected" : false @@ -236,7 +236,7 @@ var testCases = [ "scrollSnapCoordinate" : "none", "initialX" : 500, "initialY" : 500, - "key" : "VK_UP", + "key" : "KEY_ArrowUp", "expectedX" : 500, "expectedY" : 500, "notExpected" : false @@ -251,7 +251,7 @@ var testCases = [ "scrollSnapCoordinate" : "none", "initialX" : 500, "initialY" : 500, - "key" : "VK_DOWN", + "key" : "KEY_ArrowDown", "expectedX" : 500, "expectedY" : 500, "notExpected" : false @@ -266,7 +266,7 @@ var testCases = [ "scrollSnapCoordinate" : "none", "initialX" : 0, "initialY" : 200, - "key" : "VK_UP", + "key" : "KEY_ArrowUp", "expectedX" : 0, "expectedY" : 200, "notExpected" : false @@ -281,7 +281,7 @@ var testCases = [ "scrollSnapCoordinate" : "none", "initialX" : 0, "initialY" : 200, - "key" : "VK_PAGE_UP", + "key" : "KEY_PageUp", "expectedX" : 0, "expectedY" : 200, "notExpected" : false @@ -296,7 +296,7 @@ var testCases = [ "scrollSnapCoordinate" : "none", "initialX" : 0, "initialY" : 200, - "key" : "VK_HOME", + "key" : "KEY_Home", "expectedX" : 0, "expectedY" : 475, "notExpected" : false @@ -311,7 +311,7 @@ var testCases = [ "scrollSnapCoordinate" : "none", "initialX" : 200, "initialY" : 0, - "key" : "VK_LEFT", + "key" : "KEY_ArrowLeft", "expectedX" : 200, "expectedY" : 0, "notExpected" : false @@ -326,7 +326,7 @@ var testCases = [ "scrollSnapCoordinate" : "none", "initialX" : 0, "initialY" : 800, - "key" : "VK_DOWN", + "key" : "KEY_ArrowDown", "expectedX" : 0, "expectedY" : 800, "notExpected" : false @@ -341,7 +341,7 @@ var testCases = [ "scrollSnapCoordinate" : "none", "initialX" : 0, "initialY" : 800, - "key" : "VK_PAGE_DOWN", + "key" : "KEY_PageDown", "expectedX" : 0, "expectedY" : 800, "notExpected" : false @@ -356,7 +356,7 @@ var testCases = [ "scrollSnapCoordinate" : "none", "initialX" : 0, "initialY" : 800, - "key" : "VK_END", + "key" : "KEY_End", "expectedX" : 0, "expectedY" : 525, "notExpected" : false @@ -371,7 +371,7 @@ var testCases = [ "scrollSnapCoordinate" : "500px 100px", "initialX" : 500, "initialY" : 500, - "key" : "VK_HOME", + "key" : "KEY_Home", "expectedX" : 500, "expectedY" : 100, "notExpected" : false @@ -386,7 +386,7 @@ var testCases = [ "scrollSnapCoordinate" : "500px 900px", "initialX" : 500, "initialY" : 500, - "key" : "VK_END", + "key" : "KEY_End", "expectedX" : 500, "expectedY" : 900, "notExpected" : false @@ -401,7 +401,7 @@ var testCases = [ "scrollSnapCoordinate" : "none", "initialX" : 500, "initialY" : 500, - "key" : "VK_LEFT", + "key" : "KEY_ArrowLeft", "expectedX" : 500, "expectedY" : 500, "notExpected" : false @@ -416,7 +416,7 @@ var testCases = [ "scrollSnapCoordinate" : "none", "initialX" : 500, "initialY" : 500, - "key" : "VK_RIGHT", + "key" : "KEY_ArrowRight", "expectedX" : 500, "expectedY" : 500, "notExpected" : false @@ -431,7 +431,7 @@ var testCases = [ "scrollSnapCoordinate" : "none", "initialX" : 500, "initialY" : 500, - "key" : "VK_UP", + "key" : "KEY_ArrowUp", "expectedX" : 500, "expectedY" : 500, "notExpected" : false @@ -446,7 +446,7 @@ var testCases = [ "scrollSnapCoordinate" : "none", "initialX" : 500, "initialY" : 500, - "key" : "VK_DOWN", + "key" : "KEY_ArrowDown", "expectedX" : 500, "expectedY" : 500, "notExpected" : false @@ -461,7 +461,7 @@ var testCases = [ "scrollSnapCoordinate" : "120px 120px, 220px 220px", "initialX" : 0, "initialY" : 0, - "key" : "VK_RIGHT", + "key" : "KEY_ArrowRight", "expectedX" : 120, "expectedY" : 0, "notExpected" : false @@ -476,7 +476,7 @@ var testCases = [ "scrollSnapCoordinate" : "120px 120px, 220px 220px", "initialX" : 120, "initialY" : 0, - "key" : "VK_RIGHT", + "key" : "KEY_ArrowRight", "expectedX" : 200, "expectedY" : 0, "notExpected" : false @@ -492,7 +492,7 @@ var testCases = [ "scrollSnapCoordinate" : "120px 120px, 220px 220px", "initialX" : 200, "initialY" : 0, - "key" : "VK_RIGHT", + "key" : "KEY_ArrowRight", "expectedX" : 220, "expectedY" : 0, "notExpected" : false @@ -507,7 +507,7 @@ var testCases = [ "scrollSnapCoordinate" : "120px 120px, 220px 220px", "initialX" : 0, "initialY" : 300, - "key" : "VK_UP", + "key" : "KEY_ArrowUp", "expectedX" : 0, "expectedY" : 220, "notExpected" : false @@ -522,7 +522,7 @@ var testCases = [ "scrollSnapCoordinate" : "120px 120px, 220px 220px", "initialX" : 0, "initialY" : 220, - "key" : "VK_UP", + "key" : "KEY_ArrowUp", "expectedX" : 0, "expectedY" : 200, "notExpected" : false @@ -537,7 +537,7 @@ var testCases = [ "scrollSnapCoordinate" : "120px 120px, 220px 220px", "initialX" : 0, "initialY" : 200, - "key" : "VK_UP", + "key" : "KEY_ArrowUp", "expectedX" : 0, "expectedY" : 120, "notExpected" : false @@ -552,7 +552,7 @@ var testCases = [ "scrollSnapCoordinate" : "600px 600px, 475px 475px", "initialX" : 500, "initialY" : 500, - "key" : "VK_PAGE_DOWN", + "key" : "KEY_PageDown", "expectedX" : 500, "expectedY" : 600, "notExpected" : false @@ -567,7 +567,7 @@ var testCases = [ "scrollSnapCoordinate" : "400px 400px, 525px 525px", "initialX" : 500, "initialY" : 500, - "key" : "VK_PAGE_UP", + "key" : "KEY_PageUp", "expectedX" : 500, "expectedY" : 400, "notExpected" : false @@ -582,7 +582,7 @@ var testCases = [ "scrollSnapCoordinate" : "525px 525px, 550px 550px, 800px 800px", "initialX" : 500, "initialY" : 500, - "key" : "VK_PAGE_DOWN", + "key" : "KEY_PageDown", "expectedX" : 500, "expectedY" : 550, "notExpected" : false @@ -597,7 +597,7 @@ var testCases = [ "scrollSnapCoordinate" : "475px 475px, 450px 450px, 200px 200px", "initialX" : 500, "initialY" : 500, - "key" : "VK_PAGE_UP", + "key" : "KEY_PageUp", "expectedX" : 500, "expectedY" : 450, "notExpected" : false @@ -612,7 +612,7 @@ var testCases = [ "scrollSnapCoordinate" : "50px 50px, 800px 800px, 900px 900px", "initialX" : 100, "initialY" : 100, - "key" : "VK_PAGE_DOWN", + "key" : "KEY_PageDown", "expectedX" : 100, "expectedY" : 800, "notExpected" : false @@ -627,7 +627,7 @@ var testCases = [ "scrollSnapCoordinate" : "950px 950px, 200px 200px, 100px 100px", "initialX" : 900, "initialY" : 900, - "key" : "VK_PAGE_UP", + "key" : "KEY_PageUp", "expectedX" : 900, "expectedY" : 200, "notExpected" : false @@ -642,7 +642,7 @@ var testCases = [ "scrollSnapCoordinate" : "50px 50px, 800px 800px, 900px 900px", "initialX" : 100, "initialY" : 100, - "key" : "VK_PAGE_DOWN", + "key" : "KEY_PageDown", "expectedX" : 100, "expectedY" : 800, "notExpected" : false @@ -657,7 +657,7 @@ var testCases = [ "scrollSnapCoordinate" : "950px 950px, 200px 200px, 100px 100px", "initialX" : 900, "initialY" : 900, - "key" : "VK_PAGE_UP", + "key" : "KEY_PageUp", "expectedX" : 900, "expectedY" : 200, "notExpected" : false @@ -672,7 +672,7 @@ var testCases = [ "scrollSnapCoordinate" : "950px 950px, 200px 200px, 100px 100px", "initialX" : 900, "initialY" : 900, - "key" : "VK_LEFT", + "key" : "KEY_ArrowLeft", "expectedX" : 200, "expectedY" : 900, "notExpected" : false @@ -715,7 +715,7 @@ function initTest() { sd.style.scrollSnapCoordinate = testCase.scrollSnapCoordinate; sc.scrollTo(testCase.initialX, testCase.initialY); sc.focus(); - synthesizeKey(testCase.key, {}); + synthesizeKey(testCase.key); stopFrameCount = 0; lastScrollTop = sc.scrollTop; diff --git a/layout/base/tests/textarea-maxlength-invalid-change.html b/layout/base/tests/textarea-maxlength-invalid-change.html index 8c1691b91305..20de85a08a34 100644 --- a/layout/base/tests/textarea-maxlength-invalid-change.html +++ b/layout/base/tests/textarea-maxlength-invalid-change.html @@ -13,7 +13,7 @@ var textarea = document.getElementById('textarea'); textarea.setSelectionRange(textarea.value.length, textarea.value.length) textarea.focus(); - synthesizeKey('VK_BACK_SPACE', {}); + synthesizeKey("KEY_Backspace"); textarea.blur(); // to hide the caret document.documentElement.className=''; } diff --git a/layout/base/tests/textarea-maxlength-ui-invalid-change.html b/layout/base/tests/textarea-maxlength-ui-invalid-change.html index eed6de90fed4..77cbb1ced061 100644 --- a/layout/base/tests/textarea-maxlength-ui-invalid-change.html +++ b/layout/base/tests/textarea-maxlength-ui-invalid-change.html @@ -13,7 +13,7 @@ var textarea = document.getElementById('textarea'); textarea.setSelectionRange(textarea.value.length, textarea.value.length) textarea.focus(); - synthesizeKey('VK_BACK_SPACE', {}); + synthesizeKey("KEY_Backspace"); textarea.blur(); // to hide the caret document.documentElement.className=''; } diff --git a/layout/base/tests/textarea-maxlength-ui-valid-change.html b/layout/base/tests/textarea-maxlength-ui-valid-change.html index b7385ee6de3b..714ccf35087e 100644 --- a/layout/base/tests/textarea-maxlength-ui-valid-change.html +++ b/layout/base/tests/textarea-maxlength-ui-valid-change.html @@ -13,10 +13,10 @@ var textarea = document.getElementById('textarea'); textarea.setSelectionRange(textarea.value.length, textarea.value.length) textarea.focus(); - synthesizeKey('VK_BACK_SPACE', {}); // so that it becomes invalid first + synthesizeKey("KEY_Backspace"); // so that it becomes invalid first textarea.blur(); textarea.focus(); - synthesizeKey('VK_BACK_SPACE', {}); + synthesizeKey("KEY_Backspace"); textarea.blur(); // to hide the caret document.documentElement.className=''; } diff --git a/layout/base/tests/textarea-maxlength-valid-change.html b/layout/base/tests/textarea-maxlength-valid-change.html index c845111ac330..01f769cf72e3 100644 --- a/layout/base/tests/textarea-maxlength-valid-change.html +++ b/layout/base/tests/textarea-maxlength-valid-change.html @@ -13,10 +13,10 @@ var textarea = document.getElementById('textarea'); textarea.setSelectionRange(textarea.value.length, textarea.value.length) textarea.focus(); - synthesizeKey('VK_BACK_SPACE', {}); // so that it becomes invalid first + synthesizeKey("KEY_Backspace"); // so that it becomes invalid first textarea.blur(); textarea.focus(); - synthesizeKey('VK_BACK_SPACE', {}); + synthesizeKey("KEY_Backspace"); textarea.blur(); // to hide the caret document.documentElement.className=''; } diff --git a/layout/base/tests/textarea-minlength-invalid-change.html b/layout/base/tests/textarea-minlength-invalid-change.html index 3e26feada1e3..ca300d808895 100644 --- a/layout/base/tests/textarea-minlength-invalid-change.html +++ b/layout/base/tests/textarea-minlength-invalid-change.html @@ -13,7 +13,7 @@ var textarea = document.getElementById('textarea'); textarea.setSelectionRange(textarea.value.length, textarea.value.length) textarea.focus(); - synthesizeKey('o', {}); + sendString("o"); textarea.blur(); // to hide the caret document.documentElement.className=''; } diff --git a/layout/base/tests/textarea-minlength-ui-invalid-change.html b/layout/base/tests/textarea-minlength-ui-invalid-change.html index 99ce7721ee0f..bc27901d4768 100644 --- a/layout/base/tests/textarea-minlength-ui-invalid-change.html +++ b/layout/base/tests/textarea-minlength-ui-invalid-change.html @@ -13,7 +13,7 @@ var textarea = document.getElementById('textarea'); textarea.setSelectionRange(textarea.value.length, textarea.value.length) textarea.focus(); - synthesizeKey('o', {}); + sendString("o"); textarea.blur(); // to hide the caret document.documentElement.className=''; } diff --git a/layout/base/tests/textarea-minlength-ui-valid-change.html b/layout/base/tests/textarea-minlength-ui-valid-change.html index 1449b5fa2875..834614f583c8 100644 --- a/layout/base/tests/textarea-minlength-ui-valid-change.html +++ b/layout/base/tests/textarea-minlength-ui-valid-change.html @@ -13,10 +13,10 @@ var textarea = document.getElementById('textarea'); textarea.setSelectionRange(textarea.value.length, textarea.value.length) textarea.focus(); - synthesizeKey('o', {}); // so that it becomes invalid first + sendString("o"); // so that it becomes invalid first textarea.blur(); textarea.focus(); - synthesizeKey('o', {}); + sendString("o"); textarea.blur(); // to hide the caret document.documentElement.className=''; } diff --git a/layout/base/tests/textarea-minlength-valid-change.html b/layout/base/tests/textarea-minlength-valid-change.html index 081d5d21a443..993fe9b14066 100644 --- a/layout/base/tests/textarea-minlength-valid-change.html +++ b/layout/base/tests/textarea-minlength-valid-change.html @@ -13,10 +13,10 @@ var textarea = document.getElementById('textarea'); textarea.setSelectionRange(textarea.value.length, textarea.value.length) textarea.focus(); - synthesizeKey('o', {}); // so that it becomes invalid first + sendString("o"); // so that it becomes invalid first textarea.blur(); textarea.focus(); - synthesizeKey('o', {}); + sendString("o"); textarea.blur(); // to hide the caret document.documentElement.className=''; } diff --git a/layout/forms/test/test_bug1305282.html b/layout/forms/test/test_bug1305282.html index 39d59c9a5523..166965f6d3af 100644 --- a/layout/forms/test/test_bug1305282.html +++ b/layout/forms/test/test_bug1305282.html @@ -33,13 +33,13 @@ select.addEventListener("change", function(aEvent) { select.addEventListener("focus", function() { SimpleTest.executeSoon(function () { - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); SimpleTest.executeSoon(function () { - synthesizeKey('b', {}); + sendString("b"); SimpleTest.executeSoon(function () { - synthesizeKey(' ', {}); + sendString(" "); SimpleTest.executeSoon(function () { - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); }); }); }); diff --git a/layout/forms/test/test_bug1327129.html b/layout/forms/test/test_bug1327129.html index f8473d91455b..3b615abdfe95 100644 --- a/layout/forms/test/test_bug1327129.html +++ b/layout/forms/test/test_bug1327129.html @@ -181,7 +181,7 @@ function runTests() const listboxes = Array.from(document.querySelectorAll('select[size="3"]')); listboxes.forEach((elem) => { elem.focus(); - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); is(""+elem.selectedIndex, elem.getAttribute('firstNonDisabledIndex'), elem.id + ": DOWN selected first non-disabled option"); @@ -192,7 +192,7 @@ function runTests() if (!kIsMac) { comboboxes.forEach((elem) => { elem.focus(); - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); is(""+elem.selectedIndex, elem.getAttribute('firstNonDisabledIndex'), elem.id + ": DOWN selected first non-disabled option"); @@ -209,7 +209,7 @@ function runTests() // listboxes.forEach((elem) => { elem.focus(); - synthesizeKey("VK_DOWN", {shiftKey:true}); + synthesizeKey("KEY_ArrowDown", {shiftKey:true}); is(""+elem.selectedIndex, elem.getAttribute('firstNonDisabledIndex'), elem.id + ": SHIFT+DOWN selected first non-disabled option"); @@ -219,7 +219,7 @@ function runTests() if (!kIsMac) { comboboxes.forEach((elem) => { elem.focus(); - synthesizeKey("VK_DOWN", {shiftKey:true}); + synthesizeKey("KEY_ArrowDown", {shiftKey:true}); is(""+elem.selectedIndex, elem.getAttribute('firstNonDisabledIndex'), elem.id + ": SHIFT+DOWN selected first non-disabled option"); @@ -236,7 +236,7 @@ function runTests() // listboxes.forEach((elem) => { elem.focus(); - synthesizeKey("VK_DOWN", {ctrlKey:true}); + synthesizeKey("KEY_ArrowDown", {ctrlKey:true}); if (!elem.multiple) is(""+elem.selectedIndex, elem.getAttribute('firstNonDisabledIndex'), @@ -249,7 +249,7 @@ function runTests() if (!kIsMac) { comboboxes.forEach((elem) => { elem.focus(); - synthesizeKey("VK_DOWN", {ctrlKey:true}); + synthesizeKey("KEY_ArrowDown", {ctrlKey:true}); is(""+elem.selectedIndex, elem.getAttribute('firstNonDisabledIndex'), elem.id + ": CTRL+DOWN selected first non-disabled option"); @@ -266,7 +266,7 @@ function runTests() // listboxes.forEach((elem) => { elem.focus(); - synthesizeKey(" ", {}); + sendString(" "); is(""+elem.selectedIndex, elem.getAttribute('firstNonDisabledIndex'), elem.id + ": SPACE selected first non-disabled option"); @@ -331,7 +331,7 @@ function runTests() // listboxes.forEach((elem) => { elem.focus(); - synthesizeKey("VK_DOWN", {ctrlKey:true, shiftKey:true}); + synthesizeKey("KEY_ArrowDown", {ctrlKey:true, shiftKey:true}); is(""+elem.selectedIndex, elem.getAttribute('firstNonDisabledIndex'), elem.id + ": CTRL+SHIFT+DOWN selected first non-disabled option"); @@ -341,7 +341,7 @@ function runTests() if (!kIsMac) { comboboxes.forEach((elem) => { elem.focus(); - synthesizeKey("VK_DOWN", {ctrlKey:true, shiftKey:true}); + synthesizeKey("KEY_ArrowDown", {ctrlKey:true, shiftKey:true}); is(""+elem.selectedIndex, elem.getAttribute('firstNonDisabledIndex'), elem.id + ": CTRL+SHIFT+DOWN selected first non-disabled option"); diff --git a/layout/forms/test/test_bug346043.html b/layout/forms/test/test_bug346043.html index f509ae1fcbf4..d073c1bb82a7 100644 --- a/layout/forms/test/test_bug346043.html +++ b/layout/forms/test/test_bug346043.html @@ -21,7 +21,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=346043 // mouse events work with the dropdown itself, instead of the window below // it. select.focus(); - synthesizeKey("VK_DOWN", {altKey: true}); + synthesizeKey("KEY_ArrowDown", {altKey: true}); var options = select.getElementsByTagName("option"); synthesizeMouseAtCenter(options[1], @@ -29,7 +29,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=346043 // Close the select dropdown. if (useEscape) - synthesizeKey("VK_ESCAPE", {}); // Tests a different code path. + synthesizeKey("KEY_Escape"); // Tests a different code path. select.blur(); is(select.selectedIndex, index, "Selected index shouldn't change"); } diff --git a/layout/forms/test/test_bug411236.html b/layout/forms/test/test_bug411236.html index 7637fae00baf..cf78730df8e6 100644 --- a/layout/forms/test/test_bug411236.html +++ b/layout/forms/test/test_bug411236.html @@ -30,7 +30,7 @@ function test() { var i = 0; while (!window.oTarget && i < 100) { ++i; - synthesizeKey("KEY_Tab", {}); + synthesizeKey("KEY_Tab"); } if (i >= 100) { diff --git a/layout/forms/test/test_bug534785.html b/layout/forms/test/test_bug534785.html index 1a08bdc7cac0..fd2c22d53c34 100644 --- a/layout/forms/test/test_bug534785.html +++ b/layout/forms/test/test_bug534785.html @@ -32,7 +32,7 @@ SimpleTest.waitForFocus(function() { is(i.value, "test", "Sanity check"); is(document.activeElement, i, "Should be focused before frame reconstruction"); - synthesizeKey("1", {}); + sendString("1"); is(i.value, "1test", "Can accept keyboard events before frame reconstruction"); // force frame reconstruction @@ -42,7 +42,7 @@ SimpleTest.waitForFocus(function() { document.offsetHeight; is(document.activeElement, i, "Should be focused after frame reconstruction"); - synthesizeKey("2", {}); + sendString("2"); is(i.value, "12test", "Can accept keyboard events after frame reconstruction"); // Make sure reframing happens gracefully diff --git a/layout/forms/test/test_bug571352.html b/layout/forms/test/test_bug571352.html index 547ab400700b..5899b6988a32 100644 --- a/layout/forms/test/test_bug571352.html +++ b/layout/forms/test/test_bug571352.html @@ -33,10 +33,10 @@ SimpleTest.waitForFocus(function test() { var sel = $('display').firstChild; sel.removeChild(sel.childNodes[index]); } - function up() { synthesizeKey("VK_UP", {}); } - function shiftUp() { synthesizeKey("VK_UP", {shiftKey:true}); } - function down() { synthesizeKey("VK_DOWN", {}); } - function shiftDown() { synthesizeKey("VK_DOWN", {shiftKey:true}); } + function up() { synthesizeKey("KEY_ArrowUp"); } + function shiftUp() { synthesizeKey("KEY_ArrowUp", {shiftKey:true}); } + function down() { synthesizeKey("KEY_ArrowDown"); } + function shiftDown() { synthesizeKey("KEY_ArrowDown", {shiftKey:true}); } function mouseEvent(index,event) { synthesizeMouse(option(index), 5, 5, event); } diff --git a/layout/forms/test/test_bug672810.html b/layout/forms/test/test_bug672810.html index 3caf9e48b69a..ede2991f71d7 100644 --- a/layout/forms/test/test_bug672810.html +++ b/layout/forms/test/test_bug672810.html @@ -30,26 +30,26 @@ SimpleTest.waitForFocus(function() { sel[0].addEventListener('focus', function() { s = sel[0]; s.removeEventListener('focus', arguments.callee); - synthesizeKey('VK_DOWN', {}); + synthesizeKey('KEY_ArrowDown'); is(s.selectedIndex,0, s.id + ": initial DOWN selects first option"); - synthesizeKey('VK_DOWN', {ctrlKey: true}); + synthesizeKey('KEY_ArrowDown', {ctrlKey: true}); is(s.selectedIndex,0, s.id + ": first option is still selected"); ok(!s[1].selected,s.id + ": CTRL+DOWN did not select 2nd option"); - synthesizeKey('VK_DOWN', {ctrlKey: true}); - synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true}); + synthesizeKey('KEY_ArrowDown', {ctrlKey: true}); + synthesizeKey('KEY_ArrowDown', {ctrlKey: true, shiftKey: true}); is(s.selectedIndex,0, s.id + ": first option is still selected"); ok(!s[1].selected,s.id + ": 2nd option is still unselected"); ok(s[2].selected,s.id + ": 3rd option is selected"); ok(s[3].selected,s.id + ": 4th option is selected"); ok(!s[4].selected,s.id + ": 5th option is unselected"); - synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true}); + synthesizeKey('KEY_ArrowDown', {ctrlKey: true, shiftKey: true}); is(s.selectedIndex,0, s.id + ": first option is still selected"); ok(!s[1].selected,s.id + ": 2nd option is still unselected"); ok(s[2].selected,s.id + ": 3rd option is still selected"); ok(s[3].selected,s.id + ": 4th option is still selected"); ok(s[4].selected,s.id + ": 5th option is selected"); ok(!s[5].selected,s.id + ": 6th option is unselected"); - synthesizeKey('VK_UP', {ctrlKey: true, shiftKey: true}); + synthesizeKey('KEY_ArrowUp', {ctrlKey: true, shiftKey: true}); is(s.selectedIndex,0, s.id + ": first option is still selected"); ok(!s[1].selected,s.id + ": 2nd option is still unselected"); ok(s[2].selected,s.id + ": 3rd option is still selected"); @@ -75,13 +75,13 @@ SimpleTest.waitForFocus(function() { sel[1].addEventListener('focus', function() { s = sel[1]; s.removeEventListener('focus', arguments.callee); - synthesizeKey('VK_DOWN', {}); + synthesizeKey('KEY_ArrowDown'); is(s.selectedIndex,0, s.id + ": initial DOWN selects first option"); - synthesizeKey('VK_DOWN', {ctrlKey: true}); + synthesizeKey('KEY_ArrowDown', {ctrlKey: true}); is(s.selectedIndex,1, s.id + ": 2nd option is selected"); ok(!s[0].selected,s.id + ": CTRL+DOWN deselected first option"); - synthesizeKey('VK_DOWN', {ctrlKey: true}); - synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true}); + synthesizeKey('KEY_ArrowDown', {ctrlKey: true}); + synthesizeKey('KEY_ArrowDown', {ctrlKey: true, shiftKey: true}); is(s.selectedIndex,3, s.id + ": 4th option is selected"); ok(!s[1].selected,s.id + ": CTRL+SHIFT+DOWN deselected 2nd option"); synthesizeKey(' ', {ctrlKey: true, shiftKey: true}); @@ -94,12 +94,12 @@ SimpleTest.waitForFocus(function() { if (!navigator.platform.includes("Mac")) { s = sel[2]; s.removeEventListener('focus', arguments.callee); - synthesizeKey('VK_DOWN', {}); + synthesizeKey('KEY_ArrowDown'); is(s.selectedIndex,1, s.id + ": initial DOWN selects 2nd option"); - synthesizeKey('VK_DOWN', {ctrlKey: true}); + synthesizeKey('KEY_ArrowDown', {ctrlKey: true}); is(s.selectedIndex,2, s.id + ": 3rd option is selected"); ok(!s[1].selected,s.id + ": CTRL+DOWN deselected 2nd option"); - synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true}); + synthesizeKey('KEY_ArrowDown', {ctrlKey: true, shiftKey: true}); is(s.selectedIndex,3, s.id + ": 4th option is selected"); ok(!s[2].selected,s.id + ": CTRL+SHIFT+DOWN deselected 3rd option"); synthesizeKey(' ', {ctrlKey: true, shiftKey: true}); diff --git a/layout/forms/test/test_bug903715.html b/layout/forms/test/test_bug903715.html index 559b04b3b34b..f81b561df276 100644 --- a/layout/forms/test/test_bug903715.html +++ b/layout/forms/test/test_bug903715.html @@ -58,7 +58,7 @@ function runTests() select.addEventListener("popupshowing", function (aEvent) { setTimeout(function () { - synthesizeKey("VK_DOWN", { }); + synthesizeKey("KEY_ArrowDown"); select.addEventListener("popuphiding", function (aEvent) { setTimeout(function () { // Enter key should cause closing the dropdown of the select element @@ -69,12 +69,12 @@ function runTests() }, 100); }); // Close dropdown. - synthesizeKey("VK_RETURN", { }); + synthesizeKey("KEY_Enter"); }, 100); }); // Open dropdown. - synthesizeKey("VK_DOWN", { altKey: true }); + synthesizeKey("KEY_ArrowDown", { altKey: true }); } diff --git a/layout/forms/test/test_bug935876.html b/layout/forms/test/test_bug935876.html index a68fa952250a..ad8450563f72 100644 --- a/layout/forms/test/test_bug935876.html +++ b/layout/forms/test/test_bug935876.html @@ -127,66 +127,66 @@ function runTests() doPreventDefault = consume; for (var i = 0; i < listbox.options.length + 1; i++) { reset() - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); check(true, false, "DownArrow key on listbox #" + i); } for (var i = 0; i < listbox.options.length + 1; i++) { reset() - synthesizeKey("KEY_ArrowUp", {}); + synthesizeKey("KEY_ArrowUp"); check(true, false, "'ArrowUp' key on listbox #" + i); } for (var i = 0; i < listbox.options.length + 1; i++) { reset() - synthesizeKey("KEY_ArrowRight", {}); + synthesizeKey("KEY_ArrowRight"); check(true, false, "'ArrowRight' key on listbox #" + i); } for (var i = 0; i < listbox.options.length + 1; i++) { reset() - synthesizeKey("KEY_ArrowLeft", {}); + synthesizeKey("KEY_ArrowLeft"); check(true, false, "'ArrowLeft' key on listbox #" + i); } for (var i = 0; i < 4; i++) { reset() - synthesizeKey("KEY_PageDown", {}); + synthesizeKey("KEY_PageDown"); check(true, false, "'PageDown' key on listbox #" + i); } for (var i = 0; i < 4; i++) { reset() - synthesizeKey("KEY_PageUp", {}); + synthesizeKey("KEY_PageUp"); check(true, false, "'PageUp' key on listbox #" + i); } for (var i = 0; i < 2; i++) { reset() - synthesizeKey("KEY_End", {}); + synthesizeKey("KEY_End"); check(true, false, "'End' key on listbox #" + i); } for (var i = 0; i < 2; i++) { reset() - synthesizeKey("KEY_Home", {}); + synthesizeKey("KEY_Home"); check(true, false, "'Home' key on listbox #" + i); } reset() - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); check(false, true, "'Enter' key on listbox"); reset() - synthesizeKey("KEY_Escape", {}); + synthesizeKey("KEY_Escape"); check(false, false, "'Escape' key on listbox"); reset() - synthesizeKey("KEY_F4", {}); + synthesizeKey("KEY_F4"); check(false, false, "F4 key on listbox"); reset() - synthesizeKey("a", {}); + sendString("a"); check(false, true, "'A' key on listbox"); }); @@ -207,66 +207,66 @@ function runTests() doPreventDefault = consume; for (var i = 0; i < multipleListbox.options.length + 1; i++) { reset() - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); check(true, false, "'ArrowDown' key on multiple listbox #" + i); } for (var i = 0; i < multipleListbox.options.length + 1; i++) { reset() - synthesizeKey("KEY_ArrowUp", {}); + synthesizeKey("KEY_ArrowUp"); check(true, false, "'ArrowUp' key on multiple listbox #" + i); } for (var i = 0; i < multipleListbox.options.length + 1; i++) { reset() - synthesizeKey("KEY_ArrowRight", {}); + synthesizeKey("KEY_ArrowRight"); check(true, false, "'ArrowRight' key on multiple listbox #" + i); } for (var i = 0; i < multipleListbox.options.length + 1; i++) { reset() - synthesizeKey("KEY_ArrowLeft", {}); + synthesizeKey("KEY_ArrowLeft"); check(true, false, "'ArrowLeft' key on multiple listbox #" + i); } for (var i = 0; i < 4; i++) { reset() - synthesizeKey("KEY_PageDown", {}); + synthesizeKey("KEY_PageDown"); check(true, false, "'PageDown' key on multiple listbox #" + i); } for (var i = 0; i < 4; i++) { reset() - synthesizeKey("KEY_PageUp", {}); + synthesizeKey("KEY_PageUp"); check(true, false, "'PageUp' key on multiple listbox #" + i); } for (var i = 0; i < 2; i++) { reset() - synthesizeKey("KEY_End", {}); + synthesizeKey("KEY_End"); check(true, false, "'End' key on multiple listbox #" + i); } for (var i = 0; i < 2; i++) { reset() - synthesizeKey("KEY_Home", {}); + synthesizeKey("KEY_Home"); check(true, false, "'Home' key on multiple listbox #" + i); } reset() - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); check(true, true, "'Enter' key on multiple listbox"); reset() - synthesizeKey("KEY_Escape", {}); + synthesizeKey("KEY_Escape"); check(false, false, "'Escape' key on multiple listbox"); reset() - synthesizeKey("KEY_F4", {}); + synthesizeKey("KEY_F4"); check(false, false, "'F4' key on multiple listbox"); reset() - synthesizeKey("a", {}); + sendString("a"); check(false, true, "'A' key on multiple listbox"); }); @@ -288,13 +288,13 @@ function runTests() if (!kIsMac) { for (var i = 0; i < combobox.options.length + 1; i++) { reset() - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); check(true, false, "'ArrowDown' key on combobox #" + i); } for (var i = 0; i < combobox.options.length + 1; i++) { reset() - synthesizeKey("KEY_ArrowUp", {}); + synthesizeKey("KEY_ArrowUp"); check(true, false, "'ArrowUp' key on combobox #" + i); } } else { @@ -303,56 +303,56 @@ function runTests() for (var i = 0; i < combobox.options.length + 1; i++) { reset() - synthesizeKey("KEY_ArrowRight", {}); + synthesizeKey("KEY_ArrowRight"); check(true, false, "'ArrowRight' key on combobox #" + i); } for (var i = 0; i < combobox.options.length + 1; i++) { reset() - synthesizeKey("KEY_ArrowLeft", {}); + synthesizeKey("KEY_ArrowLeft"); check(true, false, "'ArrowLeft' key on combobox #" + i); } for (var i = 0; i < 4; i++) { reset() - synthesizeKey("KEY_PageDown", {}); + synthesizeKey("KEY_PageDown"); check(true, false, "'PageDown' key on combobox #" + i); } for (var i = 0; i < 4; i++) { reset() - synthesizeKey("KEY_PageUp", {}); + synthesizeKey("KEY_PageUp"); check(true, false, "'PageUp' key on combobox #" + i); } for (var i = 0; i < 2; i++) { reset() - synthesizeKey("KEY_End", {}); + synthesizeKey("KEY_End"); check(true, false, "'End' key on combobox #" + i); } for (var i = 0; i < 2; i++) { reset() - synthesizeKey("KEY_Home", {}); + synthesizeKey("KEY_Home"); check(true, false, "'Home' key on combobox #" + i); } reset() - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); check(false, true, "'Enter' key on combobox"); reset() - synthesizeKey("KEY_Escape", {}); + synthesizeKey("KEY_Escape"); check(true, false, "'Escape' key on combobox"); if (!kIsWin) { reset() - synthesizeKey("KEY_F4", {}); + synthesizeKey("KEY_F4"); check(false, false, "'F4' key on combobox"); } reset() - synthesizeKey("a", {}); + sendString("a"); check(false, true, "'A' key on combobox"); }); @@ -382,55 +382,55 @@ function runTests() for (var i = 0; i < combobox.options.length + 1; i++) { reset() - synthesizeKey("KEY_ArrowDown", {}); + synthesizeKey("KEY_ArrowDown"); check(true, false, "'ArrowDown' key on combobox during dropdown open #" + i); } for (var i = 0; i < combobox.options.length + 1; i++) { reset() - synthesizeKey("KEY_ArrowUp", {}); + synthesizeKey("KEY_ArrowUp"); check(true, false, "'ArrowUp' key on combobox during dropdown open #" + i); } for (var i = 0; i < combobox.options.length + 1; i++) { reset() - synthesizeKey("KEY_ArrowRight", {}); + synthesizeKey("KEY_ArrowRight"); check(true, false, "'ArrowRight' key on combobox during dropdown open #" + i); } for (var i = 0; i < combobox.options.length + 1; i++) { reset() - synthesizeKey("KEY_ArrowLeft", {}); + synthesizeKey("KEY_ArrowLeft"); check(true, false, "'ArrowLeft' key on combobox during dropdown open #" + i); } for (var i = 0; i < 4; i++) { reset() - synthesizeKey("KEY_PageDown", {}); + synthesizeKey("KEY_PageDown"); check(true, false, "'PageDown' key on combobox during dropdown open #" + i); } for (var i = 0; i < 4; i++) { reset() - synthesizeKey("KEY_PageUp", {}); + synthesizeKey("KEY_PageUp"); check(true, false, "'PageUp' key on combobox during dropdown open #" + i); } for (var i = 0; i < 2; i++) { reset() - synthesizeKey("KEY_End", {}); + synthesizeKey("KEY_End"); check(true, false, "'End' key on combobox during dropdown open #" + i); } for (var i = 0; i < 2; i++) { reset() - synthesizeKey("KEY_Home", {}); + synthesizeKey("KEY_Home"); check(true, false, "'Home' key on combobox during dropdown open #" + i); } testCloseDropDown(function () { reset() - synthesizeKey("KEY_Enter", {}); + synthesizeKey("KEY_Enter"); }, function () { testOpenDropDown(function () { check(true, true, "'Enter' key on combobox at closing dropdown"); @@ -441,7 +441,7 @@ function runTests() testCloseDropDown(function () { reset() - synthesizeKey("KEY_Escape", {}); + synthesizeKey("KEY_Escape"); }, function () { check(true, false, "'Escape' key on combobox at closing dropdown"); @@ -454,13 +454,13 @@ function runTests() testOpenDropDown(function () { reset() - synthesizeKey("KEY_F4", {}); + synthesizeKey("KEY_F4"); }, function () { check(true, false, "'F4' key on combobox at opening dropdown on Windows"); testCloseDropDown(function () { reset() - synthesizeKey("KEY_F4", {}); + synthesizeKey("KEY_F4"); }, function () { check(true, false, "'F4' key on combobox at closing dropdown on Windows"); diff --git a/layout/forms/test/test_listcontrol_search.html b/layout/forms/test/test_listcontrol_search.html index 7f73c5f7576c..243e7692352d 100644 --- a/layout/forms/test/test_listcontrol_search.html +++ b/layout/forms/test/test_listcontrol_search.html @@ -18,7 +18,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=849438 SimpleTest.waitForFocus(function() { var select = document.getElementsByTagName('select')[0]; select.focus(); - synthesizeKey('a', {}); + sendString('a'); is(select.options[0].selected, false, "the first option isn't selected"); is(select.options[1].selected, true, "the second option is selected"); diff --git a/layout/generic/test/test_bug240933.html b/layout/generic/test/test_bug240933.html index e4e20c37e4cf..20f588a8499f 100644 --- a/layout/generic/test/test_bug240933.html +++ b/layout/generic/test/test_bug240933.html @@ -38,18 +38,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=240933 t.focus(); t.selectionStart = t.selectionEnd = t.value.length; var val = t.value; - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); is(t.value, val + "\n", "Pressing enter right after focusing the textarea should work"); t = document.getElementById("tb"); t.focus(); - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); is(t.value, "\n", "Pressing enter for the first time should work"); - synthesizeKey("VK_RETURN", {}); + synthesizeKey("KEY_Enter"); is(t.value, "\n\n", "Pressing enter for the second time should work"); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); is(t.value, "\n", "Pressing backspace for the first time should work"); - synthesizeKey("VK_BACK_SPACE", {}); + synthesizeKey("KEY_Backspace"); is(t.value, "", "Pressing backspace for the second time should work"); SimpleTest.finish(); }); diff --git a/layout/generic/test/test_bug288789.html b/layout/generic/test/test_bug288789.html index 5c5e72569a49..2f09d090f08e 100644 --- a/layout/generic/test/test_bug288789.html +++ b/layout/generic/test/test_bug288789.html @@ -43,12 +43,12 @@ function test() { } function testRight(offset) { - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowRight"); is(textarea.selectionStart, offset, "Right movement broken"); } function testLeft(offset) { - synthesizeKey("VK_LEFT", {}); + synthesizeKey("KEY_ArrowLeft"); is(textarea.selectionStart, offset, "Left movement broken"); } diff --git a/layout/generic/test/test_bug404872.html b/layout/generic/test/test_bug404872.html index 42acabcb61ae..b70882c6edd7 100644 --- a/layout/generic/test/test_bug404872.html +++ b/layout/generic/test/test_bug404872.html @@ -26,8 +26,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=404872 /* Focus, press key down twice, and make sure we successfully selected the second item. */ $('a').focus(); -synthesizeKey("VK_DOWN", {}); -synthesizeKey("VK_DOWN", {}); +synthesizeKey("KEY_ArrowDown"); +synthesizeKey("KEY_ArrowDown"); is($("a").value, "value2", "value2 should be selected!"); diff --git a/layout/generic/test/test_bug424627.html b/layout/generic/test/test_bug424627.html index dd5f00c8927e..a5aecff0ffb1 100644 --- a/layout/generic/test/test_bug424627.html +++ b/layout/generic/test/test_bug424627.html @@ -28,7 +28,7 @@ SimpleTest.waitForFocus(function() { t.focus(); var originalValue = t.value; synthesizeMouse(t, 10, 30, {accelKey: true}); - synthesizeKey("x", {}); + sendString("x"); t = document.querySelector("textarea") ok(t, "The text area should not be removed from the document"); isnot(t.value, originalValue, "Its value should be modified"); diff --git a/layout/generic/test/test_bug448860.html b/layout/generic/test/test_bug448860.html index 6d1a8edcae37..60e00030ffca 100644 --- a/layout/generic/test/test_bug448860.html +++ b/layout/generic/test/test_bug448860.html @@ -42,11 +42,7 @@ function mapChange(mapNo){ } function focusarea() { - synthesizeKey("VK_TAB", {}); - synthesizeKey("VK_TAB", {}); - synthesizeKey("VK_TAB", {}); - synthesizeKey("VK_TAB", {}); - synthesizeKey("VK_TAB", {}); + synthesizeKey("KEY_Tab", {repeat: 5}); ok(true, "we did not crash"); SimpleTest.finish(); } diff --git a/layout/generic/test/test_bug468167.html b/layout/generic/test/test_bug468167.html index 2f8cf7c7e226..2238ab2fe4a4 100644 --- a/layout/generic/test/test_bug468167.html +++ b/layout/generic/test/test_bug468167.html @@ -42,7 +42,7 @@ function runTests() ta.setSelectionRange(0, 99); // 33 lines out of 40 // Send a backspace key event to delete the selection - synthesizeKey("VK_BACK_SPACE", { }); + synthesizeKey("KEY_Backspace"); is(ta.scrollTop, 0, "scrolled to top after deleting selection"); diff --git a/layout/generic/test/test_bug597333.html b/layout/generic/test/test_bug597333.html index 3eb6f78440ec..b84908921e75 100644 --- a/layout/generic/test/test_bug597333.html +++ b/layout/generic/test/test_bug597333.html @@ -22,7 +22,7 @@ function runTests() { var t = document.getElementById("a"); t.focus(); setTimeout(function() { - synthesizeKey('VK_RIGHT', {}); + synthesizeKey('KEY_ArrowRight'); ok(true, "The browser did not crash!"); SimpleTest.finish(); diff --git a/layout/generic/test/test_bug632379.xul b/layout/generic/test/test_bug632379.xul index 8e64085cc70d..0b5000f3ec50 100644 --- a/layout/generic/test/test_bug632379.xul +++ b/layout/generic/test/test_bug632379.xul @@ -179,8 +179,8 @@ function snapshot(elem) ++count; if (count <= 1) { // close the submenu and open the bottom submenu - synthesizeKey("VK_LEFT", {}); - synthesizeKey("9", {}); + synthesizeKey("KEY_ArrowLeft"); + sendString("9"); } else { if (!navigator.platform.includes("Mac")) { is(pos[1], pos[0], "Popup should open in the same place when the menu is scrolled"); @@ -205,7 +205,7 @@ function openSubmenu() todo(false, "openSubmenu() called"); } // open a submenu in the middle - synthesizeKey("5", {}); + sendString("5"); } SimpleTest.waitForExplicitFinish(); diff --git a/layout/generic/test/test_bug756984.html b/layout/generic/test/test_bug756984.html index 52f415261542..035b53af4c6c 100644 --- a/layout/generic/test/test_bug756984.html +++ b/layout/generic/test/test_bug756984.html @@ -86,19 +86,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=756984 selRange = sel.getRangeAt(0); is(selRange.endContainer.nodeName, "#text", "selection should be in text node (1)"); is(selRange.endOffset, 10, "offset should be 10"); - synthesizeKey("X", {}); + sendString("X"); // 2) Down arrow to the end of the second line, add "Y". - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); selRange = sel.getRangeAt(0); is(selRange.endContainer.nodeName, "#text", "selection should be in text node (2)"); is(selRange.endOffset, 3, "offset should be 3"); - synthesizeKey("Y", {}); + sendString("Y"); // 3) Right arrow and end key to the end of the third line, add "Z". - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowRight"); if (navigator.platform.indexOf("Win") == 0) { - synthesizeKey("VK_END", {}); + synthesizeKey("KEY_End"); } else { // End key doesn't work as expected on Mac and Linux. sel.modify("move", "right", "lineboundary"); @@ -106,26 +106,21 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=756984 selRange = sel.getRangeAt(0); is(selRange.endContainer.nodeName, "#text", "selection should be in text node (3)"); is(selRange.endOffset, 12, "offset should be 12"); - synthesizeKey("Z", {}); + sendString("Z"); // 4) Up arrow to the end of the second line, add "T". - synthesizeKey("VK_UP", {}); + synthesizeKey("KEY_ArrowUp"); selRange = sel.getRangeAt(0); is(selRange.endContainer.nodeName, "#text", "selection should be in text node (4)"); is(selRange.endOffset, 4, "offset should be 4"); - synthesizeKey("T", {}); + sendString("T"); // 5) Left arrow six times to the end of the first line, add "A". - synthesizeKey("VK_LEFT", {}); - synthesizeKey("VK_LEFT", {}); - synthesizeKey("VK_LEFT", {}); - synthesizeKey("VK_LEFT", {}); - synthesizeKey("VK_LEFT", {}); - synthesizeKey("VK_LEFT", {}); + synthesizeKey("KEY_ArrowLeft", {repeat: 6}); selRange = sel.getRangeAt(0); is(selRange.endContainer.nodeName, "#text", "selection should be in text node (5)"); is(selRange.endOffset, 11, "offset should be 11"); - synthesizeKey("A", {}); + sendString("A"); // Check the resulting HTML. First prepare what we expect. originalHTML = originalHTML.replace(/1234567890/, "1234567890XA"); diff --git a/layout/generic/test/test_bug784410.html b/layout/generic/test/test_bug784410.html index 313306d71703..c415e22aab33 100644 --- a/layout/generic/test/test_bug784410.html +++ b/layout/generic/test/test_bug784410.html @@ -69,7 +69,7 @@ function doneTest() { function test() { sel.collapse(inner.firstChild, 2); - synthesizeKey("VK_PAGE_DOWN", {}); + synthesizeKey("KEY_PageDown"); } SimpleTest.waitForExplicitFinish(); diff --git a/layout/generic/test/test_bug791616.html b/layout/generic/test/test_bug791616.html index e2816ea735b3..acab392e30b7 100644 --- a/layout/generic/test/test_bug791616.html +++ b/layout/generic/test/test_bug791616.html @@ -43,7 +43,7 @@ function runTest() { // Move the caret to scroll it into view sel.collapse(target.firstChild, 2); - synthesizeKey("VK_LEFT", {}); + synthesizeKey("KEY_ArrowLeft"); // Delay until next repaint in case stuff is asynchronous. Also // take a trip through the event loop. diff --git a/layout/generic/test/test_bug904810.html b/layout/generic/test/test_bug904810.html index b2b4355e7709..a738f4476247 100644 --- a/layout/generic/test/test_bug904810.html +++ b/layout/generic/test/test_bug904810.html @@ -35,12 +35,12 @@ SimpleTest.expectAssertions(0, 2); SimpleTest.waitForFocus(function test() { function shiftLeft(i) { for ( ; i > 0; --i) - synthesizeKey("VK_LEFT", {shiftKey:true}); + synthesizeKey("KEY_ArrowLeft", {shiftKey:true}); } function shiftRight(i) { for ( ; i > 0; --i) - synthesizeKey("VK_RIGHT", {shiftKey:true}); + synthesizeKey("KEY_ArrowRight", {shiftKey:true}); } const isWindows = /WINNT/.test(SpecialPowers.OS); @@ -48,11 +48,11 @@ SimpleTest.waitForFocus(function test() { var textarea = document.getElementById('textarea904810'); textarea.focus(); - // Testing VK_DOWN with forward selection + // Testing KEY_ArrowDown with forward selection textarea.selectionStart = 1; textarea.selectionEnd = 1; shiftRight(7); - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); if (isWindows) { is(textarea.selectionStart, 19, "caret moved to next line below selection end"); is(textarea.selectionEnd, 19, "caret moved to next line below selection end"); @@ -61,11 +61,11 @@ SimpleTest.waitForFocus(function test() { is(textarea.selectionEnd, 8, "caret moved to visual end of selection"); } - // Testing VK_DOWN with backward selection + // Testing KEY_ArrowDown with backward selection textarea.selectionStart = 8; textarea.selectionEnd = 8; shiftLeft(7); - synthesizeKey("VK_DOWN", {}); + synthesizeKey("KEY_ArrowDown"); if (isWindows) { is(textarea.selectionStart, 12, "caret moved to next line below selection start"); is(textarea.selectionEnd, 12, "caret moved to next line below selection start"); @@ -74,11 +74,11 @@ SimpleTest.waitForFocus(function test() { is(textarea.selectionEnd, 8, "caret moved to visual end of selection"); } - // Testing VK_UP with forward selection + // Testing KEY_ArrowUp with forward selection textarea.selectionStart = 12; textarea.selectionEnd = 12; shiftRight(7); - synthesizeKey("VK_UP", {}); + synthesizeKey("KEY_ArrowUp"); var result = textarea.selectionEnd if (isWindows) { is(textarea.selectionStart, 8, "caret moved to previous line above selection end"); @@ -88,11 +88,11 @@ SimpleTest.waitForFocus(function test() { is(textarea.selectionEnd, 12, "caret moved to visual start of selection"); } - // Testing VK_UP with backward selection + // Testing KEY_ArrowUp with backward selection textarea.selectionStart = 19; textarea.selectionEnd = 19; shiftLeft(7); - synthesizeKey("VK_UP", {}); + synthesizeKey("KEY_ArrowUp"); var result = textarea.selectionEnd if (isWindows) { is(textarea.selectionStart, 1, "caret moved to previous line above selection start"); diff --git a/layout/generic/test/test_bug970363.html b/layout/generic/test/test_bug970363.html index e0ac0370aca6..d7fda754e0cb 100644 --- a/layout/generic/test/test_bug970363.html +++ b/layout/generic/test/test_bug970363.html @@ -34,11 +34,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=970363 sel.collapse(t, 0); // Move past the 'S' char. - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowRight"); // Move across the span. - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowRight"); // Insert an 'I' to show when IP currently is. - synthesizeKey("I", {}); + sendString("I"); is(t.textContent, "SreadonlyIE", "the 'I' char should be inserted between 'readonly' and 'E'"); SimpleTest.finish(); diff --git a/layout/generic/test/test_movement_by_characters.html b/layout/generic/test/test_movement_by_characters.html index d85e4e0f44de..6e67c21afdd9 100644 --- a/layout/generic/test/test_movement_by_characters.html +++ b/layout/generic/test/test_movement_by_characters.html @@ -34,13 +34,13 @@ function test() { var editor = document.getElementById("editor"); function testRight(node, offset) { - synthesizeKey("VK_RIGHT", {}); + synthesizeKey("KEY_ArrowRight"); is(sel.anchorNode, node, "Right movement broken in " + editor.innerHTML); is(sel.anchorOffset, offset, "Right movement broken in " + editor.innerHTML); } function testLeft(node, offset) { - synthesizeKey("VK_LEFT", {}); + synthesizeKey("KEY_ArrowLeft"); is(sel.anchorNode, node, "Left movement broken in " + editor.innerHTML); is(sel.anchorOffset, offset, "Left movement broken in " + editor.innerHTML); } diff --git a/layout/style/test/chrome/test_display_mode.html b/layout/style/test/chrome/test_display_mode.html index b035bf7e1d6a..137e00360387 100644 --- a/layout/style/test/chrome/test_display_mode.html +++ b/layout/style/test/chrome/test_display_mode.html @@ -64,14 +64,14 @@ add_task(async function() { // Test entering the OS's fullscreen mode. var fullScreenEntered = waitOneEvent(win, "sizemodechange"); - synthesizeKey("VK_F11", {}); + synthesizeKey("KEY_F11"); await fullScreenEntered; // Wait for the next tick to apply media feature changes. See bug 1430380. await promiseNextTick(); shouldApply("all and (display-mode: fullscreen)"); shouldNotApply("all and (display-mode: browser)"); var fullScreenExited = waitOneEvent(win, "sizemodechange"); - synthesizeKey("VK_F11", {}); + synthesizeKey("KEY_F11"); await fullScreenExited; // Wait for the next tick to apply media feature changes. See bug 1430380. await promiseNextTick(); diff --git a/layout/style/test/chrome/test_display_mode_reflow.html b/layout/style/test/chrome/test_display_mode_reflow.html index 1f766bdf403d..66bd61c0c581 100644 --- a/layout/style/test/chrome/test_display_mode_reflow.html +++ b/layout/style/test/chrome/test_display_mode_reflow.html @@ -43,14 +43,14 @@ add_task(async function() { // Test entering the OS's fullscreen mode. var fullScreenEntered = waitOneEvent(win, "sizemodechange"); - synthesizeKey("VK_F11", {}); + synthesizeKey("KEY_F11"); await fullScreenEntered; // Wait for the next tick to apply media feature changes. See bug 1430380. await promiseNextTick(); ok(offsetTop !== secondDiv.offsetTop, "offset top changes"); var fullScreenExited = waitOneEvent(win, "sizemodechange"); - synthesizeKey("VK_F11", {}); + synthesizeKey("KEY_F11"); await fullScreenExited; // Wait for the next tick to apply media feature changes. See bug 1430380. diff --git a/layout/style/test/test_flexbox_focus_order.html b/layout/style/test/test_flexbox_focus_order.html index 44c764f2d22a..47d1d442ec14 100644 --- a/layout/style/test/test_flexbox_focus_order.html +++ b/layout/style/test/test_flexbox_focus_order.html @@ -60,7 +60,7 @@ function doTest() { // And then we advance focus across the focusable things in the flex container // and check that we traverse them in the expected order: for (let expectedId of gExpectedFocusedIds) { - synthesizeKey("KEY_Tab", {}); + synthesizeKey("KEY_Tab"); is(document.activeElement, document.getElementById(expectedId), "expecting element '#" + expectedId + "' to be focused"); } diff --git a/layout/xul/test/browser_bug1163304.js b/layout/xul/test/browser_bug1163304.js index 9dec3a3c77ae..acdbf9ee9021 100644 --- a/layout/xul/test/browser_bug1163304.js +++ b/layout/xul/test/browser_bug1163304.js @@ -19,7 +19,7 @@ function test() { is(DOMWindowUtils.IMEStatus, DOMWindowUtils.IME_STATUS_DISABLED, "IME should not be available when menubar is active"); // Inactivate the menubar (and restore the focus to the searchbar - EventUtils.synthesizeKey("VK_ESCAPE", {}); + EventUtils.synthesizeKey("KEY_Escape"); is(DOMWindowUtils.IMEStatus, DOMWindowUtils.IME_STATUS_ENABLED, "IME should be available after focus is back to the searchbar"); Services.prefs.clearUserPref("browser.search.widget.inNavBar"); @@ -27,9 +27,9 @@ function test() { }, 0); }, {once: true}); // Activate the menubar, then, the popup should be closed - EventUtils.synthesizeKey("VK_ALT", {}); + EventUtils.synthesizeKey("KEY_Alt"); }, 0); }, {once: true}); // Open popup of the searchbar - EventUtils.synthesizeKey("VK_F4", {}); + EventUtils.synthesizeKey("KEY_F4"); } diff --git a/testing/mochitest/tests/Harness_sanity/test_sanity.html b/testing/mochitest/tests/Harness_sanity/test_sanity.html index 3c9266685663..0ca52715363d 100644 --- a/testing/mochitest/tests/Harness_sanity/test_sanity.html +++ b/testing/mochitest/tests/Harness_sanity/test_sanity.html @@ -33,13 +33,13 @@ isnot(undefined, null, "Undefined must not be null"); var press1 = false; $("testKeyEvent1").focus(); -synthesizeKey("x", {}); +sendString("x"); is($("testKeyEvent1").value, "x", "synthesizeKey should work"); is(press1, true, "synthesizeKey should dispatch keyPress"); var press2 = false; $("testKeyEvent2").focus(); -synthesizeKey("x", {}); +sendString("x"); is($("testKeyEvent2").value, "", "synthesizeKey should respect keydown preventDefault"); is(press2, false, "synthesizeKey should not dispatch keyPress with default prevented"); diff --git a/testing/mochitest/tests/Harness_sanity/test_sanityEventUtils.html b/testing/mochitest/tests/Harness_sanity/test_sanityEventUtils.html index f1a8e05723f1..264c23e59dad 100644 --- a/testing/mochitest/tests/Harness_sanity/test_sanityEventUtils.html +++ b/testing/mochitest/tests/Harness_sanity/test_sanityEventUtils.html @@ -112,7 +112,7 @@ function starttest() { check = false; $("testKeyEvent").addEventListener("keypress", function() { check = true; }); $("testKeyEvent").focus(); - synthesizeKey("a", {}); + sendString("a"); is($("testKeyEvent").value, "a", "synthesizeKey should work"); is(check, true, "synthesizeKey should dispatch keyPress"); $("testKeyEvent").value = ""; diff --git a/toolkit/components/passwordmgr/test/browser/browser_formless_submit_chrome.js b/toolkit/components/passwordmgr/test/browser/browser_formless_submit_chrome.js index 09ac7e967f31..83ae8afa2ee1 100644 --- a/toolkit/components/passwordmgr/test/browser/browser_formless_submit_chrome.js +++ b/toolkit/components/passwordmgr/test/browser/browser_formless_submit_chrome.js @@ -39,7 +39,7 @@ add_task(async function test_urlbar_new_URL() { await focusPromise; info("focused"); EventUtils.sendString("http://mochi.test:8888/"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); await BrowserTestUtils.browserLoaded(aBrowser, false, "http://mochi.test:8888/"); }); }); @@ -47,9 +47,9 @@ add_task(async function test_urlbar_new_URL() { add_task(async function test_urlbar_fragment_enter() { await withTestPage(function(aBrowser) { gURLBar.focus(); - EventUtils.synthesizeKey("VK_RIGHT", {}); + EventUtils.synthesizeKey("KEY_ArrowRight"); EventUtils.sendString("#fragment"); - EventUtils.synthesizeKey("VK_RETURN", {}); + EventUtils.synthesizeKey("KEY_Enter"); }); }); @@ -127,7 +127,7 @@ add_task(async function test_back_keyboard_shortcut() { await fillTestPage(aBrowser); let backPromise = BrowserTestUtils.browserStopped(aBrowser); - EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + EventUtils.synthesizeKey("KEY_Backspace"); await backPromise; }); }); diff --git a/toolkit/components/passwordmgr/test/browser/browser_notifications_2.js b/toolkit/components/passwordmgr/test/browser/browser_notifications_2.js index 3de74127d487..d78119115029 100644 --- a/toolkit/components/passwordmgr/test/browser/browser_notifications_2.js +++ b/toolkit/components/passwordmgr/test/browser/browser_notifications_2.js @@ -36,8 +36,8 @@ add_task(async function test_empty_password() { // Synthesize input to empty the field passwordTextbox.focus(); - await EventUtils.synthesizeKey("VK_RIGHT", {}); - await EventUtils.synthesizeKey("VK_BACK_SPACE", {}); + await EventUtils.synthesizeKey("KEY_ArrowRight"); + await EventUtils.synthesizeKey("KEY_Backspace"); let mainActionButton = notificationElement.button; Assert.ok(mainActionButton.disabled, "Main action button is disabled"); diff --git a/toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_4.html b/toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_4.html index 3b19e30d5dae..cc620e4f9fed 100644 --- a/toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_4.html +++ b/toolkit/components/passwordmgr/test/chrome/subtst_privbrowsing_4.html @@ -21,13 +21,13 @@