Diff
Modified: trunk/LayoutTests/ChangeLog (128874 => 128875)
--- trunk/LayoutTests/ChangeLog 2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/LayoutTests/ChangeLog 2012-09-18 11:41:16 UTC (rev 128875)
@@ -1,3 +1,13 @@
+2012-09-14 Andrey Kosyakov <[email protected]>
+
+ Web Inspector: [Extensions API] explicitly manage extension audit progress
+ https://bugs.webkit.org/show_bug.cgi?id=96803
+
+ Reviewed by Alexander Pavlov.
+
+ * inspector/extensions/extensions-audits-api-expected.txt: Added AuditResults.updateProgress()
+ * inspector/extensions/extensions-audits.html: Added a call to updateProgress()
+
2012-09-18 Raphael Kubo da Costa <[email protected]>
[EFL] Unreviewed gardening.
Modified: trunk/LayoutTests/inspector/extensions/extensions-audits-api-expected.txt (128874 => 128875)
--- trunk/LayoutTests/inspector/extensions/extensions-audits-api-expected.txt 2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/LayoutTests/inspector/extensions/extensions-audits-api-expected.txt 2012-09-18 11:41:16 UTC (rev 128875)
@@ -26,6 +26,7 @@
createText : <function>
createURL : <function>
done : <function>
+ updateProgress : <function>
}
{
children : {
Modified: trunk/LayoutTests/inspector/extensions/extensions-audits-expected.txt (128874 => 128875)
--- trunk/LayoutTests/inspector/extensions/extensions-audits-expected.txt 2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/LayoutTests/inspector/extensions/extensions-audits-expected.txt 2012-09-18 11:41:16 UTC (rev 128875)
@@ -3,6 +3,8 @@
Started extension.
Running tests...
RUNNING TEST: extension_testAudits
+Progress: 50%
+Progress: 75%
Extension audits
Failed rule (42)
this rule always fails
Modified: trunk/LayoutTests/inspector/extensions/extensions-audits-tests.js (128874 => 128875)
--- trunk/LayoutTests/inspector/extensions/extensions-audits-tests.js 2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/LayoutTests/inspector/extensions/extensions-audits-tests.js 2012-09-18 11:41:16 UTC (rev 128875)
@@ -29,4 +29,10 @@
launcherView._launchButtonClicked();
}
+
+ InspectorTest.dumpAuditProgress = function()
+ {
+ var progress = document.querySelector(".panel.audits progress");
+ InspectorTest.addResult("Progress: " + Math.round(100 * progress.value / progress.max) + "%");
+ }
}
Modified: trunk/LayoutTests/inspector/extensions/extensions-audits.html (128874 => 128875)
--- trunk/LayoutTests/inspector/extensions/extensions-audits.html 2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/LayoutTests/inspector/extensions/extensions-audits.html 2012-09-18 11:41:16 UTC (rev 128875)
@@ -29,12 +29,11 @@
webInspector.inspectedWindow.eval("location.href", function(inspectedPageURL) {
nestedNode.addChild(results.createResourceLink(inspectedPageURL, 20));
- results.addResult("Rule with details subtree (1)", "This rule has a lot of details", results.Severity.Warning, node);
-
- // Audit normally terminates when number of added rule results is equal to
- // the rule count declared when adding a category. done() is only for
- // emergency cases, when we know we won't be able to run the rest of the rules.
- results.done();
+ evaluateOnFrontend("InspectorTest.dumpAuditProgress(); reply();", function() {
+ results.addResult("Rule with details subtree (1)", "This rule has a lot of details", results.Severity.Warning, node);
+ results.updateProgress(10, 20);
+ evaluateOnFrontend("InspectorTest.dumpAuditProgress(); reply();", results.done.bind(results));
+ });
});
}
function onStartAuditFailedCategory()
@@ -48,7 +47,7 @@
results.done();
}
- var category = webInspector.audits.addCategory("Extension audits", 20);
+ var category = webInspector.audits.addCategory("Extension audits");
category.onAuditStarted.addListener(onStartAuditCategory);
var failedCategory = webInspector.audits.addCategory("Extension audits that fail", 2);
Modified: trunk/Source/WebCore/ChangeLog (128874 => 128875)
--- trunk/Source/WebCore/ChangeLog 2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/Source/WebCore/ChangeLog 2012-09-18 11:41:16 UTC (rev 128875)
@@ -1,3 +1,38 @@
+2012-09-14 Andrey Kosyakov <[email protected]>
+
+ Web Inspector: [Extensions API] explicitly manage extension audit progress
+ https://bugs.webkit.org/show_bug.cgi?id=96803
+
+ Reviewed by Alexander Pavlov.
+
+ - create a sub-progress per audit category;
+ - manage audit category progress within the category, not in the panel logic;
+ - consider audit is done when all categories are done;
+ - expose AuditResults.updateProgress(worked, totalWork) in the extensions API;
+ - retain old magic for computing audit progress if extension specifies extension results count.
+
+ * inspector/front-end/AuditsPanel.js:
+ (WebInspector.AuditsPanel.prototype._executeAudit.ruleResultReadyCallback):
+ (WebInspector.AuditsPanel.prototype._executeAudit):
+ (WebInspector.AuditCategory.prototype.run.callbackWrapper):
+ (WebInspector.AuditCategory.prototype.run):
+ * inspector/front-end/ExtensionAPI.js:
+ (defineCommonExtensionSymbols):
+ (injectedExtensionAPI.Audits.prototype.addCategory):
+ (injectedExtensionAPI.AuditResultImpl.prototype.updateProgress):
+ * inspector/front-end/ExtensionAuditCategory.js:
+ (WebInspector.ExtensionAuditCategory.prototype.run):
+ (WebInspector.ExtensionAuditCategoryResults):
+ (WebInspector.ExtensionAuditCategoryResults.prototype.done):
+ (WebInspector.ExtensionAuditCategoryResults.prototype._addResult):
+ (WebInspector.ExtensionAuditCategoryResults.prototype.updateProgress):
+ * inspector/front-end/ExtensionServer.js:
+ (WebInspector.ExtensionServer):
+ (WebInspector.ExtensionServer.prototype._onUpdateAuditProgress):
+ (WebInspector.ExtensionServer.prototype._onStopAuditCategoryRun):
+ * inspector/front-end/ProgressBar.js:
+ (WebInspector.ProgressIndicator.prototype.done): Assure only first call to done() has effect.
+
2012-09-19 Allan Sandfeld Jensen <[email protected]>
Revert r127457 and following fixes due to several hit-testing regressions
Modified: trunk/Source/WebCore/inspector/front-end/AuditsPanel.js (128874 => 128875)
--- trunk/Source/WebCore/inspector/front-end/AuditsPanel.js 2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/Source/WebCore/inspector/front-end/AuditsPanel.js 2012-09-18 11:41:16 UTC (rev 128875)
@@ -98,43 +98,38 @@
_executeAudit: function(categories, resultCallback)
{
- var requests = WebInspector.networkLog.requests;
-
- var rulesRemaining = 0;
- for (var i = 0; i < categories.length; ++i)
- rulesRemaining += categories[i].ruleCount;
-
- this._progress.setTotalWork(rulesRemaining);
this._progress.setTitle(WebInspector.UIString("Running audit"));
- var results = [];
- var mainResourceURL = WebInspector.inspectedPageURL;
-
function ruleResultReadyCallback(categoryResult, ruleResult)
{
- if (this._progress.isCanceled())
- return;
-
if (ruleResult && ruleResult.children)
categoryResult.addRuleResult(ruleResult);
- --rulesRemaining;
- this._progress.worked();
-
- if (!rulesRemaining || this._progress.isCanceled())
- resultCallback(mainResourceURL, results);
+ if (this._progress.isCanceled())
+ this._progress.done();
}
- if (!rulesRemaining || this._progress.isCanceled()) {
- resultCallback(mainResourceURL, results);
- return;
+ var results = [];
+ var mainResourceURL = WebInspector.inspectedPageURL;
+ var categoriesDone = 0;
+ function categoryDoneCallback()
+ {
+ if (++categoriesDone !== categories.length)
+ return;
+ this._progress.done();
+ resultCallback(mainResourceURL, results)
}
+ var requests = WebInspector.networkLog.requests.slice();
+ var compositeProgress = new WebInspector.CompositeProgress(this._progress);
+ var subprogresses = [];
+ for (var i = 0; i < categories.length; ++i)
+ subprogresses.push(compositeProgress.createSubProgress());
for (var i = 0; i < categories.length; ++i) {
var category = categories[i];
var result = new WebInspector.AuditCategoryResult(category);
results.push(result);
- category.run(requests, ruleResultReadyCallback.bind(this, result), this._progress);
+ category.run(requests, ruleResultReadyCallback.bind(this, result), categoryDoneCallback.bind(this), subprogresses[i]);
}
},
@@ -270,12 +265,6 @@
return this._displayName;
},
- get ruleCount()
- {
- this._ensureInitialized();
- return this._rules.length;
- },
-
addRule: function(rule, severity)
{
rule.severity = severity;
@@ -284,14 +273,24 @@
/**
* @param {Array.<WebInspector.NetworkRequest>} requests
- * @param {function()} callback
+ * @param {function(WebInspector.AuditRuleResult)} ruleResultCallback
+ * @param {function()} categoryDoneCallback
* @param {WebInspector.Progress} progress
*/
- run: function(requests, callback, progress)
+ run: function(requests, ruleResultCallback, categoryDoneCallback, progress)
{
this._ensureInitialized();
+ var remainingRulesCount = this._rules.length;
+ progress.setTotalWork(remainingRulesCount);
+ function callbackWrapper()
+ {
+ ruleResultCallback.apply(this, arguments);
+ progress.worked();
+ if (!--remainingRulesCount)
+ categoryDoneCallback();
+ }
for (var i = 0; i < this._rules.length; ++i)
- this._rules[i].run(requests, callback, progress);
+ this._rules[i].run(requests, callbackWrapper, progress);
},
_ensureInitialized: function()
Modified: trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js (128874 => 128875)
--- trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js 2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js 2012-09-18 11:41:16 UTC (rev 128875)
@@ -97,6 +97,7 @@
ShowPanel: "showPanel",
StopAuditCategoryRun: "stopAuditCategoryRun",
Unsubscribe: "unsubscribe",
+ UpdateAuditProgress: "updateAuditProgress",
UpdateButton: "updateButton",
InspectedURLChanged: "inspectedURLChanged"
};
@@ -509,6 +510,8 @@
addCategory: function(displayName, resultCount)
{
var id = "extension-audit-category-" + extensionServer.nextObjectId();
+ if (typeof resultCount !== "undefined")
+ console.warn("Passing resultCount to audits.addCategory() is deprecated. Use AuditResult.updateProgress() instead.");
extensionServer.sendRequest({ command: commands.AddAuditCategory, id: id, displayName: displayName, resultCount: resultCount });
return new AuditCategory(id);
}
@@ -570,6 +573,11 @@
return new AuditResultNode(Array.prototype.slice.call(arguments));
},
+ updateProgress: function(worked, totalWork)
+ {
+ extensionServer.sendRequest({ command: commands.UpdateAuditProgress, resultId: this._id, progress: worked / totalWork });
+ },
+
done: function()
{
extensionServer.sendRequest({ command: commands.StopAuditCategoryRun, resultId: this._id });
Modified: trunk/Source/WebCore/inspector/front-end/ExtensionAuditCategory.js (128874 => 128875)
--- trunk/Source/WebCore/inspector/front-end/ExtensionAuditCategory.js 2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionAuditCategory.js 2012-09-18 11:41:16 UTC (rev 128875)
@@ -30,10 +30,11 @@
/**
* @constructor
+ * @extends {WebInspector.AuditCategory}
* @param {string} extensionOrigin
* @param {string} id
* @param {string} displayName
- * @param {number} ruleCount
+ * @param {number=} ruleCount
*/
WebInspector.ExtensionAuditCategory = function(extensionOrigin, id, displayName, ruleCount)
{
@@ -55,44 +56,47 @@
return this._displayName;
},
- get ruleCount()
+ /**
+ * @param {Array.<WebInspector.NetworkRequest>} requests
+ * @param {function(WebInspector.AuditRuleResult)} ruleResultCallback
+ * @param {function()} categoryDoneCallback
+ * @param {WebInspector.Progress} progress
+ */
+ run: function(requests, ruleResultCallback, categoryDoneCallback, progress)
{
- return this._ruleCount;
- },
-
- run: function(resources, callback)
- {
- new WebInspector.ExtensionAuditCategoryResults(this, callback);
+ var results = new WebInspector.ExtensionAuditCategoryResults(this, ruleResultCallback, categoryDoneCallback, progress);
+ WebInspector.extensionServer.startAuditRun(this, results);
}
}
/**
* @constructor
* @param {WebInspector.ExtensionAuditCategory} category
- * @param {function(WebInspector.AuditRuleResult)} callback
+ * @param {function(WebInspector.AuditRuleResult)} ruleResultCallback
+ * @param {function()} categoryDoneCallback
+ * @param {WebInspector.Progress} progress
*/
-WebInspector.ExtensionAuditCategoryResults = function(category, callback)
+WebInspector.ExtensionAuditCategoryResults = function(category, ruleResultCallback, categoryDoneCallback, progress)
{
this._category = category;
- this._pendingRules = category.ruleCount;
- this._ruleCompletionCallback = callback;
+ this._ruleResultCallback = ruleResultCallback;
+ this._categoryDoneCallback = categoryDoneCallback;
+ this._progress = progress;
+ this._progress.setTotalWork(1);
+ this._expectedResults = category._ruleCount;
+ this._actualResults = 0;
this.id = category.id + "-" + ++WebInspector.ExtensionAuditCategoryResults._lastId;
- WebInspector.extensionServer.startAuditRun(category, this);
}
WebInspector.ExtensionAuditCategoryResults.prototype = {
- get complete()
+ done: function()
{
- return !this._pendingRules;
+ WebInspector.extensionServer.stopAuditRun(this);
+ this._progress.done();
+ this._categoryDoneCallback();
},
- cancel: function()
- {
- while (!this.complete)
- this._addResult(null);
- },
-
addResult: function(displayName, description, severity, details)
{
var result = new WebInspector.AuditRuleResult(displayName);
@@ -115,13 +119,24 @@
_addResult: function(result)
{
- this._ruleCompletionCallback(result);
- this._pendingRules--;
- if (!this._pendingRules)
- WebInspector.extensionServer.stopAuditRun(this);
+ this._ruleResultCallback(result);
+ ++this._actualResults;
+ if (typeof this._expectedResults === "number") {
+ this._progress.setWorked(this._actualResults / this._expectedResults);
+ if (this._actualResults === this._expectedResults)
+ this.done();
+ }
},
/**
+ * @param {number} progress
+ */
+ updateProgress: function(progress)
+ {
+ this._progress.setWorked(progress);
+ },
+
+ /**
* @param {string} _expression_
* @param {function(WebInspector.RemoteObject)} callback
*/
Modified: trunk/Source/WebCore/inspector/front-end/ExtensionServer.js (128874 => 128875)
--- trunk/Source/WebCore/inspector/front-end/ExtensionServer.js 2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionServer.js 2012-09-18 11:41:16 UTC (rev 128875)
@@ -71,6 +71,7 @@
this._registerHandler(commands.Subscribe, this._onSubscribe.bind(this));
this._registerHandler(commands.Unsubscribe, this._onUnsubscribe.bind(this));
this._registerHandler(commands.UpdateButton, this._onUpdateButton.bind(this));
+ this._registerHandler(commands.UpdateAuditProgress, this._onUpdateAuditProgress.bind(this));
window.addEventListener("message", this._onWindowMessage.bind(this), false);
}
@@ -550,12 +551,20 @@
return this._status.OK();
},
+ _onUpdateAuditProgress: function(message)
+ {
+ var auditResult = this._clientObjects[message.resultId];
+ if (!auditResult)
+ return this._status.E_NOTFOUND(message.resultId);
+ auditResult.updateProgress(Math.min(Math.max(0, message.progress), 1));
+ },
+
_onStopAuditCategoryRun: function(message)
{
var auditRun = this._clientObjects[message.resultId];
if (!auditRun)
return this._status.E_NOTFOUND(message.resultId);
- auditRun.cancel();
+ auditRun.done();
},
_dispatchCallback: function(requestId, port, result)
Modified: trunk/Source/WebCore/inspector/front-end/ProgressBar.js (128874 => 128875)
--- trunk/Source/WebCore/inspector/front-end/ProgressBar.js 2012-09-18 11:33:03 UTC (rev 128874)
+++ trunk/Source/WebCore/inspector/front-end/ProgressBar.js 2012-09-18 11:41:16 UTC (rev 128875)
@@ -105,6 +105,9 @@
done: function()
{
+ if (this._isDone)
+ return;
+ this._isDone = true;
this.hide();
this.dispatchEventToListeners(WebInspector.ProgressIndicator.Events.Done);
},