summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/plugins/browser_CTP_iframe.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/base/content/test/plugins/browser_CTP_iframe.js')
-rw-r--r--browser/base/content/test/plugins/browser_CTP_iframe.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/browser/base/content/test/plugins/browser_CTP_iframe.js b/browser/base/content/test/plugins/browser_CTP_iframe.js
new file mode 100644
index 000000000..58565559f
--- /dev/null
+++ b/browser/base/content/test/plugins/browser_CTP_iframe.js
@@ -0,0 +1,48 @@
+var rootDir = getRootDirectory(gTestPath);
+const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
+
+add_task(function* () {
+ registerCleanupFunction(function () {
+ clearAllPluginPermissions();
+ setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
+ setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
+ Services.prefs.clearUserPref("plugins.click_to_play");
+ Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
+ gBrowser.removeCurrentTab();
+ window.focus();
+ });
+});
+
+add_task(function* () {
+ Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
+
+ gBrowser.selectedTab = gBrowser.addTab();
+
+ Services.prefs.setBoolPref("plugins.click_to_play", true);
+ setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
+
+ yield promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_iframe.html");
+
+ // Tests that the overlays are visible and actionable if the plugin is in an iframe.
+
+ yield ContentTask.spawn(gBrowser.selectedBrowser, null, function* () {
+ let frame = content.document.getElementById("frame");
+ let doc = frame.contentDocument;
+ let plugin = doc.getElementById("test");
+ let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
+ Assert.ok(plugin && overlay.classList.contains("visible"),
+ "Test 1, Plugin overlay should exist, not be hidden");
+
+ let closeIcon = doc.getAnonymousElementByAttribute(plugin, "anonid", "closeIcon");
+ let bounds = closeIcon.getBoundingClientRect();
+ let left = (bounds.left + bounds.right) / 2;
+ let top = (bounds.top + bounds.bottom) / 2;
+ let utils = doc.defaultView.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+ .getInterface(Components.interfaces.nsIDOMWindowUtils);
+ utils.sendMouseEvent("mousedown", left, top, 0, 1, 0, false, 0, 0);
+ utils.sendMouseEvent("mouseup", left, top, 0, 1, 0, false, 0, 0);
+ Assert.ok(!overlay.classList.contains("visible"),
+ "Test 1, Plugin overlay should exist, be hidden");
+ });
+});
+