mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1054920 - Do not allow casting UI to appear if the video is an unsupported format r=wesj
This commit is contained in:
parent
99cb17f066
commit
c559937f3d
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user