1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
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
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 // Basic tests to verify that MacSharingService returns expected data
8 function test_getSharingProviders() {
9 let sharingService = Cc["@mozilla.org/widget/macsharingservice;1"].getService(
10 Ci.nsIMacSharingService
13 // Ensure these URL's are accepted without error by the getSharingProviders()
14 // method. This does not test if the URL's are interpreted correctly by
15 // the platform implementation and does not test that the URL will be
16 // successfully shared to the target application if the shareURL method is
17 // used. It does indicate the Mac API's used to get the sharing providers
18 // successfully created a URL object for the URL provided and returned at
19 // least one provider.
22 "http://example.org/#",
23 "http://example.org/dkl??",
24 "http://example.org/dkl?a=b;c=d#thisisaref",
25 "http://example.org/dkl?a=b;c=d#thisisaref#double",
26 "http://example.org/#/",
27 "http://example.org/#/#",
28 "http://example.org/#/#/",
29 // This test fails due to the '|' in the path which needs additional
30 // encoding before conversion to NSURL. See bug 1740565.
31 // "http://example.org/foo/bar/x|page.html#this_is_a_fragment",
32 "http://example.org/page.html#this_is_a_fragment",
33 "http://example.org/page.html#this_is_a_fragment#and_another",
34 "http://example.org/foo/bar;#foo",
35 "http://example.org/a file with spaces.html",
36 "https://chat.mozilla.org/#/room/#macdev:mozilla.org",
37 "https://chat.mozilla.org/#/room/%23macdev:mozilla.org",
40 urls.forEach(url => testGetSharingProvidersForUrl(sharingService, url));
43 function testGetSharingProvidersForUrl(sharingService, url) {
44 let providers = sharingService.getSharingProviders(url);
45 Assert.greater(providers.length, 1, "There are providers returned");
46 providers.forEach(provider => {
47 Assert.ok("name" in provider, "Provider has name");
48 Assert.ok("menuItemTitle" in provider, "Provider has menuItemTitle");
49 Assert.ok("image" in provider, "Provider has image");
54 "Known filtered provider not returned"
60 test_getSharingProviders();