modules/libjar/zipwriter/test/unit/test_bug467740.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/.
     4  */
     6 function run_test()
     7 {
     8   // In this test we try to open some files that aren't archives:
     9   //  - An empty file, that is certainly not an archive.
    10   //  - A file that couldn't be mistaken for archive, since it is too small.
    11   //  - A file that could be mistaken for archive, if we checked only the file
    12   //     size, but is invalid since it contains no ZIP signature.
    13   var invalidArchives = ["emptyfile.txt", "smallfile.txt", "test.png"];
    15   invalidArchives.forEach(function(invalidArchive) {
    16     // Get a reference to the invalid file
    17     var invalidFile = do_get_file(DATA_DIR + invalidArchive);
    19     // Opening the invalid file should fail (but not crash)
    20     try {
    21       zipW.open(invalidFile, PR_RDWR);
    22       do_throw("Should have thrown NS_ERROR_FILE_CORRUPTED on " +
    23                invalidArchive + " !");
    24     } catch (e if (e instanceof Ci.nsIException &&
    25                    e.result == Components.results.NS_ERROR_FILE_CORRUPTED)) {
    26       // do nothing
    27     }
    28   });
    29 }

mercurial