| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 // Test that live-editing a frame that uses new.target fails. | 6 // Test that live-editing a frame that uses new.target fails. |
| 7 | 7 |
| 8 Debug = debug.Debug | 8 Debug = debug.Debug |
| 9 var calls = 0; | 9 var calls = 0; |
| 10 var exceptions = 0; | 10 var exceptions = 0; |
| 11 var results = []; | 11 var results = []; |
| 12 var replace_again; | 12 var replace_again; |
| 13 | 13 |
| 14 eval(` | 14 eval(` |
| 15 function LogNewTarget() { | 15 function LogNewTarget() { |
| 16 calls++; | 16 calls++; |
| 17 ReplaceOnce(); | 17 ReplaceOnce(); |
| 18 results.push(true); | 18 results.push(true); |
| 19 results.push(new.target); | 19 results.push(new.target); |
| 20 } | 20 } |
| 21 `); | 21 `); |
| 22 | 22 |
| 23 function Dummy() {} | 23 function Dummy() {} |
| 24 | 24 |
| 25 function ExecuteInDebugContext(f) { |
| 26 var result; |
| 27 var exception = null; |
| 28 Debug.setListener(function(event) { |
| 29 if (event == Debug.DebugEvent.Break) { |
| 30 try { |
| 31 result = f(); |
| 32 } catch (e) { |
| 33 // Rethrow this exception later. |
| 34 exception = e; |
| 35 } |
| 36 } |
| 37 }); |
| 38 debugger; |
| 39 Debug.setListener(null); |
| 40 if (exception !== null) throw exception; |
| 41 return result; |
| 42 } |
| 43 |
| 25 function Replace(fun, original, patch) { | 44 function Replace(fun, original, patch) { |
| 26 %ExecuteInDebugContext(function() { | 45 ExecuteInDebugContext(function() { |
| 27 var change_log = []; | 46 var change_log = []; |
| 28 try { | 47 try { |
| 29 var script = Debug.findScript(fun); | 48 var script = Debug.findScript(fun); |
| 30 var patch_pos = script.source.indexOf(original); | 49 var patch_pos = script.source.indexOf(original); |
| 31 Debug.LiveEdit.TestApi.ApplySingleChunkPatch( | 50 Debug.LiveEdit.TestApi.ApplySingleChunkPatch( |
| 32 script, patch_pos, original.length, patch, change_log); | 51 script, patch_pos, original.length, patch, change_log); |
| 33 } catch (e) { | 52 } catch (e) { |
| 34 assertEquals("BLOCKED_NO_NEW_TARGET_ON_RESTART", | 53 assertEquals("BLOCKED_NO_NEW_TARGET_ON_RESTART", |
| 35 change_log[0].functions_on_stack[0].replace_problem); | 54 change_log[0].functions_on_stack[0].replace_problem); |
| 36 assertInstanceof(e, Debug.LiveEdit.Failure); | 55 assertInstanceof(e, Debug.LiveEdit.Failure); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 65 new LogNewTarget(); | 84 new LogNewTarget(); |
| 66 | 85 |
| 67 replace_again = true; | 86 replace_again = true; |
| 68 Reflect.construct(LogNewTarget, [], Dummy); | 87 Reflect.construct(LogNewTarget, [], Dummy); |
| 69 | 88 |
| 70 assertEquals( | 89 assertEquals( |
| 71 [false, LogNewTarget, true, undefined, true, LogNewTarget, true, Dummy], | 90 [false, LogNewTarget, true, undefined, true, LogNewTarget, true, Dummy], |
| 72 results); | 91 results); |
| 73 assertEquals(4, calls); // No restarts | 92 assertEquals(4, calls); // No restarts |
| 74 assertEquals(3, exceptions); // Replace failed. | 93 assertEquals(3, exceptions); // Replace failed. |
| OLD | NEW |