| OLD | NEW |
| 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 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1548 * @param {?JavaScriptCallFrame} callFrame | 1548 * @param {?JavaScriptCallFrame} callFrame |
| 1549 */ | 1549 */ |
| 1550 function CommandLineAPI(commandLineAPIImpl, callFrame) | 1550 function CommandLineAPI(commandLineAPIImpl, callFrame) |
| 1551 { | 1551 { |
| 1552 /** | 1552 /** |
| 1553 * @param {string} member | 1553 * @param {string} member |
| 1554 * @return {boolean} | 1554 * @return {boolean} |
| 1555 */ | 1555 */ |
| 1556 function inScopeVariables(member) | 1556 function inScopeVariables(member) |
| 1557 { | 1557 { |
| 1558 if (!callFrame) | |
| 1559 return (member in inspectedGlobalObject); | |
| 1560 | |
| 1561 var scopeChain = callFrame.scopeChain; | 1558 var scopeChain = callFrame.scopeChain; |
| 1562 for (var i = 0; i < scopeChain.length; ++i) { | 1559 for (var i = 0; i < scopeChain.length; ++i) { |
| 1563 if (member in scopeChain[i]) | 1560 if (member in scopeChain[i]) |
| 1564 return true; | 1561 return true; |
| 1565 } | 1562 } |
| 1566 return false; | 1563 return false; |
| 1567 } | 1564 } |
| 1568 | 1565 |
| 1569 /** | 1566 /** |
| 1570 * @param {string} name The name of the method for which a toString method s
hould be generated. | 1567 * @param {string} name The name of the method for which a toString method s
hould be generated. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1583 funcSyntax = funcSyntax.replace(/\bopt_(\w+)\b/g, "[$1]"); | 1580 funcSyntax = funcSyntax.replace(/\bopt_(\w+)\b/g, "[$1]"); |
| 1584 funcArgsSyntax = funcSyntax.trim(); | 1581 funcArgsSyntax = funcSyntax.trim(); |
| 1585 } catch (e) { | 1582 } catch (e) { |
| 1586 } | 1583 } |
| 1587 return "function " + name + "(" + funcArgsSyntax + ") { [Command Lin
e API] }"; | 1584 return "function " + name + "(" + funcArgsSyntax + ") { [Command Lin
e API] }"; |
| 1588 }; | 1585 }; |
| 1589 } | 1586 } |
| 1590 | 1587 |
| 1591 for (var i = 0; i < CommandLineAPI.members_.length; ++i) { | 1588 for (var i = 0; i < CommandLineAPI.members_.length; ++i) { |
| 1592 var member = CommandLineAPI.members_[i]; | 1589 var member = CommandLineAPI.members_[i]; |
| 1593 if (inScopeVariables(member)) | 1590 if (callFrame && inScopeVariables(member)) |
| 1594 continue; | 1591 continue; |
| 1595 | 1592 |
| 1596 this[member] = bind(commandLineAPIImpl[member], commandLineAPIImpl); | 1593 this[member] = bind(commandLineAPIImpl[member], commandLineAPIImpl); |
| 1597 this[member].toString = customToStringMethod(member); | 1594 this[member].toString = customToStringMethod(member); |
| 1598 } | 1595 } |
| 1599 | 1596 |
| 1600 for (var i = 0; i < 5; ++i) { | 1597 for (var i = 0; i < 5; ++i) { |
| 1601 var member = "$" + i; | 1598 var member = "$" + i; |
| 1602 if (inScopeVariables(member)) | 1599 if (callFrame && inScopeVariables(member)) |
| 1603 continue; | 1600 continue; |
| 1604 | 1601 |
| 1605 this.__defineGetter__("$" + i, bind(commandLineAPIImpl._inspectedObject,
commandLineAPIImpl, i)); | 1602 this[member] = bind(commandLineAPIImpl._inspectedObject, commandLineAPII
mpl, i); |
| 1606 } | 1603 } |
| 1607 | 1604 |
| 1608 this.$_ = injectedScript._lastResult; | 1605 this.$_ = injectedScript._lastResult; |
| 1609 | 1606 |
| 1610 this.__proto__ = null; | 1607 this.__proto__ = null; |
| 1611 } | 1608 } |
| 1612 | 1609 |
| 1613 // NOTE: Please keep the list of API methods below synchronized to that in WebIn
spector.RuntimeModel | 1610 // NOTE: Please keep the list of API methods below synchronized to that in WebIn
spector.RuntimeModel |
| 1614 // and V8InjectedScriptHost! | 1611 // and V8InjectedScriptHost! |
| 1615 // NOTE: Argument names of these methods will be printed in the console, so use
pretty names! | 1612 // NOTE: Argument names of these methods will be printed in the console, so use
pretty names! |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1894 */ | 1891 */ |
| 1895 _logEvent: function(event) | 1892 _logEvent: function(event) |
| 1896 { | 1893 { |
| 1897 inspectedGlobalObject.console.log(event.type, event); | 1894 inspectedGlobalObject.console.log(event.type, event); |
| 1898 } | 1895 } |
| 1899 } | 1896 } |
| 1900 | 1897 |
| 1901 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); | 1898 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); |
| 1902 return injectedScript; | 1899 return injectedScript; |
| 1903 }) | 1900 }) |
| OLD | NEW |