OLD | NEW |
| (Empty) |
1 // Copyright 2015 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Flags: --expose-debug-as debug --allow-natives-syntax | |
6 | |
7 // Test that live-editing a frame to introduce new.target fails. | |
8 | |
9 Debug = debug.Debug | |
10 var calls = 0; | |
11 var exceptions = 0; | |
12 var results = []; | |
13 var replace_again; | |
14 | |
15 eval(` | |
16 function LogNewTarget() { | |
17 calls++; | |
18 ReplaceOnce(); | |
19 results.push(true); | |
20 } | |
21 `); | |
22 | |
23 function Replace(fun, original, patch) { | |
24 %ExecuteInDebugContext(function() { | |
25 var change_log = []; | |
26 try { | |
27 var script = Debug.findScript(fun); | |
28 var patch_pos = script.source.indexOf(original); | |
29 Debug.LiveEdit.TestApi.ApplySingleChunkPatch( | |
30 script, patch_pos, original.length, patch, change_log); | |
31 } catch (e) { | |
32 assertEquals("BLOCKED_NO_NEW_TARGET_ON_RESTART", | |
33 change_log[0].functions_on_stack[0].replace_problem); | |
34 assertInstanceof(e, Debug.LiveEdit.Failure); | |
35 exceptions++; | |
36 } | |
37 }); | |
38 } | |
39 | |
40 function ReplaceOnce(x) { | |
41 if (replace_again) { | |
42 replace_again = false; | |
43 Replace(LogNewTarget, "true", "new.target"); | |
44 } | |
45 } | |
46 | |
47 function Revert() { | |
48 Replace(LogNewTarget, "new.target", "true"); | |
49 } | |
50 | |
51 replace_again = true; | |
52 ReplaceOnce(); | |
53 new LogNewTarget(); | |
54 Revert(); | |
55 assertEquals(1, calls); | |
56 assertEquals(0, exceptions); | |
57 assertEquals([LogNewTarget], results); | |
58 | |
59 replace_again = true; | |
60 new LogNewTarget(); | |
61 assertEquals(2, calls); // No restarts | |
62 assertEquals(1, exceptions); // Replace failed. | |
63 assertEquals([LogNewTarget, true], results); | |
OLD | NEW |