summaryrefslogtreecommitdiffstats
path: root/dom/plugins/test/mochitest/test_bug784131.html
blob: ff2dd19c17d93e0df77920091b29025ae409dc79 (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
<!doctype html>
<html>
<head>
  <title>Test for Bug 784131</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript" src="plugin-utils.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>

  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <base href="chrome://browser/content/">
</head>
<body>

<script type="text/javascript">
  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
</script>

<embed id="body" type="application/x-test">
<div>
  <embed id="nested" type="application/x-test">
</div>

<script type="application/javascript">
  function getObjectValue(obj) {
    try {
      return obj.getObjectValue();
    } catch (e) {
      return null;
    }
  }
  SimpleTest.waitForExplicitFinish();

  var body_embed = document.querySelector("embed#body");
  var nested_embed = document.querySelector("embed#nested");
  var nested_parent = nested_embed.parentNode;
  // Ensure plugins are spawned
  var body_obj = getObjectValue(body_embed);
  var nested_obj = getObjectValue(nested_embed);
  isnot(body_obj, null, "body plugin spawned");
  isnot(nested_obj, null, "nested plugin spawned");
  // Display:none the plugin and the nested plugin's parent
  body_embed.style.display = "none";
  nested_parent.style.display = "none";
  body_embed.clientTop;
  nested_embed.clientTop;

  // Plugins should still be running the same instance
  ok(body_embed.checkObjectValue(body_obj), "body plugin still running");
  ok(nested_embed.checkObjectValue(nested_obj), "nested plugin still running");
  // Spin event loop
  SimpleTest.executeSoon(function() {
    // Plugins should be stopped
    is(getObjectValue(body_embed), null, "body plugin gone");
    is(getObjectValue(nested_embed), null, "nested plugin gone");

    // Restart plugins...
    body_embed.style.display = "inherit";
    nested_parent.style.display = "inherit";

    // Ensure plugins are spawned
    var body_obj = getObjectValue(body_embed);
    var nested_obj = getObjectValue(nested_embed);
    isnot(body_obj, null, "body plugin spawned");
    isnot(nested_obj, null, "nested plugin spawned");

    // Take away frames again, flush layout, restore frames
    body_embed.style.display = "none";
    nested_parent.style.display = "none";
    body_embed.clientTop;
    nested_embed.clientTop;
    body_embed.style.display = "inherit";
    nested_parent.style.display = "inherit";
    body_embed.clientTop;
    nested_embed.clientTop;

    // Spin event loop, ensure plugin remains running
    SimpleTest.executeSoon(function() {
      ok(body_embed.checkObjectValue(body_obj), "body plugin still running");
      ok(nested_embed.checkObjectValue(nested_obj), "nested plugin still running");
      SimpleTest.finish();
    });
  });
</script>
</body>
</html>