diff --git a/browser/base/content/test/plugins/browser.ini b/browser/base/content/test/plugins/browser.ini index 4da3d033b51c..f80616160ff4 100644 --- a/browser/base/content/test/plugins/browser.ini +++ b/browser/base/content/test/plugins/browser.ini @@ -26,6 +26,7 @@ support-files = plugin_hidden_to_visible.html plugin_iframe.html plugin_outsideScrollArea.html + plugin_overlay_styles.html plugin_overlayed.html plugin_positioned.html plugin_simple_blank.swf @@ -71,6 +72,7 @@ tags = blocklist tags = blocklist [browser_CTP_outsideScrollArea.js] tags = blocklist +[browser_CTP_overlay_styles.js] [browser_CTP_remove_navigate.js] tags = blocklist [browser_CTP_resize.js] diff --git a/browser/base/content/test/plugins/browser_CTP_notificationBar.js b/browser/base/content/test/plugins/browser_CTP_notificationBar.js index 14122b04eb27..9ded20213bc8 100644 --- a/browser/base/content/test/plugins/browser_CTP_notificationBar.js +++ b/browser/base/content/test/plugins/browser_CTP_notificationBar.js @@ -82,8 +82,8 @@ add_task(async function() { let doc = content.document; let plugin = doc.getElementById("test"); let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); - Assert.ok(!overlay || !overlay.classList.contains("visible"), - "Test 3b, overlay should be hidden."); + Assert.ok(!overlay || overlay.getAttribute("sizing") == "blank", + "Test 3b, overlay should be blank."); }); }); @@ -109,8 +109,8 @@ add_task(async function() { let doc = content.document; let plugin = doc.getElementById("test"); let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); - Assert.ok(!overlay || !overlay.classList.contains("visible"), - "Test 4b, overlay should be hidden."); + Assert.ok(!overlay || overlay.getAttribute("sizing") == "blank", + "Test 4b, overlay should be blank."); }); }); diff --git a/browser/base/content/test/plugins/browser_CTP_outsideScrollArea.js b/browser/base/content/test/plugins/browser_CTP_outsideScrollArea.js index 88a65b475c34..35205ff75b79 100644 --- a/browser/base/content/test/plugins/browser_CTP_outsideScrollArea.js +++ b/browser/base/content/test/plugins/browser_CTP_outsideScrollArea.js @@ -58,7 +58,7 @@ add_task(async function() { let doc = content.document; let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); Assert.ok(overlay && overlay.classList.contains("visible") && - !overlay.classList.contains("minimal"), + overlay.getAttribute("sizing") != "blank", "Test 2, overlay should be visible."); }); }); @@ -88,7 +88,7 @@ add_task(async function() { let doc = content.document; let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); Assert.ok(overlay && overlay.classList.contains("visible") && - !overlay.classList.contains("minimal"), + overlay.getAttribute("sizing") != "blank", "Test 3, overlay should be visible."); }); }); @@ -116,7 +116,7 @@ add_task(async function() { let plugin = content.document.getElementById("test"); let doc = content.document; let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); - Assert.ok(!overlay || !overlay.classList.contains("visible"), - "Test 4, overlay should be hidden."); + Assert.ok(!overlay || overlay.getAttribute("sizing") == "blank", + "Test 4, overlay should be blank."); }); }); diff --git a/browser/base/content/test/plugins/browser_CTP_overlay_styles.js b/browser/base/content/test/plugins/browser_CTP_overlay_styles.js new file mode 100644 index 000000000000..3e33f87c01d6 --- /dev/null +++ b/browser/base/content/test/plugins/browser_CTP_overlay_styles.js @@ -0,0 +1,93 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +/* This test ensures that the click-to-play "Activate Plugin" overlay + * is shown in the right style (which is dependent on its size). + */ + +const rootDir = getRootDirectory(gTestPath); +const gTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); + +var gTestBrowser = null; + +const gTestcases = { + + // 10x10 + testcase1: { + sizing: "blank", + notext: null, + }, + + // 40x40 + testcase2: { + sizing: "tiny", + notext: "notext", + }, + + // 100x70 + testcase3: { + sizing: "reduced", + notext: "notext", + }, + + // 200x200 + testcase4: { + sizing: null, + notext: "notext", + }, + + // 300x300 + testcase5: { + sizing: null, + notext: null, + }, +} + + +add_task(async function() { + registerCleanupFunction(function() { + clearAllPluginPermissions(); + setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in"); + gBrowser.removeCurrentTab(); + gTestBrowser = null; + }); +}); + +add_task(async function() { + gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser); + gTestBrowser = gBrowser.selectedBrowser; + + setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in"); + + let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); + ok(!popupNotification, "Sanity check, should not have a click-to-play notification"); + + await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_overlay_styles.html"); + + // Work around for delayed PluginBindingAttached + await promiseUpdatePluginBindings(gTestBrowser); + + await ContentTask.spawn(gTestBrowser, gTestcases, async function(testcases) { + let doc = content.document; + + for (let testcaseId of Object.keys(testcases)) { + let plugin = doc.querySelector(`#${testcaseId} > object`); + let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); + Assert.ok(overlay, `overlay exists in ${testcaseId}`); + + let expectations = testcases[testcaseId]; + + Assert.ok(overlay.classList.contains("visible") == true, + `The expected visibility is correct in ${testcaseId}`); + + Assert.ok(overlay.getAttribute("sizing") == expectations.sizing, + `The expected sizing is correct in ${testcaseId}`); + + Assert.ok(overlay.getAttribute("notext") == expectations.notext, + `The expected notext is correct in ${testcaseId}`); + } + }); +}); diff --git a/browser/base/content/test/plugins/browser_CTP_resize.js b/browser/base/content/test/plugins/browser_CTP_resize.js index 239ff82aeaa8..90745a166512 100644 --- a/browser/base/content/test/plugins/browser_CTP_resize.js +++ b/browser/base/content/test/plugins/browser_CTP_resize.js @@ -46,8 +46,8 @@ add_task(async function() { let doc = content.document; let plugin = doc.getElementById("test"); let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); - Assert.ok(!overlay || overlay.classList.contains("minimal"), - "Test 2, overlay should be hidden."); + Assert.ok(!overlay || overlay.getAttribute("sizing") == "blank", + "Test 2, overlay should be blank."); }); }); @@ -64,8 +64,8 @@ add_task(async function() { let doc = content.document; let plugin = doc.getElementById("test"); let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); - Assert.ok(!overlay || overlay.classList.contains("minimal"), - "Test 3, overlay should be hidden."); + Assert.ok(!overlay || overlay.getAttribute("sizing") == "blank", + "Test 3, overlay should be blank."); }); }); @@ -84,7 +84,7 @@ add_task(async function() { let doc = content.document; let plugin = doc.getElementById("test"); let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); - Assert.ok(overlay && overlay.classList.contains("visible"), + Assert.ok(overlay && overlay.getAttribute("sizing") != "blank", "Test 4, overlay should be visible."); }); }); @@ -104,8 +104,8 @@ add_task(async function() { let doc = content.document; let plugin = doc.getElementById("test"); let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); - Assert.ok(!overlay || overlay.classList.contains("minimal"), - "Test 5, overlay should be hidden."); + Assert.ok(!overlay || overlay.getAttribute("sizing") == "blank", + "Test 5, overlay should be blank."); }); }); @@ -124,7 +124,7 @@ add_task(async function() { let doc = content.document; let plugin = doc.getElementById("test"); let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); - Assert.ok(overlay && overlay.classList.contains("visible"), + Assert.ok(overlay && overlay.getAttribute("sizing") != "blank", "Test 6, overlay should be visible."); }); }); diff --git a/browser/base/content/test/plugins/browser_CTP_shouldShowOverlay.js b/browser/base/content/test/plugins/browser_CTP_shouldShowOverlay.js index 6af674a0e5b2..479cd47382c2 100644 --- a/browser/base/content/test/plugins/browser_CTP_shouldShowOverlay.js +++ b/browser/base/content/test/plugins/browser_CTP_shouldShowOverlay.js @@ -7,6 +7,12 @@ /* This test ensures that the click-to-play "Activate Plugin" overlay * is shown when expected. * All testcases are in the plugin_shouldShowOverlay.html file. + * + * Note: Technically, the overlay is *always* shown. When this test was + * originally written, the meaning of "shown" was "shown with the contents", + * as opposed to "shown as blank". The behavior hasn't changed, but the naming + * has: now, a "shown as blank" overlay no longer receives a ".hidden" class. + * It receives a sizing="blank" attribute. */ var rootDir = getRootDirectory(gTestPath); @@ -49,7 +55,7 @@ add_task(async function() { Assert.ok(overlay, `overlay exists in ${testcase.id}`); let expectedVisibility = (testcase.getAttribute("shouldshow") == "true"); - Assert.ok(overlay.classList.contains("visible") == expectedVisibility, + Assert.ok((overlay.getAttribute("sizing") != "blank") == expectedVisibility, `The expected visibility is correct in ${testcase.id}`); } }) diff --git a/browser/base/content/test/plugins/plugin_overlay_styles.html b/browser/base/content/test/plugins/plugin_overlay_styles.html new file mode 100644 index 000000000000..500045d16e4c --- /dev/null +++ b/browser/base/content/test/plugins/plugin_overlay_styles.html @@ -0,0 +1,29 @@ + + +
+ + + + +