| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 // Flags: --expose-debug-as debug | 28 // Flags: --expose-debug-as debug |
| 29 // Get the Debug object exposed from the debug context global object. | 29 // Get the Debug object exposed from the debug context global object. |
| 30 Debug = debug.Debug | 30 Debug = debug.Debug |
| 31 | 31 |
| 32 listenerComplete = false; | 32 listenerComplete = false; |
| 33 exception = false; | 33 exception = false; |
| 34 | 34 |
| 35 | 35 |
| 36 function checkFrame0(name, value) { | 36 function checkFrame0(name, value) { |
| 37 assertTrue(name == 'a' || name == 'b', 'frame0 name'); | 37 assertTrue(name == 'a' || name == 'b'); |
| 38 if (name == 'a') { | 38 if (name == 'a') { |
| 39 assertEquals(1, value); | 39 assertEquals(1, value); |
| 40 } else if (name == 'b') { | 40 } |
| 41 if (name == 'b') { |
| 41 assertEquals(2, value); | 42 assertEquals(2, value); |
| 42 } | 43 } |
| 43 } | 44 } |
| 44 | 45 |
| 45 | 46 |
| 46 function checkFrame1(name, value) { | 47 function checkFrame1(name, value) { |
| 47 assertTrue(name == '.arguments' || name == 'arguments' || name == 'a', | 48 assertTrue(name == '.arguments' || name == 'a'); |
| 48 'frame1 name'); | |
| 49 if (name == 'a') { | 49 if (name == 'a') { |
| 50 assertEquals(3, value); | 50 assertEquals(3, value); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 function checkFrame2(name, value) { | 55 function checkFrame2(name, value) { |
| 56 assertTrue(name == 'a' || name == 'b', 'frame2 name'); | 56 assertTrue(name == '.arguments' || name == 'a' || |
| 57 name == 'arguments' || name == 'b'); |
| 57 if (name == 'a') { | 58 if (name == 'a') { |
| 58 assertEquals(5, value); | 59 assertEquals(5, value); |
| 59 } else if (name == 'b') { | 60 } |
| 61 if (name == 'b') { |
| 60 assertEquals(0, value); | 62 assertEquals(0, value); |
| 61 } | 63 } |
| 62 } | 64 } |
| 63 | 65 |
| 64 | 66 |
| 65 function listener(event, exec_state, event_data, data) { | 67 function listener(event, exec_state, event_data, data) { |
| 66 try { | 68 try { |
| 67 if (event == Debug.DebugEvent.Break) | 69 if (event == Debug.DebugEvent.Break) |
| 68 { | 70 { |
| 69 // Frame 0 has normal variables a and b. | 71 // Frame 0 has normal variables a and b. |
| 70 var frame0 = exec_state.frame(0); | 72 var frame0 = exec_state.frame(0); |
| 71 checkFrame0(frame0.localName(0), frame0.localValue(0).value()); | 73 checkFrame0(frame0.localName(0), frame0.localValue(0).value()); |
| 72 checkFrame0(frame0.localName(1), frame0.localValue(1).value()); | 74 checkFrame0(frame0.localName(1), frame0.localValue(1).value()); |
| 73 | 75 |
| 74 // Frame 1 has normal variables a and arguments (and the .arguments | 76 // Frame 1 has normal variable a (and the .arguments variable). |
| 75 // variable). | |
| 76 var frame1 = exec_state.frame(1); | 77 var frame1 = exec_state.frame(1); |
| 77 checkFrame1(frame1.localName(0), frame1.localValue(0).value()); | 78 checkFrame1(frame1.localName(0), frame1.localValue(0).value()); |
| 78 checkFrame1(frame1.localName(1), frame1.localValue(1).value()); | 79 checkFrame1(frame1.localName(1), frame1.localValue(1).value()); |
| 79 checkFrame1(frame1.localName(2), frame1.localValue(2).value()); | |
| 80 | 80 |
| 81 // Frame 2 has normal variables a and b. | 81 // Frame 2 has normal variables a and b (and both the .arguments and |
| 82 // arguments variable). |
| 82 var frame2 = exec_state.frame(2); | 83 var frame2 = exec_state.frame(2); |
| 83 checkFrame2(frame2.localName(0), frame2.localValue(0).value()); | 84 checkFrame2(frame2.localName(0), frame2.localValue(0).value()); |
| 84 checkFrame2(frame2.localName(1), frame2.localValue(1).value()); | 85 checkFrame2(frame2.localName(1), frame2.localValue(1).value()); |
| 86 checkFrame2(frame2.localName(2), frame2.localValue(2).value()); |
| 87 checkFrame2(frame2.localName(3), frame2.localValue(3).value()); |
| 85 | 88 |
| 86 // Evaluating a and b on frames 0, 1 and 2 produces 1, 2, 3, 4, 5 and 6. | 89 // Evaluating a and b on frames 0, 1 and 2 produces 1, 2, 3, 4, 5 and 6. |
| 87 assertEquals(1, exec_state.frame(0).evaluate('a').value()); | 90 assertEquals(1, exec_state.frame(0).evaluate('a').value()); |
| 88 assertEquals(2, exec_state.frame(0).evaluate('b').value()); | 91 assertEquals(2, exec_state.frame(0).evaluate('b').value()); |
| 89 assertEquals(3, exec_state.frame(1).evaluate('a').value()); | 92 assertEquals(3, exec_state.frame(1).evaluate('a').value()); |
| 90 assertEquals(4, exec_state.frame(1).evaluate('b').value()); | 93 assertEquals(4, exec_state.frame(1).evaluate('b').value()); |
| 91 assertEquals(5, exec_state.frame(2).evaluate('a').value()); | 94 assertEquals(5, exec_state.frame(2).evaluate('a').value()); |
| 92 assertEquals(6, exec_state.frame(2).evaluate('b').value()); | 95 assertEquals(6, exec_state.frame(2).evaluate('b').value()); |
| 93 | 96 |
| 94 // Indicate that all was processed. | 97 // Indicate that all was processed. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 120 with ({b:6}) { | 123 with ({b:6}) { |
| 121 g(); | 124 g(); |
| 122 } | 125 } |
| 123 }; | 126 }; |
| 124 | 127 |
| 125 f(); | 128 f(); |
| 126 | 129 |
| 127 // Make sure that the debug event listener vas invoked. | 130 // Make sure that the debug event listener vas invoked. |
| 128 assertTrue(listenerComplete); | 131 assertTrue(listenerComplete); |
| 129 assertFalse(exception, "exception in listener") | 132 assertFalse(exception, "exception in listener") |
| OLD | NEW |