B2G/gecko/browser/components/sessionstore/test/browser_394759_privatebrowsing.js
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
This Source Code Form is subject to the terms of the Mozilla Public
License, v.
This Source Code Form is subject to the terms of the Mozilla Public License v .
function test() {
  waitForExplicitFinish();
  gPrefService.setIntPref("browser.sessionstore.interval", 100000);
  let blankState = JSON.stringify({
    windows: [{
      tabs: [{ entries: [{ url: "about:blank" }] }],
      _closedTabs: []
    }],
    _closedWindows: []
  });
  ss.setBrowserState(blankState);
  Services.obs.addObserver(function (aSubject, aTopic, aData) {
    Services.obs.removeObserver(arguments.callee, aTopic);
    info("sessionstore.js is being written");
    executeSoon(continue_test);
  }, "sessionstore-state-write", false);
  let profilePath = Cc["@mozilla.org/file/directory_service;1"].
                    getService(Ci.nsIProperties).
                    get("ProfD", Ci.nsIFile);
  let sessionStoreJS = profilePath.clone();
  sessionStoreJS.append("sessionstore.js");
  if (sessionStoreJS.exists())
    sessionStoreJS.remove(false);
  info("sessionstore.js was correctly removed: " + (!sessionStoreJS.exists()));
  gPrefService.setIntPref("browser.sessionstore.interval", 0);
}
function test ( ) { waitForExplicitFinish ( ) ; gPrefService . setIntPref ( "browser.sessionstore.interval" , 100000 ) ; let blankState = JSON . stringify ( { windows : [ { tabs : [ { entries : [ { url : "about:blank" } ] } ] , _closedTabs : [ ] } ] , _closedWindows : [ ] } ) ; ss . setBrowserState ( blankState ) ; Services . obs . addObserver ( function ( aSubject , aTopic , aData ) { Services . obs . removeObserver ( arguments . callee , aTopic ) ; info ( "sessionstore.js is being written" ) ; executeSoon ( continue_test ) ; } , "sessionstore-state-write" , false ) ; let profilePath = Cc [ "@mozilla.org/file/directory_service;1" ] . getService ( Ci . nsIProperties ) . get ( "ProfD" , Ci . nsIFile ) ; let sessionStoreJS = profilePath . clone ( ) ; sessionStoreJS . append ( "sessionstore.js" ) ; if ( sessionStoreJS . exists ( ) ) sessionStoreJS . remove ( false ) ; info ( "sessionstore.js was correctly removed: " + ( ! sessionStoreJS . exists ( ) ) ) ; gPrefService . setIntPref ( "browser.sessionstore.interval" , 0 ) ; }
This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0.
This Source Code Form is subject to the terms of the Mozilla Public License v . 2 . 0 .
/** Private Browsing Test for Bug 394759 **/ // Set interval to a large time so state won't be written while we setup env. // Set up the browser in a blank state. Popup windows in previous tests result // in different states on different platforms. // Wait for the sessionstore.js file to be written before going on. // Note: we don't wait for the complete event, since if asyncCopy fails we // would timeout. // Remove the sessionstore.js file before setting the interval to 0 // Make sure that sessionstore.js can be forced to be created by setting // the interval pref to 0.