browser_viewport_resizing_minimum_scale.js (2012B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test viewport resizing, with and without meta viewport support. 7 8 const TEST_URL = 9 "data:text/html;charset=utf-8," + 10 "<!DOCTYPE html>" + 11 '<head><meta name="viewport" content="initial-scale=1.0, ' + 12 'minimum-scale=1.0, width=device-width"></head>' + 13 '<div style="width:100%;background-color:green">test</div>' + 14 "</body>"; 15 addRDMTask(TEST_URL, async function ({ ui, manager }) { 16 info("--- Starting viewport test output ---"); 17 18 // We're going to take a 300,600 viewport (before) and resize it 19 // to 600,300 (after) and then resize it back. At the before and 20 // after points, we'll measure zoom and the layout viewport width 21 // and height. 22 const expected = [ 23 { 24 before: { 25 zoom: 1.0, 26 width: 300, 27 height: 600, 28 }, 29 after: { 30 zoom: 1.0, 31 width: 600, 32 height: 300, 33 }, 34 }, 35 ]; 36 37 for (const e of expected) { 38 const b = e.before; 39 const a = e.after; 40 41 const message = "Meta Viewport ON"; 42 43 // Ensure meta viewport is set. 44 info(message + " setting meta viewport support."); 45 await setTouchAndMetaViewportSupport(ui, true); 46 47 // Get to the initial size and check values. 48 await setViewportSizeAndAwaitReflow(ui, manager, 300, 600); 49 await testViewportZoomWidthAndHeight( 50 message + " before resize", 51 ui, 52 b.zoom, 53 b.width, 54 b.height 55 ); 56 57 // Move to the smaller size. 58 await setViewportSizeAndAwaitReflow(ui, manager, 600, 300); 59 await testViewportZoomWidthAndHeight( 60 message + " after resize", 61 ui, 62 a.zoom, 63 a.width, 64 a.height 65 ); 66 67 // Go back to the initial size and check again. 68 await setViewportSizeAndAwaitReflow(ui, manager, 300, 600); 69 await testViewportZoomWidthAndHeight( 70 message + " return to initial size", 71 ui, 72 b.zoom, 73 b.width, 74 b.height 75 ); 76 } 77 });