blob: 632601603a7594d717e2a032171fe5bc11cca247 [file] [log] [blame]
<html>
<head>
<script src='media-file.js'></script>
<script src='video-test.js'></script>
<script>
var video;
var callbackId;
var nextStep;
function start()
{
findMediaElement();
if (window.internals) {
internals.setMockMediaPlaybackTargetPickerEnabled(true);
internals.settings.setAllowsAirPlayForMediaPlayback(true);
}
consoleWrite('<br>** prompt() when disableRemotePlayback is set should fail');
run('video.disableRemotePlayback = true');
video.remote.prompt().then(failTest).catch(handleDisabledError);
}
function handleDisabledError(error)
{
consoleWrite(`EXPECTED ERROR: ${ error }`);
run('video.disableRemotePlayback = false');
consoleWrite('<br>** prompt() outside of a user action should fail');
video.remote.prompt().then(failTest).catch(handleUserGestureError);
}
function handleUserGestureError(error)
{
consoleWrite(`EXPECTED ERROR: ${ error }`);
consoleWrite('<br>** prompt() when no targets are available should fail');
runWithKeyDown(() => { video.remote.prompt().then(failTest).catch(handleNoTargetError); });
}
function handleNoTargetError(error)
{
consoleWrite(`EXPECTED ERROR: ${ error }`);
consoleWrite('<br>** Simulate a device becoming available')
video.remote.watchAvailability(availabilityChanged).catch(failTest);
if (window.internals)
internals.setMockMediaPlaybackTargetPickerState('', 'DeviceAvailable');
}
function availabilityChanged(available)
{
if (!available)
return;
if (video.src)
return;
run('video.src = findMediaFile("video", "content/test")');
waitForEvent('canplaythrough', canplaythrough);
}
function canplaythrough()
{
consoleWrite('<br>** Simulate a device becoming selected');
runWithKeyDown(() => { video.remote.prompt().catch(failTest); });
if (window.internals)
internals.setMockMediaPlaybackTargetPickerState('Sleepy TV', 'DeviceAvailable');
waitForEventOn(video.remote, 'connecting');
waitForEventOn(video.remote, 'connect', endTest);
}
</script>
</head>
<body onload='start()'>
<video controls></video>
<p>Test the operation of prompt().</p>
</body>
</html>