Update WPT tests for embedded content
[WebKit-https.git] / LayoutTests / imported / w3c / web-platform-tests / html / semantics / embedded-content / media-elements / ready-states / autoplay-hidden.optional.html
1 <!doctype html>
2 <title>autoplay hidden</title>
3 <link rel="author" title="Intel" href="http://www.intel.com">
4 <link rel="help" href="https://html.spec.whatwg.org/multipage/media.html#ready-states"/>
5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 <script src="/common/media.js"></script>
8 <div id="log"></div>
9 <script>
10
11 promise_test(async t => {
12   let video = document.createElement("video");
13   video.src = getVideoURI("/media/movie_5");
14   video.autoplay = true;
15   // In Safari and Chrome, the video needs to be muted in order to be paused when
16   // hidden. They decided to do this in order to save resources when a video
17   // goes out of view and isn't expected to make any sound.
18   video.muted = true;
19   video.loop = true;
20   let watcher = new EventWatcher(t, video, ["playing", "pause"]);
21   document.body.appendChild(video);
22
23   await watcher.wait_for("playing");
24   assert_false(video.paused, "paused when video is display");
25   video.hidden = true;
26
27   await watcher.wait_for("pause");
28   assert_true(video.paused, "paused when video is hidden");
29   video.hidden = false;
30
31   await watcher.wait_for("playing");
32   assert_false(video.paused, "paused when video is display");
33 }, "Allow delaying autoplay until video elements become visible");
34
35 </script>