Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <html> | |
| 2 <head> | |
| 3 <script src="../../http/tests/inspector/inspector-test.js"></script> | |
| 4 <script type="text/javascript"> | |
| 5 | |
| 6 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.
| |
| 7 InspectorTest.preloadModule("components_lazy"); | |
| 8 | |
| 9 InspectorTest.dumpResults = function (cookies) { | |
| 10 InspectorTest.addResult(cookies.map(x => x.name()).join(',')); | |
| 11 }; | |
| 12 | |
| 13 InspectorTest.createCookie = function (data) { | |
| 14 const cookie = new SDK.Cookie(null, data.name, data.value); | |
| 15 for (let key in data) { | |
| 16 if (key === 'name' || key === 'value') | |
| 17 continue; | |
| 18 | |
| 19 cookie.addAttribute(key, data[key]); | |
| 20 } | |
| 21 return cookie; | |
| 22 }; | |
| 23 | |
| 24 InspectorTest.createSortAndDumpCookies = function (cookieData, column, isAsc) { | |
| 25 const table = new Components.CookiesTable(true); | |
| 26 const cookies = cookieData.map(InspectorTest.createCookie); | |
| 27 table._dataGrid = {isSortOrderAscending: () => isAsc, sortColumnId: () => co lumn}; | |
| 28 table._sortCookies(cookies); | |
| 29 InspectorTest.addResult(`params: ${column} ${isAsc ? 'asc' : 'desc'}`); | |
| 30 InspectorTest.dumpResults(cookies); | |
| 31 }; | |
| 32 } | |
| 33 | |
| 34 var test = function () { | |
| 35 const cookieData = [ | |
| 36 {name: 'cookieA', value: '11', path: '/zzz', domain: 'example.com'}, | |
| 37 {name: 'cookieB', value: '2', path: '/abc', domain: '.example.com'}, | |
| 38 {name: 'cookieC', value: 'foo', path: '/', domain: 'abc.example.com'}, | |
| 39 {name: 'cookieD', value: '{other}', path: '/aa', domain: '.other.com'}, | |
| 40 {name: 'cookieE', value: 'zz', path: '/gg', domain: 'z.example.com'}, | |
| 41 {name: 'cookieF', value: 'null', path: '/', domain: 'example.com'}, | |
| 42 ]; | |
| 43 | |
| 44 InspectorTest.createSortAndDumpCookies(cookieData, 'name', false); | |
| 45 InspectorTest.createSortAndDumpCookies(cookieData, 'value', true); | |
| 46 InspectorTest.createSortAndDumpCookies(cookieData, 'path', false); | |
| 47 InspectorTest.createSortAndDumpCookies(cookieData, 'domain', true); | |
| 48 InspectorTest.createSortAndDumpCookies(cookieData, null, true); | |
| 49 InspectorTest.completeTest(); | |
| 50 }; | |
| 51 | |
| 52 </script> | |
| 53 </head> | |
| 54 <body onload="runTest()"> | |
| 55 <p>Tests inspector cookies table</p> | |
| 56 </body> | |
| 57 </html> | |
| OLD | NEW |