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

58 lines
1.6 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test SetCurrentSource 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];
tuner.oncurrentsourcechanged = function(aEvent) {
ok(aEvent instanceof TVCurrentSourceChangedEvent,
"The event is in the right type");
ok(aEvent.source instanceof TVSource,
"The source is in the right type.");
is(aEvent.source, tuner.currentSource,
"The current source is set.");
is(tuner.currentSource.type, selectedSourceType,
"The current source type is correct.");
SimpleTest.finish();
};
tuner.setCurrentSource(selectedSourceType).then(
function() {},
function(aError) {
ok(false, "Error occurred when setting current source: " + aError);
SimpleTest.finish();
}
);
},
function(aError) {
ok(false, "Error occurred when getting tuners: " + aError);
SimpleTest.finish();
}
);
}
SimpleTest.waitForExplicitFinish();
prepareTest(runTest);
</script>
</pre>
</body>
</html>