Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/inspector/components/cookies-table.html |
| diff --git a/third_party/WebKit/LayoutTests/inspector/components/cookies-table.html b/third_party/WebKit/LayoutTests/inspector/components/cookies-table.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0ab9eea028dd98bf85d68e2a22f1d15df06e8993 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/inspector/components/cookies-table.html |
| @@ -0,0 +1,57 @@ |
| +<html> |
| +<head> |
| +<script src="../../http/tests/inspector/inspector-test.js"></script> |
| +<script type="text/javascript"> |
| + |
| +function initialize_CookiesTableTests() { |
|
dgozman
2016/12/08 19:41:20
Don't put initialize_XXX functions in a test - it'
phulce
2016/12/08 23:02:55
Done.
|
| + InspectorTest.preloadModule("components_lazy"); |
| + |
| + InspectorTest.dumpResults = function (cookies) { |
| + InspectorTest.addResult(cookies.map(x => x.name()).join(',')); |
| + }; |
| + |
| + InspectorTest.createCookie = function (data) { |
| + const cookie = new SDK.Cookie(null, data.name, data.value); |
| + for (let key in data) { |
| + if (key === 'name' || key === 'value') |
| + continue; |
| + |
| + cookie.addAttribute(key, data[key]); |
| + } |
| + return cookie; |
| + }; |
| + |
| + InspectorTest.createSortAndDumpCookies = function (cookieData, column, isAsc) { |
| + const table = new Components.CookiesTable(true); |
| + const cookies = cookieData.map(InspectorTest.createCookie); |
| + table._dataGrid = {isSortOrderAscending: () => isAsc, sortColumnId: () => column}; |
| + table._sortCookies(cookies); |
| + InspectorTest.addResult(`params: ${column} ${isAsc ? 'asc' : 'desc'}`); |
| + InspectorTest.dumpResults(cookies); |
| + }; |
| +} |
| + |
| +var test = function () { |
| + const cookieData = [ |
| + {name: 'cookieA', value: '11', path: '/zzz', domain: 'example.com'}, |
| + {name: 'cookieB', value: '2', path: '/abc', domain: '.example.com'}, |
| + {name: 'cookieC', value: 'foo', path: '/', domain: 'abc.example.com'}, |
| + {name: 'cookieD', value: '{other}', path: '/aa', domain: '.other.com'}, |
| + {name: 'cookieE', value: 'zz', path: '/gg', domain: 'z.example.com'}, |
| + {name: 'cookieF', value: 'null', path: '/', domain: 'example.com'}, |
| + ]; |
| + |
| + InspectorTest.createSortAndDumpCookies(cookieData, 'name', false); |
| + InspectorTest.createSortAndDumpCookies(cookieData, 'value', true); |
| + InspectorTest.createSortAndDumpCookies(cookieData, 'path', false); |
| + InspectorTest.createSortAndDumpCookies(cookieData, 'domain', true); |
| + InspectorTest.createSortAndDumpCookies(cookieData, null, true); |
| + InspectorTest.completeTest(); |
| +}; |
| + |
| +</script> |
| +</head> |
| +<body onload="runTest()"> |
| +<p>Tests inspector cookies table</p> |
| +</body> |
| +</html> |