navigation-state-reset-crossorigin.sub.html (2107B)
1 <!DOCTYPE html> 2 <html> 3 <head> 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 <script src="resources/utils.js"></script> 9 </head> 10 <body> 11 <h1>Post-navigation activation state in child</h1> 12 <p>Tests that navigating a cross-origin child frame resets its activation states.</p> 13 <ol id="instructions"> 14 <li>Click inside the yellow area. 15 </ol> 16 <iframe id="child" width="200" height="50"> 17 </iframe> 18 <script> 19 async_test(function(t) { 20 var child = document.getElementById("child"); 21 child.src = "http://{{hosts[alt][]}}:{{ports[http][0]}}/html/user-activation/resources/child-one.html"; 22 window.addEventListener("message", t.step_func(event => { 23 // Test driver can send messages too... 24 if (typeof event.data !== "string") return; 25 26 var msg = JSON.parse(event.data); 27 if (msg.type == 'child-one-loaded') { 28 assert_false(navigator.userActivation.isActive); 29 assert_false(navigator.userActivation.hasBeenActive); 30 assert_false(msg.isActive); 31 assert_false(msg.hasBeenActive); 32 33 delayByFrames(() => test_driver.click(child), 5); 34 } else if (msg.type == 'child-one-clicked') { 35 assert_true(navigator.userActivation.isActive); 36 assert_true(navigator.userActivation.hasBeenActive); 37 assert_true(msg.isActive); 38 assert_true(msg.hasBeenActive); 39 40 child.src = "http://{{hosts[alt][]}}:{{ports[http][1]}}/html/user-activation/resources/child-two.html"; 41 } else if (msg.type == 'child-two-loaded') { 42 assert_true(navigator.userActivation.isActive); 43 assert_true(navigator.userActivation.hasBeenActive); 44 assert_false(msg.isActive); 45 assert_false(msg.hasBeenActive); 46 47 t.done(); 48 } 49 })); 50 }, "Post-navigation state reset."); 51 </script> 52 </body> 53 </html>