Bug 921454 - Use background-finalize-ity forwarding for all wrappers, not just CCWs. r=jonco
authorBobby Holley <bobbyholley@gmail.com>
Fri, 04 Oct 2013 13:29:36 +0200
changeset 149903 52bd45873c876eec4c3a0bef518448a8b13de14a
parent 149902 fb163ed3947e45d7aa384893c1965c7d0bb6c7d4
child 149904 896e70eccffb77aa000d493a29399368e7ca117e
push idunknown
push userunknown
push dateunknown
reviewersjonco
bugs921454
milestone27.0a1
Bug 921454 - Use background-finalize-ity forwarding for all wrappers, not just CCWs. r=jonco The current setup allows mismatches for same compartment wrappers, which causes us to assert when transplanting them.
js/src/jswrapper.cpp
js/src/jswrapper.h
--- a/js/src/jswrapper.cpp
+++ b/js/src/jswrapper.cpp
@@ -169,17 +169,17 @@ CrossCompartmentWrapper::CrossCompartmen
   : Wrapper(CROSS_COMPARTMENT | flags, hasPrototype)
 {
 }
 
 CrossCompartmentWrapper::~CrossCompartmentWrapper()
 {
 }
 
-bool CrossCompartmentWrapper::finalizeInBackground(Value priv)
+bool Wrapper::finalizeInBackground(Value priv)
 {
     if (!priv.isObject())
         return true;
 
     /*
      * Make the 'background-finalized-ness' of the wrapper the same as the
      * wrapped object, to allow transplanting between them.
      */
--- a/js/src/jswrapper.h
+++ b/js/src/jswrapper.h
@@ -61,30 +61,30 @@ class JS_FRIEND_API(Wrapper) : public Di
     unsigned flags() const {
         return mFlags;
     }
 
     explicit Wrapper(unsigned flags, bool hasPrototype = false);
 
     virtual ~Wrapper();
 
+    virtual bool finalizeInBackground(Value priv) MOZ_OVERRIDE;
+
     static Wrapper singleton;
     static Wrapper singletonWithPrototype;
 };
 
 /* Base class for all cross compartment wrapper handlers. */
 class JS_FRIEND_API(CrossCompartmentWrapper) : public Wrapper
 {
   public:
     CrossCompartmentWrapper(unsigned flags, bool hasPrototype = false);
 
     virtual ~CrossCompartmentWrapper();
 
-    virtual bool finalizeInBackground(Value priv) MOZ_OVERRIDE;
-
     /* ES5 Harmony fundamental wrapper traps. */
     virtual bool preventExtensions(JSContext *cx, HandleObject wrapper) MOZ_OVERRIDE;
     virtual bool getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
                                        MutableHandle<JSPropertyDescriptor> desc,
                                        unsigned flags) MOZ_OVERRIDE;
     virtual bool getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
                                           MutableHandle<JSPropertyDescriptor> desc,
                                           unsigned flags) MOZ_OVERRIDE;