-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wptrunner] Transmit test results via postMessage #13881
[wptrunner] Transmit test results via postMessage #13881
Conversation
A recent improvement to wptrunner modified the way data structures are transmitted from the browser to the WebDriver server [1]. One consequence of this change is that the data structures are created in a JavaScript realm which differs from the realm in which the "Execute Script" WebDriver command is running. As of version 17, Microsoft Edge does not correctly serialize cross-realm values, so referenced improvement unintentionally precluded testing in that browser. Transmit data structures between realms via the `postMessage` API to avoid this problem. [1] web-platform-tests#13419
@jugglinmike, infrastructure/ tests are failing on Travis, can you see about fixing those? |
Looks like I was a little too aggressive in trying to remove global state. I think I've resolved this by caching the https://tools.taskcluster.net/groups/Mmj2u8piTuyoDlvdad2gGg This branch is currently based on ffeba23, so we should compare with the Taskcluster results for that commit: |
@lukebjerring @Hexcles how can we get https://tools.taskcluster.net/groups/Mmj2u8piTuyoDlvdad2gGg into wpt.fyi for a comparison? This is a perfect case for #13263 :) |
The Taskcluster webhook takes all the task groups and turns them into artifact URLs, and then posts to the results receiver with a full list of all of those URLs.. might be worth extracting that code, and exposing it into another api endpoint which is Taskcluster specific. However, as a one off, you could reproduce the same list of urls and send the POST event yourself? |
So, with a little scrape of the UI:
Looks like the task ID is in the URL you gave (
|
In theory, the following scrape of URLs, and a hack for /admin/results/upload, might result in the output we want: I (cheekily) ran it as EDIT: Yeah FF worked, so ran chrome too. |
Amazing, thanks @lukebjerring! @jugglinmikes, looks like there are regressions to investigate here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jugglinmike plz look through the regressions @lukebjerring linked
I took the weekend off, but this is on the docket for today. |
FWIW we eventually need to work on getting this to work without |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what you're doing here is OK, but it's a larger than necessary change from the current design which makes it harder to reason about the correctness.
if (!event) { | ||
|
||
if (event.data.type === "testdriver-resume") { | ||
source = event.source; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand the point of this; it seems like the identity of the test window is statically known here; it's window.win
. Why do we need to keep updating it?
}; | ||
|
||
source.postMessage({ | ||
type: "testdriver-next message", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type string doesn't match anything else.
window.opener.testdriver_callback = callback; | ||
window.opener.process_next_event(); | ||
|
||
window.addEventListener("message", function handle(event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the pattern where we keep adding and removing message listeners; we've had bags with such code before. Ideally we define the message handler once in testharnessreport.js
and just have this script update the current callback and resume the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong button, sorry!
On Friday, we learned that in addition to tripping up Edge, gh-13419 interferes with the semantics of some tests (see gh-13876). That prompted @jgraham to begin work on an alternate solution which reduces the number of browsing contexts to one. As James noted above, that approach will also enable contributors to test more parts of the platform. We discussed simplifying this patch to use as a short-term fix. @jgraham shared some details about what they had in mind, but I'm having trouble interpreting them. What I have locally is no less complicated than this patch, and it's still not quite right, somehow. I'm time-boxing my effort on this because we expect the change to be short-lived. That's why I'm proposing an even simpler change: gh-13938. That will not fix support for the invalidated tests, but it will correct the regression to Microsoft Edge. That may be preferable to reverting gh-13419 altogether. |
Superseded by gh-13938. |
A recent improvement to wptrunner modified the way data structures are
transmitted from the browser to the WebDriver server [1]. One
consequence of this change is that the data structures are created in a
JavaScript realm which differs from the realm in which the "Execute
Script" WebDriver command is running. As of version 17, Microsoft Edge
does not correctly serialize cross-realm values, so referenced
improvement unintentionally precluded testing in that browser.
Transmit data structures between realms via the
postMessage
API toavoid this problem.
[1] #13419
This is the reason we've recently been reporting such laughably incomplete results for Edge on wpt.fyi. I've also submitted WebDriver spec tests for the expected serialization behavior