window-open-multi-global.html (1713B)
1 <!DOCTYPE html> 2 <title>window.open() and consuming user activation with multiple globals in play</title> 3 <link rel="help" href="https://html.spec.whatwg.org/#window-open-steps"> 4 <link rel="help" href="https://html.spec.whatwg.org/#the-rules-for-choosing-a-navigable"> 5 <!-- 6 2. Let sourceDocument be the entry global object's associated Document. 7 10. Let targetNavigable and windowType be the result of applying the rules for choosing a navigable 8 given target, sourceDocument's node navigable, and noopener. 9 --> 10 <script src="/resources/testharness.js"></script> 11 <script src="/resources/testharnessreport.js"></script> 12 <script src="/resources/testdriver.js"></script> 13 <script src="/resources/testdriver-vendor.js"></script> 14 15 <!-- This is the entry global --> 16 17 <script> 18 'use strict'; 19 20 function pageDone(expectedMessage) { 21 return new Promise(resolve => { 22 window.addEventListener('message', e => { 23 if (e.data === expectedMessage) { 24 resolve(); 25 } 26 }); 27 }); 28 } 29 30 promise_test(async function(t) { 31 await test_driver.bless("open incumbent popup"); 32 const incumbentDone = pageDone("incumbent page"); 33 const incumbentWin = window.open("support/incumbent.html", "_blank"); 34 // incumbent.html opens two further popups and sets these properties (for this window): 35 // window.currentWin 36 // window.relevantWin 37 await incumbentDone; 38 await test_driver.bless("user activation in entry global"); 39 const testWin = incumbentWin.openTestPopup(); 40 t.add_cleanup(() => { 41 testWin.close(); 42 relevantWin.close(); 43 currentWin.close(); 44 incumbentWin.close(); 45 }); 46 assert_false(navigator.userActivation.isActive, "User activation of the entry global should be consumed"); 47 }); 48 </script>