js/src/jsapi-tests/testBindCallable.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 /* 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 #include "jsapi-tests/tests.h"
     7 BEGIN_TEST(test_BindCallable)
     8 {
     9   JS::RootedValue v(cx);
    10   EVAL("({ somename : 1717 })", &v);
    11   CHECK(v.isObject());
    13   JS::RootedValue func(cx);
    14   EVAL("(function() { return this.somename; })", &func);
    15   CHECK(func.isObject());
    17   JS::RootedObject funcObj(cx, JSVAL_TO_OBJECT(func));
    18   JS::RootedObject vObj(cx, JSVAL_TO_OBJECT(v));
    19   JSObject* newCallable = JS_BindCallable(cx, funcObj, vObj);
    20   CHECK(newCallable);
    22   JS::RootedValue retval(cx);
    23   JS::RootedValue fun(cx, JS::ObjectValue(*newCallable));
    24   bool called = JS_CallFunctionValue(cx, JS::NullPtr(), fun, JS::HandleValueArray::empty(), &retval);
    25   CHECK(called);
    27   CHECK(JSVAL_IS_INT(retval));
    29   CHECK(JSVAL_TO_INT(retval) == 1717);
    30   return true;
    31 }
    32 END_TEST(test_BindCallable)

mercurial