OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 print('Checks that breaks in framework code correctly processed.'); |
| 6 |
| 7 InspectorTest.addScript( |
| 8 ` |
| 9 function frameworkAssert() { |
| 10 console.assert(false); |
| 11 } |
| 12 |
| 13 function throwCaughtError() { |
| 14 try { |
| 15 throw new Error(); |
| 16 } catch (e) { |
| 17 } |
| 18 } |
| 19 |
| 20 function throwUncaughtError() { |
| 21 throw new Error(); |
| 22 } |
| 23 |
| 24 function breakpoint() { |
| 25 return 239; |
| 26 } |
| 27 |
| 28 function debuggerStatement() { |
| 29 debugger; |
| 30 } |
| 31 |
| 32 function syncDOMBreakpoint() { |
| 33 breakProgram('', ''); |
| 34 } |
| 35 |
| 36 function asyncDOMBreakpoint() { |
| 37 return 42; |
| 38 } |
| 39 |
| 40 function throwCaughtSyntaxError() { |
| 41 try { |
| 42 eval('}'); |
| 43 } catch (e) { |
| 44 } |
| 45 } |
| 46 |
| 47 function throwFromJSONParse() { |
| 48 try { |
| 49 JSON.parse('ping'); |
| 50 } catch (e) { |
| 51 } |
| 52 } |
| 53 |
| 54 //# sourceURL=framework.js`, |
| 55 7, 26); |
| 56 |
| 57 InspectorTest.setupScriptMap(); |
| 58 Protocol.Debugger.onPaused(message => { |
| 59 InspectorTest.logCallFrames(message.params.callFrames); |
| 60 InspectorTest.log(''); |
| 61 Protocol.Debugger.resume(); |
| 62 }); |
| 63 |
| 64 Protocol.Debugger.enable(); |
| 65 Protocol.Debugger.setBlackboxPatterns({patterns: ['framework\.js']}); |
| 66 |
| 67 InspectorTest.runTestSuite([ |
| 68 function testConsoleAssert(next) { |
| 69 Protocol.Debugger.setPauseOnExceptions({state: 'all'}) |
| 70 .then(() => InspectorTest.log('> all frames in framework:')) |
| 71 .then( |
| 72 () => Protocol.Runtime.evaluate( |
| 73 {expression: 'frameworkAssert()//# sourceURL=framework.js'})) |
| 74 .then(() => InspectorTest.log('> mixed, top frame in framework:')) |
| 75 .then( |
| 76 () => Protocol.Runtime.evaluate( |
| 77 {expression: 'frameworkAssert()//# sourceURL=user.js'})) |
| 78 .then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'})) |
| 79 .then(next); |
| 80 }, |
| 81 |
| 82 function testCaughtException(next) { |
| 83 Protocol.Debugger.setPauseOnExceptions({state: 'all'}) |
| 84 .then(() => InspectorTest.log('> all frames in framework:')) |
| 85 .then( |
| 86 () => Protocol.Runtime.evaluate( |
| 87 {expression: 'throwCaughtError()//# sourceURL=framework.js'})) |
| 88 .then(() => InspectorTest.log('> mixed, top frame in framework:')) |
| 89 .then( |
| 90 () => Protocol.Runtime.evaluate( |
| 91 {expression: 'throwCaughtError()//# sourceURL=user.js'})) |
| 92 .then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'})) |
| 93 .then(next); |
| 94 }, |
| 95 |
| 96 function testUncaughtException(next) { |
| 97 Protocol.Debugger.setPauseOnExceptions({state: 'all'}) |
| 98 .then(() => InspectorTest.log('> all frames in framework:')) |
| 99 .then( |
| 100 () => Protocol.Runtime.evaluate( |
| 101 {expression: 'throwUncaughtError()//# sourceURL=framework.js'})) |
| 102 .then(() => InspectorTest.log('> mixed, top frame in framework:')) |
| 103 .then( |
| 104 () => Protocol.Runtime.evaluate( |
| 105 {expression: 'throwUncaughtError()//# sourceURL=user.js'})) |
| 106 .then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'})) |
| 107 .then(next); |
| 108 }, |
| 109 |
| 110 function testBreakpoint(next) { |
| 111 Protocol.Debugger.setBreakpointByUrl({lineNumber: 24, url: 'framework.js'}) |
| 112 .then(() => InspectorTest.log('> all frames in framework:')) |
| 113 .then( |
| 114 () => Protocol.Runtime.evaluate( |
| 115 {expression: 'breakpoint()//# sourceURL=framework.js'})) |
| 116 .then(() => InspectorTest.log('> mixed, top frame in framework:')) |
| 117 .then( |
| 118 () => Protocol.Runtime.evaluate( |
| 119 {expression: 'breakpoint()//# sourceURL=user.js'})) |
| 120 .then(next); |
| 121 }, |
| 122 |
| 123 function testDebuggerStatement(next) { |
| 124 InspectorTest.log('> all frames in framework:'); |
| 125 Protocol.Runtime |
| 126 .evaluate({expression: 'debuggerStatement()//# sourceURL=framework.js'}) |
| 127 .then(() => InspectorTest.log('> mixed, top frame in framework:')) |
| 128 .then( |
| 129 () => Protocol.Runtime.evaluate( |
| 130 {expression: 'debuggerStatement()//# sourceURL=user.js'})) |
| 131 .then(next); |
| 132 }, |
| 133 |
| 134 function testSyncDOMBreakpoint(next) { |
| 135 InspectorTest.log('> all frames in framework:'); |
| 136 Protocol.Runtime |
| 137 .evaluate({expression: 'syncDOMBreakpoint()//# sourceURL=framework.js'}) |
| 138 .then(() => InspectorTest.log('> mixed, top frame in framework:')) |
| 139 .then( |
| 140 () => Protocol.Runtime.evaluate( |
| 141 {expression: 'syncDOMBreakpoint()//# sourceURL=user.js'})) |
| 142 .then(next); |
| 143 }, |
| 144 |
| 145 function testAsyncDOMBreakpoint(next) { |
| 146 schedulePauseOnNextStatement('', ''); |
| 147 InspectorTest.log('> all frames in framework:'); |
| 148 Protocol.Runtime |
| 149 .evaluate( |
| 150 {expression: 'asyncDOMBreakpoint()//# sourceURL=framework.js'}) |
| 151 .then(() => cancelPauseOnNextStatement()) |
| 152 .then( |
| 153 () => Protocol.Runtime.evaluate( |
| 154 {expression: '42//# sourceURL=user.js'})) |
| 155 .then(() => schedulePauseOnNextStatement('', '')) |
| 156 .then( |
| 157 () => Protocol.Runtime.evaluate( |
| 158 {expression: 'asyncDOMBreakpoint()//# sourceURL=user.js'})) |
| 159 .then(next); |
| 160 }, |
| 161 |
| 162 function testCaughtSyntaxError(next) { |
| 163 Protocol.Debugger.setPauseOnExceptions({state: 'all'}) |
| 164 .then(() => InspectorTest.log('> all frames in framework:')) |
| 165 .then(() => Protocol.Runtime.evaluate({ |
| 166 expression: 'throwCaughtSyntaxError()//# sourceURL=framework.js' |
| 167 })) |
| 168 .then(() => InspectorTest.log('> mixed, top frame in framework:')) |
| 169 .then( |
| 170 () => Protocol.Runtime.evaluate( |
| 171 {expression: 'throwCaughtSyntaxError()//# sourceURL=user.js'})) |
| 172 .then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'})) |
| 173 .then(next); |
| 174 }, |
| 175 |
| 176 function testCaughtJSONParseError(next) { |
| 177 Protocol.Debugger.setPauseOnExceptions({state: 'all'}) |
| 178 .then(() => InspectorTest.log('> all frames in framework:')) |
| 179 .then( |
| 180 () => Protocol.Runtime.evaluate( |
| 181 {expression: 'throwFromJSONParse()//# sourceURL=framework.js'})) |
| 182 .then(() => InspectorTest.log('> mixed, top frame in framework:')) |
| 183 .then( |
| 184 () => Protocol.Runtime.evaluate( |
| 185 {expression: 'throwFromJSONParse()//# sourceURL=user.js'})) |
| 186 .then(() => Protocol.Debugger.setPauseOnExceptions({state: 'none'})) |
| 187 .then(next); |
| 188 } |
| 189 ]); |
OLD | NEW |