gecko-dev/dom/plugins/test/mochitest/test_secondPlugin.html

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

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

<html>
<head>
<title>Second Test Plug-in Test</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body onload="run()">
<script class="testbody" type="application/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_DISABLED, "Second Test Plug-in");
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Shockwave Flash");
function findPlugin(pluginName) {
for (var i = 0; i < navigator.plugins.length; i++) {
var plugin = navigator.plugins[i];
if (plugin.name === pluginName) {
return plugin;
}
}
return null;
}
function findMimeType(mimeTypeType) {
for (var i = 0; i < navigator.mimeTypes.length; i++) {
var mimeType = navigator.mimeTypes[i];
if (mimeType.type === mimeTypeType) {
return mimeType;
}
}
return null;
}
function run() {
var pluginElement = document.getElementById("plugin");
is(pluginElement.identifierToStringTest("foo"), "foo", "Should be able to call a function provided by the plugin");
pluginElement = document.getElementById("disabledPlugin");
is(typeof pluginElement.identifierToStringTest, "undefined", "Should NOT be able to call a function on a disabled plugin");
pluginElement = document.getElementById("clickToPlayPlugin");
is(typeof pluginElement.identifierToStringTest, "undefined", "Should NOT be able to call a function on a click-to-play plugin");
ok(navigator.plugins["Test Plug-in"], "Should have queried a plugin named 'Test Plug-in'");
ok(!navigator.plugins["Second Test Plug-in"], "Should NOT have queried a disabled plugin named 'Second Test Plug-in'");
ok(navigator.plugins["Shockwave Flash"], "Should have queried a click-to-play plugin named 'Shockwave Flash'");
ok(findPlugin("Test Plug-in"), "Should have found a plugin named 'Test Plug-in'");
ok(!findPlugin("Second Test Plug-in"), "Should NOT found a disabled plugin named 'Second Test Plug-in'");
ok(findPlugin("Shockwave Flash"), "Should have found a click-to-play plugin named 'Shockwave Flash'");
ok(navigator.mimeTypes["application/x-test"], "Should have queried a MIME type named 'application/x-test'");
ok(!navigator.mimeTypes["application/x-second-test"], "Should NOT have queried a disabled type named 'application/x-second-test'");
ok(navigator.mimeTypes["application/x-shockwave-flash-test"], "Should have queried a click-to-play MIME type named 'application/x-shockwave-flash-test'");
ok(findMimeType("application/x-test"), "Should have found a MIME type named 'application/x-test'");
ok(!findMimeType("application/x-second-test"), "Should NOT have found a disabled MIME type named 'application/x-second-test'");
ok(findMimeType("application/x-shockwave-flash-test"), "Should have found a click-to-play MIME type named 'application/x-shockwave-flash-test'");
SimpleTest.finish();
}
</script>
<object id="plugin" type="application/x-test" width=200 height=200></object>
<object id="disabledPlugin" type="application/x-second-test" width=200 height=200></object>
<object id="clickToPlayPlugin" type="application/x-shockwave-flash-test" width=200 height=200></object>
</body>
</html>