Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | function run_test() |
michael@0 | 6 | { |
michael@0 | 7 | // We're testing migration to this version from one version below |
michael@0 | 8 | var targetVersion = 9; |
michael@0 | 9 | |
michael@0 | 10 | // First import the downloads.sqlite file |
michael@0 | 11 | importDatabaseFile("v" + (targetVersion - 1) + ".sqlite"); |
michael@0 | 12 | |
michael@0 | 13 | // Init the download manager which will try migrating to the new version |
michael@0 | 14 | var dm = Cc["@mozilla.org/download-manager;1"]. |
michael@0 | 15 | getService(Ci.nsIDownloadManager); |
michael@0 | 16 | var dbConn = dm.DBConnection; |
michael@0 | 17 | |
michael@0 | 18 | // Check schema version |
michael@0 | 19 | do_check_true(dbConn.schemaVersion >= targetVersion); |
michael@0 | 20 | |
michael@0 | 21 | // Make sure all the columns are there |
michael@0 | 22 | var stmt = dbConn.createStatement( |
michael@0 | 23 | "SELECT name, source, target, tempPath, startTime, endTime, state, " + |
michael@0 | 24 | "referrer, entityID, currBytes, maxBytes, mimeType, " + |
michael@0 | 25 | "preferredApplication, preferredAction, autoResume, guid " + |
michael@0 | 26 | "FROM moz_downloads " + |
michael@0 | 27 | "WHERE id = 28"); |
michael@0 | 28 | stmt.executeStep(); |
michael@0 | 29 | |
michael@0 | 30 | // This data is based on the original values in the table |
michael@0 | 31 | var data = [ |
michael@0 | 32 | "firefox-3.0a9pre.en-US.linux-i686.tar.bz2", |
michael@0 | 33 | "http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/firefox-3.0a9pre.en-US.linux-i686.tar.bz2", |
michael@0 | 34 | "file:///Users/Ed/Desktop/firefox-3.0a9pre.en-US.linux-i686.tar.bz2", |
michael@0 | 35 | "/Users/Ed/Desktop/+EZWafFQ.bz2.part", |
michael@0 | 36 | 1192469856209164, |
michael@0 | 37 | 1192469877017396, |
michael@0 | 38 | Ci.nsIDownloadManager.DOWNLOAD_FINISHED, |
michael@0 | 39 | "http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-trunk/", |
michael@0 | 40 | "%2210e66c1-8a2d6b-9b33f380%22/9055595/Mon, 15 Oct 2007 11:45:34 GMT", |
michael@0 | 41 | 1210772, |
michael@0 | 42 | 9055595, |
michael@0 | 43 | "application/x-bzip2", |
michael@0 | 44 | "AAAAAAGqAAIAAQxNYWNpbnRvc2ggSEQAAAAAAAAAAAAAAAAAAAC+91IESCsAAAAHc5UUU3R1ZmZJdCBFeHBhbmRlci5hcHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAdzmb3SGI8AAAAAAAAAAP////8AAAkgAAAAAAAAAAAAAAAAAAAAFFN0dWZmSXQgU3RhbmRhcmQgOS4wABAACAAAvveYVAAAABEACAAAvdJs7wAAAAEACAAHc5UAAAAWAAIAQ01hY2ludG9zaCBIRDpBcHBsaWNhdGlvbnM6U3R1ZmZJdCBTdGFuZGFyZCA5LjA6U3R1ZmZJdCBFeHBhbmRlci5hcHAAAA4AKgAUAFMAdAB1AGYAZgBJAHQAIABFAHgAcABhAG4AZABlAHIALgBhAHAAcAAPABoADABNAGEAYwBpAG4AdABvAHMAaAAgAEgARAASADZBcHBsaWNhdGlvbnMvU3R1ZmZJdCBTdGFuZGFyZCA5LjAvU3R1ZmZJdCBFeHBhbmRlci5hcHAAEwABLwD//wAA", |
michael@0 | 45 | 2, |
michael@0 | 46 | 0, |
michael@0 | 47 | // For the new columns added, check that default values are sensible |
michael@0 | 48 | 'ignored-value' |
michael@0 | 49 | ]; |
michael@0 | 50 | |
michael@0 | 51 | // Make sure the values are correct after the migration |
michael@0 | 52 | var i = 0; |
michael@0 | 53 | do_check_eq(data[i], stmt.getString(i++)); |
michael@0 | 54 | do_check_eq(data[i], stmt.getUTF8String(i++)); |
michael@0 | 55 | do_check_eq(data[i], stmt.getUTF8String(i++)); |
michael@0 | 56 | do_check_eq(data[i], stmt.getString(i++)); |
michael@0 | 57 | do_check_eq(data[i], stmt.getInt64(i++)); |
michael@0 | 58 | do_check_eq(data[i], stmt.getInt64(i++)); |
michael@0 | 59 | do_check_eq(data[i], stmt.getInt32(i++)); |
michael@0 | 60 | do_check_eq(data[i], stmt.getUTF8String(i++)); |
michael@0 | 61 | do_check_eq(data[i], stmt.getUTF8String(i++)); |
michael@0 | 62 | do_check_eq(data[i], stmt.getInt64(i++)); |
michael@0 | 63 | do_check_eq(data[i], stmt.getInt64(i++)); |
michael@0 | 64 | do_check_eq(data[i], stmt.getUTF8String(i++)); |
michael@0 | 65 | do_check_eq(data[i], stmt.getUTF8String(i++)); |
michael@0 | 66 | do_check_eq(data[i], stmt.getInt32(i++)); |
michael@0 | 67 | do_check_eq(data[i], stmt.getInt32(i++)); |
michael@0 | 68 | do_check_true(/^[a-zA-Z0-9\-_]{12}$/.test(stmt.getString(i++))); |
michael@0 | 69 | |
michael@0 | 70 | stmt.reset(); |
michael@0 | 71 | stmt.finalize(); |
michael@0 | 72 | |
michael@0 | 73 | cleanup(); |
michael@0 | 74 | } |