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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 document.body.appendChild(getAnchorAd()); | 302 document.body.appendChild(getAnchorAd()); |
303 return INJECTION_NEW_AD; | 303 return INJECTION_NEW_AD; |
304 }); | 304 }); |
305 | 305 |
306 functions.push(function NewAnchorLikelyAd() { | 306 functions.push(function NewAnchorLikelyAd() { |
307 var anchor = document.createElement('a'); | 307 var anchor = document.createElement('a'); |
308 document.body.appendChild(anchor).href = kMaybeAdNetwork; | 308 document.body.appendChild(anchor).href = kMaybeAdNetwork; |
309 return INJECTION_LIKELY_NEW_AD; | 309 return INJECTION_LIKELY_NEW_AD; |
310 }); | 310 }); |
311 | 311 |
| 312 // Test that an extension adding an element is not considered likely ad |
| 313 // injection if the element has a local resource. |
| 314 functions.push(function LocalResourceNotConsideredAd() { |
| 315 var anchor = document.createElement('a'); |
| 316 document.body.appendChild(anchor).href = chrome.extension.getURL('foo.html'); |
| 317 return NO_AD_INJECTION; |
| 318 }); |
| 319 |
| 320 // Test that an extension adding an element with the same host as the current |
| 321 // page is not considered ad injection. |
| 322 functions.push(function SamePageUrlNotConsideredAd() { |
| 323 var anchor = document.createElement('a'); |
| 324 // This source is something like 'http://127.0.0.1:49725/foo.html'. |
| 325 document.body.appendChild(anchor).href = document.URL + 'foo.html'; |
| 326 return NO_AD_INJECTION; |
| 327 }); |
| 328 |
| 329 |
312 functions.push(function ModifyExistingAnchorToAdNetwork() { | 330 functions.push(function ModifyExistingAnchorToAdNetwork() { |
313 var anchor = $('non-ad-anchor'); | 331 var anchor = $('non-ad-anchor'); |
314 anchor.href = kAdNetwork; | 332 anchor.href = kAdNetwork; |
315 return INJECTION_NEW_AD; | 333 return INJECTION_NEW_AD; |
316 }); | 334 }); |
317 | 335 |
318 // Add a new element which has a nested ad, to ensure we do a deep check of | 336 // Add a new element which has a nested ad, to ensure we do a deep check of |
319 // elements appended to the dom. | 337 // elements appended to the dom. |
320 functions.push(function NewNestedAd() { | 338 functions.push(function NewNestedAd() { |
321 document.body.appendChild(getNestedAd()); | 339 document.body.appendChild(getNestedAd()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 }); | 384 }); |
367 return NO_AD_INJECTION; | 385 return NO_AD_INJECTION; |
368 }); | 386 }); |
369 | 387 |
370 // TODO(rdevlin.cronin): We are not covering every case yet. Fix this. | 388 // TODO(rdevlin.cronin): We are not covering every case yet. Fix this. |
371 // See crbug.com/357204. | 389 // See crbug.com/357204. |
372 | 390 |
373 // Kick off the tests. | 391 // Kick off the tests. |
374 var test = new AdInjectorTest(functions); | 392 var test = new AdInjectorTest(functions); |
375 test.runNextFunction(); | 393 test.runNextFunction(); |
OLD | NEW |