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

76 lines
2.2 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test StartScanning and StopScanning 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.");
var isClearedEventFired = false;
navigator.tv.getTuners().then(
function(aTuners) {
ok(aTuners.length > 0, "Got at least 1 tuner.");
aTuners[0].getSources().then(
function(aSources) {
ok(aSources.length > 0, "Got at least 1 source.");
var source = aSources[0];
source.onscanningstatechanged = function(aEvent) {
if (aEvent.state === 'cleared') {
isClearedEventFired = true;
info("Received channel cache cleared event.");
} else if (aEvent.state === 'stopped') {
ok(isClearedEventFired, "Received channel scanning stopped event after cleared event.");
SimpleTest.finish();
}
};
// TODO Bug 1088818 - Modify the behavior of channel scanning.
source.startScanning({ isRescanned: true }).then(
function() {
source.stopScanning().then(
function() {},
function(aError) {
ok(false, "Error occurred when stopping scanning: " + aError);
SimpleTest.finish();
}
);
},
function(aError) {
ok(false, "Error occurred when starting scanning: " + 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>