summaryrefslogtreecommitdiffstats
path: root/dom/plugins/test/mochitest/xulbrowser_plugin_visibility.xul
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/xulbrowser_plugin_visibility.xul
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/xulbrowser_plugin_visibility.xul')
-rw-r--r--dom/plugins/test/mochitest/xulbrowser_plugin_visibility.xul139
1 files changed, 139 insertions, 0 deletions
diff --git a/dom/plugins/test/mochitest/xulbrowser_plugin_visibility.xul b/dom/plugins/test/mochitest/xulbrowser_plugin_visibility.xul
new file mode 100644
index 000000000..d08730520
--- /dev/null
+++ b/dom/plugins/test/mochitest/xulbrowser_plugin_visibility.xul
@@ -0,0 +1,139 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ orient="vertical">
+
+ <tabbox id="tabbox" flex="1">
+ <tabs>
+ <tab id="tab1" label="Tab 1" />
+ <tab id="tab2" label="Tab 2" />
+ </tabs>
+ <tabpanels flex="1">
+ <browser id="browser1" type="content-primary" flex="1" src="about:blank"/>
+ <browser id="browser2" type="content-primary" flex="1" src="about:blank"/>
+ </tabpanels>
+ </tabbox>
+ <script type="application/javascript" src="plugin-utils.js"/>
+ <script type="application/javascript"><![CDATA[
+ const ok = window.opener.wrappedJSObject.ok;
+ const is = window.opener.wrappedJSObject.is;
+ const done = window.opener.wrappedJSObject.done;
+ const SimpleTest = window.opener.wrappedJSObject.SimpleTest;
+
+ const nsIWebProgress = Components.interfaces.nsIWebProgress;
+ const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
+
+ const kURI = 'http://mochi.test:8888/chrome/dom/plugins/test/mochitest/plugin_visibility_loader.html';
+
+ function ProgressListener() {
+ }
+ ProgressListener.prototype.onStateChange =
+ function(progress, req, flags, status) {
+ if ((flags & nsIWebProgressListener.STATE_IS_WINDOW) &&
+ (flags & nsIWebProgressListener.STATE_STOP))
+ browserLoaded();
+ };
+ ProgressListener.prototype.QueryInterface = function(iid) {
+ if (iid.equals(nsIWebProgressListener) ||
+ iid.equals(Components.interfaces.nsISupportsWeakReference))
+ return this;
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ };
+
+ var loadCount = 0;
+ function browserLoaded() {
+ ++loadCount;
+ if (2 == loadCount)
+ startTest();
+ }
+
+ var tabbox = document.getElementById('tabbox');
+ var browser1 = document.getElementById('browser1');
+ var browser2 = document.getElementById('browser2');
+
+ var progressListener1, progressListener2;
+
+ function setup() {
+ progressListener1 = new ProgressListener();
+ browser1.addProgressListener(progressListener1, nsIWebProgress.NOTIFY_STATE_WINDOW);
+ browser1.loadURI(kURI, null, null);
+ progressListener2 = new ProgressListener();
+ browser2.addProgressListener(progressListener2, nsIWebProgress.NOTIFY_STATE_WINDOW);
+ browser2.loadURI(kURI, null, null);
+ }
+
+ window.addEventListener("load", setup, false);
+
+ var plugin1, plugin2;
+
+ const kTimeout = 5000; // 5 seconds
+ var paintGiveUp;
+ var paintInterval;
+
+ function startTest() {
+ plugin1 = browser1.contentDocument.getElementById('p').wrappedJSObject;
+ plugin2 = browser2.contentDocument.getElementById('p').wrappedJSObject;
+
+ paintGiveUp = Date.now() + kTimeout;
+ paintInterval = setInterval(waitForPaint, 100);
+ }
+
+ function waitForPaint() {
+ if (!plugin1.isVisible()) {
+ if (Date.now() < paintGiveUp)
+ return;
+
+ ok(false, "Plugin in tab 1 never became visible.");
+ done();
+ return;
+ }
+
+ clearInterval(paintInterval);
+
+ ok(true, "Plugin in tab 1 should be visible.");
+ paintCountIs(plugin1, 1, "Plugin in tab 1 should have painted once.");
+
+ ok(!plugin2.isVisible(), "Plugin in tab 2 should not be visible.");
+ paintCountIs(plugin2, 0, "Plugin in tab 2 should not have painted.");
+
+ tabbox.selectedIndex = 1;
+ paintGiveUp = Date.now() + kTimeout;
+ paintInterval = setInterval(part2, 100);
+ }
+
+ function part2() {
+ if (!plugin2.isVisible()) {
+ if (Date.now() < paintGiveUp)
+ return;
+
+ ok(false, "Plugin in tab 2 never became visible.");
+ done();
+ return;
+ }
+
+ clearInterval(paintInterval);
+
+ ok(true, "Plugin in tab 2 became visible.");
+ paintCountIs(plugin2, 1, "Plugin in tab 2 should have painted once.");
+
+ ok(!plugin1.isVisible(), "Plugin in tab 1 should have become invisible.");
+ paintCountIs(plugin1, 1, "Plugin in tab 1 should have painted once.");
+
+ // Setcolor invalidates
+ plugin1.setColor('FF00FF00');
+ plugin2.setColor('FF00FF00');
+
+ setTimeout(part3, 500);
+ }
+
+ function part3() {
+ paintCountIs(plugin1, 1,
+ "Plugin in tab 1 should not have repainted after invalidate.");
+ paintCountIs(plugin2, 2,
+ "Plugin in tab 2 should have repainted after invalidate.");
+ done();
+ }
+ ]]></script>
+
+</window>