Bug 1792698 - stop ignoring LOCATION_CHANGE_SAME_DOCUMENT notifications when deciding whether to sync tabs. r=skhamis

Differential Revision: https://phabricator.services.mozilla.com/D161228
This commit is contained in:
Mark Hammond 2022-11-04 02:35:17 +00:00
Родитель e09b8a6240
Коммит d58a098aa8
2 изменённых файлов: 13 добавлений и 5 удалений

Просмотреть файл

@ -522,10 +522,11 @@ TabTracker.prototype = {
// web progress listeners.
onLocationChange(webProgress, request, locationURI, flags) {
// We only care about top-level location changes which are not in the same
// document.
// We only care about top-level location changes. We do want location changes in the
// same document because if a page uses the `pushState()` API, they *appear* as though
// they are in the same document even if the URL changes. It also doesn't hurt to accurately
// reflect the fragment changing - so we allow LOCATION_CHANGE_SAME_DOCUMENT
if (
flags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT ||
flags & Ci.nsIWebProgressListener.LOCATION_CHANGE_RELOAD ||
!webProgress.isTopLevel ||
!locationURI
@ -588,7 +589,14 @@ TabTracker.prototype = {
"tabsQuickWriteTimer"
);
} else if (scoreIncrement) {
this._log.debug(
"Detected a tab change, but conditions aren't met for a quick write - bumping score"
);
this.score += scoreIncrement;
} else {
this._log.debug(
"Detected a tab change, but conditions aren't met for a quick write or a score bump"
);
}
},
};

Просмотреть файл

@ -172,8 +172,8 @@ add_task(async function run_test() {
Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT
);
Assert.ok(
!tracker.modified,
"location change within the same document request didn't flag as modified"
tracker.modified,
"location change within the same document request did flag as modified"
);
tracker.onLocationChange(