browser_default_zoom_multitab.js (6279B)
1 /* Any copyright is dedicated to the Public Domain. 2 * https://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 add_task(async function test_multidomain_global_zoom() { 7 // eslint-disable-next-line @microsoft/sdl/no-insecure-url 8 const TEST_PAGE_URL_1 = "http://example.com/"; 9 // eslint-disable-next-line @microsoft/sdl/no-insecure-url 10 const TEST_PAGE_URL_2 = "http://example.org/"; 11 12 // Prepare the test tabs 13 console.log("Creating tab 1"); 14 let tab1 = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL_1); 15 let tabBrowser1 = gBrowser.getBrowserForTab(tab1); 16 await FullZoomHelper.selectTabAndWaitForLocationChange(tab1); 17 18 console.log("Creating tab 2"); 19 let tab2 = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL_2); 20 let tabBrowser2 = gBrowser.getBrowserForTab(tab2); 21 await FullZoomHelper.selectTabAndWaitForLocationChange(tab2); 22 23 // 67% global zoom 24 console.log("Changing default zoom"); 25 await FullZoomHelper.changeDefaultZoom(67); 26 let defaultZoom = await FullZoomHelper.getGlobalValue(); 27 is(defaultZoom, 0.67, "Global zoom is set to 67%"); 28 29 // 67% local zoom tab 1 30 console.log("Selecting tab 1"); 31 await FullZoomHelper.selectTabAndWaitForLocationChange(tab1); 32 await TestUtils.waitForCondition(() => { 33 console.log( 34 "Currnet zoom is: ", 35 ZoomManager.getZoomForBrowser(tabBrowser1) 36 ); 37 return ZoomManager.getZoomForBrowser(tabBrowser1) == 0.67; 38 }); 39 is( 40 ZoomManager.getZoomForBrowser(tabBrowser1), 41 0.67, 42 "Setting default zoom causes tab 1 (background) to zoom to default zoom." 43 ); 44 45 // 67% local zoom tab 2 46 console.log("Selecting tab 2"); 47 await FullZoomHelper.selectTabAndWaitForLocationChange(tab2); 48 await TestUtils.waitForCondition(() => { 49 console.log( 50 "Current zoom is: ", 51 ZoomManager.getZoomForBrowser(tabBrowser2) 52 ); 53 return ZoomManager.getZoomForBrowser(tabBrowser2) == 0.67; 54 }); 55 is( 56 ZoomManager.getZoomForBrowser(tabBrowser2), 57 0.67, 58 "Setting default zoom causes tab 2 (foreground) to zoom to default zoom." 59 ); 60 console.log("Enlarging tab"); 61 await FullZoom.enlarge(); 62 // 80% local zoom tab 2 63 await TestUtils.waitForCondition(() => { 64 console.log( 65 "Current zoom is: ", 66 ZoomManager.getZoomForBrowser(tabBrowser2) 67 ); 68 return ZoomManager.getZoomForBrowser(tabBrowser2) == 0.8; 69 }); 70 is( 71 ZoomManager.getZoomForBrowser(tabBrowser2), 72 0.8, 73 "Enlarging local zoom of tab 2." 74 ); 75 76 // 67% local zoom tab 1 77 console.log("Selecting tab 1"); 78 await FullZoomHelper.selectTabAndWaitForLocationChange(tab1); 79 await TestUtils.waitForCondition(() => { 80 console.log( 81 "Current zoom is: ", 82 ZoomManager.getZoomForBrowser(tabBrowser1) 83 ); 84 return ZoomManager.getZoomForBrowser(tabBrowser1) == 0.67; 85 }); 86 is( 87 ZoomManager.getZoomForBrowser(tabBrowser1), 88 0.67, 89 "Tab 1 is unchanged by tab 2's enlarge call." 90 ); 91 console.log("Removing tab"); 92 await FullZoomHelper.removeTabAndWaitForLocationChange(); 93 console.log("Removing tab"); 94 await FullZoomHelper.removeTabAndWaitForLocationChange(); 95 }); 96 97 add_task(async function test_site_specific_global_zoom() { 98 // eslint-disable-next-line @microsoft/sdl/no-insecure-url 99 const TEST_PAGE_URL_1 = "http://example.net/"; 100 // eslint-disable-next-line @microsoft/sdl/no-insecure-url 101 const TEST_PAGE_URL_2 = "http://example.net/"; 102 103 // Prepare the test tabs 104 console.log("Adding tab 1"); 105 let tab1 = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL_1); 106 console.log("Getting tab 1 browser"); 107 let tabBrowser1 = gBrowser.getBrowserForTab(tab1); 108 await FullZoomHelper.selectTabAndWaitForLocationChange(tab1); 109 110 console.log("Adding tab 2"); 111 let tab2 = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL_2); 112 console.log("Getting tab 2 browser"); 113 let tabBrowser2 = gBrowser.getBrowserForTab(tab2); 114 await FullZoomHelper.selectTabAndWaitForLocationChange(tab2); 115 116 console.log("checking global zoom"); 117 // 67% global zoom persists from previous test 118 let defaultZoom = await FullZoomHelper.getGlobalValue(); 119 is(defaultZoom, 0.67, "Default zoom is 67%"); 120 121 // 67% local zoom tab 1 122 console.log("Selecting tab 1"); 123 await FullZoomHelper.selectTabAndWaitForLocationChange(tab1); 124 console.log("Awaiting condition"); 125 await TestUtils.waitForCondition(() => { 126 console.log( 127 "Current tab 1 zoom is: ", 128 ZoomManager.getZoomForBrowser(tabBrowser1) 129 ); 130 return ZoomManager.getZoomForBrowser(tabBrowser1) == 0.67; 131 }); 132 is( 133 ZoomManager.getZoomForBrowser(tabBrowser1), 134 0.67, 135 "Setting default zoom causes tab 1 (background) to zoom to default zoom." 136 ); 137 138 // 67% local zoom tab 2 139 console.log("Selecting tab 2"); 140 await FullZoomHelper.selectTabAndWaitForLocationChange(tab2); 141 console.log("Awaiting condition"); 142 await TestUtils.waitForCondition(() => { 143 console.log( 144 "Current tab 2 zoom is: ", 145 ZoomManager.getZoomForBrowser(tabBrowser2) 146 ); 147 return ZoomManager.getZoomForBrowser(tabBrowser2) == 0.67; 148 }); 149 is( 150 ZoomManager.getZoomForBrowser(tabBrowser2), 151 0.67, 152 "Setting default zoom causes tab 2 (foreground) to zoom to default zoom." 153 ); 154 155 // 80% site specific zoom 156 console.log("Selecting tab 1"); 157 await FullZoomHelper.selectTabAndWaitForLocationChange(tab1); 158 console.log("Enlarging"); 159 await FullZoom.enlarge(); 160 await TestUtils.waitForCondition(() => { 161 console.log( 162 "Current tab 1 zoom is: ", 163 ZoomManager.getZoomForBrowser(tabBrowser1) 164 ); 165 return ZoomManager.getZoomForBrowser(tabBrowser1) == 0.8; 166 }); 167 is( 168 ZoomManager.getZoomForBrowser(tabBrowser1), 169 0.8, 170 "Changed local zoom in tab one." 171 ); 172 console.log("Selecting tab 2"); 173 await FullZoomHelper.selectTabAndWaitForLocationChange(tab2); 174 await TestUtils.waitForCondition(() => { 175 console.log( 176 "Current tab 2 zoom is: ", 177 ZoomManager.getZoomForBrowser(tabBrowser2) 178 ); 179 return ZoomManager.getZoomForBrowser(tabBrowser2) == 0.8; 180 }); 181 is( 182 ZoomManager.getZoomForBrowser(tabBrowser2), 183 0.8, 184 "Second tab respects site specific zoom." 185 ); 186 console.log("Removing tab"); 187 await FullZoomHelper.removeTabAndWaitForLocationChange(); 188 console.log("Removing tab"); 189 await FullZoomHelper.removeTabAndWaitForLocationChange(); 190 });