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

Side by Side Diff: chrome/tools/test/reference_build/chrome_linux/resources/inspector/devtools_host_stub.js

Issue 177049: On Linux, move the passing of filedescriptors to a dedicated socketpair(). (Closed)
Patch Set: Removed *.d files from reference build Created 11 years, 3 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 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview These stubs emulate backend functionality and allows 6 * @fileoverview These stubs emulate backend functionality and allows
7 * DevTools frontend to function as a standalone web app. 7 * DevTools frontend to function as a standalone web app.
8 */ 8 */
9 9
10 /** 10 /**
11 * @constructor 11 * @constructor
12 */ 12 */
13 RemoteDebuggerAgentStub = function() { 13 RemoteDebuggerAgentStub = function() {
14 this.activeProfilerModules_ =
15 devtools.DebuggerAgent.ProfilerModules.PROFILER_MODULE_NONE;
16 this.profileLogPos_ = 0;
17 this.heapProfSample_ = 0;
18 this.heapProfLog_ = '';
14 }; 19 };
15 20
21
16 RemoteDebuggerAgentStub.prototype.DebugBreak = function() { 22 RemoteDebuggerAgentStub.prototype.DebugBreak = function() {
17 }; 23 };
18 24
25
19 RemoteDebuggerAgentStub.prototype.GetContextId = function() { 26 RemoteDebuggerAgentStub.prototype.GetContextId = function() {
20 RemoteDebuggerAgent.DidGetContextId(3); 27 RemoteDebuggerAgent.SetContextId(3);
21 };
22
23 RemoteDebuggerAgentStub.prototype.StopProfiling = function() {
24 };
25
26 RemoteDebuggerAgentStub.prototype.StartProfiling = function() {
27 };
28
29 RemoteDebuggerAgentStub.prototype.IsProfilingStarted = function() {
30 setTimeout(function() {
31 RemoteDebuggerAgent.DidIsProfilingStarted(true);
32 }, 100);
33 };
34
35 RemoteDebuggerAgentStub.prototype.GetLogLines = function(pos) {
36 if (pos < RemoteDebuggerAgentStub.ProfilerLogBuffer.length) {
37 setTimeout(function() {
38 RemoteDebuggerAgent.DidGetLogLines(
39 RemoteDebuggerAgentStub.ProfilerLogBuffer,
40 pos + RemoteDebuggerAgentStub.ProfilerLogBuffer.length);
41 },
42 100);
43 } else {
44 setTimeout(function() { RemoteDebuggerAgent.DidGetLogLines('', pos); }, 100) ;
45 }
46 };
47
48 /**
49 * @constructor
50 */
51 RemoteDomAgentStub = function() {
52 }; 28 };
53 29
54 30
55 RemoteDomAgentStub.sendDocumentElement_ = function() { 31 RemoteDebuggerAgentStub.prototype.StopProfiling = function(modules) {
56 RemoteDomAgent.SetDocumentElement([ 32 this.activeProfilerModules_ &= ~modules;
57 1, // id
58 1, // type = Node.ELEMENT_NODE,
59 'HTML', // nodeName
60 '', // nodeValue
61 ['foo','bar'], // attributes
62 2, // childNodeCount
63 ]);
64 }; 33 };
65 34
66 35
67 RemoteDomAgentStub.sendChildNodes_ = function(id) { 36 RemoteDebuggerAgentStub.prototype.StartProfiling = function(modules) {
68 if (id == 1) { 37 var profModules = devtools.DebuggerAgent.ProfilerModules;
69 RemoteDomAgent.SetChildNodes(id, 38 if (modules & profModules.PROFILER_MODULE_HEAP_SNAPSHOT) {
70 [ 39 if (modules & profModules.PROFILER_MODULE_HEAP_STATS) {
71 [ 40 this.heapProfLog_ +=
72 2, // id 41 'heap-sample-begin,"Heap","allocated",' +
73 1, // type = Node.ELEMENT_NODE, 42 (new Date()).getTime() + '\n' +
74 'DIV', // nodeName 43 'heap-sample-stats,"Heap","allocated",10000,1000\n';
75 '', // nodeValue 44 this.heapProfLog_ +=
76 ['foo','bar'], // attributes 45 'heap-sample-item,STRING_TYPE,100,1000\n' +
77 1, // childNodeCount 46 'heap-sample-item,CODE_TYPE,10,200\n' +
78 ], 47 'heap-sample-item,MAP_TYPE,20,350\n';
79 [ 48 var sample = RemoteDebuggerAgentStub.HeapSamples[this.heapProfSample_];
80 3, // id 49 if (++this.heapProfSample_ == RemoteDebuggerAgentStub.HeapSamples.length)
81 3, // type = Node.TEXT_NODE, 50 this.heapProfSample_ = 0;
82 '', // nodeName 51 for (var obj in sample) {
83 'Text', // nodeValue 52 this.heapProfLog_ +=
84 ] 53 'heap-js-cons-item,"' + obj + '",' + sample[obj][0] +
85 ]); 54 ',' + sample[obj][1] + '\n';
86 } else if (id == 2) { 55 }
87 RemoteDomAgent.SetChildNodes(id, 56 this.heapProfLog_ +=
88 [ 57 'heap-sample-end,"Heap","allocated"\n';
89 [ 58 }
90 4, // id 59 } else {
91 1, // type = Node.ELEMENT_NODE, 60 this.activeProfilerModules_ |= modules;
92 'span', // nodeName
93 '', // nodeValue
94 ['foo','bar'], // attributes
95 0, // childNodeCount
96 ]
97 ]);
98 } 61 }
99 }; 62 };
100 63
101 64
102 RemoteDomAgentStub.prototype.GetDocumentElement = function(callId) { 65 RemoteDebuggerAgentStub.prototype.GetActiveProfilerModules = function() {
66 var self = this;
103 setTimeout(function() { 67 setTimeout(function() {
104 RemoteDomAgentStub.sendDocumentElement_(); 68 RemoteDebuggerAgent.DidGetActiveProfilerModules(
105 }, 0); 69 self.activeProfilerModules_);
70 }, 100);
106 }; 71 };
107 72
108 73
109 RemoteDomAgentStub.prototype.GetChildNodes = function(callId, id) { 74 RemoteDebuggerAgentStub.prototype.GetNextLogLines = function() {
75 var profModules = devtools.DebuggerAgent.ProfilerModules;
76 var logLines = '';
77 if (this.activeProfilerModules_ & profModules.PROFILER_MODULE_CPU) {
78 if (this.profileLogPos_ < RemoteDebuggerAgentStub.ProfilerLogBuffer.length) {
79 this.profileLogPos_ += RemoteDebuggerAgentStub.ProfilerLogBuffer.length;
80 logLines += RemoteDebuggerAgentStub.ProfilerLogBuffer;
81 }
82 }
83 if (this.heapProfLog_) {
84 logLines += this.heapProfLog_;
85 this.heapProfLog_ = '';
86 }
110 setTimeout(function() { 87 setTimeout(function() {
111 RemoteDomAgentStub.sendChildNodes_(id); 88 RemoteDebuggerAgent.DidGetNextLogLines(logLines);
112 RemoteDomAgent.DidGetChildNodes(callId); 89 }, 100);
113 }, 0);
114 }; 90 };
115 91
116 92
117 RemoteDomAgentStub.prototype.SetAttribute = function(callId) {
118 setTimeout(function() {
119 RemoteDomAgent.DidApplyDomChange(callId, true);
120 }, 0);
121 };
122
123
124 RemoteDomAgentStub.prototype.RemoveAttribute = function(callId) {
125 setTimeout(function() {
126 RemoteDomAgent.DidApplyDomChange(callId, true);
127 }, 0);
128 };
129
130
131 RemoteDomAgentStub.prototype.SetTextNodeValue = function(callId) {
132 setTimeout(function() {
133 RemoteDomAgent.DidApplyDomChange(callId, true);
134 }, 0);
135 };
136
137
138 RemoteDomAgentStub.prototype.PerformSearch = function(callId, query) {
139 setTimeout(function() {
140 RemoteDomAgent.DidPerformSearch(callId, [1]);
141 }, 0);
142 };
143
144
145 RemoteDomAgentStub.prototype.DiscardBindings = function() {
146 };
147
148
149 /** 93 /**
150 * @constructor 94 * @constructor
151 */ 95 */
152 RemoteToolsAgentStub = function() { 96 RemoteToolsAgentStub = function() {
153 }; 97 };
154 98
155 99
156 RemoteToolsAgentStub.prototype.HideDOMNodeHighlight = function() { 100 RemoteToolsAgentStub.prototype.HideDOMNodeHighlight = function() {
157 }; 101 };
158 102
159 103
160 RemoteToolsAgentStub.prototype.HighlightDOMNode = function() { 104 RemoteToolsAgentStub.prototype.HighlightDOMNode = function() {
161 }; 105 };
162 106
163 107
164 RemoteToolsAgentStub.prototype.evaluate = function(expr) { 108 RemoteToolsAgentStub.prototype.evaluate = function(expr) {
165 window.eval(expr); 109 window.eval(expr);
166 }; 110 };
167 111
168 RemoteToolsAgentStub.prototype.EvaluateJavaScript = function(callId, script) { 112 RemoteToolsAgentStub.prototype.EvaluateJavaScript = function(callId, script) {
169 setTimeout(function() { 113 setTimeout(function() {
170 var result = eval(script); 114 var result = eval(script);
171 RemoteToolsAgent.DidEvaluateJavaScript(callId, result); 115 RemoteToolsAgent.DidEvaluateJavaScript(callId, result);
172 }, 0); 116 }, 0);
173 }; 117 };
174 118
175 119
176 RemoteToolsAgentStub.prototype.ExecuteUtilityFunction = function(callId, 120 RemoteToolsAgentStub.prototype.ExecuteUtilityFunction = function(callId,
177 functionName, nodeId, args) { 121 functionName, args) {
178 setTimeout(function() { 122 setTimeout(function() {
179 var result = []; 123 var result = [];
180 if (functionName == 'getProperties') { 124 if (functionName == 'getProperties') {
181 result = [ 125 result = [
182 'undefined', 'undefined_key', undefined, 126 'undefined', 'undefined_key', undefined,
183 'string', 'string_key', 'value', 127 'string', 'string_key', 'value',
184 'function', 'func', undefined, 128 'function', 'func', undefined,
185 'array', 'array_key', [10], 129 'array', 'array_key', [10],
186 'object', 'object_key', undefined, 130 'object', 'object_key', undefined,
187 'boolean', 'boolean_key', true, 131 'boolean', 'boolean_key', true,
(...skipping 12 matching lines...) Expand all
200 { 'selector' : 'S', 144 { 'selector' : 'S',
201 'style' : [3, '0px', '0px', null, null, null, ['display', false, fal se, '', 'none']], 145 'style' : [3, '0px', '0px', null, null, null, ['display', false, fal se, '', 'none']],
202 'parentStyleSheet' : { 'href' : 'http://localhost', 146 'parentStyleSheet' : { 'href' : 'http://localhost',
203 'ownerNodeName' : 'DIV' } 147 'ownerNodeName' : 'DIV' }
204 } 148 }
205 ] 149 ]
206 }; 150 };
207 } else if (functionName == 'toggleNodeStyle' || 151 } else if (functionName == 'toggleNodeStyle' ||
208 functionName == 'applyStyleText' || 152 functionName == 'applyStyleText' ||
209 functionName == 'setStyleProperty') { 153 functionName == 'setStyleProperty') {
210 alert(functionName + '(' + nodeId + ', ' + args + ')'); 154 alert(functionName + '(' + args + ')');
155 } else if (functionName == 'evaluate') {
156 try {
157 result = [ window.eval(JSON.parse(args)[0]), false ];
158 } catch (e) {
159 result = [ e.toString(), true ];
160 }
161 } else if (functionName == 'InspectorController' ||
162 functionName == 'InjectedScript') {
163 // do nothing;
211 } else { 164 } else {
212 alert('Unexpected utility function:' + functionName); 165 alert('Unexpected utility function:' + functionName);
213 } 166 }
214 RemoteToolsAgent.DidExecuteUtilityFunction(callId, 167 RemoteToolsAgent.DidExecuteUtilityFunction(callId,
215 JSON.stringify(result), ''); 168 JSON.stringify(result), '');
216 }, 0); 169 }, 0);
217 }; 170 };
218 171
219 172
220 RemoteToolsAgentStub.prototype.GetNodePrototypes = function(callId, nodeId) { 173 RemoteToolsAgentStub.prototype.SetResourceTrackingEnabled = function(enabled, al ways) {
221 setTimeout(function() { 174 RemoteToolsAgent.SetResourcesPanelEnabled(enabled);
222 RemoteToolsAgent.DidGetNodePrototypes(callId, 175 if (enabled) {
223 JSON.stringify()); 176 WebInspector.resourceTrackingWasEnabled();
224 }, 0); 177 } else {
225 }; 178 WebInspector.resourceTrackingWasDisabled();
226 179 }
227 180 addDummyResource();
228 RemoteToolsAgentStub.prototype.ClearConsoleMessages = function() {
229 }; 181 };
230 182
231 183
232 RemoteDebuggerAgentStub.ProfilerLogBuffer = 184 RemoteDebuggerAgentStub.ProfilerLogBuffer =
185 'profiler,begin,1\n' +
186 'profiler,resume\n' +
233 'code-creation,LazyCompile,0x1000,256,"test1 http://aaa.js:1"\n' + 187 'code-creation,LazyCompile,0x1000,256,"test1 http://aaa.js:1"\n' +
234 'code-creation,LazyCompile,0x2000,256,"test2 http://bbb.js:2"\n' + 188 'code-creation,LazyCompile,0x2000,256,"test2 http://bbb.js:2"\n' +
235 'code-creation,LazyCompile,0x3000,256,"test3 http://ccc.js:3"\n' + 189 'code-creation,LazyCompile,0x3000,256,"test3 http://ccc.js:3"\n' +
236 'tick,0x1010,0x0,3\n' + 190 'tick,0x1010,0x0,3\n' +
237 'tick,0x2020,0x0,3,0x1010\n' + 191 'tick,0x2020,0x0,3,0x1010\n' +
238 'tick,0x2020,0x0,3,0x1010\n' + 192 'tick,0x2020,0x0,3,0x1010\n' +
239 'tick,0x3010,0x0,3,0x2020, 0x1010\n' + 193 'tick,0x3010,0x0,3,0x2020, 0x1010\n' +
240 'tick,0x2020,0x0,3,0x1010\n' + 194 'tick,0x2020,0x0,3,0x1010\n' +
241 'tick,0x2030,0x0,3,0x2020, 0x1010\n' + 195 'tick,0x2030,0x0,3,0x2020, 0x1010\n' +
242 'tick,0x2020,0x0,3,0x1010\n' + 196 'tick,0x2020,0x0,3,0x1010\n' +
243 'tick,0x1010,0x0,3\n'; 197 'tick,0x1010,0x0,3\n' +
198 'profiler,pause\n';
199
200
201 RemoteDebuggerAgentStub.HeapSamples = [
202 {foo: [1, 100], bar: [20, 2000]},
203 {foo: [2000, 200000], bar: [10, 1000]},
204 {foo: [15, 1500], bar: [15, 1500]},
205 {bar: [20, 2000]},
206 {foo: [15, 1500], bar: [15, 1500]},
207 {bar: [20, 2000], baz: [15, 1500]}
208 ];
244 209
245 210
246 /** 211 /**
247 * @constructor 212 * @constructor
248 */ 213 */
249 RemoteDebuggerCommandExecutorStub = function() { 214 RemoteDebuggerCommandExecutorStub = function() {
250 }; 215 };
251 216
252 217
253 RemoteDebuggerCommandExecutorStub.prototype.DebuggerCommand = function(cmd) { 218 RemoteDebuggerCommandExecutorStub.prototype.DebuggerCommand = function(cmd) {
219 if ('{"seq":2,"type":"request","command":"scripts","arguments":{"' +
220 'includeSource":false}}' == cmd) {
221 var response1 =
222 '{"seq":5,"request_seq":2,"type":"response","command":"scripts","' +
223 'success":true,"body":[{"handle":61,"type":"script","name":"' +
224 'http://www/~test/t.js","id":59,"lineOffset":0,"columnOffset":0,' +
225 '"lineCount":1,"sourceStart":"function fib(n) {","sourceLength":300,' +
226 '"scriptType":2,"compilationType":0,"context":{"ref":60}}],"refs":[{' +
227 '"handle":60,"type":"context","data":{"type":"page","value":3}}],' +
228 '"running":false}';
229 this.sendResponse_(response1);
230 } else if ('{"seq":3,"type":"request","command":"scripts","arguments":{' +
231 '"ids":[59],"includeSource":true}}' == cmd) {
232 this.sendResponse_(
233 '{"seq":8,"request_seq":3,"type":"response","command":"scripts",' +
234 '"success":true,"body":[{"handle":1,"type":"script","name":' +
235 '"http://www/~test/t.js","id":59,"lineOffset":0,"columnOffset":0,' +
236 '"lineCount":1,"source":"function fib(n) {return n+1;}",' +
237 '"sourceLength":244,"scriptType":2,"compilationType":0,"context":{' +
238 '"ref":0}}],"refs":[{"handle":0,"type":"context","data":{"type":' +
239 '"page","value":3}}],"running":false}');
240 } else {
241 debugPrint('Unexpected command: ' + cmd);
242 }
254 }; 243 };
255 244
256 245
257 /** 246 RemoteDebuggerCommandExecutorStub.prototype.sendResponse_ = function(response) {
258 * @constructor 247 setTimeout(function() {
259 */ 248 RemoteDebuggerAgent.DebuggerOutput(response);
260 RemoteNetAgentStub = function() { 249 }, 0);
261 }; 250 };
262 251
263 252
264 /** 253 /**
265 * @constructor 254 * @constructor
266 */ 255 */
267 DevToolsHostStub = function() { 256 DevToolsHostStub = function() {
257 this.isStub = true;
258 window.domAutomationController = {
259 send: function(text) {
260 debugPrint(text);
261 }
262 };
268 }; 263 };
269 264
270 265
266 function addDummyResource() {
267 var payload = {
268 requestHeaders : {},
269 requestURL: 'http://google.com/simple_page.html',
270 host: 'google.com',
271 path: 'simple_page.html',
272 lastPathComponent: 'simple_page.html',
273 isMainResource: true,
274 cached: false,
275 mimeType: 'text/html',
276 suggestedFilename: 'simple_page.html',
277 expectedContentLength: 10000,
278 statusCode: 200,
279 contentLength: 10000,
280 responseHeaders: {},
281 type: WebInspector.Resource.Type.Document,
282 finished: true,
283 startTime: new Date(),
284
285 didResponseChange: true,
286 didCompletionChange: true,
287 didTypeChange: true
288 };
289
290 WebInspector.addResource(1, payload);
291 WebInspector.updateResource(1, payload);
292 }
293
294
271 DevToolsHostStub.prototype.loaded = function() { 295 DevToolsHostStub.prototype.loaded = function() {
272 RemoteDomAgentStub.sendDocumentElement_(); 296 addDummyResource();
273 RemoteDomAgentStub.sendChildNodes_(1); 297 uiTests.runAllTests();
274 RemoteDomAgentStub.sendChildNodes_(2);
275 devtools.tools.updateFocusedNode(4);
276 devtools.tools.addMessageToConsole('message', 'source', 3);
277 }; 298 };
278 299
279 300
301 DevToolsHostStub.prototype.reset = function() {
302 };
303
304
305 DevToolsHostStub.prototype.getPlatform = function() {
306 return "windows";
307 };
308
309
310 DevToolsHostStub.prototype.addResourceSourceToFrame = function(
311 identifier, mimeType, element) {
312 };
313
314
315 DevToolsHostStub.prototype.addSourceToFrame = function(mimeType, source,
316 element) {
317 };
318
319
320 DevToolsHostStub.prototype.getApplicationLocale = function() {
321 return "en-US";
322 };
323
324
280 if (!window['DevToolsHost']) { 325 if (!window['DevToolsHost']) {
281 window['RemoteDebuggerAgent'] = new RemoteDebuggerAgentStub(); 326 window['RemoteDebuggerAgent'] = new RemoteDebuggerAgentStub();
282 window['RemoteDebuggerCommandExecutor'] = 327 window['RemoteDebuggerCommandExecutor'] =
283 new RemoteDebuggerCommandExecutorStub(); 328 new RemoteDebuggerCommandExecutorStub();
284 window['RemoteDomAgent'] = new RemoteDomAgentStub();
285 window['RemoteNetAgent'] = new RemoteNetAgentStub();
286 window['RemoteToolsAgent'] = new RemoteToolsAgentStub(); 329 window['RemoteToolsAgent'] = new RemoteToolsAgentStub();
287 window['DevToolsHost'] = new DevToolsHostStub(); 330 window['DevToolsHost'] = new DevToolsHostStub();
288 } 331 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698