Bug 1158761: Part 2 - Update checks for plugin stop event in tests; r=jimm

--HG--
extra : rebase_source : ccefb0a28d7092d9d89c8b240b90787461e8d20a
extra : histedit_source : c4272d9cea3e0a6ba43e2b351276adcf5ccb886d
This commit is contained in:
Aaron Klotz 2015-05-06 17:13:05 -06:00
Родитель 78887e2436
Коммит 0279fb3749
4 изменённых файлов: 55 добавлений и 19 удалений

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

@ -37,13 +37,23 @@ i.addEventListener("load", function loadfunc() {
// Navigate the frame to cause the document with the plugin to go inactive
i.removeEventListener("load", loadfunc);
i.src = "about:blank";
SimpleTest.executeSoon(function() {
// Ensure this event doesn't race with CheckPluginStopEvent
SimpleTest.executeSoon(function() {
const MAX_ATTEMPTS = 5;
var attempts = 0;
function checkPluginDestroyRan() {
// We may need to retry a few times until the plugin stop event makes
// its way through the event queue.
if (attempts < MAX_ATTEMPTS && !destroyran) {
++attempts;
SimpleTest.executeSoon(checkPluginDestroyRan);
} else {
info("Number of retry attempts: " + attempts);
ok(destroyran, "OnDestroy callback ran and did not crash");
SimpleTest.finish();
});
});
}
}
SimpleTest.executeSoon(checkPluginDestroyRan);
});
document.body.appendChild(i);

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

@ -12,14 +12,24 @@
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
const MAX_ATTEMPTS = 5;
var attempts = 0;
var destroyed = false;
function onDestroy() {
destroyed = true;
}
function checkPluginAlreadyDestroyed() {
is(destroyed, true, "Plugin instance should have been destroyed.");
SimpleTest.finish();
// We may need to retry a few times until the plugin stop event makes
// its way through the event queue.
if (attempts < MAX_ATTEMPTS && !destroyed) {
++attempts;
SimpleTest.executeSoon(checkPluginAlreadyDestroyed);
} else {
info("Number of retry attempts: " + attempts);
is(destroyed, true, "Plugin instance should have been destroyed.");
SimpleTest.finish();
}
}
function startTest() {
@ -27,10 +37,8 @@
var d1 = document.getElementById('div1');
p1.callOnDestroy(onDestroy);
setTimeout(checkPluginAlreadyDestroyed, 0);
d1.removeChild(p1);
SimpleTest.executeSoon(checkPluginAlreadyDestroyed);
}
</script>

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

@ -12,14 +12,24 @@
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
const MAX_ATTEMPTS = 5;
var attempts = 0;
var destroyed = false;
function onDestroy() {
destroyed = true;
}
function checkPluginAlreadyDestroyed() {
is(destroyed, true, "Plugin instance should have been destroyed.");
SimpleTest.finish();
// We may need to retry a few times until the plugin stop event makes
// its way through the event queue.
if (attempts < MAX_ATTEMPTS && !destroyed) {
++attempts;
SimpleTest.executeSoon(checkPluginAlreadyDestroyed);
} else {
info("Number of retry attempts: " + attempts);
is(destroyed, true, "Plugin instance should have been destroyed.");
SimpleTest.finish();
}
}
function startTest() {
@ -28,12 +38,12 @@
p1.callOnDestroy(onDestroy);
setTimeout(checkPluginAlreadyDestroyed, 0);
// Get two parent check events to run.
d1.removeChild(p1);
d1.appendChild(p1);
d1.removeChild(p1);
SimpleTest.executeSoon(checkPluginAlreadyDestroyed);
}
</script>

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

@ -12,14 +12,24 @@
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
const MAX_ATTEMPTS = 5;
var attempts = 0;
var destroyed = false;
function onDestroy() {
destroyed = true;
}
function checkPluginAlreadyDestroyed() {
is(destroyed, true, "Plugin instance should have been destroyed.");
SimpleTest.finish();
// We may need to retry a few times until the plugin stop event makes
// its way through the event queue.
if (attempts < MAX_ATTEMPTS && !destroyed) {
++attempts;
SimpleTest.executeSoon(checkPluginAlreadyDestroyed);
} else {
info("Number of retry attempts: " + attempts);
is(destroyed, true, "Plugin instance should have been destroyed.");
SimpleTest.finish();
}
}
function startTest() {
@ -28,10 +38,8 @@
var d2 = document.getElementById('div2');
p1.callOnDestroy(onDestroy);
setTimeout(checkPluginAlreadyDestroyed, 0);
d1.removeChild(d2);
SimpleTest.executeSoon(checkPluginAlreadyDestroyed);
}
</script>