Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: LayoutTests/media/video-controls-fullscreen.js

Issue 1240573005: Make video.webkitSupportsFullscreen an alias of document.fullscreenEnabled (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: move comments to assert descriptions Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 "use strict"; 1 "use strict";
2 2
3 function hasFullscreenButton(element)
4 {
5 var size = mediaControlsButtonDimensions(element, "fullscreen-button");
6 return size[0] > 0 && size[1] > 0;
7 }
8
3 function fullscreen_test(controller) 9 function fullscreen_test(controller)
4 { 10 {
5 async_test(function(t) 11 async_test(function(t)
6 { 12 {
7 var v1 = document.createElement("video"); 13 var v1 = document.createElement("video");
8 var v2 = document.createElement("video"); 14 var v2 = document.createElement("video");
9 v1.controls = v2.controls = true; 15 v1.controls = v2.controls = true;
10 v1.controller = v2.controller = controller; 16 v1.controller = v2.controller = controller;
11 v1.src = findMediaFile("video", "content/test"); 17 v1.src = findMediaFile("video", "content/test");
12 v2.src = findMediaFile("audio", "content/test"); 18 v2.src = findMediaFile("audio", "content/test");
13 document.body.appendChild(v1); 19 document.body.appendChild(v1);
14 document.body.appendChild(v2); 20 document.body.appendChild(v2);
15 21
16 // load event fires when both video elements are ready 22 // load event fires when both video elements are ready
17 window.addEventListener("load", t.step_func(function() 23 window.addEventListener("load", t.step_func(function()
18 { 24 {
19 // no fullscreen button for a video element with no video track 25 assert_true(hasFullscreenButton(v1),
20 assert_button_hidden(v2); 26 "fullscreen button shown when there is a video track");
27 assert_false(hasFullscreenButton(v2),
28 "fullscreen button not shown when there is no video tra ck");
21 29
22 // click the fullscreen button 30 // click the fullscreen button
23 var coords = mediaControlsButtonCoordinates(v1, "fullscreen-button") ; 31 var coords = mediaControlsButtonCoordinates(v1, "fullscreen-button") ;
24 eventSender.mouseMoveTo(coords[0], coords[1]); 32 eventSender.mouseMoveTo(coords[0], coords[1]);
25 eventSender.mouseDown(); 33 eventSender.mouseDown();
26 eventSender.mouseUp(); 34 eventSender.mouseUp();
27 // wait for the fullscreenchange event 35 // wait for the fullscreenchange event
28 })); 36 }));
29 37
30 v1.addEventListener("webkitfullscreenchange", t.step_func(function() 38 v1.addEventListener("webkitfullscreenchange", t.step_func_done());
39 v2.addEventListener("webkitfullscreenchange", t.unreached_func());
40 });
41 }
42
43 function fullscreen_iframe_test()
44 {
45 async_test(function(t)
46 {
47 var iframe = document.querySelector("iframe");
48 var doc = iframe.contentDocument;
49 var v = doc.createElement("video");
50 v.controls = true;
51 v.src = findMediaFile("video", "content/test");
52 doc.body.appendChild(v);
53
54 v.addEventListener("loadeddata", t.step_func_done(function()
31 { 55 {
32 t.done(); 56 assert_equals(hasFullscreenButton(v), iframe.allowFullscreen,
33 })); 57 "fullscreen button shown if and only if fullscreen is allowed");
34
35 v2.addEventListener("webkitfullscreenchange", t.step_func(function()
36 {
37 assert_unreached();
38 })); 58 }));
39 }); 59 });
40 } 60 }
41 61
42 function fullscreen_not_supported_test() 62 function fullscreen_not_supported_test()
43 { 63 {
44 async_test(function(t) 64 async_test(function(t)
45 { 65 {
46 var v = document.createElement("video"); 66 var v = document.createElement("video");
47 v.controls = true; 67 v.controls = true;
48 v.src = findMediaFile("video", "content/test"); 68 v.src = findMediaFile("video", "content/test");
49 document.body.appendChild(v); 69 document.body.appendChild(v);
50 70
51 // load event fires when video elements is ready 71 v.addEventListener("loadeddata", t.step_func_done(function()
52 window.addEventListener("load", t.step_func(function()
53 { 72 {
54 // no fullscreen button for a video element when fullscreen is not 73 assert_false(hasFullscreenButton(v),
55 // supported 74 "fullscreen button not show when fullscreen is not supp orted");
56 assert_button_hidden(v);
57 t.done();
58 })); 75 }));
59 }); 76 });
60 } 77 }
61
62 function assert_button_hidden(elm)
63 {
64 assert_array_equals(mediaControlsButtonDimensions(elm, "fullscreen-button"), [0, 0]);
65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698