test_bug371375.html 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=371375
  5. -->
  6. <head>
  7. <title>Test for Bug 371375</title>
  8. <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  10. </head>
  11. <body>
  12. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=371375">Mozilla Bug 371375</a>
  13. <p id="display"></p>
  14. <div id="content" style="display: none">
  15. </div>
  16. <pre id="test">
  17. <script class="testbody" type="text/javascript">
  18. /** Test for Bug 371375 **/
  19. var load1Called = false;
  20. var error1Called = false;
  21. var s = document.createElement('script');
  22. s.type = 'text/javascript';
  23. s.onload = function() { load1Called = true; };
  24. s.onerror = function(event) { error1Called = true; event.stopPropagation(); };
  25. s.src = 'about:cache-entry?client=image&sb=0&key=http://www.google.com';
  26. document.body.appendChild(s);
  27. var load2Called = false;
  28. var error2Called = false;
  29. var s2 = document.createElement('script');
  30. s2.type = 'text/javascript';
  31. s2.onload = function() { load2Called = true; };
  32. s2.onerror = function(event) { error2Called = true; event.stopPropagation(); };
  33. s2.src = 'data:text/plain, var x = 1;'
  34. document.body.appendChild(s2);
  35. SimpleTest.waitForExplicitFinish();
  36. addLoadEvent(function() {
  37. is(load1Called, false, "Load handler should not be called");
  38. is(error1Called, true, "Error handler should be called");
  39. is(load2Called, true, "Load handler for valid script should be called");
  40. is(error2Called, false,
  41. "Error handler for valid script should not be called");
  42. SimpleTest.finish();
  43. });
  44. </script>
  45. </body>
  46. </html>
  47. </script>
  48. </pre>
  49. </body>
  50. </html>