Index: LayoutTests/fast/workers/worker-timeout-decreasing-order.html |
diff --git a/LayoutTests/fast/workers/worker-timeout-decreasing-order.html b/LayoutTests/fast/workers/worker-timeout-decreasing-order.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..14257bcdc6b35e38e5ea1c7b3dfb30b40786cf27 |
--- /dev/null |
+++ b/LayoutTests/fast/workers/worker-timeout-decreasing-order.html |
@@ -0,0 +1,56 @@ |
+<!DOCTYPE html> |
+<html> |
+<body> |
+<p>Test setTimeOut,fired in decreasing order in Web Workers.</p> |
+<div id="result"></div> |
+<script type="text/javascript"> |
+function log(message) |
+{ |
+ document.getElementById("result").innerHTML += message + "</br>"; |
+} |
+ |
+if (window.testRunner) { |
+ testRunner.dumpAsText(); |
+ testRunner.waitUntilDone(); |
+} |
+ |
+var worker = new Worker('resources/worker-timeout-decreasing-order.js'); |
+// Start the first test of settimeout's |
+var lastTestResult = 0; |
+var testCounterLimit = 3; |
+var timerLimit = 3; |
+var testStarted = false; |
+var testAlreadyFailed = false; |
+ |
+worker.postMessage("TS"); |
+ |
+worker.onmessage = function(evt) { |
+ if(testStarted) { |
+ var currentNum = evt.data; |
+ if(lastTestResult == currentNum - 1 && !testAlreadyFailed) { |
+ lastTestResult = currentNum; |
+ --timerLimit; |
+ // we got all the results in order |
+ if(lastTestResult == testCounterLimit && timerLimit == 0) |
+ log("PASS: Timeouts executed in order."); |
+ } |
+ else { |
+ testAlreadyFailed = true; |
+ --timerLimit; |
+ if(timerLimit == 0) |
+ log("FAIL: Timeouts executed out of order."); |
+ } |
+ } |
+ if(evt.data == "Test started.") { |
+ log(evt.data); |
+ testStarted = true; |
+ } |
+ if (evt.data == "DONE") { |
+ log("DONE."); |
+ if (window.testRunner) |
+ testRunner.notifyDone(); |
+ } |
+} |
+</script> |
+</body> |
+</html> |