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

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)
106 {
107 var scriptId;
108 for (var prop of result.internalProperties) {
109 if (prop.name === "[[FunctionLocation]]")
110 scriptId = prop.value.value.scriptId;
111 }
112 return createScriptManipulationArc(scriptId, null);
113 }
114
115 // Several steps with scriptId in context.
110 function createScriptManipulationArc(scriptId, next) { 116 function createScriptManipulationArc(scriptId, next) {
111 return { command: "Debugger.getScriptSource", params: { scriptId: script Id }, callback: callbackGetScriptSource }; 117 return { command: "Debugger.getScriptSource", params: { scriptId: script Id }, callback: callbackGetScriptSource };
112 118
113 var originalText; 119 var originalText;
114 120
115 function callbackGetScriptSource(result) { 121 function callbackGetScriptSource(result) {
116 originalText = result.scriptSource; 122 originalText = result.scriptSource;
117 var patched = originalText.replace("a + b", "a * b"); 123 var patched = originalText.replace("a + b", "a * b");
118 124
119 return { command: "Debugger.setScriptSource", params: { scriptId: sc riptId, scriptSource: patched }, callback: callbackSetScriptSource }; 125 return { command: "Debugger.setScriptSource", params: { scriptId: sc riptId, scriptSource: patched }, callback: callbackSetScriptSource };
120 } 126 }
121 127
122 function callbackSetScriptSource(result) { 128 function callbackSetScriptSource(result) {
123 var expression = "TestExpression(2, 4)"; 129 var expression = "TestExpression(2, 4)";
124 return { command: "Runtime.evaluate", params: { expression: expressi on }, callback: callbackEvalFunction2 }; 130 return { command: "Runtime.evaluate", params: { expression: expressi on }, callback: callbackEvalFunction2 };
125 } 131 }
126 132
127 function callbackEvalFunction2(result) { 133 function callbackEvalFunction2(result) {
128 InspectorTest.log("Function evaluate: " + JSON.stringify(result.resu lt)); 134 InspectorTest.log("Function evaluate: " + JSON.stringify(result.resu lt));
129 logEqualsCheck(result.result.value, 8); 135 logEqualsCheck(result.result.value, 8);
130 136
131 var patched = originalText.replace("a + b", "a # b"); 137 var patched = originalText.replace("a + b", "a # b");
132 138
133 return { command: "Debugger.setScriptSource", params: { scriptId: sc riptId, scriptSource: patched }, callback: errorCallbackSetScriptSource2 }; 139 return { command: "Debugger.setScriptSource", params: { scriptId: sc riptId, scriptSource: patched }, callback: errorCallbackSetScriptSource2 };
134 } 140 }
135 141
136 function errorCallbackSetScriptSource2(result) { 142 function errorCallbackSetScriptSource2(result) {
137 var compileError = result.compileError; 143 var compileError = result.compileError;
138 logCheck("Has error reported", !!compileError); 144 logCheck("Has error reported", !!compileError);
139 logCheck("Reported error is a compile error", !!compileError); 145 logCheck("Reported error is a compile error", !!compileError);
140 if (compileError) { 146 if (compileError) {
141 logEqualsCheck(compileError.lineNumber, 2); 147 logEqualsCheck(compileError.lineNumber, 2);
142 } 148 }
143 return next; 149 return next;
144 } 150 }
145 } 151 }
146 } 152 }
147 </script> 153 </script>
148 </head> 154 </head>
149 <body onLoad="runTest();"> 155 <body onLoad="runTest();">
150 </body> 156 </body>
151 </html> 157 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698