Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: test/inspector/debugger/stepping-with-blackboxed-ranges.js

Issue 2390733002: [inspector] Make InspectorTest.sendCommand* private (Closed)
Patch Set: addressed comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 InspectorTest.evaluateInPage( 5 InspectorTest.addScript(
6 `function blackboxedBoo() 6 `function blackboxedBoo()
7 { 7 {
8 var a = 42; 8 var a = 42;
9 var b = foo(); 9 var b = foo();
10 return a + b; 10 return a + b;
11 } 11 }
12 //# sourceURL=blackboxed-script.js`); 12 //# sourceURL=blackboxed-script.js`);
13 13
14 InspectorTest.evaluateInPage( 14 InspectorTest.addScript(
15 `function notBlackboxedFoo() 15 `function notBlackboxedFoo()
16 { 16 {
17 var a = 42; 17 var a = 42;
18 var b = blackboxedBoo(); 18 var b = blackboxedBoo();
19 return a + b; 19 return a + b;
20 } 20 }
21 21
22 function blackboxedFoo() 22 function blackboxedFoo()
23 { 23 {
24 var a = 42; 24 var a = 42;
25 var b = notBlackboxedFoo(); 25 var b = notBlackboxedFoo();
26 return a + b; 26 return a + b;
27 } 27 }
28 28
29 function notBlackboxedBoo() 29 function notBlackboxedBoo()
30 { 30 {
31 var a = 42; 31 var a = 42;
32 var b = blackboxedFoo(); 32 var b = blackboxedFoo();
33 return a + b; 33 return a + b;
34 } 34 }
35 //# sourceURL=mixed-source.js`); 35 //# sourceURL=mixed-source.js`);
36 36
37 InspectorTest.evaluateInPage( 37 InspectorTest.addScript(
38 `function testFunction() 38 `function testFunction()
39 { 39 {
40 notBlackboxedBoo(); // for setup ranges and stepOut 40 notBlackboxedBoo(); // for setup ranges and stepOut
41 notBlackboxedBoo(); // for stepIn 41 notBlackboxedBoo(); // for stepIn
42 } 42 }
43 43
44 function foo() 44 function foo()
45 { 45 {
46 debugger; 46 debugger;
47 return 239; 47 return 239;
48 }`); 48 }`);
49 49
50 InspectorTest.eventHandler["Debugger.paused"] = setBlackboxedScriptRanges; 50 Protocol.Debugger.oncePaused().then(setBlackboxedScriptRanges);
51 InspectorTest.sendCommandOrDie("Debugger.enable", {}, callTestFunction); 51 Protocol.Debugger.enable().then(callTestFunction);
52 52
53 function callTestFunction(response) 53 function callTestFunction(response)
54 { 54 {
55 InspectorTest.sendCommand("Runtime.evaluate", { expression: "setTimeout(testFu nction, 0);"}); 55 Protocol.Runtime.evaluate({ expression: "setTimeout(testFunction, 0);"});
56 } 56 }
57 57
58 function setBlackboxedScriptRanges(response) 58 function setBlackboxedScriptRanges(response)
59 { 59 {
60 var callFrames = response.params.callFrames; 60 var callFrames = response.params.callFrames;
61 printCallFrames(callFrames); 61 printCallFrames(callFrames);
62 InspectorTest.sendCommand("Debugger.setBlackboxedRanges", { 62 Protocol.Debugger.setBlackboxedRanges({
63 scriptId: callFrames[1].location.scriptId, 63 scriptId: callFrames[1].location.scriptId,
64 positions: [ { lineNumber: 0, columnNumber: 0 } ] // blackbox ranges for bla ckboxed.js 64 positions: [ { lineNumber: 0, columnNumber: 0 } ] // blackbox ranges for bla ckboxed.js
65 }, setIncorrectRanges.bind(null, callFrames[2].location.scriptId)); 65 }).then(setIncorrectRanges.bind(null, callFrames[2].location.scriptId));
66 } 66 }
67 67
68 var incorrectPositions = [ 68 var incorrectPositions = [
69 [ { lineNumber: 0, columnNumber: 0 }, { lineNumber: 0, columnNumber: 0 } ], 69 [ { lineNumber: 0, columnNumber: 0 }, { lineNumber: 0, columnNumber: 0 } ],
70 [ { lineNumber: 0, columnNumber: 1 }, { lineNumber: 0, columnNumber: 0 } ], 70 [ { lineNumber: 0, columnNumber: 1 }, { lineNumber: 0, columnNumber: 0 } ],
71 [ { lineNumber: 0, columnNumber: -1 } ], 71 [ { lineNumber: 0, columnNumber: -1 } ],
72 ]; 72 ];
73 73
74 function setIncorrectRanges(scriptId, response) 74 function setIncorrectRanges(scriptId, response)
75 { 75 {
76 if (response.error) 76 if (response.error)
77 InspectorTest.log(response.error.message); 77 InspectorTest.log(response.error.message);
78 var positions = incorrectPositions.shift(); 78 var positions = incorrectPositions.shift();
79 if (!positions) { 79 if (!positions) {
80 setMixedSourceRanges(scriptId); 80 setMixedSourceRanges(scriptId);
81 return; 81 return;
82 } 82 }
83 InspectorTest.log("Try to set positions: " + JSON.stringify(positions)); 83 InspectorTest.log("Try to set positions: " + JSON.stringify(positions));
84 InspectorTest.sendCommand("Debugger.setBlackboxedRanges", { 84 Protocol.Debugger.setBlackboxedRanges({
85 scriptId: scriptId, 85 scriptId: scriptId,
86 positions: positions 86 positions: positions
87 }, setIncorrectRanges.bind(null, scriptId)); 87 }).then(setIncorrectRanges.bind(null, scriptId));
88 } 88 }
89 89
90 function setMixedSourceRanges(scriptId) 90 function setMixedSourceRanges(scriptId)
91 { 91 {
92 InspectorTest.eventHandler["Debugger.paused"] = runAction; 92 Protocol.Debugger.onPaused(runAction);
93 InspectorTest.sendCommandOrDie("Debugger.setBlackboxedRanges", { 93 Protocol.Debugger.setBlackboxedRanges({
94 scriptId: scriptId, 94 scriptId: scriptId,
95 positions: [ { lineNumber: 8, columnNumber: 0 }, { lineNumber: 15, columnNum ber: 0 } ] // blackbox ranges for mixed.js 95 positions: [ { lineNumber: 8, columnNumber: 0 }, { lineNumber: 15, columnNum ber: 0 } ] // blackbox ranges for mixed.js
96 }, runAction); 96 }).then(runAction);
97 } 97 }
98 98
99 var actions = [ "stepOut", "print", "stepOut", "print", "stepOut", "print", 99 var actions = [ "stepOut", "print", "stepOut", "print", "stepOut", "print",
100 "stepInto", "print", "stepOver", "stepInto", "print", "stepOver", "stepInto" , "print", 100 "stepInto", "print", "stepOver", "stepInto", "print", "stepOver", "stepInto" , "print",
101 "stepOver", "stepInto", "print" ]; 101 "stepOver", "stepInto", "print" ];
102 102
103 function runAction(response) 103 function runAction(response)
104 { 104 {
105 var action = actions.shift(); 105 var action = actions.shift();
106 if (!action) 106 if (!action)
107 InspectorTest.completeTest(); 107 InspectorTest.completeTest();
108 108
109 if (action === "print") { 109 if (action === "print") {
110 printCallFrames(response.params.callFrames); 110 printCallFrames(response.params.callFrames);
111 runAction({}); 111 runAction({});
112 } else { 112 } else {
113 InspectorTest.log("action: " + action); 113 InspectorTest.log("action: " + action);
114 InspectorTest.sendCommandOrDie("Debugger." + action, {}); 114 Protocol.Debugger[action]();
115 } 115 }
116 } 116 }
117 117
118 function printCallFrames(callFrames) 118 function printCallFrames(callFrames)
119 { 119 {
120 var topCallFrame = callFrames[0]; 120 var topCallFrame = callFrames[0];
121 if (topCallFrame.functionName.startsWith("blackboxed")) 121 if (topCallFrame.functionName.startsWith("blackboxed"))
122 InspectorTest.log("FAIL: blackboxed function in top call frame"); 122 InspectorTest.log("FAIL: blackboxed function in top call frame");
123 for (var callFrame of callFrames) 123 for (var callFrame of callFrames)
124 InspectorTest.log(callFrame.functionName + ": " + callFrame.location.lineNum ber + ":" + callFrame.location.columnNumber); 124 InspectorTest.log(callFrame.functionName + ": " + callFrame.location.lineNum ber + ":" + callFrame.location.columnNumber);
125 InspectorTest.log(""); 125 InspectorTest.log("");
126 } 126 }
OLDNEW
« no previous file with comments | « test/inspector/debugger/step-over-caught-exception.js ('k') | test/inspector/debugger/update-call-frame-scopes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698