2012-08-13 10:40:15 -07:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Second Test Plug-in Test</title>
|
|
|
|
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
2013-09-04 07:05:40 -07:00
|
|
|
<script type="text/javascript" src="utils.js"></script>
|
2012-08-13 10:40:15 -07:00
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body onload="run()">
|
|
|
|
<script class="testbody" type="application/javascript">
|
2013-10-31 22:19:09 -07:00
|
|
|
"use strict";
|
|
|
|
|
2012-08-13 10:40:15 -07:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
2013-09-04 07:05:40 -07:00
|
|
|
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
|
|
|
|
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
|
2012-08-13 10:40:15 -07:00
|
|
|
|
2013-10-31 22:19:09 -07: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 10:40:15 -07:00
|
|
|
function run() {
|
2013-10-31 22:19:09 -07:00
|
|
|
// Add "Test Plug-in" (but not "Second Test Plug-in") to the list of
|
|
|
|
// unhidden plugins. This test must modify the "plugins.enumerable_names"
|
|
|
|
// pref BEFORE accessing the navigator.plugins or navigator.mimeTypes
|
|
|
|
// arrays because they only read the pref when they first initialize
|
|
|
|
// their internal arrays!
|
|
|
|
var prefs = SpecialPowers.Cc["@mozilla.org/preferences-service;1"].getService(SpecialPowers.Ci.nsIPrefBranch);
|
|
|
|
var defaultEnumerableNamesPref = prefs.getCharPref("plugins.enumerable_names");
|
|
|
|
prefs.setCharPref("plugins.enumerable_names", defaultEnumerableNamesPref + ",Test Plug-in");
|
2012-08-13 10:40:15 -07:00
|
|
|
|
|
|
|
var pluginElement = document.getElementById("plugin");
|
|
|
|
is(pluginElement.identifierToStringTest("foo"), "foo", "Should be able to call a function provided by the plugin");
|
|
|
|
|
2013-10-31 22:19:09 -07:00
|
|
|
ok(navigator.plugins["Test Plug-in"], "Should have queried a non-hidden plugin named 'Test Plug-in'");
|
|
|
|
ok(navigator.plugins["Second Test Plug-in"], "Should have queried a hidden plugin named 'Test Plug-in'");
|
|
|
|
|
|
|
|
ok(findPlugin("Test Plug-in"), "Should have found a non-hidden plugin named 'Test Plug-in'");
|
|
|
|
ok(!findPlugin("Second Test Plug-in"), "Should NOT found a hidden plugin named 'Test Plug-in'");
|
|
|
|
|
|
|
|
ok(navigator.mimeTypes["application/x-test"], "Should have queried a non-hidden MIME type named 'application/x-test'");
|
|
|
|
ok(navigator.mimeTypes["application/x-second-test"], "Should have queried a MIME type named 'application/x-second-test'");
|
|
|
|
|
|
|
|
ok(findMimeType("application/x-test"), "Should have found a non-hidden MIME type named 'application/x-test'");
|
|
|
|
ok(!findMimeType("application/x-second-test"), "Should NOT have found a MIME type named 'application/x-second-test'");
|
|
|
|
|
|
|
|
// Restore original pref to hide "Test Plug-in" and "Second Test Plug-in".
|
|
|
|
prefs.setCharPref("plugins.enumerable_names", defaultEnumerableNamesPref);
|
|
|
|
|
2012-08-13 10:40:15 -07:00
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
</script>
|
2013-09-04 07:05:40 -07:00
|
|
|
|
|
|
|
<object id="plugin" type="application/x-second-test" width=200 height=200></object>
|
2012-08-13 10:40:15 -07:00
|
|
|
</body>
|
|
|
|
</html>
|