From c061b27076be5480dc6141e2180886b0ae604bdf Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 24 Nov 2015 17:36:44 +0100 Subject: [PATCH] :white_check_mark: --- spec/window-event-handler-spec.coffee | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/spec/window-event-handler-spec.coffee b/spec/window-event-handler-spec.coffee index 3148942b4..a988ae7de 100644 --- a/spec/window-event-handler-spec.coffee +++ b/spec/window-event-handler-spec.coffee @@ -200,3 +200,34 @@ describe "WindowEventHandler", -> expect(dispatchedCommands.length).toBe 1 expect(dispatchedCommands[0].type).toBe 'foo-command' + + describe "native key bindings", -> + it "correctly dispatches them to active elements with the '.native-key-bindings' class", -> + webContentsSpy = jasmine.createSpyObj("webContents", ["copy", "paste"]) + spyOn(atom.applicationDelegate, "getCurrentWindow").andReturn({ + webContents: webContentsSpy + }) + + nativeKeyBindingsInput = document.createElement("input") + nativeKeyBindingsInput.classList.add("native-key-bindings") + jasmine.attachToDOM(nativeKeyBindingsInput) + nativeKeyBindingsInput.focus() + + atom.dispatchApplicationMenuCommand("core:copy") + atom.dispatchApplicationMenuCommand("core:paste") + + expect(webContentsSpy.copy).toHaveBeenCalled() + expect(webContentsSpy.paste).toHaveBeenCalled() + + webContentsSpy.copy.reset() + webContentsSpy.paste.reset() + + normalInput = document.createElement("input") + jasmine.attachToDOM(normalInput) + normalInput.focus() + + atom.dispatchApplicationMenuCommand("core:copy") + atom.dispatchApplicationMenuCommand("core:paste") + + expect(webContentsSpy.copy).not.toHaveBeenCalled() + expect(webContentsSpy.paste).not.toHaveBeenCalled()