diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /browser/base/content/test/plugins/browser_CTP_drag_drop.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/base/content/test/plugins/browser_CTP_drag_drop.js')
-rw-r--r-- | browser/base/content/test/plugins/browser_CTP_drag_drop.js | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/browser/base/content/test/plugins/browser_CTP_drag_drop.js b/browser/base/content/test/plugins/browser_CTP_drag_drop.js new file mode 100644 index 000000000..7c9858e27 --- /dev/null +++ b/browser/base/content/test/plugins/browser_CTP_drag_drop.js @@ -0,0 +1,96 @@ +var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); +var gNewWindow = null; + +add_task(function* () { + registerCleanupFunction(function () { + clearAllPluginPermissions(); + setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in"); + setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in"); + Services.prefs.clearUserPref("plugins.click_to_play"); + Services.prefs.clearUserPref("extensions.blocklist.suppressUI"); + gNewWindow.close(); + gNewWindow = null; + window.focus(); + }); +}); + +add_task(function* () { + Services.prefs.setBoolPref("plugins.click_to_play", true); + Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true); + + gBrowser.selectedTab = gBrowser.addTab(); + + setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in"); + + yield promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html"); + + // Work around for delayed PluginBindingAttached + yield promiseUpdatePluginBindings(gBrowser.selectedBrowser); + + yield promisePopupNotification("click-to-play-plugins"); +}); + +add_task(function* () { + gNewWindow = gBrowser.replaceTabWithWindow(gBrowser.selectedTab); + + // XXX technically can't load fire before we get this call??? + yield waitForEvent(gNewWindow, "load", null, true); + + yield promisePopupNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser); + + ok(PopupNotifications.getNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser), "Should have a click-to-play notification in the tab in the new window"); + ok(!PopupNotifications.getNotification("click-to-play-plugins", gBrowser.selectedBrowser), "Should not have a click-to-play notification in the old window now"); +}); + +add_task(function* () { + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.swapBrowsersAndCloseOther(gBrowser.selectedTab, gNewWindow.gBrowser.selectedTab); + + yield promisePopupNotification("click-to-play-plugins", gBrowser.selectedBrowser); + + ok(PopupNotifications.getNotification("click-to-play-plugins", gBrowser.selectedBrowser), "Should have a click-to-play notification in the initial tab again"); + + // Work around for delayed PluginBindingAttached + yield promiseUpdatePluginBindings(gBrowser.selectedBrowser); +}); + +add_task(function* () { + yield promisePopupNotification("click-to-play-plugins"); + + gNewWindow = gBrowser.replaceTabWithWindow(gBrowser.selectedTab); + + yield promiseWaitForFocus(gNewWindow); + + yield promisePopupNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser); +}); + +add_task(function* () { + ok(PopupNotifications.getNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser), "Should have a click-to-play notification in the tab in the new window"); + ok(!PopupNotifications.getNotification("click-to-play-plugins", gBrowser.selectedBrowser), "Should not have a click-to-play notification in the old window now"); + + let pluginInfo = yield promiseForPluginInfo("test", gNewWindow.gBrowser.selectedBrowser); + ok(!pluginInfo.activated, "plugin should not be activated"); + + yield ContentTask.spawn(gNewWindow.gBrowser.selectedBrowser, {}, function* () { + let doc = content.document; + let plugin = doc.getElementById("test"); + let bounds = plugin.getBoundingClientRect(); + let left = (bounds.left + bounds.right) / 2; + let top = (bounds.top + bounds.bottom) / 2; + let utils = content.QueryInterface(Components.interfaces.nsIInterfaceRequestor) + .getInterface(Components.interfaces.nsIDOMWindowUtils); + utils.sendMouseEvent("mousedown", left, top, 0, 1, 0, false, 0, 0); + utils.sendMouseEvent("mouseup", left, top, 0, 1, 0, false, 0, 0); + }); + + let condition = () => !PopupNotifications.getNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser).dismissed && gNewWindow.PopupNotifications.panel.firstChild; + yield promiseForCondition(condition); +}); + +add_task(function* () { + // Click the activate button on doorhanger to make sure it works + gNewWindow.PopupNotifications.panel.firstChild._primaryButton.click(); + + let pluginInfo = yield promiseForPluginInfo("test", gNewWindow.gBrowser.selectedBrowser); + ok(pluginInfo.activated, "plugin should be activated"); +}); |