Implement the Remote Playback API.
[WebKit-https.git] / LayoutTests / media / remoteplayback-watch-disableremoteplayback.html
1 <html>
2     <head>
3         <script src='media-file.js'></script>
4         <script src='video-test.js'></script>
5         <script>
6             var video;
7
8             function start()
9             {
10                 findMediaElement();
11
12                 if (window.internals) {
13                     internals.setMockMediaPlaybackTargetPickerEnabled(true);
14                     internals.settings.setAllowsAirPlayForMediaPlayback(true);
15                 }
16
17                 consoleWrite('** create initial callback');
18                 run('video.disableRemotePlayback = true');
19                 video.remote.watchAvailability(callback).then(failTest).catch(handleInitialError);
20             }
21
22             function callback(available) { };
23
24             function handleInitialError(exception)
25             {
26                 consoleWrite(`EXPECTED ERROR: ${ exception }`);
27                 consoleWrite('** try again without disableRemotePlayback');
28                 run('video.disableRemotePlayback = false');
29                 video.remote.watchAvailability(callback).then(succeeded).catch(failTest);
30             }
31
32             function succeeded(id)
33             {
34                 consoleWrite('SUCCEEDED');
35                 consoleWrite('** set disableRemotePlayback and try to cancel callback');
36                 run('video.disableRemotePlayback = true');
37                 video.remote.cancelWatchAvailability(id).then(failTest).catch(handleError);
38             }
39
40             function handleError(exception)
41             {
42                 consoleWrite(`EXPECTED ERROR: ${ exception }`);
43                 endTest();
44             }
45         </script>
46     </head>
47
48     <body onload='start()'>
49         <video controls></video>
50         <p>Test that trying to watchAvailability on a video with the "disableremoteplayback" attribute set will generate an error.</p>
51     </body>
52 </html>