| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } | 316 } |
| 317 | 317 |
| 318 WebInspector.ExecutionContext.prototype = { | 318 WebInspector.ExecutionContext.prototype = { |
| 319 /** | 319 /** |
| 320 * @param {string} expression | 320 * @param {string} expression |
| 321 * @param {string} objectGroup | 321 * @param {string} objectGroup |
| 322 * @param {boolean} includeCommandLineAPI | 322 * @param {boolean} includeCommandLineAPI |
| 323 * @param {boolean} doNotPauseOnExceptionsAndMuteConsole | 323 * @param {boolean} doNotPauseOnExceptionsAndMuteConsole |
| 324 * @param {boolean} returnByValue | 324 * @param {boolean} returnByValue |
| 325 * @param {boolean} generatePreview | 325 * @param {boolean} generatePreview |
| 326 * @param {boolean} userGesture |
| 326 * @param {function(?WebInspector.RemoteObject, boolean, ?RuntimeAgent.Remot
eObject=, ?RuntimeAgent.ExceptionDetails=)} callback | 327 * @param {function(?WebInspector.RemoteObject, boolean, ?RuntimeAgent.Remot
eObject=, ?RuntimeAgent.ExceptionDetails=)} callback |
| 327 */ | 328 */ |
| 328 evaluate: function(expression, objectGroup, includeCommandLineAPI, doNotPaus
eOnExceptionsAndMuteConsole, returnByValue, generatePreview, callback) | 329 evaluate: function(expression, objectGroup, includeCommandLineAPI, doNotPaus
eOnExceptionsAndMuteConsole, returnByValue, generatePreview, userGesture, callba
ck) |
| 329 { | 330 { |
| 330 // FIXME: It will be moved to separate ExecutionContext. | 331 // FIXME: It will be moved to separate ExecutionContext. |
| 331 if (this.debuggerModel.selectedCallFrame()) { | 332 if (this.debuggerModel.selectedCallFrame()) { |
| 332 this.debuggerModel.evaluateOnSelectedCallFrame(expression, objectGro
up, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue,
generatePreview, callback); | 333 this.debuggerModel.evaluateOnSelectedCallFrame(expression, objectGro
up, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue,
generatePreview, callback); |
| 333 return; | 334 return; |
| 334 } | 335 } |
| 335 this._evaluateGlobal.apply(this, arguments); | 336 this._evaluateGlobal.apply(this, arguments); |
| 336 }, | 337 }, |
| 337 | 338 |
| 338 /** | 339 /** |
| 339 * @param {string} objectGroup | 340 * @param {string} objectGroup |
| 340 * @param {boolean} returnByValue | 341 * @param {boolean} returnByValue |
| 341 * @param {boolean} generatePreview | 342 * @param {boolean} generatePreview |
| 342 * @param {function(?WebInspector.RemoteObject, boolean, ?RuntimeAgent.Remot
eObject=, ?RuntimeAgent.ExceptionDetails=)} callback | 343 * @param {function(?WebInspector.RemoteObject, boolean, ?RuntimeAgent.Remot
eObject=, ?RuntimeAgent.ExceptionDetails=)} callback |
| 343 */ | 344 */ |
| 344 globalObject: function(objectGroup, returnByValue, generatePreview, callback
) | 345 globalObject: function(objectGroup, returnByValue, generatePreview, callback
) |
| 345 { | 346 { |
| 346 this._evaluateGlobal("this", objectGroup, false, true, returnByValue, ge
neratePreview, callback); | 347 this._evaluateGlobal("this", objectGroup, false, true, returnByValue, ge
neratePreview, false, callback); |
| 347 }, | 348 }, |
| 348 | 349 |
| 349 /** | 350 /** |
| 350 * @param {string} expression | 351 * @param {string} expression |
| 351 * @param {string} objectGroup | 352 * @param {string} objectGroup |
| 352 * @param {boolean} includeCommandLineAPI | 353 * @param {boolean} includeCommandLineAPI |
| 353 * @param {boolean} doNotPauseOnExceptionsAndMuteConsole | 354 * @param {boolean} doNotPauseOnExceptionsAndMuteConsole |
| 354 * @param {boolean} returnByValue | 355 * @param {boolean} returnByValue |
| 355 * @param {boolean} generatePreview | 356 * @param {boolean} generatePreview |
| 357 * @param {boolean} userGesture |
| 356 * @param {function(?WebInspector.RemoteObject, boolean, ?RuntimeAgent.Remot
eObject=, ?RuntimeAgent.ExceptionDetails=)} callback | 358 * @param {function(?WebInspector.RemoteObject, boolean, ?RuntimeAgent.Remot
eObject=, ?RuntimeAgent.ExceptionDetails=)} callback |
| 357 */ | 359 */ |
| 358 _evaluateGlobal: function(expression, objectGroup, includeCommandLineAPI, do
NotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, callback) | 360 _evaluateGlobal: function(expression, objectGroup, includeCommandLineAPI, do
NotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, userGesture,
callback) |
| 359 { | 361 { |
| 360 if (!expression) { | 362 if (!expression) { |
| 361 // There is no expression, so the completion should happen against g
lobal properties. | 363 // There is no expression, so the completion should happen against g
lobal properties. |
| 362 expression = "this"; | 364 expression = "this"; |
| 363 } | 365 } |
| 364 | 366 |
| 365 /** | 367 /** |
| 366 * @this {WebInspector.ExecutionContext} | 368 * @this {WebInspector.ExecutionContext} |
| 367 * @param {?Protocol.Error} error | 369 * @param {?Protocol.Error} error |
| 368 * @param {!RuntimeAgent.RemoteObject} result | 370 * @param {!RuntimeAgent.RemoteObject} result |
| 369 * @param {boolean=} wasThrown | 371 * @param {boolean=} wasThrown |
| 370 * @param {?RuntimeAgent.ExceptionDetails=} exceptionDetails | 372 * @param {?RuntimeAgent.ExceptionDetails=} exceptionDetails |
| 371 */ | 373 */ |
| 372 function evalCallback(error, result, wasThrown, exceptionDetails) | 374 function evalCallback(error, result, wasThrown, exceptionDetails) |
| 373 { | 375 { |
| 374 if (error) { | 376 if (error) { |
| 375 console.error(error); | 377 console.error(error); |
| 376 callback(null, false); | 378 callback(null, false); |
| 377 return; | 379 return; |
| 378 } | 380 } |
| 379 | 381 |
| 380 if (returnByValue) | 382 if (returnByValue) |
| 381 callback(null, !!wasThrown, wasThrown ? null : result, exception
Details); | 383 callback(null, !!wasThrown, wasThrown ? null : result, exception
Details); |
| 382 else | 384 else |
| 383 callback(this.runtimeModel.createRemoteObject(result), !!wasThro
wn, undefined, exceptionDetails); | 385 callback(this.runtimeModel.createRemoteObject(result), !!wasThro
wn, undefined, exceptionDetails); |
| 384 } | 386 } |
| 385 this.target().runtimeAgent().evaluate(expression, objectGroup, includeCo
mmandLineAPI, doNotPauseOnExceptionsAndMuteConsole, this.id, returnByValue, gene
ratePreview, evalCallback.bind(this)); | 387 this.target().runtimeAgent().evaluate(expression, objectGroup, includeCo
mmandLineAPI, doNotPauseOnExceptionsAndMuteConsole, this.id, returnByValue, gene
ratePreview, userGesture, evalCallback.bind(this)); |
| 386 }, | 388 }, |
| 387 | 389 |
| 388 /** | 390 /** |
| 389 * @param {string} expressionString | 391 * @param {string} expressionString |
| 390 * @param {string} text | 392 * @param {string} text |
| 391 * @param {number} cursorOffset | 393 * @param {number} cursorOffset |
| 392 * @param {string} prefix | 394 * @param {string} prefix |
| 393 * @param {boolean} force | 395 * @param {boolean} force |
| 394 * @param {function(!Array.<string>, number=)} completionsReadyCallback | 396 * @param {function(!Array.<string>, number=)} completionsReadyCallback |
| 395 */ | 397 */ |
| (...skipping 14 matching lines...) Expand all Loading... |
| 410 } | 412 } |
| 411 | 413 |
| 412 if (!prefix && !expressionString && !force) { | 414 if (!prefix && !expressionString && !force) { |
| 413 completionsReadyCallback([]); | 415 completionsReadyCallback([]); |
| 414 return; | 416 return; |
| 415 } | 417 } |
| 416 | 418 |
| 417 if (!expressionString && this.debuggerModel.selectedCallFrame()) | 419 if (!expressionString && this.debuggerModel.selectedCallFrame()) |
| 418 this.debuggerModel.selectedCallFrame().variableNames(receivedPropert
yNames.bind(this)); | 420 this.debuggerModel.selectedCallFrame().variableNames(receivedPropert
yNames.bind(this)); |
| 419 else | 421 else |
| 420 this.evaluate(expressionString, "completion", true, true, false, fal
se, evaluated.bind(this)); | 422 this.evaluate(expressionString, "completion", true, true, false, fal
se, false, evaluated.bind(this)); |
| 421 | 423 |
| 422 /** | 424 /** |
| 423 * @this {WebInspector.ExecutionContext} | 425 * @this {WebInspector.ExecutionContext} |
| 424 */ | 426 */ |
| 425 function evaluated(result, wasThrown) | 427 function evaluated(result, wasThrown) |
| 426 { | 428 { |
| 427 if (!result || wasThrown) { | 429 if (!result || wasThrown) { |
| 428 completionsReadyCallback([]); | 430 completionsReadyCallback([]); |
| 429 return; | 431 return; |
| 430 } | 432 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 461 } | 463 } |
| 462 } catch (e) { | 464 } catch (e) { |
| 463 } | 465 } |
| 464 } | 466 } |
| 465 return resultSet; | 467 return resultSet; |
| 466 } | 468 } |
| 467 | 469 |
| 468 if (result.type === "object" || result.type === "function") | 470 if (result.type === "object" || result.type === "function") |
| 469 result.callFunctionJSON(getCompletions, [WebInspector.RemoteObje
ct.toCallArgument(result.subtype)], receivedPropertyNames.bind(this)); | 471 result.callFunctionJSON(getCompletions, [WebInspector.RemoteObje
ct.toCallArgument(result.subtype)], receivedPropertyNames.bind(this)); |
| 470 else if (result.type === "string" || result.type === "number" || res
ult.type === "boolean") | 472 else if (result.type === "string" || result.type === "number" || res
ult.type === "boolean") |
| 471 this.evaluate("(" + getCompletions + ")(\"" + result.type + "\")
", "completion", false, true, true, false, receivedPropertyNamesFromEval.bind(th
is)); | 473 this.evaluate("(" + getCompletions + ")(\"" + result.type + "\")
", "completion", false, true, true, false, false, receivedPropertyNamesFromEval.
bind(this)); |
| 472 } | 474 } |
| 473 | 475 |
| 474 /** | 476 /** |
| 475 * @param {?WebInspector.RemoteObject} notRelevant | 477 * @param {?WebInspector.RemoteObject} notRelevant |
| 476 * @param {boolean} wasThrown | 478 * @param {boolean} wasThrown |
| 477 * @param {?RuntimeAgent.RemoteObject=} result | 479 * @param {?RuntimeAgent.RemoteObject=} result |
| 478 * @this {WebInspector.ExecutionContext} | 480 * @this {WebInspector.ExecutionContext} |
| 479 */ | 481 */ |
| 480 function receivedPropertyNamesFromEval(notRelevant, wasThrown, result) | 482 function receivedPropertyNamesFromEval(notRelevant, wasThrown, result) |
| 481 { | 483 { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 /** | 690 /** |
| 689 * @param {string} listenerType | 691 * @param {string} listenerType |
| 690 */ | 692 */ |
| 691 setListenerType: function(listenerType) | 693 setListenerType: function(listenerType) |
| 692 { | 694 { |
| 693 this._listenerType = listenerType; | 695 this._listenerType = listenerType; |
| 694 }, | 696 }, |
| 695 | 697 |
| 696 __proto__: WebInspector.SDKObject.prototype | 698 __proto__: WebInspector.SDKObject.prototype |
| 697 } | 699 } |
| OLD | NEW |