Skip to content

Commit 5c1807c

Browse files
committed
Add testing for osx keydown browser bug
On macOS, there is an existing bug that will always report the keydown event.key as lowercase, even when pressing cmd-shift-letter. This can result in the toolbar hotkey firing for both the uppercase and lowercase meta keys. This was fixed in a prior commit, but a test is being added here to emulate this behavior in the test, so that there is a “breaking” regression test.
1 parent b540e7c commit 5c1807c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ describe('markdown-toolbar-element', function () {
4141
event.initEvent('keydown', true, true)
4242
event.metaKey = osx
4343
event.ctrlKey = !osx
44-
event.key = hotkey
44+
event.shiftKey = hotkey === hotkey.toUpperCase()
45+
46+
// emulate existing osx browser bug
47+
// https://bugs.webkit.org/show_bug.cgi?id=174782
48+
event.key = osx ? hotkey.toLowerCase() : hotkey
49+
4550
textarea.dispatchEvent(event)
4651
}
4752

0 commit comments

Comments
 (0)