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

Unified Diff: Source/devtools/front_end/ConsoleView.js

Issue 232023005: DevTools: better address console self-xss. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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 | « no previous file | Source/devtools/front_end/Settings.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/ConsoleView.js
diff --git a/Source/devtools/front_end/ConsoleView.js b/Source/devtools/front_end/ConsoleView.js
index 3b866d6e9d6391e868f0f883f031ab01f13f3bcd..6532cca5faf11277d8562c071401584a26fb3810 100644
--- a/Source/devtools/front_end/ConsoleView.js
+++ b/Source/devtools/front_end/ConsoleView.js
@@ -86,6 +86,8 @@ WebInspector.ConsoleView = function(hideContextSelector)
this.promptElement.id = "console-prompt";
this.promptElement.className = "source-code";
this.promptElement.spellcheck = false;
+ this.promptElement.addEventListener("paste", this._onPasteIntoPrompt.bind(this), false);
+ this.promptElement.addEventListener("drop", this._onPasteIntoPrompt.bind(this), false);
this.messagesElement.appendChild(this.promptElement);
this.messagesElement.appendChild(document.createElement("br"));
@@ -119,7 +121,10 @@ WebInspector.ConsoleView = function(hideContextSelector)
this.prompt.renderAsBlock();
this.prompt.attach(this.promptElement);
this.prompt.proxyElement.addEventListener("keydown", this._promptKeyDown.bind(this), false);
- this.prompt.setHistoryData(WebInspector.settings.consoleHistory.get());
+ var historyData = WebInspector.settings.consoleHistory.get();
+ this.prompt.setHistoryData(historyData);
+ if (!WebInspector.settings.allowPastingJavaScript.get() && historyData && historyData.length > 10)
+ WebInspector.settings.allowPastingJavaScript.set(true);
WebInspector.targetManager.observeTargets(this);
@@ -279,8 +284,6 @@ WebInspector.ConsoleView.prototype = {
*/
_currentTarget: function()
{
-// var executionContext = this._currentExecutionContext();
-// return executionContext ? executionContext.target() : null;
return WebInspector.targetManager.activeTarget();
},
@@ -921,6 +924,21 @@ WebInspector.ConsoleView.prototype = {
this._searchResults[index].highlightSearchResults(this._searchRegex);
},
+ /**
+ * @param {?Event} e
+ */
+ _onPasteIntoPrompt: function(e)
+ {
+ if (WebInspector.settings.allowPastingJavaScript.get())
+ return;
+ var result = prompt(WebInspector.UIString("You may be a victim of a scam. Executing this code is probably bad for you. \n\nType 'always allow' in the input field below to allow this action"));
+ if (result === "always allow") {
+ WebInspector.settings.allowPastingJavaScript.set(true);
+ return;
+ }
+ e.consume(true);
+ },
+
__proto__: WebInspector.VBox.prototype
}
« no previous file with comments | « no previous file | Source/devtools/front_end/Settings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698