Bug 1172627: Update test_instance_re-parent to account for bug 1158761; r=jimm

This commit is contained in:
Aaron Klotz 2015-06-08 19:57:54 -06:00
parent 1783c9ae8d
commit fea93d9fcd

View File

@ -12,6 +12,8 @@
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
const MAX_CHECK_PLUGIN_STOPPED_ATTEMPTS = 5;
var numCheckPluginStoppedAttempts = 0;
var exceptionThrown = false;
var p = null;
var d1 = null;
@ -38,6 +40,20 @@
});
}
function checkPluginStopped(callback, param) {
if (numCheckPluginStoppedAttempts < MAX_CHECK_PLUGIN_STOPPED_ATTEMPTS &&
!destroyed) {
++numCheckPluginStoppedAttempts;
SimpleTest.executeSoon(function() {
checkPluginStopped(callback, param);
});
} else {
info("Number of check plugin stopped attempts: " +
numCheckPluginStoppedAttempts);
callback(param);
}
}
function runTests(callback) {
p = document.getElementById('plugin1');
d1 = document.getElementById('div1');
@ -71,22 +87,23 @@
is(destroyed, false, "No instances should have been destroyed at this point.");
is(p.getInstanceCount(), 0, "No new instances should have been created at this point.");
// Removing the instance for a full event loop *should* respawn
d2.removeChild(p);
SimpleTest.executeSoon(function() {
d2.appendChild(p);
SimpleTest.executeSoon(function() {
try {
is(p.getInstanceCount(), 1, "One new instance should have been created at this point.");
} catch (e) {
exceptionThrown = true;
}
is(exceptionThrown, false, "Testing for exception getting instance count from plugin.");
checkPluginStopped(continueTestsAfterPluginDestruction, callback);
});
}
p.stopWatchingInstanceCount();
callback.apply(null);
});
});
function continueTestsAfterPluginDestruction(callback) {
d2.appendChild(p);
SimpleTest.executeSoon(function() {
try {
is(p.getInstanceCount(), 1, "One new instance should have been created at this point.");
} catch (e) {
exceptionThrown = true;
}
is(exceptionThrown, false, "Testing for exception getting instance count from plugin.");
p.stopWatchingInstanceCount();
callback.apply(null);
});
}
</script>