2012-08-13 21:40:15 +04:00
< html >
< head >
< title > Second Test Plug-in Test< / title >
< script type = "text/javascript" src = "/tests/SimpleTest/SimpleTest.js" > < / script >
2015-11-17 01:54:12 +03:00
< script type = "text/javascript" src = "plugin-utils.js" > < / script >
2012-08-13 21:40:15 +04:00
< link rel = "stylesheet" type = "text/css" href = "/tests/SimpleTest/test.css" / >
< / head >
< body onload = "run()" >
< script class = "testbody" type = "application/javascript" >
2013-11-01 09:19:09 +04:00
"use strict";
2012-08-13 21:40:15 +04:00
SimpleTest.waitForExplicitFinish();
2013-09-04 18:05:40 +04:00
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
2015-05-30 08:42:23 +03:00
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_DISABLED, "Second Test Plug-in");
2017-07-18 02:45:48 +03:00
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Shockwave Flash");
2012-08-13 21:40:15 +04:00
2013-11-01 09:19:09 +04:00
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;
}
2012-08-13 21:40:15 +04:00
function run() {
var pluginElement = document.getElementById("plugin");
is(pluginElement.identifierToStringTest("foo"), "foo", "Should be able to call a function provided by the plugin");
2015-05-30 08:42:23 +03:00
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'");
2017-07-18 02:45:48 +03:00
ok(navigator.plugins["Shockwave Flash"], "Should have queried a click-to-play plugin named 'Shockwave Flash'");
2013-11-01 09:19:09 +04:00
2015-05-30 08:42:23 +03:00
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'");
2017-07-18 02:45:48 +03:00
ok(findPlugin("Shockwave Flash"), "Should have found a click-to-play plugin named 'Shockwave Flash'");
2013-11-01 09:19:09 +04:00
2015-05-30 08:42:23 +03:00
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'");
2017-07-18 02:45:48 +03:00
ok(navigator.mimeTypes["application/x-shockwave-flash-test"], "Should have queried a click-to-play MIME type named 'application/x-shockwave-flash-test'");
2013-11-01 09:19:09 +04:00
2015-05-30 08:42:23 +03:00
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'");
2017-07-18 02:45:48 +03:00
ok(findMimeType("application/x-shockwave-flash-test"), "Should have found a click-to-play MIME type named 'application/x-shockwave-flash-test'");
2013-11-01 09:19:09 +04:00
2012-08-13 21:40:15 +04:00
SimpleTest.finish();
}
< / script >
2013-09-04 18:05:40 +04:00
2015-05-30 08:42:23 +03:00
< 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 >
2017-07-18 02:45:48 +03:00
< object id = "clickToPlayPlugin" type = "application/x-shockwave-flash-test" width = 200 height = 200 > < / object >
2012-08-13 21:40:15 +04:00
< / body >
< / html >