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

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

Issue 102433002: [DevTools] Improved console.copy command to handle JSON.stringifyable objects. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed indentation. Created 7 years 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-command-copy-expected.txt ('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 5a8b55725a598bbe4fbc7c94ec62126c03476211..64c39f7c5585f4e420d80bdd10f3a5de88e87e1b 100644
--- a/Source/core/inspector/InjectedScriptSource.js
+++ b/Source/core/inspector/InjectedScriptSource.js
@@ -1383,9 +1383,19 @@ CommandLineAPIImpl.prototype = {
copy: function(object)
{
- if (injectedScript._subtype(object) === "node")
- object = object.outerHTML;
- var string = toString(object);
+ var string;
+ if (injectedScript._subtype(object) === "node") {
+ string = object.outerHTML;
+ } else if (injectedScript.isPrimitiveValue(object)) {
+ string = toString(object);
+ } else {
+ try {
+ string = JSON.stringify(object, null, " ");
+ } catch (e) {
+ string = toString(object);
+ }
+ }
+
var hints = { copyToClipboard: true };
var remoteObject = injectedScript._wrapObject(string, "")
InjectedScriptHost.inspect(remoteObject, hints);
« no previous file with comments | « LayoutTests/inspector/console/console-command-copy-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698