gecko-dev/dom/plugins/test/mochitest/test_refresh_navigator_plug...

67 строки
2.8 KiB
HTML
Исходник Обычный вид История

<!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>
<script type="application/javascript" src="utils.js"></script>
</head>
<body>
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
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");
ok(navigator.mimeTypes[mimeType], "navigator.mimeTypes should have an entry for '" + mimeType + "'");
ok(!tagTestPlugin.disabled, "test plugin should not be disabled");
nextTest = testPart2;
tagTestPlugin.enabledState = Components.interfaces.nsIPluginTag.STATE_DISABLED;
function testPart2() {
var navTestPlugin = navigator.plugins.namedItem("Test Plug-in");
ok(!navTestPlugin, "now navigator.plugins should not have Test Plug-in");
ok(!navigator.mimeTypes[mimeType], "now navigator.mimeTypes should not have an entry for '" + mimeType + "'");
nextTest = testPart3;
tagTestPlugin.enabledState = Components.interfaces.nsIPluginTag.STATE_ENABLED;
}
function testPart3() {
ok(navTestPlugin, "now navigator.plugins should have Test Plug-in again");
ok(navigator.mimeTypes[mimeType], "now navigator.mimeTypes should have an entry for '" + mimeType + "' again");
obsService.removeObserver(observer, "plugin-info-updated");
SimpleTest.finish();
}
</script>
</body>
</html>