toolkit/components/osfile/tests/xpcshell/test_osfile_closed.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 "use strict";
     3 Components.utils.import("resource://gre/modules/osfile.jsm");
     4 Components.utils.import("resource://gre/modules/Task.jsm");
     6 function run_test() {
     7   do_test_pending();
     8   run_next_test();
     9 }
    11 add_task(function test_closed() {
    12   OS.Shared.DEBUG = true;
    13   let currentDir = yield OS.File.getCurrentDirectory();
    14   do_print("Open a file, ensure that we can call stat()");
    15   let path = OS.Path.join(currentDir, "test_osfile_closed.js");
    16   let file = yield OS.File.open(path);
    17   yield file.stat();
    18   do_check_true(true);
    20   yield file.close();
    22   do_print("Ensure that we cannot stat() on closed file");
    23   let exn;
    24   try {
    25     yield file.stat();
    26   } catch (ex) {
    27     exn = ex;
    28   }
    29   do_print("Ensure that this raises the correct error");
    30   do_check_true(!!exn);
    31   do_check_true(exn instanceof OS.File.Error);
    32   do_check_true(exn.becauseClosed);
    34   do_print("Ensure that we cannot read() on closed file");
    35   exn = null;
    36   try {
    37     yield file.read();
    38   } catch (ex) {
    39     exn = ex;
    40   }
    41   do_print("Ensure that this raises the correct error");
    42   do_check_true(!!exn);
    43   do_check_true(exn instanceof OS.File.Error);
    44   do_check_true(exn.becauseClosed);
    46 });
    48 add_task(do_test_finished);

mercurial