summaryrefslogtreecommitdiffstats
path: root/webkit/glue/devtools/js
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/glue/devtools/js')
-rw-r--r--webkit/glue/devtools/js/devtools.js21
-rw-r--r--webkit/glue/devtools/js/inject.js23
-rw-r--r--webkit/glue/devtools/js/tests.js22
3 files changed, 46 insertions, 20 deletions
diff --git a/webkit/glue/devtools/js/devtools.js b/webkit/glue/devtools/js/devtools.js
index c3f8ac7..79a2a71 100644
--- a/webkit/glue/devtools/js/devtools.js
+++ b/webkit/glue/devtools/js/devtools.js
@@ -67,18 +67,21 @@ devtools.ToolsAgent.prototype.reset = function() {
/**
* @param {string} script Script exression to be evaluated in the context of the
* inspected page.
- * @param {function(string):undefined} callback Function to call with the
- * result.
+ * @param {function(Object|string, boolean):undefined} opt_callback Function to call
+ * with the result.
*/
-devtools.ToolsAgent.prototype.evaluateJavaScript = function(script, callback) {
- var callbackId = devtools.Callback.wrap(function(result) {
- var pair = JSON.parse(result);
- if (callback) {
- callback(pair[0], pair[1]);
+devtools.ToolsAgent.prototype.evaluateJavaScript = function(script,
+ opt_callback) {
+ var callbackId = devtools.Callback.wrap(function(result, exception) {
+ if (opt_callback) {
+ if (exception) {
+ opt_callback(exception, true /* result is exception */);
+ } else {
+ opt_callback(JSON.parse(result), false);
+ }
}
});
- RemoteToolsAgent.ExecuteUtilityFunction(callbackId,
- 'evaluate', JSON.stringify([script]));
+ RemoteToolsAgent.EvaluateJavaScript(callbackId, script);
};
diff --git a/webkit/glue/devtools/js/inject.js b/webkit/glue/devtools/js/inject.js
index ec26991..6fe992a 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' || type == 'function') {
+ if ((type == 'object' && obj != null) || type == 'function') {
var objId = '#consoleobj#' + this.lastCachedConsoleObjectId_++;
this.cachedConsoleObjects_[objId] = obj;
var result = { ___devtools_id : objId };
@@ -554,24 +554,25 @@ 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 id.
+ * @return {string} Console object wrapper serialized into a JSON string.
*/
-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 ];
- }
+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;
+ });
};
diff --git a/webkit/glue/devtools/js/tests.js b/webkit/glue/devtools/js/tests.js
index ade8de3..7f75f71 100644
--- a/webkit/glue/devtools/js/tests.js
+++ b/webkit/glue/devtools/js/tests.js
@@ -444,6 +444,28 @@ TestSuite.prototype.testSetBreakpoint = function() {
/**
+ * Tests 'Pause' button will pause debugger when a snippet is evaluated.
+ */
+TestSuite.prototype.testPauseInEval = function() {
+ this.showPanel('scripts');
+
+ var test = this;
+
+ var pauseButton = document.getElementById('scripts-pause');
+ pauseButton.click();
+
+ devtools.tools.evaluateJavaScript('fib(10)');
+
+ this.addSniffer(WebInspector, 'pausedScript',
+ function() {
+ test.releaseControl();
+ });
+
+ test.takeControl();
+};
+
+
+/**
* Key event with given key identifier.
*/
TestSuite.KeyEvent = function(key) {