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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/debugger/setScriptSource.html

Issue 2122423002: [DevTools] Remove functionDetails from protocol.json (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-generator-details-from-protocol
Patch Set: a Created 4 years, 5 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 <html> 1 <html>
2 <head> 2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto r-protocol-test.js"></script> 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto r-protocol-test.js"></script>
4 <script type="text/javascript" src="resources/liveedit-me.js"></script> 4 <script type="text/javascript" src="resources/liveedit-me.js"></script>
5 <script> 5 <script>
6 6
7 function test() 7 function test()
8 { 8 {
9 // A general-purpose engine for sending a sequence of protocol commands. 9 // A general-purpose engine for sending a sequence of protocol commands.
10 // The clients provide requests and response handlers, while the engine catc hes 10 // The clients provide requests and response handlers, while the engine catc hes
11 // errors and makes sure that once there's nothing to do completeTest() is c alled. 11 // errors and makes sure that once there's nothing to do completeTest() is c alled.
12 // @param step is an object with command, params and callback fields 12 // @param step is an object with command, params and callback fields
13 function runRequestSeries(step) { 13 function runRequestSeries(step) {
14 processStep(step); 14 processStep(step);
15 15
16 function processStep(currentStep) { 16 function processStep(currentStep) {
17 try { 17 try {
18 processStepOrFail(currentStep); 18 processStepOrFail(currentStep);
19 } catch (e) { 19 } catch (e) {
20 InspectorTest.log(e.stack); 20 InspectorTest.log(e.stack);
21 InspectorTest.completeTest(); 21 InspectorTest.completeTest();
22 } 22 }
23 } 23 }
24 24
25 function processStepOrFail(currentStep) { 25 function processStepOrFail(currentStep) {
26 if (!currentStep) { 26 if (!currentStep) {
27 InspectorTest.completeTest(); 27 InspectorTest.completeTest();
28 return; 28 return;
29 } 29 }
30 if (!currentStep.command) { 30 if (!currentStep.command) {
31 // A simple loopback step. 31 // A simple loopback step.
32 var next = currentStep.callback(); 32 var next = currentStep.callback();
33 processStep(next); 33 processStep(next);
34 return; 34 return;
(...skipping 22 matching lines...) Expand all
57 InspectorTest.log(e.stack); 57 InspectorTest.log(e.stack);
58 InspectorTest.completeTest(); 58 InspectorTest.completeTest();
59 return; 59 return;
60 } 60 }
61 } 61 }
62 processStep(next); 62 processStep(next);
63 } 63 }
64 InspectorTest.sendCommand(currentStep.command, currentStep.params, i nnerCallback); 64 InspectorTest.sendCommand(currentStep.command, currentStep.params, i nnerCallback);
65 } 65 }
66 } 66 }
67 67
68 function logEqualsCheck(actual, expected) 68 function logEqualsCheck(actual, expected)
69 { 69 {
70 if (actual == expected) { 70 if (actual == expected) {
71 InspectorTest.log("PASS, result value: " + actual); 71 InspectorTest.log("PASS, result value: " + actual);
72 } else { 72 } else {
73 InspectorTest.log("FAIL, actual value: " + actual + ", expected: " + expected); 73 InspectorTest.log("FAIL, actual value: " + actual + ", expected: " + expected);
74 } 74 }
75 } 75 }
76 function logCheck(description, success) 76 function logCheck(description, success)
77 { 77 {
78 InspectorTest.log(description + ": " + (success ? "PASS" : "FAIL")); 78 InspectorTest.log(description + ": " + (success ? "PASS" : "FAIL"));
79 } 79 }
80 80
81 var firstStep = { callback: enableDebugger }; 81 var firstStep = { callback: enableDebugger };
82 82
83 runRequestSeries(firstStep); 83 runRequestSeries(firstStep);
84 84
85 function enableDebugger() { 85 function enableDebugger() {
86 return { command: "Debugger.enable", params: {}, callback: evalFunction }; 86 return { command: "Debugger.enable", params: {}, callback: evalFunction };
87 } 87 }
88 88
89 function evalFunction(response) { 89 function evalFunction(response) {
90 var expression = "TestExpression(2, 4)"; 90 var expression = "TestExpression(2, 4)";
91 return { command: "Runtime.evaluate", params: { expression: expression } , callback: callbackEvalFunction }; 91 return { command: "Runtime.evaluate", params: { expression: expression } , callback: callbackEvalFunction };
92 } 92 }
93 93
94 function callbackEvalFunction(result) { 94 function callbackEvalFunction(result) {
95 InspectorTest.log("Function evaluate: " + JSON.stringify(result.result)) ; 95 InspectorTest.log("Function evaluate: " + JSON.stringify(result.result)) ;
96 logEqualsCheck(result.result.value, 6); 96 logEqualsCheck(result.result.value, 6);
97 97
98 return { command: "Runtime.evaluate", params: { expression: "TestExpress ion" }, callback: callbackEvalFunctionObject }; 98 return { command: "Runtime.evaluate", params: { expression: "TestExpress ion" }, callback: callbackEvalFunctionObject };
99 } 99 }
100 100
101 function callbackEvalFunctionObject(result) { 101 function callbackEvalFunctionObject(result) {
102 return { command: "Debugger.getFunctionDetails", params: { functionId: r esult.result.objectId }, callback: callbackFunctionDetails }; 102 return { command: "Runtime.getProperties", params: { objectId: result.re sult.objectId }, callback: callbackFunctionDetails };
103 }
104
105 function callbackFunctionDetails(result) {
106 return createScriptManipulationArc(result.details.location.scriptId, nul l);
107 } 103 }
108 104
109 // Several steps with scriptId in context. 105 function callbackFunctionDetails(result) {
dgozman 2016/07/07 19:59:23 style: { on next line
kozy 2016/07/07 22:59:07 Done.
106 var scriptId;
107 for (var prop of result.internalProperties) {
108 if (prop.name === "[[FunctionLocation]]")
109 scriptId = prop.value.value.scriptId;
110 }
111 return createScriptManipulationArc(scriptId, null);
112 }
113
114 // Several steps with scriptId in context.
110 function createScriptManipulationArc(scriptId, next) { 115 function createScriptManipulationArc(scriptId, next) {
111 return { command: "Debugger.getScriptSource", params: { scriptId: script Id }, callback: callbackGetScriptSource }; 116 return { command: "Debugger.getScriptSource", params: { scriptId: script Id }, callback: callbackGetScriptSource };
112 117
113 var originalText; 118 var originalText;
114 119
115 function callbackGetScriptSource(result) { 120 function callbackGetScriptSource(result) {
116 originalText = result.scriptSource; 121 originalText = result.scriptSource;
117 var patched = originalText.replace("a + b", "a * b"); 122 var patched = originalText.replace("a + b", "a * b");
118 123
119 return { command: "Debugger.setScriptSource", params: { scriptId: sc riptId, scriptSource: patched }, callback: callbackSetScriptSource }; 124 return { command: "Debugger.setScriptSource", params: { scriptId: sc riptId, scriptSource: patched }, callback: callbackSetScriptSource };
120 } 125 }
121 126
122 function callbackSetScriptSource(result) { 127 function callbackSetScriptSource(result) {
123 var expression = "TestExpression(2, 4)"; 128 var expression = "TestExpression(2, 4)";
124 return { command: "Runtime.evaluate", params: { expression: expressi on }, callback: callbackEvalFunction2 }; 129 return { command: "Runtime.evaluate", params: { expression: expressi on }, callback: callbackEvalFunction2 };
125 } 130 }
126 131
127 function callbackEvalFunction2(result) { 132 function callbackEvalFunction2(result) {
128 InspectorTest.log("Function evaluate: " + JSON.stringify(result.resu lt)); 133 InspectorTest.log("Function evaluate: " + JSON.stringify(result.resu lt));
129 logEqualsCheck(result.result.value, 8); 134 logEqualsCheck(result.result.value, 8);
130 135
131 var patched = originalText.replace("a + b", "a # b"); 136 var patched = originalText.replace("a + b", "a # b");
132 137
133 return { command: "Debugger.setScriptSource", params: { scriptId: sc riptId, scriptSource: patched }, callback: errorCallbackSetScriptSource2 }; 138 return { command: "Debugger.setScriptSource", params: { scriptId: sc riptId, scriptSource: patched }, callback: errorCallbackSetScriptSource2 };
134 } 139 }
135 140
136 function errorCallbackSetScriptSource2(result) { 141 function errorCallbackSetScriptSource2(result) {
137 var compileError = result.compileError; 142 var compileError = result.compileError;
138 logCheck("Has error reported", !!compileError); 143 logCheck("Has error reported", !!compileError);
139 logCheck("Reported error is a compile error", !!compileError); 144 logCheck("Reported error is a compile error", !!compileError);
140 if (compileError) { 145 if (compileError) {
141 logEqualsCheck(compileError.lineNumber, 2); 146 logEqualsCheck(compileError.lineNumber, 2);
142 } 147 }
143 return next; 148 return next;
144 } 149 }
145 } 150 }
146 } 151 }
147 </script> 152 </script>
148 </head> 153 </head>
149 <body onLoad="runTest();"> 154 <body onLoad="runTest();">
150 </body> 155 </body>
151 </html> 156 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698