Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / netwerk / test / unit / test_substituting_protocol_handler.js
blob00e5af0c219cee1d0f5e96ddb5696268faf27a3b
1 "use strict";
3 add_task(async function test_case_insensitive_substitutions() {
4 let resProto = Services.io
5 .getProtocolHandler("resource")
6 .QueryInterface(Ci.nsISubstitutingProtocolHandler);
8 let uri = Services.io.newFileURI(do_get_file("data"));
10 resProto.setSubstitution("FooBar", uri);
11 resProto.setSubstitutionWithFlags("BarBaz", uri, 0);
13 equal(
14 resProto.resolveURI(Services.io.newURI("resource://foobar/")),
15 uri.spec,
16 "Got correct resolved URI for setSubstitution"
19 equal(
20 resProto.resolveURI(Services.io.newURI("resource://foobar/")),
21 uri.spec,
22 "Got correct resolved URI for setSubstitutionWithFlags"
25 ok(
26 resProto.hasSubstitution("foobar"),
27 "hasSubstitution works with all-lower-case root"
29 ok(
30 resProto.hasSubstitution("FooBar"),
31 "hasSubstitution works with mixed-case root"
34 equal(
35 resProto.getSubstitution("foobar").spec,
36 uri.spec,
37 "getSubstitution works with all-lower-case root"
39 equal(
40 resProto.getSubstitution("FooBar").spec,
41 uri.spec,
42 "getSubstitution works with mixed-case root"
45 resProto.setSubstitution("foobar", null);
46 resProto.setSubstitution("barbaz", null);
48 Assert.throws(
49 () => resProto.resolveURI(Services.io.newURI("resource://foobar/")),
50 e => e.result == Cr.NS_ERROR_NOT_AVAILABLE,
51 "Correctly unregistered case-insensitive substitution in setSubstitution"
53 Assert.throws(
54 () => resProto.resolveURI(Services.io.newURI("resource://barbaz/")),
55 e => e.result == Cr.NS_ERROR_NOT_AVAILABLE,
56 "Correctly unregistered case-insensitive substitution in setSubstitutionWithFlags"
59 Assert.throws(
60 () => resProto.getSubstitution("foobar"),
61 e => e.result == Cr.NS_ERROR_NOT_AVAILABLE,
62 "foobar substitution has been removed"
64 });