1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/plugins/test/mochitest/test_bug784131.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,85 @@ 1.4 +<!doctype html> 1.5 +<html> 1.6 +<head> 1.7 + <title>Test for Bug 784131</title> 1.8 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 + <script type="application/javascript" src="utils.js"></script> 1.10 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.11 + 1.12 + <meta http-equiv="content-type" content="text/html; charset=utf-8"> 1.13 + <base href="chrome://browser/content/"> 1.14 +</head> 1.15 +<body> 1.16 + 1.17 +<script type="text/javascript"> 1.18 + setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); 1.19 +</script> 1.20 + 1.21 +<embed id="body" type="application/x-test"> 1.22 +<div> 1.23 + <embed id="nested" type="application/x-test"> 1.24 +</div> 1.25 + 1.26 +<script type="application/javascript"> 1.27 + function getObjectValue(obj) { 1.28 + try { 1.29 + return obj.getObjectValue(); 1.30 + } catch (e) { 1.31 + return null; 1.32 + } 1.33 + } 1.34 + SimpleTest.waitForExplicitFinish(); 1.35 + 1.36 + var body_embed = document.querySelector("embed#body"); 1.37 + var nested_embed = document.querySelector("embed#nested"); 1.38 + var nested_parent = nested_embed.parentNode; 1.39 + // Ensure plugins are spawned 1.40 + var body_obj = getObjectValue(body_embed); 1.41 + var nested_obj = getObjectValue(nested_embed); 1.42 + isnot(body_obj, null, "body plugin spawned"); 1.43 + isnot(nested_obj, null, "nested plugin spawned"); 1.44 + // Display:none the plugin and the nested plugin's parent 1.45 + body_embed.style.display = "none"; 1.46 + nested_parent.style.display = "none"; 1.47 + body_embed.clientTop; 1.48 + nested_embed.clientTop; 1.49 + 1.50 + // Plugins should still be running the same instance 1.51 + ok(body_embed.checkObjectValue(body_obj), "body plugin still running"); 1.52 + ok(nested_embed.checkObjectValue(nested_obj), "nested plugin still running"); 1.53 + // Spin event loop 1.54 + SimpleTest.executeSoon(function() { 1.55 + // Plugins should be stopped 1.56 + is(getObjectValue(body_embed), null, "body plugin gone"); 1.57 + is(getObjectValue(nested_embed), null, "nested plugin gone"); 1.58 + 1.59 + // Restart plugins... 1.60 + body_embed.style.display = "inherit"; 1.61 + nested_parent.style.display = "inherit"; 1.62 + 1.63 + // Ensure plugins are spawned 1.64 + var body_obj = getObjectValue(body_embed); 1.65 + var nested_obj = getObjectValue(nested_embed); 1.66 + isnot(body_obj, null, "body plugin spawned"); 1.67 + isnot(nested_obj, null, "nested plugin spawned"); 1.68 + 1.69 + // Take away frames again, flush layout, restore frames 1.70 + body_embed.style.display = "none"; 1.71 + nested_parent.style.display = "none"; 1.72 + body_embed.clientTop; 1.73 + nested_embed.clientTop; 1.74 + body_embed.style.display = "inherit"; 1.75 + nested_parent.style.display = "inherit"; 1.76 + body_embed.clientTop; 1.77 + nested_embed.clientTop; 1.78 + 1.79 + // Spin event loop, ensure plugin remains running 1.80 + SimpleTest.executeSoon(function() { 1.81 + ok(body_embed.checkObjectValue(body_obj), "body plugin still running"); 1.82 + ok(nested_embed.checkObjectValue(nested_obj), "nested plugin still running"); 1.83 + SimpleTest.finish(); 1.84 + }); 1.85 + }); 1.86 +</script> 1.87 +</body> 1.88 +</html>