Skip to content

Commit

Permalink
WebKit export: (#48373)
Browse files Browse the repository at this point in the history
[WebVTT] Cues should use white-space:pre-line
  [WPT][WebVTT] Move some WebVTT rendering tests into the correct location

https://bugs.webkit.org/show_bug.cgi?id=275616
https://bugs.webkit.org/show_bug.cgi?id=280436
  • Loading branch information
jernoble authored Oct 3, 2024
1 parent 34ba8a3 commit a18606c
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>webvtt-white-space-pre-line-expected</title>
<link rel="stylesheet" type="text/css" href="support/reference.css">
<body>
<div>Test rendering a basic <code>VTTCue</code>.</div>
<div class="test-diff">
<video-reference expected>
<cue style="width: 100%; left: 0; bottom: 0px;">
<cue-background style="margin: auto">Test Text</cue-background>
</cue>
</video-reference>
<video-reference>
<cue style="width: 100%; left: 0; bottom: 0px;">
<cue-background style="margin: auto">Test Text</cue-background>
</cue>
</video-reference>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>webvtt-white-space-pre-line</title>
<link rel="stylesheet" type="text/css" href="support/reference.css">
<script src="/common/reftest-wait.js"></script>
<script src="support/webvtt-rendering-test.js"></script>
<body>
<div>Test rendering a basic <code>VTTCue</code>.</div>
<div class="test-diff">
<video-reference expected>
<cue style="width: 100%; left: 0; bottom: 0px;">
<cue-background style="margin: auto">Test Text</cue-background>
</cue>
</video-reference>
<video muted playsinline>
<source src="/media/sound_5.mp3#t=0.05" type="audio/mp3">
<source src="/media/sound_5.oga#t=0.05" type="audio/ogg">
<track src="support/basic-cue-rendering.webvtt" kind="captions" default>
</video>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
WEBVTT

00:00:00.000 --> 00:00:00.100
Test Text
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@font-face {
font-family: 'ahem';
src: url('/fonts/Ahem.ttf');
}

.test-diff {
container-type: inline-size;
width: 200px;
height: 200px;
display: inline-block;
isolation: isolate;
position: relative;
border: 1px solid black;
}

video-reference, cue { display: inline-block; }
cue-background { display: inline; }

video, video-reference {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
mix-blend-mode: difference;
}

::cue, cue {
font: 5cqmin/1 Ahem;
}

::cue, cue-background {
color: rgb(128, 0, 0);
background-color: rgb(255, 0, 0);
}

cue {
position: absolute;
display: inline-block;
text-align: center;
white-space: pre-line;
}

video-reference[expected] > cue > cue-background {
color: rgb(128, 128, 0);
background-color: rgb(255, 255, 0);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
window.addEventListener('load', async event => {
if (!document.documentElement.classList.contains('reftest-wait'))
return;

let waitFor = (object, type) => {
return new Promise(resolve => {
object.addEventListener(type, resolve);
}, { once: true });
};

let trackElement = document.querySelector('video > track[default]');
if (!trackElement)
return;

if (trackElement.track.mode !== 'showing')
trackElement.track.mode = 'showing';
if (!trackElement.track.activeCues)
await waitFor(trackElement.track, 'cuechange');

document.documentElement.classList.remove('reftest-wait');
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
WEBVTT

00:00:00.000 --> 00:00:00.100 size:40%
Test Text
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>webvtt-white-space-pre-line</title>
<link rel="stylesheet" type="text/css" href="support/reference.css">
<body>
<div>Test rendering of wrapped text when <code>white-space: pre-line</code> is set.</div>
<div class="test-diff">
<video-reference expected>
<cue style="width: 40%; left: 30%; bottom: 0px;">
<cue-background style="margin: auto">Test Text</cue-background>
</cue>
</video-reference>
<video-reference>
<cue style="width: 40%; left: 30%; bottom: 0px;">
<cue-background style="margin: auto">Test Text</cue-background>
</cue>
</video-reference>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>webvtt-white-space-pre-line</title>
<link rel="stylesheet" type="text/css" href="support/reference.css">
<script src="support/webvtt-rendering-test.js"></script>
<body>
<div>Test rendering of wrapped text when <code>white-space: pre-line</code> is set.</div>
<div class="test-diff">
<video-reference expected>
<cue style="width: 40%; left: 30%; bottom: 0px;">
<cue-background style="margin: auto">Test Text</cue-background>
</cue>
</video-reference>
<video muted playsinline>
<source src="/media/sound_5.mp3#t=0.05" type="audio/mp3">
<source src="/media/sound_5.oga#t=0.05" type="audio/ogg">
<track src="support/white-space-pre-line.webvtt" kind="captions" default>
</video>
</div>
</body>
</html>

0 comments on commit a18606c

Please sign in to comment.