blob: 1f72026b0233135bbc46d9768565de5ec3013d2f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
<script>
function noop(x) {
}
function doGC() {
if (window.gc) {
// GC twice to make sure everything is cleaned up.
for (var i = 0; i < 4; i++) {
window.gc();
}
}
}
function runtest() {
if (window.layoutTestController)
layoutTestController.dumpAsText();
doGC();
var plug1 = document.getElementById("plug1");
var plug2 = document.getElementById("plug2");
var output = document.getElementById("output");
output.innerHTML = "";
var testObj1 = plug1.testObject;
var testObj2 = plug2.testObject;
var successCount = 0;
// Verify we can access each object.
if (testObj1.foo == "foo") {
successCount++;
output.innerHTML += "Got testObj1 property<br>";
}
if (testObj2.foo == "foo") {
successCount++;
output.innerHTML += "Got testObj2 property<br>";
}
// Now remove the first plugin
plug1.parentNode.removeChild(plug1);
try {
if (testObj1.foo == "foo") {
output.innerHTML = "Accessed nuked object!<br>";
}
} catch (e) {
if (e instanceof ReferenceError)
successCount++;
}
try {
if (testObj2.foo == "foo") {
successCount++;
output.innerHTML += "Got testObj2 property<br>";
}
} catch(e) {
output.inerHTML += "Reference error accessing live object: " + e;
}
// Now remove the second plugin
plug2.parentNode.removeChild(plug2);
try {
if (testObj2.foo == "foo") {
output.innerHTML = "Accessed nuked object!<br>";
}
} catch (e) {
if (e instanceof ReferenceError)
successCount++;
}
var success = (successCount == 5);
output.innerHTML += (success ? "SUCCESS" : "FAILURE");
}
</script>
<body onload="runtest()">
Test that we can create two plugins, and independently clean each.
Prints "SUCCESS" on success, "FAILURE" on failure.
<embed id="plug1" type="application/x-webkit-test-netscape">
<embed id="plug2" type="application/x-webkit-test-netscape">
<div id=output>FAILURE</div>
</body>
|