mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 977543 - CTP overlay is not displayed for iframes/embedded videos. r=jaws
This commit is contained in:
parent
0190343c4e
commit
37cbefd309
@ -130,7 +130,7 @@ var gPluginHandler = {
|
||||
return false;
|
||||
}
|
||||
|
||||
let contentWindow = plugin.ownerDocument.defaultView.top;
|
||||
let contentWindow = plugin.ownerDocument.defaultView;
|
||||
let cwu = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils);
|
||||
|
||||
|
@ -22,6 +22,7 @@ support-files =
|
||||
plugin_clickToPlayDeny.html
|
||||
plugin_data_url.html
|
||||
plugin_hidden_to_visible.html
|
||||
plugin_iframe.html
|
||||
plugin_outsideScrollArea.html
|
||||
plugin_overlayed.html
|
||||
plugin_positioned.html
|
||||
@ -50,6 +51,7 @@ run-if = crashreporter
|
||||
[browser_CTP_data_urls.js]
|
||||
[browser_CTP_drag_drop.js]
|
||||
[browser_CTP_hide_overlay.js]
|
||||
[browser_CTP_iframe.js]
|
||||
[browser_CTP_multi_allow.js]
|
||||
[browser_CTP_nonplugins.js]
|
||||
[browser_CTP_notificationBar.js]
|
||||
|
102
browser/base/content/test/plugins/browser_CTP_iframe.js
Normal file
102
browser/base/content/test/plugins/browser_CTP_iframe.js
Normal file
@ -0,0 +1,102 @@
|
||||
let rootDir = getRootDirectory(gTestPath);
|
||||
const gTestRoot = rootDir;
|
||||
const gHttpTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
|
||||
|
||||
let gTestBrowser = null;
|
||||
let gNextTest = null;
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
registerCleanupFunction(function() {
|
||||
clearAllPluginPermissions();
|
||||
Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
|
||||
});
|
||||
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
|
||||
|
||||
let newTab = gBrowser.addTab();
|
||||
gBrowser.selectedTab = newTab;
|
||||
gTestBrowser = gBrowser.selectedBrowser;
|
||||
gTestBrowser.addEventListener("load", pageLoad, true);
|
||||
|
||||
Services.prefs.setBoolPref("plugins.click_to_play", true);
|
||||
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
|
||||
|
||||
prepareTest(delayTest(runAfterPluginBindingAttached(test1)), gHttpTestRoot + "plugin_iframe.html");
|
||||
}
|
||||
|
||||
function finishTest() {
|
||||
clearAllPluginPermissions();
|
||||
gTestBrowser.removeEventListener("load", pageLoad, true);
|
||||
gBrowser.removeCurrentTab();
|
||||
window.focus();
|
||||
finish();
|
||||
}
|
||||
|
||||
function pageLoad() {
|
||||
gNextTest();
|
||||
}
|
||||
|
||||
function prepareTest(nextTest, url) {
|
||||
gNextTest = nextTest;
|
||||
gTestBrowser.contentWindow.location = url;
|
||||
}
|
||||
|
||||
// Delay executing a test for one load event to wait for frame loads.
|
||||
function delayTest(nextTest) {
|
||||
return () => {
|
||||
gNextTest = nextTest;
|
||||
}
|
||||
}
|
||||
|
||||
// Due to layout being async, "PluginBindAttached" may trigger later.
|
||||
// This wraps a function to force a layout flush, thus triggering it,
|
||||
// and schedules the function execution so they're definitely executed
|
||||
// afterwards.
|
||||
function runAfterPluginBindingAttached(func) {
|
||||
return () => {
|
||||
let frame = gTestBrowser.contentDocument.getElementById("frame");
|
||||
let doc = frame.contentDocument;
|
||||
let elems = doc.getElementsByTagName('embed');
|
||||
if (elems.length < 1) {
|
||||
elems = doc.getElementsByTagName('object');
|
||||
}
|
||||
elems[0].clientTop;
|
||||
executeSoon(func);
|
||||
};
|
||||
}
|
||||
|
||||
// Tests that the overlays are visible and actionable if the plugin is in an iframe.
|
||||
function test1() {
|
||||
let frame = gTestBrowser.contentDocument.getElementById("frame");
|
||||
let doc = frame.contentDocument;
|
||||
let plugin = doc.getElementById("test");
|
||||
ok(plugin, "Test 1, Found plugin in page");
|
||||
|
||||
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
|
||||
ok(overlay.classList.contains("visible"), "Test 1, Plugin overlay should exist, not be hidden");
|
||||
let closeIcon = doc.getAnonymousElementByAttribute(plugin, "anonid", "closeIcon")
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(closeIcon, {}, frame.contentWindow);
|
||||
let condition = () => !overlay.classList.contains("visible");
|
||||
waitForCondition(condition, test2, "Test 1, Waited too long for the overlay to become invisible.");
|
||||
}
|
||||
|
||||
function test2() {
|
||||
prepareTest(delayTest(runAfterPluginBindingAttached(test3)), gHttpTestRoot + "plugin_iframe.html");
|
||||
}
|
||||
|
||||
function test3() {
|
||||
let frame = gTestBrowser.contentDocument.getElementById("frame");
|
||||
let doc = frame.contentDocument;
|
||||
let plugin = doc.getElementById("test");
|
||||
ok(plugin, "Test 3, Found plugin in page");
|
||||
|
||||
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
|
||||
ok(overlay.classList.contains("visible"), "Test 3, Plugin overlay should exist, not be hidden");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(plugin, {}, frame.contentWindow);
|
||||
let condition = () => PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
|
||||
waitForCondition(condition, finishTest, "Test 3, Waited too long for the doorhanger to pop up.");
|
||||
}
|
9
browser/base/content/test/plugins/plugin_iframe.html
Normal file
9
browser/base/content/test/plugins/plugin_iframe.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<iframe id="frame" with="400" height="400" src="plugin_test.html">
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user