dom/plugins/test/mochitest/test_bug784131.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:d10e38f1aff6
1 <!doctype html>
2 <html>
3 <head>
4 <title>Test for Bug 784131</title>
5 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
6 <script type="application/javascript" src="utils.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
8
9 <meta http-equiv="content-type" content="text/html; charset=utf-8">
10 <base href="chrome://browser/content/">
11 </head>
12 <body>
13
14 <script type="text/javascript">
15 setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
16 </script>
17
18 <embed id="body" type="application/x-test">
19 <div>
20 <embed id="nested" type="application/x-test">
21 </div>
22
23 <script type="application/javascript">
24 function getObjectValue(obj) {
25 try {
26 return obj.getObjectValue();
27 } catch (e) {
28 return null;
29 }
30 }
31 SimpleTest.waitForExplicitFinish();
32
33 var body_embed = document.querySelector("embed#body");
34 var nested_embed = document.querySelector("embed#nested");
35 var nested_parent = nested_embed.parentNode;
36 // Ensure plugins are spawned
37 var body_obj = getObjectValue(body_embed);
38 var nested_obj = getObjectValue(nested_embed);
39 isnot(body_obj, null, "body plugin spawned");
40 isnot(nested_obj, null, "nested plugin spawned");
41 // Display:none the plugin and the nested plugin's parent
42 body_embed.style.display = "none";
43 nested_parent.style.display = "none";
44 body_embed.clientTop;
45 nested_embed.clientTop;
46
47 // Plugins should still be running the same instance
48 ok(body_embed.checkObjectValue(body_obj), "body plugin still running");
49 ok(nested_embed.checkObjectValue(nested_obj), "nested plugin still running");
50 // Spin event loop
51 SimpleTest.executeSoon(function() {
52 // Plugins should be stopped
53 is(getObjectValue(body_embed), null, "body plugin gone");
54 is(getObjectValue(nested_embed), null, "nested plugin gone");
55
56 // Restart plugins...
57 body_embed.style.display = "inherit";
58 nested_parent.style.display = "inherit";
59
60 // Ensure plugins are spawned
61 var body_obj = getObjectValue(body_embed);
62 var nested_obj = getObjectValue(nested_embed);
63 isnot(body_obj, null, "body plugin spawned");
64 isnot(nested_obj, null, "nested plugin spawned");
65
66 // Take away frames again, flush layout, restore frames
67 body_embed.style.display = "none";
68 nested_parent.style.display = "none";
69 body_embed.clientTop;
70 nested_embed.clientTop;
71 body_embed.style.display = "inherit";
72 nested_parent.style.display = "inherit";
73 body_embed.clientTop;
74 nested_embed.clientTop;
75
76 // Spin event loop, ensure plugin remains running
77 SimpleTest.executeSoon(function() {
78 ok(body_embed.checkObjectValue(body_obj), "body plugin still running");
79 ok(nested_embed.checkObjectValue(nested_obj), "nested plugin still running");
80 SimpleTest.finish();
81 });
82 });
83 </script>
84 </body>
85 </html>

mercurial