toolkit/components/osfile/tests/xpcshell/test_path_constants.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/. */
     5 "use strict";
     7 Cu.import("resource://gre/modules/ctypes.jsm", this);
     8 Cu.import("resource://testing-common/AppData.jsm", this);
    11 function run_test() {
    12   run_next_test();
    13 }
    15 function compare_paths(ospath, key) {
    16   let file;
    17   try {
    18     file = Services.dirsvc.get(key, Components.interfaces.nsIFile);
    19   } catch(ex) {}
    21   if (file) {
    22     do_check_true(!!ospath);
    23     do_check_eq(ospath, file.path);
    24   } else {
    25     do_print("WARNING: " + key + " is not defined. Test may not be testing anything!");
    26     do_check_false(!!ospath);
    27   }
    28 }
    30 // Some path constants aren't set up until the profile is available. This
    31 // test verifies that behavior.
    32 add_task(function* test_before_after_profile() {
    33   do_check_null(OS.Constants.Path.profileDir);
    34   do_check_null(OS.Constants.Path.localProfileDir);
    35   do_check_null(OS.Constants.Path.userApplicationDataDir);
    37   do_get_profile();
    38   do_check_true(!!OS.Constants.Path.profileDir);
    39   do_check_true(!!OS.Constants.Path.localProfileDir);
    41   // UAppData is still null because the xpcshell profile doesn't set it up.
    42   // This test is mostly here to fail in case behavior of do_get_profile() ever
    43   // changes. We want to know if our assumptions no longer hold!
    44   do_check_null(OS.Constants.Path.userApplicationDataDir);
    46   yield makeFakeAppDir();
    47   do_check_true(!!OS.Constants.Path.userApplicationDataDir);
    49   // FUTURE: verify AppData too (bug 964291).
    50 });
    52 // Test simple paths
    53 add_task(function() {
    54   do_check_true(!!OS.Constants.Path.tmpDir);
    55   do_check_eq(OS.Constants.Path.tmpDir, Services.dirsvc.get("TmpD", Components.interfaces.nsIFile).path);
    57   do_check_true(!!OS.Constants.Path.homeDir);
    58   do_check_eq(OS.Constants.Path.homeDir, Services.dirsvc.get("Home", Components.interfaces.nsIFile).path);
    60   do_check_true(!!OS.Constants.Path.desktopDir);
    61   do_check_eq(OS.Constants.Path.desktopDir, Services.dirsvc.get("Desk", Components.interfaces.nsIFile).path);
    63   compare_paths(OS.Constants.Path.userApplicationDataDir, "UAppData");
    65   compare_paths(OS.Constants.Path.winAppDataDir, "AppData");
    66   compare_paths(OS.Constants.Path.winStartMenuProgsDir, "Progs");
    68   compare_paths(OS.Constants.Path.macUserLibDir, "ULibDir");
    69   compare_paths(OS.Constants.Path.macLocalApplicationsDir, "LocApp");
    70 });
    72 // Open libxul
    73 add_task(function() {
    74   ctypes.open(OS.Constants.Path.libxul);
    75   do_print("Linked to libxul");
    76 });

mercurial