Skip to content

Commit cd85139

Browse files
Fix a zoom issue in emulated desktop mode on Android (#1573)
* Fix a zoom issue in emulated desktop mode on Android * Fix viewport tests * Limit the scope of the minimum-scale fix --------- Co-authored-by: Jonathan Kingston <[email protected]>
1 parent 2f1ce09 commit cd85139

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

injected/integration-test/web-compat.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,25 @@ test.describe('Viewport fixes', () => {
574574
);
575575
});
576576

577+
test('should override minimum-scale, if it is set', async ({ page }) => {
578+
await gotoAndWait(
579+
page,
580+
'/blank.html',
581+
{
582+
site: { enabledFeatures: ['webCompat'] },
583+
featureSettings: { webCompat: { viewportWidth: 'enabled' } },
584+
desktopModeEnabled: true,
585+
},
586+
'document.head.innerHTML += \'<meta name="viewport" content="width=device-width, initial-scale=2, user-scalable=no, minimum-scale=1, something-something">\'',
587+
);
588+
const width = await page.evaluate('screen.width');
589+
const expectedWidth = width < 1280 ? 980 : 1280;
590+
const viewportValue = await page.evaluate(getViewportValue);
591+
expect(viewportValue).toEqual(
592+
`width=${expectedWidth}, initial-scale=${(width / expectedWidth).toFixed(3)}, user-scalable=yes, minimum-scale=0, something-something`,
593+
);
594+
});
595+
577596
test('should force wide viewport, ignoring the viewport tag 2', async ({ page }) => {
578597
await gotoAndWait(
579598
page,

injected/src/features/web-compat.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,11 @@ export class WebCompat extends ContentFeature {
719719
// Race condition: depending on the loading state of the page, initial scale may or may not be respected, so the page may look zoomed-in after applying this hack.
720720
// Usually this is just an annoyance, but it may be a bigger issue if user-scalable=no is set, so we remove it too.
721721
forcedValues['user-scalable'] = 'yes';
722+
const minimumScalePart = parsedViewportContent.find(([key]) => key === 'minimum-scale');
723+
if (minimumScalePart) {
724+
// override minimum-scale to make sure you can zoom out to see the whole page. See https://app.asana.com/1/137249556945/project/1206777341262243/task/1207691440660873
725+
forcedValues['minimum-scale'] = 0;
726+
}
722727
} else {
723728
// mobile mode with a viewport tag
724729
// fix an edge case where WebView forces the wide viewport

0 commit comments

Comments
 (0)