gecko/modules/plugin/test/mochitest/test_npapi_timers.xul

60 lines
1.9 KiB
XML

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window title="NPAPI Timer Tests"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<title>NPAPI Timer Tests</title>
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<body xmlns="http://www.w3.org/1999/xhtml" onload="runTests()">
<embed id="plugin" type="application/x-test" width="50" height="50"></embed>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish();
var uniqueIDTestFinished = false;
var shortOneShotTimerFiredOnce = false;
var shortOneShotTimerFiredTwice = false;
var longRepeatingTimerFiredOnce = false;
var longRepeatingTimerFiredTwice = false;
function uniqueID(success) {
is(success, true, "Timers incorrectly given non-unique IDs.");
uniqueIDTestFinished = true;
}
function shortTimerFired() {
is(uniqueIDTestFinished, true, "Unique ID test should have reported back before short timer fired.");
if (shortOneShotTimerFiredOnce)
shortOneShotTimerFiredTwice = true;
else
shortOneShotTimerFiredOnce = true;
}
function longTimerFired() {
is(shortOneShotTimerFiredOnce, true, "Short one-shot timer did not fire.");
is(shortOneShotTimerFiredTwice, false, "Short one-shot timer fired multiple times.");
if (longRepeatingTimerFiredOnce) {
var p = document.getElementById("plugin");
p.unscheduleAllTimers();
SimpleTest.finish();
}
else {
longRepeatingTimerFiredOnce = true;
}
}
function runTests() {
var p = document.getElementById("plugin");
p.timerTest();
}
]]>
</script>
</window>