Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/inspector-unit/product-registry-impl-name-for-url.js

Issue 2869233002: [Devtools] Added product registry domain pattern test
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector-unit/product-registry-impl-name-for-url-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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}]);
+ }
+}
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector-unit/product-registry-impl-name-for-url-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698