| 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 // This file contains the tests for detecting extension's ad injection in | 5 // This file contains the tests for detecting extension's ad injection in |
| 6 // Chrome. This contains many different, independent tests, but it is all run | 6 // Chrome. This contains many different, independent tests, but it is all run |
| 7 // as a "single" browser test. The reason for this is that we want to do many | 7 // as a "single" browser test. The reason for this is that we want to do many |
| 8 // short tests for ad injection, and the set-up/tear-down time for a browsertest | 8 // short tests for ad injection, and the set-up/tear-down time for a browsertest |
| 9 // implementation of each would be prohibitive. | 9 // implementation of each would be prohibitive. |
| 10 // See also chrome/browser/extensions/activity_log/ad_injection_browsertest.cc | 10 // See also chrome/browser/extensions/activity_log/ad_injection_browsertest.cc |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 * - Signal that the test is done, and we should check for the result. | 48 * - Signal that the test is done, and we should check for the result. |
| 49 * | 49 * |
| 50 * This cycle repeats, and should be done synchronously so that we don't end up | 50 * This cycle repeats, and should be done synchronously so that we don't end up |
| 51 * recording events which we shouldn't, and can attribute each event to its | 51 * recording events which we shouldn't, and can attribute each event to its |
| 52 * cause. | 52 * cause. |
| 53 * @constructor | 53 * @constructor |
| 54 */ | 54 */ |
| 55 function AdInjectorTest(functions) { | 55 function AdInjectorTest(functions) { |
| 56 /* | 56 /* |
| 57 * The list of functions to run in order to test ad injection. | 57 * The list of functions to run in order to test ad injection. |
| 58 * @type {Array.<Function>} | 58 * @type {Array<Function>} |
| 59 * @private | 59 * @private |
| 60 */ | 60 */ |
| 61 this.functions_ = functions; | 61 this.functions_ = functions; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 AdInjectorTest.prototype = { | 64 AdInjectorTest.prototype = { |
| 65 /** | 65 /** |
| 66 * The index of the function that is next in line. | 66 * The index of the function that is next in line. |
| 67 * @type {int} | 67 * @type {int} |
| 68 * @private | 68 * @private |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 var getNestedAd = function() { | 223 var getNestedAd = function() { |
| 224 return kNestedAdTemplate.cloneNode(true); | 224 return kNestedAdTemplate.cloneNode(true); |
| 225 }; | 225 }; |
| 226 | 226 |
| 227 /* | 227 /* |
| 228 * The collection of functions to use for testing. | 228 * The collection of functions to use for testing. |
| 229 * In order to add a new test, simply append it to the collection of functions. | 229 * In order to add a new test, simply append it to the collection of functions. |
| 230 * All functions will be run in the test, and each will report its success or | 230 * All functions will be run in the test, and each will report its success or |
| 231 * failure independently of the others. | 231 * failure independently of the others. |
| 232 * All test functions must be synchronous. | 232 * All test functions must be synchronous. |
| 233 * @type {Array.<Function>} | 233 * @type {Array<Function>} |
| 234 */ | 234 */ |
| 235 var functions = []; | 235 var functions = []; |
| 236 | 236 |
| 237 // Add a bunch of elements, but nothing that looks like ad injection (no | 237 // Add a bunch of elements, but nothing that looks like ad injection (no |
| 238 // elements with an external source, no modifying existing sources). | 238 // elements with an external source, no modifying existing sources). |
| 239 functions.push(function NoAdInjection() { | 239 functions.push(function NoAdInjection() { |
| 240 var div = document.createElement('div'); | 240 var div = document.createElement('div'); |
| 241 var iframe = document.createElement('iframe'); | 241 var iframe = document.createElement('iframe'); |
| 242 var anchor = document.createElement('anchor'); | 242 var anchor = document.createElement('anchor'); |
| 243 var span = document.createElement('span'); | 243 var span = document.createElement('span'); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 eval(code); | 393 eval(code); |
| 394 return INJECTION_NEW_AD; | 394 return INJECTION_NEW_AD; |
| 395 }); | 395 }); |
| 396 | 396 |
| 397 // TODO(rdevlin.cronin): We are not covering every case yet. Fix this. | 397 // TODO(rdevlin.cronin): We are not covering every case yet. Fix this. |
| 398 // See crbug.com/357204. | 398 // See crbug.com/357204. |
| 399 | 399 |
| 400 // Kick off the tests. | 400 // Kick off the tests. |
| 401 var test = new AdInjectorTest(functions); | 401 var test = new AdInjectorTest(functions); |
| 402 test.runNextFunction(); | 402 test.runNextFunction(); |
| OLD | NEW |