| OLD | NEW |
| (Empty) | |
| 1 |
| 2 TestRunner.loadLazyModules(['product_registry_impl']).then(test); |
| 3 function test() { |
| 4 TestRunner.addResult("This tests product registry impl's register function."); |
| 5 |
| 6 resetProductRegistry(); |
| 7 ProductRegistryImpl.register([ |
| 8 "example.(com|org)", |
| 9 "*.example.com", |
| 10 "test-*.example.com", |
| 11 "subdomain.example.com" |
| 12 ], [ |
| 13 { |
| 14 hash: "0caaf24ab1a0c334", // Result of: sha1('example.com').substr(0, 16). |
| 15 prefixes: { |
| 16 "": { |
| 17 product: 0 // Reference to index of first argument of ProductRegistryI
mpl.register. |
| 18 }, |
| 19 "*": { |
| 20 product: 1 |
| 21 }, |
| 22 "test-": { |
| 23 product: 2 |
| 24 } |
| 25 } |
| 26 }, |
| 27 { |
| 28 hash: "20116dfd6774a9e7", // Result of: sha1('example.org').substr(0, 16). |
| 29 prefixes: { |
| 30 "": { |
| 31 product: 0 |
| 32 } |
| 33 } |
| 34 }, |
| 35 { |
| 36 hash: "e3d90251f85e2064", // Result of: sha1('subdomain.example.com').subs
tr(0, 16). |
| 37 prefixes: { |
| 38 "": { |
| 39 product: 3 |
| 40 } |
| 41 } |
| 42 } |
| 43 ]); |
| 44 var instance = new ProductRegistryImpl.Registry(); |
| 45 |
| 46 logDomainEntry('example.com'); |
| 47 logDomainEntry('wild.example.com'); |
| 48 logDomainEntry('test-1.example.com'); |
| 49 logDomainEntry('subdomain.example.com'); |
| 50 logDomainEntry('example.org'); |
| 51 logDomainEntry('chromium.org'); |
| 52 |
| 53 TestRunner.completeTest(); |
| 54 |
| 55 function logDomainEntry(domainStr) { |
| 56 TestRunner.addResult("Testing: " + domainStr + " -> " + instance.nameForUrl(
('http://' + domainStr).asParsedURL())); |
| 57 } |
| 58 |
| 59 function resetProductRegistry() { |
| 60 TestRunner.addResult("Cleared ProductRegistryImpl"); |
| 61 ProductRegistryImpl._productsByDomainHash.clear(); |
| 62 } |
| 63 } |
| OLD | NEW |