Skip to content

Make j$.isError_ compatible with Trusted Types#1921

Merged
sgravrock merged 1 commit into
jasmine:mainfrom
bjarkler:iserror-tt
Jul 19, 2021
Merged

Make j$.isError_ compatible with Trusted Types#1921
sgravrock merged 1 commit into
jasmine:mainfrom
bjarkler:iserror-tt

Conversation

@bjarkler

@bjarkler bjarkler commented Jul 1, 2021

Copy link
Copy Markdown
Contributor

The isError_ check uses a heuristic that calls the Function constructor
to determine if the given value is an Error object. This results in a
runtime violation in test suites that enforce Trusted Types.

Since Trusted Types are only supported in modern browsers (currently,
Chromium-based browsers), we can use a more straightforward heuristic in
environments where Trusted Types are supported.

Fixes #1910. See that thread for more details.

How Has This Been Tested?

With npm test as well as npm run serve and running the test suite in Chrome 91 (which supports Trusted Types) and Safari 14.1 (which does not support Trusted Types), both on macOS.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

cc @sgravrock

The isError_ check uses a heuristic that calls the Function constructor
to determine if the given value is an Error object. This results in a
runtime violation in test suites that enforce Trusted Types.

Since Trusted Types are only supported in modern browsers (currently,
Chromium-based browsers), we can use a more straightforward heuristic in
environments where Trusted Types are supported.

Fixes jasmine#1910. See that thread for more details.
@sgravrock sgravrock merged commit 21bfbbb into jasmine:main Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

j$.isError_ is not compatible with Trusted Types

2 participants