Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: third_party/WebKit/LayoutTests/imported/wpt/workers/support/Timer.js

Issue 2418853003: Worker: Import "imported/wpt/workers" tests (Retry) (Closed)
Patch Set: rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698