Skip to content

Add a test for PermissionsPolicyViolationReportBody #856

@Elchi3

Description

@Elchi3

I couldn't find good docs on MDN about this :(
https://github.com/w3c/webappsec-permissions-policy/blob/main/reporting.md has some good info, though.

I reckon we need some custom test like below plus a way to actually trigger a permission policy violation.

  PermissionsPolicyViolationReportBody:
    __base: |-
      // Note: the Content-Security-Policy header is already configured on this website
      if (!('ReportingObserver' in self)) {
        return {result: false, message: 'ReportingObserver is not defined'};
      }

      // Create the observer
      var observer = new ReportingObserver(
        function(reports, observer) {
          var instance = reports.length && reports[0].body;
          callback(instance);
          observer.disconnect();
        },
        {
          types: ["permissions-policy-violation"],
          buffered: true,
        }
      );

      // Start observing
      observer.observe();
    toJSON: |-
      function callback(instance) {
        try {
          success(!!instance && 'toJSON' in instance);
        } catch(e) {
          fail(e);
        }
      }
      return 'callback';

PermissionsPolicyViolationReportBody ships in Chrome 120 and wasn't detected by our collector, see mdn/browser-compat-data#21148 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions