Title: [239707] trunk/LayoutTests
Revision
239707
Author
[email protected]
Date
2019-01-07 15:42:43 -0800 (Mon, 07 Jan 2019)

Log Message

LayoutTests/http/wpt/fetch/csp-reports-bypass-csp-checks.html is flaky
https://bugs.webkit.org/show_bug.cgi?id=193178

Reviewed by Chris Dumez.

Test was flaky as the ping load CSP report request might be sent after the
fetch that grabs the report.
To overcome that issue, fetch the report several times until receiving a report.

* http/wpt/fetch/csp-reports-bypass-csp-checks.html:
* http/wpt/fetch/resources/store-csp-report.py:
(main):

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (239706 => 239707)


--- trunk/LayoutTests/ChangeLog	2019-01-07 23:34:27 UTC (rev 239706)
+++ trunk/LayoutTests/ChangeLog	2019-01-07 23:42:43 UTC (rev 239707)
@@ -1,3 +1,18 @@
+2019-01-07  Youenn Fablet  <[email protected]>
+
+        LayoutTests/http/wpt/fetch/csp-reports-bypass-csp-checks.html is flaky
+        https://bugs.webkit.org/show_bug.cgi?id=193178
+
+        Reviewed by Chris Dumez.
+
+        Test was flaky as the ping load CSP report request might be sent after the
+        fetch that grabs the report.
+        To overcome that issue, fetch the report several times until receiving a report.
+
+        * http/wpt/fetch/csp-reports-bypass-csp-checks.html:
+        * http/wpt/fetch/resources/store-csp-report.py:
+        (main):
+
 2019-01-07  Dean Jackson  <[email protected]>
 
         Turn on Pointer Events by default for iOS

Modified: trunk/LayoutTests/http/wpt/fetch/csp-reports-bypass-csp-checks.html (239706 => 239707)


--- trunk/LayoutTests/http/wpt/fetch/csp-reports-bypass-csp-checks.html	2019-01-07 23:34:27 UTC (rev 239706)
+++ trunk/LayoutTests/http/wpt/fetch/csp-reports-bypass-csp-checks.html	2019-01-07 23:42:43 UTC (rev 239707)
@@ -5,9 +5,17 @@
 <body>
 <script>
 document.addEventListener("securitypolicyviolation", async () => {
-    const response = await fetch("/WebKit/fetch/resources/store-csp-report.py?retrieve=true&file=reports-bypass-csp-checks");
-    let results = await response.json();
-
+    let counter = 0;
+    let text;
+    while (++counter <= 20) {
+        const response = await fetch("/WebKit/fetch/resources/store-csp-report.py?retrieve=true&file=reports-bypass-csp-checks");
+        text = await response.text();
+        // Let's check whether we have a CSP report.
+        if (text.startsWith("{"))
+            break;
+        await new Promise(resolve => setTimeout(resolve, 50));
+    }
+    let results = JSON.parse(text);
     const report = results["csp-report"];
     if (report["effective-directive"] === "connect-src") {
         assert_equals(report["blocked-uri"], "http://localhost:8888");

Modified: trunk/LayoutTests/http/wpt/fetch/resources/store-csp-report.py (239706 => 239707)


--- trunk/LayoutTests/http/wpt/fetch/resources/store-csp-report.py	2019-01-07 23:34:27 UTC (rev 239706)
+++ trunk/LayoutTests/http/wpt/fetch/resources/store-csp-report.py	2019-01-07 23:42:43 UTC (rev 239707)
@@ -23,6 +23,11 @@
       value = request.server.stash.take(testId)
       response.writer.write(value)
     except (KeyError, ValueError) as e:
+      response.headers.set("Access-Control-Allow-Origin", "*")
+      response.headers.set("Cache-Control", "no-cache, no-store, must-revalidate")
+      response.headers.set("Pragma", "no-cache")
+      response.headers.set("Expires", "0")
+      response.writer.end_headers()
       response.writer.write("No report has been recorded " + str(e))
       pass
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to