Changeset 128875 in webkit
- Timestamp:
- Sep 18, 2012 4:41:16 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r128873 r128875 1 2012-09-14 Andrey Kosyakov <caseq@chromium.org> 2 3 Web Inspector: [Extensions API] explicitly manage extension audit progress 4 https://bugs.webkit.org/show_bug.cgi?id=96803 5 6 Reviewed by Alexander Pavlov. 7 8 * inspector/extensions/extensions-audits-api-expected.txt: Added AuditResults.updateProgress() 9 * inspector/extensions/extensions-audits.html: Added a call to updateProgress() 10 1 11 2012-09-18 Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com> 2 12 -
trunk/LayoutTests/inspector/extensions/extensions-audits-api-expected.txt
r127147 r128875 27 27 createURL : <function> 28 28 done : <function> 29 updateProgress : <function> 29 30 } 30 31 { -
trunk/LayoutTests/inspector/extensions/extensions-audits-expected.txt
r116743 r128875 4 4 Running tests... 5 5 RUNNING TEST: extension_testAudits 6 Progress: 50% 7 Progress: 75% 6 8 Extension audits 7 9 Failed rule (42) -
trunk/LayoutTests/inspector/extensions/extensions-audits-tests.js
r116739 r128875 30 30 launcherView._launchButtonClicked(); 31 31 } 32 33 InspectorTest.dumpAuditProgress = function() 34 { 35 var progress = document.querySelector(".panel.audits progress"); 36 InspectorTest.addResult("Progress: " + Math.round(100 * progress.value / progress.max) + "%"); 37 } 32 38 } -
trunk/LayoutTests/inspector/extensions/extensions-audits.html
r116739 r128875 30 30 nestedNode.addChild(results.createResourceLink(inspectedPageURL, 20)); 31 31 32 results.addResult("Rule with details subtree (1)", "This rule has a lot of details", results.Severity.Warning, node); 33 34 // Audit normally terminates when number of added rule results is equal to 35 // the rule count declared when adding a category. done() is only for 36 // emergency cases, when we know we won't be able to run the rest of the rules. 37 results.done(); 32 evaluateOnFrontend("InspectorTest.dumpAuditProgress(); reply();", function() { 33 results.addResult("Rule with details subtree (1)", "This rule has a lot of details", results.Severity.Warning, node); 34 results.updateProgress(10, 20); 35 evaluateOnFrontend("InspectorTest.dumpAuditProgress(); reply();", results.done.bind(results)); 36 }); 38 37 }); 39 38 } … … 49 48 } 50 49 51 var category = webInspector.audits.addCategory("Extension audits" , 20);50 var category = webInspector.audits.addCategory("Extension audits"); 52 51 category.onAuditStarted.addListener(onStartAuditCategory); 53 52 -
trunk/Source/WebCore/ChangeLog
r128869 r128875 1 2012-09-14 Andrey Kosyakov <caseq@chromium.org> 2 3 Web Inspector: [Extensions API] explicitly manage extension audit progress 4 https://bugs.webkit.org/show_bug.cgi?id=96803 5 6 Reviewed by Alexander Pavlov. 7 8 - create a sub-progress per audit category; 9 - manage audit category progress within the category, not in the panel logic; 10 - consider audit is done when all categories are done; 11 - expose AuditResults.updateProgress(worked, totalWork) in the extensions API; 12 - retain old magic for computing audit progress if extension specifies extension results count. 13 14 * inspector/front-end/AuditsPanel.js: 15 (WebInspector.AuditsPanel.prototype._executeAudit.ruleResultReadyCallback): 16 (WebInspector.AuditsPanel.prototype._executeAudit): 17 (WebInspector.AuditCategory.prototype.run.callbackWrapper): 18 (WebInspector.AuditCategory.prototype.run): 19 * inspector/front-end/ExtensionAPI.js: 20 (defineCommonExtensionSymbols): 21 (injectedExtensionAPI.Audits.prototype.addCategory): 22 (injectedExtensionAPI.AuditResultImpl.prototype.updateProgress): 23 * inspector/front-end/ExtensionAuditCategory.js: 24 (WebInspector.ExtensionAuditCategory.prototype.run): 25 (WebInspector.ExtensionAuditCategoryResults): 26 (WebInspector.ExtensionAuditCategoryResults.prototype.done): 27 (WebInspector.ExtensionAuditCategoryResults.prototype._addResult): 28 (WebInspector.ExtensionAuditCategoryResults.prototype.updateProgress): 29 * inspector/front-end/ExtensionServer.js: 30 (WebInspector.ExtensionServer): 31 (WebInspector.ExtensionServer.prototype._onUpdateAuditProgress): 32 (WebInspector.ExtensionServer.prototype._onStopAuditCategoryRun): 33 * inspector/front-end/ProgressBar.js: 34 (WebInspector.ProgressIndicator.prototype.done): Assure only first call to done() has effect. 35 1 36 2012-09-19 Allan Sandfeld Jensen <allan.jensen@nokia.com> 2 37 -
trunk/Source/WebCore/inspector/front-end/AuditsPanel.js
r128598 r128875 99 99 _executeAudit: function(categories, resultCallback) 100 100 { 101 var requests = WebInspector.networkLog.requests;102 103 var rulesRemaining = 0;104 for (var i = 0; i < categories.length; ++i)105 rulesRemaining += categories[i].ruleCount;106 107 this._progress.setTotalWork(rulesRemaining);108 101 this._progress.setTitle(WebInspector.UIString("Running audit")); 102 103 function ruleResultReadyCallback(categoryResult, ruleResult) 104 { 105 if (ruleResult && ruleResult.children) 106 categoryResult.addRuleResult(ruleResult); 107 108 if (this._progress.isCanceled()) 109 this._progress.done(); 110 } 109 111 110 112 var results = []; 111 113 var mainResourceURL = WebInspector.inspectedPageURL; 112 113 function ruleResultReadyCallback(categoryResult, ruleResult)114 var categoriesDone = 0; 115 function categoryDoneCallback() 114 116 { 115 if ( this._progress.isCanceled())117 if (++categoriesDone !== categories.length) 116 118 return; 117 118 if (ruleResult && ruleResult.children) 119 categoryResult.addRuleResult(ruleResult); 120 121 --rulesRemaining; 122 this._progress.worked(); 123 124 if (!rulesRemaining || this._progress.isCanceled()) 125 resultCallback(mainResourceURL, results); 126 } 127 128 if (!rulesRemaining || this._progress.isCanceled()) { 129 resultCallback(mainResourceURL, results); 130 return; 131 } 132 119 this._progress.done(); 120 resultCallback(mainResourceURL, results) 121 } 122 123 var requests = WebInspector.networkLog.requests.slice(); 124 var compositeProgress = new WebInspector.CompositeProgress(this._progress); 125 var subprogresses = []; 126 for (var i = 0; i < categories.length; ++i) 127 subprogresses.push(compositeProgress.createSubProgress()); 133 128 for (var i = 0; i < categories.length; ++i) { 134 129 var category = categories[i]; 135 130 var result = new WebInspector.AuditCategoryResult(category); 136 131 results.push(result); 137 category.run(requests, ruleResultReadyCallback.bind(this, result), this._progress);132 category.run(requests, ruleResultReadyCallback.bind(this, result), categoryDoneCallback.bind(this), subprogresses[i]); 138 133 } 139 134 }, … … 271 266 }, 272 267 273 get ruleCount()274 {275 this._ensureInitialized();276 return this._rules.length;277 },278 279 268 addRule: function(rule, severity) 280 269 { … … 285 274 /** 286 275 * @param {Array.<WebInspector.NetworkRequest>} requests 287 * @param {function()} callback 276 * @param {function(WebInspector.AuditRuleResult)} ruleResultCallback 277 * @param {function()} categoryDoneCallback 288 278 * @param {WebInspector.Progress} progress 289 279 */ 290 run: function(requests, callback, progress)280 run: function(requests, ruleResultCallback, categoryDoneCallback, progress) 291 281 { 292 282 this._ensureInitialized(); 283 var remainingRulesCount = this._rules.length; 284 progress.setTotalWork(remainingRulesCount); 285 function callbackWrapper() 286 { 287 ruleResultCallback.apply(this, arguments); 288 progress.worked(); 289 if (!--remainingRulesCount) 290 categoryDoneCallback(); 291 } 293 292 for (var i = 0; i < this._rules.length; ++i) 294 this._rules[i].run(requests, callback , progress);293 this._rules[i].run(requests, callbackWrapper, progress); 295 294 }, 296 295 -
trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js
r123902 r128875 98 98 StopAuditCategoryRun: "stopAuditCategoryRun", 99 99 Unsubscribe: "unsubscribe", 100 UpdateAuditProgress: "updateAuditProgress", 100 101 UpdateButton: "updateButton", 101 102 InspectedURLChanged: "inspectedURLChanged" … … 510 511 { 511 512 var id = "extension-audit-category-" + extensionServer.nextObjectId(); 513 if (typeof resultCount !== "undefined") 514 console.warn("Passing resultCount to audits.addCategory() is deprecated. Use AuditResult.updateProgress() instead."); 512 515 extensionServer.sendRequest({ command: commands.AddAuditCategory, id: id, displayName: displayName, resultCount: resultCount }); 513 516 return new AuditCategory(id); … … 569 572 { 570 573 return new AuditResultNode(Array.prototype.slice.call(arguments)); 574 }, 575 576 updateProgress: function(worked, totalWork) 577 { 578 extensionServer.sendRequest({ command: commands.UpdateAuditProgress, resultId: this._id, progress: worked / totalWork }); 571 579 }, 572 580 -
trunk/Source/WebCore/inspector/front-end/ExtensionAuditCategory.js
r117293 r128875 31 31 /** 32 32 * @constructor 33 * @extends {WebInspector.AuditCategory} 33 34 * @param {string} extensionOrigin 34 35 * @param {string} id 35 36 * @param {string} displayName 36 * @param {number } ruleCount37 * @param {number=} ruleCount 37 38 */ 38 39 WebInspector.ExtensionAuditCategory = function(extensionOrigin, id, displayName, ruleCount) … … 56 57 }, 57 58 58 get ruleCount() 59 { 60 return this._ruleCount; 61 }, 62 63 run: function(resources, callback) 64 { 65 new WebInspector.ExtensionAuditCategoryResults(this, callback); 59 /** 60 * @param {Array.<WebInspector.NetworkRequest>} requests 61 * @param {function(WebInspector.AuditRuleResult)} ruleResultCallback 62 * @param {function()} categoryDoneCallback 63 * @param {WebInspector.Progress} progress 64 */ 65 run: function(requests, ruleResultCallback, categoryDoneCallback, progress) 66 { 67 var results = new WebInspector.ExtensionAuditCategoryResults(this, ruleResultCallback, categoryDoneCallback, progress); 68 WebInspector.extensionServer.startAuditRun(this, results); 66 69 } 67 70 } … … 70 73 * @constructor 71 74 * @param {WebInspector.ExtensionAuditCategory} category 72 * @param {function(WebInspector.AuditRuleResult)} callback 75 * @param {function(WebInspector.AuditRuleResult)} ruleResultCallback 76 * @param {function()} categoryDoneCallback 77 * @param {WebInspector.Progress} progress 73 78 */ 74 WebInspector.ExtensionAuditCategoryResults = function(category, callback)79 WebInspector.ExtensionAuditCategoryResults = function(category, ruleResultCallback, categoryDoneCallback, progress) 75 80 { 76 81 this._category = category; 77 this._pendingRules = category.ruleCount; 78 this._ruleCompletionCallback = callback; 82 this._ruleResultCallback = ruleResultCallback; 83 this._categoryDoneCallback = categoryDoneCallback; 84 this._progress = progress; 85 this._progress.setTotalWork(1); 86 this._expectedResults = category._ruleCount; 87 this._actualResults = 0; 79 88 80 89 this.id = category.id + "-" + ++WebInspector.ExtensionAuditCategoryResults._lastId; 81 WebInspector.extensionServer.startAuditRun(category, this);82 90 } 83 91 84 92 WebInspector.ExtensionAuditCategoryResults.prototype = { 85 get complete() 86 { 87 return !this._pendingRules; 88 }, 89 90 cancel: function() 91 { 92 while (!this.complete) 93 this._addResult(null); 93 done: function() 94 { 95 WebInspector.extensionServer.stopAuditRun(this); 96 this._progress.done(); 97 this._categoryDoneCallback(); 94 98 }, 95 99 … … 116 120 _addResult: function(result) 117 121 { 118 this._ruleCompletionCallback(result); 119 this._pendingRules--; 120 if (!this._pendingRules) 121 WebInspector.extensionServer.stopAuditRun(this); 122 this._ruleResultCallback(result); 123 ++this._actualResults; 124 if (typeof this._expectedResults === "number") { 125 this._progress.setWorked(this._actualResults / this._expectedResults); 126 if (this._actualResults === this._expectedResults) 127 this.done(); 128 } 129 }, 130 131 /** 132 * @param {number} progress 133 */ 134 updateProgress: function(progress) 135 { 136 this._progress.setWorked(progress); 122 137 }, 123 138 -
trunk/Source/WebCore/inspector/front-end/ExtensionServer.js
r127417 r128875 72 72 this._registerHandler(commands.Unsubscribe, this._onUnsubscribe.bind(this)); 73 73 this._registerHandler(commands.UpdateButton, this._onUpdateButton.bind(this)); 74 this._registerHandler(commands.UpdateAuditProgress, this._onUpdateAuditProgress.bind(this)); 74 75 75 76 window.addEventListener("message", this._onWindowMessage.bind(this), false); … … 551 552 }, 552 553 554 _onUpdateAuditProgress: function(message) 555 { 556 var auditResult = this._clientObjects[message.resultId]; 557 if (!auditResult) 558 return this._status.E_NOTFOUND(message.resultId); 559 auditResult.updateProgress(Math.min(Math.max(0, message.progress), 1)); 560 }, 561 553 562 _onStopAuditCategoryRun: function(message) 554 563 { … … 556 565 if (!auditRun) 557 566 return this._status.E_NOTFOUND(message.resultId); 558 auditRun. cancel();567 auditRun.done(); 559 568 }, 560 569 -
trunk/Source/WebCore/inspector/front-end/ProgressBar.js
r128598 r128875 106 106 done: function() 107 107 { 108 if (this._isDone) 109 return; 110 this._isDone = true; 108 111 this.hide(); 109 112 this.dispatchEventToListeners(WebInspector.ProgressIndicator.Events.Done);
Note: See TracChangeset
for help on using the changeset viewer.