Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 // Flags: --expose-debug-as debug | 28 // Flags: --expose-debug-as debug --nocrankshaft |
| 29 | |
| 30 // Get the Debug object exposed from the debug context global object. | 29 // Get the Debug object exposed from the debug context global object. |
| 31 Debug = debug.Debug | 30 Debug = debug.Debug |
| 32 | 31 |
| 33 var exception = null; | 32 var exception = null; |
| 34 var state = 1; | 33 var state = 1; |
| 35 var expected_source_line_text = null; | |
| 36 var expected_function_name = null; | |
| 37 | 34 |
| 38 // Simple debug event handler which first time will cause 'step in' action | 35 // Simple debug event handler which first time will cause 'step in' action |
| 39 // and than check that execution is paused inside function | 36 // to get into g.call and than check that execution is stopped inside |
| 40 // expected_function_name. | 37 // function 'g'. |
| 41 function listener(event, exec_state, event_data, data) { | 38 function listener(event, exec_state, event_data, data) { |
| 42 try { | 39 try { |
| 43 if (event == Debug.DebugEvent.Break) { | 40 if (event == Debug.DebugEvent.Break) { |
| 44 if (state == 1) { | 41 if (state == 1) { |
| 45 exec_state.prepareStep(Debug.StepAction.StepIn, 2); | 42 exec_state.prepareStep(Debug.StepAction.StepIn, 3); |
| 46 state = 2; | 43 state = 2; |
| 47 } else if (state == 2) { | 44 } else if (state == 2) { |
| 48 assertEquals(expected_function_name, event_data.func().name()); | 45 assertTrue(event_data.sourceLineText().indexOf("Expected to step") > 0, "source line: \"" + event_data.sourceLineText() + "\""); |
|
Yang
2014/09/24 12:16:29
80 char limit
aandrey
2014/09/24 13:16:06
Done.
| |
| 49 assertEquals(expected_source_line_text, | |
| 50 event_data.sourceLineText()); | |
| 51 state = 3; | 46 state = 3; |
| 52 } | 47 } |
| 53 } | 48 } |
| 54 } catch(e) { | 49 } catch(e) { |
| 50 print("Exception: " + e); | |
| 55 exception = e; | 51 exception = e; |
| 56 } | 52 } |
| 57 }; | 53 }; |
| 58 | 54 |
| 59 // Add the debug event listener. | 55 // Add the debug event listener. |
| 60 Debug.setListener(listener); | 56 Debug.setListener(listener); |
| 61 | 57 |
| 62 var a = [1,2,3,4,5]; | 58 var count = 0; |
| 59 var obj = { | |
| 60 fun: function() { | |
| 61 ++count; | |
| 62 return count; // Expected to step | |
| 63 } | |
| 64 }; | |
| 65 obj.fun2 = obj.fun; | |
| 63 | 66 |
| 64 // Test step into function call from a function without local variables. | 67 function testCall_Dots() { |
| 65 function testStepInArraySlice() { | |
| 66 expected_function_name = 'testStepInArraySlice'; | |
| 67 expected_source_line_text = '} // expected line'; | |
| 68 debugger; | 68 debugger; |
| 69 var s = Array.prototype.slice.call(a, 2,3); | 69 obj.fun(); |
| 70 } // expected line | 70 } |
| 71 | 71 |
| 72 state = 1; | 72 function testCall_Quotes() { |
| 73 testStepInArraySlice(); | 73 debugger; |
| 74 assertNull(exception); | 74 obj["fun"](); |
| 75 assertEquals(3, state); | 75 } |
| 76 | |
| 77 function testCall_Call() { | |
| 78 debugger; | |
| 79 obj.fun.call(obj); | |
| 80 } | |
| 81 | |
| 82 function testCall_Apply() { | |
| 83 debugger; | |
| 84 obj.fun.apply(obj); | |
| 85 } | |
| 86 | |
| 87 function testCall_Variable() { | |
| 88 var functionName = "fun"; | |
| 89 debugger; | |
| 90 obj[functionName](); | |
| 91 } | |
| 92 | |
| 93 function testCall_Fun2() { | |
| 94 debugger; | |
| 95 obj.fun2(); | |
| 96 } | |
| 97 | |
| 98 function testCall_InternStrings() { | |
| 99 var cache = { "fun": "fun" }; | |
| 100 var functionName = "fu" + "n"; | |
| 101 debugger; | |
| 102 obj[cache[functionName]](); | |
| 103 } | |
| 104 | |
| 105 function testCall_ViaFunRef() { | |
| 106 var functionName = "fu" + "n"; | |
| 107 var funRef = obj[functionName]; | |
| 108 debugger; | |
| 109 funRef(); | |
| 110 } | |
| 111 | |
| 112 // bug 2888 | |
| 113 function testCall_RuntimeVariable1() { | |
| 114 var functionName = "fu" + "n"; | |
| 115 debugger; | |
| 116 obj[functionName](); | |
| 117 } | |
| 118 | |
| 119 // bug 2888 | |
| 120 function testCall_RuntimeVariable2() { | |
| 121 var functionName = "un".replace(/u/, "fu"); | |
| 122 debugger; | |
| 123 obj[functionName](); | |
| 124 } | |
| 125 | |
| 126 // bug 2888 | |
| 127 function testCall_RuntimeVariable3() { | |
| 128 var expr = "fu" + "n"; | |
| 129 const functionName = expr; | |
| 130 assertEquals("fun", functionName); | |
| 131 debugger; | |
| 132 obj[functionName](); | |
| 133 } | |
| 134 | |
| 135 var functionsCalled = 0; | |
| 136 for (var n in this) { | |
| 137 if (n.substr(0, 4) != 'test' || typeof this[n] !== "function") { | |
| 138 continue; | |
| 139 } | |
| 140 state = 1; | |
| 141 print("Running " + n + "..."); | |
| 142 this[n](); | |
| 143 ++functionsCalled; | |
| 144 assertNull(exception, n); | |
| 145 assertEquals(3, state, n); | |
| 146 assertEquals(functionsCalled, count, n); | |
| 147 } | |
| 148 | |
| 149 assertEquals(11, functionsCalled); | |
| 76 | 150 |
| 77 // Get rid of the debug event listener. | 151 // Get rid of the debug event listener. |
| 78 Debug.setListener(null); | 152 Debug.setListener(null); |
| OLD | NEW |