Skip to content

Derive test pass from possibleResults instead of hardcoded allowlists #555

Open

Description

@caugner

Description

Several analyzer tests compute output.pass by listing the passing Expectation values inline, e.g.:

output.pass = [
  expectation,
  Expectation.CoepNotImplemented,
  Expectation.CoepImplementedWithRequireCorp,
  Expectation.CoepImplementedWithCredentialless,
  Expectation.CoepImplementedWithUnsafeNone,
].includes(output.result ?? "");

This duplicates the list of results and is easy to get out of sync. Where a test has a single "failing" result, it can instead be inverted:

output.pass = output.result !== Expectation.CoepHeaderInvalid;

Alternatively, pass could be derived from static possibleResults (minus the known-failing ones).

Motivation

Reduce duplication and drift between possibleResults and the pass computation across tests.

Additional details

  • Applies at least to cross-origin-embedder-policy.js, cross-origin-opener-policy.js, and cross-origin-resource-policy.js (the latter uses the same pattern).
  • The expectation parameter also appears unused in practice and could be revisited as part of this.

Related issues and pull requests

Follow-up from review of #498.

Activity

  1. added
    needs triage
    on Jul 15, 2026
  2. caugner commented on Jul 17, 2026

    @caugner
    ContributorAuthor

    Maybe it would be best to list passingResults and failingResults separately, and deriving possibleResults as a union of it. The alternative is to make passingResults a list of objects instead of just strings, so each result declares if it passes or not, though the separate lists are clearer to read.

  3. removed
    needs triage
    on Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to 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