michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: var gTestBrowser = null; michael@0: var gNumPluginBindingsAttached = 0; michael@0: michael@0: Components.utils.import("resource://gre/modules/Services.jsm"); michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: registerCleanupFunction(function() { michael@0: Services.prefs.clearUserPref("plugins.click_to_play"); michael@0: gTestBrowser.removeEventListener("PluginBindingAttached", pluginBindingAttached, true, true); michael@0: gBrowser.removeCurrentTab(); michael@0: window.focus(); michael@0: }); michael@0: michael@0: Services.prefs.setBoolPref("plugins.click_to_play", true); michael@0: setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY); michael@0: setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in"); michael@0: michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: gTestBrowser = gBrowser.selectedBrowser; michael@0: gTestBrowser.addEventListener("PluginBindingAttached", pluginBindingAttached, true, true); michael@0: var gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); michael@0: gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_bug820497.html"; michael@0: } michael@0: michael@0: function pluginBindingAttached() { michael@0: gNumPluginBindingsAttached++; michael@0: michael@0: if (gNumPluginBindingsAttached == 1) { michael@0: var doc = gTestBrowser.contentDocument; michael@0: var testplugin = doc.getElementById("test"); michael@0: ok(testplugin, "should have test plugin"); michael@0: var secondtestplugin = doc.getElementById("secondtest"); michael@0: ok(!secondtestplugin, "should not yet have second test plugin"); michael@0: var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(notification, "should have popup notification"); michael@0: // We don't set up the action list until the notification is shown michael@0: notification.reshow(); michael@0: is(notification.options.pluginData.size, 1, "should be 1 type of plugin in the popup notification"); michael@0: XPCNativeWrapper.unwrap(gTestBrowser.contentWindow).addSecondPlugin(); michael@0: } else if (gNumPluginBindingsAttached == 2) { michael@0: var doc = gTestBrowser.contentDocument; michael@0: var testplugin = doc.getElementById("test"); michael@0: ok(testplugin, "should have test plugin"); michael@0: var secondtestplugin = doc.getElementById("secondtest"); michael@0: ok(secondtestplugin, "should have second test plugin"); michael@0: var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); michael@0: ok(notification, "should have popup notification"); michael@0: notification.reshow(); michael@0: is(notification.options.pluginData.size, 2, "should be 2 types of plugin in the popup notification"); michael@0: finish(); michael@0: } else { michael@0: ok(false, "if we've gotten here, something is quite wrong"); michael@0: } michael@0: }