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

Unified Diff: src/debug-debugger.js

Issue 1584008: Let LiveEdit accept a full new script source (rather than diff) (Closed)
Patch Set: follow codereview Created 10 years, 9 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 | « no previous file | src/liveedit-debugger.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug-debugger.js
diff --git a/src/debug-debugger.js b/src/debug-debugger.js
index c296e422d842e14a9f180d1bbd9fecd034a4d176..060e159f33de9aa8e0ae30692dde3dffc6d5afd1 100644
--- a/src/debug-debugger.js
+++ b/src/debug-debugger.js
@@ -1966,14 +1966,7 @@ DebugCommandProcessor.prototype.changeLiveRequest_ = function(request, response)
return response.failed('Missing arguments');
}
var script_id = request.arguments.script_id;
- var change_pos = parseInt(request.arguments.change_pos);
- var change_len = parseInt(request.arguments.change_len);
- var new_string = request.arguments.new_string;
- if (!IS_STRING(new_string)) {
- response.failed('Argument "new_string" is not a string value');
- return;
- }
-
+
var scripts = %DebugGetLoadedScripts();
var the_script = null;
@@ -1987,10 +1980,32 @@ DebugCommandProcessor.prototype.changeLiveRequest_ = function(request, response)
return;
}
+ // A function that calls a proper signature of LiveEdit API.
+ var invocation;
+
var change_log = new Array();
+
+ if (IS_STRING(request.arguments.new_source)) {
+ var new_source = request.arguments.new_source;
+ invocation = function() {
+ return Debug.LiveEdit.SetScriptSource(the_script, new_source, change_log);
+ }
+ } else {
+ var change_pos = parseInt(request.arguments.change_pos);
+ var change_len = parseInt(request.arguments.change_len);
+ var new_string = request.arguments.new_string;
+ if (!IS_STRING(new_string)) {
+ response.failed('Argument "new_string" is not a string value');
+ return;
+ }
+ invocation = function() {
+ return Debug.LiveEditChangeScript(the_script, change_pos, change_len,
+ new_string, change_log);
+ }
+ }
+
try {
- Debug.LiveEditChangeScript(the_script, change_pos, change_len, new_string,
- change_log);
+ invocation();
} catch (e) {
if (e instanceof Debug.LiveEditChangeScript.Failure) {
// Let's treat it as a "success" so that body with change_log will be
« no previous file with comments | « no previous file | src/liveedit-debugger.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698