Cleanup: Agents depend on debuggerClient
Modified RuntimeAgent and PageAgent to depend on DebuggerClient instead of session. Removed DebuggerClient.sendDebugRequest method.
This commit is contained in:
Родитель
c2165b925d
Коммит
06d90d7405
|
@ -19,7 +19,7 @@ function resolveReference(obj, refs) {
|
|||
CallFramesProvider.prototype = {
|
||||
|
||||
fetchCallFrames: function(handleResponse) {
|
||||
this._debuggerClient.sendDebugRequest('backtrace', {},
|
||||
this._debuggerClient.request('backtrace', {},
|
||||
function(err, responseBody, responseRefs) {
|
||||
if (err) {
|
||||
handleResponse(err);
|
||||
|
@ -64,7 +64,7 @@ CallFramesProvider.prototype = {
|
|||
},
|
||||
|
||||
_fetchScopes: function(frameIndex, done) {
|
||||
this._debuggerClient.sendDebugRequest(
|
||||
this._debuggerClient.request(
|
||||
'scopes',
|
||||
{
|
||||
frameNumber: frameIndex
|
||||
|
|
|
@ -73,11 +73,6 @@ DebuggerClient.prototype._emitDebuggerEvent = function(name, message) {
|
|||
this.emit(name, message.body);
|
||||
};
|
||||
|
||||
// TODO delete later
|
||||
DebuggerClient.prototype.sendDebugRequest = function(command, args, callback) {
|
||||
this.request(command, args, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} command
|
||||
* @param {!Object} args
|
||||
|
|
|
@ -3,7 +3,6 @@ var RuntimeAgent = require('./RuntimeAgent').RuntimeAgent,
|
|||
DebuggerAgent = require('./DebuggerAgent').DebuggerAgent;
|
||||
|
||||
function FrontendCommandHandler(frontendClient,
|
||||
session,
|
||||
debuggerClient,
|
||||
breakEventHandler,
|
||||
scriptManager) {
|
||||
|
@ -13,12 +12,12 @@ function FrontendCommandHandler(frontendClient,
|
|||
this._debuggerClient = debuggerClient;
|
||||
this._breakEventHandler = breakEventHandler;
|
||||
this._scriptManager = scriptManager;
|
||||
this._initializeRegistry(session);
|
||||
this._initializeRegistry();
|
||||
this._registerEventHandlers();
|
||||
}
|
||||
|
||||
FrontendCommandHandler.prototype = {
|
||||
_initializeRegistry: function(session) {
|
||||
_initializeRegistry: function() {
|
||||
this._registerAgent(
|
||||
'Debugger',
|
||||
new DebuggerAgent(
|
||||
|
@ -28,8 +27,8 @@ FrontendCommandHandler.prototype = {
|
|||
this._scriptManager)
|
||||
);
|
||||
|
||||
this._registerAgent('Runtime', new RuntimeAgent(session));
|
||||
this._registerAgent('Page', new PageAgent(session));
|
||||
this._registerAgent('Runtime', new RuntimeAgent(this._debuggerClient));
|
||||
this._registerAgent('Page', new PageAgent(this._debuggerClient));
|
||||
|
||||
this._registerNoopCommands(
|
||||
'Network.enable',
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
// node-inspector version of on webkit-inspector/InspectorPageAgent.cpp
|
||||
var convert = require('./convert.js');
|
||||
|
||||
function PageAgent(session) {
|
||||
this._session = session;
|
||||
/**
|
||||
* @param {DebuggerClient} debuggerClient
|
||||
* @constructor
|
||||
*/
|
||||
function PageAgent(debuggerClient) {
|
||||
this._debuggerClient = debuggerClient;
|
||||
}
|
||||
|
||||
PageAgent.prototype = {
|
||||
|
@ -50,7 +54,7 @@ PageAgent.prototype = {
|
|||
|
||||
getResourceContent: function(params, done) {
|
||||
var scriptName = convert.inspectorUrlToV8Name(params.url);
|
||||
this._session.sendDebugRequest(
|
||||
this._debuggerClient.request(
|
||||
'scripts',
|
||||
{
|
||||
filter: scriptName,
|
||||
|
|
|
@ -2,8 +2,12 @@
|
|||
var convert = require('./convert.js'),
|
||||
util = require('util');
|
||||
|
||||
function RuntimeAgent(session) {
|
||||
this._session = session;
|
||||
/**
|
||||
* @param {DebuggerClient} debuggerClient
|
||||
* @constructor
|
||||
*/
|
||||
function RuntimeAgent(debuggerClient) {
|
||||
this._debuggerClient = debuggerClient;
|
||||
}
|
||||
|
||||
RuntimeAgent.prototype = {
|
||||
|
@ -14,7 +18,7 @@ RuntimeAgent.prototype = {
|
|||
evaluate: function(params, done) {
|
||||
var self = this;
|
||||
|
||||
self._session.sendDebugRequest(
|
||||
self._debuggerClient.request(
|
||||
'evaluate',
|
||||
{
|
||||
expression: params.expression,
|
||||
|
@ -41,7 +45,7 @@ RuntimeAgent.prototype = {
|
|||
params.functionDeclaration,
|
||||
SELF_CONTEXT_NAME);
|
||||
|
||||
this._session.sendDebugRequest(
|
||||
this._debuggerClient.request(
|
||||
'evaluate',
|
||||
{
|
||||
expression: expression,
|
||||
|
@ -75,7 +79,7 @@ RuntimeAgent.prototype = {
|
|||
getProperties: function(params, done) {
|
||||
var handle = parseInt(params.objectId, 10);
|
||||
var request = { handles: [handle], includeSource: false };
|
||||
this._session.sendDebugRequest('lookup', request, function(error, responseBody, responseRefs) {
|
||||
this._debuggerClient.request('lookup', request, function(error, responseBody, responseRefs) {
|
||||
var obj,
|
||||
proto,
|
||||
props;
|
||||
|
|
|
@ -41,12 +41,6 @@ exports.create = function(debuggerPort, config) {
|
|||
}
|
||||
|
||||
sessionInstance = Object.create(events.EventEmitter.prototype, {
|
||||
sendDebugRequest: {
|
||||
value: function(command, args, callback) {
|
||||
debuggerClient.sendDebugRequest(command, args, callback);
|
||||
}
|
||||
},
|
||||
|
||||
close: {
|
||||
value: function()
|
||||
{
|
||||
|
@ -68,7 +62,6 @@ exports.create = function(debuggerPort, config) {
|
|||
|
||||
frontendCommandHandler = new FrontendCommandHandler(
|
||||
frontendClient,
|
||||
this,
|
||||
debuggerClient,
|
||||
breakEventHandler,
|
||||
scriptManager);
|
||||
|
|
|
@ -12,11 +12,8 @@ describe('RuntimeAgent', function() {
|
|||
var MYFUNC_LOCAL_SCOPE_ID = '-1';
|
||||
|
||||
launcher.runOnBreakInFunction(function(debuggerClient) {
|
||||
var sessionStub = {
|
||||
sendDebugRequest: debuggerClient.sendDebugRequest.bind(debuggerClient)
|
||||
},
|
||||
callFramesProvider = new CallFramesProvider(debuggerClient),
|
||||
agent = new RuntimeAgent(sessionStub);
|
||||
var callFramesProvider = new CallFramesProvider(debuggerClient),
|
||||
agent = new RuntimeAgent(debuggerClient);
|
||||
|
||||
// request call frames so that scope properties are initialized
|
||||
callFramesProvider.fetchCallFrames(function(cferror) {
|
||||
|
@ -61,10 +58,7 @@ describe('RuntimeAgent', function() {
|
|||
|
||||
it('calls function on an object to get completions', function(done) {
|
||||
launcher.runOnBreakInFunction(function(debuggerClient) {
|
||||
var sessionStub = {
|
||||
sendDebugRequest: debuggerClient.sendDebugRequest.bind(debuggerClient)
|
||||
},
|
||||
agent = new RuntimeAgent(sessionStub);
|
||||
var agent = new RuntimeAgent(debuggerClient);
|
||||
|
||||
fetchConsoleObjectId(function(consoleObjectId) {
|
||||
agent.callFunctionOn(
|
||||
|
|
Загрузка…
Ссылка в новой задаче