From 675e50128a2afc8aeda0013a85473ed9c4321c90 Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Thu, 14 Oct 2010 20:03:45 -0500 Subject: [PATCH] Bug 592882. Use setTimeout so test starts after paint suppression ends. --- .../tests/widgets/test_videocontrols.html | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/toolkit/content/tests/widgets/test_videocontrols.html b/toolkit/content/tests/widgets/test_videocontrols.html index a7572d15cec..3ee758fb739 100644 --- a/toolkit/content/tests/widgets/test_videocontrols.html +++ b/toolkit/content/tests/widgets/test_videocontrols.html @@ -213,11 +213,37 @@ function runTest(event) { testnum++; } +var canplaythroughsavedevent = null; +var gotcanplaythroughevent = false; +var gotloadevent = false; + +function canplaythroughevent(event) { + canplaythroughsavedevent = event; + gotcanplaythroughevent = true; + video.removeEventListener("canplaythrough", canplaythroughevent, false); + video.addEventListener("canplaythrough", runTest, false); + maybeStartTest(); +} + +function loadevent(event) { + gotloadevent = true; + maybeStartTest(); +} + +// setTimeout so that test starts after paint suppression ends +function maybeStartTest() { + if (!gotcanplaythroughevent || !gotloadevent) + return; + + setTimeout("runTest(canplaythroughsavedevent);", 0); +} + var testnum = 1; var video = document.getElementById("video"); // Kick off test once video has loaded. -video.addEventListener("canplaythrough", runTest, false); +video.addEventListener("canplaythrough", canplaythroughevent, false); +window.addEventListener("load", loadevent, false); // Other events expected by the test. video.addEventListener("play", runTest, false);