michael@0: var rootDir = getRootDirectory(gTestPath); michael@0: const gTestRoot = rootDir; michael@0: const gHttpTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); michael@0: michael@0: var gTestBrowser = null; michael@0: var gNextTest = null; michael@0: var gPluginHost = Components.classes["@mozilla.org/plugin/host;1"].getService(Components.interfaces.nsIPluginHost); michael@0: michael@0: Components.utils.import("resource://gre/modules/Services.jsm"); michael@0: michael@0: // This listens for the next opened tab and checks it is of the right url. michael@0: // opencallback is called when the new tab is fully loaded michael@0: // closecallback is called when the tab is closed michael@0: function TabOpenListener(url, opencallback, closecallback) { michael@0: this.url = url; michael@0: this.opencallback = opencallback; michael@0: this.closecallback = closecallback; michael@0: michael@0: gBrowser.tabContainer.addEventListener("TabOpen", this, false); michael@0: } michael@0: michael@0: TabOpenListener.prototype = { michael@0: url: null, michael@0: opencallback: null, michael@0: closecallback: null, michael@0: tab: null, michael@0: browser: null, michael@0: michael@0: handleEvent: function(event) { michael@0: if (event.type == "TabOpen") { michael@0: gBrowser.tabContainer.removeEventListener("TabOpen", this, false); michael@0: this.tab = event.originalTarget; michael@0: this.browser = this.tab.linkedBrowser; michael@0: gBrowser.addEventListener("pageshow", this, false); michael@0: } else if (event.type == "pageshow") { michael@0: if (event.target.location.href != this.url) michael@0: return; michael@0: gBrowser.removeEventListener("pageshow", this, false); michael@0: this.tab.addEventListener("TabClose", this, false); michael@0: var url = this.browser.contentDocument.location.href; michael@0: is(url, this.url, "Should have opened the correct tab"); michael@0: this.opencallback(this.tab, this.browser.contentWindow); michael@0: } else if (event.type == "TabClose") { michael@0: if (event.originalTarget != this.tab) michael@0: return; michael@0: this.tab.removeEventListener("TabClose", this, false); michael@0: this.opencallback = null; michael@0: this.tab = null; michael@0: this.browser = null; michael@0: // Let the window close complete michael@0: executeSoon(this.closecallback); michael@0: this.closecallback = null; michael@0: } michael@0: } michael@0: }; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: requestLongerTimeout(2); michael@0: registerCleanupFunction(function() { michael@0: clearAllPluginPermissions(); michael@0: Services.prefs.clearUserPref("extensions.blocklist.suppressUI"); michael@0: Services.prefs.clearUserPref("plugins.hideMissingPluginsNotification"); michael@0: }); michael@0: Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true); michael@0: michael@0: setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY); michael@0: setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in"); michael@0: michael@0: var newTab = gBrowser.addTab(); michael@0: gBrowser.selectedTab = newTab; michael@0: gTestBrowser = gBrowser.selectedBrowser; michael@0: gTestBrowser.addEventListener("load", pageLoad, true); michael@0: prepareTest(runAfterPluginBindingAttached(test1a), gTestRoot + "plugin_unknown.html"); michael@0: } michael@0: michael@0: function finishTest() { michael@0: clearAllPluginPermissions(); michael@0: gTestBrowser.removeEventListener("load", pageLoad, true); michael@0: gBrowser.removeCurrentTab(); michael@0: window.focus(); michael@0: finish(); michael@0: } michael@0: michael@0: function pageLoad() { michael@0: // The plugin events are async dispatched and can come after the load event michael@0: // This just allows the events to fire before we then go on to test the states michael@0: executeSoon(gNextTest); michael@0: } michael@0: michael@0: function prepareTest(nextTest, url) { michael@0: gNextTest = nextTest; michael@0: gTestBrowser.contentWindow.location = url; michael@0: } michael@0: michael@0: // Due to layout being async, "PluginBindAttached" may trigger later. michael@0: // This wraps a function to force a layout flush, thus triggering it, michael@0: // and schedules the function execution so they're definitely executed michael@0: // afterwards. michael@0: function runAfterPluginBindingAttached(func) { michael@0: return function() { michael@0: let doc = gTestBrowser.contentDocument; michael@0: let elems = doc.getElementsByTagName('embed'); michael@0: if (elems.length < 1) { michael@0: elems = doc.getElementsByTagName('object'); michael@0: } michael@0: elems[0].clientTop; michael@0: executeSoon(func); michael@0: }; michael@0: } michael@0: michael@0: // Tests a page with an unknown plugin in it. michael@0: function test1a() { michael@0: ok(PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 1a, Should have displayed the missing plugin notification"); michael@0: ok(gTestBrowser.missingPlugins, "Test 1a, Should be a missing plugin list"); michael@0: ok(gTestBrowser.missingPlugins.has("application/x-unknown"), "Test 1a, Should know about application/x-unknown"); michael@0: ok(!gTestBrowser.missingPlugins.has("application/x-test"), "Test 1a, Should not know about application/x-test"); michael@0: michael@0: var pluginNode = gTestBrowser.contentDocument.getElementById("unknown"); michael@0: ok(pluginNode, "Test 1a, Found plugin in page"); michael@0: var objLoadingContent = pluginNode.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_UNSUPPORTED, "Test 1a, plugin fallback type should be PLUGIN_UNSUPPORTED"); michael@0: michael@0: Services.prefs.setBoolPref("plugins.hideMissingPluginsNotification", true); michael@0: prepareTest(runAfterPluginBindingAttached(test1b), gTestRoot + "plugin_unknown.html"); michael@0: } michael@0: michael@0: michael@0: function test1b() { michael@0: ok(!PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 1b, Should not have displayed the missing plugin notification"); michael@0: ok(!gTestBrowser.missingPlugins, "Test 1b, Should not be a missing plugin list"); michael@0: Services.prefs.clearUserPref("plugins.hideMissingPluginsNotification"); michael@0: michael@0: var plugin = getTestPlugin(); michael@0: ok(plugin, "Test 1b, Should have a test plugin"); michael@0: plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED; michael@0: prepareTest(runAfterPluginBindingAttached(test2), gTestRoot + "plugin_test.html"); michael@0: } michael@0: michael@0: // Tests a page with a working plugin in it. michael@0: function test2() { michael@0: ok(!PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 2, Should not have displayed the missing plugin notification"); michael@0: ok(!gTestBrowser.missingPlugins, "Test 2, Should not be a missing plugin list"); michael@0: michael@0: var plugin = getTestPlugin(); michael@0: ok(plugin, "Should have a test plugin"); michael@0: plugin.enabledState = Ci.nsIPluginTag.STATE_DISABLED; michael@0: prepareTest(runAfterPluginBindingAttached(test3), gTestRoot + "plugin_test.html"); michael@0: } michael@0: michael@0: // Tests a page with a disabled plugin in it. michael@0: function test3() { michael@0: ok(!PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 3, Should not have displayed the missing plugin notification"); michael@0: ok(!gTestBrowser.missingPlugins, "Test 3, Should not be a missing plugin list"); michael@0: michael@0: new TabOpenListener("about:addons", test4, prepareTest5); michael@0: michael@0: var pluginNode = gTestBrowser.contentDocument.getElementById("test"); michael@0: ok(pluginNode, "Test 3, Found plugin in page"); michael@0: var objLoadingContent = pluginNode.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_DISABLED, "Test 3, plugin fallback type should be PLUGIN_DISABLED"); michael@0: var manageLink = gTestBrowser.contentDocument.getAnonymousElementByAttribute(pluginNode, "anonid", "managePluginsLink"); michael@0: ok(manageLink, "Test 3, found 'manage' link in plugin-problem binding"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(manageLink, {}, gTestBrowser.contentWindow); michael@0: } michael@0: michael@0: function test4(tab, win) { michael@0: is(win.wrappedJSObject.gViewController.currentViewId, "addons://list/plugin", "Test 4, Should have displayed the plugins pane"); michael@0: gBrowser.removeTab(tab); michael@0: } michael@0: michael@0: function prepareTest5() { michael@0: info("prepareTest5"); michael@0: var plugin = getTestPlugin(); michael@0: plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED; michael@0: setAndUpdateBlocklist(gHttpTestRoot + "blockPluginHard.xml", michael@0: function() { michael@0: info("prepareTest5 callback"); michael@0: prepareTest(runAfterPluginBindingAttached(test5), gTestRoot + "plugin_test.html"); michael@0: }); michael@0: } michael@0: michael@0: // Tests a page with a blocked plugin in it. michael@0: function test5() { michael@0: info("test5"); michael@0: ok(!PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 5, Should not have displayed the missing plugin notification"); michael@0: let notification = PopupNotifications.getNotification("click-to-play-plugins"); michael@0: ok(notification, "Test 5: There should be a plugin notification for blocked plugins"); michael@0: ok(notification.dismissed, "Test 5: The plugin notification should be dismissed by default"); michael@0: michael@0: notification.reshow(); michael@0: is(notification.options.pluginData.size, 1, "Test 5: Only the blocked plugin should be present in the notification"); michael@0: ok(PopupNotifications.panel.firstChild._buttonContainer.hidden, "Part 5: The blocked plugins notification should not have any buttons visible."); michael@0: michael@0: ok(!gTestBrowser.missingPlugins, "Test 5, Should not be a missing plugin list"); michael@0: var pluginNode = gTestBrowser.contentDocument.getElementById("test"); michael@0: ok(pluginNode, "Test 5, Found plugin in page"); michael@0: var objLoadingContent = pluginNode.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_BLOCKLISTED, "Test 5, plugin fallback type should be PLUGIN_BLOCKLISTED"); michael@0: michael@0: prepareTest(runAfterPluginBindingAttached(test6), gTestRoot + "plugin_both.html"); michael@0: } michael@0: michael@0: // Tests a page with a blocked and unknown plugin in it. michael@0: function test6() { michael@0: ok(PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 6, Should have displayed the missing plugin notification"); michael@0: ok(gTestBrowser.missingPlugins, "Test 6, Should be a missing plugin list"); michael@0: ok(gTestBrowser.missingPlugins.has("application/x-unknown"), "Test 6, Should know about application/x-unknown"); michael@0: ok(!gTestBrowser.missingPlugins.has("application/x-test"), "Test 6, application/x-test should not be a missing plugin"); michael@0: michael@0: prepareTest(runAfterPluginBindingAttached(test7), gTestRoot + "plugin_both2.html"); michael@0: } michael@0: michael@0: // Tests a page with a blocked and unknown plugin in it (alternate order to above). michael@0: function test7() { michael@0: ok(PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 7, Should have displayed the missing plugin notification"); michael@0: ok(gTestBrowser.missingPlugins, "Test 7, Should be a missing plugin list"); michael@0: ok(gTestBrowser.missingPlugins.has("application/x-unknown"), "Test 7, Should know about application/x-unknown"); michael@0: ok(!gTestBrowser.missingPlugins.has("application/x-test"), "Test 7, application/x-test should not be a missing plugin"); michael@0: michael@0: var plugin = getTestPlugin(); michael@0: plugin.enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY; michael@0: getTestPlugin("Second Test Plug-in").enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY; michael@0: michael@0: setAndUpdateBlocklist(gHttpTestRoot + "blockNoPlugins.xml", function() { michael@0: prepareTest(runAfterPluginBindingAttached(test8), gTestRoot + "plugin_test.html"); michael@0: }); michael@0: } michael@0: michael@0: // Tests a page with a working plugin that is click-to-play michael@0: function test8() { michael@0: ok(!PopupNotifications.getNotification("plugins-not-found", gTestBrowser), "Test 8, Should not have displayed the missing plugin notification"); michael@0: ok(!gTestBrowser.missingPlugins, "Test 8, Should not be a missing plugin list"); michael@0: ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser), "Test 8, Should have a click-to-play notification"); michael@0: michael@0: var pluginNode = gTestBrowser.contentDocument.getElementById("test"); michael@0: ok(pluginNode, "Test 8, Found plugin in page"); michael@0: var objLoadingContent = pluginNode.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY, "Test 8, plugin fallback type should be PLUGIN_CLICK_TO_PLAY"); michael@0: michael@0: prepareTest(runAfterPluginBindingAttached(test11a), gTestRoot + "plugin_test3.html"); michael@0: } michael@0: michael@0: // Tests 9 & 10 removed michael@0: michael@0: // Tests that the going back will reshow the notification for click-to-play plugins (part 1/4) michael@0: function test11a() { michael@0: var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(popupNotification, "Test 11a, Should have a click-to-play notification"); michael@0: michael@0: prepareTest(test11b, "about:blank"); michael@0: } michael@0: michael@0: // Tests that the going back will reshow the notification for click-to-play plugins (part 2/4) michael@0: function test11b() { michael@0: var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(!popupNotification, "Test 11b, Should not have a click-to-play notification"); michael@0: michael@0: Services.obs.addObserver(test11c, "PopupNotifications-updateNotShowing", false); michael@0: gTestBrowser.contentWindow.history.back(); michael@0: } michael@0: michael@0: // Tests that the going back will reshow the notification for click-to-play plugins (part 3/4) michael@0: function test11c() { michael@0: Services.obs.removeObserver(test11c, "PopupNotifications-updateNotShowing"); michael@0: var condition = function() PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: waitForCondition(condition, test11d, "Test 11c, waited too long for click-to-play-plugin notification"); michael@0: } michael@0: michael@0: // Tests that the going back will reshow the notification for click-to-play plugins (part 4/4) michael@0: function test11d() { michael@0: var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(popupNotification, "Test 11d, Should have a click-to-play notification"); michael@0: michael@0: prepareTest(runAfterPluginBindingAttached(test12a), gHttpTestRoot + "plugin_clickToPlayAllow.html"); michael@0: } michael@0: michael@0: // Tests that the "Allow Always" permission works for click-to-play plugins michael@0: function test12a() { michael@0: var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(popupNotification, "Test 12a, Should have a click-to-play notification"); michael@0: var plugin = gTestBrowser.contentDocument.getElementById("test"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(!objLoadingContent.activated, "Test 12a, Plugin should not be activated"); michael@0: michael@0: // Simulate clicking the "Allow Always" button. michael@0: popupNotification.reshow(); michael@0: PopupNotifications.panel.firstChild._primaryButton.click(); michael@0: michael@0: var condition = function() objLoadingContent.activated; michael@0: waitForCondition(condition, test12b, "Test 12a, Waited too long for plugin to activate"); michael@0: } michael@0: michael@0: function test12b() { michael@0: var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(popupNotification, "Test 12d, Should have a click-to-play notification"); michael@0: prepareTest(runAfterPluginBindingAttached(test12c), gHttpTestRoot + "plugin_two_types.html"); michael@0: } michael@0: michael@0: // Test that the "Always" permission, when set for just the Test plugin, michael@0: // does not also allow the Second Test plugin. michael@0: function test12c() { michael@0: var popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(popupNotification, "Test 12d, Should have a click-to-play notification"); michael@0: var test = gTestBrowser.contentDocument.getElementById("test"); michael@0: var secondtestA = gTestBrowser.contentDocument.getElementById("secondtestA"); michael@0: var secondtestB = gTestBrowser.contentDocument.getElementById("secondtestB"); michael@0: ok(test.activated, "Test 12d, Test plugin should be activated"); michael@0: ok(!secondtestA.activated, "Test 12d, Second Test plugin (A) should not be activated"); michael@0: ok(!secondtestB.activated, "Test 12d, Second Test plugin (B) should not be activated"); michael@0: michael@0: clearAllPluginPermissions(); michael@0: var plugin = getTestPlugin(); michael@0: plugin.enabledState = Ci.nsIPluginTag.STATE_ENABLED; michael@0: prepareTest(test14, gTestRoot + "plugin_test2.html"); michael@0: } michael@0: michael@0: // Test 13 removed michael@0: michael@0: // Tests that the plugin's "activated" property is true for working plugins with click-to-play disabled. michael@0: function test14() { michael@0: var plugin = gTestBrowser.contentDocument.getElementById("test1"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(objLoadingContent.activated, "Test 14, Plugin should be activated"); michael@0: michael@0: var plugin = getTestPlugin(); michael@0: plugin.enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY; michael@0: getTestPlugin("Second Test Plug-in").enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY; michael@0: prepareTest(runAfterPluginBindingAttached(test15), gTestRoot + "plugin_alternate_content.html"); michael@0: } michael@0: michael@0: // Tests that the overlay is shown instead of alternate content when michael@0: // plugins are click to play michael@0: function test15() { michael@0: var plugin = gTestBrowser.contentDocument.getElementById("test"); michael@0: var doc = gTestBrowser.contentDocument; michael@0: var mainBox = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); michael@0: ok(mainBox, "Test 15, Plugin with id=" + plugin.id + " overlay should exist"); michael@0: michael@0: prepareTest(runAfterPluginBindingAttached(test17), gTestRoot + "plugin_bug749455.html"); michael@0: } michael@0: michael@0: // Test 16 removed michael@0: michael@0: // Tests that mContentType is used for click-to-play plugins, and not the michael@0: // inspected type. michael@0: function test17() { michael@0: var clickToPlayNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(clickToPlayNotification, "Test 17, Should have a click-to-play notification"); michael@0: var missingNotification = PopupNotifications.getNotification("missing-plugins", gTestBrowser); michael@0: ok(!missingNotification, "Test 17, Should not have a missing plugin notification"); michael@0: michael@0: setAndUpdateBlocklist(gHttpTestRoot + "blockPluginVulnerableUpdatable.xml", michael@0: function() { michael@0: prepareTest(runAfterPluginBindingAttached(test18a), gHttpTestRoot + "plugin_test.html"); michael@0: }); michael@0: } michael@0: michael@0: // Tests a vulnerable, updatable plugin michael@0: function test18a() { michael@0: var clickToPlayNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(clickToPlayNotification, "Test 18a, Should have a click-to-play notification"); michael@0: var doc = gTestBrowser.contentDocument; michael@0: var plugin = doc.getElementById("test"); michael@0: ok(plugin, "Test 18a, Found plugin in page"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_UPDATABLE, "Test 18a, plugin fallback type should be PLUGIN_VULNERABLE_UPDATABLE"); michael@0: ok(!objLoadingContent.activated, "Test 18a, Plugin should not be activated"); michael@0: var overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); michael@0: ok(overlay.classList.contains("visible"), "Test 18a, Plugin overlay should exist, not be hidden"); michael@0: var updateLink = doc.getAnonymousElementByAttribute(plugin, "anonid", "checkForUpdatesLink"); michael@0: ok(updateLink.style.visibility != "hidden", "Test 18a, Plugin should have an update link"); michael@0: michael@0: var tabOpenListener = new TabOpenListener(Services.urlFormatter.formatURLPref("plugins.update.url"), false, false); michael@0: tabOpenListener.handleEvent = function(event) { michael@0: if (event.type == "TabOpen") { michael@0: gBrowser.tabContainer.removeEventListener("TabOpen", this, false); michael@0: this.tab = event.originalTarget; michael@0: is(event.target.label, this.url, "Test 18a, Update link should open up the plugin check page"); michael@0: gBrowser.removeTab(this.tab); michael@0: test18b(); michael@0: } michael@0: }; michael@0: EventUtils.synthesizeMouseAtCenter(updateLink, {}, gTestBrowser.contentWindow); michael@0: } michael@0: michael@0: function test18b() { michael@0: // clicking the update link should not activate the plugin michael@0: var doc = gTestBrowser.contentDocument; michael@0: var plugin = doc.getElementById("test"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(!objLoadingContent.activated, "Test 18b, Plugin should not be activated"); michael@0: var overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); michael@0: ok(overlay.classList.contains("visible"), "Test 18b, Plugin overlay should exist, not be hidden"); michael@0: michael@0: setAndUpdateBlocklist(gHttpTestRoot + "blockPluginVulnerableNoUpdate.xml", michael@0: function() { michael@0: prepareTest(runAfterPluginBindingAttached(test18c), gHttpTestRoot + "plugin_test.html"); michael@0: }); michael@0: } michael@0: michael@0: // Tests a vulnerable plugin with no update michael@0: function test18c() { michael@0: var clickToPlayNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(clickToPlayNotification, "Test 18c, Should have a click-to-play notification"); michael@0: var doc = gTestBrowser.contentDocument; michael@0: var plugin = doc.getElementById("test"); michael@0: ok(plugin, "Test 18c, Found plugin in page"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_NO_UPDATE, "Test 18c, plugin fallback type should be PLUGIN_VULNERABLE_NO_UPDATE"); michael@0: ok(!objLoadingContent.activated, "Test 18c, Plugin should not be activated"); michael@0: var overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); michael@0: ok(overlay.classList.contains("visible"), "Test 18c, Plugin overlay should exist, not be hidden"); michael@0: var updateLink = doc.getAnonymousElementByAttribute(plugin, "anonid", "checkForUpdatesLink"); michael@0: ok(updateLink.style.display != "block", "Test 18c, Plugin should not have an update link"); michael@0: michael@0: // check that click "Always allow" works with blocklisted plugins michael@0: clickToPlayNotification.reshow(); michael@0: PopupNotifications.panel.firstChild._primaryButton.click(); michael@0: michael@0: var condition = function() objLoadingContent.activated; michael@0: waitForCondition(condition, test18d, "Test 18d, Waited too long for plugin to activate"); michael@0: } michael@0: michael@0: // continue testing "Always allow" michael@0: function test18d() { michael@0: var plugin = gTestBrowser.contentDocument.getElementById("test"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(objLoadingContent.activated, "Test 18d, Plugin should be activated"); michael@0: michael@0: prepareTest(test18e, gHttpTestRoot + "plugin_test.html"); michael@0: } michael@0: michael@0: // continue testing "Always allow" michael@0: function test18e() { michael@0: var plugin = gTestBrowser.contentDocument.getElementById("test"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(objLoadingContent.activated, "Test 18e, Plugin should be activated"); michael@0: michael@0: clearAllPluginPermissions(); michael@0: prepareTest(runAfterPluginBindingAttached(test18f), gHttpTestRoot + "plugin_test.html"); michael@0: } michael@0: michael@0: // clicking the in-content overlay of a vulnerable plugin should bring michael@0: // up the notification and not directly activate the plugin michael@0: function test18f() { michael@0: var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(notification, "Test 18f, Should have a click-to-play notification"); michael@0: ok(notification.dismissed, "Test 18f, notification should start dismissed"); michael@0: var plugin = gTestBrowser.contentDocument.getElementById("test"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(!objLoadingContent.activated, "Test 18f, Plugin should not be activated"); michael@0: michael@0: var oldEventCallback = notification.options.eventCallback; michael@0: notification.options.eventCallback = function() { michael@0: oldEventCallback(); michael@0: executeSoon(test18g); michael@0: }; michael@0: EventUtils.synthesizeMouseAtCenter(plugin, {}, gTestBrowser.contentWindow); michael@0: } michael@0: michael@0: function test18g() { michael@0: var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(notification, "Test 18g, Should have a click-to-play notification"); michael@0: ok(!notification.dismissed, "Test 18g, notification should be open"); michael@0: notification.options.eventCallback = null; michael@0: var plugin = gTestBrowser.contentDocument.getElementById("test"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(!objLoadingContent.activated, "Test 18g, Plugin should not be activated"); michael@0: michael@0: setAndUpdateBlocklist(gHttpTestRoot + "blockNoPlugins.xml", michael@0: function() { michael@0: resetBlocklist(); michael@0: prepareTest(runAfterPluginBindingAttached(test19a), gTestRoot + "plugin_test.html"); michael@0: }); michael@0: } michael@0: michael@0: // Tests that clicking the icon of the overlay activates the doorhanger michael@0: function test19a() { michael@0: var doc = gTestBrowser.contentDocument; michael@0: var plugin = doc.getElementById("test"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(!objLoadingContent.activated, "Test 19a, Plugin should not be activated"); michael@0: ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed, "Test 19a, Doorhanger should start out dismissed"); michael@0: michael@0: var icon = doc.getAnonymousElementByAttribute(plugin, "class", "icon"); michael@0: EventUtils.synthesizeMouseAtCenter(icon, {}, gTestBrowser.contentWindow); michael@0: let condition = function() !PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed; michael@0: waitForCondition(condition, test19b, "Test 19a, Waited too long for doorhanger to activate"); michael@0: } michael@0: michael@0: function test19b() { michael@0: prepareTest(runAfterPluginBindingAttached(test19c), gTestRoot + "plugin_test.html"); michael@0: } michael@0: michael@0: // Tests that clicking the text of the overlay activates the plugin michael@0: function test19c() { michael@0: var doc = gTestBrowser.contentDocument; michael@0: var plugin = doc.getElementById("test"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(!objLoadingContent.activated, "Test 19c, Plugin should not be activated"); michael@0: michael@0: ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed, "Test 19c, Doorhanger should start out dismissed"); michael@0: michael@0: var text = doc.getAnonymousElementByAttribute(plugin, "class", "msg msgClickToPlay"); michael@0: EventUtils.synthesizeMouseAtCenter(text, {}, gTestBrowser.contentWindow); michael@0: let condition = function() !PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed; michael@0: waitForCondition(condition, test19d, "Test 19c, Waited too long for doorhanger to activate"); michael@0: } michael@0: michael@0: function test19d() { michael@0: prepareTest(runAfterPluginBindingAttached(test19e), gTestRoot + "plugin_test.html"); michael@0: } michael@0: michael@0: // Tests that clicking the box of the overlay activates the doorhanger michael@0: // (just to be thorough) michael@0: function test19e() { michael@0: var doc = gTestBrowser.contentDocument; michael@0: var plugin = doc.getElementById("test"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(!objLoadingContent.activated, "Test 19e, Plugin should not be activated"); michael@0: michael@0: ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed, "Test 19e, Doorhanger should start out dismissed"); michael@0: michael@0: EventUtils.synthesizeMouse(plugin, 50, 50, {}, gTestBrowser.contentWindow); michael@0: let condition = function() !PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed; michael@0: waitForCondition(condition, test19f, "Test 19e, Waited too long for plugin to activate"); michael@0: } michael@0: michael@0: function test19f() { michael@0: prepareTest(test20a, gTestRoot + "plugin_hidden_to_visible.html"); michael@0: } michael@0: michael@0: // Tests that a plugin in a div that goes from style="display: none" to michael@0: // "display: block" can be clicked to activate. michael@0: function test20a() { michael@0: var clickToPlayNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(!clickToPlayNotification, "Test 20a, Should not have a click-to-play notification"); michael@0: var doc = gTestBrowser.contentDocument; michael@0: var plugin = doc.getElementById("plugin"); michael@0: var mainBox = doc.getAnonymousElementByAttribute(plugin, "anonid", "main"); michael@0: ok(mainBox, "Test 20a, plugin overlay should not be null"); michael@0: var pluginRect = mainBox.getBoundingClientRect(); michael@0: ok(pluginRect.width == 0, "Test 20a, plugin should have an overlay with 0px width"); michael@0: ok(pluginRect.height == 0, "Test 20a, plugin should have an overlay with 0px height"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(!objLoadingContent.activated, "Test 20a, plugin should not be activated"); michael@0: var div = doc.getElementById("container"); michael@0: ok(div.style.display == "none", "Test 20a, container div should be display: none"); michael@0: michael@0: div.style.display = "block"; michael@0: var condition = function() { michael@0: var pluginRect = mainBox.getBoundingClientRect(); michael@0: return (pluginRect.width == 200); michael@0: } michael@0: waitForCondition(condition, test20b, "Test 20a, Waited too long for plugin to become visible"); michael@0: } michael@0: michael@0: function test20b() { michael@0: var clickToPlayNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(clickToPlayNotification, "Test 20b, Should now have a click-to-play notification"); michael@0: var doc = gTestBrowser.contentDocument; michael@0: var plugin = doc.getElementById("plugin"); michael@0: var pluginRect = doc.getAnonymousElementByAttribute(plugin, "anonid", "main").getBoundingClientRect(); michael@0: ok(pluginRect.width == 200, "Test 20b, plugin should have an overlay with 200px width"); michael@0: ok(pluginRect.height == 200, "Test 20b, plugin should have an overlay with 200px height"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(!objLoadingContent.activated, "Test 20b, plugin should not be activated"); michael@0: michael@0: ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed, "Test 20b, Doorhanger should start out dismissed"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(plugin, {}, gTestBrowser.contentWindow); michael@0: let condition = function() !PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser).dismissed; michael@0: waitForCondition(condition, test20c, "Test 20b, Waited too long for plugin to activate"); michael@0: } michael@0: michael@0: function test20c() { michael@0: PopupNotifications.panel.firstChild._primaryButton.click(); michael@0: var doc = gTestBrowser.contentDocument; michael@0: var plugin = doc.getElementById("plugin"); michael@0: let condition = function() plugin.activated; michael@0: waitForCondition(condition, test20d, "Test 20c", "Waiting for plugin to activate"); michael@0: } michael@0: michael@0: function test20d() { michael@0: var doc = gTestBrowser.contentDocument; michael@0: var plugin = doc.getElementById("plugin"); michael@0: var pluginRect = doc.getAnonymousElementByAttribute(plugin, "anonid", "main").getBoundingClientRect(); michael@0: ok(pluginRect.width == 0, "Test 20d, plugin should have click-to-play overlay with zero width"); michael@0: ok(pluginRect.height == 0, "Test 20d, plugin should have click-to-play overlay with zero height"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(objLoadingContent.activated, "Test 20d, plugin should be activated"); michael@0: michael@0: clearAllPluginPermissions(); michael@0: michael@0: prepareTest(runAfterPluginBindingAttached(test21a), gTestRoot + "plugin_two_types.html"); michael@0: } michael@0: michael@0: // Test having multiple different types of plugin on one page michael@0: function test21a() { michael@0: var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(notification, "Test 21a, Should have a click-to-play notification"); michael@0: michael@0: var doc = gTestBrowser.contentDocument; michael@0: var ids = ["test", "secondtestA", "secondtestB"]; michael@0: for (var id of ids) { michael@0: var plugin = doc.getElementById(id); michael@0: var rect = doc.getAnonymousElementByAttribute(plugin, "anonid", "main").getBoundingClientRect(); michael@0: ok(rect.width == 200, "Test 21a, Plugin with id=" + plugin.id + " overlay rect should have 200px width before being clicked"); michael@0: ok(rect.height == 200, "Test 21a, Plugin with id=" + plugin.id + " overlay rect should have 200px height before being clicked"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(!objLoadingContent.activated, "Test 21a, Plugin with id=" + plugin.id + " should not be activated"); michael@0: } michael@0: michael@0: // we have to actually show the panel to get the bindings to instantiate michael@0: notification.reshow(); michael@0: is(notification.options.pluginData.size, 2, "Test 21a, Should have two types of plugin in the notification"); michael@0: michael@0: var centerAction = null; michael@0: for (var action of notification.options.pluginData.values()) { michael@0: if (action.pluginName == "Test") { michael@0: centerAction = action; michael@0: break; michael@0: } michael@0: } michael@0: ok(centerAction, "Test 21b, found center action for the Test plugin"); michael@0: michael@0: var centerItem = null; michael@0: for (var item of PopupNotifications.panel.firstChild.childNodes) { michael@0: is(item.value, "block", "Test 21b, all plugins should start out blocked"); michael@0: if (item.action == centerAction) { michael@0: centerItem = item; michael@0: break; michael@0: } michael@0: } michael@0: ok(centerItem, "Test 21b, found center item for the Test plugin"); michael@0: michael@0: // "click" the button to activate the Test plugin michael@0: centerItem.value = "allownow"; michael@0: PopupNotifications.panel.firstChild._primaryButton.click(); michael@0: michael@0: var doc = gTestBrowser.contentDocument; michael@0: var plugin = doc.getElementById("test"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: var condition = function() objLoadingContent.activated; michael@0: waitForCondition(condition, test21c, "Test 21b, Waited too long for plugin to activate"); michael@0: } michael@0: michael@0: function test21c() { michael@0: var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(notification, "Test 21c, Should have a click-to-play notification"); michael@0: michael@0: notification.reshow(); michael@0: ok(notification.options.pluginData.size == 2, "Test 21c, Should have one type of plugin in the notification"); michael@0: michael@0: var doc = gTestBrowser.contentDocument; michael@0: var plugin = doc.getElementById("test"); michael@0: var rect = doc.getAnonymousElementByAttribute(plugin, "anonid", "main").getBoundingClientRect(); michael@0: ok(rect.width == 0, "Test 21c, Plugin with id=" + plugin.id + " overlay rect should have 0px width after being clicked"); michael@0: ok(rect.height == 0, "Test 21c, Plugin with id=" + plugin.id + " overlay rect should have 0px height after being clicked"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(objLoadingContent.activated, "Test 21c, Plugin with id=" + plugin.id + " should be activated"); michael@0: michael@0: var ids = ["secondtestA", "secondtestB"]; michael@0: for (var id of ids) { michael@0: var plugin = doc.getElementById(id); michael@0: var rect = doc.getAnonymousElementByAttribute(plugin, "anonid", "main").getBoundingClientRect(); michael@0: ok(rect.width == 200, "Test 21c, Plugin with id=" + plugin.id + " overlay rect should have 200px width before being clicked"); michael@0: ok(rect.height == 200, "Test 21c, Plugin with id=" + plugin.id + " overlay rect should have 200px height before being clicked"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(!objLoadingContent.activated, "Test 21c, Plugin with id=" + plugin.id + " should not be activated"); michael@0: } michael@0: michael@0: var centerAction = null; michael@0: for (var action of notification.options.pluginData.values()) { michael@0: if (action.pluginName == "Second Test") { michael@0: centerAction = action; michael@0: break; michael@0: } michael@0: } michael@0: ok(centerAction, "Test 21d, found center action for the Second Test plugin"); michael@0: michael@0: var centerItem = null; michael@0: for (var item of PopupNotifications.panel.firstChild.childNodes) { michael@0: if (item.action == centerAction) { michael@0: is(item.value, "block", "Test 21d, test plugin 2 should start blocked"); michael@0: centerItem = item; michael@0: break; michael@0: } michael@0: else { michael@0: is(item.value, "allownow", "Test 21d, test plugin should be enabled"); michael@0: } michael@0: } michael@0: ok(centerItem, "Test 21d, found center item for the Second Test plugin"); michael@0: michael@0: // "click" the button to activate the Second Test plugins michael@0: centerItem.value = "allownow"; michael@0: PopupNotifications.panel.firstChild._primaryButton.click(); michael@0: michael@0: var doc = gTestBrowser.contentDocument; michael@0: var plugin = doc.getElementById("secondtestA"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: var condition = function() objLoadingContent.activated; michael@0: waitForCondition(condition, test21e, "Test 21d, Waited too long for plugin to activate"); michael@0: } michael@0: michael@0: function test21e() { michael@0: var doc = gTestBrowser.contentDocument; michael@0: var ids = ["test", "secondtestA", "secondtestB"]; michael@0: for (var id of ids) { michael@0: var plugin = doc.getElementById(id); michael@0: var rect = doc.getAnonymousElementByAttribute(plugin, "anonid", "main").getBoundingClientRect(); michael@0: ok(rect.width == 0, "Test 21e, Plugin with id=" + plugin.id + " overlay rect should have 0px width after being clicked"); michael@0: ok(rect.height == 0, "Test 21e, Plugin with id=" + plugin.id + " overlay rect should have 0px height after being clicked"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(objLoadingContent.activated, "Test 21e, Plugin with id=" + plugin.id + " should be activated"); michael@0: } michael@0: michael@0: getTestPlugin().enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY; michael@0: getTestPlugin("Second Test Plug-in").enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY; michael@0: michael@0: clearAllPluginPermissions(); michael@0: michael@0: prepareTest(runAfterPluginBindingAttached(test22), gTestRoot + "plugin_test.html"); michael@0: } michael@0: michael@0: // Tests that a click-to-play plugin retains its activated state upon reloading michael@0: function test22() { michael@0: ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser), "Test 22, Should have a click-to-play notification"); michael@0: michael@0: // Plugin should start as CTP michael@0: var pluginNode = gTestBrowser.contentDocument.getElementById("test"); michael@0: ok(pluginNode, "Test 22, Found plugin in page"); michael@0: var objLoadingContent = pluginNode.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY, "Test 22, plugin fallback type should be PLUGIN_CLICK_TO_PLAY"); michael@0: michael@0: // Activate michael@0: objLoadingContent.playPlugin(); michael@0: is(objLoadingContent.displayedType, Ci.nsIObjectLoadingContent.TYPE_PLUGIN, "Test 22, plugin should have started"); michael@0: ok(pluginNode.activated, "Test 22, plugin should be activated"); michael@0: michael@0: // Spin event loop for plugin to finish spawning michael@0: executeSoon(function() { michael@0: var oldVal = pluginNode.getObjectValue(); michael@0: pluginNode.src = pluginNode.src; michael@0: is(objLoadingContent.displayedType, Ci.nsIObjectLoadingContent.TYPE_PLUGIN, "Test 22, Plugin should have retained activated state"); michael@0: ok(pluginNode.activated, "Test 22, plugin should have remained activated"); michael@0: // Sanity, ensure that we actually reloaded the instance, since this behavior might change in the future. michael@0: var pluginsDiffer; michael@0: try { michael@0: pluginNode.checkObjectValue(oldVal); michael@0: } catch (e) { michael@0: pluginsDiffer = true; michael@0: } michael@0: ok(pluginsDiffer, "Test 22, plugin should have reloaded"); michael@0: michael@0: prepareTest(runAfterPluginBindingAttached(test23), gTestRoot + "plugin_test.html"); michael@0: }); michael@0: } michael@0: michael@0: // Tests that a click-to-play plugin resets its activated state when changing types michael@0: function test23() { michael@0: ok(PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser), "Test 23, Should have a click-to-play notification"); michael@0: michael@0: // Plugin should start as CTP michael@0: var pluginNode = gTestBrowser.contentDocument.getElementById("test"); michael@0: ok(pluginNode, "Test 23, Found plugin in page"); michael@0: var objLoadingContent = pluginNode.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY, "Test 23, plugin fallback type should be PLUGIN_CLICK_TO_PLAY"); michael@0: michael@0: // Activate michael@0: objLoadingContent.playPlugin(); michael@0: is(objLoadingContent.displayedType, Ci.nsIObjectLoadingContent.TYPE_PLUGIN, "Test 23, plugin should have started"); michael@0: ok(pluginNode.activated, "Test 23, plugin should be activated"); michael@0: michael@0: // Reload plugin (this may need RunSoon() in the future when plugins change state asynchronously) michael@0: pluginNode.type = null; michael@0: // We currently don't properly change state just on type change, michael@0: // so rebind the plugin to tree. bug 767631 michael@0: pluginNode.parentNode.appendChild(pluginNode); michael@0: is(objLoadingContent.displayedType, Ci.nsIObjectLoadingContent.TYPE_NULL, "Test 23, plugin should be unloaded"); michael@0: pluginNode.type = "application/x-test"; michael@0: pluginNode.parentNode.appendChild(pluginNode); michael@0: is(objLoadingContent.displayedType, Ci.nsIObjectLoadingContent.TYPE_NULL, "Test 23, Plugin should not have activated"); michael@0: is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY, "Test 23, Plugin should be click-to-play"); michael@0: ok(!pluginNode.activated, "Test 23, plugin node should not be activated"); michael@0: michael@0: prepareTest(runAfterPluginBindingAttached(test24a), gHttpTestRoot + "plugin_test.html"); michael@0: } michael@0: michael@0: // Test that "always allow"-ing a plugin will not allow it when it becomes michael@0: // blocklisted. michael@0: function test24a() { michael@0: var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(notification, "Test 24a, Should have a click-to-play notification"); michael@0: var plugin = gTestBrowser.contentDocument.getElementById("test"); michael@0: ok(plugin, "Test 24a, Found plugin in page"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_CLICK_TO_PLAY, "Test 24a, Plugin should be click-to-play"); michael@0: ok(!objLoadingContent.activated, "Test 24a, plugin should not be activated"); michael@0: michael@0: // simulate "always allow" michael@0: notification.reshow(); michael@0: PopupNotifications.panel.firstChild._primaryButton.click(); michael@0: prepareTest(test24b, gHttpTestRoot + "plugin_test.html"); michael@0: } michael@0: michael@0: // did the "always allow" work as intended? michael@0: function test24b() { michael@0: var plugin = gTestBrowser.contentDocument.getElementById("test"); michael@0: ok(plugin, "Test 24b, Found plugin in page"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(objLoadingContent.activated, "Test 24b, plugin should be activated"); michael@0: setAndUpdateBlocklist(gHttpTestRoot + "blockPluginVulnerableUpdatable.xml", michael@0: function() { michael@0: prepareTest(runAfterPluginBindingAttached(test24c), gHttpTestRoot + "plugin_test.html"); michael@0: }); michael@0: } michael@0: michael@0: // the plugin is now blocklisted, so it should not automatically load michael@0: function test24c() { michael@0: var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(notification, "Test 24c, Should have a click-to-play notification"); michael@0: var plugin = gTestBrowser.contentDocument.getElementById("test"); michael@0: ok(plugin, "Test 24c, Found plugin in page"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: is(objLoadingContent.pluginFallbackType, Ci.nsIObjectLoadingContent.PLUGIN_VULNERABLE_UPDATABLE, "Test 24c, Plugin should be vulnerable/updatable"); michael@0: ok(!objLoadingContent.activated, "Test 24c, plugin should not be activated"); michael@0: michael@0: // simulate "always allow" michael@0: notification.reshow(); michael@0: PopupNotifications.panel.firstChild._primaryButton.click(); michael@0: michael@0: prepareTest(test24d, gHttpTestRoot + "plugin_test.html"); michael@0: } michael@0: michael@0: // We should still be able to always allow a plugin after we've seen that it's michael@0: // blocklisted. michael@0: function test24d() { michael@0: var plugin = gTestBrowser.contentDocument.getElementById("test"); michael@0: ok(plugin, "Test 24d, Found plugin in page"); michael@0: var objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent); michael@0: ok(objLoadingContent.activated, "Test 24d, plugin should be activated"); michael@0: michael@0: // this resets the vulnerable plugin permission michael@0: setAndUpdateBlocklist(gHttpTestRoot + "blockNoPlugins.xml", michael@0: function() { michael@0: clearAllPluginPermissions(); michael@0: resetBlocklist(); michael@0: prepareTest(test25, gTestRoot + "plugin_syncRemoved.html"); michael@0: }); michael@0: } michael@0: michael@0: function test25() { michael@0: let notification = PopupNotifications.getNotification("click-to-play-plugins"); michael@0: ok(notification, "Test 25: There should be a plugin notification even if the plugin was immediately removed"); michael@0: ok(notification.dismissed, "Test 25: The notification should be dismissed by default"); michael@0: michael@0: finishTest(); michael@0: }