WorkersSidebarPane.js [plain text]
WebInspector.WorkersSidebarPane = function()
{
WebInspector.SidebarPane.call(this, WebInspector.UIString("Workers"));
this._workers = {};
this._enableWorkersCheckbox = new WebInspector.Checkbox(
WebInspector.UIString("Debug"),
this._onTriggerInstrument.bind(this),
false,
"sidebar-pane-subtitle",
WebInspector.UIString("Allow debugging workers. Enabling this option will replace native workers with the iframe-based JavaScript implementation"));
this.titleElement.insertBefore(this._enableWorkersCheckbox.element, this.titleElement.firstChild);
this._listElement = document.createElement("ol");
this._listElement.className = "workers-list";
this.bodyElement.appendChild(this._listElement);
this._treeOutline = new TreeOutline(this._listElement);
}
WebInspector.WorkersSidebarPane.prototype = {
addWorker: function(id, url, isShared)
{
if (id in this._workers)
return;
var worker = new WebInspector.Worker(id, url, isShared);
this._workers[id] = worker;
var title = WebInspector.linkifyURL(url, WebInspector.displayNameForURL(url), "worker-item", true, url);
var treeElement = new TreeElement(title, worker, false);
this._treeOutline.appendChild(treeElement);
},
removeWorker: function(id)
{
if (id in this._workers) {
this._treeOutline.removeChild(this._treeOutline.findTreeElement(this._workers[id]));
delete this._workers[id];
}
},
setInstrumentation: function(enabled)
{
InspectorBackend.removeAllScriptsToEvaluateOnLoad();
if (enabled)
InspectorBackend.addScriptToEvaluateOnLoad("(" + InjectedFakeWorker + ")");
},
reset: function()
{
InspectorBackend.removeAllScriptsToEvaluateOnLoad();
this.setInstrumentation(this._enableWorkersCheckbox.checked());
this._treeOutline.removeChildren();
this._workers = {};
},
_onTriggerInstrument: function(event)
{
this.setInstrumentation(this._enableWorkersCheckbox.checked());
}
};
WebInspector.WorkersSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype;
WebInspector.Worker = function(id, url, shared)
{
this.id = id;
this.url = url;
this.shared = shared;
}
WebInspector.didCreateWorker = function()
{
var workersPane = WebInspector.panels.scripts.sidebarPanes.workers;
if (workersPane)
workersPane.addWorker.apply(workersPane, arguments);
}
WebInspector.didDestroyWorker = function()
{
var workersPane = WebInspector.panels.scripts.sidebarPanes.workers;
if (workersPane)
workersPane.removeWorker.apply(workersPane, arguments);
}