Skip to content

fix: avoid unconditional use of window in policy creation logic#1234

Merged
chrisjshull merged 2 commits into
googlemaps:mainfrom
usefulthink:fix/no-window
Jun 9, 2026
Merged

fix: avoid unconditional use of window in policy creation logic#1234
chrisjshull merged 2 commits into
googlemaps:mainfrom
usefulthink:fix/no-window

Conversation

@usefulthink

@usefulthink usefulthink commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Fixes #1233 🦕

Comment thread src/setScriptSrc.test.ts Outdated

// @jest-environment node
describe("setScriptSrc(): SSR safety", () => {
it("should be importable when window is not available", async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case our infra changes over time, can you assert that window is not available for this test?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, added a check for this

Comment thread src/setScriptSrc.test.ts
describe("setScriptSrc(): SSR safety", () => {
it("should be importable when window is not available", async () => {
await expect(import("./setScriptSrc.js")).resolves.toBeDefined();
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's also get some coverage of what the expected output is, both for supported Trusted Types envs and unsupported envs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also added tests for the different new and old behaviors of setScriptSrc

@chrisjshull chrisjshull left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty!

@chrisjshull chrisjshull merged commit 2db1e08 into googlemaps:main Jun 9, 2026
14 checks passed
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.

Window is not defined

2 participants