test_1396395.html (1398B)
1 <!DOCTYPE HTML> 2 <!-- vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: --> 3 <html> 4 <!-- Any copyright is dedicated to the Public Domain. 5 - http://creativecommons.org/publicdomain/zero/1.0/ --> 6 <head> 7 <script src="/tests/SimpleTest/SimpleTest.js"></script> 8 </head> 9 <body> 10 <iframe id="f" src="about:blank"></iframe> 11 <script type="text/javascript"> 12 SimpleTest.waitForExplicitFinish(); 13 14 var script = SpecialPowers.loadChromeScript(() => { 15 /* eslint-env mozilla/chrome-script */ 16 Services.obs.addObserver(function onExamResp(subject) { 17 let channel = subject.QueryInterface(Ci.nsIHttpChannel); 18 if (!channel.URI.spec.startsWith("http://example.org")) { 19 return; 20 } 21 Services.obs.removeObserver(onExamResp, 'http-on-examine-response'); 22 channel.suspend(); 23 Promise.resolve().then(() => { 24 channel.resume(); 25 }); 26 }, 'http-on-examine-response'); 27 28 sendAsyncMessage('start-test'); 29 }); 30 31 script.addMessageListener('start-test', () => { 32 const iframe = document.getElementById('f'); 33 34 iframe.contentWindow.onunload = function () { 35 info('initiate sync XHR during the page loading'); 36 let xhr = new XMLHttpRequest(); 37 xhr.open('GET', window.location, false); 38 xhr.send(null); 39 ok(true, 'complete without crash'); 40 script.destroy(); 41 SimpleTest.finish(); 42 } 43 44 iframe.src = 'http://example.org'; 45 }); 46 </script> 47 </body> 48 </html>