This commit is contained in:
Masatoshi Kimura 2012-08-24 14:57:51 +01:00
Родитель b8af8f21d9
Коммит 599c8bd984
3 изменённых файлов: 68 добавлений и 39 удалений

Просмотреть файл

@ -1,78 +1,78 @@
# Any copyright is dedicated to the Public Domain. // Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/ // http://creativecommons.org/publicdomain/zero/1.0/
# NULL input. // null input.
checkPublicSuffix(NULL, NULL); checkPublicSuffix(null, null);
# Mixed case. // Mixed case.
checkPublicSuffix('COM', NULL); checkPublicSuffix('COM', null);
checkPublicSuffix('example.COM', 'example.com'); checkPublicSuffix('example.COM', 'example.com');
checkPublicSuffix('WwW.example.COM', 'example.com'); checkPublicSuffix('WwW.example.COM', 'example.com');
# Leading dot. // Leading dot.
checkPublicSuffix('.com', NULL); checkPublicSuffix('.com', null);
checkPublicSuffix('.example', NULL); checkPublicSuffix('.example', null);
checkPublicSuffix('.example.com', NULL); checkPublicSuffix('.example.com', null);
checkPublicSuffix('.example.example', NULL); checkPublicSuffix('.example.example', null);
# Unlisted TLD. // Unlisted TLD.
checkPublicSuffix('example', NULL); checkPublicSuffix('example', null);
checkPublicSuffix('example.example', 'example.example'); checkPublicSuffix('example.example', 'example.example');
checkPublicSuffix('b.example.example', 'example.example'); checkPublicSuffix('b.example.example', 'example.example');
checkPublicSuffix('a.b.example.example', 'example.example'); checkPublicSuffix('a.b.example.example', 'example.example');
# Listed, but non-Internet, TLD. // Listed, but non-Internet, TLD.
#checkPublicSuffix('local', NULL); //checkPublicSuffix('local', null);
#checkPublicSuffix('example.local', NULL); //checkPublicSuffix('example.local', null);
#checkPublicSuffix('b.example.local', NULL); //checkPublicSuffix('b.example.local', null);
#checkPublicSuffix('a.b.example.local', NULL); //checkPublicSuffix('a.b.example.local', null);
# TLD with only 1 rule. // TLD with only 1 rule.
checkPublicSuffix('biz', NULL); checkPublicSuffix('biz', null);
checkPublicSuffix('domain.biz', 'domain.biz'); checkPublicSuffix('domain.biz', 'domain.biz');
checkPublicSuffix('b.domain.biz', 'domain.biz'); checkPublicSuffix('b.domain.biz', 'domain.biz');
checkPublicSuffix('a.b.domain.biz', 'domain.biz'); checkPublicSuffix('a.b.domain.biz', 'domain.biz');
# TLD with some 2-level rules. // TLD with some 2-level rules.
checkPublicSuffix('com', NULL); checkPublicSuffix('com', null);
checkPublicSuffix('example.com', 'example.com'); checkPublicSuffix('example.com', 'example.com');
checkPublicSuffix('b.example.com', 'example.com'); checkPublicSuffix('b.example.com', 'example.com');
checkPublicSuffix('a.b.example.com', 'example.com'); checkPublicSuffix('a.b.example.com', 'example.com');
checkPublicSuffix('uk.com', NULL); checkPublicSuffix('uk.com', null);
checkPublicSuffix('example.uk.com', 'example.uk.com'); checkPublicSuffix('example.uk.com', 'example.uk.com');
checkPublicSuffix('b.example.uk.com', 'example.uk.com'); checkPublicSuffix('b.example.uk.com', 'example.uk.com');
checkPublicSuffix('a.b.example.uk.com', 'example.uk.com'); checkPublicSuffix('a.b.example.uk.com', 'example.uk.com');
checkPublicSuffix('test.ac', 'test.ac'); checkPublicSuffix('test.ac', 'test.ac');
# TLD with only 1 (wildcard) rule. // TLD with only 1 (wildcard) rule.
checkPublicSuffix('cy', NULL); checkPublicSuffix('cy', null);
checkPublicSuffix('c.cy', NULL); checkPublicSuffix('c.cy', null);
checkPublicSuffix('b.c.cy', 'b.c.cy'); checkPublicSuffix('b.c.cy', 'b.c.cy');
checkPublicSuffix('a.b.c.cy', 'b.c.cy'); checkPublicSuffix('a.b.c.cy', 'b.c.cy');
# More complex TLD. // More complex TLD.
checkPublicSuffix('jp', NULL); checkPublicSuffix('jp', null);
checkPublicSuffix('test.jp', 'test.jp'); checkPublicSuffix('test.jp', 'test.jp');
checkPublicSuffix('www.test.jp', 'test.jp'); checkPublicSuffix('www.test.jp', 'test.jp');
checkPublicSuffix('ac.jp', NULL); checkPublicSuffix('ac.jp', null);
checkPublicSuffix('test.ac.jp', 'test.ac.jp'); checkPublicSuffix('test.ac.jp', 'test.ac.jp');
checkPublicSuffix('www.test.ac.jp', 'test.ac.jp'); checkPublicSuffix('www.test.ac.jp', 'test.ac.jp');
checkPublicSuffix('kyoto.jp', NULL); checkPublicSuffix('kyoto.jp', null);
checkPublicSuffix('test.kyoto.jp', 'test.kyoto.jp'); checkPublicSuffix('test.kyoto.jp', 'test.kyoto.jp');
checkPublicSuffix('ide.kyoto.jp', NULL); checkPublicSuffix('ide.kyoto.jp', null);
checkPublicSuffix('b.ide.kyoto.jp', 'b.ide.kyoto.jp'); checkPublicSuffix('b.ide.kyoto.jp', 'b.ide.kyoto.jp');
checkPublicSuffix('a.b.ide.kyoto.jp', 'b.ide.kyoto.jp'); checkPublicSuffix('a.b.ide.kyoto.jp', 'b.ide.kyoto.jp');
checkPublicSuffix('c.kobe.jp', NULL); checkPublicSuffix('c.kobe.jp', null);
checkPublicSuffix('b.c.kobe.jp', 'b.c.kobe.jp'); checkPublicSuffix('b.c.kobe.jp', 'b.c.kobe.jp');
checkPublicSuffix('a.b.c.kobe.jp', 'b.c.kobe.jp'); checkPublicSuffix('a.b.c.kobe.jp', 'b.c.kobe.jp');
checkPublicSuffix('city.kobe.jp', 'city.kobe.jp'); checkPublicSuffix('city.kobe.jp', 'city.kobe.jp');
checkPublicSuffix('www.city.kobe.jp', 'city.kobe.jp'); checkPublicSuffix('www.city.kobe.jp', 'city.kobe.jp');
# TLD with a wildcard rule and exceptions. // TLD with a wildcard rule and exceptions.
checkPublicSuffix('om', NULL); checkPublicSuffix('om', null);
checkPublicSuffix('test.om', NULL); checkPublicSuffix('test.om', null);
checkPublicSuffix('b.test.om', 'b.test.om'); checkPublicSuffix('b.test.om', 'b.test.om');
checkPublicSuffix('a.b.test.om', 'b.test.om'); checkPublicSuffix('a.b.test.om', 'b.test.om');
checkPublicSuffix('songfest.om', 'songfest.om'); checkPublicSuffix('songfest.om', 'songfest.om');
checkPublicSuffix('www.songfest.om', 'songfest.om'); checkPublicSuffix('www.songfest.om', 'songfest.om');
# US K12. // US K12.
checkPublicSuffix('us', NULL); checkPublicSuffix('us', null);
checkPublicSuffix('test.us', 'test.us'); checkPublicSuffix('test.us', 'test.us');
checkPublicSuffix('www.test.us', 'test.us'); checkPublicSuffix('www.test.us', 'test.us');
checkPublicSuffix('ak.us', NULL); checkPublicSuffix('ak.us', null);
checkPublicSuffix('test.ak.us', 'test.ak.us'); checkPublicSuffix('test.ak.us', 'test.ak.us');
checkPublicSuffix('www.test.ak.us', 'test.ak.us'); checkPublicSuffix('www.test.ak.us', 'test.ak.us');
checkPublicSuffix('k12.ak.us', NULL); checkPublicSuffix('k12.ak.us', null);
checkPublicSuffix('test.k12.ak.us', 'test.k12.ak.us'); checkPublicSuffix('test.k12.ak.us', 'test.k12.ak.us');
checkPublicSuffix('www.test.k12.ak.us', 'test.k12.ak.us'); checkPublicSuffix('www.test.k12.ak.us', 'test.k12.ak.us');

Просмотреть файл

@ -0,0 +1,28 @@
const Cc = Components.classes;
const Ci = Components.interfaces;
var etld = Cc["@mozilla.org/network/effective-tld-service;1"]
.getService(Ci.nsIEffectiveTLDService);
function run_test()
{
var file = do_get_file("data/test_psl.txt");
var ios = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
var uri = ios.newFileURI(file);
var scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader);
var srvScope = {};
scriptLoader.loadSubScript(uri.spec, srvScope);
}
function checkPublicSuffix(host, expectedSuffix)
{
var actualSuffix = null;
try {
actualSuffix = etld.getBaseDomainFromHost(host);
} catch (e if e.name == "NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS" ||
e.name == "NS_ERROR_ILLEGAL_VALUE") {
}
do_check_eq(actualSuffix, expectedSuffix);
}

Просмотреть файл

@ -160,6 +160,7 @@ skip-if = os == "win"
[test_proxy-failover_passing.js] [test_proxy-failover_passing.js]
[test_proxy-replace_canceled.js] [test_proxy-replace_canceled.js]
[test_proxy-replace_passing.js] [test_proxy-replace_passing.js]
[test_psl.js]
[test_range_requests.js] [test_range_requests.js]
[test_readline.js] [test_readline.js]
[test_redirect-caching_canceled.js] [test_redirect-caching_canceled.js]