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

Side by Side Diff: test/inspector/debugger/get-possible-breakpoints.js

Issue 2465553003: [inspector] added Debugger.getPossibleBreakpoints method (Closed)
Patch Set: addressed comments Created 4 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4 // Flags: --expose-gc
5
6 print("Test for Debugger.getPossibleBreakpoints");
7
8 Protocol.Runtime.enable();
9 Protocol.Debugger.enable();
10
11 InspectorTest.runTestSuite([
12 function getPossibleBreakpointsInRange(next) {
13 var source = "function foo(){ return Promise.resolve(); }\nfunction boo(){ r eturn Promise.resolve().then(() => 42); }\n\n";
14 var scriptId;
15 compileScript(source)
16 .then(id => scriptId = id)
17 .then(() => InspectorTest.log("Test start.scriptId != end.scriptId."))
18 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber : 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 0, scriptId: scriptId + "0" }}))
19 .then(InspectorTest.logMessage)
20 .then(() => InspectorTest.log("Test not existing scriptId."))
21 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber : 0, columnNumber: 0, scriptId: "-1" }}))
22 .then(InspectorTest.logMessage)
23 .then(() => InspectorTest.log("Test end < start."))
24 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber : 1, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 0, scriptId: scriptId }}))
25 .then(InspectorTest.logMessage)
26 .then(() => InspectorTest.log("Test empty range in first line."))
27 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber : 0, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 16, scriptId: scriptId }}))
28 .then(InspectorTest.logMessage)
29 .then(() => InspectorTest.log("Test one character range in first line."))
30 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber : 0, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 17, scriptId: scriptId }}))
31 .then(InspectorTest.logMessage)
32 .then(() => InspectorTest.log("Test empty range in not first line."))
33 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber : 1, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 16, scriptId: scriptId }}))
34 .then(InspectorTest.logMessage)
35 .then(() => InspectorTest.log("Test one character range in not first line. "))
36 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber : 1, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 17, scriptId: scriptId }}))
37 .then(InspectorTest.logMessage)
38 .then(() => InspectorTest.log("Test end is undefined"))
39 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber : 0, columnNumber: 0, scriptId: scriptId }}))
40 .then(InspectorTest.logMessage)
41 .then(() => InspectorTest.log("Test end.lineNumber > scripts.lineCount()") )
42 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber : 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 5, columnNumber: 0, scriptId: scriptId }}))
43 .then(InspectorTest.logMessage)
44 .then(() => InspectorTest.log("Test one string"))
45 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber : 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 1, columnNumber: 0, scriptId: scriptId }}))
46 .then(InspectorTest.logMessage)
47 .then(() => InspectorTest.log("Test end.columnNumber > end.line.length(), should be the same as previous."))
48 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber : 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber: 256, scriptId: scriptId }}))
49 .then(InspectorTest.logMessage)
50 .then(next);
51 },
52
53 function getPossibleBreakpointsInArrow(next) {
54 var source = "function foo() { return Promise.resolve().then(() => 239).then (() => 42).then(() => () => 42) }";
55 var scriptId;
56 compileScript(source)
57 .then(id => scriptId = id)
58 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber : 0, columnNumber: 0, scriptId: scriptId }}))
59 .then(InspectorTest.logMessage)
60 .then(next);
61 },
62
63 function arrowFunctionFirstLine(next) {
64 Protocol.Debugger.onPaused(message => {
65 InspectorTest.log("paused in " + message.params.callFrames[0].functionName );
66 InspectorTest.logMessage(message.params.callFrames[0].location);
67 Protocol.Debugger.resume();
68 });
69
70 var source = `function foo1() { Promise.resolve().then(() => 42) }
71 function foo2() { Promise.resolve().then(() => 42) }`;
72 waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }, { lin eNumber: 1, columnNumber: 0 })
73 .then(InspectorTest.logMessage)
74 .then(setAllBreakpoints)
75 .then(() => Protocol.Runtime.evaluate({ expression: "foo1(); foo2()"}))
76 .then(next);
77 },
78
79 function arrowFunctionOnPause(next) {
80 function dumpAndResume(message) {
81 InspectorTest.log("paused in " + message.params.callFrames[0].functionName );
82 InspectorTest.logMessage(message.params.callFrames[0].location);
83 Protocol.Debugger.resume();
84 }
85
86 var source = `debugger; function foo3() { Promise.resolve().then(() => 42) }
87 function foo4() { Promise.resolve().then(() => 42) };\nfoo3();\nfoo4();`;
88 waitForPossibleBreakpointsOnPause(source, { lineNumber: 0, columnNumber: 0 } , undefined, next)
89 .then(InspectorTest.logMessage)
90 .then(setAllBreakpoints)
91 .then(() => Protocol.Debugger.onPaused(dumpAndResume))
92 .then(() => Protocol.Debugger.resume());
93 }
94
95 ]);
96
97 function compileScript(source) {
98 var promise = Protocol.Debugger.onceScriptParsed().then(message => message.par ams.scriptId);
99 Protocol.Runtime.compileScript({ expression: source, sourceURL: "", persistScr ipt: true });
100 return promise;
101 }
102
103 function waitForPossibleBreakpoints(source, start, end) {
104 var promise = Protocol.Debugger.onceScriptParsed()
105 .then(msg => { (start || {}).scriptId = msg.params.scriptId; (end || {}).scr iptId = msg.params.scriptId })
106 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: start, end: en d }));
107 Protocol.Runtime.evaluate({ expression: source });
108 return promise;
109 }
110
111 function waitForPossibleBreakpointsOnPause(source, start, end, next) {
112 var promise = Protocol.Debugger.oncePaused()
113 .then(msg => { (start || {}).scriptId = msg.params.callFrames[0].location.sc riptId; (end || {}).scriptId = msg.params.callFrames[0].location.scriptId })
114 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: start, end: en d }));
115 Protocol.Runtime.evaluate({ expression: source }).then(next);
116 return promise;
117 }
118
119 function setAllBreakpoints(message) {
120 var promises = [];
121 for (var location of message.result.locations)
122 promises.push(Protocol.Debugger.setBreakpoint({ location: location }).then(c heckBreakpointAndDump));
123 return Promise.all(promises);
124 }
125
126 function checkBreakpointAndDump(message) {
127 if (message.error) {
128 InspectorTest.log("FAIL: error in setBreakpoint");
129 InspectorTest.logMessage(message);
130 return;
131 }
132 var id_data = message.result.breakpointId.split(":");
133 if (parseInt(id_data[1]) !== message.result.actualLocation.lineNumber || parse Int(id_data[2]) !== message.result.actualLocation.columnNumber) {
134 InspectorTest.log("FAIL: possible breakpoint was resolved in another locatio n");
135 InspectorTest.logMessage(message);
136 }
137 InspectorTest.logMessage(message);
138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698