| OLD | NEW |
| 1 <!DOCTYPE HTML> |
| 2 <!-- Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 Use of this source code is governed by a BSD-style license that can be |
| 4 found in the LICENSE file. |
| 5 --> |
| 1 <html> | 6 <html> |
| 7 <include src="../content_security_policy.html"/> |
| 2 <title>Workers</title> | 8 <title>Workers</title> |
| 3 <style> | 9 <style> |
| 4 thead { | 10 thead { |
| 5 background: #E0ECFF; | 11 background: #E0ECFF; |
| 6 } | 12 } |
| 7 td { | 13 td { |
| 8 padding: 0 15px 0 15px; | 14 padding: 0 15px 0 15px; |
| 9 } | 15 } |
| 10 | 16 |
| 11 </style> | 17 </style> |
| 12 <script> | 18 <script src="chrome://workers/workers.js"></script> |
| 13 function requestData() { | 19 <body> |
| 14 var xhr = new XMLHttpRequest(); | |
| 15 xhr.open('GET', 'workers_data.json', false); | |
| 16 xhr.send(null); | |
| 17 if (xhr.status === 200) | |
| 18 return JSON.parse(xhr.responseText); | |
| 19 return []; | |
| 20 } | |
| 21 | |
| 22 function addColumn(row, value) { | |
| 23 var column = document.createElement("td"); | |
| 24 column.textContent = value; | |
| 25 row.appendChild(column); | |
| 26 } | |
| 27 | |
| 28 function openDevTools(workerProcessHostId, workerRouteId) { | |
| 29 chrome.send("openDevTools", | |
| 30 [String(workerProcessHostId), String(workerRouteId)]); | |
| 31 } | |
| 32 | |
| 33 function populateWorkerList() { | |
| 34 var data = requestData(); | |
| 35 | |
| 36 var worker_properties = ["workerRouteId", "url", "name", "pid"]; | |
| 37 | |
| 38 var list = document.getElementById("workers-table"); | |
| 39 for (var i = 0; i < data.length; i++) { | |
| 40 var workerData = data[i]; | |
| 41 var row = document.createElement("tr"); | |
| 42 for (var j = 0; j < worker_properties.length; j++) | |
| 43 addColumn(row, workerData[worker_properties[j]]); | |
| 44 | |
| 45 var column = document.createElement("td"); | |
| 46 var link = document.createElement("a"); | |
| 47 link.setAttribute("href", "#"); | |
| 48 link.textContent = "inspect"; | |
| 49 link.addEventListener( | |
| 50 "click", | |
| 51 openDevTools.bind(this, | |
| 52 workerData.workerProcessHostId, | |
| 53 workerData.workerRouteId), | |
| 54 true); | |
| 55 column.appendChild(link); | |
| 56 row.appendChild(column); | |
| 57 | |
| 58 list.appendChild(row); | |
| 59 } | |
| 60 } | |
| 61 </script> | |
| 62 <body onload="populateWorkerList()"> | |
| 63 <h2>Shared workers:</h2> | 20 <h2>Shared workers:</h2> |
| 64 <table> | 21 <table> |
| 65 <thead> | 22 <thead> |
| 66 <tr> | 23 <tr> |
| 67 <th>Id</th> | 24 <th>Id</th> |
| 68 <th>URL</th> | 25 <th>URL</th> |
| 69 <th>Name</th> | 26 <th>Name</th> |
| 70 <th>Process id</th> | 27 <th>Process id</th> |
| 71 </tr> | 28 </tr> |
| 72 </thead> | 29 </thead> |
| 73 <tbody id="workers-table"> | 30 <tbody id="workers-table"> |
| 74 </tbody> | 31 </tbody> |
| 75 </table> | 32 </table> |
| 76 </body> | 33 </body> |
| 77 </html> | 34 </html> |
| OLD | NEW |