gecko/dom/tv/test/mochitest/file_tv_scan_channels_completed.html
Sean Lin a79f77fa4f Bug 1088310 - [Stingray] Add more tests to TV Manager API. r=ehsan
--HG--
rename : dom/tv/test/file_app.sjs => dom/tv/test/mochitest/file_app.sjs
rename : dom/tv/test/file_app.template.webapp => dom/tv/test/mochitest/file_app.template.webapp
rename : dom/tv/test/file_tv_non_permitted_app.html => dom/tv/test/mochitest/file_tv_non_permitted_app.html
rename : dom/tv/test/mochitest.ini => dom/tv/test/mochitest/mochitest.ini
rename : dom/tv/test/test_tv_non_permitted_app.html => dom/tv/test/mochitest/test_tv_non_permitted_app.html
2014-10-22 23:15:24 +08:00

69 lines
2.0 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test channel scanning complete for TV API</title>
</head>
<body>
<div id="content"></div>
<script type="application/javascript" src="./test_helpers.js"></script>
<script type="application/javascript;version=1.7">
ok('tv' in navigator, "navigator.tv should exist.");
var isScannedEventFired = 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.oneitbroadcasted = function(aEvent) {
info("Received EIT broadcasted event.");
var programs = aEvent.programs;
for (var i = 0; i < programs.length; i++) {
ok(programs[i], "Program " + i + " should be set.")
}
};
source.onscanningstatechanged = function(aEvent) {
if (aEvent.state === 'scanned') {
isScannedEventFired = true;
info("Received channel scanned event.");
ok(aEvent.channel, "Scanned channel should be set.");
} else if (aEvent.state === 'completed') {
ok(isScannedEventFired, "Received channel scanning completed event after channel scanned event.");
finish();
}
};
// TODO Bug 1088818 - Modify the behavior of channel scanning.
source.startScanning({}).then(
function() {},
function(aError) {
ok(false, "Error occurred when starting scanning: " + aError);
finish();
}
);
},
function(aError) {
ok(false, "Error occurred when getting sources: " + aError);
finish();
}
);
},
function(aError) {
ok(false, "Error occurred when getting tuners: " + aError);
finish();
}
);
</script>
</body>
</html>