modules/libjar/test/unit/test_bug379841.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 // Regression test for bug 379841 - nsIZipReader's last modified time ignores seconds
     3 const Cc = Components.classes;
     4 const Ci = Components.interfaces;
     5 const path = "data/test_bug379841.zip";
     6 // Retrieved time should be within 2 seconds of original file's time.
     7 const MAX_TIME_DIFF = 2000000;
     9 var ENTRY_NAME = "test";
    10 // Actual time of file was 07 May 2007 13:35:49 UTC
    11 var ENTRY_TIME = new Date(Date.UTC(2007, 4, 7, 13, 35, 49, 0));
    13 function run_test() {
    14   var file = do_get_file(path);
    15   var zipReader = Cc["@mozilla.org/libjar/zip-reader;1"].
    16                   createInstance(Ci.nsIZipReader);
    17   zipReader.open(file);
    18   var entry = zipReader.getEntry(ENTRY_NAME);
    19   var diff = Math.abs(entry.lastModifiedTime - ENTRY_TIME.getTime()*1000);
    20   zipReader.close();
    21   if (diff >= MAX_TIME_DIFF)
    22     do_throw(diff);
    23 }

mercurial