Skip to content

Commit

Permalink
Merge pull request #97 from w3c/jgraham/notify_postmessage
Browse files Browse the repository at this point in the history
Use postMessage for notifications to the harness window.
  • Loading branch information
sideshowbarker committed May 23, 2015
2 parents ff7b640 + 7cc13d2 commit 624d896
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
3 changes: 2 additions & 1 deletion wptrunner/executors/executorservo.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ def screenshot(self, test):

try:
self.proc.run()
rv = self.proc.wait(timeout=test.timeout)
timeout = test.timeout * self.timeout_multiplier + 5
rv = self.proc.wait(timeout=timeout)
except KeyboardInterrupt:
self.proc.kill()
raise
Expand Down
15 changes: 7 additions & 8 deletions wptrunner/executors/testharness_marionette.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,23 @@
window.wrappedJSObject.timeout_multiplier = %(timeout_multiplier)d;
window.wrappedJSObject.explicit_timeout = %(explicit_timeout)d;

window.wrappedJSObject.done = function(tests, status) {
window.wrappedJSObject.addEventListener("message", function(event) {
var tests = event.data[0];
var status = event.data[1];
clearTimeout(timer);
var test_results = tests.map(function(x) {
return {name:x.name, status:x.status, message:x.message, stack:x.stack}
});
marionetteScriptFinished({test:"%(url)s",
tests:test_results,
tests: tests,
status: status.status,
message: status.message,
stack: status.stack});
}
}, false);

window.wrappedJSObject.win = window.open("%(abs_url)s", "%(window_id)s");

var timer = null;
if (%(timeout)s) {
timer = setTimeout(function() {
log("Timeout fired");
window.wrappedJSObject.win.timeout();
log("Timeout fired");
window.wrappedJSObject.win.timeout();
}, %(timeout)s);
}
11 changes: 5 additions & 6 deletions wptrunner/executors/testharness_webdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
var callback = arguments[arguments.length - 1];
window.timeout_multiplier = %(timeout_multiplier)d;

window.done = function(tests, status) {
window.addEventListener("message", function(event) {
var tests = event.data[0];
var status = event.data[1];
clearTimeout(timer);
var test_results = tests.map(function(x) {
return {name:x.name, status:x.status, message:x.message, stack:x.stack}
});
callback({test:"%(url)s",
tests:test_results,
tests: tests,
status: status.status,
message: status.message,
stack: status.stack});
}
}, false);

window.win = window.open("%(abs_url)s", "%(window_id)s");

Expand Down
10 changes: 9 additions & 1 deletion wptrunner/testharnessreport.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ if (window.opener && window.opener.explicit_timeout) {
setup(props);
add_completion_callback(function() {
add_completion_callback(function(tests, status) {
window.opener.done(tests, status)
var harness_status = {
"status": status.status,
"message": status.message,
"stack": status.stack
};
var test_results = tests.map(function(x) {
return {name:x.name, status:x.status, message:x.message, stack:x.stack}
});
window.opener.postMessage([test_results, harness_status], "*");
})
});

0 comments on commit 624d896

Please sign in to comment.