Skip to content

emulation.setViewportMetaOverride#1073

Open
sadym-chromium wants to merge 3 commits into
mainfrom
sadym/emulation.setViewportMetaEnabled
Open

emulation.setViewportMetaOverride#1073
sadym-chromium wants to merge 3 commits into
mainfrom
sadym/emulation.setViewportMetaEnabled

Conversation

@sadym-chromium

@sadym-chromium sadym-chromium commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

Addressing #1053.

Introduce a new command emulation.setViewportMetaOverride allowing for force-using viewport <meta> element.

Defined the logic in the "8. Patches to Other Specifications" until the related CSS PR w3c/csswg-drafts#13548 is merged.


Preview | Diff

@sadym-chromium

Copy link
Copy Markdown
Contributor Author

@lutien WDYT?

Comment thread index.bs Outdated
Comment on lines +7039 to +7040
Note: no need to update the |affected navigables|, as |viewport meta override| takes affect
only after the next navigation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's clear that we have to trigger reflow somehow for the viewport meta tag to take effect. And I guess navigation is the only way to do it now (?). But I'm not sure if it's fine to just delay it to the next navigation. So tagging @jgraham and @juliandescottes to get their opinions.

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.

I'm not sure if it's only about a reflow, or if handling the viewport meta is only something that happens at navigation time. If it only requires a reflow, it sounds like we could try to apply this dynamically and maybe the spec should reflect that.

If not, if it's really something that can only be applied after navigation, it might be good to expose this to a user via an additional parameter that allows to reload impacted contexts? Otherwise if you want to set the emulation and make sure all impacted contexts are applying it you'd need to set the emulation, then get all the contexts, and then send individual reload commands.

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.

Agree. I updated the algorithm to trigger "evaluate media queries and report changes" which should be sufficient to re-calculate the viewport changes.

@sadym-chromium
sadym-chromium force-pushed the sadym/emulation.setViewportMetaEnabled branch from 8ad902e to e3843ca Compare February 27, 2026 12:49
Comment thread index.bs
1. Let |affected navigables| be the result of [=store WebDriver configuration=]
[=viewport meta override configuration=] |viewport meta override| for |command parameters|.

1. For each |navigable| of |affected navigables|, run [=evaluate media queries and report changes=]

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.

I believe this is sufficient to re-calculate the viewport meta, as according to the spec, the UA MUST use it after it is enabled.

@juliandescottes juliandescottes 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.

LGTM, one question + one thing to fix.

Comment thread index.bs
1. If |viewport meta override| is null, set |viewport meta override| to
[=WebDriver configuration/unset=].

1. Let |affected navigables| be the result of [=store WebDriver configuration=]

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.

This should use trying to

Suggested change
1. Let |affected navigables| be the result of [=store WebDriver configuration=]
1. Let |affected navigables| be the result of [=trying=] to [=store WebDriver configuration=]

Comment thread index.bs
Comment on lines +6951 to +6952
1. Let |navigable| be |document|'s [=node navigable=].

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.

I guess we don't really care about retrieving the top level navigable here, since the viewport meta is only relevant for top level documents? We could still do it for consistency though.

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.

4 participants