dom/plugins/test/mochitest/test_bug784131.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial