OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Processes API test for Chrome. | 5 // Processes API test for Chrome. |
6 // browser_tests.exe --gtest_filter=ExtensionApiTest.Processes | 6 // browser_tests.exe --gtest_filter=ExtensionApiTest.Processes |
7 | 7 |
8 var pass = chrome.test.callbackPass; | 8 var pass = chrome.test.callbackPass; |
9 var fail = chrome.test.callbackFail; | 9 var fail = chrome.test.callbackFail; |
10 var assertEq = chrome.test.assertEq; | 10 var assertEq = chrome.test.assertEq; |
(...skipping 11 matching lines...) Expand all Loading... | |
22 } | 22 } |
23 | 23 |
24 var getProcessId = chrome.processes.getProcessIdForTab; | 24 var getProcessId = chrome.processes.getProcessIdForTab; |
25 | 25 |
26 function pageUrl(letter) { | 26 function pageUrl(letter) { |
27 return chrome.extension.getURL(letter + ".html"); | 27 return chrome.extension.getURL(letter + ".html"); |
28 } | 28 } |
29 | 29 |
30 function dumpProcess(process) { | 30 function dumpProcess(process) { |
31 console.log("id " + process.id); | 31 console.log("id " + process.id); |
32 console.log("title " + process.title); | |
32 console.log("osProcId " + process.osProcessId); | 33 console.log("osProcId " + process.osProcessId); |
33 console.log("type " + process.type); | 34 console.log("type " + process.type); |
34 console.log("profile " + process.profile); | 35 console.log("profile " + process.profile); |
35 console.log("tabs " + process.tabs); | 36 console.log("tabs " + process.tabs); |
36 console.log("cpu " + process.cpu); | 37 console.log("cpu " + process.cpu); |
37 console.log("privMem " + process.privateMemory); | 38 console.log("privMem " + process.privateMemory); |
38 console.log("network " + process.network); | 39 console.log("network " + process.network); |
39 console.log("jsMemAlloc " + process.jsMemoryAllocated); | 40 console.log("jsMemAlloc " + process.jsMemoryAllocated); |
40 console.log("jsMemUsed " + process.jsMemoryUsed); | 41 console.log("jsMemUsed " + process.jsMemoryUsed); |
41 console.log("sqliteMem " + process.sqliteMemory); | 42 console.log("sqliteMem " + process.sqliteMemory); |
42 console.log("fps " + process.fps); | 43 console.log("fps " + process.fps); |
44 console.log("naclDebugPort " + process.naclDebugPort); | |
43 if ("imageCache" in process) { | 45 if ("imageCache" in process) { |
44 console.log("imageCache.size " + process.imageCache.size); | 46 console.log("imageCache.size " + process.imageCache.size); |
45 console.log("imageCache.liveSize " + process.imageCache.liveSize); | 47 console.log("imageCache.liveSize " + process.imageCache.liveSize); |
46 } | 48 } |
47 if ("scriptCache" in process) { | 49 if ("scriptCache" in process) { |
48 console.log("scriptCache.size " + process.scriptCache.size); | 50 console.log("scriptCache.size " + process.scriptCache.size); |
49 console.log("scriptCache.liveSize " + process.scriptCache.liveSize); | 51 console.log("scriptCache.liveSize " + process.scriptCache.liveSize); |
50 } | 52 } |
51 if ("cssCache" in process) { | 53 if ("cssCache" in process) { |
52 console.log("cssCache.size " + process.cssCache.size); | 54 console.log("cssCache.size " + process.cssCache.size); |
53 console.log("cssCache .liveSize " + process.cssCache.liveSize); | 55 console.log("cssCache .liveSize " + process.cssCache.liveSize); |
54 } | 56 } |
55 } | 57 } |
56 | 58 |
57 function validateProcessProperties(process, updating, memory_included) { | 59 function validateProcessProperties(process, updating, memory_included) { |
58 // Always present. | 60 // Always present. |
59 assertTrue("id" in process); | 61 assertTrue("id" in process); |
62 assertTrue("title" in process); | |
63 assertTrue("naclDebugPort" in process); | |
60 assertTrue("osProcessId" in process); | 64 assertTrue("osProcessId" in process); |
61 assertTrue("type" in process); | 65 assertTrue("type" in process); |
62 assertTrue("profile" in process); | 66 assertTrue("profile" in process); |
63 assertTrue("tabs" in process); | 67 assertTrue("tabs" in process); |
64 | 68 |
65 // Present if onUpdate(WithMemory) listener is registered. | 69 // Present if onUpdate(WithMemory) listener is registered. |
66 assertEq(("cpu" in process), updating); | 70 assertEq(("cpu" in process), updating); |
67 assertEq(("network" in process), updating); | 71 assertEq(("network" in process), updating); |
68 assertEq(("fps" in process), updating); | 72 assertEq(("fps" in process), updating); |
69 | 73 |
70 // Present if memory details are requested. | 74 // Present if memory details are requested. |
71 assertEq(("privateMemory" in process), memory_included); | 75 assertEq(("privateMemory" in process), memory_included); |
72 | 76 |
73 // sqliteMemory is only reported for the browser process | 77 // sqliteMemory is only reported for the browser process |
74 if (process.type == "browser") { | 78 if (process.type == "browser") { |
75 assertEq(("sqliteMemory" in process), updating); | 79 assertEq(("sqliteMemory" in process), updating); |
76 } else { | 80 } else if (process.type == "renderer") { |
77 // The rest are not present in the browser process | 81 // The rest are not present in the browser process |
78 assertEq(("jsMemoryAllocated" in process), updating); | 82 assertEq(("jsMemoryAllocated" in process), updating); |
79 assertEq(("jsMemoryUsed" in process), updating); | 83 assertEq(("jsMemoryUsed" in process), updating); |
80 assertEq(("imageCache" in process), updating); | 84 assertEq(("imageCache" in process), updating); |
81 assertEq(("scriptCache" in process), updating); | 85 assertEq(("scriptCache" in process), updating); |
82 assertEq(("cssCache" in process), updating); | 86 assertEq(("cssCache" in process), updating); |
83 } | 87 } |
84 } | 88 } |
85 | 89 |
86 chrome.test.runTests([ | 90 chrome.test.runTests([ |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 }, | 261 }, |
258 | 262 |
259 function testOnCreated() { | 263 function testOnCreated() { |
260 listenOnce(chrome.processes.onCreated, function(process) { | 264 listenOnce(chrome.processes.onCreated, function(process) { |
261 assertTrue("id" in process, "process doesn't have id property"); | 265 assertTrue("id" in process, "process doesn't have id property"); |
262 assertTrue(process.id > 0, "id is not positive " + process.id); | 266 assertTrue(process.id > 0, "id is not positive " + process.id); |
263 }); | 267 }); |
264 createTab(5, "chrome://newtab/"); | 268 createTab(5, "chrome://newtab/"); |
265 }, | 269 }, |
266 | 270 |
271 // DISABLED: crbug.com/130138 | |
bradn
2014/02/20 00:54:56
Is there a better pattern to disable a test?
Also,
Charlie Reis
2014/02/20 01:20:19
The extensions folks will know better than I do.
bradn
2014/02/20 21:31:10
Done.
| |
272 // Hangs consistently. | |
273 /* | |
267 function testOnExited() { | 274 function testOnExited() { |
268 listenOnce(chrome.processes.onExited, | 275 listenOnce(chrome.processes.onExited, |
269 function(processId, type, code) { | 276 function(processId, type, code) { |
270 assertTrue(type >= 0 && type < 5); | 277 assertTrue(type >= 0 && type < 5); |
271 }); | 278 }); |
272 chrome.tabs.create({"url": "http://google.com/"}, pass(function(tab) { | 279 chrome.tabs.create({"url": "http://google.com/"}, pass(function(tab) { |
273 chrome.tabs.remove(tab.id); | 280 chrome.tabs.remove(tab.id); |
274 })); | 281 })); |
275 }, | 282 }, |
283 */ | |
276 | 284 |
277 function testGetProcessInfoList() { | 285 function testGetProcessInfoList() { |
278 getProcessId(tabs[0].id, pass(function(pidTab0) { | 286 getProcessId(tabs[0].id, pass(function(pidTab0) { |
279 getProcessId(tabs[1].id, pass(function(pidTab1) { | 287 getProcessId(tabs[1].id, pass(function(pidTab1) { |
280 chrome.processes.getProcessInfo([pidTab0, pidTab1], false, | 288 chrome.processes.getProcessInfo([pidTab0, pidTab1], false, |
281 pass(function(processes) { | 289 pass(function(processes) { |
282 assertTrue(Object.keys(processes).length == 2); | 290 assertTrue(Object.keys(processes).length == 2); |
283 })); | 291 })); |
284 })); | 292 })); |
285 })); | 293 })); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 }); | 329 }); |
322 }); | 330 }); |
323 chrome.tabs.create({"url": "chrome://hang" }, function(tab) { | 331 chrome.tabs.create({"url": "chrome://hang" }, function(tab) { |
324 getProcessId(tab.id, function(pid0) { | 332 getProcessId(tab.id, function(pid0) { |
325 hangingTabProcess = pid0; | 333 hangingTabProcess = pid0; |
326 }); | 334 }); |
327 chrome.tabs.update(tab.id, { "url": "chrome://flags" }); | 335 chrome.tabs.update(tab.id, { "url": "chrome://flags" }); |
328 }); | 336 }); |
329 } | 337 } |
330 ]); | 338 ]); |
OLD | NEW |