Bug 722995 - Part 5: Make the tests compatible to the code changes, r=ehsan
authorSaurabh Anand <saurabhanandiit@gmail.com>
Sat, 21 Jul 2012 11:24:41 +0530
changeset 100018 73f73097fb1a93cd0ae6349f42ecfc2edcaa4881
parent 100017 705c22e1797671dc9412cbd7ff6daf0e18c19a82
child 100019 8b28f53415fe403823ca428dde1c9c675aceb963
push id12300
push userkwierso@gmail.com
push dateSat, 21 Jul 2012 06:38:36 +0000
treeherdermozilla-inbound@8b28f53415fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs722995
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 722995 - Part 5: Make the tests compatible to the code changes, r=ehsan
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_DownloadLastDirWithCPS.js
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_downloadLastDir.js
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_downloadLastDir_c.js
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_downloadLastDir_toggle.js
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_DownloadLastDirWithCPS.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_DownloadLastDirWithCPS.js
@@ -1,17 +1,19 @@
 /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
-Cu.import("resource://gre/modules/DownloadLastDir.jsm");
+let downloadModule = {};
+Cu.import("resource://gre/modules/DownloadLastDir.jsm", downloadModule);
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/FileUtils.jsm");
 
+let gDownloadLastDir = new downloadModule.DownloadLastDir(window);
 let pb = Cc["@mozilla.org/privatebrowsing;1"].
          getService(Ci.nsIPrivateBrowsingService);
 
 function test() {
   function clearHistory() {
     // simulate clearing the private data
     Services.obs.notifyObservers(null, "browser:purge-session-history", "");
   }
@@ -211,11 +213,10 @@ function test() {
   } finally {
       dir1.remove(true);
       dir2.remove(true);
       dir3.remove(true);
       Services.prefs.clearUserPref("browser.download.lastDir.savePerSite");
       Services.prefs.clearUserPref("browser.download.lastDir");
       gDownloadLastDir.cleanupPrivateFile();
       delete FileUtils;
-      delete gDownloadLastDir;
   }
 }
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_downloadLastDir.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_downloadLastDir.js
@@ -1,24 +1,26 @@
 /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
+let downloadModule = {};
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/DownloadLastDir.jsm");
+Cu.import("resource://gre/modules/DownloadLastDir.jsm", downloadModule);
 Cu.import("resource://gre/modules/FileUtils.jsm");
 Cu.import("resource://mochikit/MockFilePicker.jsm");
 
 let launcher = {
   source: Services.io.newURI("http://test1.com/file", null, null)
 };
 let pb = Cc["@mozilla.org/privatebrowsing;1"].
          getService(Ci.nsIPrivateBrowsingService);
+let gDownloadLastDir = new downloadModule.DownloadLastDir(window);
 
 MockFilePicker.init();
 MockFilePicker.returnValue = Ci.nsIFilePicker.returnOK;
 
 function test() {
   Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true);
   let prefs = Services.prefs.getBranch("browser.download.");
   let launcherDialog = Cc["@mozilla.org/helperapplauncherdialog;1"].
@@ -47,17 +49,16 @@ function test() {
   // cleanup functions registration
   registerCleanupFunction(function () {
     Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session");
     Services.prefs.clearUserPref("browser.download.lastDir");
     [dir1, dir2, dir3].forEach(function(dir) dir.remove(true));
     MockFilePicker.cleanup();
     gDownloadLastDir.cleanupPrivateFile();
     delete FileUtils;
-    delete gDownloadLastDir;
   });
 
   let context = gBrowser.selectedBrowser.contentWindow;
 
   prefs.setComplexValue("lastDir", Ci.nsIFile, tmpDir);
   MockFilePicker.returnFiles = [file1];
   let file = launcherDialog.promptForSaveToFile(launcher, context, null, null, null);
   ok(!!file, "promptForSaveToFile correctly returned a file");
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_downloadLastDir_c.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_downloadLastDir_c.js
@@ -1,20 +1,22 @@
 /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
-Cu.import("resource://gre/modules/DownloadLastDir.jsm");
+let downloadModule = {};
+Cu.import("resource://gre/modules/DownloadLastDir.jsm", downloadModule);
 Cu.import("resource://gre/modules/FileUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://mochikit/MockFilePicker.jsm");
 
 let pb = Cc["@mozilla.org/privatebrowsing;1"].
          getService(Ci.nsIPrivateBrowsingService);
+let gDownloadLastDir = new downloadModule.DownloadLastDir(window);
 
 MockFilePicker.init();
 MockFilePicker.returnValue = Ci.nsIFilePicker.returnOK;
 
 function test() {
   let stringBundleToRestore = ContentAreaUtils.stringBundle;
   let validateFileNameToRestore = validateFileName;
 
@@ -47,17 +49,16 @@ function test() {
     Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session");
     Services.prefs.clearUserPref("browser.download.lastDir");
     [dir1, dir2, dir3].forEach(function(dir) dir.remove(true));
     MockFilePicker.cleanup();
     ContentAreaUtils.stringBundle = stringBundleToRestore;
     validateFileName = validateFileNameToRestore;
     gDownloadLastDir.cleanupPrivateFile();
     delete FileUtils;
-    delete gDownloadLastDir;
   });
 
   // Overwrite stringBundle to return an object masquerading as a string bundle
   delete ContentAreaUtils.stringBundle;
   ContentAreaUtils.stringBundle = {
     GetStringFromName: function() ""
   };
 
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_downloadLastDir_toggle.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_downloadLastDir_toggle.js
@@ -1,17 +1,19 @@
 /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
-Cu.import("resource://gre/modules/DownloadLastDir.jsm");
+let downloadModule = {};
+Cu.import("resource://gre/modules/DownloadLastDir.jsm", downloadModule);
 Cu.import("resource://gre/modules/FileUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
+let gDownloadLastDir = new downloadModule.DownloadLastDir(window);
 let pb = Cc["@mozilla.org/privatebrowsing;1"].
          getService(Ci.nsIPrivateBrowsingService);
 
 function test() {
   function clearHistory() {
     // simulate clearing the private data
     Services.obs.notifyObservers(null, "browser:purge-session-history", "");
   }
@@ -22,17 +24,16 @@ function test() {
   let newDir = tmpDir.clone();
 
   registerCleanupFunction(function () {
     Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session");
     Services.prefs.clearUserPref("browser.download.lastDir");
     newDir.remove(true);
     gDownloadLastDir.cleanupPrivateFile();
     delete FileUtils;
-    delete gDownloadLastDir;
   });
 
   newDir.append("testdir");
   newDir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0700);
 
   gDownloadLastDir.file = tmpDir;
   is(gDownloadLastDir.file.path, tmpDir.path, "LastDir should point to the temporary directory");
   isnot(gDownloadLastDir.file, tmpDir, "gDownloadLastDir.file should not be pointing to the tmpDir");