Skip to content

fix(system-info): guard compute-pressure observer behind permissions policy - #23

Merged
antsukanova merged 2 commits into
mainfrom
antsukan/system-info-pressure
Sep 3, 2026
Merged

fix(system-info): guard compute-pressure observer behind permissions policy#23
antsukanova merged 2 commits into
mainfrom
antsukan/system-info-pressure

Conversation

@antsukanova

@antsukanova antsukanova commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Description

  • Prevent SystemInfo imports from starting CPU pressure observation when the document permissions policy denies compute-pressure.
  • Handle observer construction and asynchronous observe() failures so restricted cross-origin iframes do not produce unhandled promise rejections.
  • Preserve CPU pressure monitoring when policy access is allowed or policy inspection is unavailable.

Testing

  • yarn test
  • Manually loaded the linked package in a cross-origin test iframe. Both denied and allow="compute-pressure" cases completed with zero unhandled rejections.

This change implements...

  • A new feature
  • A bug fix
  • Other (please specify):

Is this a breaking change?

  • Yes
  • No

I certify that...

  • All relevant unit and integration tests have passed and/or have been updated according to this change.

Generative AI (GAI) Usage Disclosure

Reference: Cisco GAI Coding Guidelines

  • Cisco approved GAI tool/IDE was used for coding - eg: VSCode, Cursor, Windsurf, Codex, Claude code
  • No GAI - Code was written entirely manually without GAI assistance

If a GAI tool/IDE was used then select the category that best describes GAI usage in this PR:

  • Manual Draft with GAI Refinement - I/we created a draft manually that was non-substantively modified by GAI (e.g., refactoring was performed by GAI on manually written code) (Default)
  • GAI Draft with Manual Customization - GAI tool was used to create a draft that I/we subsequently customized or modified.
  • GAI Generated Code - Code was generated entirely by GAI

Additional GAI Usage Details (Optional):

@antsukanova
antsukanova marked this pull request as ready for review September 3, 2026 09:25
@wiekiera

wiekiera commented Sep 3, 2026

Copy link
Copy Markdown

Overall looks fine for me, except testing stuff - there are many conditions in setPermissionsPolicy function depends on testing scenarios that can make hard to debug and tell whats gone wrong if something fails. In my opinion the test scenario should be simple and readable, even if some code overlaps with other tests. This is not the time for doing it when customer is waiting for the fix. I will let you know if it's working - need to test it on local environment then we can merge it.

@wiekiera

wiekiera commented Sep 3, 2026

Copy link
Copy Markdown

Tested - seems It won't break anything existing

@antsukanova

antsukanova commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

@wiekiera Thanks, fair point. The setup is more involved because SystemInfo creates the observer during module import, so each case requires a fresh module load and mocked browser globals. I used setPermissionsPolicy to keep the individual tests focused, but I agree that the scenario mapping adds some complication.
These tests will need revisiting with the planned API change anyway, so we can simplify this setup then. 🙌

@antsukanova
antsukanova merged commit 9aab1eb into main Sep 3, 2026
1 check passed
@antsukanova
antsukanova deleted the antsukan/system-info-pressure branch September 3, 2026 11:39
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.

2 participants