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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector/sources/debugger-ui/script-snippet-model.html

Issue 1707043002: [DevTools] Support CommandLineAPI in snippets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector/sources/debugger-ui/script-snippet-model-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../../../http/tests/inspector/inspector-test.js"></script> 3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/debugger-test.js"></script> 4 <script src="../../../http/tests/inspector/debugger-test.js"></script>
5 <script> 5 <script>
6 function startWorker() 6 function startWorker()
7 { 7 {
8 var workerScript = "postMessage('Done.');"; 8 var workerScript = "postMessage('Done.');";
9 var blob = new Blob([workerScript], { type: "text/javascript" }); 9 var blob = new Blob([workerScript], { type: "text/javascript" });
10 var worker = new Worker(URL.createObjectURL(blob)); 10 var worker = new Worker(URL.createObjectURL(blob));
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 WebInspector.scriptSnippetModel.project().createFile("", nul l, "", step4.bind(this)); 140 WebInspector.scriptSnippetModel.project().createFile("", nul l, "", step4.bind(this));
141 } 141 }
142 } 142 }
143 143
144 function step4(uiSourceCode) 144 function step4(uiSourceCode)
145 { 145 {
146 var uiSourceCode3 = uiSourceCode; 146 var uiSourceCode3 = uiSourceCode;
147 InspectorTest.addResult("Snippet3 created."); 147 InspectorTest.addResult("Snippet3 created.");
148 WebInspector.scriptSnippetModel.project().deleteFile(uiSourceCod e3.url()); 148 WebInspector.scriptSnippetModel.project().deleteFile(uiSourceCod e3.url());
149 InspectorTest.addResult("Snippet3 deleted."); 149 InspectorTest.addResult("Snippet3 deleted.");
150 150
151 InspectorTest.addResult("Number of uiSourceCodes in workspace: " + workspace.uiSourceCodes().filter(filterSnippet).length); 151 InspectorTest.addResult("Number of uiSourceCodes in workspace: " + workspace.uiSourceCodes().filter(filterSnippet).length);
152 var storageSnippetsCount = WebInspector.scriptSnippetModel._snip petStorage.snippets().length; 152 var storageSnippetsCount = WebInspector.scriptSnippetModel._snip petStorage.snippets().length;
153 InspectorTest.addResult("Number of snippets in the storage: " + storageSnippetsCount); 153 InspectorTest.addResult("Number of snippets in the storage: " + storageSnippetsCount);
154 154
155 workspace.removeEventListener(WebInspector.Workspace.Events.UISo urceCodeAdded, uiSourceCodeAdded); 155 workspace.removeEventListener(WebInspector.Workspace.Events.UISo urceCodeAdded, uiSourceCodeAdded);
156 workspace.removeEventListener(WebInspector.Workspace.Events.UISo urceCodeRemoved, uiSourceCodeRemoved); 156 workspace.removeEventListener(WebInspector.Workspace.Events.UISo urceCodeRemoved, uiSourceCodeRemoved);
157 157
158 next(); 158 next();
159 } 159 }
160 }, 160 },
161 161
162 function testEvaluate(next) 162 function testEvaluate(next)
163 { 163 {
164 var uiSourceCode1; 164 var uiSourceCode1;
165 var uiSourceCode2; 165 var uiSourceCode2;
166 var uiSoruceCode3;
166 var context = WebInspector.context.flavor(WebInspector.ExecutionCont ext); 167 var context = WebInspector.context.flavor(WebInspector.ExecutionCont ext);
167 168
168 resetSnippetsSettings(); 169 resetSnippetsSettings();
169 var snippetScriptMapping = WebInspector.scriptSnippetModel.snippetSc riptMapping(WebInspector.targetManager.targets()[0]); 170 var snippetScriptMapping = WebInspector.scriptSnippetModel.snippetSc riptMapping(WebInspector.targetManager.targets()[0]);
170 171
171 WebInspector.scriptSnippetModel.project().createFile("", null, "", s tep2.bind(this)); 172 WebInspector.scriptSnippetModel.project().createFile("", null, "", s tep2.bind(this));
172 173
173 function step2(uiSourceCode) 174 function step2(uiSourceCode)
174 { 175 {
175 uiSourceCode1 = uiSourceCode; 176 uiSourceCode1 = uiSourceCode;
176 uiSourceCode1.rename("Snippet1", function() { }); 177 uiSourceCode1.rename("Snippet1", function() { });
177 var content = ""; 178 var content = "";
178 content += "// This snippet does nothing.\n"; 179 content += "// This snippet does nothing.\n";
179 content += "var i = 2+2;\n"; 180 content += "var i = 2+2;\n";
180 uiSourceCode1.setWorkingCopy(content); 181 uiSourceCode1.setWorkingCopy(content);
181 WebInspector.scriptSnippetModel.project().createFile("", null, " ", step3.bind(this)); 182 WebInspector.scriptSnippetModel.project().createFile("", null, " ", step3.bind(this));
182 } 183 }
183 184
184 function step3(uiSourceCode) 185 function step3(uiSourceCode)
185 { 186 {
186 uiSourceCode2 = uiSourceCode; 187 uiSourceCode2 = uiSourceCode;
187 uiSourceCode2.rename("Snippet2", function() { }); 188 uiSourceCode2.rename("Snippet2", function() { });
188 content = ""; 189 content = "";
189 content += "// This snippet creates a function that does nothing and returns it.\n"; 190 content += "// This snippet creates a function that does nothing and returns it.\n";
190 content += "function doesNothing() {\n"; 191 content += "function doesNothing() {\n";
191 content += " var i = 2+2;\n"; 192 content += " var i = 2+2;\n";
192 content += "};\n"; 193 content += "};\n";
193 content += "doesNothing;\n"; 194 content += "doesNothing;\n";
194 uiSourceCode2.setWorkingCopy(content); 195 uiSourceCode2.setWorkingCopy(content);
195 evaluateSnippetAndDumpEvaluationDetails(uiSourceCode1, context, step4); 196 WebInspector.scriptSnippetModel.project().createFile("", null, " ", step4.bind(this));
196 } 197 }
197 198
198 function step4() 199 function step4(uiSourceCode)
199 { 200 {
200 evaluateSnippetAndDumpEvaluationDetails(uiSourceCode2, context, step5); 201 uiSourceCode3 = uiSourceCode;
202 uiSourceCode3.rename("Snippet3", function() { });
203 content = "";
204 content += "// This snippet uses Command Line API.\n";
205 content += "$$(\"p\").length";
206 uiSourceCode3.setWorkingCopy(content);
207 evaluateSnippetAndDumpEvaluationDetails(uiSourceCode1, context, step5);
201 } 208 }
202 209
203 function step5() 210 function step5()
204 { 211 {
205 evaluateSnippetAndDumpEvaluationDetails(uiSourceCode1, context, next); 212 evaluateSnippetAndDumpEvaluationDetails(uiSourceCode2, context, step6);
213 }
214
215 function step6()
216 {
217 evaluateSnippetAndDumpEvaluationDetails(uiSourceCode1, context, step7);
218 }
219
220 function step7()
221 {
222 evaluateSnippetAndDumpEvaluationDetails(uiSourceCode3, context, next);
206 } 223 }
207 }, 224 },
208 225
209 function testEvaluateEditReload(next) 226 function testEvaluateEditReload(next)
210 { 227 {
211 function evaluateSnippetAndReloadPage(uiSourceCode, callback) 228 function evaluateSnippetAndReloadPage(uiSourceCode, callback)
212 { 229 {
213 InspectorTest.addSniffer(WebInspector.ScriptSnippetModel.prototy pe, "_printRunScriptResult", snippetFinished); 230 InspectorTest.addSniffer(WebInspector.ScriptSnippetModel.prototy pe, "_printRunScriptResult", snippetFinished);
214 WebInspector.scriptSnippetModel.evaluateScriptSnippet(WebInspect or.context.flavor(WebInspector.ExecutionContext), uiSourceCode); 231 WebInspector.scriptSnippetModel.evaluateScriptSnippet(WebInspect or.context.flavor(WebInspector.ExecutionContext), uiSourceCode);
215 232
216 function snippetFinished(result, wasThrown) 233 function snippetFinished(result, wasThrown)
217 { 234 {
218 var script = snippetScriptMapping._scriptForUISourceCode.get (uiSourceCode); 235 var script = snippetScriptMapping._scriptForUISourceCode.get (uiSourceCode);
219 InspectorTest.addResult("Snippet execution result: " + resul t.description); 236 InspectorTest.addResult("Snippet execution result: " + resul t.description);
220 237
221 InspectorTest.reloadPage(callback) 238 InspectorTest.reloadPage(callback)
222 } 239 }
223 } 240 }
224 241
225 resetSnippetsSettings(); 242 resetSnippetsSettings();
226 var snippetScriptMapping = WebInspector.scriptSnippetModel.snippetSc riptMapping(WebInspector.targetManager.targets()[0]); 243 var snippetScriptMapping = WebInspector.scriptSnippetModel.snippetSc riptMapping(WebInspector.targetManager.targets()[0]);
227 244
228 WebInspector.scriptSnippetModel.project().createFile("", null, "", s tep3.bind(this)); 245 WebInspector.scriptSnippetModel.project().createFile("", null, "", s tep3.bind(this));
229 246
230 function step3(uiSourceCode) 247 function step3(uiSourceCode)
231 { 248 {
232 var uiSourceCode1 = uiSourceCode; 249 var uiSourceCode1 = uiSourceCode;
233 uiSourceCode1.rename("Snippet1", function() { }); 250 uiSourceCode1.rename("Snippet1", function() { });
234 var content = ""; 251 var content = "";
235 content += "// This snippet does nothing.\n"; 252 content += "// This snippet does nothing.\n";
236 content += "var i = 2+2;\n"; 253 content += "var i = 2+2;\n";
237 uiSourceCode1.setWorkingCopy(content); 254 uiSourceCode1.setWorkingCopy(content);
238 255
239 evaluateSnippetAndReloadPage(uiSourceCode1, next); 256 evaluateSnippetAndReloadPage(uiSourceCode1, next);
(...skipping 25 matching lines...) Expand all
265 } 282 }
266 }, 283 },
267 ]); 284 ]);
268 }; 285 };
269 </script> 286 </script>
270 </head> 287 </head>
271 <body onload="runTest()"> 288 <body onload="runTest()">
272 <p>Tests script snippet model.</p> 289 <p>Tests script snippet model.</p>
273 </body> 290 </body>
274 </html> 291 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector/sources/debugger-ui/script-snippet-model-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698