| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <title>Test that video is not reloaded on showing a dialog.</title> |
| 3 <head> | 3 <script src="../resources/testharness.js"></script> |
| 4 <script src=../../media-resources/media-file.js></script> | 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 5 <script src="../../media-resources/media-file.js"></script> |
| 6 (Please avoid writing new tests using video-test.js) --> | 6 <video></video> |
| 7 <script src=../../media-resources/video-test.js></script> | 7 <script> |
| 8 <script> | 8 // Make sure we don't reload a "video" element after a dialog is shown. |
| 9 var loadCount = 0; | 9 // Test this by loading a movie slowly and showing a dialog when a |
| 10 // "loadstart" event handler is called. If the movie is reloaded when |
| 11 // the dialog is "dismissed", another "loadstart" event will be fired. |
| 12 async_test(function(t) { |
| 13 var movie = findMediaFile("video", "../resources/test"); |
| 14 var video = document.querySelector("video"); |
| 10 | 15 |
| 11 if (window.testRunner) { | 16 video.onloadstart = t.step_func(function() { |
| 12 testRunner.dumpAsText(); | 17 video.onloadstart = t.unreached_func(); |
| 13 testRunner.waitUntilDone(); | |
| 14 } | |
| 15 | 18 |
| 16 function logEvent(event) | 19 // Showing confirm dialog. |
| 17 { | 20 confirm("I hope the movie continues to play!"); |
| 18 consoleWrite("<br><b><em>'" + event.type + "'<" + "/em> event<"
+ "/b>"); | 21 }); |
| 19 } | |
| 20 | 22 |
| 21 function loadstart() | 23 video.oncanplaythrough = t.step_func_done(); |
| 22 { | |
| 23 logEvent(event); | |
| 24 | 24 |
| 25 if (++loadCount > 1) { | 25 video.src = "http://127.0.0.1:8000/media/video-throttled-load.cgi?name=" + m
ovie + "&throttle=100"; |
| 26 consoleWrite('FAIL: loadstart fired more than once.'); | 26 }); |
| 27 endTest(); | 27 </script> |
| 28 return; | |
| 29 } | |
| 30 | |
| 31 consoleWrite("*** Showing confirm dialog..."); | |
| 32 confirm('I hope the movie continues to play!'); | |
| 33 } | |
| 34 | |
| 35 function canplaythrough() | |
| 36 { | |
| 37 logEvent(event); | |
| 38 | |
| 39 consoleWrite(""); | |
| 40 endTest(); | |
| 41 } | |
| 42 | |
| 43 function setup() | |
| 44 { | |
| 45 logEvent(event); | |
| 46 consoleWrite("*** Setting up element..."); | |
| 47 | |
| 48 findMediaElement(); | |
| 49 var movie = findMediaFile("video", "../resources/test"); | |
| 50 video.src = "http://127.0.0.1:8000/media/video-throttled-load.cg
i?name=" + movie + "&throttle=100"; | |
| 51 } | |
| 52 | |
| 53 </script> | |
| 54 </head> | |
| 55 | |
| 56 <body onload="setup()"> | |
| 57 <video controls | |
| 58 oncanplaythrough="canplaythrough()" | |
| 59 onloadstart="loadstart()"> | |
| 60 </video> | |
| 61 <p>Make sure we don't reload a <video> element after a dialog is s
hown.<br> | |
| 62 Test this by loading a movie slowly and showing a dialog when a 'loadsta
rt' event <br> | |
| 63 handler is called. If the movie is reloaded when the dialog is "dismisse
d", another <br> | |
| 64 'loadstart' event will be fired</p> | |
| 65 </body> | |
| 66 </html> | |
| OLD | NEW |