Bug 1409148 - Add test to ensure that the plugin overlay is displayed in the correct style. r=johannh

MozReview-Commit-ID: Hn9HtnJvbyC
This commit is contained in:
Felipe Gomes committed 2017-11-10 14:05:05 -02:00
1 parent 2894bd6bc4
commit fe951d8b11
7 files changed
+147 -17

No files matched your search

@@ -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]
@@ -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.");
});
});
@@ -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.");
});
});
@@ -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}`);
}
});
});
@@ -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.");
});
});
@@ -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}`);
}
})
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div id="testcase1" class="testcase">
<object width="10" height="10" type="application/x-test"></object>
</div>
<div id="testcase2" class="testcase">
<object width="40" height="40" type="application/x-test"></object>
</div>
<div id="testcase3" class="testcase">
<object width="100" height="70" type="application/x-test"></object>
</div>
<div id="testcase4" class="testcase">
<object width="200" height="200" type="application/x-test"></object>
</div>
<div id="testcase5" class="testcase">
<object width="300" height="300" type="application/x-test"></object>
</div>
</body>
</html>