tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_tab_detach_vt.js (1538B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   https://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const TEST_PAGE = `
      7 <!doctype html>
      8 <style>
      9  :root::view-transition {
     10    background-color: pink;
     11  }
     12  :root::view-transition-group(*) {
     13    /* Keeps the transition up until timeout */
     14    animation-play-state: paused;
     15    opacity: 0;
     16  }
     17 </style>
     18 `;
     19 
     20 async function detachTab(tab) {
     21  let newWindowPromise = BrowserTestUtils.waitForNewWindow();
     22  await EventUtils.synthesizePlainDragAndDrop({
     23    srcElement: tab,
     24    // destElement is null because tab detaching happens due
     25    // to a drag'n'drop on an invalid drop target.
     26    destElement: null,
     27    // don't move horizontally because that could cause a tab move
     28    // animation, and there's code to prevent a tab detaching if
     29    // the dragged tab is released while the animation is running.
     30    stepX: 0,
     31    stepY: 100,
     32  });
     33  return newWindowPromise;
     34 }
     35 
     36 // Test for bug 1972259
     37 add_task(async function test_tab_detach_active_vt() {
     38  await BrowserTestUtils.withNewTab(
     39    {
     40      gBrowser,
     41      url: `https://example.com/document-builder.sjs?html=${encodeURIComponent(
     42        TEST_PAGE
     43      )}`,
     44    },
     45    async browser => {
     46      await ContentTask.spawn(browser, null, async function () {
     47        return content.document.startViewTransition().ready;
     48      });
     49      let newWin = await detachTab(gBrowser.selectedTab);
     50      ok(!!newWin, "Opened a new window, without crashing");
     51      await BrowserTestUtils.closeWindow(newWin);
     52    }
     53  );
     54 });