diff --git a/lib/NavigatorWatcher.js b/lib/NavigatorWatcher.js index 196ad30e..18a591f0 100644 --- a/lib/NavigatorWatcher.js +++ b/lib/NavigatorWatcher.js @@ -36,7 +36,6 @@ class NavigatorWatcher { * @return {!Promise>} */ async waitForNavigation() { - this._inflightRequests = 0; this._requestIds = new Set(); this._eventListeners = []; @@ -84,9 +83,7 @@ class NavigatorWatcher { */ _onLoadingStarted(event) { this._requestIds.add(event.requestId); - if (!event.redirectResponse) - ++this._inflightRequests; - if (this._inflightRequests > this._idleInflight) { + if (this._requestIds.size > this._idleInflight) { clearTimeout(this._idleTimer); this._idleTimer = null; } @@ -96,11 +93,8 @@ class NavigatorWatcher { * @param {!Object} event */ _onLoadingCompleted(event) { - if (!this._requestIds.has(event.requestId)) - return; - - --this._inflightRequests; - if (this._inflightRequests <= this._idleInflight && !this._idleTimer) + this._requestIds.delete(event.requestId); + if (this._requestIds.size <= this._idleInflight && !this._idleTimer) this._idleTimer = setTimeout(this._networkIdleCallback, this._idleTime); }