Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / js / src / jsapi-tests / testBoundFunction.cpp
blob74f51ffd359aa676cb3c90341a9afc714dd0858f
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "jsapi-tests/tests.h"
10 BEGIN_TEST(testBoundFunction) {
11 EXEC("function foo() {}");
12 JS::RootedValue foo(cx);
13 EVAL("foo", &foo);
14 JS::RootedValue bound(cx);
15 EVAL("foo.bind(1)", &bound);
17 JS::Rooted<JSObject*> foofun(cx, &foo.toObject());
18 JS::Rooted<JSObject*> boundfun(cx, &bound.toObject());
20 CHECK(!JS_ObjectIsBoundFunction(foofun));
21 CHECK(JS_ObjectIsBoundFunction(boundfun));
23 CHECK(!JS_GetBoundFunctionTarget(foofun));
24 JSObject* target = JS_GetBoundFunctionTarget(boundfun);
25 CHECK(!!target);
26 CHECK(JS_ObjectIsFunction(target));
27 JS::RootedValue targetVal(cx, JS::ObjectValue(*target));
28 CHECK_SAME(foo, targetVal);
30 return true;
32 END_TEST(testBoundFunction)