browser_mousewheel_zoom.js (2313B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 "use strict"; 5 6 const TEST_PAGE = 7 // eslint-disable-next-line @microsoft/sdl/no-insecure-url 8 "http://example.org/browser/browser/base/content/test/zoom/zoom_test.html"; 9 10 var gTab1, gTab2, gLevel1; 11 12 function test() { 13 waitForExplicitFinish(); 14 15 // Scroll on Ctrl + mousewheel 16 SpecialPowers.pushPrefEnv({ set: [["mousewheel.with_control.action", 3]] }); 17 18 (async function () { 19 gTab1 = BrowserTestUtils.addTab(gBrowser); 20 gTab2 = BrowserTestUtils.addTab(gBrowser); 21 22 await FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); 23 await FullZoomHelper.load(gTab1, TEST_PAGE); 24 await FullZoomHelper.load(gTab2, TEST_PAGE); 25 })().then(zoomTab1, FullZoomHelper.failAndContinue(finish)); 26 } 27 28 function zoomTab1() { 29 (async function () { 30 is(gBrowser.selectedTab, gTab1, "Tab 1 is selected"); 31 FullZoomHelper.zoomTest(gTab1, 1, "Initial zoom of tab 1 should be 1"); 32 FullZoomHelper.zoomTest(gTab2, 1, "Initial zoom of tab 2 should be 1"); 33 34 let browser1 = gBrowser.getBrowserForTab(gTab1); 35 await BrowserTestUtils.synthesizeMouse( 36 null, 37 10, 38 10, 39 { 40 wheel: true, 41 ctrlKey: true, 42 deltaY: -1, 43 deltaMode: WheelEvent.DOM_DELTA_LINE, 44 }, 45 browser1 46 ); 47 48 info("Waiting for tab 1 to be zoomed"); 49 await TestUtils.waitForCondition(() => { 50 gLevel1 = ZoomManager.getZoomForBrowser(browser1); 51 return gLevel1 > 1; 52 }); 53 54 await FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); 55 FullZoomHelper.zoomTest( 56 gTab2, 57 gLevel1, 58 "Tab 2 should have zoomed along with tab 1" 59 ); 60 })().then(finishTest, FullZoomHelper.failAndContinue(finish)); 61 } 62 63 function finishTest() { 64 (async function () { 65 await FullZoomHelper.selectTabAndWaitForLocationChange(gTab1); 66 await FullZoom.reset(); 67 await FullZoomHelper.removeTabAndWaitForLocationChange(gTab1); 68 await FullZoomHelper.selectTabAndWaitForLocationChange(gTab2); 69 await FullZoom.reset(); 70 await FullZoomHelper.removeTabAndWaitForLocationChange(gTab2); 71 })().then(finish, FullZoomHelper.failAndContinue(finish)); 72 }