OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
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 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1376 * @param {*} object | 1376 * @param {*} object |
1377 * @return {*} | 1377 * @return {*} |
1378 */ | 1378 */ |
1379 inspect: function(object) | 1379 inspect: function(object) |
1380 { | 1380 { |
1381 return injectedScript._inspect(object); | 1381 return injectedScript._inspect(object); |
1382 }, | 1382 }, |
1383 | 1383 |
1384 copy: function(object) | 1384 copy: function(object) |
1385 { | 1385 { |
1386 if (injectedScript._subtype(object) === "node") | 1386 var string; |
1387 object = object.outerHTML; | 1387 if (injectedScript._subtype(object) === "node") { |
1388 var string = toString(object); | 1388 string = object.outerHTML; |
| 1389 } else if (injectedScript.isPrimitiveValue(object)) { |
| 1390 string = toString(object); |
| 1391 } else { |
| 1392 try { |
| 1393 string = JSON.stringify(object, null, " "); |
| 1394 } catch (e) { |
| 1395 string = toString(object); |
| 1396 } |
| 1397 } |
| 1398 |
1389 var hints = { copyToClipboard: true }; | 1399 var hints = { copyToClipboard: true }; |
1390 var remoteObject = injectedScript._wrapObject(string, "") | 1400 var remoteObject = injectedScript._wrapObject(string, "") |
1391 InjectedScriptHost.inspect(remoteObject, hints); | 1401 InjectedScriptHost.inspect(remoteObject, hints); |
1392 }, | 1402 }, |
1393 | 1403 |
1394 clear: function() | 1404 clear: function() |
1395 { | 1405 { |
1396 InjectedScriptHost.clearConsoleMessages(); | 1406 InjectedScriptHost.clearConsoleMessages(); |
1397 }, | 1407 }, |
1398 | 1408 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 */ | 1494 */ |
1485 _logEvent: function(event) | 1495 _logEvent: function(event) |
1486 { | 1496 { |
1487 inspectedWindow.console.log(event.type, event); | 1497 inspectedWindow.console.log(event.type, event); |
1488 } | 1498 } |
1489 } | 1499 } |
1490 | 1500 |
1491 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); | 1501 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); |
1492 return injectedScript; | 1502 return injectedScript; |
1493 }) | 1503 }) |
OLD | NEW |