Skip to content

Commit 5273909

Browse files
committed
[testharnessreport.js] Only pay attention to the top-level completion handler
https://bugs.webkit.org/show_bug.cgi?id=259409 rdar://problem/112683033 Reviewed by Jonathan Bedard. Previously, we were considering the test as having to run to completion when any testharness.js completion handler first ran (which was sometimes that of the frame within the opened window; the nondeterminism here just adds flakiness to the already bad behaviour). Instead, only output anything for the top-level completion handler, as all results should be passed up to it. Note wptrunner with the WebDriver or Marionette executors only ever pays attention to the top-level completion handler (as they only pay attention to the top-level frame & window), thus they don't have any flakiness like this. Ideally testharness.js would have an API we could use for this; I've filed an RFC at web-platform-tests/rfcs#168 for this, but there's no reason not to do the simple fix ourselves, as at least for now this is a strict progression. (It would stop being a strict progression if at some point testharness.js started allowing fetch_tests_from_window() with a window with noopener.) It seems likely we have other tests that are marked as flaky because of it, but alas there's no easy way to find what tests will have been fixed by this. * LayoutTests/TestExpectations: * LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/basic-upgrade-cors.https-expected.txt: * LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/basic-upgrade-cors.https.html: * LayoutTests/imported/w3c/web-platform-tests/cookies/partitioned-cookies/partitioned-cookies.tentative.https-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/source/navigate-child-function-parent-then-fragment-expected.txt: * LayoutTests/platform/wk2/TestExpectations: * LayoutTests/resources/testharnessreport.js: Canonical link: https://commits.webkit.org/269483@main
1 parent b4cd98a commit 5273909

File tree

7 files changed

+35
-11
lines changed

7 files changed

+35
-11
lines changed

LayoutTests/TestExpectations

+1
Original file line numberDiff line numberDiff line change
@@ -6163,6 +6163,7 @@ imported/w3c/web-platform-tests/html/browsers/browsing-the-web/history-traversal
61636163
imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/004.html [ Skip ]
61646164
imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-global-scope.html [ Skip ]
61656165
imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/navigate-cross-origin-iframe-to-same-url-with-fragment-fire-load-event.html [ Skip ]
6166+
imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/source/navigate-child-function-parent-then-fragment.html [ Skip ]
61666167
imported/w3c/web-platform-tests/html/browsers/browsing-the-web/unloading-documents/004.html [ Skip ]
61676168
imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/008.html [ Skip ]
61686169
imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/combination_history_004.html [ Skip ]

LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/basic-upgrade-cors.https-expected.txt

+3
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ CONSOLE MESSAGE: PASS: Successfully retrieved image data.
22
This test opens a window that loads an insecure image. We should upgrade this request and thereby avoid triggering a mixed content callback.
33

44

5+
6+
PASS Verify that images have correct cross-origin behavior.
7+
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<!DOCTYPE html>
22
<html>
3+
<head>
4+
<script src="/js-test-resources/testharness.js"></script>
5+
<script src="/js-test-resources/testharnessreport.js"></script>
36
<body>
4-
<script>
5-
if (window.testRunner) {
6-
testRunner.waitUntilDone();
7-
testRunner.dumpAsText();
8-
}
9-
</script>
107
<p>This test opens a window that loads an insecure image. We should upgrade
118
this request and thereby avoid triggering a mixed content callback.</p>
129
<iframe src="https://127.0.0.1:8443/security/contentSecurityPolicy/upgrade-insecure-requests/resources/basic-upgrade-cors.https.html"></iframe>
10+
<script>
11+
fetch_tests_from_window(window.frames[0]);
12+
</script>
1313
</body>
1414
</html>

LayoutTests/imported/w3c/web-platform-tests/cookies/partitioned-cookies/partitioned-cookies.tentative.https-expected.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
FAIL Partitioned cookies accessible on the top-level site they are created in via HTTP assert_equals: Expected __Host-pccookistore to be available on the top-level site it was created in expected true but got false
3-
FAIL Partitioned cookies accessible on the top-level site they are created in via DOM assert_equals: Expected __Host-pccookistore to be available on the top-level site it was created in expected true but got false
4-
FAIL Partitioned cookies accessible on the top-level site they are created in via CookieStore assert_equals: Expected __Host-pccookistore to be available on the top-level site it was created in expected true but got false
2+
FAIL Partitioned cookies accessible on the top-level site they are created in via HTTP assert_equals: Expected __Host-pccookiestore to be available on the top-level site it was created in expected true but got false
3+
FAIL Partitioned cookies accessible on the top-level site they are created in via DOM assert_equals: Expected __Host-pccookiestore to be available on the top-level site it was created in expected true but got false
4+
FAIL Partitioned cookies accessible on the top-level site they are created in via CookieStore assert_equals: Expected __Host-pccookiestore to be available on the top-level site it was created in expected true but got false
55
PASS Cross-site window opened correctly
66
FAIL Partitioned cookies are not accessible on a different top-level site via HTTP assert_equals: Expected __Host-pchttp to not be available on a different top-level site expected false but got true
77
FAIL Partitioned cookies are not accessible on a different top-level site via DOM assert_equals: Expected __Host-pchttp to not be available on a different top-level site expected false but got true
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
11

2+
3+
Harness Error (TIMEOUT), message = null
4+
5+
TIMEOUT
6+
Set location from a parent, then do a fragment navigation from within the
7+
frame.
8+
Test timed out
9+

LayoutTests/platform/wk2/TestExpectations

-2
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,6 @@ webkit.org/b/253533 imported/w3c/web-platform-tests/fetch/api/basic/status.h2.an
874874
webkit.org/b/253533 imported/w3c/web-platform-tests/fetch/api/basic/status.h2.any.worker.html [ Pass Failure ]
875875
webkit.org/b/253533 imported/w3c/web-platform-tests/xhr/status.h2.window.html [ Pass Failure ]
876876

877-
webkit.org/b/259409 imported/w3c/web-platform-tests/cookies/partitioned-cookies/partitioned-cookies.tentative.https.html [ Pass Failure ]
878-
879877
webkit.org/b/259482 fast/media/managed-media-source-open-crash.html [ Pass Failure ]
880878

881879
webkit.org/b/260640 [ Release arm64 ] editing/execCommand/apply-inline-style-to-element-with-no-renderer-crash.html [ Pass Failure ]

LayoutTests/resources/testharnessreport.js

+14
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
* parameters they are called with see testharness.js
1111
*/
1212

13+
(function(){
14+
1315
// Setup for WebKit JavaScript tests
1416
if (self.testRunner) {
1517
testRunner.dumpAsText();
@@ -57,10 +59,20 @@ if (self.testRunner) {
5759
*/
5860
setup({"output": false, "explicit_timeout": true});
5961

62+
// window.opener is a configurable property, so store it before we run anything.
63+
const orig_opener = window.opener;
64+
6065
/* Using a callback function, test results will be added to the page in a
6166
* manner that allows dumpAsText to produce readable test results
6267
*/
6368
add_completion_callback(function (tests, harness_status) {
69+
// Only pay attention to results at the top-level window.
70+
// Ideally testharness.js would allow us to only attach a completion handler in this case:
71+
// https://github.com/web-platform-tests/rfcs/pull/168
72+
if (window !== window.top || (orig_opener !== null && orig_opener !== window)) {
73+
return;
74+
}
75+
6476
var resultStr = "\n";
6577

6678
// Sanitizes the given text for display in test results.
@@ -140,3 +152,5 @@ if (self.testRunner) {
140152
}, 0);
141153
});
142154
}
155+
156+
})();

0 commit comments

Comments
 (0)