diff options
Diffstat (limited to 'browser/base/content/test/plugins/browser_CTP_outsideScrollArea.js')
-rw-r--r-- | browser/base/content/test/plugins/browser_CTP_outsideScrollArea.js | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/browser/base/content/test/plugins/browser_CTP_outsideScrollArea.js b/browser/base/content/test/plugins/browser_CTP_outsideScrollArea.js new file mode 100644 index 0000000000..ed68a27688 --- /dev/null +++ b/browser/base/content/test/plugins/browser_CTP_outsideScrollArea.js @@ -0,0 +1,122 @@ +var rootDir = getRootDirectory(gTestPath); +const gTestRoot = rootDir.replace( + "chrome://mochitests/content/", + "http://127.0.0.1:8888/" +); +var gTestBrowser = null; +var gPluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost); + +add_task(async function() { + registerCleanupFunction(function() { + clearAllPluginPermissions(); + Services.prefs.clearUserPref("extensions.blocklist.suppressUI"); + gBrowser.removeCurrentTab(); + window.focus(); + gTestBrowser = null; + }); +}); + +add_task(async function() { + Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true); + + let newTab = BrowserTestUtils.addTab(gBrowser); + gBrowser.selectedTab = newTab; + gTestBrowser = gBrowser.selectedBrowser; +}); + +// Test that the plugin "blockall" overlay is always present but hidden, +// regardless of whether the overlay is fully, partially, or not in the +// viewport. + +// fully in viewport +add_task(async function() { + await promiseTabLoadEvent( + gBrowser.selectedTab, + gTestRoot + "plugin_outsideScrollArea.html" + ); + + await SpecialPowers.spawn(gTestBrowser, [], async function() { + let doc = content.document; + let p = doc.createElement("embed"); + + p.setAttribute("id", "test"); + p.setAttribute("type", "application/x-shockwave-flash"); + p.style.left = "0"; + p.style.bottom = "200px"; + + doc.getElementById("container").appendChild(p); + }); + + // Work around for delayed PluginBindingAttached + await promiseUpdatePluginBindings(gTestBrowser); + + await SpecialPowers.spawn(gTestBrowser, [], async function() { + let plugin = content.document.getElementById("test"); + let overlay = plugin.openOrClosedShadowRoot.getElementById("main"); + Assert.ok(overlay); + Assert.ok(!overlay.getAttribute("visible")); + Assert.ok(overlay.getAttribute("blockall") == "blockall"); + }); +}); + +// partially in viewport +add_task(async function() { + await promiseTabLoadEvent( + gBrowser.selectedTab, + gTestRoot + "plugin_outsideScrollArea.html" + ); + + await SpecialPowers.spawn(gTestBrowser, [], async function() { + let doc = content.document; + let p = doc.createElement("embed"); + + p.setAttribute("id", "test"); + p.setAttribute("type", "application/x-shockwave-flash"); + p.style.left = "0"; + p.style.bottom = "-410px"; + + doc.getElementById("container").appendChild(p); + }); + + // Work around for delayed PluginBindingAttached + await promiseUpdatePluginBindings(gTestBrowser); + + await SpecialPowers.spawn(gTestBrowser, [], async function() { + let plugin = content.document.getElementById("test"); + let overlay = plugin.openOrClosedShadowRoot.getElementById("main"); + Assert.ok(overlay); + Assert.ok(!overlay.getAttribute("visible")); + Assert.ok(overlay.getAttribute("blockall") == "blockall"); + }); +}); + +// not in viewport +add_task(async function() { + await promiseTabLoadEvent( + gBrowser.selectedTab, + gTestRoot + "plugin_outsideScrollArea.html" + ); + + await SpecialPowers.spawn(gTestBrowser, [], async function() { + let doc = content.document; + let p = doc.createElement("embed"); + + p.setAttribute("id", "test"); + p.setAttribute("type", "application/x-shockwave-flash"); + p.style.left = "-600px"; + p.style.bottom = "0"; + + doc.getElementById("container").appendChild(p); + }); + + // Work around for delayed PluginBindingAttached + await promiseUpdatePluginBindings(gTestBrowser); + + await SpecialPowers.spawn(gTestBrowser, [], async function() { + let plugin = content.document.getElementById("test"); + let overlay = plugin.openOrClosedShadowRoot.getElementById("main"); + Assert.ok(overlay); + Assert.ok(!overlay.getAttribute("visible")); + Assert.ok(overlay.getAttribute("blockall") == "blockall"); + }); +}); |