OLD | NEW |
---|---|
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src=media-file.js></script> | 3 <script src=media-file.js></script> |
4 <!-- TODO(mlamouri): use testharness.js, see https://crbug.com/588956 --> | 4 <!-- TODO(mlamouri): use testharness.js, see https://crbug.com/588956 --> |
5 <script src=video-test.js></script> | 5 <script src=video-test.js></script> |
6 | 6 |
7 <script> | 7 <script> |
8 // This is testing the behavior of play() with regards to the returned | 8 // This is testing the behavior of play() with regards to the returned |
9 // promise. This test file is creating a small framework in order to be able | 9 // promise. This test file is creating a small framework in order to be able |
10 // to test different cases easily and independently of each other. | 10 // to test different cases easily and independently of each other. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 waitForEvent('playing'); | 98 waitForEvent('playing'); |
99 | 99 |
100 waitForEvent('canplay', function() { | 100 waitForEvent('canplay', function() { |
101 testExpected("mediaElement.readyState", HTMLMediaElement.HAVE_FU TURE_DATA, ">="); | 101 testExpected("mediaElement.readyState", HTMLMediaElement.HAVE_FU TURE_DATA, ">="); |
102 testExpected("mediaElement.paused", true); | 102 testExpected("mediaElement.paused", true); |
103 | 103 |
104 play(); | 104 play(); |
105 }); | 105 }); |
106 }, | 106 }, |
107 | 107 |
108 // Test that play() on an element that is already playing returns a | |
109 // promise that resolves successfuly. | |
fs
2016/06/06 09:13:24
Nit: successfully (also below)
mlamouri (slow - plz ping)
2016/06/06 16:00:55
Changed other places in the file.
| |
108 function playAfterPlaybackStarted() | 110 function playAfterPlaybackStarted() |
109 { | 111 { |
110 consoleWrite("playAfterPlaybackStarted()"); | 112 consoleWrite("playAfterPlaybackStarted()"); |
111 internals.settings.setMediaPlaybackRequiresUserGesture(false); | 113 internals.settings.setMediaPlaybackRequiresUserGesture(false); |
112 | 114 |
113 run("mediaElement = document.createElement('audio')"); | 115 run("mediaElement = document.createElement('audio')"); |
114 mediaElement.preload = "auto"; | 116 mediaElement.preload = "auto"; |
115 var mediaFile = findMediaFile("audio", "content/test"); | 117 var mediaFile = findMediaFile("audio", "content/test"); |
116 run("mediaElement.src = '" + mediaFile + "'"); | 118 run("mediaElement.src = '" + mediaFile + "'"); |
117 | 119 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
384 waitForEvent('error', function() { | 386 waitForEvent('error', function() { |
385 // Until https://crbug.com/587871 is fixed, the events will be | 387 // Until https://crbug.com/587871 is fixed, the events will be |
386 // [ volumechange, volumechange, promise ], it should be | 388 // [ volumechange, volumechange, promise ], it should be |
387 // [ volumechange, promise, volumechange ]. | 389 // [ volumechange, promise, volumechange ]. |
388 waitForEvent('volumechange'); | 390 waitForEvent('volumechange'); |
389 run("mediaElement.volume = 0.1"); | 391 run("mediaElement.volume = 0.1"); |
390 play(); | 392 play(); |
391 run("mediaElement.volume = 0.2"); | 393 run("mediaElement.volume = 0.2"); |
392 }); | 394 }); |
393 | 395 |
394 } | 396 }, |
397 | |
398 // Test that calling pause() then play() on an element that is already | |
399 // playing returns a promise that resolves successfuly. | |
400 function pausePlayAfterPlaybackStarted() | |
401 { | |
402 consoleWrite("pausePlayAfterPlaybackStarted()"); | |
403 internals.settings.setMediaPlaybackRequiresUserGesture(false); | |
404 | |
405 run("mediaElement = document.createElement('audio')"); | |
406 mediaElement.preload = "auto"; | |
407 var mediaFile = findMediaFile("audio", "content/test"); | |
408 run("mediaElement.src = '" + mediaFile + "'"); | |
409 | |
410 waitForEvent('playing', function() { | |
411 testExpected("mediaElement.readyState", HTMLMediaElement.HAVE_EN OUGH_DATA); | |
412 testExpected("mediaElement.paused", false); | |
413 | |
414 run("mediaElement.pause()"); | |
415 play(); | |
416 }); | |
417 | |
418 waitForEvent('canplaythrough', function() { | |
419 run("mediaElement.play()"); | |
420 }); | |
421 }, | |
395 ]; | 422 ]; |
396 | 423 |
397 function start() | 424 function start() |
398 { | 425 { |
399 if (!('eventSender' in window) || !('internals' in window)) { | 426 if (!('eventSender' in window) || !('internals' in window)) { |
400 failTest("Not running in LayoutTests."); | 427 failTest("Not running in LayoutTests."); |
401 return; | 428 return; |
402 } | 429 } |
403 runNextTestOrFinish(); | 430 runNextTestOrFinish(); |
404 } | 431 } |
405 | 432 |
406 </script> | 433 </script> |
407 </head> | 434 </head> |
408 | 435 |
409 <body onload="start()"> | 436 <body onload="start()"> |
410 | 437 |
411 <p>Test the play() behaviour with regards to the returned promise for media elem ents.</p> | 438 <p>Test the play() behaviour with regards to the returned promise for media elem ents.</p> |
412 | 439 |
413 </body> | 440 </body> |
414 </html> | 441 </html> |
OLD | NEW |