Browse Source

Assert key and code in keyup input event spec

Kevin Sawicki 8 years ago
parent
commit
e4b0577cb0
3 changed files with 3 additions and 2 deletions
  1. 1 0
      atom/common/keyboard_util.h
  2. 1 1
      spec/fixtures/pages/onkeyup.html
  3. 1 1
      spec/webview-spec.js

+ 1 - 0
atom/common/keyboard_util.h

@@ -15,6 +15,7 @@ namespace atom {
 // pressed.
 ui::KeyboardCode KeyboardCodeFromStr(const std::string& str, bool* shifted);
 
+// Ported from ui/events/blink/blink_event_util.h
 int WebEventModifiersToEventFlags(int modifiers);
 
 }  // namespace atom

+ 1 - 1
spec/fixtures/pages/onkeyup.html

@@ -2,7 +2,7 @@
 <body>
 <script type="text/javascript" charset="utf-8">
 document.onkeyup = function(e) {
-  require('electron').ipcRenderer.sendToHost('keyup', e.keyCode, e.shiftKey, e.ctrlKey);
+  require('electron').ipcRenderer.sendToHost('keyup', e.key, e.code, e.keyCode, e.shiftKey, e.ctrlKey);
 }
 </script>
 </body>

+ 1 - 1
spec/webview-spec.js

@@ -776,7 +776,7 @@ describe('<webview> tag', function () {
     it('can send keyboard event', function (done) {
       webview.addEventListener('ipc-message', function (e) {
         assert.equal(e.channel, 'keyup')
-        assert.deepEqual(e.args, [67, true, false])
+        assert.deepEqual(e.args, ['C', 'KeyC', 67, true, false])
         done()
       })
       webview.addEventListener('dom-ready', function () {