diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/sourceeditor/test/browser_editor_autocomplete_events.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/sourceeditor/test/browser_editor_autocomplete_events.js')
-rw-r--r-- | devtools/client/sourceeditor/test/browser_editor_autocomplete_events.js | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/devtools/client/sourceeditor/test/browser_editor_autocomplete_events.js b/devtools/client/sourceeditor/test/browser_editor_autocomplete_events.js new file mode 100644 index 000000000..e2f976afe --- /dev/null +++ b/devtools/client/sourceeditor/test/browser_editor_autocomplete_events.js @@ -0,0 +1,126 @@ +/* vim: set ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const {InspectorFront} = require("devtools/shared/fronts/inspector"); +const AUTOCOMPLETION_PREF = "devtools.editor.autocomplete"; +const TEST_URI = "data:text/html;charset=UTF-8,<html><body><bar></bar>" + + "<div id='baz'></div><body></html>"; + +add_task(function* () { + yield addTab(TEST_URI); + yield runTests(); +}); + +function* runTests() { + let target = TargetFactory.forTab(gBrowser.selectedTab); + yield target.makeRemote(); + let inspector = InspectorFront(target.client, target.form); + let walker = yield inspector.getWalker(); + let {ed, win, edWin} = yield setup(null, { + autocomplete: true, + mode: Editor.modes.css, + autocompleteOpts: {walker: walker, cssProperties: getClientCssProperties()} + }); + yield testMouse(ed, edWin); + yield testKeyboard(ed, edWin); + yield testKeyboardCycle(ed, edWin); + yield testKeyboardCycleForPrefixedString(ed, edWin); + yield testKeyboardCSSComma(ed, edWin); + teardown(ed, win); +} + +function* testKeyboard(ed, win) { + ed.focus(); + ed.setText("b"); + ed.setCursor({line: 1, ch: 1}); + + let popupOpened = ed.getAutocompletionPopup().once("popup-opened"); + + let autocompleteKey = + Editor.keyFor("autocompletion", { noaccel: true }).toUpperCase(); + EventUtils.synthesizeKey("VK_" + autocompleteKey, { ctrlKey: true }, win); + + info("Waiting for popup to be opened"); + yield popupOpened; + + EventUtils.synthesizeKey("VK_RETURN", { }, win); + is(ed.getText(), "bar", "Editor text has been updated"); +} + +function* testKeyboardCycle(ed, win) { + ed.focus(); + ed.setText("b"); + ed.setCursor({line: 1, ch: 1}); + + let popupOpened = ed.getAutocompletionPopup().once("popup-opened"); + + let autocompleteKey = + Editor.keyFor("autocompletion", { noaccel: true }).toUpperCase(); + EventUtils.synthesizeKey("VK_" + autocompleteKey, { ctrlKey: true }, win); + + info("Waiting for popup to be opened"); + yield popupOpened; + + EventUtils.synthesizeKey("VK_DOWN", { }, win); + is(ed.getText(), "bar", "Editor text has been updated"); + + EventUtils.synthesizeKey("VK_DOWN", { }, win); + is(ed.getText(), "body", "Editor text has been updated"); + + EventUtils.synthesizeKey("VK_DOWN", { }, win); + is(ed.getText(), "#baz", "Editor text has been updated"); +} + +function* testKeyboardCycleForPrefixedString(ed, win) { + ed.focus(); + ed.setText("#b"); + ed.setCursor({line: 1, ch: 2}); + + let popupOpened = ed.getAutocompletionPopup().once("popup-opened"); + + let autocompleteKey = + Editor.keyFor("autocompletion", { noaccel: true }).toUpperCase(); + EventUtils.synthesizeKey("VK_" + autocompleteKey, { ctrlKey: true }, win); + + info("Waiting for popup to be opened"); + yield popupOpened; + + EventUtils.synthesizeKey("VK_DOWN", { }, win); + is(ed.getText(), "#baz", "Editor text has been updated"); +} + +function* testKeyboardCSSComma(ed, win) { + ed.focus(); + ed.setText("b"); + ed.setCursor({line: 1, ch: 1}); + + let isPopupOpened = false; + let popupOpened = ed.getAutocompletionPopup().once("popup-opened"); + popupOpened.then(() => isPopupOpened = true); + + EventUtils.synthesizeKey(",", { }, win); + + yield wait(500); + + ok(!isPopupOpened, "Autocompletion shouldn't be opened"); +} + +function* testMouse(ed, win) { + ed.focus(); + ed.setText("b"); + ed.setCursor({line: 1, ch: 1}); + + let popupOpened = ed.getAutocompletionPopup().once("popup-opened"); + + let autocompleteKey = + Editor.keyFor("autocompletion", { noaccel: true }).toUpperCase(); + EventUtils.synthesizeKey("VK_" + autocompleteKey, { ctrlKey: true }, win); + + info("Waiting for popup to be opened"); + yield popupOpened; + ed.getAutocompletionPopup()._list.children[2].click(); + is(ed.getText(), "#baz", "Editor text has been updated"); +} |