| Index: third_party/WebKit/LayoutTests/http/tests/inspector-unit/product-registry-impl-name-for-url.js
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-unit/product-registry-impl-name-for-url.js b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/product-registry-impl-name-for-url.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..42d7a4adc2992d0c6020bfc783a8d8d752cbcb01
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/product-registry-impl-name-for-url.js
|
| @@ -0,0 +1,75 @@
|
| +
|
| +TestRunner.loadLazyModules(['product_registry_impl']).then(test);
|
| +function test() {
|
| + TestRunner.addResult("This tests product registry impl to ensure it gives consistant names for domains.");
|
| +
|
| + var instance = new ProductRegistryImpl.Registry();
|
| + resetProductRegistry();
|
| + addProductRegistryEntry('example.com');
|
| + addProductRegistryEntry('*.example.com');
|
| + addProductRegistryEntry('test*.example.com');
|
| + addProductRegistryEntry('test.example.com');
|
| + addProductRegistryEntry('*.test.example.com');
|
| + addProductRegistryEntry('cdn*.test.example.com');
|
| +
|
| + TestRunner.addResult("");
|
| +
|
| + logDomainEntry('example.com');
|
| + logDomainEntry('www.example.com');
|
| + logDomainEntry('www.asdf.example.com');
|
| + logDomainEntry('wwwasdf.example.com');
|
| + logDomainEntry('asdf.www.example.com');
|
| + logDomainEntry('asdf.example.com');
|
| + logDomainEntry('test.example.com');
|
| + logDomainEntry('www.test.example.com');
|
| + logDomainEntry('test-asdf.example.com');
|
| + logDomainEntry('test-1.example.com');
|
| + logDomainEntry('testTest.example.com');
|
| + logDomainEntry('www.test-1.example.com');
|
| + logDomainEntry('cdn.test.example.com');
|
| + logDomainEntry('test.cdn.test.example.com');
|
| + logDomainEntry('cdnTest.test.example.com');
|
| + logDomainEntry('test.cdn.test.example.com');
|
| + logDomainEntry('test.com');
|
| + logDomainEntry('example.org');
|
| +
|
| + TestRunner.completeTest();
|
| +
|
| + function logDomainEntry(domainStr) {
|
| + TestRunner.addResult("Testing: " + domainStr + " -> " + instance.nameForUrl(('http://' + domainStr).asParsedURL()));
|
| + }
|
| +
|
| + function resetProductRegistry() {
|
| + TestRunner.addResult("Cleared ProductRegistryImpl");
|
| + ProductRegistryImpl._productsByDomainHash.clear();
|
| + }
|
| +
|
| + /**
|
| + * @param {string} domainPattern
|
| + */
|
| + function addProductRegistryEntry(domainPattern) {
|
| + TestRunner.addResult("Adding entry: " + domainPattern);
|
| + var domain = domainPattern;
|
| + var wildCardPosition = domainPattern.indexOf('*');
|
| + var prefix = '';
|
| + if (wildCardPosition === -1) {
|
| + // If not found '' means exact match.
|
| + } else if (wildCardPosition === 0) {
|
| + prefix = '*';
|
| + console.assert(domainPattern.substr(1, 1) === '.', 'Domain pattern wildcard must be followed by \'.\'');
|
| + domain = domainPattern.substr(2); // Should always be *.example.com (note dot, so 2 chars).
|
| + } else {
|
| + prefix = domainPattern.substr(0, wildCardPosition);
|
| + console.assert(
|
| + domainPattern.substr(wildCardPosition + 1, 1) === '.', 'Domain pattern wildcard must be followed by \'.\'');
|
| + domain = domainPattern.substr(wildCardPosition + 2);
|
| + }
|
| + console.assert(domain.indexOf('*') === -1, 'Domain pattern may only have 1 wildcard.');
|
| +
|
| + var prefixes = {};
|
| + prefixes[prefix] = {product: 0};
|
| +
|
| + ProductRegistryImpl.register(
|
| + [domainPattern], [{hash: ProductRegistryImpl._hashForDomain(domain), prefixes: prefixes}]);
|
| + }
|
| +}
|
|
|