Bug 800018 - Part 4 - Fix plugin fallback tests for new events. r=josh

This commit is contained in:
John Schoenick 2012-11-07 17:24:39 -08:00
Родитель d20ac91882
Коммит 2b76da943f
6 изменённых файлов: 62 добавлений и 56 удалений

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

@ -14,7 +14,7 @@ function test() {
var newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
gTestBrowser = gBrowser.selectedBrowser;
gTestBrowser.addEventListener("PluginNotFound", pluginNotFound, true);
gTestBrowser.addEventListener("PluginBindingAttached", pluginBindingAttached, true, true);
var consoleService = Cc["@mozilla.org/consoleservice;1"]
.getService(Ci.nsIConsoleService);
var errorListener = {
@ -25,7 +25,7 @@ function test() {
};
consoleService.registerListener(errorListener);
registerCleanupFunction(function() {
gTestBrowser.removeEventListener("PluginNotFound", pluginNotFound, true);
gTestBrowser.removeEventListener("PluginBindingAttached", pluginBindingAttached, true);
consoleService.unregisterListener(errorListener);
gBrowser.removeCurrentTab();
window.focus();
@ -33,7 +33,7 @@ function test() {
gTestBrowser.contentWindow.location = gHttpTestRoot + "plugin_bug797677.html";
}
function pluginNotFound() {
function pluginBindingAttached() {
// Let browser-plugins.js handle the PluginNotFound event, then run the test
executeSoon(runTest);
}

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

@ -21,21 +21,10 @@ object:-moz-type-unsupported {
}
</style>
<script type="text/javascript">
function unknown_plugin_detected(event) {
window.parent.unknown_plugin_detected(event);
function plugin_binding_attached(event) {
window.parent.plugin_binding_attached(event);
}
function blocked_plugin_detected(event) {
window.parent.blocked_plugin_detected(event);
}
function disabled_plugin_detected(event) {
window.parent.disabled_plugin_detected(event);
}
document.addEventListener("PluginNotFound", unknown_plugin_detected, true);
document.addEventListener("PluginDisabled", disabled_plugin_detected, true);
document.addEventListener("PluginBlocklisted", blocked_plugin_detected, true);
document.addEventListener("PluginBindingAttached", plugin_binding_attached, true, true);
</script>
</head>
<body>

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

@ -21,21 +21,10 @@ object:-moz-type-unsupported {
}
</style>
<script type="text/javascript">
function unknown_plugin_detected(event) {
window.parent.unknown_plugin_detected(event);
function plugin_binding_attached(event) {
window.parent.plugin_binding_attached(event);
}
function blocked_plugin_detected(event) {
window.parent.blocked_plugin_detected(event);
}
function disabled_plugin_detected(event) {
window.parent.disabled_plugin_detected(event);
}
document.addEventListener("PluginNotFound", unknown_plugin_detected, true);
document.addEventListener("PluginDisabled", disabled_plugin_detected, true);
document.addEventListener("PluginBlocklisted", blocked_plugin_detected, true);
document.addEventListener("PluginBindingAttached", plugin_binding_attached, true, true);
</script>
</head>
<body>

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

@ -22,22 +22,27 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=391728
const PLUGIN_COUNT = 13;
// Plugins that should neither dispatch error events or have the pseudo classes set
const FALLBACK_COUNT = 5;
const OBJLC = Components.interfaces.nsIObjectLoadingContent;
var gNextTest = null;
var gUnknown = [];
var gBlocked = [];
var gDisabled = [];
function disabled_plugin_detected(event) {
gDisabled.push(event.target.id);
}
function blocked_plugin_detected(event) {
gBlocked.push(event.target.id);
}
function unknown_plugin_detected(event) {
gUnknown.push(event.target.id);
function plugin_binding_attached(event) {
var plugin = event.target;
plugin instanceof OBJLC;
switch (SpecialPowers.wrap(plugin).pluginFallbackType) {
case OBJLC.PLUGIN_DISABLED:
gDisabled.push(plugin.id);
break;
case OBJLC.PLUGIN_BLOCKLISTED:
gBlocked.push(plugin.id);
break;
case OBJLC.PLUGIN_UNSUPPORTED:
gUnknown.push(plugin.id);
break;
}
}
function init_test() {

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

@ -13,15 +13,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=425013
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=425013">Mozilla Bug 425013</a>
<br>
<script>
<script type="text/javascript;version=1.7">
var missingPlugins = new Array();
var OBJLC = Components.interfaces.nsIObjectLoadingContent;
function pluginNotFound(event)
function pluginBinding(event)
{
missingPlugins.push(event.target);
var plugin = event.target;
plugin instanceof OBJLC;
if (SpecialPowers.wrap(plugin).pluginFallbackType == OBJLC.PLUGIN_UNSUPPORTED)
missingPlugins.push(plugin);
}
document.addEventListener("PluginNotFound", pluginNotFound, false);
document.addEventListener("PluginBindingAttached", pluginBinding, true);
</script>
<object type="foo/bar" id="obj1"></object>
@ -55,14 +59,23 @@ document.addEventListener("PluginNotFound", pluginNotFound, false);
<script class="testbody" type="text/javascript">
function runtests()
{
ok(missingPlugins.indexOf(document.getElementById("obj1")) >= 0, "Missing plugin element obj1");
ok(missingPlugins.indexOf(document.getElementById("embed1")) >= 0, "Missing plugin element embed1");
ok(missingPlugins.indexOf(document.getElementById("embed2")) >= 0, "Missing plugin element embed2");
ok(missingPlugins.indexOf(document.getElementById("obj3")) >= 0, "Missing plugin element obj3");
// Force layout flush so the binding is attached and the event is fired
document.getElementById("obj1").clientTop;
document.getElementById("obj3").clientTop;
document.getElementById("embed1").clientTop;
document.getElementById("embed2").clientTop;
is(missingPlugins.length, 4, "Wrong number of missing plugins");
// Let pending events flush
SimpleTest.executeSoon(function () {
ok(missingPlugins.indexOf(document.getElementById("obj1")) >= 0, "Missing plugin element obj1");
ok(missingPlugins.indexOf(document.getElementById("embed1")) >= 0, "Missing plugin element embed1");
ok(missingPlugins.indexOf(document.getElementById("embed2")) >= 0, "Missing plugin element embed2");
ok(missingPlugins.indexOf(document.getElementById("obj3")) >= 0, "Missing plugin element obj3");
SimpleTest.finish();
is(missingPlugins.length, 4, "Wrong number of missing plugins");
SimpleTest.finish();
});
}
SimpleTest.waitForExplicitFinish();

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

@ -15,13 +15,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=429157
<script>
var missingPlugins = new Array();
const OBJLC = Components.interfaces.nsIObjectLoadingContent;
function pluginNotFound(event)
function pluginBindingAttached(event)
{
missingPlugins.push(event.target);
var plugin = event.target;
plugin instanceof OBJLC;
if (SpecialPowers.wrap(plugin).pluginFallbackType == OBJLC.PLUGIN_UNSUPPORTED)
missingPlugins.push(plugin);
}
document.addEventListener("PluginNotFound", pluginNotFound, false);
document.addEventListener("PluginBindingAttached", pluginBindingAttached, true);
</script>
<object id="obj1" type="image/png" >ALT image/png</object><br>
@ -32,9 +36,15 @@ document.addEventListener("PluginNotFound", pluginNotFound, false);
<script class="testbody" type="text/javascript">
function runtests()
{
is(missingPlugins.length, 0, "There should be no missing plugins for this page");
for (var obj of document.querySelectorAll("object")) {
obj.clientTop;
}
SimpleTest.finish();
SimpleTest.executeSoon(function () {
is(missingPlugins.length, 0, "There should be no missing plugins for this page");
SimpleTest.finish();
});
}
SimpleTest.waitForExplicitFinish();