Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / media / video-controls-fullscreen.js
blob1b78051e03dae8c577283e3185680deacae5bf13
1 "use strict";
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)
12     {
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()
24         {
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
36         }));
38         v1.addEventListener("webkitfullscreenchange", t.step_func_done());
39         v2.addEventListener("webkitfullscreenchange", t.unreached_func());
40     });
43 function fullscreen_iframe_test()
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);
54         v.addEventListener("loadeddata", t.step_func_done(function()
55         {
56             assert_equals(hasFullscreenButton(v), iframe.allowFullscreen,
57                           "fullscreen button shown if and only if fullscreen is allowed");
58         }));
59     });
62 function fullscreen_not_supported_test()
64     async_test(function(t)
65     {
66         var v = document.createElement("video");
67         v.controls = true;
68         v.src = findMediaFile("video", "content/test");
69         document.body.appendChild(v);
71         v.addEventListener("loadeddata", t.step_func_done(function()
72         {
73             assert_false(hasFullscreenButton(v),
74                          "fullscreen button not show when fullscreen is not supported");
75         }));
76     });