summaryrefslogtreecommitdiffstats
path: root/dom/plugins/test/mochitest/test_visibility.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/plugins/test/mochitest/test_visibility.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/plugins/test/mochitest/test_visibility.html')
-rw-r--r--dom/plugins/test/mochitest/test_visibility.html100
1 files changed, 100 insertions, 0 deletions
diff --git a/dom/plugins/test/mochitest/test_visibility.html b/dom/plugins/test/mochitest/test_visibility.html
new file mode 100644
index 000000000..943fddaf4
--- /dev/null
+++ b/dom/plugins/test/mochitest/test_visibility.html
@@ -0,0 +1,100 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Test whether windowless plugins receive correct visible/invisible notifications.</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+
+ <style>
+ .hidden { visibility: hidden; }
+ </style>
+
+<body onload="startTest()">
+ <p id="display"></p>
+
+ <script type="application/javascript" src="plugin-utils.js"></script>
+ <script type="application/javascript">
+ SimpleTest.waitForExplicitFinish();
+ SimpleTest.requestFlakyTimeout("untriaged");
+ setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
+
+ var didPaint = function() {};
+
+ function startTest() {
+ if (p.getPaintCount() < 1) {
+ setTimeout(startTest, 0);
+ return;
+ }
+
+ didPaint = function() {
+ ok(false, "Plugin should not paint until it is visible!");
+ };
+
+ ok(!p.isVisible(), "Plugin should not be visible.");
+ paintCountIs(p, 0, "Plugin should not have painted.");
+
+ didPaint = part2;
+
+ p.style.visibility = 'visible';
+ }
+
+ function part2() {
+ ok(p.isVisible(), "Plugin should now be visible.");
+ paintCountIs(p, 1, "Plugin should have painted once.");
+
+ didPaint = part3;
+
+ p.setColor('FF0000FF'); // this causes an invalidate/repaint
+ }
+
+ const kTimeout = 5000; // 5 seconds
+ var part4GiveUp;
+ var part4Interval;
+
+ function part3() {
+ ok(p.isVisible(), "Plugin should still be visible.");
+ paintCountIs(p, 2, "Plugin should have painted twice.");
+
+ didPaint = function() {
+ ok(false, "Plugin should not paint when it is invisible.");
+ };
+
+ p.style.visibility = 'hidden';
+
+ part4GiveUp = Date.now() + kTimeout;
+ part4Interval = setInterval(part4, 100);
+ }
+
+ function part4() {
+ if (p.isVisible()) {
+ if (Date.now() < part4GiveUp)
+ return;
+
+ ok(false, "Plugin never became invisible in part4.");
+ SimpleTest.finish();
+ return;
+ }
+
+ clearInterval(part4Interval);
+
+ ok(true, "Plugin became invisible again.");
+ p.setColor('FF00FF00');
+ setTimeout(SimpleTest.finish, 500);
+ // wait to make sure we don't actually paint
+ }
+
+ function inPaint() {
+ // We're actually in the middle of painting the plugin so don't do anything
+ // complex here, for the sake of cases where async plugin painting isn't
+ // enabled yet
+ setTimeout(didPaint, 0);
+ // Don't run that didPaint callback again
+ didPaint = function() {};
+ }
+ </script>
+
+ <embed id="theplugin" class="hidden" type="application/x-test" drawmode="solid" color="FFFF0000" paintscript="inPaint()"></embed>
+
+ <script type="application/javascript">
+ var p = document.getElementById('theplugin');
+ </script>