Chromium Code Reviews| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 | 51 |
| 52 function createPoint(x, y) { | 52 function createPoint(x, y) { |
| 53 return new Point(x, y); | 53 return new Point(x, y); |
| 54 } | 54 } |
| 55 | 55 |
| 56 a=[1,2,distance]; | 56 a=[1,2,distance]; |
| 57 | 57 |
| 58 // Get the Debug object exposed from the debug context global object. | 58 // Get the Debug object exposed from the debug context global object. |
| 59 Debug = debug.Debug | 59 Debug = debug.Debug |
| 60 | 60 |
| 61 testConstructor = false; // Flag to control which part of the test is run. | 61 what = 'constructor'; // Flag to control which part of the test is run. |
| 62 listenerCalled = false; | 62 listenerCalled = false; |
| 63 exception = false; | 63 exception = false; |
| 64 | 64 |
| 65 function safeEval(code) { | 65 function safeEval(code) { |
| 66 try { | 66 try { |
| 67 return eval('(' + code + ')'); | 67 return eval('(' + code + ')'); |
| 68 } catch (e) { | 68 } catch (e) { |
| 69 return undefined; | 69 return undefined; |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 function listener(event, exec_state, event_data, data) { | 73 function listener(event, exec_state, event_data, data) { |
| 74 try { | 74 try { |
| 75 if (event == Debug.DebugEvent.Break) | 75 if (event == Debug.DebugEvent.Break) { |
| 76 { | 76 if (what == 'constructor') { |
| 77 if (!testConstructor) { | 77 // The expected backtrace is |
| 78 // The expected backtrace is | 78 // 0: Call distance on Point where distance is a property on the prototy pe |
|
Yang
2016/07/06 05:39:29
Since you already did the work below, how about al
| |
| 79 // 0: Call distance on Point where distance is a property on the prototype | 79 // 1: Call distance on Point where distance is a direct property |
| 80 // 1: Call distance on Point where distance is a direct property | 80 // 2: Call on function an array element 2 |
| 81 // 2: Call on function an array element 2 | 81 // 3: [anonymous] |
| 82 // 3: [anonymous] | 82 assertEquals("#<Point>.distanceTo(p=#<Point>)", |
| 83 assertEquals("#<Point>.distanceTo(p=#<Point>)", exec_state.frame(0).invoca tionText()); | 83 exec_state.frame(0).invocationText()); |
| 84 assertEquals("#<Point>.distanceTo(p=#<Point>)", exec_state.frame(1).invoca tionText()); | 84 assertEquals("#<Point>.distanceTo(p=#<Point>)", |
| 85 assertEquals("#<Array>[2](aka distance)(p=#<Point>, q=#<Point>)", exec_sta te.frame(2).invocationText()); | 85 exec_state.frame(1).invocationText()); |
| 86 assertEquals("[anonymous]()", exec_state.frame(3).invocationText()); | 86 assertEquals("#<Array>[2](aka distance)(p=#<Point>, q=#<Point>)", |
| 87 listenerCalled = true; | 87 exec_state.frame(2).invocationText()); |
| 88 } else { | 88 assertEquals("[anonymous]()", exec_state.frame(3).invocationText()); |
| 89 // The expected backtrace is | 89 listenerCalled = true; |
| 90 // 0: Call Point constructor | 90 } else if (what == 'breakpoint') { |
| 91 // 1: Call on global function createPoint | 91 // The expected backtrace is |
| 92 // 2: [anonymous] | 92 // 0: Call Point constructor |
| 93 assertEquals("new Point(x=0, y=0)", exec_state.frame(0).invocationText()); | 93 // 1: Call on global function createPoint |
| 94 assertEquals("createPoint(x=0, y=0)", exec_state.frame(1).invocationText() ); | 94 // 2: [anonymous] |
| 95 assertEquals("[anonymous]()", exec_state.frame(2).invocationText()); | 95 assertEquals("new Point(x=0, y=0)", |
| 96 listenerCalled = true; | 96 exec_state.frame(0).invocationText()); |
| 97 assertEquals("createPoint(x=0, y=0)", | |
| 98 exec_state.frame(1).invocationText()); | |
| 99 assertEquals("[anonymous]()", exec_state.frame(2).invocationText()); | |
| 100 listenerCalled = true; | |
| 101 } else if (what == 'symbol') { | |
| 102 // The expected backtrace is | |
| 103 // 0: Call Point constructor | |
| 104 // 1: Call on symbol method | |
| 105 // 2: [anonymous] | |
| 106 assertEquals("new Point(x=0, y=0)", | |
| 107 exec_state.frame(0).invocationText()); | |
| 108 assertEquals("#<Object>[Symbol(Das Symbol)](x=0, y=0)", | |
| 109 exec_state.frame(1).invocationText()); | |
| 110 assertEquals("[anonymous]()", exec_state.frame(2).invocationText()); | |
| 111 listenerCalled = true; | |
| 112 } else { | |
| 113 assertUnreachable(); | |
| 114 } | |
| 97 } | 115 } |
| 98 } | |
| 99 } catch (e) { | 116 } catch (e) { |
| 100 exception = e | 117 exception = e |
| 101 }; | 118 }; |
| 102 }; | 119 }; |
| 103 | 120 |
| 104 // Add the debug event listener. | 121 // Add the debug event listener. |
| 105 Debug.setListener(listener); | 122 Debug.setListener(listener); |
| 106 | 123 |
| 107 // Set a break point and call to invoke the debug event listener. | 124 // Set a break point and call to invoke the debug event listener. |
| 108 a[2](p1, p2) | 125 a[2](p1, p2) |
| 109 | 126 |
| 110 // Make sure that the debug event listener vas invoked. | 127 // Make sure that the debug event listener vas invoked. |
| 111 assertTrue(listenerCalled); | 128 assertTrue(listenerCalled); |
| 112 assertFalse(exception, "exception in listener") | 129 assertFalse(exception, "exception in listener") |
| 113 | 130 |
| 114 // Set a break point and call to invoke the debug event listener. | 131 // Set a break point and call to invoke the debug event listener. |
| 132 what = 'breakpoint'; | |
| 115 listenerCalled = false; | 133 listenerCalled = false; |
| 116 testConstructor = true; | |
| 117 Debug.setBreakPoint(Point, 0, 0); | 134 Debug.setBreakPoint(Point, 0, 0); |
| 118 createPoint(0, 0); | 135 createPoint(0, 0); |
| 119 | 136 |
| 120 // Make sure that the debug event listener vas invoked (again). | 137 // Make sure that the debug event listener vas invoked (again). |
| 121 assertTrue(listenerCalled); | 138 assertTrue(listenerCalled); |
| 122 assertFalse(exception, "exception in listener") | 139 assertFalse(exception, "exception in listener") |
| 140 | |
| 141 what = 'symbol'; | |
| 142 listenerCalled = false; | |
| 143 var S = Symbol('Das Symbol'); | |
| 144 var o = { [S](x, y) { return new Point(x, y); } }; | |
| 145 Debug.setBreakPoint(Point, 0, 0); | |
| 146 o[S](0, 0); | |
| 147 | |
| 148 assertTrue(listenerCalled); | |
| 149 assertFalse(exception, "exception in listener") | |
| OLD | NEW |