PageRenderTime 52ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/third_party/blink/web_tests/external/wpt/html/cross-origin-opener-policy/reporting/navigation-reporting/reporting-coop-navigated-popup.https.html

https://github.com/chromium/chromium
HTML | 85 lines | 78 code | 7 blank | 0 comment | 0 complexity | 9ead84f36f9b90bcb7536f33434c9dc8 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, Apache-2.0, BSD-3-Clause
  1. <title>Cross-Origin-Opener-Policy: a navigated popup with reporting</title>
  2. <script src=/resources/testharness.js></script>
  3. <script src=/resources/testharnessreport.js></script>
  4. <script src="/common/utils.js"></script> <!-- Use token() to allow running tests in parallel -->
  5. <script src="/common/dispatcher/dispatcher.js"></script>
  6. <script
  7. src="/html/cross-origin-opener-policy/reporting/resources/reporting-common.js?pipe=sub&report_id=df3cde15-b00b-4a59-b6e2-498b67a6146e&report_only_id=ebf3a415-7a74-42e1-92d1-e600b1bbe22e"></script>
  8. <script>
  9. // This test does the following:
  10. // 1 - This document has COOP: same-origin-allow-popups; report-to="coop-report-endpoint"
  11. // 2 - Open a popup on a same-origin page without COOP, with the coop-popup-report-endpoint
  12. // 3 - Navigate the popup to a same-origin page with COOP, with the coop-redirect-report-endpoint
  13. // it verifies that the reports are properly send for the browsing context switch
  14. // during the navigation in the popup (step 3). The current document (the opener)
  15. // endpoint should not receive any report as no switch ocurred on 2.
  16. promise_test( async t => {
  17. const callbackToken = token();
  18. const noCoopToken = token();
  19. const coopToken= token();
  20. await reportingTest(async resolve => {
  21. const noCOOPUrl = executor_path +
  22. convertToWPTHeaderPipe(getReportingEndpointsHeader(location.origin)) +
  23. `|header(Cross-Origin-Opener-Policy,${encodeURIComponent(`unsafe-none; report-to="${popupReportEndpoint.name}"`)})` +
  24. `&uuid=${noCoopToken}`;
  25. const coopUrl = executor_path +
  26. convertToWPTHeaderPipe(getReportingEndpointsHeader(location.origin)) +
  27. `|header(Cross-Origin-Opener-Policy,${encodeURIComponent(`same-origin; report-to="${redirectReportEndpoint.name}"`)})` +
  28. `&uuid=${coopToken}`;
  29. // 1. Open a popup without COOP and with reporting. COOP does not trigger
  30. // a browsing context group switch because the current document is
  31. // same-origin-allow-popups
  32. const popup = window.open(noCOOPUrl);
  33. t.add_cleanup(() => send(noCoopToken, "window.close()"));
  34. // 2. Navigate the popup to a COOP document, which switches the browsing
  35. // context group.
  36. send(noCoopToken, `window.location = "${coopUrl}";`);
  37. t.add_cleanup(() => send(coopToken, "window.close()"));
  38. // 3. Make sure the new document is loaded.
  39. send(coopToken, `
  40. send("${callbackToken}", "Ready");
  41. `);
  42. let reply = await receive(callbackToken);
  43. resolve();
  44. },
  45. "", // executor token for the report replacements, unused in this test
  46. [
  47. // Reports expected for the navigation from "noCOOP" to "coop"
  48. {
  49. "endpoint": popupReportEndpoint,
  50. "report": {
  51. "body": {
  52. "disposition": "enforce",
  53. "effectivePolicy": "unsafe-none",
  54. "nextResponseURL": RegExp(`uuid=${coopToken}$`),
  55. "type": "navigation-from-response"
  56. },
  57. "url": RegExp(`uuid=${noCoopToken}$`),
  58. "type": "coop"
  59. }
  60. },
  61. {
  62. "endpoint": redirectReportEndpoint,
  63. "report": {
  64. "body": {
  65. "disposition": "enforce",
  66. "effectivePolicy": "same-origin",
  67. "previousResponseURL": RegExp(`uuid=${noCoopToken}$`),
  68. "referrer": RegExp(`uuid=${noCoopToken}$`),
  69. "type": "navigation-to-response"
  70. },
  71. "url": RegExp(`uuid=${coopToken}$`),
  72. "type": "coop"
  73. }
  74. },
  75. ]);
  76. }, "Open a popup to a document without COOP, then navigate it to a document with");
  77. verifyRemainingReports();
  78. </script>