minimize_restore_popup.html (1497B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>TestDriver minimize/restore method in popup</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/resources/testdriver.js"></script> 7 <script src="/resources/testdriver-vendor.js"></script> 8 9 <script> 10 const params = new URLSearchParams(location.search); 11 const is_popup_page = params.has('popup'); 12 const channel = new BroadcastChannel("testchannel"); 13 14 if (is_popup_page) { 15 onload = async () => { 16 window.opener.events.push(document.visibilityState); 17 let rect = await test_driver.minimize_window(); 18 window.opener.events.push(document.visibilityState); 19 await test_driver.set_window_rect(rect); 20 window.opener.events.push(document.visibilityState); 21 channel.postMessage("done"); 22 }; 23 } else { 24 promise_test(async t => { 25 let popup; 26 onload = () => { 27 window.events = []; 28 popup = window.open("?popup"); 29 }; 30 31 await new Promise(resolve => { 32 channel.addEventListener( 33 "message", t.step_func(async (e) => { 34 if (e.data === "done") { 35 const expectedEvents = ["visible", "hidden", "visible"]; 36 assert_array_equals(window.events, expectedEvents, 'incorrect event order'); 37 popup.close(); 38 resolve(); 39 } 40 })); 41 }); 42 }, `minimize and restore on popup`); 43 } 44 </script>