Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 // -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 "use strict";
7 const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
9 Cu.import("resource://gre/modules/Services.jsm");
10 Cu.import("resource://gre/modules/SimpleServiceDiscovery.jsm");
12 function discovery_observer(subject, topic, data) {
13 do_print("Observer: " + data);
15 let service = SimpleServiceDiscovery.findServiceForLocation(data);
16 if (!service)
17 return;
19 do_check_eq(service.friendlyName, "Pretend Device");
20 do_check_eq(service.uuid, "uuid:5ec9ff92-e8b2-4a94-a72c-76b34e6dabb1");
21 do_check_eq(service.manufacturer, "Copy Cat Inc.");
22 do_check_eq(service.modelName, "Eureka Dongle");
24 run_next_test();
25 };
27 add_test(function test_default() {
28 do_register_cleanup(function cleanup() {
29 Services.obs.removeObserver(discovery_observer, "ssdp-service-found");
30 });
32 Services.obs.addObserver(discovery_observer, "ssdp-service-found", false);
34 // Create a pretend service
35 let service = {
36 location: "http://mochi.test:8888/tests/robocop/simpleservice.xml",
37 target: "test:service"
38 };
40 do_print("Force a detailed ping from a pretend service");
42 // Poke the service directly to get the discovery to happen
43 SimpleServiceDiscovery._processService(service);
44 });
46 run_next_test();