| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 Debug = debug.Debug; | 30 Debug = debug.Debug; |
| 31 var listened = false; | 31 var listened = false; |
| 32 | 32 |
| 33 function listener(event, exec_state, event_data, data) { | 33 function listener(event, exec_state, event_data, data) { |
| 34 if (event != Debug.DebugEvent.Break) return; | 34 if (event != Debug.DebugEvent.Break) return; |
| 35 try { | 35 try { |
| 36 assertEquals("goo", exec_state.frame(0).evaluate("goo").value()); | 36 assertEquals("goo", exec_state.frame(0).evaluate("goo").value()); |
| 37 exec_state.frame(0).evaluate("goo = 'goo foo'"); | 37 exec_state.frame(0).evaluate("goo = 'goo foo'"); |
| 38 assertEquals("bar return", exec_state.frame(0).evaluate("bar()").value()); | 38 assertEquals("bar return", exec_state.frame(0).evaluate("bar()").value()); |
| 39 assertEquals("inner bar", exec_state.frame(0).evaluate("inner").value()); | 39 // Check that calling bar() has no effect to context-allocated variables. |
| 40 assertEquals("outer bar", exec_state.frame(0).evaluate("outer").value()); | 40 // TODO(yangguo): reevaluate this if we no longer update context from copy. |
| 41 assertEquals("inner", exec_state.frame(0).evaluate("inner").value()); |
| 42 assertEquals("outer", exec_state.frame(0).evaluate("outer").value()); |
| 43 |
| 41 assertEquals("baz inner", exec_state.frame(0).evaluate("baz").value()); | 44 assertEquals("baz inner", exec_state.frame(0).evaluate("baz").value()); |
| 42 assertEquals("baz outer", exec_state.frame(1).evaluate("baz").value()); | 45 assertEquals("baz outer", exec_state.frame(1).evaluate("baz").value()); |
| 43 exec_state.frame(0).evaluate("w = 'w foo'"); | 46 exec_state.frame(0).evaluate("w = 'w foo'"); |
| 44 exec_state.frame(0).evaluate("inner = 'inner foo'"); | 47 exec_state.frame(0).evaluate("inner = 'inner foo'"); |
| 45 exec_state.frame(0).evaluate("outer = 'outer foo'"); | 48 exec_state.frame(0).evaluate("outer = 'outer foo'"); |
| 46 exec_state.frame(0).evaluate("baz = 'baz inner foo'"); | 49 exec_state.frame(0).evaluate("baz = 'baz inner foo'"); |
| 47 exec_state.frame(1).evaluate("baz = 'baz outer foo'"); | 50 exec_state.frame(1).evaluate("baz = 'baz outer foo'"); |
| 48 listened = true; | 51 listened = true; |
| 49 } catch (e) { | 52 } catch (e) { |
| 50 print(e); | 53 print(e); |
| 51 print(e.stack); | 54 print(e.stack); |
| 52 } | 55 } |
| 53 } | 56 } |
| 54 | 57 |
| 55 Debug.setListener(listener); | 58 Debug.setListener(listener); |
| 56 | 59 |
| 57 var outer = "outer"; | 60 var outer = "outer"; |
| 58 var baz = "baz outer"; | 61 var baz = "baz outer"; |
| 59 | 62 |
| 60 function foo() { | 63 function foo() { |
| 61 var inner = "inner"; | 64 var inner = "inner"; |
| 62 var baz = "baz inner"; | 65 var baz = "baz inner"; |
| 63 var goo = "goo"; | 66 var goo = "goo"; |
| 64 var withw = { w: "w" }; | 67 var withw = { w: "w" }; |
| 65 var withv = { v: "v" }; | 68 var withv = { v: "v" }; |
| 66 | 69 |
| 67 with (withv) { | 70 with (withv) { |
| 68 var bar = function bar() { | 71 var bar = function bar() { |
| 69 assertEquals("goo foo", goo); | 72 assertEquals("goo foo", goo); |
| 70 inner = "inner bar"; | 73 inner = "inner bar"; // this has no effect, when called from debug-eval |
| 71 outer = "outer bar"; | 74 outer = "outer bar"; // this has no effect, when called from debug-eval |
| 72 v = "v bar"; | 75 v = "v bar"; |
| 73 return "bar return"; | 76 return "bar return"; |
| 74 }; | 77 }; |
| 75 } | 78 } |
| 76 | 79 |
| 77 with (withw) { | 80 with (withw) { |
| 78 debugger; | 81 debugger; |
| 79 } | 82 } |
| 80 | 83 |
| 81 assertEquals("inner foo", inner); | 84 assertEquals("inner foo", inner); |
| 82 assertEquals("baz inner foo", baz); | 85 assertEquals("baz inner foo", baz); |
| 83 assertEquals("w foo", withw.w); | 86 assertEquals("w foo", withw.w); |
| 84 assertEquals("v bar", withv.v); | 87 assertEquals("v bar", withv.v); |
| 85 } | 88 } |
| 86 | 89 |
| 87 foo(); | 90 foo(); |
| 88 assertEquals("outer foo", outer); | 91 assertEquals("outer foo", outer); |
| 89 assertEquals("baz outer foo", baz); | 92 assertEquals("baz outer foo", baz); |
| 90 assertTrue(listened); | 93 assertTrue(listened); |
| 91 Debug.setListener(null); | 94 Debug.setListener(null); |
| OLD | NEW |