| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 // Filters used alone and in all combinations. | 147 // Filters used alone and in all combinations. |
| 148 // |text| is the string to add to the filter. | 148 // |text| is the string to add to the filter. |
| 149 // |matches| is a 2-element array of booleans indicating which of the two | 149 // |matches| is a 2-element array of booleans indicating which of the two |
| 150 // requests passes the filter. | 150 // requests passes the filter. |
| 151 var testFilters = [ | 151 var testFilters = [ |
| 152 {text: 'http://www.google.com', matches: [true, true] }, | 152 {text: 'http://www.google.com', matches: [true, true] }, |
| 153 {text: 'MyMagicPony', matches: [false, false] }, | 153 {text: 'MyMagicPony', matches: [false, false] }, |
| 154 {text: 'type:URL_REQUEST', matches: [true, true] }, | 154 {text: 'type:URL_REQUEST', matches: [true, true] }, |
| 155 {text: 'type:SOCKET,URL_REQUEST', matches: [true, true] }, | 155 {text: 'type:SOCKET,URL_REQUEST', matches: [true, true] }, |
| 156 {text: 'type:SOCKET', matches: [false, false] }, | 156 {text: 'type:SOCKET', matches: [false, false] }, |
| 157 {text: '-type:PONY', matches: [true, true] }, |
| 158 {text: '-type:URL_REQUEST', matches: [false, false] }, |
| 157 {text: 'id:31,32', matches: [true, false] }, | 159 {text: 'id:31,32', matches: [true, false] }, |
| 160 {text: '-id:31,32', matches: [false, true] }, |
| 158 {text: 'id:32,56,', matches: [false, true] }, | 161 {text: 'id:32,56,', matches: [false, true] }, |
| 159 {text: 'is:-active', matches: [true, false] }, | 162 {text: '-is:active', matches: [true, false] }, |
| 160 {text: 'is:active', matches: [false, true] }, | 163 {text: 'is:active', matches: [false, true] }, |
| 161 {text: 'is:-error', matches: [true, true] }, | 164 {text: '-is:error', matches: [true, true] }, |
| 162 {text: 'is:error', matches: [false, false] }, | 165 {text: 'is:error', matches: [false, false] }, |
| 163 // Partial match of source type. | 166 // Partial match of source type. |
| 164 {text: 'URL_REQ', matches: [true, true] }, | 167 {text: 'URL_REQ', matches: [true, true] }, |
| 165 // Partial match of event type type. | 168 // Partial match of event type type. |
| 166 {text: 'SEND_REQUEST', matches: [true, false] }, | 169 {text: 'SEND_REQUEST', matches: [true, false] }, |
| 167 // Check that ":" works in strings. | 170 // Check that ":" works in strings. |
| 168 { text: 'Host:', matches: [true, false] }, | 171 { text: 'Host:', matches: [true, false] }, |
| 169 { text: '::', matches: [false, false] }, | 172 { text: '::', matches: [false, false] }, |
| 170 // Test quotes. | 173 // Test quotes. |
| 171 { text: '"Quoted String"', matches: [true, false] }, | 174 { text: '"Quoted String"', matches: [true, false] }, |
| 172 { text: '"Quoted source"', matches: [false, false] }, | 175 { text: '"Quoted source"', matches: [false, false] }, |
| 173 { text: '"\\"Quoted String\\""', matches: [true, false] }, | 176 { text: '"\\"Quoted String\\""', matches: [true, false] }, |
| 174 { text: '"\\"\\"Quoted String\\""', matches: [false, false] }, | 177 { text: '"\\"\\"Quoted String\\""', matches: [false, false] }, |
| 175 { text: '\\"\\"\\"', matches: [true, false] }, | 178 { text: '\\"\\"\\"', matches: [true, false] }, |
| 176 { text: '\\"\\"\\"\\"', matches: [false, false] }, | 179 { text: '\\"\\"\\"\\"', matches: [false, false] }, |
| 177 { text: '"Host: www.google.com"', matches: [true, false], }, | 180 { text: '"Host: www.google.com"', matches: [true, false], }, |
| 178 { text: 'Connection:" keep-alive"', matches: [true, false], }, | 181 { text: 'Connection:" keep-alive"', matches: [true, false], }, |
| 182 { text: '-Connection:" keep-alive"', matches: [false, true], }, |
| 179 { text: '"Host: GET"', matches: [false, false] }, | 183 { text: '"Host: GET"', matches: [false, false] }, |
| 180 // Make sure sorting has no effect on filters. Sort by ID so order is | 184 // Make sure sorting has no effect on filters. Sort by ID so order is |
| 181 // preserved. | 185 // preserved. |
| 182 { text: 'sort:"id"', matches: [true, true] }, | 186 { text: 'sort:"id"', matches: [true, true] }, |
| 183 // Sorting by unrecognized methods should do a text match. | 187 { text: '-sort:"shoe size"', matches: [true, true] }, |
| 184 { text: 'sort:"shoe size"', matches: [false, false] }, | 188 { text: '"-sort:shoe size"', matches: [false, false] }, |
| 185 ]; | 189 ]; |
| 186 | 190 |
| 187 for (var filter1 = 0; filter1 < testFilters.length; ++filter1) { | 191 for (var filter1 = 0; filter1 < testFilters.length; ++filter1) { |
| 188 checkFilter(testFilters[filter1].text, testFilters[filter1].matches); | 192 checkFilter(testFilters[filter1].text, testFilters[filter1].matches); |
| 189 // Check |filter1| in combination with all the other filters. | 193 // Check |filter1| in combination with all the other filters. |
| 190 for (var filter2 = 0; filter2 < testFilters.length; ++filter2) { | 194 for (var filter2 = 0; filter2 < testFilters.length; ++filter2) { |
| 191 var matches = []; | 195 var matches = []; |
| 192 for (var i = 0; i < testFilters[filter1].matches.length; ++i) { | 196 for (var i = 0; i < testFilters[filter1].matches.length; ++i) { |
| 193 // The merged filter matches an entry if both individual filters do. | 197 // The merged filter matches an entry if both individual filters do. |
| 194 matches[i] = testFilters[filter1].matches[i] && | 198 matches[i] = testFilters[filter1].matches[i] && |
| (...skipping 11 matching lines...) Expand all Loading... |
| 206 checkFilter('"Quoted String', [true, false]); | 210 checkFilter('"Quoted String', [true, false]); |
| 207 checkFilter('"Quoted String source', [false, false]); | 211 checkFilter('"Quoted String source', [false, false]); |
| 208 checkFilter('Quoted" String', [true, false]); | 212 checkFilter('Quoted" String', [true, false]); |
| 209 checkFilter('Quoted" source', [false, false]); | 213 checkFilter('Quoted" source', [false, false]); |
| 210 checkFilter('Quoted "String', [true, false]); | 214 checkFilter('Quoted "String', [true, false]); |
| 211 | 215 |
| 212 testDone(); | 216 testDone(); |
| 213 }); | 217 }); |
| 214 | 218 |
| 215 })(); // Anonymous namespace | 219 })(); // Anonymous namespace |
| OLD | NEW |