Index: Source/devtools/front_end/ExtensionServer.js |
diff --git a/Source/devtools/front_end/ExtensionServer.js b/Source/devtools/front_end/ExtensionServer.js |
index c3e0e97e9744c38f6135f7040af1b2fc69a0fdcd..b610d1b17b5c6c4f2f2b78c6f46df0c667b927b4 100644 |
--- a/Source/devtools/front_end/ExtensionServer.js |
+++ b/Source/devtools/front_end/ExtensionServer.js |
@@ -54,6 +54,7 @@ WebInspector.ExtensionServer = function() |
this._registerHandler(commands.CreateSidebarPane, this._onCreateSidebarPane.bind(this)); |
this._registerHandler(commands.CreateStatusBarButton, this._onCreateStatusBarButton.bind(this)); |
this._registerHandler(commands.EvaluateOnInspectedPage, this._onEvaluateOnInspectedPage.bind(this)); |
+ this._registerHandler(commands.ForwardKeyboardEvent, this._onForwardKeyboardEvent.bind(this)); |
this._registerHandler(commands.GetHAR, this._onGetHAR.bind(this)); |
this._registerHandler(commands.GetConsoleMessages, this._onGetConsoleMessages.bind(this)); |
this._registerHandler(commands.GetPageResources, this._onGetPageResources.bind(this)); |
@@ -566,6 +567,25 @@ WebInspector.ExtensionServer.prototype = { |
auditRun.done(); |
}, |
+ _onForwardKeyboardEvent: function(message) |
+ { |
+ const Esc = "U+001B"; |
+ |
+ if (!message.ctrlKey && !message.altKey && !message.metaKey && !/^F\d+$/.test(message.keyIdentifier) && message.keyIdentifier !== Esc) |
+ return; |
+ // Fool around closure compiler -- it has its own notion of both KeyboardEvent constructor |
+ // and initKeyboardEvent methods and overriding these in externs.js does not have effect. |
+ var event = new window.KeyboardEvent(message.eventType, { |
+ keyIdentifier: message.keyIdentifier, |
+ keyLocation: message.keyLocation, |
+ ctrlKey: message.ctrlKey, |
+ altKey: message.altKey, |
+ shiftKey: message.shiftKey, |
+ metaKey: message.metaKey |
+ }); |
+ document.dispatchEvent(event); |
+ }, |
+ |
_dispatchCallback: function(requestId, port, result) |
{ |
if (requestId) |