Bug 1114580 - Return a fixed name for @@toString on plugins. r=billm
authorTom Schuster <evilpies@gmail.com>
Wed, 31 Aug 2016 00:13:10 +0200
changeset 311955 2f9eb93beee93e8cb4fe0525df7e9cc684cfdc3b
parent 311954 f382d56789de9a9c9324cb4ba401d6fb747e5c0e
child 311956 b53afafbfb4325d8511e9de25d02df3943c3d73c
push id30627
push userryanvm@gmail.com
push dateWed, 31 Aug 2016 13:15:23 +0000
treeherdermozilla-central@3d9cabea1e56 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1114580
milestone51.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 1114580 - Return a fixed name for @@toString on plugins. r=billm
dom/plugins/base/nsJSNPRuntime.cpp
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -1365,16 +1365,29 @@ NPObjWrapper_GetProperty(JSContext *cx, 
                                  JS_NewFunction(
                                    cx, NPObjWrapper_toPrimitive, 1, 0,
                                    "Symbol.toPrimitive")));
       if (!obj)
         return false;
       vp.setObject(*obj);
       return true;
     }
+
+    if (JS::GetSymbolCode(sym) == JS::SymbolCode::toStringTag) {
+      JS::RootedString tag(cx, JS_NewStringCopyZ(cx, NPRUNTIME_JSCLASS_NAME));
+      if (!tag) {
+        return false;
+      }
+
+      vp.setString(tag);
+      return true;
+    }
+
+    vp.setUndefined();
+    return true;
   }
 
   // Find out what plugin (NPP) is the owner of the object we're
   // manipulating, and make it own any JSObject wrappers created here.
   NPP npp = LookupNPP(npobj);
   if (!npp) {
     ThrowJSException(cx, "No NPP found for NPObject!");