Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | var Cc = Components.classes; |
michael@0 | 2 | var Ci = Components.interfaces; |
michael@0 | 3 | |
michael@0 | 4 | function run_test() { |
michael@0 | 5 | function makeURI(aURLSpec, aCharset) { |
michael@0 | 6 | var ios = Cc["@mozilla.org/network/io-service;1"]. |
michael@0 | 7 | getService(Ci.nsIIOService); |
michael@0 | 8 | return ios.newURI(aURLSpec, aCharset, null); |
michael@0 | 9 | } |
michael@0 | 10 | |
michael@0 | 11 | var httpURI = makeURI("http://foo.com"); |
michael@0 | 12 | do_check_eq(-1, httpURI.port); |
michael@0 | 13 | |
michael@0 | 14 | // Setting to default shouldn't cause a change |
michael@0 | 15 | httpURI.port = 80; |
michael@0 | 16 | do_check_eq(-1, httpURI.port); |
michael@0 | 17 | |
michael@0 | 18 | // Setting to default after setting to non-default shouldn't cause a change (bug 403480) |
michael@0 | 19 | httpURI.port = 123; |
michael@0 | 20 | do_check_eq(123, httpURI.port); |
michael@0 | 21 | httpURI.port = 80; |
michael@0 | 22 | do_check_eq(-1, httpURI.port); |
michael@0 | 23 | do_check_false(/80/.test(httpURI.spec)); |
michael@0 | 24 | |
michael@0 | 25 | // URL parsers shouldn't set ports to default value (bug 407538) |
michael@0 | 26 | httpURI.spec = "http://foo.com:81"; |
michael@0 | 27 | do_check_eq(81, httpURI.port); |
michael@0 | 28 | httpURI.spec = "http://foo.com:80"; |
michael@0 | 29 | do_check_eq(-1, httpURI.port); |
michael@0 | 30 | do_check_false(/80/.test(httpURI.spec)); |
michael@0 | 31 | |
michael@0 | 32 | httpURI = makeURI("http://foo.com"); |
michael@0 | 33 | do_check_eq(-1, httpURI.port); |
michael@0 | 34 | do_check_false(/80/.test(httpURI.spec)); |
michael@0 | 35 | |
michael@0 | 36 | httpURI = makeURI("http://foo.com:80"); |
michael@0 | 37 | do_check_eq(-1, httpURI.port); |
michael@0 | 38 | do_check_false(/80/.test(httpURI.spec)); |
michael@0 | 39 | |
michael@0 | 40 | httpURI = makeURI("http://foo.com:80"); |
michael@0 | 41 | do_check_eq(-1, httpURI.port); |
michael@0 | 42 | do_check_false(/80/.test(httpURI.spec)); |
michael@0 | 43 | |
michael@0 | 44 | httpURI = makeURI("https://foo.com"); |
michael@0 | 45 | do_check_eq(-1, httpURI.port); |
michael@0 | 46 | do_check_false(/443/.test(httpURI.spec)); |
michael@0 | 47 | |
michael@0 | 48 | httpURI = makeURI("https://foo.com:443"); |
michael@0 | 49 | do_check_eq(-1, httpURI.port); |
michael@0 | 50 | do_check_false(/443/.test(httpURI.spec)); |
michael@0 | 51 | |
michael@0 | 52 | // XXX URL parsers shouldn't set ports to default value, even when changing scheme? |
michael@0 | 53 | // not really possible given current nsIURI impls |
michael@0 | 54 | //httpURI.spec = "https://foo.com:443"; |
michael@0 | 55 | //do_check_eq(-1, httpURI.port); |
michael@0 | 56 | } |