#include "third_party/blink/renderer/core/frame/ad_tracker.h"
#include <memory>
#include "base/containers/contains.h"
#include "base/run_loop.h"
#include "base/test/scoped_feature_list.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/core/dom/element_traversal.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/html/html_image_element.h"
#include "third_party/blink/renderer/core/probe/async_task_context.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
#include "third_party/blink/renderer/core/testing/sim/sim_request.h"
#include "third_party/blink/renderer/core/testing/sim/sim_test.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
namespace blink {
namespace {
const unsigned char kSmallGifData[] = …;
const char kPageWithVanillaExternalStylesheet[] = …;
const char kPageWithAdExternalStylesheet[] = …;
const char kPageWithVanillaScript[] = …;
const char kPageWithAdScript[] = …;
const char kPageWithFrame[] = …;
const char kPageWithStyleTagLoadingVanillaResources[] = …;
const char kStylesheetWithVanillaResources[] = …;
const char kStylesheetWithAdResources[] = …;
class TestAdTracker : public AdTracker { … };
void SetIsAdFrame(LocalFrame* frame) { … }
}
class AdTrackerTest : public testing::Test { … };
void AdTrackerTest::SetUp() { … }
void AdTrackerTest::TearDown() { … }
TEST_F(AdTrackerTest, AnyExecutingScriptsTaggedAsAdResource) { … }
TEST_F(AdTrackerTest, BottomScriptTaggedAsAdResource) { … }
TEST_F(AdTrackerTest, TopScriptTaggedAsAdResource) { … }
TEST_F(AdTrackerTest, AnyExecutingScriptsTaggedAsAdResource_False) { … }
TEST_F(AdTrackerTest, TopOfStackIncluded) { … }
TEST_F(AdTrackerTest, AdStackFrameCounting) { … }
TEST_F(AdTrackerTest, AsyncTagging) { … }
TEST_F(AdTrackerTest, BottommostAdScript) { … }
TEST_F(AdTrackerTest, BottommostAsyncAdScript) { … }
class AdTrackerSimTest : public SimTest { … };
TEST_F(AdTrackerSimTest, ScriptLoadedWhileExecutingAdScript) { … }
TEST_F(AdTrackerSimTest, ScriptDetectedByContext) { … }
TEST_F(AdTrackerSimTest, EventHandlerForPostMessageFromAdFrame_NoAdInStack) { … }
TEST_F(AdTrackerSimTest, RedirectToAdUrl) { … }
TEST_F(AdTrackerSimTest, AdResourceDetectedByContext) { … }
TEST_F(AdTrackerSimTest, InlineAdScriptRunningInNonAdContext) { … }
TEST_F(AdTrackerSimTest, ImageLoadedWhileExecutingAdScriptAsyncEnabled) { … }
TEST_F(AdTrackerSimTest, DataURLImageLoadedWhileExecutingAdScriptAsyncEnabled) { … }
TEST_F(AdTrackerSimTest, FrameLoadedWhileExecutingAdScript) { … }
TEST_F(AdTrackerSimTest, Contexts) { … }
TEST_F(AdTrackerSimTest, SameOriginSubframeFromAdScript) { … }
TEST_F(AdTrackerSimTest, SameOriginDocWrittenSubframeFromAdScript) { … }
class AdTrackerVanillaOrAdSimTest : public AdTrackerSimTest,
public ::testing::WithParamInterface<bool> { … };
TEST_P(AdTrackerVanillaOrAdSimTest, VanillaExternalStylesheetLoadsResources) { … }
TEST_P(AdTrackerVanillaOrAdSimTest, AdExternalStylesheetLoadsResources) { … }
TEST_P(AdTrackerVanillaOrAdSimTest, LinkRelStylesheetAddedByScript) { … }
TEST_P(AdTrackerVanillaOrAdSimTest, ExternalStylesheetInFrame) { … }
TEST_P(AdTrackerVanillaOrAdSimTest, InlineCSSSetByScript) { … }
TEST_F(AdTrackerSimTest, StyleTagInMainframe) { … }
TEST_P(AdTrackerVanillaOrAdSimTest, StyleTagInSubframe) { … }
TEST_P(AdTrackerVanillaOrAdSimTest, StyleTagAddedByScript) { … }
TEST_P(AdTrackerVanillaOrAdSimTest, VanillaImportInStylesheet) { … }
TEST_P(AdTrackerVanillaOrAdSimTest, AdImportInStylesheet) { … }
TEST_P(AdTrackerVanillaOrAdSimTest, ImageSetInStylesheet) { … }
TEST_P(AdTrackerVanillaOrAdSimTest, ConstructableCSSCreatedByScript) { … }
TEST_F(AdTrackerSimTest, StyleRecalcCausedByAdScript) { … }
TEST_F(AdTrackerSimTest, DynamicallyAddedScriptNoSrc_StillTagged) { … }
TEST_F(AdTrackerSimTest,
DynamicallyAddedScriptNoSrc_NotTaggedBasedOnUseByAdScript) { … }
TEST_F(AdTrackerSimTest, VanillaModuleScript_ResourceNotTagged) { … }
TEST_F(AdTrackerSimTest, AdModuleScript_ResourceTagged) { … }
TEST_F(AdTrackerSimTest, AdScriptWithSourceURLAtTopOfStack_StillTagged) { … }
TEST_F(AdTrackerSimTest, InlineAdScriptWithSourceURLAtTopOfStack_StillTagged) { … }
class AdTrackerDisabledSimTest : public SimTest,
private ScopedAdTaggingForTest { … };
TEST_F(AdTrackerDisabledSimTest, VerifyAdTrackingDisabled) { … }
INSTANTIATE_TEST_SUITE_P(…);
}