Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: chrome/test/data/extensions/activity_log/ad_injection/content_script.js

Issue 384983003: Enabling AdInjectionBrowserTest after Activity Log refactoring. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments & unit tests Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/activity_log/ad_injection/content_script.js
diff --git a/chrome/test/data/extensions/activity_log/ad_injection/content_script.js b/chrome/test/data/extensions/activity_log/ad_injection/content_script.js
index 12ce7889af1ba2022f208903c79c9c59c34fa157..4d1af4c79a54e021389e6ef946917273119928fa 100644
--- a/chrome/test/data/extensions/activity_log/ad_injection/content_script.js
+++ b/chrome/test/data/extensions/activity_log/ad_injection/content_script.js
@@ -31,8 +31,6 @@
var kBodyHtml =
'<iframe id="ad-iframe" src="http://www.known-ads.adnetwork"></iframe>' +
'<iframe id="non-ad-iframe" src="http://www.not-ads.adnetwork"></iframe>' +
- '<embed id="ad-embed" src="http://www.known-ads.adnetwork"><embed>' +
- '<embed id="non-ad-embed" src="http://www.not-ads.adnetwork"><embed>' +
'<a id="ad-anchor" href="http://www.known-ads.adnetwork"></a>' +
'<a id="non-ad-anchor" href="http://www.not-ads.adnetwork"></a>' +
'<div id="empty-div"></div>';
@@ -43,8 +41,8 @@ var kBodyHtml =
* - Signal the C++ test that we're going to do page setup, and we shouldn't
* record any ad-injector events (as some of the page setup could qualify).
* - Do the page setup, which involves creating a 'playground' for ad injectors
- * of iframes, embeds, etc. See also ad_injectors.html. We do this set up for
- * each test, so that none of the tests conflicts with each other.
+ * of iframes, etc. See also ad_injectors.html. We do this set up for each
+ * test, so that none of the tests conflicts with each other.
* - Signal that we are done with page setup, and should start recording events.
* - Run the next test.
* - Signal that the test is done, and we should check for the result.
@@ -180,18 +178,6 @@ var getIframeAd = function() {
return kIframeAdTemplate.cloneNode(true);
};
-// Creates an embed ad, like so:
-// <embed src="http://www.known-ads.adnetwork"></embed>
-var kEmbedAdTemplate = document.createElement('embed');
-kEmbedAdTemplate.src = kAdNetwork;
-
-/**
- * @return An embed element which will count as ad injection in the tests.
- */
-var getEmbedAd = function() {
- return kEmbedAdTemplate.cloneNode(true);
-};
-
// Creates an anchor ad, like so:
// <a href="http://www.known-ads.adnetwork"></a>
var kAnchorAdTemplate = document.createElement('a');
@@ -241,12 +227,10 @@ var functions = [];
functions.push(function NoAdInjection() {
var div = document.createElement('div');
var iframe = document.createElement('iframe');
- var embed = document.createElement('embed');
var anchor = document.createElement('anchor');
var span = document.createElement('span');
span.textContent = 'Hello, world';
div.appendChild(iframe);
- div.appendChild(embed);
div.appendChild(anchor);
div.appendChild(span);
document.body.appendChild(div);
@@ -269,31 +253,15 @@ functions.push(function NewIframeLikelyAdNetwork() {
// Modify an iframe which is currently in the DOM, switching the src to an
// ad network.
-functions.push(function ModifyExistingIframeToAdNetwork() {
+functions.push(function ModifyExistingIframeToAdNetwork1() {
var frame = $('non-ad-iframe');
frame.src = kAdNetwork;
return INJECTION_NEW_AD;
});
-// Add a new embed element which serves ads.
-functions.push(function NewEmbedAdNetwork() {
- document.body.appendChild(getEmbedAd());
- return INJECTION_NEW_AD;
-});
-
-// Add a new embed element which does not serve ads. We should not record
-// anything.
-functions.push(function NewEmbedLikelyAdNetwork() {
- var embed = document.createElement('embed');
- document.body.appendChild(embed).src = kMaybeAdNetwork;
- return INJECTION_LIKELY_NEW_AD;
-});
-
-// Modify an embed which is currently in the DOM, switching the src to an
-// ad network.
-functions.push(function ModifyExistingEmbedToAdNetwork() {
- var embed = $('non-ad-embed');
- embed.src = kAdNetwork;
+functions.push(function ModifyExistingIframeToAdNetwork2() {
+ var frame = $('non-ad-iframe');
+ frame.setAttribute('src', kAdNetwork);
return INJECTION_NEW_AD;
});
@@ -326,13 +294,18 @@ functions.push(function SamePageUrlNotConsideredAd() {
return NO_AD_INJECTION;
});
-
-functions.push(function ModifyExistingAnchorToAdNetwork() {
+functions.push(function ModifyExistingAnchorToAdNetwork1() {
var anchor = $('non-ad-anchor');
anchor.href = kAdNetwork;
return INJECTION_NEW_AD;
});
+functions.push(function ModifyExistingAnchorToAdNetwork2() {
+ var anchor = $('non-ad-anchor');
+ anchor.setAttribute('href', kAdNetwork);
+ return INJECTION_NEW_AD;
+});
+
// Add a new element which has a nested ad, to ensure we do a deep check of
// elements appended to the dom.
functions.push(function NewNestedAd() {
@@ -340,38 +313,26 @@ functions.push(function NewNestedAd() {
return INJECTION_NEW_AD;
});
-// Switch an existing embed ad to a new ad network.
-functions.push(function ReplaceEmbedAd() {
- $('ad-embed').src = kAdNetwork2;
+// Switch an existing iframe ad to a new ad network.
+functions.push(function ReplaceIframeAd1() {
+ $('ad-iframe').src = kAdNetwork2;
return INJECTION_REPLACED_AD;
});
-// Switch an existing iframe ad to a new ad network.
-functions.push(function ReplaceIframeAd() {
- $('ad-iframe').src = kAdNetwork2;
+functions.push(function ReplaceIframeAd2() {
+ $('ad-iframe').setAttribute('src', kAdNetwork2);
return INJECTION_REPLACED_AD;
});
// Switch an existing anchor ad to a new ad network.
-functions.push(function ReplaceAnchorAd() {
+functions.push(function ReplaceAnchorAd1() {
$('ad-anchor').href = kAdNetwork2;
return INJECTION_REPLACED_AD;
});
-// Remove an existing embed ad by setting it's src to a non-ad network.
-functions.push(function RemoveAdBySettingSrc() {
- $('ad-embed').src = kMaybeAdNetwork;
- return INJECTION_REMOVED_AD;
Devlin 2014/07/16 20:14:49 Even though these are using embeds now, they shoul
pmarch 2014/07/17 14:04:26 Done.
-});
-
-// Ensure that we flag actions that look a lot like ad injection, even if we're
-// not sure.
-functions.push(function LikelyReplacedAd() {
- // Switching from one valid url src to another valid url src is very
- // suspicious behavior, and should be relatively rare. This helps us determine
- // the effectiveness of our ad network recognition.
- $('non-ad-embed').src = 'http://www.thismightbeanadnetwork.ads';
- return INJECTION_LIKELY_REPLACED_AD;
+functions.push(function ReplaceAnchorAd2() {
+ $('ad-anchor').setAttribute('href', kAdNetwork2);
+ return INJECTION_REPLACED_AD;
});
// Verify that we do not enter the javascript world when we check for ad

Powered by Google App Engine
This is Rietveld 408576698