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 | // 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 | } |