tenfourfox/dom/tv/test/mochitest/test_tv_set_current_channel.html
Cameron Kaiser c9b2922b70 hello FPR
2017-04-19 00:56:45 -07:00

80 lines
2.5 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test SetCurrentChannel for TV API</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
<script type="application/javascript" src="./head.js"></script>
<script type="application/javascript">
function runTest() {
ok('tv' in navigator, "navigator.tv should exist.");
navigator.tv.getTuners().then(
function(aTuners) {
ok(aTuners.length > 0, "Got at least 1 tuner.");
var tuner = aTuners[0];
var selectedSourceType = tuner.getSupportedSourceTypes()[0];
aTuners[0].getSources().then(
function(aSources) {
ok(aSources.length > 0, "Got at least 1 source.");
var source = aSources[0];
source.getChannels().then(
function(aChannels) {
ok(aChannels.length > 0, "Got at least 1 channel.");
var selectedChannelNumber = aChannels[0].number;
source.oncurrentchannelchanged = function(aEvent) {
ok(aEvent instanceof TVCurrentChannelChangedEvent,
"The event is in the right type");
ok(aEvent.channel instanceof TVChannel,
"The channel is in the right type.");
is(aEvent.channel, source.currentChannel,
"The current channel is set.");
is(source.currentChannel.number, selectedChannelNumber,
"The current channel number is correct.");
SimpleTest.finish();
};
source.setCurrentChannel(selectedChannelNumber).then(
function() {},
function(aError) {
ok(false, "Error occurred when setting current channel: " + aError);
SimpleTest.finish();
}
);
},
function(aError) {
ok(false, "Error occurred when getting channels: " + aError);
SimpleTest.finish();
}
);
},
function(aError) {
ok(false, "Error occurred when getting sources: " + aError);
SimpleTest.finish();
}
);
},
function(aError) {
ok(false, "Error occurred when getting tuners: " + aError);
SimpleTest.finish();
}
);
}
SimpleTest.waitForExplicitFinish();
prepareTest(runTest);
</script>
</pre>
</body>
</html>