| OLD | NEW |
| (Empty) |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | |
| 2 // Redistribution and use in source and binary forms, with or without | |
| 3 // modification, are permitted provided that the following conditions are | |
| 4 // met: | |
| 5 // | |
| 6 // * Redistributions of source code must retain the above copyright | |
| 7 // notice, this list of conditions and the following disclaimer. | |
| 8 // * Redistributions in binary form must reproduce the above | |
| 9 // copyright notice, this list of conditions and the following | |
| 10 // disclaimer in the documentation and/or other materials provided | |
| 11 // with the distribution. | |
| 12 // * Neither the name of Google Inc. nor the names of its | |
| 13 // contributors may be used to endorse or promote products derived | |
| 14 // from this software without specific prior written permission. | |
| 15 // | |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 27 | |
| 28 // Flags: --expose-debug-as debug | |
| 29 | |
| 30 // Check that the ScopeIterator can properly recreate the scope at | |
| 31 // every point when stepping through functions. | |
| 32 | |
| 33 var Debug = debug.Debug; | |
| 34 | |
| 35 function listener(event, exec_state, event_data, data) { | |
| 36 if (event == Debug.DebugEvent.Break) { | |
| 37 // Access scope details. | |
| 38 var scope_count = exec_state.frame().scopeCount(); | |
| 39 for (var i = 0; i < scope_count; i++) { | |
| 40 var scope = exec_state.frame().scope(i); | |
| 41 // assertTrue(scope.isScope()); | |
| 42 scope.scopeType(); | |
| 43 scope.scopeObject(); | |
| 44 } | |
| 45 | |
| 46 // Do steps until we reach the global scope again. | |
| 47 exec_state.prepareStep(Debug.StepAction.StepIn); | |
| 48 } | |
| 49 } | |
| 50 | |
| 51 Debug.setListener(listener); | |
| 52 | |
| 53 | |
| 54 function test1() { | |
| 55 debugger; | |
| 56 with ({x:1}) { | |
| 57 x = 2; | |
| 58 } | |
| 59 } | |
| 60 test1(); | |
| 61 | |
| 62 | |
| 63 function test2() { | |
| 64 if (true) { | |
| 65 with ({}) { | |
| 66 debugger; | |
| 67 } | |
| 68 } else { | |
| 69 with ({}) { | |
| 70 return 10; | |
| 71 } | |
| 72 } | |
| 73 } | |
| 74 test2(); | |
| 75 | |
| 76 | |
| 77 function test3() { | |
| 78 if (true) { | |
| 79 debugger; | |
| 80 } else { | |
| 81 with ({}) { | |
| 82 return 10; | |
| 83 } | |
| 84 } | |
| 85 } | |
| 86 test3(); | |
| 87 | |
| 88 | |
| 89 function test4() { | |
| 90 debugger; | |
| 91 with ({x:1}) x = 1 | |
| 92 } | |
| 93 test4(); | |
| 94 | |
| 95 | |
| 96 function test5() { | |
| 97 debugger; | |
| 98 var dummy = 1; | |
| 99 with ({}) { | |
| 100 with ({}) { | |
| 101 dummy = 2; | |
| 102 } | |
| 103 } | |
| 104 dummy = 3; | |
| 105 } | |
| 106 test5(); | |
| 107 | |
| 108 | |
| 109 function test6() { | |
| 110 debugger; | |
| 111 try { | |
| 112 throw 'stuff'; | |
| 113 } catch (e) { | |
| 114 e = 1; | |
| 115 } | |
| 116 } | |
| 117 test6(); | |
| 118 | |
| 119 | |
| 120 function test7() { | |
| 121 debugger; | |
| 122 function foo() {} | |
| 123 } | |
| 124 test7(); | |
| 125 | |
| 126 | |
| 127 function test8() { | |
| 128 debugger; | |
| 129 (function foo() {})(); | |
| 130 } | |
| 131 test8(); | |
| 132 | |
| 133 | |
| 134 function test10() { | |
| 135 debugger; | |
| 136 with ({}) { | |
| 137 return 10; | |
| 138 } | |
| 139 } | |
| 140 test10(); | |
| 141 | |
| 142 | |
| 143 function test11() { | |
| 144 debugger; | |
| 145 try { | |
| 146 throw 'stuff'; | |
| 147 } catch (e) { | |
| 148 return 10; | |
| 149 } | |
| 150 } | |
| 151 test11(); | |
| 152 | |
| 153 | |
| 154 var prefixes = [ | |
| 155 "debugger; ", | |
| 156 "if (false) { try { throw 0; } catch(x) { return x; } }; debugger; " ]; | |
| 157 | |
| 158 | |
| 159 // Return from function constructed with Function constructor. | |
| 160 var anon = 12; | |
| 161 for (var i = 0; i < prefixes.length; ++i) { | |
| 162 var pre = prefixes[i]; | |
| 163 Function(pre + "return 42")(); | |
| 164 Function(pre + "return 42 ")(); | |
| 165 Function(pre + "return 42;")(); | |
| 166 Function(pre + "return 42; ")(); | |
| 167 Function(pre + "return anon")(); | |
| 168 Function(pre + "return anon ")(); | |
| 169 Function(pre + "return anon;")(); | |
| 170 Function(pre + "return anon; ")(); | |
| 171 } | |
| 172 | |
| 173 | |
| 174 try { | |
| 175 with({}) { | |
| 176 debugger; | |
| 177 eval("{}$%:^"); | |
| 178 } | |
| 179 } catch(e) { | |
| 180 nop(); | |
| 181 } | |
| 182 | |
| 183 | |
| 184 function nop() {} | |
| 185 | |
| 186 | |
| 187 // With block as the last(!) statement in global code. | |
| 188 with ({}) { debugger; } | |
| OLD | NEW |