js/src/jsapi-tests/testContexts.cpp

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 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * vim: set ts=8 sts=4 et sw=4 tw=99:
     3  * This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #include "jsapi-tests/tests.h"
     9 BEGIN_TEST(testContexts_IsRunning)
    10     {
    11         CHECK(JS_DefineFunction(cx, global, "chk", chk, 0, 0));
    12         EXEC("for (var i = 0; i < 9; i++) chk();");
    13         return true;
    14     }
    16     static bool chk(JSContext *cx, unsigned argc, jsval *vp)
    17     {
    18         JSRuntime *rt = JS_GetRuntime(cx);
    19         JSContext *acx = JS_NewContext(rt, 8192);
    20         if (!acx) {
    21             JS_ReportOutOfMemory(cx);
    22             return false;
    23         }
    25         // acx should not be running
    26         bool ok = !JS_IsRunning(acx);
    27         if (!ok)
    28             JS_ReportError(cx, "Assertion failed: brand new context claims to be running");
    29         JS_DestroyContext(acx);
    30         return ok;
    31     }
    32 END_TEST(testContexts_IsRunning)
    34 BEGIN_TEST(testContexts_bug563735)
    35 {
    36     JSContext *cx2 = JS_NewContext(rt, 8192);
    37     CHECK(cx2);
    39     bool ok;
    40     {
    41         JSAutoRequest req(cx2);
    42         JSAutoCompartment ac(cx2, global);
    43         JS::RootedValue v(cx2);
    44         ok = JS_SetProperty(cx2, global, "x", v);
    45     }
    46     CHECK(ok);
    48     EXEC("(function () { for (var i = 0; i < 9; i++) ; })();");
    50     JS_DestroyContext(cx2);
    51     return true;
    52 }
    53 END_TEST(testContexts_bug563735)

mercurial