Bug 739866 - Store last accessed timestamp for tabbrowser tabs [r=zpao]

This commit is contained in:
Pallani Kumaran 2012-04-16 23:17:54 -07:00
Родитель ff0f226d01
Коммит effa34a879
3 изменённых файлов: 27 добавлений и 0 удалений

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

@ -924,6 +924,7 @@
if (!this._previewMode) {
this.mCurrentTab.removeAttribute("unread");
this.selectedTab.lastAccessed = Date.now();
#ifdef MOZ_E10S_COMPAT
// Bug 666816 - TypeAheadFind support for e10s
@ -3816,6 +3817,7 @@
<field name="mCorrespondingMenuitem">null</field>
<field name="_fullyOpen">false</field>
<field name="closing">false</field>
<field name="lastAccessed">0</field>
</implementation>
<handlers>

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

@ -273,6 +273,7 @@ _BROWSER_FILES = \
browser_middleMouse_inherit.js \
redirect_bug623155.sjs \
browser_tabDrop.js \
browser_lastAccessedTab.js \
$(NULL)
ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT))

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

@ -0,0 +1,24 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test for bug 739866.
*
* 1. Adds a new tab (but doesn't select it)
* 2. Checks if timestamp on the new tab is 0
* 3. Selects the new tab, checks that the timestamp is updated (>0)
* 4. Selects the original tab & checks if new tab's timestamp has remained changed
*/
function test() {
let originalTab = gBrowser.selectedTab;
let newTab = gBrowser.addTab("about:blank", {skipAnimation: true});
is(newTab.lastAccessed, 0, "Timestamp on the new tab is 0.");
gBrowser.selectedTab = newTab;
let newTabAccessedDate = newTab.lastAccessed;
ok(newTabAccessedDate > 0, "Timestamp on the selected tab is more than 0.");
ok(newTabAccessedDate <= Date.now(), "Timestamp less than or equal current Date.");
gBrowser.selectedTab = originalTab;
is(newTab.lastAccessed, newTabAccessedDate, "New tab's timestamp remains the same.");
gBrowser.removeTab(newTab);
}