diff options
Diffstat (limited to 'dom/plugins/test/mochitest/test_secondPlugin.html')
-rw-r--r-- | dom/plugins/test/mochitest/test_secondPlugin.html | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/dom/plugins/test/mochitest/test_secondPlugin.html b/dom/plugins/test/mochitest/test_secondPlugin.html new file mode 100644 index 000000000..4c1f051ca --- /dev/null +++ b/dom/plugins/test/mochitest/test_secondPlugin.html @@ -0,0 +1,73 @@ +<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, "Java Test Plug-in"); + + 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["Java Test Plug-in"], "Should have queried a click-to-play plugin named 'Java Test Plug-in'"); + + 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("Java Test Plug-in"), "Should have found a click-to-play plugin named 'Java Test Plug-in'"); + + 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-java-test"], "Should have queried a click-to-play MIME type named 'application/x-java-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-java-test"), "Should have found a click-to-play MIME type named 'application/x-java-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-java-test" width=200 height=200></object> + </body> +</html> |