pip-resize.https.html (1915B)
1 <!DOCTYPE html> 2 <title>Test resizeTo and resizeBy for a PiP window</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/resources/testdriver.js"></script> 6 <script src="/resources/testdriver-vendor.js"></script> 7 <body> 8 <script> 9 promise_test(async (t) => { 10 await test_driver.bless('request PiP window from top window'); 11 let pipWindow = await documentPictureInPicture.requestWindow({ 12 preferInitialWindowPlacement: true 13 }); 14 15 const iniWidth = pipWindow.innerWidth; 16 assert_true(true, `PIP has default inner width ${iniWidth}`); 17 18 await assert_throws_dom('NotAllowedError', pipWindow.DOMException, () => 19 pipWindow.resizeTo(pipWindow.outerWidth, pipWindow.outerHeight + 100) 20 , 'resizeTo requires user activation'); 21 22 await test_driver.bless('resize window'); 23 let resized = new Promise(res => pipWindow.addEventListener("resize", res, { once: true })); 24 pipWindow.resizeTo(pipWindow.outerWidth + 100, pipWindow.outerHeight); 25 await resized; 26 27 assert_equals(pipWindow.innerWidth, iniWidth + 100, 'PIP was resized'); 28 }, 'Test resizeTo PiP'); 29 30 promise_test(async (t) => { 31 await test_driver.bless('request PiP window from top window'); 32 let pipWindow = await documentPictureInPicture.requestWindow({ 33 preferInitialWindowPlacement: true 34 }); 35 36 const iniWidth = pipWindow.innerWidth; 37 assert_true(true, `PIP has default inner width ${iniWidth}`); 38 39 await assert_throws_dom('NotAllowedError', pipWindow.DOMException, () => 40 pipWindow.resizeBy(100, 0) 41 , 'resizeBy requires user activation'); 42 43 await test_driver.bless('resize window'); 44 let resized = new Promise(res => pipWindow.addEventListener("resize", res, { once: true })); 45 pipWindow.resizeBy(100, 0); 46 await resized; 47 48 assert_equals(pipWindow.innerWidth, iniWidth + 100, 'Width was resized with activation'); 49 }, 'Test resizeBy PiP'); 50 </script> 51 </body>