js/xpconnect/tests/unit/test_bug641378.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 const Cc = Components.classes;
     2 const Ci = Components.interfaces;
     4 var timer;
     6 // This test XPConnect's ability to deal with a certain type of exception. In
     7 // particular, bug 641378 meant that if an exception had both 'message' and
     8 // 'result' properties, then it wouldn't successfully read the 'result' field
     9 // out of the exception (and sometimes crash).
    10 //
    11 // In order to make the test not fail completely on a negative result, we use
    12 // a timer. The first time through the timer, we throw our special exception.
    13 // Then, the second time through, we can test to see if XPConnect properly
    14 // dealt with our exception.
    15 var exception = {
    16   message: "oops, something failed!",
    18   tries: 0,
    19   get result() {
    20     ++this.tries;
    21     return 3;
    22   }
    23 };
    25 var callback = {
    26   tries: 0,
    27   notify: function (timer) {
    28     if (++this.tries === 1)
    29       throw exception;
    31     try {
    32         do_check_true(exception.tries >= 1);
    33     } finally {
    34         timer.cancel();
    35         timer = null;
    36         do_test_finished();
    37     }
    38   }
    39 };
    41 function run_test() {
    42   do_test_pending();
    44   timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
    45   timer.initWithCallback(callback, 0, timer.TYPE_REPEATING_SLACK);
    46 }

mercurial