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

Side by Side Diff: LayoutTests/http/tests/inspector-protocol/inspector-protocol-test.js

Issue 177963004: DevTools: Split creating inspector stylesheet and adding a new rule into stylesheet in protocol. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Comments addressed Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Samsung Electronics. All rights reserved. 2 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 var messageObject = { "method": method, 45 var messageObject = { "method": method,
46 "params": params, 46 "params": params,
47 "id": this._requestId }; 47 "id": this._requestId };
48 48
49 InspectorFrontendHost.sendMessageToBackend(JSON.stringify(messageObject)); 49 InspectorFrontendHost.sendMessageToBackend(JSON.stringify(messageObject));
50 50
51 return this._requestId; 51 return this._requestId;
52 } 52 }
53 53
54 InspectorTest.sendCommandOrDie = function(command, properties, callback)
55 {
56 InspectorTest.sendCommand(command, properties || {}, commandCallback);
57 function commandCallback(msg)
58 {
59 if (msg.error) {
60 InspectorTest.log("ERROR: " + msg.error.message);
61 InspectorTest.completeTest();
62 return;
63 }
64 if (callback)
65 callback(msg.result);
66 }
67 }
68
54 /** 69 /**
55 * @param {function(object)=} callback 70 * @param {function(object)=} callback
56 */ 71 */
57 InspectorTest.wrapCallback = function(callback) 72 InspectorTest.wrapCallback = function(callback)
58 { 73 {
59 /** 74 /**
60 * @param {object} message 75 * @param {object} message
61 */ 76 */
62 function callbackWrapper(message) 77 function callbackWrapper(message)
63 { 78 {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 * @param {string} scriptName 239 * @param {string} scriptName
225 */ 240 */
226 InspectorTest.importScript = function(scriptName) 241 InspectorTest.importScript = function(scriptName)
227 { 242 {
228 var xhr = new XMLHttpRequest(); 243 var xhr = new XMLHttpRequest();
229 xhr.open("GET", scriptName, false); 244 xhr.open("GET", scriptName, false);
230 xhr.send(null); 245 xhr.send(null);
231 window.eval(xhr.responseText + "\n//@ sourceURL=" + scriptName); 246 window.eval(xhr.responseText + "\n//@ sourceURL=" + scriptName);
232 } 247 }
233 248
249 InspectorTest.requestMainFrameId = function(callback)
250 {
251 InspectorTest.sendCommandOrDie("Page.enable", {}, pageEnabled);
252
253 function pageEnabled()
254 {
255 InspectorTest.sendCommandOrDie("Page.getResourceTree", {}, resourceTreeL oaded);
256 }
257
258 function resourceTreeLoaded(payload)
259 {
260 callback(payload.frameTree.frame.id);
261 }
262 };
263
264 InspectorTest.requestDocumentNodeId = function(callback)
265 {
266 InspectorTest.sendCommandOrDie("DOM.getDocument", {}, onGotDocument);
267
268 function onGotDocument(result)
269 {
270 callback(result.root.nodeId);
271 }
272 };
273
274 InspectorTest.requestNodeId = function(selector, callback)
275 {
276 InspectorTest.requestDocumentNodeId(onGotDocumentNodeId);
277
278 function onGotDocumentNodeId(documentNodeId)
279 {
280 InspectorTest.sendCommandOrDie("DOM.querySelector", { "nodeId": document NodeId , "selector": selector }, onGotNode);
281 }
282
283 function onGotNode(result)
284 {
285 callback(result.nodeId);
286 }
287 };
288
234 }; 289 };
235 290
236 var outputElement; 291 var outputElement;
237 292
238 /** 293 /**
239 * Logs message to process stdout via alert (hopefully implemented with immediat e flush). 294 * Logs message to process stdout via alert (hopefully implemented with immediat e flush).
240 * @param {string} text 295 * @param {string} text
241 */ 296 */
242 function debugLog(text) 297 function debugLog(text)
243 { 298 {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 initializers += "(" + window[symbol].toString() + ")();\n"; 370 initializers += "(" + window[symbol].toString() + ")();\n";
316 } 371 }
317 inspectorFrontend.postMessage(initializers + "(" + testFunction.toSt ring() +")();", "*"); 372 inspectorFrontend.postMessage(initializers + "(" + testFunction.toSt ring() +")();", "*");
318 return; 373 return;
319 } 374 }
320 // Kill waiting process if failed to send. 375 // Kill waiting process if failed to send.
321 alert("Failed to send test function"); 376 alert("Failed to send test function");
322 testRunner.notifyDone(); 377 testRunner.notifyDone();
323 }); 378 });
324 } 379 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698