2012-12-21 04:53:21 +04:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<!-- bug 820708 -->
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta><charset="utf-8"/>
|
|
|
|
<title>Test Refreshing navigator.plugins (bug 820708)</title>
|
|
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"></script>
|
2013-09-04 18:05:40 +04:00
|
|
|
<script type="application/javascript" src="utils.js"></script>
|
2012-12-21 04:53:21 +04:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<script class="testbody" type="application/javascript">
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
2013-09-04 18:05:40 +04:00
|
|
|
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
|
|
|
|
|
2012-12-21 04:53:21 +04:00
|
|
|
var pluginHost = Components.classes["@mozilla.org/plugin/host;1"]
|
|
|
|
.getService(Components.interfaces.nsIPluginHost);
|
|
|
|
var pluginTags = pluginHost.getPluginTags();
|
|
|
|
var nextTest = null;
|
|
|
|
var obsService = Components.classes["@mozilla.org/observer-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIObserverService);
|
|
|
|
var observer = {
|
|
|
|
observe: function(aSubject, aTopic, aData) {
|
|
|
|
if (aTopic == "plugin-info-updated") {
|
|
|
|
SimpleTest.executeSoon(nextTest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
obsService.addObserver(observer, "plugin-info-updated", false);
|
|
|
|
|
|
|
|
var navTestPlugin = navigator.plugins.namedItem("Test Plug-in");
|
|
|
|
ok(navTestPlugin, "navigator.plugins should have Test Plug-in");
|
|
|
|
var tagTestPlugin = null;
|
|
|
|
for (var plugin of pluginTags) {
|
|
|
|
if (plugin.name == navTestPlugin.name) {
|
|
|
|
tagTestPlugin = plugin;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ok(tagTestPlugin, "plugin tags should have Test Plug-in");
|
|
|
|
var mimeType = tagTestPlugin.getMimeTypes()[0];
|
|
|
|
ok(mimeType, "should have a MIME type for Test Plug-in");
|
2013-03-28 09:19:41 +04:00
|
|
|
ok(navigator.mimeTypes[mimeType], "navigator.mimeTypes should have an entry for '" + mimeType + "'");
|
2013-02-16 01:00:25 +04:00
|
|
|
ok(!tagTestPlugin.disabled, "test plugin should not be disabled");
|
2012-12-21 04:53:21 +04:00
|
|
|
|
|
|
|
nextTest = testPart2;
|
2013-03-28 01:06:43 +04:00
|
|
|
tagTestPlugin.enabledState = Components.interfaces.nsIPluginTag.STATE_DISABLED;
|
2012-12-21 04:53:21 +04:00
|
|
|
|
|
|
|
function testPart2() {
|
|
|
|
var navTestPlugin = navigator.plugins.namedItem("Test Plug-in");
|
|
|
|
ok(!navTestPlugin, "now navigator.plugins should not have Test Plug-in");
|
2013-03-28 09:19:41 +04:00
|
|
|
ok(!navigator.mimeTypes[mimeType], "now navigator.mimeTypes should not have an entry for '" + mimeType + "'");
|
2012-12-21 04:53:21 +04:00
|
|
|
|
|
|
|
nextTest = testPart3;
|
2013-03-28 01:06:43 +04:00
|
|
|
tagTestPlugin.enabledState = Components.interfaces.nsIPluginTag.STATE_ENABLED;
|
2012-12-21 04:53:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function testPart3() {
|
|
|
|
ok(navTestPlugin, "now navigator.plugins should have Test Plug-in again");
|
2013-03-28 09:19:41 +04:00
|
|
|
ok(navigator.mimeTypes[mimeType], "now navigator.mimeTypes should have an entry for '" + mimeType + "' again");
|
2012-12-21 04:53:21 +04:00
|
|
|
obsService.removeObserver(observer, "plugin-info-updated");
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|