Back out bug 679509 -- need to try another approach. r=backout
authorJeff Walden <jwalden@mit.edu>
Thu, 13 Oct 2011 11:30:17 -0700
changeset 78711 40f077f9c4a2529d9fccb9f35e7fdc7fa101482d
parent 78710 dcc28a7cfa318ff0dde12e0c0bd7cd5cd9e8341a
child 78712 2f53f26d9e1b90687890a3b5010854536a444f84
push id21326
push userbmo@edmorley.co.uk
push dateFri, 14 Oct 2011 10:00:06 +0000
treeherdermozilla-central@ca73f057dab7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs679509
milestone10.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
Back out bug 679509 -- need to try another approach. r=backout
dom/plugins/base/nsJSNPRuntime.cpp
dom/plugins/test/mochitest/Makefile.in
dom/plugins/test/mochitest/test_defaultValue.html
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -155,16 +155,19 @@ NPObjWrapper_GetProperty(JSContext *cx, 
 static JSBool
 NPObjWrapper_newEnumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
                           jsval *statep, jsid *idp);
 
 static JSBool
 NPObjWrapper_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
                         JSObject **objp);
 
+static JSBool
+NPObjWrapper_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp);
+
 static void
 NPObjWrapper_Finalize(JSContext *cx, JSObject *obj);
 
 static JSBool
 NPObjWrapper_Call(JSContext *cx, uintN argc, jsval *vp);
 
 static JSBool
 NPObjWrapper_Construct(JSContext *cx, uintN argc, jsval *vp);
@@ -175,17 +178,17 @@ CreateNPObjectMember(NPP npp, JSContext 
 
 static JSClass sNPObjectJSWrapperClass =
   {
     NPRUNTIME_JSCLASS_NAME,
     JSCLASS_HAS_PRIVATE | JSCLASS_NEW_RESOLVE | JSCLASS_NEW_ENUMERATE,
     NPObjWrapper_AddProperty, NPObjWrapper_DelProperty,
     NPObjWrapper_GetProperty, NPObjWrapper_SetProperty,
     (JSEnumerateOp)NPObjWrapper_newEnumerate,
-    (JSResolveOp)NPObjWrapper_NewResolve, JS_ConvertStub,
+    (JSResolveOp)NPObjWrapper_NewResolve, NPObjWrapper_Convert,
     NPObjWrapper_Finalize, nsnull, nsnull, NPObjWrapper_Call,
     NPObjWrapper_Construct, nsnull, nsnull
   };
 
 typedef struct NPObjectMemberPrivate {
     JSObject *npobjWrapper;
     jsval fieldValue;
     NPIdentifier methodName;
@@ -1675,16 +1678,28 @@ NPObjWrapper_NewResolve(JSContext *cx, J
 
     return fnc != nsnull;
   }
 
   // no property or method
   return JS_TRUE;
 }
 
+static JSBool
+NPObjWrapper_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
+{
+  // The sole reason we implement this hook is to prevent the JS
+  // engine from calling valueOf() on NPObject's. Some NPObject's may
+  // actually implement a method named valueOf, but it's unlikely to
+  // behave as the JS engine expects it to. IOW, this is an empty hook
+  // that overrides what the default hook does.
+
+  return JS_TRUE;
+}
+
 static void
 NPObjWrapper_Finalize(JSContext *cx, JSObject *obj)
 {
   NPObject *npobj = (NPObject *)::JS_GetPrivate(cx, obj);
   if (npobj) {
     if (sNPObjWrappers.ops) {
       PL_DHashTableOperate(&sNPObjWrappers, npobj, PL_DHASH_REMOVE);
     }
@@ -2175,19 +2190,16 @@ NPObjectMember_Convert(JSContext *cx, JS
 
   switch (type) {
   case JSTYPE_VOID:
   case JSTYPE_STRING:
   case JSTYPE_NUMBER:
   case JSTYPE_BOOLEAN:
   case JSTYPE_OBJECT:
     *vp = memberPrivate->fieldValue;
-    if (!JSVAL_IS_PRIMITIVE(*vp)) {
-      return JS_ConvertStub(cx, JSVAL_TO_OBJECT(*vp), type, vp);
-    }
     return JS_TRUE;
   case JSTYPE_FUNCTION:
     // Leave this to NPObjectMember_Call.
     return JS_TRUE;
   default:
     NS_ERROR("illegal operation on JSObject prototype object");
     return JS_FALSE;
   }
--- a/dom/plugins/test/mochitest/Makefile.in
+++ b/dom/plugins/test/mochitest/Makefile.in
@@ -41,17 +41,16 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 relativesrcdir  = dom/plugins/test
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _MOCHITEST_FILES = \
   utils.js \
-  test_defaultValue.html \
   test_getauthenticationinfo.html \
   test_npobject_getters.html \
   test_npruntime_npnevaluate.html \
   test_npruntime_npninvoke.html \
   test_npruntime_npninvokedefault.html \
   test_npruntime_identifiers.html \
   npruntime_identifiers_subpage.html \
   loremipsum.txt \
deleted file mode 100644
--- a/dom/plugins/test/mochitest/test_defaultValue.html
+++ /dev/null
@@ -1,36 +0,0 @@
-<html>
-  <head>
-    <title>NPObject [[DefaultValue]] implementation</title>
-
-    <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  </head>
-
-  <body onload="run()">
-
-    <embed id="plugin" type="application/x-test" wmode="window"></embed>
-
-    <script class="testbody" type="application/javascript">
-      SimpleTest.waitForExplicitFinish();
-
-      function run() {
-        var plugin = document.getElementById("plugin");
-        var pluginProto = Object.getPrototypeOf(plugin);
-
-        plugin.propertyAndMethod = {};
-        plugin.propertyAndMethod + "baz";
-        ok(true, "|plugin.propertyAndMethod + \"baz\"| shouldn't assert");
-        pluginProto.propertyAndMethod = {};
-        pluginProto.propertyAndMethod + "quux";
-        ok(true, "|pluginProto.propertyAndMethod + \"quux\"| shouldn't assert");
-
-        plugin + "foo";
-        ok(true, "|plugin + \"foo\"| shouldn't assert");
-        pluginProto + "bar";
-        ok(true, "|pluginProto + \"bar\"| shouldn't assert");
-
-        SimpleTest.finish();
-      }
-    </script>
-  </body>
-</html>