summaryrefslogtreecommitdiffstats
path: root/dom/plugins/test/mochitest/browser_tabswitchbetweenplugins.js
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/browser_tabswitchbetweenplugins.js
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/browser_tabswitchbetweenplugins.js')
-rw-r--r--dom/plugins/test/mochitest/browser_tabswitchbetweenplugins.js105
1 files changed, 105 insertions, 0 deletions
diff --git a/dom/plugins/test/mochitest/browser_tabswitchbetweenplugins.js b/dom/plugins/test/mochitest/browser_tabswitchbetweenplugins.js
new file mode 100644
index 000000000..d1994c209
--- /dev/null
+++ b/dom/plugins/test/mochitest/browser_tabswitchbetweenplugins.js
@@ -0,0 +1,105 @@
+var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
+
+// tests that we get plugin updates when we flip between tabs that
+// have the same plugin in the same position in the page.
+
+add_task(function* () {
+ let result, tabSwitchedPromise;
+
+ setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
+
+ let testTab = gBrowser.selectedTab;
+ let pluginTab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_test.html");
+ let pluginTab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, gTestRoot + "plugin_test.html");
+
+ result = yield ContentTask.spawn(pluginTab1.linkedBrowser, null, function*() {
+ let doc = content.document;
+ let plugin = doc.getElementById("testplugin");
+ return !!plugin;
+ });
+ is(result, true, "plugin1 is loaded");
+
+ result = yield ContentTask.spawn(pluginTab2.linkedBrowser, null, function*() {
+ let doc = content.document;
+ let plugin = doc.getElementById("testplugin");
+ return !!plugin;
+ });
+ is(result, true, "plugin2 is loaded");
+
+ // plugin tab 2 should be selected
+ is(gBrowser.selectedTab == pluginTab2, true, "plugin2 is selected");
+
+ result = yield ContentTask.spawn(pluginTab1.linkedBrowser, null, function*() {
+ let doc = content.document;
+ let plugin = doc.getElementById("testplugin");
+ return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
+ });
+ is(result, false, "plugin1 is hidden");
+
+ result = yield ContentTask.spawn(pluginTab2.linkedBrowser, null, function*() {
+ let doc = content.document;
+ let plugin = doc.getElementById("testplugin");
+ return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
+ });
+ is(result, true, "plugin2 is visible");
+
+ // select plugin1 tab
+ tabSwitchedPromise = waitTabSwitched();
+ gBrowser.selectedTab = pluginTab1;
+ yield tabSwitchedPromise;
+
+ result = yield ContentTask.spawn(pluginTab1.linkedBrowser, null, function*() {
+ let doc = content.document;
+ let plugin = doc.getElementById("testplugin");
+ return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
+ });
+ is(result, true, "plugin1 is visible");
+
+ result = yield ContentTask.spawn(pluginTab2.linkedBrowser, null, function*() {
+ let doc = content.document;
+ let plugin = doc.getElementById("testplugin");
+ return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
+ });
+ is(result, false, "plugin2 is hidden");
+
+ // select plugin2 tab
+ tabSwitchedPromise = waitTabSwitched();
+ gBrowser.selectedTab = pluginTab2;
+ yield tabSwitchedPromise;
+
+ result = yield ContentTask.spawn(pluginTab1.linkedBrowser, null, function*() {
+ let doc = content.document;
+ let plugin = doc.getElementById("testplugin");
+ return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
+ });
+ is(result, false, "plugin1 is hidden");
+
+ result = yield ContentTask.spawn(pluginTab2.linkedBrowser, null, function*() {
+ let doc = content.document;
+ let plugin = doc.getElementById("testplugin");
+ return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
+ });
+ is(result, true, "plugin2 is visible");
+
+ // select test tab
+ tabSwitchedPromise = waitTabSwitched();
+ gBrowser.selectedTab = testTab;
+ yield tabSwitchedPromise;
+
+ result = yield ContentTask.spawn(pluginTab1.linkedBrowser, null, function*() {
+ let doc = content.document;
+ let plugin = doc.getElementById("testplugin");
+ return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
+ });
+ is(result, false, "plugin1 is hidden");
+
+ result = yield ContentTask.spawn(pluginTab2.linkedBrowser, null, function*() {
+ let doc = content.document;
+ let plugin = doc.getElementById("testplugin");
+ return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible();
+ });
+ is(result, false, "plugin2 is hidden");
+
+ gBrowser.removeTab(pluginTab1);
+ gBrowser.removeTab(pluginTab2);
+});