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 | var tld = Cc["@mozilla.org/network/effective-tld-service;1"] |
michael@0 | 6 | .getService(Ci.nsIEffectiveTLDService); |
michael@0 | 7 | |
michael@0 | 8 | var tests = [ |
michael@0 | 9 | { data: "bar.foo.co.uk", result: "foo.co.uk" }, |
michael@0 | 10 | { data: "foo.bar.foo.co.uk", result: "bar.foo.co.uk" }, |
michael@0 | 11 | { data: "foo.co.uk", throw: true }, |
michael@0 | 12 | { data: "co.uk", throw: true }, |
michael@0 | 13 | { data: ".co.uk", throw: true }, |
michael@0 | 14 | { data: "com", throw: true }, |
michael@0 | 15 | { data: "tûlîp.foo.fr", result: "foo.fr" }, |
michael@0 | 16 | { data: "tûlîp.fôû.fr", result: "xn--f-xgav.fr" }, |
michael@0 | 17 | { data: "file://foo/bar", throw: true }, |
michael@0 | 18 | ]; |
michael@0 | 19 | |
michael@0 | 20 | tests.forEach(function(test) { |
michael@0 | 21 | try { |
michael@0 | 22 | var r = tld.getNextSubDomain(test.data); |
michael@0 | 23 | do_check_eq(r, test.result); |
michael@0 | 24 | } catch (e) { |
michael@0 | 25 | do_check_true(test.throw); |
michael@0 | 26 | } |
michael@0 | 27 | }); |
michael@0 | 28 | } |