Unreviewed. Update W3C WebDriver imported tests.
[WebKit-https.git] / WebDriverTests / imported / w3c / tools / wptrunner / wptrunner / executors / testharness_webdriver_resume.js
1 var callback = arguments[arguments.length - 1];
2
3 function process_event(event) {
4   var data = event.data;
5
6   var payload = undefined;
7
8   switch(data.type) {
9   case "complete":
10     var tests = event.data.tests;
11     var status = event.data.status;
12
13     var subtest_results = tests.map(function(x) {
14       return [x.name, x.status, x.message, x.stack];
15     });
16     payload = [status.status,
17                status.message,
18                status.stack,
19                subtest_results];
20     clearTimeout(window.timer);
21     break;
22
23   case "action":
24     window.setMessageListener(function(event) {
25       window.message_queue.push(event);
26     });
27     payload = data;
28     break;
29   }
30
31   callback(["%(url)s", data.type, payload]);
32 }
33
34 window.removeEventListener("message", window.current_listener);
35 if (window.message_queue.length) {
36   var next = window.message_queue.shift();
37   process_event(next);
38 } else {
39   window.addEventListener(
40     "message", function f(event) {
41       window.removeEventListener("message", f);
42       process_event(event);
43     }, false);
44 }