mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-11-19 18:38:36 +00:00
58 lines
1.6 KiB
HTML
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>
|