Bug 1347515 - Get rid of nsIJSON.decodeToJSVal, r=qdot
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 10 Nov 2017 00:26:51 +0100
changeset 444314 e26f2365ea7c7ec993d1d514a26c278ff381b43a
parent 444313 a3c81ef737006a74b0b7d23e85867f73ba6de144
child 444315 08f21a0e7ebebf714060f31650025244f993ac89
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1347515
milestone58.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 1347515 - Get rid of nsIJSON.decodeToJSVal, r=qdot
dom/interfaces/json/nsIJSON.idl
dom/json/nsJSON.cpp
--- a/dom/interfaces/json/nsIJSON.idl
+++ b/dom/interfaces/json/nsIJSON.idl
@@ -19,12 +19,9 @@ interface nsIScriptGlobalObject;
  * Don't use this!  Use JSON.parse and JSON.stringify directly.
  */
 [scriptable, uuid(083aebb0-7790-43b2-ae81-9e404e626236)]
 interface nsIJSON : nsISupports
 {
   [implicit_jscontext]
   jsval decodeFromStream(in nsIInputStream stream,
                          in long contentLength);
-
-  // Make sure you GCroot the result of this function before using it.
-  [noscript] jsval    decodeToJSVal(in AString str, in JSContext cx);
 };
--- a/dom/json/nsJSON.cpp
+++ b/dom/json/nsJSON.cpp
@@ -46,27 +46,16 @@ nsJSON::~nsJSON()
 
 NS_IMETHODIMP
 nsJSON::DecodeFromStream(nsIInputStream *aStream, int32_t aContentLength,
                          JSContext* cx, JS::MutableHandle<JS::Value> aRetval)
 {
   return DecodeInternal(cx, aStream, aContentLength, true, aRetval);
 }
 
-NS_IMETHODIMP
-nsJSON::DecodeToJSVal(const nsAString &str, JSContext *cx,
-                      JS::MutableHandle<JS::Value> result)
-{
-  if (!JS_ParseJSON(cx, static_cast<const char16_t*>(PromiseFlatString(str).get()),
-                    str.Length(), result)) {
-    return NS_ERROR_UNEXPECTED;
-  }
-  return NS_OK;
-}
-
 nsresult
 nsJSON::DecodeInternal(JSContext* cx,
                        nsIInputStream *aStream,
                        int32_t aContentLength,
                        bool aNeedsConverter,
                        JS::MutableHandle<JS::Value> aRetval)
 {
   // Consume the stream