Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | var gTestBrowser = null; |
michael@0 | 6 | var gNumPluginBindingsAttached = 0; |
michael@0 | 7 | |
michael@0 | 8 | Components.utils.import("resource://gre/modules/Services.jsm"); |
michael@0 | 9 | |
michael@0 | 10 | function test() { |
michael@0 | 11 | waitForExplicitFinish(); |
michael@0 | 12 | registerCleanupFunction(function() { |
michael@0 | 13 | Services.prefs.clearUserPref("plugins.click_to_play"); |
michael@0 | 14 | gTestBrowser.removeEventListener("PluginBindingAttached", pluginBindingAttached, true, true); |
michael@0 | 15 | gBrowser.removeCurrentTab(); |
michael@0 | 16 | window.focus(); |
michael@0 | 17 | }); |
michael@0 | 18 | |
michael@0 | 19 | Services.prefs.setBoolPref("plugins.click_to_play", true); |
michael@0 | 20 | setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY); |
michael@0 | 21 | setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in"); |
michael@0 | 22 | |
michael@0 | 23 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 24 | gTestBrowser = gBrowser.selectedBrowser; |
michael@0 | 25 | gTestBrowser.addEventListener("PluginBindingAttached", pluginBindingAttached, true, true); |
michael@0 | 26 | var gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/"); |
michael@0 | 27 | gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_bug820497.html"; |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | function pluginBindingAttached() { |
michael@0 | 31 | gNumPluginBindingsAttached++; |
michael@0 | 32 | |
michael@0 | 33 | if (gNumPluginBindingsAttached == 1) { |
michael@0 | 34 | var doc = gTestBrowser.contentDocument; |
michael@0 | 35 | var testplugin = doc.getElementById("test"); |
michael@0 | 36 | ok(testplugin, "should have test plugin"); |
michael@0 | 37 | var secondtestplugin = doc.getElementById("secondtest"); |
michael@0 | 38 | ok(!secondtestplugin, "should not yet have second test plugin"); |
michael@0 | 39 | var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); |
michael@0 | 40 | ok(notification, "should have popup notification"); |
michael@0 | 41 | // We don't set up the action list until the notification is shown |
michael@0 | 42 | notification.reshow(); |
michael@0 | 43 | is(notification.options.pluginData.size, 1, "should be 1 type of plugin in the popup notification"); |
michael@0 | 44 | XPCNativeWrapper.unwrap(gTestBrowser.contentWindow).addSecondPlugin(); |
michael@0 | 45 | } else if (gNumPluginBindingsAttached == 2) { |
michael@0 | 46 | var doc = gTestBrowser.contentDocument; |
michael@0 | 47 | var testplugin = doc.getElementById("test"); |
michael@0 | 48 | ok(testplugin, "should have test plugin"); |
michael@0 | 49 | var secondtestplugin = doc.getElementById("secondtest"); |
michael@0 | 50 | ok(secondtestplugin, "should have second test plugin"); |
michael@0 | 51 | var notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser); |
michael@0 | 52 | ok(notification, "should have popup notification"); |
michael@0 | 53 | notification.reshow(); |
michael@0 | 54 | is(notification.options.pluginData.size, 2, "should be 2 types of plugin in the popup notification"); |
michael@0 | 55 | finish(); |
michael@0 | 56 | } else { |
michael@0 | 57 | ok(false, "if we've gotten here, something is quite wrong"); |
michael@0 | 58 | } |
michael@0 | 59 | } |