diff options
Diffstat (limited to 'devtools/client/shared/sourceeditor/test/browser_editor_alt_b_f.js')
-rw-r--r-- | devtools/client/shared/sourceeditor/test/browser_editor_alt_b_f.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/devtools/client/shared/sourceeditor/test/browser_editor_alt_b_f.js b/devtools/client/shared/sourceeditor/test/browser_editor_alt_b_f.js new file mode 100644 index 0000000000..cacefd8dac --- /dev/null +++ b/devtools/client/shared/sourceeditor/test/browser_editor_alt_b_f.js @@ -0,0 +1,46 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Ensure Alt-B and Alt-F keyboard shortcuts work as expected in the source editor. +// See Bug 1481443. + +add_task(async function () { + const { ed, win } = await setup(); + const editorDoc = ed.container.contentDocument; + await promiseWaitForFocus(); + const isMacOS = Services.appinfo.OS === "Darwin"; + + ed.focus(); + + const initialText = "a b c d e"; + ed.setText(initialText); + + ed.setCursor({ line: 1, ch: initialText.length }); + + EventUtils.synthesizeKey("b", { altKey: true }, editorDoc.defaultView); + + // A character is added only on OSX. + let expectedText = isMacOS ? initialText + "b" : initialText; + is( + ed.getCursor().ch, + expectedText.length, + "Cursor is at expected position after Alt-B" + ); + is(ed.getText(), expectedText, "Editor has expected content after Alt-B"); + + EventUtils.synthesizeKey("f", { altKey: true }, editorDoc.defaultView); + + // A character is added only on OSX. + expectedText = isMacOS ? expectedText + "f" : initialText; + is( + ed.getCursor().ch, + expectedText.length, + "Cursor is at expected position after Alt-F" + ); + is(ed.getText(), expectedText, "Editor has expected content after Alt-F"); + + ed.destroy(); + win.close(); +}); |