Bug 1335475 - Move test_refresh_navigator_plugins to a plain mochitest.r=mconley

Note that this test currently is broken/disabled in e10s mode. That's covered by bug 1090576, but this patch doesn't make it worse because chrome mochitests run in local mode always anyway.

MozReview-Commit-ID: L4hJ8LkiSNG
This commit is contained in:
Benjamin Smedberg 2017-03-08 14:49:12 -05:00
Родитель f5b5c4624c
Коммит 65dbc5c576
3 изменённых файлов: 16 добавлений и 49 удалений

Просмотреть файл

@ -27,7 +27,6 @@ skip-if = (!crashreporter) || (os != "win")
[test_npruntime.xul]
[test_plugin_tag_clicktoplay.html]
[test_privatemode_perwindowpb.xul]
[test_refresh_navigator_plugins.html]
[test_xulbrowser_plugin_visibility.xul]
skip-if = (toolkit == "cocoa") || (os == "win")
support-files = xulbrowser_plugin_visibility.xul plugin_visibility_loader.html

Просмотреть файл

@ -142,6 +142,8 @@ skip-if = (toolkit != "cocoa") || (os != "win")
[test_queryContentsScaleFactorWindowed.html]
skip-if = (toolkit != "cocoa") || (os != "win")
[test_redirect_handling.html]
[test_refresh_navigator_plugins.html]
skip-if = e10s # Bug 1090576
[test_secondPlugin.html]
[test_src_url_change.html]
[test_streamatclose.html]

Просмотреть файл

@ -4,65 +4,31 @@
<head>
<meta><charset="utf-8"/>
<title>Test Refreshing navigator.plugins (bug 820708)</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript"
src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="plugin-utils.js"></script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css">
</head>
<body>
<p id="display"></p>
<script class="testbody" type="application/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
var pluginHost = Components.classes["@mozilla.org/plugin/host;1"]
.getService(Components.interfaces.nsIPluginHost);
var pluginTags = pluginHost.getPluginTags();
var nextTest = null;
var obsService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
var observer = {
observe: function(aSubject, aTopic, aData) {
if (aTopic == "plugin-info-updated") {
SimpleTest.executeSoon(nextTest);
}
}
};
obsService.addObserver(observer, "plugin-info-updated");
ok("Test Plug-in" in navigator.plugins, "testplugin should be present");
ok("application/x-test" in navigator.mimeTypes, "testplugin MIME should be present");
var navTestPlugin1 = navigator.plugins.namedItem("Test Plug-in");
ok(navTestPlugin1, "navigator.plugins should have Test Plug-in");
var tagTestPlugin = null;
for (var plugin of pluginTags) {
if (plugin.name == navTestPlugin1.name) {
tagTestPlugin = plugin;
break;
}
}
ok(tagTestPlugin, "plugin tags should have Test Plug-in");
var mimeType = tagTestPlugin.getMimeTypes()[0];
ok(mimeType, "should have a MIME type for Test Plug-in");
ok(navigator.mimeTypes[mimeType], "navigator.mimeTypes should have an entry for '" + mimeType + "'");
ok(!tagTestPlugin.disabled, "test plugin should not be disabled");
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_DISABLED);
ok(!("Test Plug-in" in navigator.plugins), "testplugin should not be present");
ok(!("application/x-test" in navigator.mimeTypes), "testplugin MIME should not be present");
nextTest = testPart2;
tagTestPlugin.enabledState = Components.interfaces.nsIPluginTag.STATE_DISABLED;
function testPart2() {
var navTestPlugin2 = navigator.plugins.namedItem("Test Plug-in");
ok(!navTestPlugin2, "now navigator.plugins should not have Test Plug-in");
ok(!navigator.mimeTypes[mimeType], "now navigator.mimeTypes should not have an entry for '" + mimeType + "'");
nextTest = testPart3;
tagTestPlugin.enabledState = Components.interfaces.nsIPluginTag.STATE_ENABLED;
}
function testPart3() {
var navTestPlugin3 = navigator.plugins.namedItem("Test Plug-in");
ok(navTestPlugin3, "now navigator.plugins should have Test Plug-in again");
ok(navigator.mimeTypes[mimeType], "now navigator.mimeTypes should have an entry for '" + mimeType + "' again");
obsService.removeObserver(observer, "plugin-info-updated");
SimpleTest.finish();
}
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
ok("Test Plug-in" in navigator.plugins, "testplugin should be present again");
ok("application/x-test" in navigator.mimeTypes, "testplugin MIME should be present again");
SimpleTest.finish();
</script>
</body>
</html>