Skip to content
This repository was archived by the owner on Jul 18, 2018. It is now read-only.

Commit caca068

Browse files
avayvodCommit bot
authored andcommitted
[Blink, Media] Added controlsList to HTMLMediaElement
Adds a DOMTokenList backed controlsList/controlslist attribute to HTMLMediaElement with three keywords: nodownload, nofullscreen and noremoteplayback. Spec change is discussed here: whatwg/html#2293 Spec change PR is here: whatwg/html#2426 WICG repo for the API is here: https://github.com/WICG/controls-list Intent to ship is here: https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/tFuQd3AcsIQ/discussion BUG=650174,685018 TEST=manual+layout tests Review-Url: https://codereview.chromium.org/2657723002 Cr-Commit-Position: refs/heads/master@{#455926}
1 parent 5bf97f6 commit caca068

20 files changed

+268
-2
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<title>Test adding keywords to controlsList hides buttons</title>
3+
<script src="../../resources/testharness.js"></script>
4+
<script src="../../resources/testharnessreport.js"></script>
5+
<script src="../../media-resources/media-file.js"></script>
6+
<script src="../../media-resources/media-controls.js"></script>
7+
<video controls id="enabled-controls" width="500px"></video>
8+
<script>
9+
async_test(t => {
10+
var v = document.getElementById('enabled-controls');
11+
12+
v.addEventListener('canplaythrough', t.step_func(e => {
13+
assert_not_equals(getComputedStyle(fullscreenButton(v)).display, 'none');
14+
assert_not_equals(getComputedStyle(downloadButton(v)).display, 'none');
15+
16+
v.controlsList.add('nodownload');
17+
18+
testRunner.layoutAndPaintAsyncThen(t.step_func(() => {
19+
assert_not_equals(getComputedStyle(fullscreenButton(v)).display, 'none');
20+
assert_equals(getComputedStyle(downloadButton(v)).display, 'none');
21+
v.controlsList.add('nofullscreen');
22+
23+
testRunner.layoutAndPaintAsyncThen(t.step_func_done(() => {
24+
assert_equals(getComputedStyle(fullscreenButton(v)).display, 'none');
25+
assert_equals(getComputedStyle(downloadButton(v)).display, 'none');
26+
}));
27+
}));
28+
}));
29+
30+
v.src = findMediaFile('video', '../resources/test');
31+
}, 'Test disabling controls on the video element with all controls.');
32+
</script>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<title>Test removing keywords from controlsList shows buttons</title>
3+
<script src="../../resources/testharness.js"></script>
4+
<script src="../../resources/testharnessreport.js"></script>
5+
<script src="../../media-resources/media-file.js"></script>
6+
<script src="../../media-resources/media-controls.js"></script>
7+
<video controlslist="nodownload nofullscreen" id="disabled-controls" width="500px"></video>
8+
<script>
9+
async_test(t => {
10+
var v = document.getElementById('disabled-controls');
11+
12+
v.addEventListener('canplaythrough', t.step_func(e => {
13+
assert_equals(getComputedStyle(fullscreenButton(v)).display, 'none');
14+
assert_equals(getComputedStyle(downloadButton(v)).display, 'none');
15+
16+
v.controlsList.remove('nodownload');
17+
18+
testRunner.layoutAndPaintAsyncThen(t.step_func(() => {
19+
assert_equals(getComputedStyle(fullscreenButton(v)).display, 'none');
20+
assert_not_equals(getComputedStyle(downloadButton(v)).display, 'none');
21+
22+
v.controlsList.remove('nofullscreen');
23+
24+
testRunner.layoutAndPaintAsyncThen(t.step_func_done(() => {
25+
assert_not_equals(getComputedStyle(fullscreenButton(v)).display, 'none');
26+
assert_not_equals(getComputedStyle(downloadButton(v)).display, 'none');
27+
}));
28+
}));
29+
}));
30+
31+
v.src = findMediaFile('video', '../resources/test');
32+
}, 'Test enabling controls on the video element with them enabled.');
33+
</script>
34+

third_party/WebKit/LayoutTests/media/media-controls.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ function castButton(videoElement) {
1717
return button;
1818
}
1919

20+
function downloadButton(videoElement) {
21+
var controlID = '-internal-media-controls-download-button';
22+
var button = mediaControlsElement(window.internals.shadowRoot(videoElement).firstChild, controlID);
23+
if (!button)
24+
throw 'Failed to find download button';
25+
return button;
26+
}
27+
28+
function fullscreenButton(videoElement) {
29+
var controlID = '-webkit-media-controls-fullscreen-button';
30+
var button = mediaControlsElement(window.internals.shadowRoot(videoElement).firstChild, controlID);
31+
if (!button)
32+
throw 'Failed to find fullscreen button';
33+
return button;
34+
}
35+
2036
function overlayCastButton(videoElement)
2137
{
2238
var controlID = '-internal-media-controls-overlay-cast-button';

third_party/WebKit/LayoutTests/platform/mac/virtual/stable/webexposed/global-interface-listing-expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,6 +2339,7 @@ interface HTMLMediaElement : HTMLElement
23392339
getter autoplay
23402340
getter buffered
23412341
getter controls
2342+
getter controlsList
23422343
getter crossOrigin
23432344
getter currentSrc
23442345
getter currentTime
@@ -2379,6 +2380,7 @@ interface HTMLMediaElement : HTMLElement
23792380
method setSinkId
23802381
setter autoplay
23812382
setter controls
2383+
setter controlsList
23822384
setter crossOrigin
23832385
setter currentTime
23842386
setter defaultMuted

third_party/WebKit/LayoutTests/platform/win/virtual/stable/webexposed/global-interface-listing-expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,6 +2268,7 @@ interface HTMLMediaElement : HTMLElement
22682268
getter autoplay
22692269
getter buffered
22702270
getter controls
2271+
getter controlsList
22712272
getter crossOrigin
22722273
getter currentSrc
22732274
getter currentTime
@@ -2308,6 +2309,7 @@ interface HTMLMediaElement : HTMLElement
23082309
method setSinkId
23092310
setter autoplay
23102311
setter controls
2312+
setter controlsList
23112313
setter crossOrigin
23122314
setter currentTime
23132315
setter defaultMuted

third_party/WebKit/LayoutTests/virtual/stable/webexposed/element-instance-property-listing-expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ html element audio
304304
property buffered
305305
property canPlayType
306306
property controls
307+
property controlsList
307308
property crossOrigin
308309
property currentSrc
309310
property currentTime
@@ -1019,6 +1020,7 @@ html element video
10191020
property buffered
10201021
property canPlayType
10211022
property controls
1023+
property controlsList
10221024
property crossOrigin
10231025
property currentSrc
10241026
property currentTime

third_party/WebKit/LayoutTests/webexposed/element-instance-property-listing-expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ html element audio
316316
property canPlayType
317317
property captureStream
318318
property controls
319+
property controlsList
319320
property crossOrigin
320321
property currentSrc
321322
property currentTime
@@ -1049,6 +1050,7 @@ html element video
10491050
property canPlayType
10501051
property captureStream
10511052
property controls
1053+
property controlsList
10521054
property crossOrigin
10531055
property currentSrc
10541056
property currentTime

third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2884,6 +2884,7 @@ interface HTMLMediaElement : HTMLElement
28842884
getter autoplay
28852885
getter buffered
28862886
getter controls
2887+
getter controlsList
28872888
getter crossOrigin
28882889
getter currentSrc
28892890
getter currentTime
@@ -2926,6 +2927,7 @@ interface HTMLMediaElement : HTMLElement
29262927
method setSinkId
29272928
setter autoplay
29282929
setter controls
2930+
setter controlsList
29292931
setter crossOrigin
29302932
setter currentTime
29312933
setter defaultMuted

third_party/WebKit/Source/core/frame/UseCounter.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,10 @@ class CORE_EXPORT UseCounter {
14791479
GetCanvas2DContextAttributes = 1850,
14801480
V8HTMLInputElement_Capture_AttributeGetter = 1851,
14811481
V8HTMLInputElement_Capture_AttributeSetter = 1852,
1482+
HTMLMediaElementControlsListAttribute = 1853,
1483+
HTMLMediaElementControlsListNoDownload = 1854,
1484+
HTMLMediaElementControlsListNoFullscreen = 1855,
1485+
HTMLMediaElementControlsListNoRemotePlayback = 1856,
14821486

14831487
// Add new features immediately above this line. Don't change assigned
14841488
// numbers of any item, and don't reuse removed slots.

third_party/WebKit/Source/core/html/BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ blink_core_sources("html") {
111111
"HTMLMarqueeElement.cpp",
112112
"HTMLMarqueeElement.h",
113113
"HTMLMediaElement.cpp",
114+
"HTMLMediaElementControlsList.cpp",
115+
"HTMLMediaElementControlsList.h",
114116
"HTMLMediaSource.cpp",
115117
"HTMLMediaSource.h",
116118
"HTMLMenuElement.cpp",

0 commit comments

Comments
 (0)