summaryrefslogtreecommitdiffstats
path: root/webkit/glue/devtools/js/inject.js
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/glue/devtools/js/inject.js')
-rw-r--r--webkit/glue/devtools/js/inject.js23
1 files changed, 11 insertions, 12 deletions
diff --git a/webkit/glue/devtools/js/inject.js b/webkit/glue/devtools/js/inject.js
index 6fe992a..ec26991 100644
--- a/webkit/glue/devtools/js/inject.js
+++ b/webkit/glue/devtools/js/inject.js
@@ -545,7 +545,7 @@ devtools.Injected.prototype.getUniqueStyleProperties_ = function(style) {
*/
devtools.Injected.prototype.wrapConsoleObject = function(obj) {
var type = typeof obj;
- if ((type == 'object' && obj != null) || type == 'function') {
+ if (type == 'object' || type == 'function') {
var objId = '#consoleobj#' + this.lastCachedConsoleObjectId_++;
this.cachedConsoleObjects_[objId] = obj;
var result = { ___devtools_id : objId };
@@ -554,25 +554,24 @@ devtools.Injected.prototype.wrapConsoleObject = function(obj) {
result[name] = '';
}
return result;
+ } else {
+ return obj;
}
- return obj;
};
/**
* Caches console object for subsequent calls to getConsoleObjectProperties.
* @param {Object} obj Object to cache.
- * @return {string} Console object wrapper serialized into a JSON string.
+ * @return {string} console object id.
*/
-devtools.Injected.prototype.serializeConsoleObject = function(obj) {
- var result = this.wrapConsoleObject(obj);
- return JSON.stringify(result,
- function (key, value) {
- if (value === undefined) {
- return 'undefined';
- }
- return value;
- });
+devtools.Injected.prototype.evaluate = function(expression) {
+ try {
+ // Evaluate the expression in the global context of the inspected window.
+ return [ this.wrapConsoleObject(contentWindow.eval(expression)), false ];
+ } catch (e) {
+ return [ e.toString(), true ];
+ }
};