| OLD | NEW |
| (Empty) |
| 1 // Copyright 2008 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 --noanalyze-environment-liveness | |
| 29 // Get the Debug object exposed from the debug context global object. | |
| 30 Debug = debug.Debug | |
| 31 | |
| 32 function listener(event, exec_state, event_data, data) { | |
| 33 if (event !== Debug.DebugEvent.Break) return; | |
| 34 try { | |
| 35 var context = { what_is_capybara: "a fish" }; | |
| 36 var context2 = { what_is_capybara: "a fish", what_is_parrot: "a beard" }; | |
| 37 | |
| 38 // Try in frame's scope. | |
| 39 var local_expression = | |
| 40 "(what_is_capybara ? what_is_capybara : 'a beast')" + | |
| 41 " + '/' + what_is_parrot"; | |
| 42 var result = evaluate_callback.in_top_frame( | |
| 43 exec_state, local_expression, context); | |
| 44 assertEquals('a fish/a bird', result); | |
| 45 | |
| 46 // Try in frame's scope with overrididen local variables. | |
| 47 var result = evaluate_callback.in_top_frame( | |
| 48 exec_state, local_expression, context2); | |
| 49 assertEquals('a fish/a beard', result); | |
| 50 | |
| 51 // Try in frame's scope, without context. | |
| 52 var local_expression2 = "what_is_parrot"; | |
| 53 var result = evaluate_callback.in_top_frame( | |
| 54 exec_state, local_expression2, void 0); | |
| 55 assertEquals('a bird', result); | |
| 56 | |
| 57 // Try in global additional scope. | |
| 58 var global_expression = "what_is_capybara ? what_is_capybara : 'a beast'"; | |
| 59 var result = evaluate_callback.globally( | |
| 60 exec_state, global_expression, context); | |
| 61 assertEquals('a fish', result); | |
| 62 | |
| 63 // Try in global scope with overridden global variables. | |
| 64 var context_with_undefined = { undefined: 'kitten' }; | |
| 65 var global_expression2 = "'cat' + '/' + undefined"; | |
| 66 var result = evaluate_callback.globally( | |
| 67 exec_state, global_expression2, context_with_undefined); | |
| 68 assertEquals('cat/kitten', result); | |
| 69 | |
| 70 // Try in global scope with no overridden global variables. | |
| 71 var result = evaluate_callback.globally( | |
| 72 exec_state, global_expression2, void 0); | |
| 73 assertEquals('cat/undefined', result); | |
| 74 | |
| 75 // Try in global scope without additional context. | |
| 76 var global_expression3 = "'cat' + '/' + 'dog'"; | |
| 77 var result = evaluate_callback.globally( | |
| 78 exec_state, global_expression3, void 0); | |
| 79 assertEquals('cat/dog', result); | |
| 80 | |
| 81 listenerComplete = true; | |
| 82 } catch (e) { | |
| 83 exception = e | |
| 84 }; | |
| 85 }; | |
| 86 | |
| 87 | |
| 88 function f() { | |
| 89 var what_is_parrot = "a bird"; | |
| 90 debugger; | |
| 91 }; | |
| 92 | |
| 93 function runF() { | |
| 94 exception = false; | |
| 95 listenerComplete = false; | |
| 96 | |
| 97 Debug.setListener(listener); | |
| 98 | |
| 99 // Add the debug event listener. | |
| 100 Debug.setListener(listener); | |
| 101 | |
| 102 f(); | |
| 103 | |
| 104 assertFalse(exception, "exception in listener") | |
| 105 assertTrue(listenerComplete); | |
| 106 } | |
| 107 | |
| 108 evaluate_callback = { | |
| 109 in_top_frame: function(exec_state, expression, additional_context) { | |
| 110 return exec_state.frame(0).evaluate( | |
| 111 expression, void 0, additional_context).value(); | |
| 112 }, | |
| 113 globally: function(exec_state, expression, additional_context) { | |
| 114 return exec_state.evaluateGlobal( | |
| 115 expression, void 0, additional_context).value(); | |
| 116 }, | |
| 117 }; | |
| 118 | |
| 119 | |
| 120 runF(); | |
| OLD | NEW |