Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: Source/core/inspector/InjectedScriptSource.js

Issue 300393002: Merge DevTools Refactor CL to Blink36 (Closed) Base URL: svn://svn.chromium.org/blink/branches/dart/1985
Patch Set: PTAL Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 return objectId; 333 return objectId;
334 }, 334 },
335 335
336 /** 336 /**
337 * @param {string} objectId 337 * @param {string} objectId
338 * @return {!Object} 338 * @return {!Object}
339 */ 339 */
340 _parseObjectId: function(objectId) 340 _parseObjectId: function(objectId)
341 { 341 {
342 // FIXME: upstream the change from InjectedScriptHost.evaluate to JSON.p arse. 342 // FIXME: upstream the change from InjectedScriptHost.evaluate to JSON.p arse.
343 return /** @type {Object} */ nullifyObjectProto(JSON.parse(objectId)); 343 return nullifyObjectProto( /** @type {!Object} */ (JSON.parse(objectId)) );
344 }, 344 },
345 345
346 /** 346 /**
347 * @param {string} objectGroupName 347 * @param {string} objectGroupName
348 */ 348 */
349 releaseObjectGroup: function(objectGroupName) 349 releaseObjectGroup: function(objectGroupName)
350 { 350 {
351 var group = this._objectGroups[objectGroupName]; 351 var group = this._objectGroups[objectGroupName];
352 if (!group) 352 if (!group)
353 return; 353 return;
(...skipping 11 matching lines...) Expand all
365 { 365 {
366 var argsArray = InjectedScriptHost.evaluate("(" + args + ")"); 366 var argsArray = InjectedScriptHost.evaluate("(" + args + ")");
367 var result = this[methodName].apply(this, argsArray); 367 var result = this[methodName].apply(this, argsArray);
368 if (typeof result === "undefined") { 368 if (typeof result === "undefined") {
369 inspectedWindow.console.error("Web Inspector error: InjectedScript.% s returns undefined", methodName); 369 inspectedWindow.console.error("Web Inspector error: InjectedScript.% s returns undefined", methodName);
370 result = null; 370 result = null;
371 } 371 }
372 return result; 372 return result;
373 }, 373 },
374 374
375 addCompletionsHelper: function(object, completions) {
376 if (!this._isDefined(object))
377 return;
378
379 var type = typeof(object);
380 if (type === "string")
381 object = new String("");
382 else if (type === "number")
383 object = new Number(0);
384 else if (type === "boolean")
385 object = new Boolean(false);
386
387 for (var o = object; o; o = o.__proto__) {
388 try {
389 var names = Object.getOwnPropertyNames(o);
390 for (var i = 0; i < names.length; ++i)
391 completions[names[i]] = true;
392 } catch (e) {
393 }
394 }
395 },
396
397 /**
398 * @param {string} expression
399 * @return {!Array.<String>}
400 */
401 getCompletions: function(expression)
402 {
403 var object;
404 try {
405 object = InjectedScriptHost.evaluate(expression || "this");
406 } catch (e) {
407 return [];
408 }
409
410 var completions = {};
411 this.addCompletionsHelper(object, completions);
412 return /** @type {!Array.<String>} */ (Object.keys(completions));
413 },
414
375 /** 415 /**
376 * @param {string} objectId 416 * @param {string} objectId
377 * @param {boolean} ownProperties 417 * @param {boolean} ownProperties
378 * @param {boolean} accessorPropertiesOnly 418 * @param {boolean} accessorPropertiesOnly
379 * @return {Array.<RuntimeAgent.PropertyDescriptor>|boolean} 419 * @return {Array.<RuntimeAgent.PropertyDescriptor>|boolean}
380 */ 420 */
381 getProperties: function(objectId, ownProperties, accessorPropertiesOnly) 421 getProperties: function(objectId, ownProperties, accessorPropertiesOnly)
382 { 422 {
383 var parsedObjectId = this._parseObjectId(objectId); 423 var parsedObjectId = this._parseObjectId(objectId);
384 var object = this._objectForId(parsedObjectId); 424 var object = this._objectForId(parsedObjectId);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 value: this._wrapObject(property.value, objectGroupName), 466 value: this._wrapObject(property.value, objectGroupName),
427 __proto__: null 467 __proto__: null
428 }; 468 };
429 push(descriptors, descriptor); 469 push(descriptors, descriptor);
430 } 470 }
431 } 471 }
432 return descriptors; 472 return descriptors;
433 }, 473 },
434 474
435 /** 475 /**
476 * @param {string} objectId
477 * @param {Array.<String>} propertyPath
478 * @return {Object|boolean}
479 */
480 getProperty: function(objectId, propertyPath)
481 {
482 var parsedObjectId = this._parseObjectId(objectId);
483 var object = this._objectForId(parsedObjectId);
484 var objectGroupName = this._idToObjectGroupName[parsedObjectId.id];
485 if (!this._isDefined(object))
486 return false;
487
488 for (var i = 0, n = propertyPath.length; i < n; ++i)
489 object = object[propertyPath[i]];
490 return this._wrapObject(object, objectGroupName);
491 },
492
493 /**
436 * @param {string} functionId 494 * @param {string} functionId
437 * @return {!DebuggerAgent.FunctionDetails|string} 495 * @return {!DebuggerAgent.FunctionDetails|string}
438 */ 496 */
439 getFunctionDetails: function(functionId) 497 getFunctionDetails: function(functionId)
440 { 498 {
441 var parsedFunctionId = this._parseObjectId(functionId); 499 var parsedFunctionId = this._parseObjectId(functionId);
442 var func = this._objectForId(parsedFunctionId); 500 var func = this._objectForId(parsedFunctionId);
443 if (typeof func !== "function") 501 if (typeof func !== "function")
444 return "Cannot resolve function by id."; 502 return "Cannot resolve function by id.";
445 var details = nullifyObjectProto(InjectedScriptHost.functionDetails(func )); 503 var details = nullifyObjectProto(InjectedScriptHost.functionDetails(func ));
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 var callFrame = this._callFrameForParsedId(topCallFrame, parsedCallFrame Id, asyncCallStacks); 809 var callFrame = this._callFrameForParsedId(topCallFrame, parsedCallFrame Id, asyncCallStacks);
752 if (!callFrame) 810 if (!callFrame)
753 return "Could not find call frame with given id"; 811 return "Could not find call frame with given id";
754 if (parsedCallFrameId["asyncOrdinal"]) 812 if (parsedCallFrameId["asyncOrdinal"])
755 return this._evaluateAndWrap(InjectedScriptHost.evaluate, InjectedSc riptHost, expression, objectGroup, false, injectCommandLineAPI, returnByValue, g eneratePreview, callFrame.scopeChain); 813 return this._evaluateAndWrap(InjectedScriptHost.evaluate, InjectedSc riptHost, expression, objectGroup, false, injectCommandLineAPI, returnByValue, g eneratePreview, callFrame.scopeChain);
756 return this._evaluateAndWrap(callFrame.evaluate, callFrame, expression, objectGroup, true, injectCommandLineAPI, returnByValue, generatePreview); 814 return this._evaluateAndWrap(callFrame.evaluate, callFrame, expression, objectGroup, true, injectCommandLineAPI, returnByValue, generatePreview);
757 }, 815 },
758 816
759 /** 817 /**
760 * @param {!Object} topCallFrame 818 * @param {!Object} topCallFrame
819 * @param {!Array.<!Object>} asyncCallStacks
820 * @param {string} callFrameId
821 * @param {string} expression
822 * @return {!Array.<String>}
823 */
824 getCompletionsOnCallFrame: function(topCallFrame, asyncCallStacks, callFrame Id, expression)
825 {
826 var completions = {};
827 var parsedCallFrameId = nullifyObjectProto(InjectedScriptHost.evaluate(" (" + callFrameId + ")"));
828 var callFrame = this._callFrameForParsedId(topCallFrame, parsedCallFrame Id, asyncCallStacks);
829 if (!callFrame)
830 return ["Could not find call frame with given id"];
831 if (expression == "") {
832 var scopeChain = callFrame.scopeChain;
833 for (var i = 0; i < scopeChain.length; i++) {
834 var names = Object.getOwnPropertyNames(scopeChain[i]);
835 for (var i = 0; i < names.length; ++i)
836 completions[names[i]] = true;
837 }
838 }
839 expression = expression || "this";
840 var object;
841 try {
842 if (parsedCallFrameId["asyncOrdinal"]) {
843 object = this._evaluateOn(InjectedScriptHost.evaluate, InjectedS criptHost, "completion", expression, false, false, callFrame.scopeChain);
844 } else {
845 object = this._evaluateOn(callFrame.evaluate, callFrame, "comple tion", expression, true, false);
846 }
847 } catch (e) {
848 return [];
849 }
850
851 this.addCompletionsHelper(object, completions);
852 return /** @type {!Array.<String>} */ (Object.keys(completions));
853 },
854
855
856 /**
857 * @param {!Object} topCallFrame
761 * @param {string} callFrameId 858 * @param {string} callFrameId
762 * @return {*} 859 * @return {*}
763 */ 860 */
764 restartFrame: function(topCallFrame, callFrameId) 861 restartFrame: function(topCallFrame, callFrameId)
765 { 862 {
766 var callFrame = this.callFrameForId(topCallFrame, callFrameId); 863 var callFrame = this.callFrameForId(topCallFrame, callFrameId);
767 if (!callFrame) 864 if (!callFrame)
768 return "Could not find call frame with given id"; 865 return "Could not find call frame with given id";
769 var result = callFrame.restart(); 866 var result = callFrame.restart();
770 if (result === false) 867 if (result === false)
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 */ 1727 */
1631 _logEvent: function(event) 1728 _logEvent: function(event)
1632 { 1729 {
1633 inspectedWindow.console.log(event.type, event); 1730 inspectedWindow.console.log(event.type, event);
1634 } 1731 }
1635 } 1732 }
1636 1733
1637 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); 1734 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl();
1638 return injectedScript; 1735 return injectedScript;
1639 }) 1736 })
OLDNEW
« no previous file with comments | « Source/core/inspector/InjectedScriptModule.cpp ('k') | Source/core/inspector/InspectorCanvasAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698