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

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
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);
dgozman 2016/02/17 23:47:43 Bring this one back.
kozy 2016/02/18 00:27:33 Done.
213 }
214
215 function step6()
216 {
217 evaluateSnippetAndDumpEvaluationDetails(uiSourceCode3, context, next);
206 } 218 }
207 }, 219 },
208 220
209 function testEvaluateEditReload(next) 221 function testEvaluateEditReload(next)
210 { 222 {
211 function evaluateSnippetAndReloadPage(uiSourceCode, callback) 223 function evaluateSnippetAndReloadPage(uiSourceCode, callback)
212 { 224 {
213 InspectorTest.addSniffer(WebInspector.ScriptSnippetModel.prototy pe, "_printRunScriptResult", snippetFinished); 225 InspectorTest.addSniffer(WebInspector.ScriptSnippetModel.prototy pe, "_printRunScriptResult", snippetFinished);
214 WebInspector.scriptSnippetModel.evaluateScriptSnippet(WebInspect or.context.flavor(WebInspector.ExecutionContext), uiSourceCode); 226 WebInspector.scriptSnippetModel.evaluateScriptSnippet(WebInspect or.context.flavor(WebInspector.ExecutionContext), uiSourceCode);
215 227
216 function snippetFinished(result, wasThrown) 228 function snippetFinished(result, wasThrown)
217 { 229 {
218 var script = snippetScriptMapping._scriptForUISourceCode.get (uiSourceCode); 230 var script = snippetScriptMapping._scriptForUISourceCode.get (uiSourceCode);
219 InspectorTest.addResult("Snippet execution result: " + resul t.description); 231 InspectorTest.addResult("Snippet execution result: " + resul t.description);
220 232
221 InspectorTest.reloadPage(callback) 233 InspectorTest.reloadPage(callback)
222 } 234 }
223 } 235 }
224 236
225 resetSnippetsSettings(); 237 resetSnippetsSettings();
226 var snippetScriptMapping = WebInspector.scriptSnippetModel.snippetSc riptMapping(WebInspector.targetManager.targets()[0]); 238 var snippetScriptMapping = WebInspector.scriptSnippetModel.snippetSc riptMapping(WebInspector.targetManager.targets()[0]);
227 239
228 WebInspector.scriptSnippetModel.project().createFile("", null, "", s tep3.bind(this)); 240 WebInspector.scriptSnippetModel.project().createFile("", null, "", s tep3.bind(this));
229 241
230 function step3(uiSourceCode) 242 function step3(uiSourceCode)
231 { 243 {
232 var uiSourceCode1 = uiSourceCode; 244 var uiSourceCode1 = uiSourceCode;
233 uiSourceCode1.rename("Snippet1", function() { }); 245 uiSourceCode1.rename("Snippet1", function() { });
234 var content = ""; 246 var content = "";
235 content += "// This snippet does nothing.\n"; 247 content += "// This snippet does nothing.\n";
236 content += "var i = 2+2;\n"; 248 content += "var i = 2+2;\n";
237 uiSourceCode1.setWorkingCopy(content); 249 uiSourceCode1.setWorkingCopy(content);
238 250
239 evaluateSnippetAndReloadPage(uiSourceCode1, next); 251 evaluateSnippetAndReloadPage(uiSourceCode1, next);
(...skipping 25 matching lines...) Expand all
265 } 277 }
266 }, 278 },
267 ]); 279 ]);
268 }; 280 };
269 </script> 281 </script>
270 </head> 282 </head>
271 <body onload="runTest()"> 283 <body onload="runTest()">
272 <p>Tests script snippet model.</p> 284 <p>Tests script snippet model.</p>
273 </body> 285 </body>
274 </html> 286 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698