6 if (window
.GCController
) {
7 window
.GCController
.collectAll();
12 if (window
.testRunner
)
13 testRunner
.dumpAsText();
16 var output
= document
.getElementById("output");
17 output
.innerHTML
= "";
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
;
27 var countAfterGC
= plug
.testObjectCount
;
29 output
.innerHTML
+= "--- num test objects:<br>";
30 output
.innerHTML
+= "countAfterCreate == countOrig + 3? "
31 + ((countAfterCreate
== countOrig
+ 3) ? "PASS" : "FAIL")
33 output
.innerHTML
+= "countOrig == countAfterGC? "
34 + ((countOrig
== countAfterGC
) ? "PASS" : "FAIL")
36 output
.innerHTML
+= "<br>";
38 // Test that the object refcount returns to normal after JS references
40 var testObj
= plug
.testObject
;
41 var refOrig
= testObj
.refCount
;
42 var o1
= plug
.testObject
;
43 var o2
= plug
.testObject
;
44 var o3
= plug
.testObject
;
45 var refAfterGet
= testObj
.refCount
;
48 var refAfterGetGC
= testObj
.refCount
;
50 // Test that calling NPN_Invoke with our object as a parameter returns
51 // our refcount to normal (may require a GC).
52 plug
.testPassTestObject("noop", testObj
);
53 plug
.testPassTestObject("noop", testObj
);
54 plug
.testPassTestObject("noop", testObj
);
56 var refAfterPass
= testObj
.refCount
;
58 output
.innerHTML
+= "--- refcount on plug.testObject:<br>";
59 output
.innerHTML
+= "originally: " + refOrig
+ "<br>";
60 output
.innerHTML
+= "after GC: " + refAfterGetGC
+ "<br>";
61 output
.innerHTML
+= "after passing: " + refAfterPass
+ "<br>";
63 var success
= (countAfterGC
== countOrig
) && (refAfterPass
== refOrig
);
64 output
.innerHTML
+= (success
? "SUCCESS" : "FAILURE");
68 <body onload=
"runtest()">
70 Test that we can get an NPObject returned through a method on
73 Prints
"SUCCESS" on success,
"FAILURE" on failure.
75 <embed name=
"plug" type=
"application/x-webkit-test-netscape">
77 <div id=output
>FAILURE
</div>