mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 478845 Disable mochitest of test plugin if test plugin is absent r=ted.mielczarek, jwalden
This commit is contained in:
parent
9521f5d189
commit
fc1e6ae42b
@ -7,6 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=391728
|
||||
<title>Test for Bug 391728</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/PluginUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
@ -28,18 +29,6 @@ var gUnknown = [];
|
||||
var gBlocked = [];
|
||||
var gDisabled = [];
|
||||
|
||||
function get_test_plugin() {
|
||||
var ph = Components.classes["@mozilla.org/plugin/host;1"]
|
||||
.getService(Components.interfaces.nsIPluginHost);
|
||||
var tags = ph.getPluginTags({});
|
||||
|
||||
// Find the test plugin
|
||||
for (var i = 0; i < tags.length; i++) {
|
||||
if (tags[i].name == "Test Plug-in")
|
||||
return tags[i];
|
||||
}
|
||||
}
|
||||
|
||||
function disabled_plugin_detected(event) {
|
||||
gDisabled.push(event.target.id);
|
||||
}
|
||||
@ -59,9 +48,11 @@ function init_test() {
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
prefs.setBoolPref("extensions.blocklist.enabled", false);
|
||||
|
||||
var plugin = get_test_plugin();
|
||||
ok(plugin, "Test plugin was not found");
|
||||
if (!PluginUtils.withTestPlugin(start_test))
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function start_test(plugin) {
|
||||
is(plugin.description, "Plug-in for testing purposes.", "Test plugin had an incorrect description");
|
||||
is(plugin.version, "1.0.0.0", "Test plugin had an incorrect version");
|
||||
ok(!plugin.disabled, "Test plugin should not be disabled");
|
||||
@ -72,8 +63,7 @@ function init_test() {
|
||||
load_frame(test_normal, "file_bug391728");
|
||||
}
|
||||
|
||||
function finish_test() {
|
||||
var plugin = get_test_plugin();
|
||||
function finish_test(plugin) {
|
||||
plugin.disabled = false;
|
||||
plugin.blocklisted = false;
|
||||
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
@ -91,9 +81,13 @@ function load_frame(nextTest, file) {
|
||||
frame.src = file + ".html?" + Math.random();
|
||||
}
|
||||
|
||||
function next_text() {
|
||||
PluginUtils.withTestPlugin(gNextTest);
|
||||
}
|
||||
|
||||
function frame_loaded() {
|
||||
// We must delay to wait for the plugin sources to be loaded :(
|
||||
setTimeout(gNextTest, 500);
|
||||
setTimeout(next_text, 500);
|
||||
}
|
||||
|
||||
function test_style(expected) {
|
||||
@ -121,51 +115,48 @@ function test_list(list) {
|
||||
}
|
||||
}
|
||||
|
||||
function test_normal() {
|
||||
function test_normal(plugin) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
is(gUnknown.length, 0, "Should not have been any unknown plugins");
|
||||
is(gDisabled.length, 0, "Should not have been any disabled plugins");
|
||||
is(gBlocked.length, 0, "Should not have been any blocked plugins");
|
||||
test_style("solid");
|
||||
var plugin = get_test_plugin();
|
||||
plugin.disabled = true;
|
||||
load_frame(test_disabled, "file_bug391728");
|
||||
}
|
||||
|
||||
function test_disabled() {
|
||||
function test_disabled(plugin) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
is(gUnknown.length, 0, "Should not have been any unknown plugins");
|
||||
is(gDisabled.length, PLUGIN_COUNT, "Should have been disabled plugins");
|
||||
test_list(gDisabled);
|
||||
is(gBlocked.length, 0, "Should not have been any blocked plugins");
|
||||
test_style("dotted");
|
||||
var plugin = get_test_plugin();
|
||||
ok(plugin.disabled, "Plugin lost its disabled status");
|
||||
plugin.disabled = false;
|
||||
plugin.blocklisted = true;
|
||||
load_frame(test_blocked, "file_bug391728");
|
||||
}
|
||||
|
||||
function test_blocked() {
|
||||
function test_blocked(plugin) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
is(gUnknown.length, 0, "Should not have been any unknown plugins");
|
||||
is(gDisabled.length, 0, "Should not have been any disabled plugins");
|
||||
is(gBlocked.length, PLUGIN_COUNT, "Should have been blocked plugins");
|
||||
test_list(gBlocked);
|
||||
test_style("dashed");
|
||||
var plugin = get_test_plugin();
|
||||
ok(plugin.blocklisted, "Plugin lost its blocklist status");
|
||||
load_frame(test_unknown, "file_bug391728_2");
|
||||
}
|
||||
|
||||
function test_unknown() {
|
||||
function test_unknown(plugin) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
is(gUnknown.length, PLUGIN_COUNT, "Should have been unknown plugins");
|
||||
test_list(gUnknown);
|
||||
is(gDisabled.length, 0, "Should not have been any disabled plugins");
|
||||
is(gBlocked.length, 0, "Should not have been any blocked plugins");
|
||||
test_style("none");
|
||||
finish_test();
|
||||
finish_test(plugin);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
@ -73,7 +73,7 @@ TOOL_DIRS += default/mac
|
||||
endif
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
ifneq (,$(filter WINNT Darwin Linux OS2,$(OS_ARCH)))
|
||||
ifneq (,$(filter WINNT Darwin Linux OS2 SunOS,$(OS_ARCH)))
|
||||
DIRS += test
|
||||
TOOL_DIRS += sdk
|
||||
endif
|
||||
|
@ -52,6 +52,7 @@ _SIMPLETEST_FILES = MozillaFileLogger.js \
|
||||
setup.js \
|
||||
EventUtils.js \
|
||||
WindowSnapshot.js \
|
||||
PluginUtils.js \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_SIMPLETEST_FILES)
|
||||
|
28
testing/mochitest/tests/SimpleTest/PluginUtils.js
Normal file
28
testing/mochitest/tests/SimpleTest/PluginUtils.js
Normal file
@ -0,0 +1,28 @@
|
||||
var PluginUtils =
|
||||
{
|
||||
withTestPlugin : function(callback)
|
||||
{
|
||||
if (typeof Components == "undefined")
|
||||
{
|
||||
todo(false, "Not a Mozilla-based browser");
|
||||
return false;
|
||||
}
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
var ph = Components.classes["@mozilla.org/plugin/host;1"]
|
||||
.getService(Components.interfaces.nsIPluginHost);
|
||||
var tags = ph.getPluginTags({});
|
||||
|
||||
// Find the test plugin
|
||||
for (var i = 0; i < tags.length; i++)
|
||||
{
|
||||
if (tags[i].name == "Test Plug-in")
|
||||
{
|
||||
callback(tags[i]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
todo(false, "Need a test plugin on this platform");
|
||||
return false;
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user