Index: third_party/WebKit/LayoutTests/plugins/refcount-leaks.html |
diff --git a/third_party/WebKit/LayoutTests/plugins/refcount-leaks.html b/third_party/WebKit/LayoutTests/plugins/refcount-leaks.html |
index 0980fe1b275022a35f3739c7ced425f67bdc1bb6..f7a0daa20123abf27fa7af4dabfe1f638a23e624 100644 |
--- a/third_party/WebKit/LayoutTests/plugins/refcount-leaks.html |
+++ b/third_party/WebKit/LayoutTests/plugins/refcount-leaks.html |
@@ -7,24 +7,13 @@ |
window.GCController.collectAll(); |
} |
} |
+ var countOrig; |
+ var countAfterCreate; |
+ var countAfterGC; |
- function runtest() { |
- if (window.testRunner) |
- testRunner.dumpAsText(); |
- |
- |
- var output = document.getElementById("output"); |
- output.innerHTML = ""; |
- |
- // Test that objects are deleted after their JS references are released. |
- var countOrig = plug.testObjectCount; |
- o1 = plug.testCreateTestObject(); |
- o2 = plug.testCreateTestObject(); |
- o3 = plug.testCreateTestObject(); |
- var countAfterCreate = plug.testObjectCount; |
- o1 = o2 = o3 = null; |
+ function finishTest() { |
doGC(); |
- var countAfterGC = plug.testObjectCount; |
+ var countAfterGC2 = plug.testObjectCount; |
output.innerHTML += "--- num test objects:<br>"; |
output.innerHTML += "countAfterCreate == countOrig + 3? " |
@@ -33,35 +22,57 @@ |
output.innerHTML += "countOrig == countAfterGC? " |
+ ((countOrig == countAfterGC) ? "PASS" : "FAIL") |
+ "<br>"; |
+ output.innerHTML += "countOrig == countAfterGC2? " |
+ + ((countOrig == countAfterGC2) ? "PASS" : "FAIL") |
+ + "<br>"; |
output.innerHTML += "<br>"; |
- // Test that the object refcount returns to normal after JS references |
- // are released. |
- var testObj = plug.testObject; |
- var refOrig = testObj.refCount; |
- var o1 = plug.testObject; |
- var o2 = plug.testObject; |
- var o3 = plug.testObject; |
- var refAfterGet = testObj.refCount; |
- o1 = o2 = o3 = null; |
+ var success = (countAfterGC == countOrig) && (countAfterGC2 == countOrig); |
+ output.innerHTML += (success ? "SUCCESS" : "FAILURE"); |
+ |
+ if (window.testRunner) |
+ testRunner.notifyDone(); |
+ } |
+ |
+ function step2() { |
doGC(); |
- var refAfterGetGC = testObj.refCount; |
+ countAfterGC = plug.testObjectCount; |
- // Test that calling NPN_Invoke with our object as a parameter returns |
- // our refcount to normal (may require a GC). |
+ var testObj = plug.testCreateTestObject(); |
+ // The following will refcount testObj by passing it to the plugin and again |
+ // by the plugin calling noop, and we will verify in finishTest that the |
+ // refcounts are properly released, by verifying the plugin object was |
+ // properly deleted. |
plug.testPassTestObject("noop", testObj); |
plug.testPassTestObject("noop", testObj); |
plug.testPassTestObject("noop", testObj); |
+ |
doGC(); |
- var refAfterPass = testObj.refCount; |
+ // PPAPI requires the main loop to run to fully release references. See |
+ // PPB_Var_Deprecated_Proxy::OnMsgReleaseObject. |
+ setTimeout(finishTest, 0); |
+ } |
- output.innerHTML += "--- refcount on plug.testObject:<br>"; |
- output.innerHTML += "originally: " + refOrig + "<br>"; |
- output.innerHTML += "after GC: " + refAfterGetGC + "<br>"; |
- output.innerHTML += "after passing: " + refAfterPass + "<br>"; |
+ function runtest() { |
+ if (window.testRunner) { |
+ testRunner.dumpAsText(); |
+ testRunner.waitUntilDone(); |
+ } |
- var success = (countAfterGC == countOrig) && (refAfterPass == refOrig); |
- output.innerHTML += (success ? "SUCCESS" : "FAILURE"); |
+ var output = document.getElementById("output"); |
+ output.innerHTML = ""; |
+ |
+ // Test that objects are deleted after their JS references are released. |
+ countOrig = plug.testObjectCount; |
+ o1 = plug.testCreateTestObject(); |
+ o2 = plug.testCreateTestObject(); |
+ o3 = plug.testCreateTestObject(); |
+ countAfterCreate = plug.testObjectCount; |
+ o1 = o2 = o3 = null; |
+ doGC(); |
+ // PPAPI requires the main loop to run to fully release references. See |
+ // PPB_Var_Deprecated_Proxy::OnMsgReleaseObject. |
+ setTimeout(step2, 0); |
} |
</script> |
@@ -72,7 +83,7 @@ an NPAPI Object.<P> |
Prints "SUCCESS" on success, "FAILURE" on failure. |
-<embed name="plug" type="application/x-webkit-test-netscape"> |
+<embed name="plug" type="application/x-blink-deprecated-test-plugin"> |
<div id=output>FAILURE</div> |