Settings: Fix logical error in CCT's chrome-cleanup-on-idle event handler.
The code seems to be updating the |this.ongoingAction_| variable too
soon even though it needs to access its previous value later on.
This was actually discovered by the TypeScript compiler during the
attempt to migrate chrome_cleanup_page.js to TypeScript.
Fixed: 1239610
Change-Id: I70e61f762754a29f55d2b464566b038ab97490fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3094405
Auto-Submit: dpapad <dpapad@chromium.org>
Reviewed-by: Fabio Tirelo <ftirelo@chromium.org>
Reviewed-by: Daniel Rubery <drubery@chromium.org>
Commit-Queue: Daniel Rubery <drubery@chromium.org>
Cr-Commit-Position: refs/heads/master@{#911803}
diff --git a/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.js b/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.js
index edb97be..c6f5df4 100644
--- a/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.js
+++ b/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.js
@@ -403,6 +403,7 @@
* @private
*/
onIdle_(idleReason) {
+ const lastAction = this.ongoingAction_;
this.ongoingAction_ = ChromeCleanupOngoingAction.NONE;
this.scannerResults_ = this.emptyChromeCleanerScannerResults_;
@@ -428,10 +429,10 @@
break;
case ChromeCleanupIdleReason.CONNECTION_LOST:
- if (this.ongoingAction_ === ChromeCleanupOngoingAction.SCANNING) {
+ if (lastAction === ChromeCleanupOngoingAction.SCANNING) {
this.renderCleanupCard_(ChromeCleanerCardState.SCANNING_FAILED);
} else {
- assert(this.ongoingAction_ === ChromeCleanupOngoingAction.CLEANING);
+ assert(lastAction === ChromeCleanupOngoingAction.CLEANING);
this.renderCleanupCard_(ChromeCleanerCardState.CLEANING_FAILED);
}
break;