forked from mirrors/gecko-dev
		
	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
		
			
				
	
	
		
			53 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
"use strict";
 | 
						|
 | 
						|
// Opening non-popup from a popup should open a new tab in the most recent
 | 
						|
// non-popup window.
 | 
						|
add_task(async function test_non_popup_from_popup() {
 | 
						|
  const BLANK_PAGE = "data:text/html,";
 | 
						|
 | 
						|
  // A page opened in a new tab.
 | 
						|
  const OPEN_PAGE = "data:text/plain,hello";
 | 
						|
 | 
						|
  // A page opened in a new popup.
 | 
						|
  // This opens a new non-popup page with OPEN_PAGE,
 | 
						|
  // tha should be opened in a new tab in most recent window.
 | 
						|
  const NON_POPUP_OPENER = btoa(
 | 
						|
    `data:text/html,<script>window.open('${OPEN_PAGE}', '', '')</script>`
 | 
						|
  );
 | 
						|
 | 
						|
  // A page opened in a new tab.
 | 
						|
  // This opens a popup with NON_POPUP_OPENER.
 | 
						|
  const POPUP_OPENER = `data:text/html,<script>window.open(atob("${NON_POPUP_OPENER}"), "", "width=500");</script>`;
 | 
						|
 | 
						|
  await SpecialPowers.pushPrefEnv({
 | 
						|
    set: [["browser.link.open_newwindow", 3]],
 | 
						|
  });
 | 
						|
 | 
						|
  await BrowserTestUtils.withNewTab(
 | 
						|
    {
 | 
						|
      gBrowser,
 | 
						|
      url: BLANK_PAGE,
 | 
						|
    },
 | 
						|
    async function(browser) {
 | 
						|
      // Wait for a popup opened by POPUP_OPENER.
 | 
						|
      const newPopupPromise = BrowserTestUtils.waitForNewWindow();
 | 
						|
 | 
						|
      // Wait for a new tab opened by NON_POPUP_OPENER.
 | 
						|
      const newTabPromise = BrowserTestUtils.waitForNewTab(gBrowser, OPEN_PAGE);
 | 
						|
 | 
						|
      // Open a new tab that opens a popup with NON_POPUP_OPENER.
 | 
						|
      BrowserTestUtils.loadURI(gBrowser, POPUP_OPENER);
 | 
						|
 | 
						|
      let win = await newPopupPromise;
 | 
						|
      Assert.ok(true, "popup is opened");
 | 
						|
 | 
						|
      let tab = await newTabPromise;
 | 
						|
      Assert.ok(true, "new tab is opened in the recent window");
 | 
						|
 | 
						|
      BrowserTestUtils.removeTab(tab);
 | 
						|
      await BrowserTestUtils.closeWindow(win);
 | 
						|
    }
 | 
						|
  );
 | 
						|
 | 
						|
  await SpecialPowers.popPrefEnv();
 | 
						|
});
 |