Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(709)

Side by Side Diff: third_party/WebKit/LayoutTests/plugins/refcount-leaks.html

Issue 1840963002: Port refcount-leaks to PPAPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <script> 1 <script>
2 function noop(x) { 2 function noop(x) {
3 } 3 }
4 4
5 function doGC() { 5 function doGC() {
6 if (window.GCController) { 6 if (window.GCController) {
7 window.GCController.collectAll(); 7 window.GCController.collectAll();
8 } 8 }
9 } 9 }
10 var countOrig;
11 var countAfterCreate;
12 var countAfterGC;
10 13
11 function runtest() { 14 function finishTest() {
12 if (window.testRunner)
13 testRunner.dumpAsText();
14
15
16 var output = document.getElementById("output");
17 output.innerHTML = "";
18
19 // Test that objects are deleted after their JS references are released.
20 var countOrig = plug.testObjectCount;
21 o1 = plug.testCreateTestObject();
22 o2 = plug.testCreateTestObject();
23 o3 = plug.testCreateTestObject();
24 var countAfterCreate = plug.testObjectCount;
25 o1 = o2 = o3 = null;
26 doGC(); 15 doGC();
27 var countAfterGC = plug.testObjectCount; 16 var countAfterGC2 = plug.testObjectCount;
28 17
29 output.innerHTML += "--- num test objects:<br>"; 18 output.innerHTML += "--- num test objects:<br>";
30 output.innerHTML += "countAfterCreate == countOrig + 3? " 19 output.innerHTML += "countAfterCreate == countOrig + 3? "
31 + ((countAfterCreate == countOrig + 3) ? "PASS" : "FAIL") 20 + ((countAfterCreate == countOrig + 3) ? "PASS" : "FAIL")
32 + "<br>"; 21 + "<br>";
33 output.innerHTML += "countOrig == countAfterGC? " 22 output.innerHTML += "countOrig == countAfterGC? "
34 + ((countOrig == countAfterGC) ? "PASS" : "FAIL") 23 + ((countOrig == countAfterGC) ? "PASS" : "FAIL")
35 + "<br>"; 24 + "<br>";
25 output.innerHTML += "countOrig == countAfterGC2? "
26 + ((countOrig == countAfterGC2) ? "PASS" : "FAIL")
27 + "<br>";
36 output.innerHTML += "<br>"; 28 output.innerHTML += "<br>";
37 29
38 // Test that the object refcount returns to normal after JS references 30 var success = (countAfterGC == countOrig) && (countAfterGC2 == countOrig);
39 // are released. 31 output.innerHTML += (success ? "SUCCESS" : "FAILURE");
40 var testObj = plug.testObject; 32
41 var refOrig = testObj.refCount; 33 if (window.testRunner)
42 var o1 = plug.testObject; 34 testRunner.notifyDone();
43 var o2 = plug.testObject; 35 }
44 var o3 = plug.testObject; 36
45 var refAfterGet = testObj.refCount; 37 function step2() {
46 o1 = o2 = o3 = null;
47 doGC(); 38 doGC();
48 var refAfterGetGC = testObj.refCount; 39 countAfterGC = plug.testObjectCount;
49 40
50 // Test that calling NPN_Invoke with our object as a parameter returns 41 var testObj = plug.testCreateTestObject();
51 // our refcount to normal (may require a GC).
52 plug.testPassTestObject("noop", testObj); 42 plug.testPassTestObject("noop", testObj);
53 plug.testPassTestObject("noop", testObj); 43 plug.testPassTestObject("noop", testObj);
54 plug.testPassTestObject("noop", testObj); 44 plug.testPassTestObject("noop", testObj);
45
dcheng 2016/03/29 03:15:24 No test expectations here because we can't get to
piman 2016/03/29 05:09:29 Oh, yeah I should add a comment. This will refcoun
55 doGC(); 46 doGC();
56 var refAfterPass = testObj.refCount; 47 // PPAPI requires the main loop to run to fully release references. See
48 // PPB_Var_Deprecated_Proxy::OnMsgReleaseObject.
49 setTimeout(finishTest, 0);
50 }
57 51
58 output.innerHTML += "--- refcount on plug.testObject:<br>"; 52 function runtest() {
59 output.innerHTML += "originally: " + refOrig + "<br>"; 53 if (window.testRunner) {
60 output.innerHTML += "after GC: " + refAfterGetGC + "<br>"; 54 testRunner.dumpAsText();
61 output.innerHTML += "after passing: " + refAfterPass + "<br>"; 55 testRunner.waitUntilDone();
56 }
62 57
63 var success = (countAfterGC == countOrig) && (refAfterPass == refOrig); 58 var output = document.getElementById("output");
64 output.innerHTML += (success ? "SUCCESS" : "FAILURE"); 59 output.innerHTML = "";
60
61 // Test that objects are deleted after their JS references are released.
62 countOrig = plug.testObjectCount;
63 o1 = plug.testCreateTestObject();
64 o2 = plug.testCreateTestObject();
65 o3 = plug.testCreateTestObject();
66 countAfterCreate = plug.testObjectCount;
67 o1 = o2 = o3 = null;
68 doGC();
69 // PPAPI requires the main loop to run to fully release references. See
70 // PPB_Var_Deprecated_Proxy::OnMsgReleaseObject.
71 setTimeout(step2, 0);
65 } 72 }
66 </script> 73 </script>
67 74
68 <body onload="runtest()"> 75 <body onload="runtest()">
69 76
70 Test that we can get an NPObject returned through a method on 77 Test that we can get an NPObject returned through a method on
71 an NPAPI Object.<P> 78 an NPAPI Object.<P>
72 79
73 Prints "SUCCESS" on success, "FAILURE" on failure. 80 Prints "SUCCESS" on success, "FAILURE" on failure.
74 81
75 <embed name="plug" type="application/x-webkit-test-netscape"> 82 <embed name="plug" type="application/x-blink-deprecated-test-plugin">
76 83
77 <div id=output>FAILURE</div> 84 <div id=output>FAILURE</div>
78 85
79 </body> 86 </body>
80 87
OLDNEW
« no previous file with comments | « ppapi/tests/blink_deprecated_test_plugin.cc ('k') | third_party/WebKit/LayoutTests/plugins/refcount-leaks-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698