[Feature] allow viewport size to be independent from the window size
See original GitHub issueI’m trying to test for responsive behavior of my library, The tests inspect the HTML state in a specific size, resize the viewport and re-check the state.
First of all, for debugging, I really like the behavior of the fixed viewport which allows debugging with a full window while keeping the document viewport restricted.
However there are several issues with the way the viewport works that makes it hard to build responsive tests:
- once viewport is set, there is no way to return to
viewport: null(setViewportSize doesn’t accept null). - changing the viewport size also triggers a change to the window size - that makes it hard to run multiple tests under the same window and removes the nice benefit that the separation of window & viewport sizes gives. It is also not consistent across browsers (Chromium changes size and if the dev tools are open it might minimize to hide the viewport while Firefox only changes the viewport and doesn’t change the window), it would be nice to maybe add a flag to prevent changing the window size.
- There is no API to control the window size (although it exist under the devTools protocol: setWindowBounds, getWindowBounds).
Giving control over the window size and viewport size would really help building maintainable tests for libraries, applications and websites resize behavior.
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Window.innerWidth - Web APIs | MDN
An integer value indicating the width of the window's layout viewport in pixels. This property is read-only, and has no default value. To...
Read more >Using jQuery To Get Size of Viewport - resize - Stack Overflow
To get the width and height of the viewport: var viewportWidth = $(window).width(); var viewportHeight = $(window).height();.
Read more >Using React Hooks to Recognize & Respond to Current ...
In this useEffect , I created a function named handleResize() which is responsible for setting my local state variables of showMobileNavView ...
Read more >Responsive web design basics
Using the meta viewport value width=device-width instructs the page to match the screen's width in device-independent pixels.
Read more >Supporting different screens in web apps - Android Developers
For example, although a device screen might have physical a width of 480 pixels, the viewport can have a width of 800 pixels....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thank you for contributing!
I think this is the easiest way. Just check outerWidth/outerHeight before/after calling the method with and without the flag.
emulation.spec.jsis the right place. Mark it asit.skip(!CHROMIUM).Oh, that’s bad news. Mind sharing the list of failing tests? We are serious about fighting flakiness.
Sure, why not. I think it would be easier to discuss in the PR itself.
Tests for rpc could be run with
PWCHANNEL=1 npm run test. This is still experimental, but plumbing it through will be the right thing.I opened a PR.
About the failing tests:
ERROR: the process "XXXX" not foundwhen running only on Chromium (not getting them when running withPWCHANNEL=1)