Commit 283a0491 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Mark some blink testing targets testonly

This forbids production code depending on these targets, and enables
these targets to depend on other testonly targets in the future.

The only dependency prevented core:testing from being testonly was
from BlinkLeakDetector.
Add Page::SetInternalSettingsPrepareForLeakDetectionCallback()
to reverse the dependency.

Change-Id: I64cba73f0c4d1383a192e468220f3d55e926a8f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1864720
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708516}
parent e1cc9641
...@@ -18,7 +18,6 @@ jumbo_component("controller") { ...@@ -18,7 +18,6 @@ jumbo_component("controller") {
deps = [ deps = [
"//skia", "//skia",
"//third_party/blink/renderer/core", "//third_party/blink/renderer/core",
"//third_party/blink/renderer/core:testing",
"//third_party/blink/renderer/modules", "//third_party/blink/renderer/modules",
"//third_party/blink/renderer/platform", "//third_party/blink/renderer/platform",
"//v8", "//v8",
......
...@@ -67,10 +67,7 @@ void BlinkLeakDetector::PerformLeakDetection( ...@@ -67,10 +67,7 @@ void BlinkLeakDetector::PerformLeakDetection(
for (auto resource_fetcher : ResourceFetcher::MainThreadFetchers()) for (auto resource_fetcher : ResourceFetcher::MainThreadFetchers())
resource_fetcher->PrepareForLeakDetection(); resource_fetcher->PrepareForLeakDetection();
// Internal settings are ScriptWrappable and thus may retain documents Page::PrepareForLeakDetection();
// depending on whether the garbage collector(s) are able to find the settings
// object through the Page supplement.
InternalSettings::PrepareForLeakDetection();
// Task queue may contain delayed object destruction tasks. // Task queue may contain delayed object destruction tasks.
// This method is called from navigation hook inside FrameLoader, // This method is called from navigation hook inside FrameLoader,
......
...@@ -241,6 +241,8 @@ component("core") { ...@@ -241,6 +241,8 @@ component("core") {
} }
jumbo_source_set("testing") { jumbo_source_set("testing") {
testonly = true
configs += [ configs += [
":blink_core_pch", ":blink_core_pch",
"//third_party/blink/renderer:config", "//third_party/blink/renderer:config",
......
...@@ -1019,6 +1019,21 @@ void Page::ClearMediaFeatureOverrides() { ...@@ -1019,6 +1019,21 @@ void Page::ClearMediaFeatureOverrides() {
SettingsChanged(SettingsDelegate::kColorSchemeChange); SettingsChanged(SettingsDelegate::kColorSchemeChange);
} }
static void (*g_internal_settings_prepare_for_leak_detection_callback)() =
nullptr;
// static
void Page::SetInternalSettingsPrepareForLeakDetectionCallback(
void (*callback)()) {
g_internal_settings_prepare_for_leak_detection_callback = callback;
}
// static
void Page::PrepareForLeakDetection() {
if (!g_internal_settings_prepare_for_leak_detection_callback)
g_internal_settings_prepare_for_leak_detection_callback();
}
Page::PageClients::PageClients() : chrome_client(nullptr) {} Page::PageClients::PageClients() : chrome_client(nullptr) {}
Page::PageClients::~PageClients() = default; Page::PageClients::~PageClients() = default;
......
...@@ -341,6 +341,12 @@ class CORE_EXPORT Page final : public GarbageCollected<Page>, ...@@ -341,6 +341,12 @@ class CORE_EXPORT Page final : public GarbageCollected<Page>,
return history_navigation_virtual_time_pauser_; return history_navigation_virtual_time_pauser_;
} }
// See InternalSettings::PrepareForLeakDetection(). The callback is to avoid
// dependency from production code to test-only code.
static void SetInternalSettingsPrepareForLeakDetectionCallback(
void (*callback)());
static void PrepareForLeakDetection();
private: private:
friend class ScopedPagePauser; friend class ScopedPagePauser;
......
...@@ -122,7 +122,10 @@ InternalSettings::~InternalSettings() = default; ...@@ -122,7 +122,10 @@ InternalSettings::~InternalSettings() = default;
InternalSettings::InternalSettings(Page& page) InternalSettings::InternalSettings(Page& page)
: InternalSettingsGenerated(&page), : InternalSettingsGenerated(&page),
Supplement<Page>(page), Supplement<Page>(page),
backup_(&page.GetSettings()) {} backup_(&page.GetSettings()) {
Page::SetInternalSettingsPrepareForLeakDetectionCallback(
&PrepareForLeakDetection);
}
void InternalSettings::ResetToConsistentState() { void InternalSettings::ResetToConsistentState() {
backup_.RestoreTo(GetSettings()); backup_.RestoreTo(GetSettings());
...@@ -557,8 +560,10 @@ void InternalSettings::setUniversalAccessFromFileURLs( ...@@ -557,8 +560,10 @@ void InternalSettings::setUniversalAccessFromFileURLs(
} }
void InternalSettings::PrepareForLeakDetection() { void InternalSettings::PrepareForLeakDetection() {
// Prepares for leak detection by removing all InternalSetting objects from // Internal settings are ScriptWrappable and thus may retain documents
// Pages. // depending on whether the garbage collector(s) are able to find the settings
// object through the Page supplement. Prepares for leak detection by
// removing all InternalSetting objects from Pages.
for (Page* page : Page::OrdinaryPages()) { for (Page* page : Page::OrdinaryPages()) {
page->RemoveSupplement<InternalSettings>(); page->RemoveSupplement<InternalSettings>();
} }
......
...@@ -51,8 +51,6 @@ class InternalSettings final : public InternalSettingsGenerated, ...@@ -51,8 +51,6 @@ class InternalSettings final : public InternalSettingsGenerated,
public: public:
static const char kSupplementName[]; static const char kSupplementName[];
static void PrepareForLeakDetection();
class Backup { class Backup {
DISALLOW_NEW(); DISALLOW_NEW();
...@@ -147,6 +145,7 @@ class InternalSettings final : public InternalSettingsGenerated, ...@@ -147,6 +145,7 @@ class InternalSettings final : public InternalSettingsGenerated,
void SetPreloadLogging(bool, ExceptionState&); void SetPreloadLogging(bool, ExceptionState&);
private: private:
static void PrepareForLeakDetection();
Settings* GetSettings() const; Settings* GetSettings() const;
Page* GetPage() const { return GetSupplementable(); } Page* GetPage() const { return GetSupplementable(); }
......
...@@ -23,6 +23,8 @@ blink_modules_sources("exported") { ...@@ -23,6 +23,8 @@ blink_modules_sources("exported") {
} }
static_library("test_support") { static_library("test_support") {
testonly = true
deps = [ deps = [
"//skia", "//skia",
"//third_party/blink/renderer/core:testing", "//third_party/blink/renderer/core:testing",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment