| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Include test fixture. | 5 // Include test fixture. |
| 6 GEN_INCLUDE(['net_internals_test.js']); | 6 GEN_INCLUDE(['net_internals_test.js']); |
| 7 | 7 |
| 8 // Anonymous namespace | 8 // Anonymous namespace |
| 9 (function() { | 9 (function() { |
| 10 | 10 |
| 11 // Path to the page containing iframe. Iframe is used to load sdch-related | 11 // Path to the page containing iframe. Iframe is used to load sdch-related |
| 12 // content from the different origin. Otherwise favicon requests for the main | 12 // content from the different origin. Otherwise favicon requests for the main |
| 13 // page domain would spoil SDCH blacklists counters making test behavior hardly | 13 // page domain would spoil SDCH blacklists counters making test behavior hardly |
| 14 // predicatble. | 14 // predicatble. |
| 15 var BASE_PATH = 'files/sdch/base-page.html?iframe_url='; | 15 var BASE_PATH = '/sdch/base-page.html?iframe_url='; |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * Checks the display on the SDCH tab against the information it should be | 18 * Checks the display on the SDCH tab against the information it should be |
| 19 * displaying. | 19 * displaying. |
| 20 * @param {object} sdchInfo Results from a sdch manager info query. | 20 * @param {object} sdchInfo Results from a sdch manager info query. |
| 21 */ | 21 */ |
| 22 function checkDisplay(sdchInfo) { | 22 function checkDisplay(sdchInfo) { |
| 23 expectEquals(sdchInfo.sdch_enabled, | 23 expectEquals(sdchInfo.sdch_enabled, |
| 24 $(SdchView.SDCH_ENABLED_SPAN_ID).innerText === 'true'); | 24 $(SdchView.SDCH_ENABLED_SPAN_ID).innerText === 'true'); |
| 25 NetInternalsTest.checkTbodyRows(SdchView.BLACKLIST_TBODY_ID, | 25 NetInternalsTest.checkTbodyRows(SdchView.BLACKLIST_TBODY_ID, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 if (sdchInfo.dictionaries.length > 0) { | 93 if (sdchInfo.dictionaries.length > 0) { |
| 94 var testDict = sdchInfo.dictionaries.filter(function(dictionary) { | 94 var testDict = sdchInfo.dictionaries.filter(function(dictionary) { |
| 95 return dictionary.domain === 'sub.testdomain.com'; | 95 return dictionary.domain === 'sub.testdomain.com'; |
| 96 }); | 96 }); |
| 97 if (testDict.length === 0) | 97 if (testDict.length === 0) |
| 98 return; | 98 return; |
| 99 | 99 |
| 100 expectEquals(1, testDict.length); | 100 expectEquals(1, testDict.length); |
| 101 var dict = testDict[0]; | 101 var dict = testDict[0]; |
| 102 expectEquals('/', dict.path); | 102 expectEquals('/', dict.path); |
| 103 expectTrue(dict.url.indexOf('/files/sdch/dict') !== -1); | 103 expectTrue(dict.url.indexOf('/sdch/dict') !== -1); |
| 104 | 104 |
| 105 var tableId = SdchView.DICTIONARIES_TBODY_ID; | 105 var tableId = SdchView.DICTIONARIES_TBODY_ID; |
| 106 var domain = NetInternalsTest.getTbodyText(tableId, 0, 0); | 106 var domain = NetInternalsTest.getTbodyText(tableId, 0, 0); |
| 107 var path = NetInternalsTest.getTbodyText(tableId, 0, 1); | 107 var path = NetInternalsTest.getTbodyText(tableId, 0, 1); |
| 108 var url = NetInternalsTest.getTbodyText(tableId, 0, 5); | 108 var url = NetInternalsTest.getTbodyText(tableId, 0, 5); |
| 109 | 109 |
| 110 expectEquals(dict.domain, domain); | 110 expectEquals(dict.domain, domain); |
| 111 expectEquals(dict.path, path); | 111 expectEquals(dict.path, path); |
| 112 expectEquals(dict.url, url); | 112 expectEquals(dict.url, url); |
| 113 | 113 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 /** | 177 /** |
| 178 * Load a page, which results in downloading a SDCH dictionary. Make sure its | 178 * Load a page, which results in downloading a SDCH dictionary. Make sure its |
| 179 * data is displayed. | 179 * data is displayed. |
| 180 */ | 180 */ |
| 181 TEST_F('NetInternalsTest', 'netInternalsSdchViewFetchDictionary', function() { | 181 TEST_F('NetInternalsTest', 'netInternalsSdchViewFetchDictionary', function() { |
| 182 var taskQueue = new NetInternalsTest.TaskQueue(true); | 182 var taskQueue = new NetInternalsTest.TaskQueue(true); |
| 183 taskQueue.addTask( | 183 taskQueue.addTask( |
| 184 new NetInternalsTest.GetTestServerURLTask( | 184 new NetInternalsTest.GetTestServerURLTask( |
| 185 BASE_PATH + encodeURI('/files/sdch/page.html'))); | 185 BASE_PATH + encodeURI('/sdch/page.html'))); |
| 186 taskQueue.addTask(new LoadSdchDictionaryTask()); | 186 taskQueue.addTask(new LoadSdchDictionaryTask()); |
| 187 taskQueue.run(); | 187 taskQueue.run(); |
| 188 }); | 188 }); |
| 189 | 189 |
| 190 /** | 190 /** |
| 191 * Load a page, get the dictionary for it, and get decoding error to see | 191 * Load a page, get the dictionary for it, and get decoding error to see |
| 192 * the blacklist in action. | 192 * the blacklist in action. |
| 193 */ | 193 */ |
| 194 TEST_F('NetInternalsTest', 'netInternalsSdchViewBlacklistMeta', function() { | 194 TEST_F('NetInternalsTest', 'netInternalsSdchViewBlacklistMeta', function() { |
| 195 var taskQueue = new NetInternalsTest.TaskQueue(true); | 195 var taskQueue = new NetInternalsTest.TaskQueue(true); |
| 196 taskQueue.addTask( | 196 taskQueue.addTask( |
| 197 new NetInternalsTest.GetTestServerURLTask( | 197 new NetInternalsTest.GetTestServerURLTask( |
| 198 BASE_PATH + encodeURI('/files/sdch/page.html'))); | 198 BASE_PATH + encodeURI('/sdch/page.html'))); |
| 199 taskQueue.addTask(new LoadSdchDictionaryTask()); | 199 taskQueue.addTask(new LoadSdchDictionaryTask()); |
| 200 taskQueue.addTask( | 200 taskQueue.addTask( |
| 201 new NetInternalsTest.GetTestServerURLTask( | 201 new NetInternalsTest.GetTestServerURLTask( |
| 202 BASE_PATH + encodeURI('/files/sdch/non-html'))); | 202 BASE_PATH + encodeURI('/sdch/non-html'))); |
| 203 taskQueue.addTask( | 203 taskQueue.addTask( |
| 204 new LoadPageWithDecodeErrorTask('META_REFRESH_UNSUPPORTED')); | 204 new LoadPageWithDecodeErrorTask('META_REFRESH_UNSUPPORTED')); |
| 205 taskQueue.run(); | 205 taskQueue.run(); |
| 206 }); | 206 }); |
| 207 | 207 |
| 208 /** | 208 /** |
| 209 * Load a page, which is said to be SDCH-encoded, though we don't expect it. | 209 * Load a page, which is said to be SDCH-encoded, though we don't expect it. |
| 210 */ | 210 */ |
| 211 TEST_F('NetInternalsTest', 'netInternalsSdchViewBlacklistNonSdch', function() { | 211 TEST_F('NetInternalsTest', 'netInternalsSdchViewBlacklistNonSdch', function() { |
| 212 var taskQueue = new NetInternalsTest.TaskQueue(true); | 212 var taskQueue = new NetInternalsTest.TaskQueue(true); |
| 213 taskQueue.addTask( | 213 taskQueue.addTask( |
| 214 new NetInternalsTest.GetTestServerURLTask( | 214 new NetInternalsTest.GetTestServerURLTask( |
| 215 BASE_PATH + encodeURI('/files/sdch/non-sdch.html'))); | 215 BASE_PATH + encodeURI('/sdch/non-sdch.html'))); |
| 216 taskQueue.addTask( | 216 taskQueue.addTask( |
| 217 new LoadPageWithDecodeErrorTask('PASSING_THROUGH_NON_SDCH')); | 217 new LoadPageWithDecodeErrorTask('PASSING_THROUGH_NON_SDCH')); |
| 218 taskQueue.run(); | 218 taskQueue.run(); |
| 219 }); | 219 }); |
| 220 | 220 |
| 221 })(); // Anonymous namespace | 221 })(); // Anonymous namespace |
| OLD | NEW |