Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / js / src / jsapi-tests / testIteratorObject.cpp
blob71ac16dabb3a7a038b4f2e662247116bf4947033
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 "js/Class.h" // js::ESClass
6 #include "js/Object.h" // JS::GetBuiltinClass
7 #include "js/RootingAPI.h" // JS::Rooted
8 #include "js/Value.h" // JS::Value
9 #include "jsapi-tests/tests.h"
11 BEGIN_TEST(testIteratorObject) {
12 using js::ESClass;
14 JS::Rooted<JS::Value> result(cx);
16 EVAL("new Map([['key1', 'value1'], ['key2', 'value2']]).entries()", &result);
18 CHECK(result.isObject());
19 JS::Rooted<JSObject*> obj1(cx, &result.toObject());
20 ESClass class1 = ESClass::Other;
21 CHECK(JS::GetBuiltinClass(cx, obj1, &class1));
22 CHECK(class1 == ESClass::MapIterator);
24 EVAL("new Set(['value1', 'value2']).entries()", &result);
26 CHECK(result.isObject());
27 JS::Rooted<JSObject*> obj2(cx, &result.toObject());
28 ESClass class2 = ESClass::Other;
29 CHECK(JS::GetBuiltinClass(cx, obj2, &class2));
30 CHECK(class2 == ESClass::SetIterator);
32 return true;
34 END_TEST(testIteratorObject)