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