Bug 997285 part 1. Add JS_GetErrorPrototype to JSAPI. r=jorendorff
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 05 May 2014 16:01:57 -0400
changeset 181837 a4d9d03ecfdf3436f6492f3b2cea7215ec69e6a8
parent 181836 44dc4cab616d0b77efb318aa20207507c36a38c6
child 181838 3a949414f5bcf52f7b02b065a734b9a52abdd83e
push id43150
push userbzbarsky@mozilla.com
push dateTue, 06 May 2014 20:53:55 +0000
treeherdermozilla-inbound@1ef41f4b806d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs997285
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 997285 part 1. Add JS_GetErrorPrototype to JSAPI. r=jorendorff
js/src/jsapi.cpp
js/src/jsapi.h
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -1380,16 +1380,24 @@ JS_GetArrayPrototype(JSContext *cx, Hand
 {
     CHECK_REQUEST(cx);
     assertSameCompartment(cx, forObj);
     Rooted<GlobalObject*> global(cx, &forObj->global());
     return GlobalObject::getOrCreateArrayPrototype(cx, global);
 }
 
 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_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
@@ -1821,16 +1821,23 @@ JS_GetObjectPrototype(JSContext *cx, JS:
 
 /*
  * Returns the original value of |Array.prototype| from the global object in
  * which |forObj| was created.
  */
 extern JS_PUBLIC_API(JSObject *)
 JS_GetArrayPrototype(JSContext *cx, JS::HandleObject forObj);
 
+/*
+ * 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);
+
 extern JS_PUBLIC_API(JSObject *)
 JS_GetGlobalForObject(JSContext *cx, JSObject *obj);
 
 extern JS_PUBLIC_API(bool)
 JS_IsGlobalObject(JSObject *obj);
 
 /*
  * May return nullptr, if |c| never had a global (e.g. the atoms compartment),