From 080a0fd25866268ebfc916f23b46eb479ab63a97 Mon Sep 17 00:00:00 2001 From: Jack Lynch Date: Mon, 15 Jun 2020 12:55:19 -0700 Subject: [PATCH] Add browser test for forwarded key whitelist changes This CL adds a browser test for the changes in [1], which added logic to update the whitelist of keys that the browser forwards to the DevTools whenever the keybind set changes rather than just once at launch. Forwarded keys don't work in remote debugging/hosted sessions, so they can't be tested with an e2e test. There's also a small change here to enable this new test in the backend: https://chromium-review.googlesource.com/c/chromium/src/+/2246552 [1] https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2231908 Bug: 174309 Change-Id: Ib511abe8192fce245e72b371954eb94c2aa3d907 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2244468 Reviewed-by: Robert Paveza Reviewed-by: Brian Cui Reviewed-by: Jose Leal Commit-Queue: Jack Lynch --- front_end/Tests.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/front_end/Tests.js b/front_end/Tests.js index bf5890cda2..9bf1d38143 100644 --- a/front_end/Tests.js +++ b/front_end/Tests.js @@ -772,6 +772,23 @@ {type: 'rawKeyDown', key: 'F8', windowsVirtualKeyCode: 119, nativeVirtualKeyCode: 119}); }; + // Tests that the key whitelist in the browser is updated when shortcuts + // are changed + TestSuite.prototype.testKeyWhitelistChanged = function() { + this.takeControl(); + + this.addSniffer(self.UI.shortcutRegistry, '_registerBindings', () => { + self.SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( + {type: 'rawKeyDown', key: 'F1', windowsVirtualKeyCode: 112, nativeVirtualKeyCode: 112}); + }); + this.addSniffer(self.UI.shortcutRegistry, 'handleKey', key => { + this.assertEquals(112, key); + this.releaseControl(); + }); + + self.Common.settings.moduleSetting('activeKeybindSet').set('vsCode'); + }; + TestSuite.prototype.testDispatchKeyEventDoesNotCrash = function() { self.SDK.targetManager.mainTarget().inputAgent().invoke_dispatchKeyEvent( {type: 'rawKeyDown', windowsVirtualKeyCode: 0x23, key: 'End'});