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