forked from mirrors/gecko-dev
		
	 42028efc71
			
		
	
	
		42028efc71
		
	
	
	
	
		
			
			This method only is async in order to allow callers to wait for a process switch triggered by the call to `loadURI` to be finished before resolving. With DocumentChannel, we should never trigger a process switch eagerly like this again, so we don't need any of the async behaviour here anymore. This part is largely mechanical changes to tests, removing the `await` calls on `loadURI`, and a follow-up part will remove the actual async logic from `BrowserTestUtils.loadURI`. Differential Revision: https://phabricator.services.mozilla.com/D94641
		
			
				
	
	
		
			80 lines
		
	
	
	
		
			2.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			80 lines
		
	
	
	
		
			2.4 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| /* This Source Code Form is subject to the terms of the Mozilla Public
 | |
|  * License, v. 2.0. If a copy of the MPL was not distributed with this
 | |
|  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 | |
| 
 | |
| // This test makes sure that about:privatebrowsing does not appear zoomed in
 | |
| // if there is already a zoom site pref for about:blank (bug 487656).
 | |
| 
 | |
| add_task(async function test() {
 | |
|   // initialization
 | |
|   let windowsToClose = [];
 | |
|   let windowsToReset = [];
 | |
| 
 | |
|   function promiseLocationChange() {
 | |
|     return new Promise(resolve => {
 | |
|       Services.obs.addObserver(function onLocationChange(subj, topic, data) {
 | |
|         Services.obs.removeObserver(onLocationChange, topic);
 | |
|         resolve();
 | |
|       }, "browser-fullZoom:location-change");
 | |
|     });
 | |
|   }
 | |
| 
 | |
|   async function promiseTestReady(aIsZoomedWindow, aWindow) {
 | |
|     // Need to wait on two things, the ordering of which is not guaranteed:
 | |
|     // (1) the page load, and (2) FullZoom's update to the new page's zoom
 | |
|     // level.  FullZoom broadcasts "browser-fullZoom:location-change" when its
 | |
|     // update is done.  (See bug 856366 for details.)
 | |
| 
 | |
|     let browser = aWindow.gBrowser.selectedBrowser;
 | |
|     BrowserTestUtils.loadURI(browser, "about:blank");
 | |
|     await Promise.all([
 | |
|       BrowserTestUtils.browserLoaded(browser),
 | |
|       promiseLocationChange(),
 | |
|     ]);
 | |
|     doTest(aIsZoomedWindow, aWindow);
 | |
|   }
 | |
| 
 | |
|   function doTest(aIsZoomedWindow, aWindow) {
 | |
|     if (aIsZoomedWindow) {
 | |
|       is(
 | |
|         aWindow.ZoomManager.zoom,
 | |
|         1,
 | |
|         "Zoom level for freshly loaded about:blank should be 1"
 | |
|       );
 | |
|       // change the zoom on the blank page
 | |
|       aWindow.FullZoom.enlarge();
 | |
|       isnot(
 | |
|         aWindow.ZoomManager.zoom,
 | |
|         1,
 | |
|         "Zoom level for about:blank should be changed"
 | |
|       );
 | |
|       return;
 | |
|     }
 | |
| 
 | |
|     // make sure the zoom level is set to 1
 | |
|     is(
 | |
|       aWindow.ZoomManager.zoom,
 | |
|       1,
 | |
|       "Zoom level for about:privatebrowsing should be reset"
 | |
|     );
 | |
|   }
 | |
| 
 | |
|   function testOnWindow(options, callback) {
 | |
|     return BrowserTestUtils.openNewBrowserWindow(options).then(win => {
 | |
|       windowsToClose.push(win);
 | |
|       windowsToReset.push(win);
 | |
|       return win;
 | |
|     });
 | |
|   }
 | |
| 
 | |
|   await testOnWindow({}).then(win => promiseTestReady(true, win));
 | |
|   await testOnWindow({ private: true }).then(win =>
 | |
|     promiseTestReady(false, win)
 | |
|   );
 | |
| 
 | |
|   // cleanup
 | |
|   windowsToReset.forEach(win => win.FullZoom.reset());
 | |
|   await Promise.all(
 | |
|     windowsToClose.map(win => BrowserTestUtils.closeWindow(win))
 | |
|   );
 | |
| });
 |