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

Unified Diff: Source/core/inspector/InjectedScriptSource.js

Issue 189723004: DevTools: console evaluation should work when window.console is overriden. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/inspector/console/console-substituted.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InjectedScriptSource.js
diff --git a/Source/core/inspector/InjectedScriptSource.js b/Source/core/inspector/InjectedScriptSource.js
index efb945164e81a6a6bd36be4931240f8a3c5f87da..6897dcfb408b1149ab35f57eb4d9776580e3a428 100644
--- a/Source/core/inspector/InjectedScriptSource.js
+++ b/Source/core/inspector/InjectedScriptSource.js
@@ -614,20 +614,21 @@ InjectedScript.prototype = {
// Surround the expression in with statements to inject our command line API so that
// the window object properties still take more precedent than our API functions.
- var injectScopeChain = scopeChain && scopeChain.length;
+ injectCommandLineAPI = injectCommandLineAPI && !("__commandLineAPI" in inspectedWindow);
+ var injectScopeChain = scopeChain && scopeChain.length && !("__scopeChainForEval" in inspectedWindow);
try {
var prefix = "";
var suffix = "";
- if (injectCommandLineAPI && inspectedWindow.console) {
- inspectedWindow.console._commandLineAPI = new CommandLineAPI(this._commandLineAPIImpl, isEvalOnCallFrame ? object : null);
- prefix = "with ((console && console._commandLineAPI) || { __proto__: null }) {";
+ if (injectCommandLineAPI) {
+ inspectedWindow.__commandLineAPI = new CommandLineAPI(this._commandLineAPIImpl, isEvalOnCallFrame ? object : null);
+ prefix = "with (__commandLineAPI || { __proto__: null }) {";
suffix = "}";
}
- if (injectScopeChain && inspectedWindow.console) {
- inspectedWindow.console._scopeChainForEval = scopeChain;
+ if (injectScopeChain) {
+ inspectedWindow.__scopeChainForEval = scopeChain;
for (var i = 0; i < scopeChain.length; ++i) {
- prefix = "with ((console && console._scopeChainForEval[" + i + "]) || { __proto__: null }) {" + (suffix ? " " : "") + prefix;
+ prefix = "with (__scopeChainForEval[" + i + "] || { __proto__: null }) {" + (suffix ? " " : "") + prefix;
if (suffix)
suffix += " }";
else
@@ -642,10 +643,10 @@ InjectedScript.prototype = {
this._lastResult = result;
return result;
} finally {
- if (injectCommandLineAPI && inspectedWindow.console)
- delete inspectedWindow.console._commandLineAPI;
- if (injectScopeChain && inspectedWindow.console)
- delete inspectedWindow.console._scopeChainForEval;
+ if (injectCommandLineAPI)
+ delete inspectedWindow.__commandLineAPI;
+ if (injectScopeChain)
+ delete inspectedWindow.__scopeChainForEval;
}
},
« no previous file with comments | « LayoutTests/inspector/console/console-substituted.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698