js/xpconnect/tests/unit/test_bogus_files.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 function test_BrokenFile(path, shouldThrow, expectedName) {
     6   var didThrow = false;
     7   try {
     8     Components.utils.import(path);
     9   } catch (ex) {
    10     var exceptionName = ex.name;
    11     print("ex: " + ex + "; name = " + ex.name);
    12     didThrow = true;
    13   }
    15   do_check_eq(didThrow, shouldThrow);
    16   if (didThrow)
    17     do_check_eq(exceptionName, expectedName);
    18 }
    20 function run_test() {
    21   test_BrokenFile("resource://test/bogus_exports_type.jsm", true, "Error");
    23   test_BrokenFile("resource://test/bogus_element_type.jsm", true, "Error");
    25   test_BrokenFile("resource://test/non_existing.jsm",
    26                   true,
    27                   "NS_ERROR_FILE_NOT_FOUND");
    29   test_BrokenFile("chrome://test/content/test.jsm",
    30                   true,
    31                   "NS_ERROR_ILLEGAL_VALUE");
    33   // check that we can access modules' global objects even if
    34   // EXPORTED_SYMBOLS is missing or ill-formed:
    35   do_check_eq(typeof(Components.utils.import("resource://test/bogus_exports_type.jsm",
    36                                              null)),
    37               "object");
    39   do_check_eq(typeof(Components.utils.import("resource://test/bogus_element_type.jsm",
    40                                              null)),
    41               "object");
    42 }

mercurial