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);
14 resProto
.resolveURI(Services
.io
.newURI("resource://foobar/")),
16 "Got correct resolved URI for setSubstitution"
20 resProto
.resolveURI(Services
.io
.newURI("resource://foobar/")),
22 "Got correct resolved URI for setSubstitutionWithFlags"
26 resProto
.hasSubstitution("foobar"),
27 "hasSubstitution works with all-lower-case root"
30 resProto
.hasSubstitution("FooBar"),
31 "hasSubstitution works with mixed-case root"
35 resProto
.getSubstitution("foobar").spec
,
37 "getSubstitution works with all-lower-case root"
40 resProto
.getSubstitution("FooBar").spec
,
42 "getSubstitution works with mixed-case root"
45 resProto
.setSubstitution("foobar", null);
46 resProto
.setSubstitution("barbaz", null);
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"
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"
60 () => resProto
.getSubstitution("foobar"),
61 e
=> e
.result
== Cr
.NS_ERROR_NOT_AVAILABLE
,
62 "foobar substitution has been removed"