diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /netwerk/test/unit/test_standardurl_port.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/test/unit/test_standardurl_port.js')
-rw-r--r-- | netwerk/test/unit/test_standardurl_port.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/netwerk/test/unit/test_standardurl_port.js b/netwerk/test/unit/test_standardurl_port.js new file mode 100644 index 0000000000..76fdad6405 --- /dev/null +++ b/netwerk/test/unit/test_standardurl_port.js @@ -0,0 +1,53 @@ +"use strict"; + +function run_test() { + function makeURI(aURLSpec, aCharset) { + return Services.io.newURI(aURLSpec, aCharset); + } + + var httpURI = makeURI("http://foo.com"); + Assert.equal(-1, httpURI.port); + + // Setting to default shouldn't cause a change + httpURI = httpURI.mutate().setPort(80).finalize(); + Assert.equal(-1, httpURI.port); + + // Setting to default after setting to non-default shouldn't cause a change (bug 403480) + httpURI = httpURI.mutate().setPort(123).finalize(); + Assert.equal(123, httpURI.port); + httpURI = httpURI.mutate().setPort(80).finalize(); + Assert.equal(-1, httpURI.port); + Assert.ok(!/80/.test(httpURI.spec)); + + // URL parsers shouldn't set ports to default value (bug 407538) + httpURI = httpURI.mutate().setSpec("http://foo.com:81").finalize(); + Assert.equal(81, httpURI.port); + httpURI = httpURI.mutate().setSpec("http://foo.com:80").finalize(); + Assert.equal(-1, httpURI.port); + Assert.ok(!/80/.test(httpURI.spec)); + + httpURI = makeURI("http://foo.com"); + Assert.equal(-1, httpURI.port); + Assert.ok(!/80/.test(httpURI.spec)); + + httpURI = makeURI("http://foo.com:80"); + Assert.equal(-1, httpURI.port); + Assert.ok(!/80/.test(httpURI.spec)); + + httpURI = makeURI("http://foo.com:80"); + Assert.equal(-1, httpURI.port); + Assert.ok(!/80/.test(httpURI.spec)); + + httpURI = makeURI("https://foo.com"); + Assert.equal(-1, httpURI.port); + Assert.ok(!/443/.test(httpURI.spec)); + + httpURI = makeURI("https://foo.com:443"); + Assert.equal(-1, httpURI.port); + Assert.ok(!/443/.test(httpURI.spec)); + + // XXX URL parsers shouldn't set ports to default value, even when changing scheme? + // not really possible given current nsIURI impls + //httpURI.spec = "https://foo.com:443"; + //do_check_eq(-1, httpURI.port); +} |