1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 * Test that default uri is bypassable by an unknown protocol that is
7 * present in the bypass list (and the pref is enabled)
12 checkInputAndSerializationMatch
,
13 checkSerializationMissingSecondColon
,
14 } = ChromeUtils
.importESModule(
15 "resource://testing-common/simple_unknown_uri_helpers.sys.mjs"
18 function inChildProcess() {
19 return Services
.appinfo
.processType
!= Ci
.nsIXULRuntime
.PROCESS_TYPE_DEFAULT
;
23 // In-Parent-only process pref setup
24 if (!inChildProcess()) {
25 // child-test sets these in test_simple_unknown_uris_wrap.js
26 Services
.prefs
.setBoolPref("network.url.useDefaultURI", true);
27 Services
.prefs
.setBoolPref(
28 "network.url.simple_uri_unknown_schemes_enabled",
31 Services
.prefs
.setCharPref(
32 "network.url.simple_uri_unknown_schemes",
33 "simpleprotocol,otherproto"
37 // sanity check: non-nested special url is fine
38 checkInputAndSerializationMatch("https://example.com/");
40 // nsStandardURL removes second colon when nesting protocols
41 checkSerializationMissingSecondColon("https://https://example.com/");
43 // no-bypass for unknown protocol uses defaultURI
44 checkSerializationMissingSecondColon(
45 "nonsimpleprotocol://https://example.com"
48 // an unknown protocol in the bypass list will use simpleURI
49 checkInputAndSerializationMatch("simpleprotocol://https://example.com");
51 // setCharPref not accessible from child process
52 if (!inChildProcess()) {
53 // check that pref update removes simpleprotocol from bypass list
54 Services
.prefs
.setCharPref(
55 "network.url.simple_uri_unknown_schemes",
58 checkSerializationMissingSecondColon(
59 "simpleprotocol://https://example.com"
62 // check that spaces are parsed out
63 Services
.prefs
.setCharPref(
64 "network.url.simple_uri_unknown_schemes",
65 " simpleprotocol , otherproto "
67 checkInputAndSerializationMatch("simpleprotocol://https://example.com");
68 checkInputAndSerializationMatch("otherproto://https://example.com");