Bug 1225392 part 1. Expose JSAPI for getting %IteratorPrototype%. r=efaust a=ritu
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 18 Nov 2015 18:26:07 -0500
changeset 284778 90e71bcc23db2fb7a6db2c7dcb2b8ba47fe804c9
parent 284777 3c7fef57944e58ae63f8797c6f50037a8d4b1eb7
child 284779 c1477aa0bfa49894142d058e9f0b524b626cab22
push id175
push usercbook@mozilla.com
push dateTue, 24 Nov 2015 10:35:25 +0000
reviewersefaust, ritu
bugs1225392
milestone44.0a2
Bug 1225392 part 1. Expose JSAPI for getting %IteratorPrototype%. r=efaust a=ritu
js/src/jsapi.cpp
js/src/jsapi.h
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -1358,16 +1358,24 @@ JS_PUBLIC_API(JSObject*)
 JS_GetErrorPrototype(JSContext* cx)
 {
     CHECK_REQUEST(cx);
     Rooted<GlobalObject*> global(cx, cx->global());
     return GlobalObject::getOrCreateCustomErrorPrototype(cx, global, JSEXN_ERR);
 }
 
 JS_PUBLIC_API(JSObject*)
+JS_GetIteratorPrototype(JSContext* cx)
+{
+    CHECK_REQUEST(cx);
+    Rooted<GlobalObject*> global(cx, cx->global());
+    return GlobalObject::getOrCreateIteratorPrototype(cx, global);
+}
+
+JS_PUBLIC_API(JSObject*)
 JS_GetGlobalForObject(JSContext* cx, JSObject* obj)
 {
     AssertHeapIsIdle(cx);
     assertSameCompartment(cx, obj);
     return &obj->global();
 }
 
 extern JS_PUBLIC_API(bool)
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -1555,16 +1555,23 @@ JS_GetArrayPrototype(JSContext* cx, JS::
 
 /**
  * Returns the original value of |Error.prototype| from the global
  * object of the current compartment of cx.
  */
 extern JS_PUBLIC_API(JSObject*)
 JS_GetErrorPrototype(JSContext* cx);
 
+/**
+ * Returns the %IteratorPrototype% object that all built-in iterator prototype
+ * chains go through for the global object of the current compartment of cx.
+ */
+extern JS_PUBLIC_API(JSObject*)
+JS_GetIteratorPrototype(JSContext* cx);
+
 extern JS_PUBLIC_API(JSObject*)
 JS_GetGlobalForObject(JSContext* cx, JSObject* obj);
 
 extern JS_PUBLIC_API(bool)
 JS_IsGlobalObject(JSObject* obj);
 
 extern JS_PUBLIC_API(JSObject*)
 JS_GlobalLexicalScope(JSObject* obj);