Bug 1490505 [wpt PR 12957] - [csp] Remove cookies following test completion, a=testonly
authorjugglinmike <mike@mikepennisi.com>
Tue, 09 Oct 2018 04:14:09 +0000
changeset 495957 61366a5d2ba916ea91ec730781e6ddcd8ee010b2
parent 495956 045207d4b58a072e7780cdf244906d756982106a
child 495958 7b67ae2b52aedb838bb7be437812bb96d1bb1809
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1490505, 12957
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1490505 [wpt PR 12957] - [csp] Remove cookies following test completion, a=testonly Automatic update from web-platform-testsMerge pull request #12957 from bocoup/csp-cleanup [csp] Remove cookies following test completion Approved by @andypaicu in https://github.com/web-platform-tests/wpt/pull/12957 -- wpt-commits: 660a69402170f880e9cd17d9c8a5998b47d446bf wpt-pr: 12957
testing/web-platform/tests/content-security-policy/reporting/report-cross-origin-no-cookies.sub.html
testing/web-platform/tests/content-security-policy/reporting/report-same-origin-with-cookies.html
--- a/testing/web-platform/tests/content-security-policy/reporting/report-cross-origin-no-cookies.sub.html
+++ b/testing/web-platform/tests/content-security-policy/reporting/report-cross-origin-no-cookies.sub.html
@@ -5,26 +5,32 @@
     <script src="/resources/testharnessreport.js"></script>
     <title>Cookies are not sent on cross origin violation reports</title>
     <!-- CSP headers
          Content-Security-Policy: script-src 'unsafe-inline' 'self'; img-src 'none'; report-uri http://{{domains[www1]}}:{{ports[http][0]}}/content-security-policy/support/report.py?op=put&reportID=$id
          -->
 </head>
 <body>
 <script>
-  var test = async_test("Image should not load");
-  fetch(
-    "/cookies/resources/set-cookie.py?name=cspViolationReportCookie1&path=" + encodeURIComponent("{{domains[www1]}}:{{ports[http][0]}}/"),
-    {mode: 'no-cors', credentials: 'include'})
-  .then(() => {
-    // This image will generate a CSP violation report.
-    const img = new Image();
-    img.onerror = test.step_func_done();
-    img.onload = test.unreached_func("Should not have loaded the image");
+  promise_test(function(test) {
+	const path = encodeURIComponent("{{domains[www1]}}:{{ports[http][0]}}/");
+    return fetch(
+      "/cookies/resources/set-cookie.py?name=cspViolationReportCookie1&path=" + path,
+      {mode: 'no-cors', credentials: 'include'})
+    .then(() => {
+      test.add_cleanup(() => {
+        return fetch("/cookies/resources/set.py?cspViolationReportCookie1=; path=" + path + "; expires=Thu, 01 Jan 1970 00:00:01 GMT");
+      });
 
-    img.src = "../support/fail.png";
-    document.body.appendChild(img);
-  });
+      // This image will generate a CSP violation report.
+      const img = new Image();
+      img.onerror = test.step_func_done();
+      img.onload = test.unreached_func("Should not have loaded the image");
+
+      img.src = "../support/fail.png";
+      document.body.appendChild(img);
+    });
+  }, "Image should not load");
 </script>
 <script async defer src='../support/checkReport.sub.js?reportField=violated-directive&reportValue=img-src%20%27none%27&noCookies=true'></script>
 
 </body>
 </html>
--- a/testing/web-platform/tests/content-security-policy/reporting/report-same-origin-with-cookies.html
+++ b/testing/web-platform/tests/content-security-policy/reporting/report-same-origin-with-cookies.html
@@ -10,16 +10,20 @@
 </head>
 <body>
 <script>
   var test = async_test("Image should not load");
   fetch(
     "/cookies/resources/set-cookie.py?name=cspViolationReportCookie2&path=" + encodeURIComponent("/"),
     {mode: 'no-cors', credentials: 'include'})
   .then(() => {
+    test.add_cleanup(() => {
+      document.cookie = "cspViolationReportCookie2=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT";
+    });
+
     // This image will generate a CSP violation report.
     const img = new Image();
     img.onerror = test.step_func_done();
     img.onload = test.unreached_func("Should not have loaded the image");
 
     img.src = "../support/fail.png";
     document.body.appendChild(img);
   });