1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/downloads/test/schema_migration/head_migration.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,37 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +Components.utils.import("resource://gre/modules/Services.jsm"); 1.9 + 1.10 +const Cc = Components.classes; 1.11 +const Ci = Components.interfaces; 1.12 +const Cr = Components.results; 1.13 + 1.14 +do_get_profile(); 1.15 + 1.16 +do_register_cleanup(function() { 1.17 + Services.obs.notifyObservers(null, "quit-application", null); 1.18 +}); 1.19 + 1.20 +var dirSvc = Cc["@mozilla.org/file/directory_service;1"]. 1.21 + getService(Ci.nsIProperties); 1.22 + 1.23 +function importDatabaseFile(aFName) 1.24 +{ 1.25 + var file = do_get_file(aFName); 1.26 + var newFile = dirSvc.get("ProfD", Ci.nsIFile); 1.27 + file.copyTo(newFile, "downloads.sqlite"); 1.28 +} 1.29 + 1.30 +function cleanup() 1.31 +{ 1.32 + // removing database 1.33 + var dbFile = dirSvc.get("ProfD", Ci.nsIFile); 1.34 + dbFile.append("downloads.sqlite"); 1.35 + if (dbFile.exists()) 1.36 + try { dbFile.remove(true); } catch(e) { /* stupid windows box */ } 1.37 +} 1.38 + 1.39 +cleanup(); 1.40 +