| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 InspectorTest = {}; | 5 InspectorTest = {}; |
| 6 InspectorTest._dispatchTable = new Map(); | 6 InspectorTest._dispatchTable = new Map(); |
| 7 InspectorTest._requestId = 0; | 7 InspectorTest._requestId = 0; |
| 8 InspectorTest._dumpInspectorProtocolMessages = false; | 8 InspectorTest._dumpInspectorProtocolMessages = false; |
| 9 InspectorTest._eventHandler = {}; | 9 InspectorTest._eventHandler = {}; |
| 10 | 10 |
| 11 Protocol = new Proxy({}, { | 11 Protocol = new Proxy({}, { |
| 12 get: function(target, agentName, receiver) { | 12 get: function(target, agentName, receiver) { |
| 13 return new Proxy({}, { | 13 return new Proxy({}, { |
| 14 get: function(target, methodName, receiver) { | 14 get: function(target, methodName, receiver) { |
| 15 const eventPattern = /^on(ce)?([A-Z][A-Za-z0-9]+)/; | 15 const eventPattern = /^on(ce)?([A-Z][A-Za-z0-9]+)/; |
| 16 var match = eventPattern.exec(methodName); | 16 var match = eventPattern.exec(methodName); |
| 17 if (!match) { | 17 if (!match) { |
| 18 return (args) => InspectorTest._sendCommandPromise(`${agentName}.${met
hodName}`, args || {}); | 18 return (args) => InspectorTest._sendCommandPromise(`${agentName}.${met
hodName}`, args || {}); |
| 19 } else { | 19 } else { |
| 20 var eventName = match[2]; | 20 var eventName = match[2]; |
| 21 eventName = eventName.charAt(0).toLowerCase() + eventName.slice(1); | 21 eventName = eventName.charAt(0).toLowerCase() + eventName.slice(1); |
| 22 if (match[1]) | 22 if (match[1]) |
| 23 return (args) => InspectorTest._waitForEventPromise(`${agentName}.${
eventName}`, args || {}); | 23 return () => InspectorTest._waitForEventPromise( |
| 24 `${agentName}.${eventName}`); |
| 24 else | 25 else |
| 25 return (listener) => { InspectorTest._eventHandler[`${agentName}.${e
ventName}`] = listener }; | 26 return (listener) => { InspectorTest._eventHandler[`${agentName}.${e
ventName}`] = listener }; |
| 26 } | 27 } |
| 27 } | 28 } |
| 28 }); | 29 }); |
| 29 } | 30 } |
| 30 }); | 31 }); |
| 31 | 32 |
| 32 InspectorTest.log = print.bind(null); | 33 InspectorTest.log = print.bind(null); |
| 33 | 34 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 if (InspectorTest._scriptMap && eventName === "Debugger.scriptParsed") | 215 if (InspectorTest._scriptMap && eventName === "Debugger.scriptParsed") |
| 215 InspectorTest._scriptMap.set(messageObject.params.scriptId, JSON.parse(J
SON.stringify(messageObject.params))); | 216 InspectorTest._scriptMap.set(messageObject.params.scriptId, JSON.parse(J
SON.stringify(messageObject.params))); |
| 216 if (eventHandler) | 217 if (eventHandler) |
| 217 eventHandler(messageObject); | 218 eventHandler(messageObject); |
| 218 } | 219 } |
| 219 } catch (e) { | 220 } catch (e) { |
| 220 InspectorTest.log("Exception when dispatching message: " + e + "\n" + e.stac
k + "\n message = " + JSON.stringify(messageObject, null, 2)); | 221 InspectorTest.log("Exception when dispatching message: " + e + "\n" + e.stac
k + "\n message = " + JSON.stringify(messageObject, null, 2)); |
| 221 InspectorTest.completeTest(); | 222 InspectorTest.completeTest(); |
| 222 } | 223 } |
| 223 } | 224 } |
| OLD | NEW |