Bug 980943 - Test that the overlay cannot be interacted with after the user closes the overlay. r=mconley

This commit is contained in:
Trevor Rowbotham 2015-07-08 11:58:00 +02:00
parent ab15650767
commit 8b8c872220

View File

@ -52,3 +52,43 @@ add_task(function* () {
});
ok(!overlayIsVisible, "overlay should be hidden.");
});
// Test that the overlay cannot be interacted with after the user closes the overlay
add_task(function* () {
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in");
yield promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
// Work around for delayed PluginBindingAttached
yield promiseUpdatePluginBindings(gBrowser.selectedBrowser);
let overlayHidden = yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
let doc = content.document;
let plugin = doc.getElementById("test");
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
let closeIcon = doc.getAnonymousElementByAttribute(plugin, "anonid", "closeIcon")
let closeIconBounds = closeIcon.getBoundingClientRect();
let overlayBounds = overlay.getBoundingClientRect();
let overlayLeft = (overlayBounds.left + overlayBounds.right) / 2;
let overlayTop = (overlayBounds.left + overlayBounds.right) / 2 ;
let closeIconLeft = (closeIconBounds.left + closeIconBounds.right) / 2;
let closeIconTop = (closeIconBounds.top + closeIconBounds.bottom) / 2;
let utils = content.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils);
// Simulate clicking on the close icon.
utils.sendMouseEvent("mousedown", closeIconLeft, closeIconTop, 0, 1, 0, false, 0, 0);
utils.sendMouseEvent("mouseup", closeIconLeft, closeIconTop, 0, 1, 0, false, 0, 0);
// Simulate clicking on the overlay.
utils.sendMouseEvent("mousedown", overlayLeft, overlayTop, 0, 1, 0, false, 0, 0);
utils.sendMouseEvent("mouseup", overlayLeft, overlayTop, 0, 1, 0, false, 0, 0);
return plugin && !overlay.classList.contains("visible");
});
let notification = PopupNotifications.getNotification("click-to-play-plugins");
ok(notification.dismissed, "No notification should be shown");
ok(overlayHidden, "Overlay should be hidden");
});