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

Side by Side Diff: test/mjsunit/debug-liveedit-2.js

Issue 546125: A brutal approach to V8 script liveedit (Closed)
Patch Set: merge Created 10 years, 10 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 unified diff | Download patch
« no previous file with comments | « test/mjsunit/debug-liveedit-1.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Flags: --expose-debug-as debug
2 // Get the Debug object exposed from the debug context global object.
3
4 Debug = debug.Debug
5
6 eval(
7 "function ChooseAnimal(p) { " +
8 " if (p == 7) {" + // Use p
9 " return;" +
10 " }" +
11 " return function Chooser() {" +
12 " return 'Cat';" +
13 " };" +
14 "}"
15 );
16
17 var old_closure = ChooseAnimal(19);
18
19 assertEquals("Cat", old_closure());
20
21 var script = Debug.findScript(ChooseAnimal);
22
23 var orig_animal = "'Cat'";
24 var patch_pos = script.source.indexOf(orig_animal);
25 var new_animal_patch = "'Capybara' + p";
26
27 // We patch innermost function "Chooser".
28 // However, this does not actually patch existing "Chooser" instances,
29 // because old value of parameter "p" was not saved.
30 // Instead it patches ChooseAnimal.
31 Debug.change_script_live(script, patch_pos, orig_animal.length, new_animal_patch );
32
33 var new_closure = ChooseAnimal(19);
34 // New instance of closure is patched.
35 assertEquals("Capybara19", new_closure());
36
37 // Old instance of closure is not patched.
38 assertEquals("Cat", old_closure());
39
OLDNEW
« no previous file with comments | « test/mjsunit/debug-liveedit-1.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698