Bug 1125477 - Part 1: Modify dom/tv mochitest in order to enable e10s test. r=seanlin

This commit is contained in:
Mantaroh Yoshinaga 2015-11-15 14:48:40 +01:00
parent ffbe892e3a
commit 9eb8de6c3f
35 changed files with 585 additions and 1153 deletions

View File

@ -1,55 +0,0 @@
var gBasePath = "tests/dom/tv/test/mochitest/";
function handleRequest(request, response) {
var query = getQuery(request);
var testToken = '';
if ('testToken' in query) {
testToken = query.testToken;
}
var template = '';
if ('template' in query) {
template = query.template;
}
var template = gBasePath + template;
response.setHeader("Content-Type", "application/x-web-app-manifest+json", false);
response.write(readTemplate(template).replace(/TESTTOKEN/g, testToken));
}
// Copy-pasted incantations. There ought to be a better way to synchronously read
// a file into a string, but I guess we're trying to discourage that.
function readTemplate(path) {
var file = Components.classes["@mozilla.org/file/directory_service;1"].
getService(Components.interfaces.nsIProperties).
get("CurWorkD", Components.interfaces.nsILocalFile);
var fis = Components.classes['@mozilla.org/network/file-input-stream;1'].
createInstance(Components.interfaces.nsIFileInputStream);
var cis = Components.classes["@mozilla.org/intl/converter-input-stream;1"].
createInstance(Components.interfaces.nsIConverterInputStream);
var split = path.split("/");
for(var i = 0; i < split.length; ++i) {
file.append(split[i]);
}
fis.init(file, -1, -1, false);
cis.init(fis, "UTF-8", 0, 0);
var data = "";
let str = {};
let read = 0;
do {
read = cis.readString(0xffffffff, str); // read as much as we can and put it in str.value
data += str.value;
} while (read != 0);
cis.close();
return data;
}
function getQuery(request) {
var query = {};
request.queryString.split('&').forEach(function (val) {
var [name, value] = val.split('=');
query[name] = unescape(value);
});
return query;
}

View File

@ -1,6 +0,0 @@
{
"name": "TV Test App (hosted)",
"description": "Hosted TV test app used for mochitest.",
"launch_path": "/tests/dom/tv/test/mochitest/TESTTOKEN",
"icons": { "128": "default_icon" }
}

View File

@ -1,60 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test GetChannels 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.");
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.");
aSources[0].getChannels().then(
function(aChannels) {
ok(aChannels.length > 0, "Got at least 1 channel.");
for (var i = 0; i < aChannels.length; i++) {
var channel = aChannels[i];
ok(channel instanceof TVChannel, "Channel " + i + " should be in right type.")
ok('source' in channel, "Channel " + i + " should have a source.");
ok('networkId' in channel, "Channel " + i + " should have a network ID.");
ok('transportStreamId' in channel, "Channel " + i + " should have a transport stream ID.");
ok('serviceId' in channel, "Channel " + i + " should have a service ID.");
ok('type' in channel, "Channel " + i + " should have a type.");
ok('name' in channel, "Channel " + i + " should have a name.");
ok('number' in channel, "Channel " + i + " should have a number.");
}
finish();
},
function(aError) {
ok(false, "Error occurred when getting channels: " + 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>

View File

@ -1,58 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test an error case for GetChannels during scanning 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.");
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];
// TODO Bug 1088818 - Modify the behavior of channel scanning.
source.startScanning({}).then(
function() {
source.getChannels().then(
function() {
ok(false, "Getting channels during scanning should get error.");
finish();
},
function(aError) {
is(aError.name, "InvalidStateError",
"InvalidStateError should be expected.");
finish();
}
);
},
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>

View File

@ -1,68 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test GetCurrentProgram 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.");
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.");
aSources[0].getChannels().then(
function(aChannels) {
ok(aChannels.length > 0, "Got at least 1 channel.");
aChannels[0].getCurrentProgram().then(
function(aCurrentProgram) {
ok(aCurrentProgram, "Got the current program.");
ok(aCurrentProgram instanceof TVProgram, "The current program should be in the right type.")
ok('channel' in aCurrentProgram, "The current program should have a channel.");
ok('eventId' in aCurrentProgram, "The current program should have an event ID.");
ok('title' in aCurrentProgram, "The current program should have a title.");
ok('startTime' in aCurrentProgram, "The current program should have start time.");
ok('duration' in aCurrentProgram, "The current program should have duration.");
ok(aCurrentProgram.getAudioLanguages().length >= 0,
"The current program may have audio language(s).");
ok(aCurrentProgram.getSubtitleLanguages().length >= 0,
"The current program may have subtitle language(s).");
finish();
},
function(aError) {
ok(false, "Error occurred when getting programs: " + aError);
finish();
}
);
},
function(aError) {
ok(false, "Error occurred when getting channels: " + 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>

View File

@ -1,71 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test GetPrograms 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.");
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.");
aSources[0].getChannels().then(
function(aChannels) {
ok(aChannels.length > 0, "Got at least 1 channel.");
aChannels[0].getPrograms().then(
function(aPrograms) {
ok(aPrograms.length > 0, "Got at least 1 program.");
for (var i = 0; i < aPrograms.length; i++) {
var program = aPrograms[i];
ok(program instanceof TVProgram, "Program " + i + " should be in the right type.")
ok('channel' in program, "Program " + i + " should have a channel.");
ok('eventId' in program, "Program " + i + " should have an event ID.");
ok('title' in program, "Program " + i + " should have a title.");
ok('startTime' in program, "Program " + i + " should have start time.");
ok('duration' in program, "Program " + i + " should have duration.");
ok(program.getAudioLanguages().length >= 0,
"Program " + i + " may have audio language(s).");
ok(program.getSubtitleLanguages().length >= 0,
"Program " + i + " may have subtitle language(s).");
}
finish();
},
function(aError) {
ok(false, "Error occurred when getting programs: " + aError);
finish();
}
);
},
function(aError) {
ok(false, "Error occurred when getting channels: " + 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>

View File

@ -1,49 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test GetSources 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.");
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.");
for (var i = 0; i < aSources.length; i++) {
var source = aSources[i];
ok(source instanceof TVSource, "Source " + i + " should be in the right type.");
ok('tuner' in source, "Source " + i + " should have a tuner.");
ok('type' in source, "Source " + i + " should have a type.");
ok('isScanning' in source, "Source " + i + " should have isScanning.");
ok(!source.isScanning,
"Source " + i + " should not be scanning by default.");
ok(!source.currentChannel,
"Source " + i + " should have no current channel by default.");
}
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>

View File

@ -1,38 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test GetTuners 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.");
navigator.tv.getTuners().then(
function(aTuners) {
ok(aTuners.length > 0, "Got at least 1 tuner.");
for (var i = 0; i < aTuners.length; i++) {
var tuner = aTuners[i];
ok(tuner instanceof TVTuner, "Tuner " + i + " should be in the right type.");
ok('id' in tuner, "Tuner " + i + " should have an ID.");
ok(tuner.getSupportedSourceTypes().length > 0,
"Tuner " + i + " should have supported source type(s).");
ok(!tuner.currentSource,
"Tuner " + i + " should have no current source by default.");
ok(!tuner.stream, "Tuner " + i + " should have no stream by default.");
}
finish();
},
function(aError) {
ok(false, "Error occurred when getting tuners: " + aError);
finish();
}
);
</script>
</body>
</html>

View File

@ -1,17 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test the availability of TV Manager API for non-permitted Apps</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 not exist for non-permitted app.");
finish();
</script>
</body>
</html>

View File

@ -1,16 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test the availability of TV Manager API for permitted Apps</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 for permitted app.");
finish();
</script>
</body>
</html>

View File

@ -1,68 +0,0 @@
<!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>

View File

@ -1,66 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test StartScanning and StopScanning 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 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.");
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);
finish();
}
);
},
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>

View File

@ -1,70 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test SetCurrentChannel 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.");
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.");
finish();
};
source.setCurrentChannel(selectedChannelNumber).then(
function() {},
function(aError) {
ok(false, "Error occurred when setting current channel: " + aError);
finish();
}
);
},
function(aError) {
ok(false, "Error occurred when getting channels: " + 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>

View File

@ -1,58 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test an error case for SetCurrentChannel during scanning 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.");
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];
// TODO Bug 1088818 - Modify the behavior of channel scanning.
source.startScanning({}).then(
function() {
source.setCurrentChannel("1").then(
function() {
ok(false, "Setting current channel during scanning should get error.");
finish();
},
function(aError) {
is(aError.name, "InvalidStateError",
"InvalidStateError should be expected.");
finish();
}
);
},
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>

View File

@ -1,48 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test SetCurrentSource 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.");
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.");
finish();
};
tuner.setCurrentSource(selectedSourceType).then(
function() {},
function(aError) {
ok(false, "Error occurred when setting current source: " + aError);
finish();
}
);
},
function(aError) {
ok(false, "Error occurred when getting tuners: " + aError);
finish();
}
);
</script>
</body>
</html>

View File

@ -1,49 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test an error case for SetCurrentChannel 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.");
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.");
aSources[0].setCurrentChannel("NonExistentChannelNumber").then(
function() {
ok(false, "Setting an invalid current channel should get error.");
finish();
},
function(aError) {
is(aError.name, "AbortError", "AbortError should be expected.");
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>

View File

@ -1,36 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test an error case for SetCurrentSource 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.");
navigator.tv.getTuners().then(
function(aTuners) {
ok(aTuners.length > 0, "Got at least 1 tuner.");
aTuners[0].setCurrentSource("InvalidSourceType").then(
function() {
ok(false, "Setting an invalid current source should get error.");
finish();
},
function(aError) {
is(aError.name, "TypeError", "TypeError should be expected.");
finish();
}
);
},
function(aError) {
ok(false, "Error occurred when getting tuners: " + aError);
finish();
}
);
</script>
</body>
</html>

View File

@ -1,98 +1,28 @@
"use strict";
var gAppsService = SpecialPowers.Cc["@mozilla.org/AppsService;1"]
.getService(SpecialPowers.Ci.nsIAppsService);
var gApp;
function cbError(e) {
ok(false, "Error callback invoked: " + this.error.name);
SimpleTest.finish();
}
function installApp(aTestToken, aTemplate) {
var hostedManifestURL = window.location.origin +
'/tests/dom/tv/test/mochitest/file_app.sjs?testToken='
+ aTestToken + '&template=' + aTemplate;
var request = navigator.mozApps.install(hostedManifestURL);
request.onerror = cbError;
request.onsuccess = function() {
gApp = request.result;
var appId = gAppsService.getAppLocalIdByManifestURL(gApp.manifestURL);
SpecialPowers.addPermission("tv", true, { url: gApp.origin,
originAttributes: {
appId: appId
}});
runTest();
}
}
function uninstallApp() {
var request = navigator.mozApps.mgmt.uninstall(gApp);
request.onerror = cbError;
request.onsuccess = function() {
// All done.
info("All done");
runTest();
}
}
function testApp() {
var ifr = document.createElement('iframe');
ifr.setAttribute('mozbrowser', 'true');
ifr.setAttribute('mozapp', gApp.manifestURL);
ifr.setAttribute('src', gApp.manifest.launch_path);
var domParent = document.getElementById('content');
// Set us up to listen for messages from the app.
var listener = function(e) {
var message = e.detail.message;
if (/^OK/.exec(message)) {
ok(true, "Message from app: " + message);
} else if (/KO/.exec(message)) {
ok(false, "Message from app: " + message);
} else if (/^INFO/.exec(message)) {
info("Message from app: " + message);
} else if (/DONE/.exec(message)) {
ok(true, "Messaging from app complete");
ifr.removeEventListener('mozbrowsershowmodalprompt', listener);
domParent.removeChild(ifr);
runTest();
}
}
// This event is triggered when the app calls "alert".
ifr.addEventListener('mozbrowsershowmodalprompt', listener, false);
domParent.appendChild(ifr);
}
function runTest() {
if (!tests.length) {
SimpleTest.finish();
return;
}
var test = tests.shift();
test();
}
function setupPrefsAndPermissions() {
SpecialPowers.pushPrefEnv({"set": [["dom.tv.enabled", true],
["dom.testing.tv_enabled_for_hosted_apps", true]]}, function() {
SpecialPowers.pushPermissions(
[{ "type": "browser", "allow": true, "context": document },
{ "type": "embed-apps", "allow": true, "context": document },
{ "type": "webapps-manage", "allow": true, "context": document }],
function() {
SpecialPowers.setAllAppsLaunchable(true);
SpecialPowers.setBoolPref("dom.mozBrowserFramesEnabled", true);
// No confirmation needed when an app is installed and uninstalled.
SpecialPowers.autoConfirmAppInstall(() => {
SpecialPowers.autoConfirmAppUninstall(runTest);
});
});
function setupPrefsAndPermissions(callback) {
setupPrefs(function() {
SpecialPowers.pushPermissions([
{"type":"tv", "allow":1, "context":document}
], callback);
});
}
function setupPrefs(callback) {
SpecialPowers.pushPrefEnv({"set": [["dom.tv.enabled", true],
["dom.testing.tv_enabled_for_hosted_apps", true]]}, function() {
callback();
});
}
function removePrefsAndPermissions(callback) {
SpecialPowers.popPrefEnv(function() {
SpecialPowers.popPermissions(callback);
});
}
function prepareTest(callback) {
removePrefsAndPermissions(function() {
setupPrefsAndPermissions(callback);
});
}

View File

@ -1,25 +1,5 @@
[DEFAULT]
skip-if = e10s || toolkit == 'gonk' # Bug 1125477
support-files =
file_app.sjs
file_app.template.webapp
file_tv_non_permitted_app.html
file_tv_permitted_app.html
file_tv_get_tuners.html
file_tv_get_sources.html
file_tv_get_channels.html
file_tv_get_channels_during_scanning.html
file_tv_get_programs.html
file_tv_get_current_program.html
file_tv_set_current_source.html
file_tv_set_invalid_current_source.html
file_tv_set_current_channel.html
file_tv_set_current_channel_during_scanning.html
file_tv_set_invalid_current_channel.html
file_tv_scan_channels_stopped.html
file_tv_scan_channels_completed.html
head.js
test_helpers.js
support-files = head.js
[test_tv_non_permitted_app.html]
[test_tv_permitted_app.html]

View File

@ -1,17 +0,0 @@
"use strict";
function is(a, b, msg) {
alert((a === b ? 'OK' : 'KO') + ' ' + msg);
}
function ok(a, msg) {
alert((a ? 'OK' : 'KO')+ ' ' + msg);
}
function info(msg) {
alert('INFO ' + msg);
}
function finish() {
alert('DONE');
}

View File

@ -12,22 +12,57 @@
<script type="application/javascript" src="./head.js"></script>
<script type="application/javascript">
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
function runTest() {
// Installing the app
installApp.bind(this, "file_tv_get_channels.html", "file_app.template.webapp"),
ok('tv' in navigator, "navigator.tv should exist.");
// Run tests in app
testApp,
navigator.tv.getTuners().then(
function(aTuners) {
ok(aTuners.length > 0, "Got at least 1 tuner.");
// Uninstall the app
uninstallApp
];
aTuners[0].getSources().then(
function(aSources) {
ok(aSources.length > 0, "Got at least 1 source.");
aSources[0].getChannels().then(
function(aChannels) {
ok(aChannels.length > 0, "Got at least 1 channel.");
for (var i = 0; i < aChannels.length; i++) {
var channel = aChannels[i];
ok(channel instanceof TVChannel, "Channel " + i + " should be in right type.")
ok('source' in channel, "Channel " + i + " should have a source.");
ok('networkId' in channel, "Channel " + i + " should have a network ID.");
ok('transportStreamId' in channel, "Channel " + i + " should have a transport stream ID.");
ok('serviceId' in channel, "Channel " + i + " should have a service ID.");
ok('type' in channel, "Channel " + i + " should have a type.");
ok('name' in channel, "Channel " + i + " should have a name.");
ok('number' in channel, "Channel " + i + " should have a number.");
}
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();
runTest();
prepareTest(runTest);
</script>
</pre>

View File

@ -12,22 +12,54 @@
<script type="application/javascript" src="./head.js"></script>
<script type="application/javascript">
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
function runTest() {
ok('tv' in navigator, "navigator.tv should exist.");
// Installing the app
installApp.bind(this, "file_tv_get_channels_during_scanning.html", "file_app.template.webapp"),
navigator.tv.getTuners().then(
function(aTuners) {
ok(aTuners.length > 0, "Got at least 1 tuner.");
// Run tests in app
testApp,
aTuners[0].getSources().then(
function(aSources) {
ok(aSources.length > 0, "Got at least 1 source.");
var source = aSources[0];
// Uninstall the app
uninstallApp
];
// TODO Bug 1088818 - Modify the behavior of channel scanning.
source.startScanning({}).then(
function() {
source.getChannels().then(
function() {
ok(false, "Getting channels during scanning should get error.");
SimpleTest.finish();
},
function(aError) {
is(aError.name, "InvalidStateError",
"InvalidStateError should be expected.");
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();
runTest();
prepareTest(runTest);
</script>
</pre>

View File

@ -12,22 +12,64 @@
<script type="application/javascript" src="./head.js"></script>
<script type="application/javascript">
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
function runTest() {
ok('tv' in navigator, "navigator.tv should exist.");
// Installing the app
installApp.bind(this, "file_tv_get_current_program.html", "file_app.template.webapp"),
navigator.tv.getTuners().then(
function(aTuners) {
ok(aTuners.length > 0, "Got at least 1 tuner.");
// Run tests in app
testApp,
aTuners[0].getSources().then(
function(aSources) {
ok(aSources.length > 0, "Got at least 1 source.");
// Uninstall the app
uninstallApp
];
aSources[0].getChannels().then(
function(aChannels) {
ok(aChannels.length > 0, "Got at least 1 channel.");
aChannels[0].getCurrentProgram().then(
function(aCurrentProgram) {
ok(aCurrentProgram, "Got the current program.");
ok(aCurrentProgram instanceof TVProgram, "The current program should be in the right type.")
ok('channel' in aCurrentProgram, "The current program should have a channel.");
ok('eventId' in aCurrentProgram, "The current program should have an event ID.");
ok('title' in aCurrentProgram, "The current program should have a title.");
ok('startTime' in aCurrentProgram, "The current program should have start time.");
ok('duration' in aCurrentProgram, "The current program should have duration.");
ok(aCurrentProgram.getAudioLanguages().length >= 0,
"The current program may have audio language(s).");
ok(aCurrentProgram.getSubtitleLanguages().length >= 0,
"The current program may have subtitle language(s).");
SimpleTest.finish();
},
function(aError) {
ok(false, "Error occurred when getting programs: " + 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();
runTest();
prepareTest(runTest);
</script>
</pre>

View File

@ -12,22 +12,68 @@
<script type="application/javascript" src="./head.js"></script>
<script type="application/javascript">
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
function runTest() {
ok('tv' in navigator, "navigator.tv should exist.");
// Installing the app
installApp.bind(this, "file_tv_get_programs.html", "file_app.template.webapp"),
navigator.tv.getTuners().then(
function(aTuners) {
ok(aTuners.length > 0, "Got at least 1 tuner.");
// Run tests in app
testApp,
aTuners[0].getSources().then(
function(aSources) {
ok(aSources.length > 0, "Got at least 1 source.");
// Uninstall the app
uninstallApp
];
aSources[0].getChannels().then(
function(aChannels) {
ok(aChannels.length > 0, "Got at least 1 channel.");
aChannels[0].getPrograms().then(
function(aPrograms) {
ok(aPrograms.length > 0, "Got at least 1 program.");
for (var i = 0; i < aPrograms.length; i++) {
var program = aPrograms[i];
ok(program instanceof TVProgram, "Program " + i + " should be in the right type.")
ok('channel' in program, "Program " + i + " should have a channel.");
ok('eventId' in program, "Program " + i + " should have an event ID.");
ok('title' in program, "Program " + i + " should have a title.");
ok('startTime' in program, "Program " + i + " should have start time.");
ok('duration' in program, "Program " + i + " should have duration.");
ok(program.getAudioLanguages().length >= 0,
"Program " + i + " may have audio language(s).");
ok(program.getSubtitleLanguages().length >= 0,
"Program " + i + " may have subtitle language(s).");
}
SimpleTest.finish();
},
function(aError) {
ok(false, "Error occurred when getting programs: " + 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();
runTest();
prepareTest(runTest);
</script>
</pre>

View File

@ -12,24 +12,45 @@
<script type="application/javascript" src="./head.js"></script>
<script type="application/javascript">
"use strict";
function runTest() {
ok('tv' in navigator, "navigator.tv should exist.");
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
navigator.tv.getTuners().then(
function(aTuners) {
ok(aTuners.length > 0, "Got at least 1 tuner.");
// Installing the app
installApp.bind(this, "file_tv_get_sources.html", "file_app.template.webapp"),
aTuners[0].getSources().then(
function(aSources) {
ok(aSources.length > 0, "Got at least 1 source.");
for (var i = 0; i < aSources.length; i++) {
var source = aSources[i];
ok(source instanceof TVSource, "Source " + i + " should be in the right type.");
ok('tuner' in source, "Source " + i + " should have a tuner.");
ok('type' in source, "Source " + i + " should have a type.");
ok('isScanning' in source, "Source " + i + " should have isScanning.");
ok(!source.isScanning,
"Source " + i + " should not be scanning by default.");
ok(!source.currentChannel,
"Source " + i + " should have no current channel by default.");
}
// Run tests in app
testApp,
// Uninstall the app
uninstallApp
];
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();
runTest();
prepareTest(runTest);
</script>
</pre>

View File

@ -12,22 +12,34 @@
<script type="application/javascript" src="./head.js"></script>
<script type="application/javascript">
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
function runTest() {
ok('tv' in navigator, "navigator.tv should exist.");
// Installing the app
installApp.bind(this, "file_tv_get_tuners.html", "file_app.template.webapp"),
navigator.tv.getTuners().then(
function(aTuners) {
ok(aTuners.length > 0, "Got at least 1 tuner.");
for (var i = 0; i < aTuners.length; i++) {
var tuner = aTuners[i];
ok(tuner instanceof TVTuner, "Tuner " + i + " should be in the right type.");
ok('id' in tuner, "Tuner " + i + " should have an ID.");
ok(tuner.getSupportedSourceTypes().length > 0,
"Tuner " + i + " should have supported source type(s).");
ok(!tuner.currentSource,
"Tuner " + i + " should have no current source by default.");
ok(!tuner.stream, "Tuner " + i + " should have no stream by default.");
}
// Run tests in app
testApp,
// Uninstall the app
uninstallApp
];
SimpleTest.finish();
},
function(aError) {
ok(false, "Error occurred when getting tuners: " + aError);
SimpleTest.finish();
}
);
}
SimpleTest.waitForExplicitFinish();
runTest();
prepareTest(runTest);
</script>
</pre>

View File

@ -12,35 +12,14 @@
<script type="application/javascript" src="./head.js"></script>
<script type="application/javascript">
var tests = [
function() {
SpecialPowers.pushPrefEnv({"set": [["dom.tv.enabled", true],["dom.mozBrowserFramesEnabled", true]]}, function() {
SpecialPowers.pushPermissions(
[{ "type": "browser", "allow": true, "context": document },
{ "type": "embed-apps", "allow": true, "context": document },
{ "type": "webapps-manage", "allow": true, "context": document }],
function() {
SpecialPowers.setAllAppsLaunchable(true);
// No confirmation needed when an app is installed and uninstalled.
SpecialPowers.autoConfirmAppInstall(() => {
SpecialPowers.autoConfirmAppUninstall(runTest);
});
});
});
},
// Installing the app
installApp.bind(this, "file_tv_non_permitted_app.html", "file_app.template.webapp"),
// Run tests in app
testApp,
// Uninstall the app
uninstallApp
];
function runTest() {
ok(!('tv' in navigator),
"navigator.tv should not exist for non-permitted app.");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
runTest();
setupPrefs(runTest);
</script>
</pre>

View File

@ -12,22 +12,13 @@
<script type="application/javascript" src="./head.js"></script>
<script type="application/javascript">
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
// Installing the app
installApp.bind(this, "file_tv_permitted_app.html", "file_app.template.webapp"),
// Run tests in app
testApp,
// Uninstall the app
uninstallApp
];
function runTest() {
ok('tv' in navigator, "navigator.tv should exist for permitted app.");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
runTest();
prepareTest(runTest);
</script>
</pre>

View File

@ -12,23 +12,65 @@
<script type="application/javascript" src="./head.js"></script>
<script type="application/javascript">
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
function runTest() {
ok('tv' in navigator, "navigator.tv should exist.");
// Installing the app
installApp.bind(this, "file_tv_scan_channels_completed.html", "file_app.template.webapp"),
var isScannedEventFired = false;
navigator.tv.getTuners().then(
function(aTuners) {
ok(aTuners.length > 0, "Got at least 1 tuner.");
// Run tests in app
testApp,
aTuners[0].getSources().then(
function(aSources) {
ok(aSources.length > 0, "Got at least 1 source.");
var source = aSources[0];
// Uninstall the app
uninstallApp
];
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.");
SimpleTest.finish();
}
};
// TODO Bug 1088818 - Modify the behavior of channel scanning.
source.startScanning({}).then(
function() {},
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.expectAssertions(0, 2);
SimpleTest.waitForExplicitFinish();
runTest();
prepareTest(runTest);
</script>
</pre>

View File

@ -12,22 +12,62 @@
<script type="application/javascript" src="./head.js"></script>
<script type="application/javascript">
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
function runTest() {
ok('tv' in navigator, "navigator.tv should exist.");
// Installing the app
installApp.bind(this, "file_tv_scan_channels_stopped.html", "file_app.template.webapp"),
var isClearedEventFired = false;
navigator.tv.getTuners().then(
function(aTuners) {
ok(aTuners.length > 0, "Got at least 1 tuner.");
// Run tests in app
testApp,
aTuners[0].getSources().then(
function(aSources) {
ok(aSources.length > 0, "Got at least 1 source.");
var source = aSources[0];
// Uninstall the app
uninstallApp
];
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();
runTest();
prepareTest(runTest);
</script>
</pre>

View File

@ -12,22 +12,66 @@
<script type="application/javascript" src="./head.js"></script>
<script type="application/javascript">
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
function runTest() {
ok('tv' in navigator, "navigator.tv should exist.");
// Installing the app
installApp.bind(this, "file_tv_set_current_channel.html", "file_app.template.webapp"),
navigator.tv.getTuners().then(
function(aTuners) {
ok(aTuners.length > 0, "Got at least 1 tuner.");
var tuner = aTuners[0];
var selectedSourceType = tuner.getSupportedSourceTypes()[0];
// Run tests in app
testApp,
aTuners[0].getSources().then(
function(aSources) {
ok(aSources.length > 0, "Got at least 1 source.");
var source = aSources[0];
// Uninstall the app
uninstallApp
];
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();
runTest();
prepareTest(runTest);
</script>
</pre>

View File

@ -12,22 +12,54 @@
<script type="application/javascript" src="./head.js"></script>
<script type="application/javascript">
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
function runTest() {
ok('tv' in navigator, "navigator.tv should exist.");
// Installing the app
installApp.bind(this, "file_tv_set_current_channel_during_scanning.html", "file_app.template.webapp"),
navigator.tv.getTuners().then(
function(aTuners){
ok(aTuners.length > 0, "Got at least 1 tuner.");
// Run tests in app
testApp,
aTuners[0].getSources().then(
function(aSources) {
ok(aSources.length > 0, "Got at least 1 source.");
var source = aSources[0];
// Uninstall the app
uninstallApp
];
// TODO Bug 1088818 - Modify the behavior of channel scanning.
source.startScanning({}).then(
function() {
source.setCurrentChannel("1").then(
function() {
ok(false, "Setting current channel during scanning should get error.");
SimpleTest.finish();
},
function(aError) {
is(aError.name, "InvalidStateError",
"InvalidStateError should be expected.");
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();
runTest();
prepareTest(runTest);
</script>
</pre>

View File

@ -12,22 +12,44 @@
<script type="application/javascript" src="./head.js"></script>
<script type="application/javascript">
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
function runTest() {
ok('tv' in navigator, "navigator.tv should exist.");
// Installing the app
installApp.bind(this, "file_tv_set_current_source.html", "file_app.template.webapp"),
navigator.tv.getTuners().then(
function(aTuners) {
ok(aTuners.length > 0, "Got at least 1 tuner.");
var tuner = aTuners[0];
var selectedSourceType = tuner.getSupportedSourceTypes()[0];
// Run tests in app
testApp,
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();
};
// Uninstall the app
uninstallApp
];
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();
runTest();
prepareTest(runTest);
</script>
</pre>

View File

@ -12,22 +12,45 @@
<script type="application/javascript" src="./head.js"></script>
<script type="application/javascript">
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
function runTest() {
ok('tv' in navigator, "navigator.tv should exist.");
// Installing the app
installApp.bind(this, "file_tv_set_invalid_current_channel.html", "file_app.template.webapp"),
navigator.tv.getTuners().then(
function(aTuners) {
ok(aTuners.length > 0, "Got at least 1 tuner.");
var tuner = aTuners[0];
var selectedSourceType = tuner.getSupportedSourceTypes()[0];
// Run tests in app
testApp,
aTuners[0].getSources().then(
function(aSources) {
ok(aSources.length > 0, "Got at least 1 source.");
// Uninstall the app
uninstallApp
];
aSources[0].setCurrentChannel("NonExistentChannelNumber").then(
function() {
ok(false, "Setting an invalid current channel should get error.");
SimpleTest.finish();
},
function(aError) {
is(aError.name, "AbortError", "AbortError should be expected.");
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();
runTest();
prepareTest(runTest);
</script>
</pre>

View File

@ -12,22 +12,33 @@
<script type="application/javascript" src="./head.js"></script>
<script type="application/javascript">
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
function runTest() {
ok('tv' in navigator, "navigator.tv should exist.");
// Installing the app
installApp.bind(this, "file_tv_set_invalid_current_source.html", "file_app.template.webapp"),
navigator.tv.getTuners().then(
function(aTuners) {
ok(aTuners.length > 0, "Got at least 1 tuner.");
// Run tests in app
testApp,
// Uninstall the app
uninstallApp
];
aTuners[0].setCurrentSource("InvalidSourceType").then(
function() {
ok(false, "Setting an invalid current source should get error.");
SimpleTest.finish();
},
function(aError) {
is(aError.name, "TypeError", "TypeError should be expected.");
SimpleTest.finish();
}
);
},
function(aError) {
ok(false, "Error occurred when getting tuners: " + aError);
SimpleTest.finish();
}
);
}
SimpleTest.waitForExplicitFinish();
runTest();
prepareTest(runTest);
</script>
</pre>