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

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

Issue 340803002: DevTools: fix for test inspector-protocol/page/enable-disable.html (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: race was removed Created 6 years, 6 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 13 matching lines...) Expand all
24 --> 24 -->
25 <html> 25 <html>
26 <head> 26 <head>
27 <script> 27 <script>
28 28
29 InspectorFrontendAPI = {}; 29 InspectorFrontendAPI = {};
30 30
31 InspectorTest = {}; 31 InspectorTest = {};
32 InspectorTest._dispatchTable = []; 32 InspectorTest._dispatchTable = [];
33 InspectorTest._requestId = -1; 33 InspectorTest._requestId = -1;
34 InspectorTest._dumpInspectorProtocolMessages = false;
34 InspectorTest.eventHandler = {}; 35 InspectorTest.eventHandler = {};
35 36
37 InspectorTest.startDumpingProtocolMessages = function()
38 {
39 InspectorTest._dumpInspectorProtocolMessages = true;
40 }
41
36 /** 42 /**
37 * @param {string} method 43 * @param {string} method
38 * @param {object} params 44 * @param {object} params
39 * @param {function({object} messageObject)=} handler 45 * @param {function({object} messageObject)=} handler
40 */ 46 */
41 InspectorTest.sendCommand = function(method, params, handler) 47 InspectorTest.sendCommand = function(method, params, handler)
42 { 48 {
43 this._dispatchTable[++this._requestId] = handler; 49 this._dispatchTable[++this._requestId] = handler;
44 50
45 var messageObject = { "method": method, 51 var messageObject = { "method": method,
46 "params": params, 52 "params": params,
47 "id": this._requestId }; 53 "id": this._requestId };
48 54
55 if (InspectorTest._dumpInspectorProtocolMessages)
56 testRunner.logToStderr(JSON.stringify(messageObject, ""));
49 InspectorFrontendHost.sendMessageToBackend(JSON.stringify(messageObject)); 57 InspectorFrontendHost.sendMessageToBackend(JSON.stringify(messageObject));
50 58
51 return this._requestId; 59 return this._requestId;
52 } 60 }
53 61
54 InspectorTest.sendCommandOrDie = function(command, properties, callback) 62 InspectorTest.sendCommandOrDie = function(command, properties, callback)
55 { 63 {
56 InspectorTest.sendCommand(command, properties || {}, commandCallback); 64 InspectorTest.sendCommand(command, properties || {}, commandCallback);
57 function commandCallback(msg) 65 function commandCallback(msg)
58 { 66 {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 InspectorFrontendHost.sendMessageToBackend(command); 134 InspectorFrontendHost.sendMessageToBackend(command);
127 return this._requestId; 135 return this._requestId;
128 } 136 }
129 137
130 /** 138 /**
131 * @param {string} message 139 * @param {string} message
132 */ 140 */
133 InspectorFrontendAPI.dispatchMessage = function(message) 141 InspectorFrontendAPI.dispatchMessage = function(message)
134 { 142 {
135 var messageObject = JSON.parse(message); 143 var messageObject = JSON.parse(message);
144 if (InspectorTest._dumpInspectorProtocolMessages)
145 testRunner.logToStderr(JSON.stringify(messageObject, ""));
136 var messageId = messageObject["id"]; 146 var messageId = messageObject["id"];
137 try { 147 try {
138 if (typeof messageId === "number") { 148 if (typeof messageId === "number") {
139 var handler = InspectorTest._dispatchTable[messageId]; 149 var handler = InspectorTest._dispatchTable[messageId];
140 if (handler && typeof handler === "function") 150 if (handler && typeof handler === "function")
141 handler(messageObject); 151 handler(messageObject);
142 } else { 152 } else {
143 var eventName = messageObject["method"]; 153 var eventName = messageObject["method"];
144 var eventHandler = InspectorTest.eventHandler[eventName]; 154 var eventHandler = InspectorTest.eventHandler[eventName];
145 if (eventHandler) 155 if (eventHandler)
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 function enableInspectorAgent() 317 function enableInspectorAgent()
308 { 318 {
309 InspectorTest.sendCommand("Inspector.enable", { }); 319 InspectorTest.sendCommand("Inspector.enable", { });
310 } 320 }
311 321
312 window.addEventListener("load", enableInspectorAgent, false); 322 window.addEventListener("load", enableInspectorAgent, false);
313 323
314 </script> 324 </script>
315 </head> 325 </head>
316 </html> 326 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698