toolkit/components/downloads/test/schema_migration/test_migration_to_2.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 // This file tests migration from v1 to v2
     7 function run_test()
     8 {
     9   // First import the downloads.sqlite file
    10   importDatabaseFile("v1.sqlite");
    12   // ok, now it is OK to init the download manager - this will perform the
    13   // migration!
    14   var dm = Cc["@mozilla.org/download-manager;1"].
    15            getService(Ci.nsIDownloadManager);
    16   var dbConn = dm.DBConnection;
    17   var stmt = null;
    19   // check schema version
    20   do_check_true(dbConn.schemaVersion >= 2);
    22   // Check that the column no longer exists
    23   try {
    24     // throws when it doesn't exist
    25     stmt = dbConn.createStatement("SELECT iconURL FROM moz_downloads");
    26     do_throw("should not get here");
    27   } catch (e) {
    28     do_check_eq(Cr.NS_ERROR_FAILURE, e.result);
    29   }
    31   // now we check the entries
    32   stmt = dbConn.createStatement(
    33     "SELECT name, source, target, startTime, endTime, state " +
    34     "FROM moz_downloads " +
    35     "WHERE id = 2");
    36   stmt.executeStep();
    37   do_check_eq("381603.patch", stmt.getString(0));
    38   do_check_eq("https://bugzilla.mozilla.org/attachment.cgi?id=266520",
    39               stmt.getUTF8String(1));
    40   do_check_eq("file:///Users/sdwilsh/Desktop/381603.patch",
    41               stmt.getUTF8String(2));
    42   do_check_eq(1180493839859230, stmt.getInt64(3));
    43   do_check_eq(1180493839859230, stmt.getInt64(4));
    44   do_check_eq(1, stmt.getInt32(5));
    45   stmt.finalize();
    47   cleanup();
    48 }

mercurial