6 var test_port = function (port, exception_expected) {
7 dump((port || "no port provided") + "\n");
8 var exception_threw = false;
10 var newURI = ios.newURI("http://foo.com" + port);
12 exception_threw = e.result == Cr.NS_ERROR_MALFORMED_URI;
14 if (exception_threw != exception_expected) {
17 (exception_expected ? "n't" : "") +
18 " throw NS_ERROR_MALFORMED_URI when creating a new URI with " +
23 Assert.equal(exception_threw, exception_expected);
25 exception_threw = false;
26 newURI = ios.newURI("http://foo.com");
30 .setSpec("http://foo.com" + port)
33 exception_threw = e.result == Cr.NS_ERROR_MALFORMED_URI;
35 if (exception_threw != exception_expected) {
38 (exception_expected ? "n't" : "") +
39 " throw NS_ERROR_MALFORMED_URI when setting a spec of a URI with " +
44 Assert.equal(exception_threw, exception_expected);
47 test_port(":invalid", true);
48 test_port(":-2", true);
49 test_port(":-1", true);
50 test_port(":0", false);
52 ":185891548721348172817857824356013651809236172635716571865023757816234081723451516780356",
56 // Following 3 tests are all failing, we do not throw, although we parse the whole string and use only 5870 as a portnumber
57 test_port(":5870:80", true);
58 test_port(":5870-80", true);
59 test_port(":5870+80", true);
61 // Just a regression check
62 test_port(":5870", false);
63 test_port(":80", false);