head.js (718B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 async function newTabWithPiP() { 5 // Create a tab that can use the API (secure context) 6 const tab = await BrowserTestUtils.openNewForegroundTab({ 7 gBrowser, 8 opening: "https://example.com", 9 waitForLoad: true, 10 }); 11 const browser = tab.linkedBrowser; 12 13 // Open a document PiP window 14 const chromePiPPromise = BrowserTestUtils.waitForNewWindow(); 15 await SpecialPowers.spawn(browser, [], async () => { 16 content.document.notifyUserGestureActivation(); 17 await content.documentPictureInPicture.requestWindow(); 18 }); 19 const chromePiP = await chromePiPPromise; 20 21 return [tab, chromePiP]; 22 }