Release ppp_class_data in mocked V8ObjectVar.

The CreateObject implementation should release the ppp_class_data when
it goes out of scope.

Bug: 258113
Change-Id: I563c6b5234f5ac94fed4fd43ce69c448e54866de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1539692
Reviewed-by: Bill Budge <bbudge@chromium.org>
Commit-Queue: David Benjamin <davidben@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#644512}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 1ad71d5814950c7107f7a2c9adf43dcdc363cafc
diff --git a/proxy/ppp_instance_private_proxy_unittest.cc b/proxy/ppp_instance_private_proxy_unittest.cc
index db491cb..fd7d860 100644
--- a/proxy/ppp_instance_private_proxy_unittest.cc
+++ b/proxy/ppp_instance_private_proxy_unittest.cc
@@ -25,12 +25,17 @@
 // A fake version of V8ObjectVar for testing.
 class V8ObjectVar : public ppapi::Var {
  public:
-  V8ObjectVar() {}
-  ~V8ObjectVar() override {}
+  V8ObjectVar(const PPP_Class_Deprecated* ppp_class, void* ppp_class_data)
+      : ppp_class_(ppp_class), ppp_class_data_(ppp_class_data) {}
+  ~V8ObjectVar() override { ppp_class_->Deallocate(ppp_class_data_); }
 
   // Var overrides.
   V8ObjectVar* AsV8ObjectVar() override { return this; }
   PP_VarType GetType() const override { return PP_VARTYPE_OBJECT; }
+
+ private:
+  const PPP_Class_Deprecated* ppp_class_;
+  void* ppp_class_data_;
 };
 
 namespace proxy {
@@ -110,9 +115,9 @@
 
 // Mock PPB_Var_Deprecated, so that we can emulate creating an Object Var.
 PP_Var CreateObject(PP_Instance /*instance*/,
-                    const PPP_Class_Deprecated* /*ppp_class*/,
-                    void* /*ppp_class_data*/) {
-  V8ObjectVar* obj_var = new V8ObjectVar;
+                    const PPP_Class_Deprecated* ppp_class,
+                    void* ppp_class_data) {
+  V8ObjectVar* obj_var = new V8ObjectVar(ppp_class, ppp_class_data);
   return obj_var->GetPPVar();
 }