WorkersSidebarPane.js [plain text]
WebInspector.WorkersSidebarPane = function()
{
WebInspector.SidebarPane.call(this, WebInspector.UIString("Workers"));
this._workers = {};
this._enableWorkersCheckbox = new WebInspector.Checkbox(
WebInspector.UIString("Debug"),
"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._enableWorkersCheckbox.addEventListener(this._onTriggerInstrument.bind(this));
this._enableWorkersCheckbox.checked = false;
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(null, worker, false);
treeElement.titleHTML = title;
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)
{
PageAgent.removeAllScriptsToEvaluateOnLoad();
if (enabled)
PageAgent.addScriptToEvaluateOnLoad("(" + InjectedFakeWorker + ")");
},
reset: function()
{
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;
}