Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

Commit

Permalink
fix(addon): #808 fix uncertain load_reason for the back button
Browse files Browse the repository at this point in the history
  • Loading branch information
ncloudioj committed Jun 8, 2016
1 parent 28d578a commit 1308fed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/TabTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ TabTracker.prototype = {
// already ended, likely with an 'unfocus' unload reason.
if (this.isActivityStreamsURL(tab.url) && tabs.activeTab.id === tab.id) {
if (!this._tabData.url) {
// load_reason could have been set as 'back_button' from before.
this._tabData.load_reason = this._tabData.load_reason || "newtab";
this._tabData.load_reason = "newtab";
} else if (!this._tabData.session_duration) {
// The page content has been reloaded but a total time wasn't set.
// This is due to a page refresh. Let's set the total time now.
Expand All @@ -202,7 +201,9 @@ TabTracker.prototype = {
// Thus, if we get here and load_reason still has not been set, then we know
// we got here due to a click of the 'back' button.
if (this.isActivityStreamsURL(tab.url) && !this._tabData.load_reason) {
this._tabData.load_reason = "back_button";
// logReady will start a new session and set the 'load_reason' as 'newtab'.
// we do not use 'back_button' for the 'load_reason' due to a known issue:
// https://github.com/mozilla/activity-stream/issues/808
this.logReady(tab);
}
},
Expand Down
2 changes: 1 addition & 1 deletion test/test-TabTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ exports.test_TabTracker_back_button_load = function*(assert) {
yield tabClosedPromise;
yield pingsSentPromise;

let loadReasons = ["newtab", "back_button"];
let loadReasons = ["newtab", "newtab"];
let unloadReasons = ["refresh", "close"];
checkLoadUnloadReasons(assert, pingData, loadReasons, unloadReasons);
};
Expand Down

0 comments on commit 1308fed

Please sign in to comment.