helper_basic_zoom.html (3106B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="viewport" content="width=device-width"> 6 <title>Sanity check for zooming</title> 7 <script type="application/javascript" src="apz_test_native_event_utils.js"></script> 8 <script type="application/javascript" src="apz_test_utils.js"></script> 9 <script src="/tests/SimpleTest/paint_listener.js"></script> 10 <script src="/tests/SimpleTest/EventUtils.js"></script> 11 <script type="application/javascript"> 12 13 async function test() { 14 let visResEvt = new EventCounter(window.visualViewport, "resize"); 15 let visScrEvt = new EventCounter(window.visualViewport, "scroll"); 16 // Our internal visual viewport events aren't restricted to the visual view- 17 // port itself, so we can listen on the window itself, however the event 18 // listener needs to be in the system group. 19 let visResEvtInternal = new EventCounter(window, "mozvisualresize", 20 { mozSystemGroup: true }); 21 let visScrEvtInternal = new EventCounter(window, "mozvisualscroll", 22 { mozSystemGroup: true }); 23 let visResEvtContent = new EventCounter(window, "mozvisualresize"); 24 let visScrEvtContent = new EventCounter(window, "mozvisualscroll"); 25 26 var initial_resolution = await getResolution(); 27 ok(initial_resolution > 0, 28 "The initial_resolution is " + initial_resolution + ", which is some sane value"); 29 30 await pinchZoomInWithTouch(150, 300); 31 32 // Flush state and get the resolution we're at now 33 await promiseApzFlushedRepaints(); 34 let final_resolution = await getResolution(); 35 ok(final_resolution > initial_resolution, "The final resolution (" + final_resolution + ") is greater after zooming in"); 36 37 // Check we've got the expected events. 38 // Pinch-zooming the page should fire visual viewport resize events: 39 visResEvt.unregister(); 40 ok(visResEvt.count > 0, "Got some visual viewport resize events"); 41 visResEvtInternal.unregister(); 42 ok(visResEvtInternal.count > 0, "Got some mozvisualresize events"); 43 44 // We're pinch-zooming somewhere in the middle of the page, so the visual 45 // viewport's coordinates change, too. 46 // This is true both relative to the page (mozvisualscroll), as well as 47 // relative to the layout viewport (visual viewport "scroll" event). 48 visScrEvt.unregister(); 49 ok(visScrEvt.count > 0, "Got some visual viewport scroll events"); 50 visScrEvtInternal.unregister(); 51 ok(visScrEvtInternal.count > 0, "Got some mozvisualscroll events"); 52 53 // Our internal events shouldn't leak to normal content. 54 visResEvtContent.unregister(); 55 is(visResEvtContent.count, 0, "Got no mozvisualresize events in content"); 56 visScrEvtContent.unregister(); 57 is(visScrEvtContent.count, 0, "Got no mozvisualscroll events in content"); 58 } 59 60 waitUntilApzStable() 61 .then(test) 62 .then(subtestDone, subtestFailed); 63 64 </script> 65 </head> 66 <body> 67 Here is some text to stare at as the test runs. It serves no functional 68 purpose, but gives you an idea of the zoom level. It's harder to tell what 69 the zoom level is when the page is just solid white. 70 </body> 71 </html>