michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: function test() { michael@0: /** Test for Bug 506482 **/ michael@0: michael@0: // test setup michael@0: waitForExplicitFinish(); michael@0: michael@0: // read the sessionstore.js mtime (picked from browser_248970_a.js) michael@0: let profilePath = Cc["@mozilla.org/file/directory_service;1"]. michael@0: getService(Ci.nsIProperties). michael@0: get("ProfD", Ci.nsIFile); michael@0: function getSessionstoreFile() { michael@0: let sessionStoreJS = profilePath.clone(); michael@0: sessionStoreJS.append("sessionstore.js"); michael@0: return sessionStoreJS; michael@0: } michael@0: function getSessionstorejsModificationTime() { michael@0: let file = getSessionstoreFile(); michael@0: if (file.exists()) michael@0: return file.lastModifiedTime; michael@0: else michael@0: return -1; michael@0: } michael@0: michael@0: // delete existing sessionstore.js, to make sure we're not reading michael@0: // the mtime of an old one initialy michael@0: let (sessionStoreJS = getSessionstoreFile()) { michael@0: if (sessionStoreJS.exists()) michael@0: sessionStoreJS.remove(false); michael@0: } michael@0: michael@0: // test content URL michael@0: const TEST_URL = "data:text/html;charset=utf-8," michael@0: + "
top
" michael@0: michael@0: // preferences that we use michael@0: const PREF_INTERVAL = "browser.sessionstore.interval"; michael@0: michael@0: // make sure sessionstore.js is saved ASAP on all events michael@0: gPrefService.setIntPref(PREF_INTERVAL, 0); michael@0: michael@0: // get the initial sessionstore.js mtime (-1 if it doesn't exist yet) michael@0: let mtime0 = getSessionstorejsModificationTime(); michael@0: michael@0: // create and select a first tab michael@0: let tab = gBrowser.addTab(TEST_URL); michael@0: whenBrowserLoaded(tab.linkedBrowser, function() { michael@0: // step1: the above has triggered some saveStateDelayed(), sleep until michael@0: // it's done, and get the initial sessionstore.js mtime michael@0: setTimeout(function step1(e) { michael@0: let mtime1 = getSessionstorejsModificationTime(); michael@0: isnot(mtime1, mtime0, "initial sessionstore.js update"); michael@0: michael@0: // step2: test sessionstore.js is not updated on tab selection michael@0: // or content scrolling michael@0: gBrowser.selectedTab = tab; michael@0: tab.linkedBrowser.contentWindow.scrollTo(1100, 1200); michael@0: setTimeout(function step2(e) { michael@0: let mtime2 = getSessionstorejsModificationTime(); michael@0: is(mtime2, mtime1, michael@0: "tab selection and scrolling: sessionstore.js not updated"); michael@0: michael@0: // ok, done, cleanup and finish michael@0: if (gPrefService.prefHasUserValue(PREF_INTERVAL)) michael@0: gPrefService.clearUserPref(PREF_INTERVAL); michael@0: gBrowser.removeTab(tab); michael@0: finish(); michael@0: }, 3500); // end of sleep after tab selection and scrolling michael@0: }, 3500); // end of sleep after initial saveStateDelayed() michael@0: }); michael@0: }