ExtensionAuditCategory.js [plain text]
WebInspector.ExtensionAuditCategory = function(id, displayName, ruleCount)
{
this._id = id;
this._displayName = displayName;
this._ruleCount = ruleCount;
}
WebInspector.ExtensionAuditCategory.prototype = {
get id()
{
return this._id;
},
get displayName()
{
return this._displayName;
},
get ruleCount()
{
return this._ruleCount;
},
run: function(resources, callback)
{
new WebInspector.ExtensionAuditCategoryResults(this, callback);
}
}
WebInspector.ExtensionAuditCategoryResults = function(category, callback)
{
this._category = category;
this._pendingRules = category.ruleCount;
this._ruleCompletionCallback = callback;
this.id = category.id + "-" + ++WebInspector.ExtensionAuditCategoryResults._lastId;
WebInspector.extensionServer.startAuditRun(category, this);
}
WebInspector.ExtensionAuditCategoryResults.prototype = {
get complete()
{
return !this._pendingRules;
},
cancel: function()
{
while (!this.complete)
this._addResult(null);
},
addResult: function(displayName, description, severity, details)
{
var result = new WebInspector.AuditRuleResult(displayName);
result.addChild(description);
result.severity = severity;
if (details)
this._addNode(result, details);
this._addResult(result);
},
_addNode: function(parent, node)
{
var addedNode = parent.addChild(node.contents, node.expanded);
if (node.children) {
for (var i = 0; i < node.children.length; ++i)
this._addNode(addedNode, node.children[i]);
}
},
_addResult: function(result)
{
this._ruleCompletionCallback(result);
this._pendingRules--;
if (!this._pendingRules)
WebInspector.extensionServer.stopAuditRun(this);
}
}
WebInspector.ExtensionAuditCategoryResults._lastId = 0;