2010-11-18 Tony Chang <tony@chromium.org>
authortony@chromium.org <tony@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Nov 2010 17:54:25 +0000 (17:54 +0000)
committertony@chromium.org <tony@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Nov 2010 17:54:25 +0000 (17:54 +0000)
        Reviewed by Adam Barth.

        run platform/chromium/plugins/refcount-leaks.html on all platforms
        https://bugs.webkit.org/show_bug.cgi?id=49485

        Moving the test into the top level plugins dir.

        * platform/chromium/drt_expectations.txt:
        * platform/chromium/plugins/refcount-leaks-expected.txt: Removed.
        * platform/chromium/plugins/refcount-leaks.html: Removed.
        * plugins/refcount-leaks-expected.txt: Copied from LayoutTests/platform/chromium/plugins/refcount-leaks-expected.txt.
        * plugins/refcount-leaks.html: Copied from LayoutTests/platform/chromium/plugins/refcount-leaks.html.
2010-11-18  Tony Chang  <tony@chromium.org>

        Reviewed by Adam Barth.

        run platform/chromium/plugins/refcount-leaks.html on all platforms
        https://bugs.webkit.org/show_bug.cgi?id=49485

        Add PluginObject.testObjectCount which returns the number of allocated
        TestObjects. Add PluginObject.testCreateTestObject which allocates
        and returns a TestObject.

        Add TestObject.refCount which returns the number of refs on the
        TestObject.

        * DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp:
        (pluginGetProperty):
        (pluginInvoke):
        * DumpRenderTree/TestNetscapePlugIn/TestObject.cpp:
        (getTestObjectCount):
        (testAllocate):
        (testDeallocate):
        (testGetProperty):
        (testScriptObjectInvoke): Release a ref to a plugin object that was
            previously leaked.
        * DumpRenderTree/TestNetscapePlugIn/TestObject.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@72302 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/chromium/drt_expectations.txt
LayoutTests/plugins/refcount-leaks-expected.txt [moved from LayoutTests/platform/chromium/plugins/refcount-leaks-expected.txt with 76% similarity]
LayoutTests/plugins/refcount-leaks.html [moved from LayoutTests/platform/chromium/plugins/refcount-leaks.html with 86% similarity]
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp
WebKitTools/DumpRenderTree/TestNetscapePlugIn/TestObject.cpp
WebKitTools/DumpRenderTree/TestNetscapePlugIn/TestObject.h

index f478d4e..0a56bd2 100644 (file)
@@ -1,3 +1,18 @@
+2010-11-18  Tony Chang  <tony@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        run platform/chromium/plugins/refcount-leaks.html on all platforms
+        https://bugs.webkit.org/show_bug.cgi?id=49485
+
+        Moving the test into the top level plugins dir.
+
+        * platform/chromium/drt_expectations.txt:
+        * platform/chromium/plugins/refcount-leaks-expected.txt: Removed.
+        * platform/chromium/plugins/refcount-leaks.html: Removed.
+        * plugins/refcount-leaks-expected.txt: Copied from LayoutTests/platform/chromium/plugins/refcount-leaks-expected.txt.
+        * plugins/refcount-leaks.html: Copied from LayoutTests/platform/chromium/plugins/refcount-leaks.html.
+
 2010-11-18  Alexey Proskuryakov  <ap@apple.com>
 
         Reviewed by Darin Adler.
index 4b7f13b..5627913 100644 (file)
@@ -85,7 +85,6 @@ BUG_DRT MAC : plugins/override-node-method.html = PASS
 BUG_DRT MAC : plugins/reloadplugins-no-pages.html = PASS
 BUG_DRT MAC : plugins/reloadplugins-and-pages.html = PASS
 BUG_DRT MAC : plugins/update-widgets-crash.html = PASS
-BUG_DRT MAC : platform/chromium/plugins/refcount-leaks.html = TEXT
 
 // This test is failing because the plugin is currently named
 // WebKitTestNetscapePlugin because the fork in the Chromium repo is named
@@ -2,13 +2,11 @@ Test that we can get an NPObject returned through a method on an NPAPI Object.
 Prints "SUCCESS" on success, "FAILURE" on failure.  
 
 --- num test objects:
-originally: 1
-after creation: 4
-after GC: 1
+countAfterCreate == countOrig + 3? PASS
+countOrig == countAfterGC? PASS
 
 --- refcount on plug.testObject:
 originally: 2
-after get: 2
 after GC: 2
 after passing: 2
 SUCCESS
@@ -3,10 +3,10 @@
   }
 
   function doGC() {
-    if (window.gc) {
+    if (window.GCController) {
       // GC twice to make sure everything is cleaned up.
       for (var i = 0; i < 2; i++) {
-        window.gc();
+        window.GCController.collect();
       }
     }
   }
     var countAfterGC = plug.testObjectCount;
 
     output.innerHTML += "--- num test objects:<br>";
-    output.innerHTML += "originally: " + countOrig + "<br>";
-    output.innerHTML += "after creation: " + countAfterCreate + "<br>";
-    output.innerHTML += "after GC: " + countAfterGC + "<br>";
+    output.innerHTML += "countAfterCreate == countOrig + 3? "
+        + ((countAfterCreate == countOrig + 3) ? "PASS" : "FAIL")
+        + "<br>";
+    output.innerHTML += "countOrig == countAfterGC? "
+        + ((countOrig == countAfterGC) ? "PASS" : "FAIL")
+        + "<br>";
     output.innerHTML += "<br>";
 
     // Test that the object refcount returns to normal after JS references
@@ -57,7 +60,6 @@
 
     output.innerHTML += "--- refcount on plug.testObject:<br>";
     output.innerHTML += "originally: " + refOrig + "<br>";
-    output.innerHTML += "after get: " + refAfterGet + "<br>";
     output.innerHTML += "after GC: " + refAfterGetGC + "<br>";
     output.innerHTML += "after passing: " + refAfterPass + "<br>";
 
index 213c9ba..46f0116 100644 (file)
@@ -1,3 +1,29 @@
+2010-11-18  Tony Chang  <tony@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        run platform/chromium/plugins/refcount-leaks.html on all platforms
+        https://bugs.webkit.org/show_bug.cgi?id=49485
+
+        Add PluginObject.testObjectCount which returns the number of allocated
+        TestObjects. Add PluginObject.testCreateTestObject which allocates
+        and returns a TestObject.
+
+        Add TestObject.refCount which returns the number of refs on the
+        TestObject.
+
+        * DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp:
+        (pluginGetProperty):
+        (pluginInvoke):
+        * DumpRenderTree/TestNetscapePlugIn/TestObject.cpp:
+        (getTestObjectCount):
+        (testAllocate):
+        (testDeallocate):
+        (testGetProperty):
+        (testScriptObjectInvoke): Release a ref to a plugin object that was
+            previously leaked.
+        * DumpRenderTree/TestNetscapePlugIn/TestObject.h:
+
 2010-11-17  Steve Falkenburg  <sfalken@apple.com>
 
         Reviewed by Adam Roben.
index 966ed2f..198d3c5 100644 (file)
@@ -141,6 +141,7 @@ enum {
     ID_PROPERTY_THROW_EXCEPTION_PROPERTY,
     ID_LAST_SET_WINDOW_ARGUMENTS,
     ID_PROPERTY_WINDOWED_PLUGIN,
+    ID_PROPERTY_TEST_OBJECT_COUNT,
     NUM_PROPERTY_IDENTIFIERS
 };
 
@@ -157,7 +158,8 @@ static const NPUTF8 *pluginPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = {
     "cachedPrivateBrowsingEnabled",
     "testThrowExceptionProperty",
     "lastSetWindowArguments",
-    "windowedPlugin"
+    "windowedPlugin",
+    "testObjectCount",
 };
 
 enum {
@@ -184,6 +186,7 @@ enum {
     ID_TEST_FAIL_METHOD,
     ID_TEST_CLONE_OBJECT,
     ID_TEST_SCRIPT_OBJECT_INVOKE,
+    ID_TEST_CREATE_TEST_OBJECT,
     ID_DESTROY_NULL_STREAM,
     ID_TEST_RELOAD_PLUGINS_NO_PAGES,
     ID_TEST_RELOAD_PLUGINS_AND_PAGES,
@@ -224,6 +227,7 @@ static const NPUTF8 *pluginMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
     "testFail",
     "testCloneObject",
     "testScriptObjectInvoke",
+    "testCreateTestObject",
     "destroyNullStream",
     "reloadPluginsNoPages",
     "reloadPluginsAndPages",
@@ -327,6 +331,10 @@ static bool pluginGetProperty(NPObject* obj, NPIdentifier name, NPVariant* resul
         STRINGZ_TO_NPVARIANT(buf, *result);
         return true;
     }
+    if (name == pluginPropertyIdentifiers[ID_PROPERTY_TEST_OBJECT_COUNT]) {
+        INT32_TO_NPVARIANT(getTestObjectCount(), *result);
+        return true;
+    }
 
     return false;
 }
@@ -836,6 +844,9 @@ static bool testScriptObjectInvoke(PluginObject* obj, const NPVariant* args, uin
         browser->releasevariantvalue(&object_method_result);
         VOID_TO_NPVARIANT(*result);
     }
+
+    browser->releaseobject(object_arg);
+
     return true;
 }
 
@@ -1035,6 +1046,12 @@ static bool pluginInvoke(NPObject* header, NPIdentifier name, const NPVariant* a
         OBJECT_TO_NPVARIANT(new_object, *result);
         return true;
     }
+    if (name == pluginMethodIdentifiers[ID_TEST_CREATE_TEST_OBJECT]) {
+        NPObject* testObject = browser->createobject(plugin->npp, getTestClass());
+        assert(testObject->referenceCount == 1);
+        OBJECT_TO_NPVARIANT(testObject, *result);
+        return true;
+    }
     if (name == pluginMethodIdentifiers[ID_DESTROY_NULL_STREAM])
         return destroyNullStream(plugin, args, argCount, result);
     if (name == pluginMethodIdentifiers[ID_TEST_RELOAD_PLUGINS_NO_PAGES]) {
index 8946c0e..9e65f11 100644 (file)
@@ -59,6 +59,13 @@ NPClass *getTestClass(void)
     return &testClass;
 }
 
+static int testObjectCount = 0;
+
+int getTestObjectCount()
+{
+    return testObjectCount;
+}
+
 typedef struct {
     NPObject header;
     NPObject* testObject;
@@ -73,6 +80,7 @@ enum {
     ID_PROPERTY_BAR,
     ID_PROPERTY_OBJECT_POINTER,
     ID_PROPERTY_TEST_OBJECT,
+    ID_PROPERTY_REF_COUNT,
     NUM_TEST_IDENTIFIERS,
 };
 
@@ -82,6 +90,7 @@ static const NPUTF8 *testIdentifierNames[NUM_TEST_IDENTIFIERS] = {
     "bar",
     "objectPointer",
     "testObject",
+    "refCount",
 };
 
 #define ID_THROW_EXCEPTION_METHOD   0
@@ -102,6 +111,7 @@ static NPObject* testAllocate(NPP /*npp*/, NPClass* /*theClass*/)
 {
     TestObject* newInstance = static_cast<TestObject*>(malloc(sizeof(TestObject)));
     newInstance->testObject = 0;
+    ++testObjectCount;
 
     if (!identifiersInitialized) {
         identifiersInitialized = true;
@@ -116,6 +126,8 @@ static void testDeallocate(NPObject *obj)
     TestObject* testObject = reinterpret_cast<TestObject*>(obj);
     if (testObject->testObject)
         browser->releaseobject(testObject->testObject);
+
+    --testObjectCount;
     free(obj);
 }
 
@@ -169,6 +181,10 @@ static bool testGetProperty(NPObject* npobj, NPIdentifier name, NPVariant* resul
         OBJECT_TO_NPVARIANT(testObject->testObject, *result);
         return true;
     }
+    if (name == testIdentifiers[ID_PROPERTY_REF_COUNT]) {
+        INT32_TO_NPVARIANT(npobj->referenceCount, *result);
+        return true;
+    }
     
     return false;
 }
index 1295fb7..73748e0 100644 (file)
@@ -26,4 +26,5 @@
 #include <WebKit/npapi.h>
 #include <WebKit/npruntime.h>
 
-NPClass *getTestClass(void);
+NPClass* getTestClass(void);
+int getTestObjectCount();