OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 // Flags: --harmony-object-observe | |
6 // Flags: --allow-natives-syntax --expose-debug-as debug | 5 // Flags: --allow-natives-syntax --expose-debug-as debug |
7 | 6 |
8 Debug = debug.Debug | 7 Debug = debug.Debug |
9 var exception = null; | 8 var exception = null; |
10 var break_count = 0; | 9 var break_count = 0; |
11 var expected_breaks = -1; | 10 var expected_breaks = -1; |
12 | 11 |
13 function listener(event, exec_state, event_data, data) { | 12 function listener(event, exec_state, event_data, data) { |
14 try { | 13 try { |
15 if (event == Debug.DebugEvent.Break) { | 14 if (event == Debug.DebugEvent.Break) { |
(...skipping 23 matching lines...) Expand all Loading... |
39 }; | 38 }; |
40 | 39 |
41 Debug.setListener(listener); | 40 Debug.setListener(listener); |
42 | 41 |
43 Promise.resolve(42) | 42 Promise.resolve(42) |
44 .then(promise1) | 43 .then(promise1) |
45 .then(Object) // Should skip stepping into native. | 44 .then(Object) // Should skip stepping into native. |
46 .then(Boolean) // Should skip stepping into native. | 45 .then(Boolean) // Should skip stepping into native. |
47 .then(promise2) | 46 .then(promise2) |
48 .catch(promise3) | 47 .catch(promise3) |
| 48 .then(promise4) |
49 .catch(function(e) { | 49 .catch(function(e) { |
50 %AbortJS("FAIL: uncaught exception " + e); | 50 %AbortJS("FAIL: uncaught exception " + e); |
51 }); | 51 }); |
52 | 52 |
53 function promise1() { | 53 function promise1() { |
54 debugger; // Break 0. | 54 debugger; // Break 0. |
55 return exception || 1; // Break 1. | 55 return exception || 1; // Break 1. |
56 } // Break 2. | 56 } // Break 2. |
57 | 57 |
58 function promise2() { | 58 function promise2() { |
59 throw new Error; // Break 3. | 59 throw new Error; // Break 3. |
60 } | 60 } |
61 | 61 |
62 function promise3() { | 62 function promise3() { |
63 installObservers(); // Break 4. StepOver. | 63 return break_count; // Break 4. |
64 return break_count; // Break 5. | 64 } // Break 5. |
65 } // Break 6. | |
66 | |
67 function installObservers() { | |
68 var dummy = {}; | |
69 Object.observe(dummy, observer1); | |
70 Object.observe(dummy, Object); // Should skip stepping into native. | |
71 Object.observe(dummy, Boolean); // Should skip stepping into native. | |
72 Object.observe(dummy, observer2); | |
73 dummy.foo = 1; | |
74 } | |
75 | |
76 function observer1() { | |
77 return exception || 3; // Break 7. | |
78 } // Break 8. | |
79 | |
80 function observer2() { | |
81 Promise.resolve().then(promise4); // Break 9. StepOver. | |
82 return break_count + 1; // Break 10. | |
83 } // Break 11. | |
84 | 65 |
85 function promise4() { | 66 function promise4() { |
86 finalize(); // Break 12. StepOver. | 67 finalize(); // Break 6. StepOver. |
87 return 0; // Break 13. | 68 return 0; // Break 7. |
88 } // Break 14. StepOver. | 69 } // Break 8. StepOver. |
89 | 70 |
90 function finalize() { | 71 function finalize() { |
91 var dummy = {}; | 72 Promise.resolve().then(function() { |
92 Object.observe(dummy, function() { | |
93 if (expected_breaks !== break_count) { | 73 if (expected_breaks !== break_count) { |
94 %AbortJS("FAIL: expected <" + expected_breaks + "> breaks instead of <" + | 74 %AbortJS("FAIL: expected <" + expected_breaks + "> breaks instead of <" + |
95 break_count + ">"); | 75 break_count + ">"); |
96 } | 76 } |
97 if (exception !== null) { | 77 if (exception !== null) { |
98 %AbortJS("FAIL: exception: " + exception); | 78 %AbortJS("FAIL: exception: " + exception); |
99 } | 79 } |
100 }); | 80 }); |
101 dummy.foo = 1; | |
102 } | 81 } |
OLD | NEW |