3 function hasFullscreenButton(element)
5 var size = mediaControlsButtonDimensions(element, "fullscreen-button");
6 return size[0] > 0 && size[1] > 0;
9 function fullscreen_test(controller)
11 async_test(function(t)
13 var v1 = document.createElement("video");
14 var v2 = document.createElement("video");
15 v1.controls = v2.controls = true;
16 v1.controller = v2.controller = controller;
17 v1.src = findMediaFile("video", "content/test");
18 v2.src = findMediaFile("audio", "content/test");
19 document.body.appendChild(v1);
20 document.body.appendChild(v2);
22 // load event fires when both video elements are ready
23 window.addEventListener("load", t.step_func(function()
25 assert_true(hasFullscreenButton(v1),
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 track");
30 // click the fullscreen button
31 var coords = mediaControlsButtonCoordinates(v1, "fullscreen-button");
32 eventSender.mouseMoveTo(coords[0], coords[1]);
33 eventSender.mouseDown();
34 eventSender.mouseUp();
35 // wait for the fullscreenchange event
38 v1.addEventListener("webkitfullscreenchange", t.step_func_done());
39 v2.addEventListener("webkitfullscreenchange", t.unreached_func());
43 function fullscreen_iframe_test()
45 async_test(function(t)
47 var iframe = document.querySelector("iframe");
48 var doc = iframe.contentDocument;
49 var v = doc.createElement("video");
51 v.src = findMediaFile("video", "content/test");
52 doc.body.appendChild(v);
54 v.addEventListener("loadeddata", t.step_func_done(function()
56 assert_equals(hasFullscreenButton(v), iframe.allowFullscreen,
57 "fullscreen button shown if and only if fullscreen is allowed");
62 function fullscreen_not_supported_test()
64 async_test(function(t)
66 var v = document.createElement("video");
68 v.src = findMediaFile("video", "content/test");
69 document.body.appendChild(v);
71 v.addEventListener("loadeddata", t.step_func_done(function()
73 assert_false(hasFullscreenButton(v),
74 "fullscreen button not show when fullscreen is not supported");