Bug 1866777 - Disable test_race_cache_with_network.js on windows opt for frequent...
[gecko.git] / netwerk / dns / nsIEffectiveTLDService.idl
blobabf786e5edbcd48888c865c7d60f33366a0336cd
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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 #include "nsISupports.idl"
8 interface nsIURI;
10 [scriptable, uuid(68067eb5-ad8d-43cb-a043-1cc85ebe06e7)]
11 interface nsIEffectiveTLDService : nsISupports
13 /**
14 * Returns the public suffix of a URI. A public suffix is the highest-level domain
15 * under which individual domains may be registered; it may therefore contain one
16 * or more dots. For example, the public suffix for "www.bbc.co.uk" is "co.uk",
17 * because the .uk TLD does not allow the registration of domains at the
18 * second level ("bbc.uk" is forbidden).
20 * The public suffix will be returned encoded in ASCII/ACE and will be normalized
21 * according to RFC 3454, i.e. the same encoding returned by nsIURI::GetAsciiHost().
22 * If consumers wish to compare the result of this method against the host from
23 * another nsIURI, the host should be obtained using nsIURI::GetAsciiHost().
24 * In the case of nested URIs, the innermost URI will be used.
26 * @param aURI The URI to be analyzed
28 * @returns the public suffix
30 * @throws NS_ERROR_UNEXPECTED
31 * or other error returned by nsIIDNService::normalize when
32 * the hostname contains characters disallowed in URIs
33 * @throws NS_ERROR_HOST_IS_IP_ADDRESS
34 * if the host is a numeric IPv4 or IPv6 address (as determined by
35 * the success of a call to PR_StringToNetAddr()).
37 ACString getPublicSuffix(in nsIURI aURI);
39 /**
40 * Similar to getPublicSuffix, but the suffix is validated against
41 * the Public Suffix List. If the suffix is unknown this will return
42 * an empty string.
44 * @param aURI The URI to be analyzed
45 * @returns the public suffix if known, an empty string otherwise
46 * @see getPublicSuffixFromHost()
48 ACString getKnownPublicSuffix(in nsIURI aURI);
50 /**
51 * Returns the base domain of a URI; that is, the public suffix with a given
52 * number of additional domain name parts. For example, the result of this method
53 * for "www.bbc.co.uk", depending on the value of aAdditionalParts parameter, will
54 * be:
56 * 0 (default) -> bbc.co.uk
57 * 1 -> www.bbc.co.uk
59 * Similarly, the public suffix for "www.developer.mozilla.org" is "org", and the base
60 * domain will be:
62 * 0 (default) -> mozilla.org
63 * 1 -> developer.mozilla.org
64 * 2 -> www.developer.mozilla.org
66 * The base domain will be returned encoded in ASCII/ACE and will be normalized
67 * according to RFC 3454, i.e. the same encoding returned by nsIURI::GetAsciiHost().
68 * If consumers wish to compare the result of this method against the host from
69 * another nsIURI, the host should be obtained using nsIURI::GetAsciiHost().
70 * In the case of nested URIs, the innermost URI will be used.
72 * @param aURI The URI to be analyzed
73 * @param aAdditionalParts Number of domain name parts to be
74 * returned in addition to the public suffix
76 * @returns the base domain (public suffix plus the requested number of additional parts)
78 * @throws NS_ERROR_UNEXPECTED
79 * or other error returned by nsIIDNService::normalize when
80 * the hostname contains characters disallowed in URIs
81 * @throws NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS
82 * when there are insufficient subdomain levels in the hostname to satisfy the
83 * requested aAdditionalParts value.
84 * @throws NS_ERROR_HOST_IS_IP_ADDRESS
85 * if aHost is a numeric IPv4 or IPv6 address (as determined by
86 * the success of a call to PR_StringToNetAddr()).
88 * @see getPublicSuffix()
90 ACString getBaseDomain(in nsIURI aURI, [optional] in uint32_t aAdditionalParts);
92 /**
93 * Get the Site without the scheme for the origin of aURI; e.g. for
94 * "https://www.bbc.co.uk/index.html", this would be "bbc.co.uk".
95 * This uses getBaseDomain() internally. This is appropriately permissive,
96 * and will return a schemeless site for aliased hostnames and IP addresses
97 * and will therefore not throw NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS or
98 * NS_ERROR_HOST_IS_IP_ADDRESS, e.g. "http://localhost/index.html" will
99 * return "localhost" successfully, rather than throwing an error.
101 * @param aHostURI
102 * The URI to analyze.
104 * @return the Site.
106 * @throws NS_ERROR_UNEXPECTED
107 * or other error returned by nsIIDNService::normalize when
108 * the hostname contains characters disallowed in URIs
110 * @see getBaseDomain()
111 * @see getSite()
113 * @warning This function should not be used without good reason. Please
114 * use getSite() or the Origin if you are not absolutely certain.
116 ACString getSchemelessSite(in nsIURI aURI);
119 * Get the Site for the origin of aURI; e.g. for
120 * "https://www.bbc.co.uk/index.html", this would be "https://bbc.co.uk".
121 * This uses getBaseDomain() internally. This is appropriately permissive,
122 * and will return a scheme for alaised hostnames and IP addresses and will
123 * therefore not throw NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS or
124 * NS_ERROR_HOST_IS_IP_ADDRESS, e.g. "http://localhost/index.html" will
125 * return "http://localhost" successfully, rather than throwing an error.
127 * @param aHostURI
128 * The URI to analyze.
130 * @return the Site.
132 * @throws NS_ERROR_UNEXPECTED
133 * or other error returned by nsIIDNService::normalize when
134 * the hostname contains characters disallowed in URIs
136 * @see getBaseDomain()
138 ACString getSite(in nsIURI aURI);
141 * NOTE: It is strongly recommended to use getPublicSuffix() above if a suitable
142 * nsIURI is available. Only use this method if this is not the case.
144 * Returns the public suffix of a host string. Otherwise identical to getPublicSuffix().
146 * @param aHost The host to be analyzed. Any additional parts (e.g. scheme,
147 * port, or path) will cause this method to throw. ASCII/ACE and
148 * UTF8 encodings are acceptable as input; normalization will
149 * be performed as specified in getBaseDomain().
151 * @see getPublicSuffix()
153 ACString getPublicSuffixFromHost(in AUTF8String aHost);
156 * Similar to getPublicSuffixFromHost, but the suffix is validated against
157 * the Public Suffix List. If the suffix is unknown this will return
158 * an empty string.
160 * @param aHost The host to be analyzed.
161 * @returns the public suffix if known, an empty string otherwise
162 * @see getPublicSuffixFromHost()
164 ACString getKnownPublicSuffixFromHost(in AUTF8String aHost);
167 * NOTE: It is strongly recommended to use getBaseDomain() above if a suitable
168 * nsIURI is available. Only use this method if this is not the case.
170 * Returns the base domain of a host string. Otherwise identical to getBaseDomain().
172 * @param aHost The host to be analyzed. Any additional parts (e.g. scheme,
173 * port, or path) will cause this method to throw. ASCII/ACE and
174 * UTF8 encodings are acceptable as input; normalization will
175 * be performed as specified in getBaseDomain().
177 * @see getBaseDomain()
179 ACString getBaseDomainFromHost(in AUTF8String aHost, [optional] in uint32_t aAdditionalParts);
182 * Returns the parent sub-domain of a host string. If the host is a base
183 * domain, it will throw NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS.
185 * For example: "player.bbc.co.uk" would return "bbc.co.uk" and
186 * "bbc.co.uk" would throw NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS.
188 * @param aHost The host to be analyzed. Any additional parts (e.g. scheme,
189 * port, or path) will cause this method to throw. ASCII/ACE and
190 * UTF8 encodings are acceptable as input; normalization will
191 * be performed as specified in getBaseDomain().
193 ACString getNextSubDomain(in AUTF8String aHost);
196 * Returns true if the |aInput| in is part of the root domain of |aHost|.
197 * For example, if |aInput| is "www.mozilla.org", and we pass in
198 * "mozilla.org" as |aHost|, this will return true. It would return false
199 * the other way around.
201 * @param aInput The host to be analyzed.
202 * @param aHost The host to compare to.
204 bool hasRootDomain(in AUTF8String aInput, in AUTF8String aHost);