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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/devtools/front_end/Settings.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 this.messagesElement.id = "console-messages"; 79 this.messagesElement.id = "console-messages";
80 this.messagesElement.className = "monospace"; 80 this.messagesElement.className = "monospace";
81 this.messagesElement.addEventListener("click", this._messagesClicked.bind(th is), true); 81 this.messagesElement.addEventListener("click", this._messagesClicked.bind(th is), true);
82 this._contentsElement.appendChild(this.messagesElement); 82 this._contentsElement.appendChild(this.messagesElement);
83 this._scrolledToBottom = true; 83 this._scrolledToBottom = true;
84 84
85 this.promptElement = document.createElement("div"); 85 this.promptElement = document.createElement("div");
86 this.promptElement.id = "console-prompt"; 86 this.promptElement.id = "console-prompt";
87 this.promptElement.className = "source-code"; 87 this.promptElement.className = "source-code";
88 this.promptElement.spellcheck = false; 88 this.promptElement.spellcheck = false;
89 this.promptElement.addEventListener("paste", this._onPasteIntoPrompt.bind(th is), false);
90 this.promptElement.addEventListener("drop", this._onPasteIntoPrompt.bind(thi s), false);
89 this.messagesElement.appendChild(this.promptElement); 91 this.messagesElement.appendChild(this.promptElement);
90 this.messagesElement.appendChild(document.createElement("br")); 92 this.messagesElement.appendChild(document.createElement("br"));
91 93
92 this.topGroup = new WebInspector.ConsoleGroup(null); 94 this.topGroup = new WebInspector.ConsoleGroup(null);
93 this.messagesElement.insertBefore(this.topGroup.element, this.promptElement) ; 95 this.messagesElement.insertBefore(this.topGroup.element, this.promptElement) ;
94 this.currentGroup = this.topGroup; 96 this.currentGroup = this.topGroup;
95 97
96 this._showAllMessagesCheckbox = new WebInspector.StatusBarCheckbox(WebInspec tor.UIString("Show all messages")); 98 this._showAllMessagesCheckbox = new WebInspector.StatusBarCheckbox(WebInspec tor.UIString("Show all messages"));
97 this._showAllMessagesCheckbox._checkbox.checked = true; 99 this._showAllMessagesCheckbox._checkbox.checked = true;
98 this._showAllMessagesCheckbox._checkbox.addEventListener("change", this._upd ateMessageList.bind(this), false); 100 this._showAllMessagesCheckbox._checkbox.addEventListener("change", this._upd ateMessageList.bind(this), false);
(...skipping 13 matching lines...) Expand all
112 /** @type {!Map.<!WebInspector.ConsoleMessage, !WebInspector.ConsoleViewMess age>} */ 114 /** @type {!Map.<!WebInspector.ConsoleMessage, !WebInspector.ConsoleViewMess age>} */
113 this._messageToViewMessage = new Map(); 115 this._messageToViewMessage = new Map();
114 /** @type {!Array.<!WebInspector.ConsoleMessage>} */ 116 /** @type {!Array.<!WebInspector.ConsoleMessage>} */
115 this._consoleMessages = []; 117 this._consoleMessages = [];
116 118
117 this.prompt = new WebInspector.TextPromptWithHistory(this._completionsForTex tPrompt.bind(this)); 119 this.prompt = new WebInspector.TextPromptWithHistory(this._completionsForTex tPrompt.bind(this));
118 this.prompt.setSuggestBoxEnabled("generic-suggest"); 120 this.prompt.setSuggestBoxEnabled("generic-suggest");
119 this.prompt.renderAsBlock(); 121 this.prompt.renderAsBlock();
120 this.prompt.attach(this.promptElement); 122 this.prompt.attach(this.promptElement);
121 this.prompt.proxyElement.addEventListener("keydown", this._promptKeyDown.bin d(this), false); 123 this.prompt.proxyElement.addEventListener("keydown", this._promptKeyDown.bin d(this), false);
122 this.prompt.setHistoryData(WebInspector.settings.consoleHistory.get()); 124 var historyData = WebInspector.settings.consoleHistory.get();
125 this.prompt.setHistoryData(historyData);
126 if (!WebInspector.settings.allowPastingJavaScript.get() && historyData && hi storyData.length > 10)
127 WebInspector.settings.allowPastingJavaScript.set(true);
123 128
124 WebInspector.targetManager.observeTargets(this); 129 WebInspector.targetManager.observeTargets(this);
125 130
126 this._filterStatusMessageElement = document.createElement("div"); 131 this._filterStatusMessageElement = document.createElement("div");
127 this._filterStatusMessageElement.classList.add("console-message"); 132 this._filterStatusMessageElement.classList.add("console-message");
128 this._filterStatusTextElement = this._filterStatusMessageElement.createChild ("span", "console-info"); 133 this._filterStatusTextElement = this._filterStatusMessageElement.createChild ("span", "console-info");
129 this._filterStatusMessageElement.createTextChild(" "); 134 this._filterStatusMessageElement.createTextChild(" ");
130 var resetFiltersLink = this._filterStatusMessageElement.createChild("span", "console-info node-link"); 135 var resetFiltersLink = this._filterStatusMessageElement.createChild("span", "console-info node-link");
131 resetFiltersLink.textContent = WebInspector.UIString("Show all messages."); 136 resetFiltersLink.textContent = WebInspector.UIString("Show all messages.");
132 resetFiltersLink.addEventListener("click", this._filter.reset.bind(this._fil ter), true); 137 resetFiltersLink.addEventListener("click", this._filter.reset.bind(this._fil ter), true);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 { 277 {
273 var option = this._executionContextSelector.selectedOption(); 278 var option = this._executionContextSelector.selectedOption();
274 return option ? option._executionContext : null; 279 return option ? option._executionContext : null;
275 }, 280 },
276 281
277 /** 282 /**
278 * @return {?WebInspector.Target} 283 * @return {?WebInspector.Target}
279 */ 284 */
280 _currentTarget: function() 285 _currentTarget: function()
281 { 286 {
282 // var executionContext = this._currentExecutionContext();
283 // return executionContext ? executionContext.target() : null;
284 return WebInspector.targetManager.activeTarget(); 287 return WebInspector.targetManager.activeTarget();
285 }, 288 },
286 289
287 /** 290 /**
288 * @param {!Element} proxyElement 291 * @param {!Element} proxyElement
289 * @param {!Range} wordRange 292 * @param {!Range} wordRange
290 * @param {boolean} force 293 * @param {boolean} force
291 * @param {function(!Array.<string>, number=)} completionsReadyCallback 294 * @param {function(!Array.<string>, number=)} completionsReadyCallback
292 */ 295 */
293 _completionsForTextPrompt: function(proxyElement, wordRange, force, completi onsReadyCallback) 296 _completionsForTextPrompt: function(proxyElement, wordRange, force, completi onsReadyCallback)
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 917
915 _jumpToSearchResult: function(index) 918 _jumpToSearchResult: function(index)
916 { 919 {
917 index %= this._searchResults.length; 920 index %= this._searchResults.length;
918 this._clearCurrentSearchResultHighlight(); 921 this._clearCurrentSearchResultHighlight();
919 this._currentSearchResultIndex = index; 922 this._currentSearchResultIndex = index;
920 this._searchableView.updateCurrentMatchIndex(this._currentSearchResultIn dex); 923 this._searchableView.updateCurrentMatchIndex(this._currentSearchResultIn dex);
921 this._searchResults[index].highlightSearchResults(this._searchRegex); 924 this._searchResults[index].highlightSearchResults(this._searchRegex);
922 }, 925 },
923 926
927 /**
928 * @param {?Event} e
929 */
930 _onPasteIntoPrompt: function(e)
931 {
932 if (WebInspector.settings.allowPastingJavaScript.get())
933 return;
934 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 in put field below to allow this action"));
935 if (result === "always allow") {
936 WebInspector.settings.allowPastingJavaScript.set(true);
937 return;
938 }
939 e.consume(true);
940 },
941
924 __proto__: WebInspector.VBox.prototype 942 __proto__: WebInspector.VBox.prototype
925 } 943 }
926 944
927 /** 945 /**
928 * @constructor 946 * @constructor
929 * @extends {WebInspector.Object} 947 * @extends {WebInspector.Object}
930 * @param {!WebInspector.ConsoleView} view 948 * @param {!WebInspector.ConsoleView} view
931 */ 949 */
932 WebInspector.ConsoleViewFilter = function(view) 950 WebInspector.ConsoleViewFilter = function(view)
933 { 951 {
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 WebInspector.ConsoleView.ShowConsoleActionDelegate.prototype = { 1274 WebInspector.ConsoleView.ShowConsoleActionDelegate.prototype = {
1257 /** 1275 /**
1258 * @return {boolean} 1276 * @return {boolean}
1259 */ 1277 */
1260 handleAction: function() 1278 handleAction: function()
1261 { 1279 {
1262 WebInspector.console.show(); 1280 WebInspector.console.show();
1263 return true; 1281 return true;
1264 } 1282 }
1265 } 1283 }
OLDNEW
« 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