Bug 1054920 - Do not allow casting UI to appear if the video is an unsupported format r=wesj

This commit is contained in:
Mark Finkle 2014-08-19 19:34:29 -04:00
parent 99cb17f066
commit c559937f3d
3 changed files with 33 additions and 4 deletions

View File

@ -8,6 +8,7 @@
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/SimpleServiceDiscovery.jsm");
function ok(passed, text) {
do_report_result(passed, text, Components.stack.caller, false);
@ -26,14 +27,38 @@ function middle(element) {
return [x, y];
}
// We must register a target and make a "mock" service for the target
var testTarget = {
target: "test:service",
factory: function(service) { /* dummy */ },
types: ["video/mp4", "video/webm"],
extensions: ["mp4", "webm"]
};
add_test(function setup_browser() {
chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
let BrowserApp = chromeWin.BrowserApp;
do_register_cleanup(function cleanup() {
BrowserApp.closeTab(BrowserApp.getTabForBrowser(browser));
SimpleServiceDiscovery.unregisterTarget(testTarget);
});
// We need to register a target or processService will ignore us
SimpleServiceDiscovery.registerTarget(testTarget);
// Create a pretend service
let service = {
location: "http://mochi.test:8888/tests/robocop/simpleservice.xml",
target: "test:service"
};
do_print("Force a detailed ping from a pretend service");
// Poke the service directly to get the discovery to happen
SimpleServiceDiscovery._processService(service);
// Load our test web page with <video> elements
let url = "http://mochi.test:8888/tests/robocop/video_discovery.html";
browser = BrowserApp.addTab(url, { selected: true, parentId: BrowserApp.selectedTab.id }).browser;
browser.addEventListener("load", function startTests(event) {

View File

@ -458,6 +458,10 @@ var CastingApps = {
}
});
if (items.length == 0) {
return;
}
let prompt = new Prompt({
title: Strings.browser.GetStringFromName("casting.prompt")
}).setSingleChoiceItems(items).show(function(data) {

View File

@ -246,8 +246,8 @@ var SimpleServiceDiscovery = {
getSupportedExtensions: function() {
let extensions = [];
this._targets.forEach(function(target) {
extensions = extensions.concat(target.extensions);
this.services.forEach(function(service) {
extensions = extensions.concat(service.extensions);
}, this);
return extensions.filter(function(extension, pos) {
return extensions.indexOf(extension) == pos;
@ -256,8 +256,8 @@ var SimpleServiceDiscovery = {
getSupportedMimeTypes: function() {
let types = [];
this._targets.forEach(function(target) {
types = types.concat(target.types);
this.services.forEach(function(service) {
types = types.concat(service.types);
}, this);
return types.filter(function(type, pos) {
return types.indexOf(type) == pos;