test_1396395.html 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!-- Any copyright is dedicated to the Public Domain.
  4. - http://creativecommons.org/publicdomain/zero/1.0/ -->
  5. <head>
  6. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  7. </head>
  8. <body>
  9. <iframe id="f" src="http://example.com"></iframe>
  10. <script type="text/javascript">
  11. SimpleTest.waitForExplicitFinish();
  12. var script = SpecialPowers.loadChromeScript(() => {
  13. const Ci = Components.interfaces;
  14. const Cc = Components.classes;
  15. const Cu = Components.utils;
  16. Cu.import('resource://gre/modules/Services.jsm');
  17. Services.obs.addObserver(function onExamResp(subject, topic, data) {
  18. let channel = subject.QueryInterface(Ci.nsIHttpChannel);
  19. if (!channel.URI.spec.startsWith("http://example.org")) {
  20. return;
  21. }
  22. Services.obs.removeObserver(onExamResp, 'http-on-examine-response');
  23. channel.suspend();
  24. Promise.resolve().then(() => {
  25. channel.resume();
  26. });
  27. }, 'http-on-examine-response');
  28. sendAsyncMessage('start-test');
  29. });
  30. script.addMessageListener('start-test', () => {
  31. const iframe = document.getElementById('f');
  32. iframe.contentWindow.onunload = function () {
  33. xhr = new XMLHttpRequest();
  34. xhr.open('GET', window.location, false);
  35. xhr.send(null);
  36. ok(true, 'complete without crash');
  37. script.destroy();
  38. SimpleTest.finish();
  39. }
  40. iframe.src = 'http://example.org';
  41. });
  42. </script>
  43. </body>
  44. </html>