Skip to content

Commit

Permalink
[COOP] access reporting: fix flakes reporting.html (#25834)
Browse files Browse the repository at this point in the history
---

The WPT testharness.js is defining:
```
WindowTestEnvironment.prototype._forEach_windows = function(callback) {
// Iterate over the windows [self ... top, opener]. The callback is
// passed two objects, the first one is the window object itself, the
// second one is a boolean indicating whether or not it's on the same
// origin as the (...)
```

This causes some postMessage to be sent cross-window. They are reported
and causes failures. For instance in reporting-observer.html test.

This patch removes testharness.js from executor.html
This fixed the issue for reporting-observer.html

More generally, we shouldn't check access in between two windows, when
one of them is using testharness.js

---

Second discovery:
The official web-platform-test runner sometimes drop POST requests
when many are requested in parallel. Using a lock fixes the issue.

---

Bug: 1090273
Change-Id: I261b9bfece935e3613c250a3a9402a1c8a6ff14e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2436742
Commit-Queue: Arthur Sonzogni <[email protected]>
Reviewed-by: Pâris Meuleman <[email protected]>
Cr-Commit-Position: refs/heads/master@{#855712}

Co-authored-by: arthursonzogni <[email protected]>
  • Loading branch information
chromium-wpt-export-bot and ArthurSonzogni committed Feb 22, 2021
1 parent b30c16e commit 9b505f9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions html/cross-origin-opener-policy/reporting/resources/dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,27 @@ const dispatcher_path =
'/html/cross-origin-opener-policy/reporting/resources/dispatcher.py';
const dispatcher_url = new URL(dispatcher_path, location.href).href;

const send = function(uuid, message) {
fetch(dispatcher_url + `?uuid=${uuid}`, {
method: 'POST',
body: message
const send = async function(uuid, message) {
// The official web-platform-test runner sometimes drop POST requests when
// many are requested in parallel. Using a lock fixes the issue.
await navigator.locks.request("dispatcher_send", async lock => {
await fetch(dispatcher_url + `?uuid=${uuid}`, {
method: 'POST',
body: message
});
});
}

const receive = async function(uuid, maybe_timeout) {
const timeout = maybe_timeout || Infinity;
const retry_delay = 100;
for(let i = 0; i * retry_delay < timeout; ++i) {
let start = performance.now();
while(performance.now() - start < timeout) {
let response = await fetch(dispatcher_url + `?uuid=${uuid}`);
let data = await response.text();
if (data != 'not ready')
return data;
await new Promise(r => step_timeout(r, retry_delay));
// Save resources & spread the load:
await new Promise(r => setTimeout(r, 100*Math.random()));
}
return "timeout";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<script src=/resources/testharness.js></script>
<script src="./dispatcher.js"></script>
<script src="./try-access.js"></script>
<script>
Expand Down
1 change: 1 addition & 0 deletions lint.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ SET TIMEOUT: feature-policy/experimental-features/resources/focus-without-user-a
SET TIMEOUT: permissions-policy/experimental-features/resources/focus-without-user-activation-iframe-tentative.html
SET TIMEOUT: html/browsers/windows/auxiliary-browsing-contexts/resources/close-opener.html
SET TIMEOUT: html/cross-origin-embedder-policy/resources/reporting-worker.js
SET TIMEOUT: html/cross-origin-opener-policy/reporting/resources/dispatcher.js
SET TIMEOUT: html/dom/documents/dom-tree-accessors/Document.currentScript.html
SET TIMEOUT: html/webappapis/timers/*
SET TIMEOUT: orientation-event/resources/orientation-event-helpers.js
Expand Down

0 comments on commit 9b505f9

Please sign in to comment.