| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <title>This tests that media element in a standalone media document cannot be f
ocused directly using focus() method or by mouse click.</title> |
| 3 <head> | 3 <script src="../../resources/testharness.js"></script> |
| 4 <script src="../../media/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/media-file.js"></script> |
| 6 (Please avoid writing new tests using video-test.js) --> | 6 <iframe width="380" height="330"></iframe> |
| 7 <script src="../../media/video-test.js"></script> | 7 <script> |
| 8 <script type="text/javascript"> | 8 async_test(function(t) { |
| 9 var videoElement; | 9 var iframe = document.querySelector("iframe"); |
| 10 var standaloneMediaDocument; | 10 iframe.src = "../../media/" + findMediaFile("video", "content/test"); |
| 11 var skipOnFirstEmptyLoad = 0; | |
| 12 | 11 |
| 13 function frameLoaded() | 12 iframe.onload = t.step_func(function() { |
| 14 { | 13 var standaloneMediaDocument = iframe.contentDocument; |
| 15 if (++skipOnFirstEmptyLoad == 1) | 14 var video = standaloneMediaDocument.querySelector("video"); |
| 16 return; | |
| 17 | 15 |
| 18 standaloneMediaDocument = document.getElementById("videoframe").
contentDocument; | 16 video.onclick = t.step_func_done(function() { |
| 19 videoElement = standaloneMediaDocument.querySelector("video"); | 17 // Should not focus video element by mouse click. |
| 18 assert_not_equals(standaloneMediaDocument.activeElement, video); |
| 19 }); |
| 20 | 20 |
| 21 videoElement.addEventListener('click',function(){ | 21 // Should not focus video element by calling focus() method. |
| 22 consoleWrite("*** Video element clicked."); | 22 video.focus(); |
| 23 },false); | 23 assert_not_equals(standaloneMediaDocument.activeElement, video); |
| 24 | 24 |
| 25 testFocus(); | 25 // Simulate click event to try focus video element. |
| 26 testFocusbyMouseClick(); | 26 var mouseEvent = new MouseEvent("click"); |
| 27 consoleWrite(""); | 27 video.dispatchEvent(mouseEvent); |
| 28 endTest(); | 28 }); |
| 29 } | 29 }); |
| 30 | 30 </script> |
| 31 function testFocus() | |
| 32 { | |
| 33 consoleWrite("<br>*** Should not focus video element by calling
focus() method."); | |
| 34 videoElement.focus(); | |
| 35 testExpected("standaloneMediaDocument.activeElement", videoEleme
nt, "!="); | |
| 36 } | |
| 37 | |
| 38 function testFocusbyMouseClick() | |
| 39 { | |
| 40 // Simulate click event to try focus video element. | |
| 41 consoleWrite("<br>*** Should not focus video element by mouse cl
ick."); | |
| 42 var click = document.createEvent("MouseEvents"); | |
| 43 click.initMouseEvent("click", true, true, window, 1, 0, 0, 0, 0,
false, false, false, false, 0, document); | |
| 44 videoElement.dispatchEvent(click); | |
| 45 testExpected("standaloneMediaDocument.activeElement", videoEleme
nt, "!="); | |
| 46 } | |
| 47 </script> | |
| 48 </head> | |
| 49 <body> | |
| 50 <p> | |
| 51 This tests that media element in a standalone media document cannot
be focused directly using focus() method or by mouse click. | |
| 52 </p> | |
| 53 <iframe id="videoframe" width=380 height=330 onload="frameLoaded()"></if
rame> | |
| 54 <script type="text/javascript"> | |
| 55 document.getElementById("videoframe").src = "../../media/" + findMed
iaFile("video", "content/test"); | |
| 56 </script> | |
| 57 </body> | |
| 58 </html> | |
| OLD | NEW |