test_document-element-inserted.html 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Media test: document-element-inserted</title>
  5. <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  6. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  7. </head>
  8. <body>
  9. <iframe id = 'media'>
  10. </iframe>
  11. <pre id="test">
  12. <script class="testbody" type="text/javascript">
  13. if (navigator.platform.startsWith("Win")) {
  14. SimpleTest.expectAssertions(0, 4);
  15. }
  16. SimpleTest.waitForExplicitFinish();
  17. var loc;
  18. var observe = function(doc){
  19. if (doc == media.contentDocument) {
  20. ok(media.contentDocument.location.toString().indexOf(loc) != -1,
  21. "The loaded media should be " + loc);
  22. next();
  23. }
  24. }
  25. var media = document.getElementById('media');
  26. var tests = [
  27. "../../../media/test/short-video.ogv",
  28. "../../../media/test/sound.ogg",
  29. "../../content/test/image.png"
  30. ]
  31. function next() {
  32. if (tests.length > 0) {
  33. var t = tests.shift();
  34. loc = t.substring(t.indexOf("test"));
  35. media.setAttribute("src",t);
  36. }
  37. else {
  38. SpecialPowers.removeObserver(observe, "document-element-inserted");
  39. SimpleTest.finish();
  40. }
  41. }
  42. SpecialPowers.addObserver(observe, "document-element-inserted", false)
  43. next();
  44. </script>
  45. </pre>
  46. </body>
  47. </html>