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.

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

mercurial