[Extra zoom mode] fast/visual-viewport/extrazoom/layout-viewport-after-scrolling...
[WebKit-https.git] / LayoutTests / fast / viewport / extrazoom / viewport-change-min-device-width.html
1 <!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
2 <html>
3 <meta name="viewport" id="meta">
4 <head>
5     <script src="../../../resources/js-test.js"></script>
6     <script src="../../../resources/ui-helper.js"></script>
7     <style>
8         body, html {
9             margin: 0;
10             width: 100%;
11             height: 100%;
12         }
13     </style>
14     <script>
15         jsTestIsAsync = true;
16
17         function logWindowDimensionsAfterSettingViewportContent(content) {
18             return new Promise(async resolve => {
19                 meta.setAttribute("content", content);
20                 await UIHelper.ensureVisibleContentRectUpdate();
21                 debug(`[${meta.getAttribute("content")}] (${innerWidth}, ${innerHeight})`);
22                 resolve();
23             });
24         }
25
26         async function runTest() {
27             if (!window.testRunner) {
28                 description("Please use WebKitTestRunner to run this test.");
29                 return;
30             }
31
32             debug("1. Default viewport");
33             await logWindowDimensionsAfterSettingViewportContent("width=150");
34             await logWindowDimensionsAfterSettingViewportContent("width=device-width");
35             scaleAtDeviceWidthWithInitialShrinkToFit = parseFloat(await UIHelper.zoomScale()).toFixed(3);
36             await logWindowDimensionsAfterSettingViewportContent("width=600");
37
38             debug("\n2. shrink-to-fit explicitly disabled");
39             await logWindowDimensionsAfterSettingViewportContent("width=150, shrink-to-fit=no");
40             await logWindowDimensionsAfterSettingViewportContent("width=device-width, shrink-to-fit=0");
41             scaleAtDeviceWidthWithShrinkToFitDisabled = parseFloat(await UIHelper.zoomScale()).toFixed(3);
42             await logWindowDimensionsAfterSettingViewportContent("width=600, shrink-to-fit=-0.5");
43
44             debug("\n3. shrink-to-fit explicitly enabled");
45             await logWindowDimensionsAfterSettingViewportContent("width=150, shrink-to-fit=yes");
46             await logWindowDimensionsAfterSettingViewportContent("width=device-width, shrink-to-fit=1");
47             scaleAtDeviceWidthWithShrinkToFitEnabled = parseFloat(await UIHelper.zoomScale()).toFixed(3);
48             await logWindowDimensionsAfterSettingViewportContent("width=600, shrink-to-fit=device-width");
49
50             shouldBe("scaleAtDeviceWidthWithInitialShrinkToFit", "'0.488'");
51             shouldBe("scaleAtDeviceWidthWithShrinkToFitDisabled", "'1.000'");
52             shouldBe("scaleAtDeviceWidthWithShrinkToFitEnabled", "'0.488'");
53
54             finishJSTest();
55         }
56     </script>
57 </head>
58 <body onload="runTest()">
59 </body>
60 </html>