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

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

Issue 186693002: DevTools: Prevent setting huge textContent in UI. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: addressed Created 6 years, 10 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 | « Source/devtools/front_end/DOMExtension.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/ObjectPropertiesSection.js
diff --git a/Source/devtools/front_end/ObjectPropertiesSection.js b/Source/devtools/front_end/ObjectPropertiesSection.js
index edd37c782c8a82bc16e502407d80698ce6a80863..ce936e4c2a6d18b9e4e4d44966ad000c8cc7ed05 100644
--- a/Source/devtools/front_end/ObjectPropertiesSection.js
+++ b/Source/devtools/front_end/ObjectPropertiesSection.js
@@ -204,18 +204,20 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
this.valueElement = document.createElement("span");
this.valueElement.className = "value";
var description = this.property.value.description;
- // Render \n as a nice unicode cr symbol.
+ var valueText;
if (this.property.wasThrown) {
- this.valueElement.textContent = "[Exception: " + description + "]";
+ valueText = "[Exception: " + description + "]";
} else if (this.property.value.type === "string" && typeof description === "string") {
- this.valueElement.textContent = "\"" + description.replace(/\n/g, "\u21B5") + "\"";
+ // Render \n as a nice unicode cr symbol.
+ valueText = "\"" + description.replace(/\n/g, "\u21B5") + "\"";
this.valueElement._originalTextContent = "\"" + description + "\"";
} else if (this.property.value.type === "function" && typeof description === "string") {
- this.valueElement.textContent = /.*/.exec(description)[0].replace(/ +$/g, "");
+ valueText = /.*/.exec(description)[0].replace(/ +$/g, "");
this.valueElement._originalTextContent = description;
} else if (this.property.value.type !== "object" || this.property.value.subtype !== "node") {
- this.valueElement.textContent = description;
+ valueText = description;
}
+ this.valueElement.setTextContentTruncatedIfNeeded(valueText || "");
if (this.property.wasThrown)
this.valueElement.classList.add("error");
@@ -316,7 +318,7 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
// Edit original source.
if (typeof valueToEdit !== "undefined")
- elementToEdit.textContent = valueToEdit;
+ elementToEdit.setTextContentTruncatedIfNeeded(valueToEdit, WebInspector.UIString("<string is too large to edit>"));
var context = { expanded: this.expanded, elementToEdit: elementToEdit, previousContent: elementToEdit.textContent };
« no previous file with comments | « Source/devtools/front_end/DOMExtension.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698