Index: third_party/WebKit/LayoutTests/imported/wpt/workers/support/Timer.js |
diff --git a/third_party/WebKit/LayoutTests/imported/wpt/workers/support/Timer.js b/third_party/WebKit/LayoutTests/imported/wpt/workers/support/Timer.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a86a224dbb41749aca47ba438c15b9ba639458b2 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/imported/wpt/workers/support/Timer.js |
@@ -0,0 +1,50 @@ |
+var count = 0; |
+var id; |
+ |
+onmessage = function(evt) |
+{ |
+ try |
+ { |
+ switch(evt.data) |
+ { |
+ case "TimeoutHandler": |
+ count = 0; |
+ id = setTimeout("TimeoutHandler()", 10); |
+ postMessage('hello'); |
+ break; |
+ case "IntervalHandler": |
+ count = 0; |
+ id = setInterval("IntervalHandler()", 10); |
+ postMessage('hello'); |
+ break; |
+ } |
+ } |
+ catch(ex) |
+ { |
+ postMessage("Fail"); |
+ } |
+} |
+ |
+function TimeoutHandler() |
+{ |
+ count++; |
+ postMessage("worker"); |
+ |
+ id = setTimeout("TimeoutHandler()", 10); |
+ |
+ if (count >= 2) |
+ { |
+ clearTimeout(id); |
+ } |
+} |
+ |
+function IntervalHandler() |
+{ |
+ count++; |
+ postMessage("worker"); |
+ |
+ if (count >= 2) |
+ { |
+ clearInterval(id); |
+ } |
+} |