test_async_stacks.html (2444B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1148593 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 1148593</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 <script type="application/javascript"> 12 /* global noSuchFunction */ 13 14 /** Test for Bug 1148593 */ 15 16 SimpleTest.waitForExplicitFinish(); 17 18 var TESTS; 19 20 function nextTest() { 21 var t = TESTS.pop(); 22 if (t) { 23 t(); 24 } else { 25 SimpleTest.finish(); 26 } 27 } 28 29 function checkStack(functionName) { 30 try { 31 noSuchFunction(); 32 } catch (e) { 33 ok(e.stack.includes(functionName), "stack includes " + functionName); 34 } 35 nextTest(); 36 } 37 38 function eventListener() { 39 checkStack("registerEventListener"); 40 } 41 function registerEventListener(link) { 42 link.onload = eventListener; 43 } 44 function eventTest() { 45 var link = document.createElement("link"); 46 link.rel = "stylesheet"; 47 link.href = "data:text/css,"; 48 registerEventListener(link); 49 document.body.appendChild(link); 50 } 51 52 function xhrListener() { 53 checkStack("xhrTest"); 54 } 55 function xhrTest() { 56 var ourFile = location.href; 57 var x = new XMLHttpRequest(); 58 x.onload = xhrListener; 59 x.open("get", ourFile, true); 60 x.send(); 61 } 62 63 function rafListener() { 64 checkStack("rafTest"); 65 } 66 function rafTest() { 67 requestAnimationFrame(rafListener); 68 } 69 70 var intervalId; 71 function intervalHandler() { 72 clearInterval(intervalId); 73 checkStack("intervalTest"); 74 } 75 function intervalTest() { 76 intervalId = setInterval(intervalHandler, 5); 77 } 78 79 function postMessageHandler(ev) { 80 ev.stopPropagation(); 81 checkStack("postMessageTest"); 82 } 83 function postMessageTest() { 84 window.addEventListener("message", postMessageHandler, true); 85 window.postMessage("whatever", "*"); 86 } 87 88 function runTests() { 89 TESTS = [postMessageTest, intervalTest, rafTest, xhrTest, eventTest]; 90 nextTest(); 91 } 92 93 addLoadEvent(function() { 94 SpecialPowers.pushPrefEnv( 95 {"set": [["javascript.options.asyncstack_capture_debuggee_only", false]]}, 96 runTests); 97 }); 98 </script> 99 </head> 100 <body> 101 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1148593">Mozilla Bug 1148593</a> 102 <p id="display"></p> 103 <div id="content" style="display: none"> 104 105 </div> 106 <pre id="test"> 107 </pre> 108 </body> 109 </html>