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 | <!DOCTYPE html> |
michael@0 | 2 | <!-- bug 820708 --> |
michael@0 | 3 | <html> |
michael@0 | 4 | <head> |
michael@0 | 5 | <meta><charset="utf-8"/> |
michael@0 | 6 | <title>Test Refreshing navigator.plugins (bug 820708)</title> |
michael@0 | 7 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 8 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"></script> |
michael@0 | 9 | <script type="application/javascript" src="utils.js"></script> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <script class="testbody" type="application/javascript"> |
michael@0 | 13 | "use strict"; |
michael@0 | 14 | |
michael@0 | 15 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 16 | setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); |
michael@0 | 17 | |
michael@0 | 18 | var pluginHost = Components.classes["@mozilla.org/plugin/host;1"] |
michael@0 | 19 | .getService(Components.interfaces.nsIPluginHost); |
michael@0 | 20 | var pluginTags = pluginHost.getPluginTags(); |
michael@0 | 21 | var nextTest = null; |
michael@0 | 22 | var obsService = Components.classes["@mozilla.org/observer-service;1"] |
michael@0 | 23 | .getService(Components.interfaces.nsIObserverService); |
michael@0 | 24 | var observer = { |
michael@0 | 25 | observe: function(aSubject, aTopic, aData) { |
michael@0 | 26 | if (aTopic == "plugin-info-updated") { |
michael@0 | 27 | SimpleTest.executeSoon(nextTest); |
michael@0 | 28 | } |
michael@0 | 29 | } |
michael@0 | 30 | }; |
michael@0 | 31 | obsService.addObserver(observer, "plugin-info-updated", false); |
michael@0 | 32 | |
michael@0 | 33 | var navTestPlugin1 = navigator.plugins.namedItem("Test Plug-in"); |
michael@0 | 34 | ok(navTestPlugin1, "navigator.plugins should have Test Plug-in"); |
michael@0 | 35 | var tagTestPlugin = null; |
michael@0 | 36 | for (var plugin of pluginTags) { |
michael@0 | 37 | if (plugin.name == navTestPlugin1.name) { |
michael@0 | 38 | tagTestPlugin = plugin; |
michael@0 | 39 | break; |
michael@0 | 40 | } |
michael@0 | 41 | } |
michael@0 | 42 | ok(tagTestPlugin, "plugin tags should have Test Plug-in"); |
michael@0 | 43 | var mimeType = tagTestPlugin.getMimeTypes()[0]; |
michael@0 | 44 | ok(mimeType, "should have a MIME type for Test Plug-in"); |
michael@0 | 45 | ok(navigator.mimeTypes[mimeType], "navigator.mimeTypes should have an entry for '" + mimeType + "'"); |
michael@0 | 46 | ok(!tagTestPlugin.disabled, "test plugin should not be disabled"); |
michael@0 | 47 | |
michael@0 | 48 | nextTest = testPart2; |
michael@0 | 49 | tagTestPlugin.enabledState = Components.interfaces.nsIPluginTag.STATE_DISABLED; |
michael@0 | 50 | |
michael@0 | 51 | function testPart2() { |
michael@0 | 52 | var navTestPlugin2 = navigator.plugins.namedItem("Test Plug-in"); |
michael@0 | 53 | ok(!navTestPlugin2, "now navigator.plugins should not have Test Plug-in"); |
michael@0 | 54 | ok(!navigator.mimeTypes[mimeType], "now navigator.mimeTypes should not have an entry for '" + mimeType + "'"); |
michael@0 | 55 | |
michael@0 | 56 | nextTest = testPart3; |
michael@0 | 57 | tagTestPlugin.enabledState = Components.interfaces.nsIPluginTag.STATE_ENABLED; |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | function testPart3() { |
michael@0 | 61 | var navTestPlugin3 = navigator.plugins.namedItem("Test Plug-in"); |
michael@0 | 62 | ok(navTestPlugin3, "now navigator.plugins should have Test Plug-in again"); |
michael@0 | 63 | ok(navigator.mimeTypes[mimeType], "now navigator.mimeTypes should have an entry for '" + mimeType + "' again"); |
michael@0 | 64 | obsService.removeObserver(observer, "plugin-info-updated"); |
michael@0 | 65 | SimpleTest.finish(); |
michael@0 | 66 | } |
michael@0 | 67 | </script> |
michael@0 | 68 | </body> |
michael@0 | 69 | </html> |