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

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

Issue 391413003: DevTools: [Timeline] extract common infrastructure from tracing tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: syntax error was fixed Created 6 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 | 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 3
4 Redistribution and use in source and binary forms, with or without 4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions 5 modification, are permitted provided that the following conditions
6 are met: 6 are met:
7 7
8 1. Redistributions of source code must retain the above copyright 8 1. Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer. 9 notice, this list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright 10 2. Redistributions in binary form must reproduce the above copyright
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 */ 46 */
47 InspectorTest.sendCommand = function(method, params, handler) 47 InspectorTest.sendCommand = function(method, params, handler)
48 { 48 {
49 this._dispatchTable[++this._requestId] = handler; 49 this._dispatchTable[++this._requestId] = handler;
50 50
51 var messageObject = { "method": method, 51 var messageObject = { "method": method,
52 "params": params, 52 "params": params,
53 "id": this._requestId }; 53 "id": this._requestId };
54 54
55 if (InspectorTest._dumpInspectorProtocolMessages) 55 if (InspectorTest._dumpInspectorProtocolMessages)
56 testRunner.logToStderr("backend: " + JSON.stringify(messageObject)); 56 testRunner.logToStderr("frontend: " + JSON.stringify(messageObject));
57 InspectorFrontendHost.sendMessageToBackend(JSON.stringify(messageObject)); 57 InspectorFrontendHost.sendMessageToBackend(JSON.stringify(messageObject));
58 58
59 return this._requestId; 59 return this._requestId;
60 } 60 }
61 61
62 InspectorTest.sendCommandOrDie = function(command, properties, callback) 62 InspectorTest.sendCommandOrDie = function(command, properties, callback)
63 { 63 {
64 InspectorTest.sendCommand(command, properties || {}, commandCallback); 64 InspectorTest.sendCommand(command, properties || {}, commandCallback);
65 function commandCallback(msg) 65 function commandCallback(msg)
66 { 66 {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 InspectorFrontendHost.sendMessageToBackend(command); 134 InspectorFrontendHost.sendMessageToBackend(command);
135 return this._requestId; 135 return this._requestId;
136 } 136 }
137 137
138 /** 138 /**
139 * @param {string} message 139 * @param {string} message
140 */ 140 */
141 InspectorFrontendAPI.dispatchMessage = function(message) 141 InspectorFrontendAPI.dispatchMessage = function(message)
142 { 142 {
143 if (InspectorTest._dumpInspectorProtocolMessages) 143 if (InspectorTest._dumpInspectorProtocolMessages)
144 testRunner.logToStderr("frontend: " + message); 144 testRunner.logToStderr("backend: " + message);
145 var messageObject = JSON.parse(message); 145 var messageObject = JSON.parse(message);
146 var messageId = messageObject["id"]; 146 var messageId = messageObject["id"];
147 try { 147 try {
148 if (typeof messageId === "number") { 148 if (typeof messageId === "number") {
149 var handler = InspectorTest._dispatchTable[messageId]; 149 var handler = InspectorTest._dispatchTable[messageId];
150 if (handler && typeof handler === "function") 150 if (handler && typeof handler === "function")
151 handler(messageObject); 151 handler(messageObject);
152 } else { 152 } else {
153 var eventName = messageObject["method"]; 153 var eventName = messageObject["method"];
154 var eventHandler = InspectorTest.eventHandler[eventName]; 154 var eventHandler = InspectorTest.eventHandler[eventName];
155 if (eventHandler) 155 if (eventHandler)
156 eventHandler(messageObject); 156 eventHandler(messageObject);
157 } 157 }
158 } catch(e) { 158 } catch(e) {
159 InspectorTest.log("Exception when dispatching message: " + e + "\n\n mes sage = " + JSON.stringify(messageObject, null, 2)); 159 InspectorTest.log("Exception when dispatching message: " + e + "\n" + e. stack + "\n message = " + JSON.stringify(messageObject, null, 2));
160 InspectorTest.completeTest(); 160 InspectorTest.completeTest();
161 } 161 }
162 } 162 }
163 163
164 /** 164 /**
165 * Logs message to document. 165 * Logs message to document.
166 * @param {string} message 166 * @param {string} message
167 */ 167 */
168 InspectorTest.log = function(message) 168 InspectorTest.log = function(message)
169 { 169 {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 InspectorTest.completeTest = function() 236 InspectorTest.completeTest = function()
237 { 237 {
238 this.sendCommand("Runtime.evaluate", { "expression": "closeTest();"} ); 238 this.sendCommand("Runtime.evaluate", { "expression": "closeTest();"} );
239 } 239 }
240 240
241 /** 241 /**
242 * Evaluates string in page. 242 * Evaluates string in page.
243 * @param {string} message 243 * @param {string} message
244 * @param {!function} callback 244 * @param {!function} callback
245 */ 245 */
246 InspectorTest.executeInPage = function(string, callback) 246 InspectorTest.evaluateInPage = function(string, callback)
247 { 247 {
248 this.sendCommand("Runtime.evaluate", { "expression": string }, function(mess age) { 248 this.sendCommand("Runtime.evaluate", { "expression": string }, function(mess age) {
249 if (message.error) 249 if (message.error)
250 InspectorTest.log("Error while executing '" + string + "': " + messa ge.error.message); 250 InspectorTest.log("Error while executing '" + string + "': " + messa ge.error.message);
251 else 251 else
252 callback(); 252 callback();
253 }); 253 });
254 }; 254 };
255 255
256 InspectorTest.completeTestIfError = function(messageObject) 256 InspectorTest.completeTestIfError = function(messageObject)
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 function enableInspectorAgent() 317 function enableInspectorAgent()
318 { 318 {
319 InspectorTest.sendCommand("Inspector.enable", { }); 319 InspectorTest.sendCommand("Inspector.enable", { });
320 } 320 }
321 321
322 window.addEventListener("load", enableInspectorAgent, false); 322 window.addEventListener("load", enableInspectorAgent, false);
323 323
324 </script> 324 </script>
325 </head> 325 </head>
326 </html> 326 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698