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/. */
6 #include "js/RootingAPI.h"
7 #include "jsapi-tests/tests.h"
8 #include "vm/CommonPropertyNames.h"
9 #include "vm/JSAtomState.h"
10 #include "vm/JSContext.h"
12 BEGIN_TEST(testAtomizeWithoutActiveZone
) {
13 // Tests for JS_AtomizeAndPinString when called without an active zone.
15 MOZ_ASSERT(cx
->zone());
17 JS::RootedString
testAtom1(cx
, JS_AtomizeString(cx
, "test1234@!"));
20 JS::RootedString
testAtom2(cx
);
22 JSAutoNullableRealm
ar(cx
, nullptr);
23 MOZ_ASSERT(!cx
->zone());
26 JSString
* atom
= JS_AtomizeAndPinString(cx
, "boolean");
28 CHECK_EQUAL(atom
, cx
->names().boolean
);
31 atom
= JS_AtomizeAndPinString(cx
, "8");
33 CHECK_EQUAL(atom
, cx
->staticStrings().getUint(8));
36 atom
= JS_AtomizeAndPinString(cx
, "test1234@!");
38 CHECK_EQUAL(atom
, testAtom1
);
41 testAtom2
= JS_AtomizeAndPinString(cx
, "asdflkjsdf987_@");
45 MOZ_ASSERT(cx
->zone());
46 JSString
* atom
= JS_AtomizeString(cx
, "asdflkjsdf987_@");
48 CHECK_EQUAL(atom
, testAtom2
);
52 END_TEST(testAtomizeWithoutActiveZone
)