test_nested_event_loop_spin_and_idle_tasks.html (1007B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Nested event loop spinning and idle task handling</title> 6 <script src="/tests/SimpleTest/SimpleTest.js"></script> 7 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/> 8 <script> 9 if (!location.search.includes("newpage")) { 10 SimpleTest.waitForExplicitFinish(); 11 var win = window.open(this.location + "?newpage"); 12 win.onload = function() { 13 var xhr = new XMLHttpRequest(); 14 // Spin the event loop using a synchronous XMLHttpRequest. 15 xhr.open("GET", "slow.sjs", false); 16 xhr.send(); 17 ok(win.didRunIdleCallback, "Should have run an idle callback."); 18 win.close(); 19 SimpleTest.finish(); 20 } 21 } else { 22 var didRunIdleCallback = false; 23 requestIdleCallback(function() { 24 didRunIdleCallback = true; 25 }); 26 } 27 </script> 28 </head> 29 <body> 30 <p id="display"></p> 31 <div id="content" style="display: none"></div> 32 <pre id="test"></pre> 33 </body> 34 </html>