Commit a4453534 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::PrepareForLeakDetection() and
InternalSettingsPageSupplementStub (in page.h) to avoid the
dependency.

Change-Id: Ie22676a233d9b5c02cf3cde79629f4b84782b572
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1829586Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701334}
parent 40090bf5
...@@ -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,
......
...@@ -245,6 +245,8 @@ component("core") { ...@@ -245,6 +245,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",
......
...@@ -1004,4 +1004,17 @@ Page::PageClients::~PageClients() = default; ...@@ -1004,4 +1004,17 @@ Page::PageClients::~PageClients() = default;
template class CORE_TEMPLATE_EXPORT Supplement<Page>; template class CORE_TEMPLATE_EXPORT Supplement<Page>;
const char InternalSettingsPageSupplementStub::kSupplementName[] =
"InternalSettings";
// static
void Page::PrepareForLeakDetection() {
// Internal settings are ScriptWrappable and thus may retain documents
// 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 : OrdinaryPages())
page->RemoveSupplement<InternalSettingsPageSupplementStub>();
}
} // namespace blink } // namespace blink
...@@ -331,6 +331,8 @@ class CORE_EXPORT Page final : public GarbageCollected<Page>, ...@@ -331,6 +331,8 @@ class CORE_EXPORT Page final : public GarbageCollected<Page>,
} }
void ClearMediaFeatureOverrides(); void ClearMediaFeatureOverrides();
static void PrepareForLeakDetection();
private: private:
friend class ScopedPagePauser; friend class ScopedPagePauser;
...@@ -442,6 +444,12 @@ class CORE_EXPORT Page final : public GarbageCollected<Page>, ...@@ -442,6 +444,12 @@ class CORE_EXPORT Page final : public GarbageCollected<Page>,
extern template class CORE_EXTERN_TEMPLATE_EXPORT Supplement<Page>; extern template class CORE_EXTERN_TEMPLATE_EXPORT Supplement<Page>;
class CORE_EXPORT InternalSettingsPageSupplementStub : public Supplement<Page> {
public:
using Supplement<Page>::Supplement;
static const char kSupplementName[];
};
} // namespace blink } // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_PAGE_PAGE_H_ #endif // THIRD_PARTY_BLINK_RENDERER_CORE_PAGE_PAGE_H_
...@@ -115,13 +115,12 @@ InternalSettings* InternalSettings::From(Page& page) { ...@@ -115,13 +115,12 @@ InternalSettings* InternalSettings::From(Page& page) {
} }
return supplement; return supplement;
} }
const char InternalSettings::kSupplementName[] = "InternalSettings";
InternalSettings::~InternalSettings() = default; InternalSettings::~InternalSettings() = default;
InternalSettings::InternalSettings(Page& page) InternalSettings::InternalSettings(Page& page)
: InternalSettingsGenerated(&page), : InternalSettingsGenerated(&page),
Supplement<Page>(page), InternalSettingsPageSupplementStub(page),
backup_(&page.GetSettings()) {} backup_(&page.GetSettings()) {}
void InternalSettings::ResetToConsistentState() { void InternalSettings::ResetToConsistentState() {
...@@ -549,12 +548,4 @@ void InternalSettings::setAutoplayPolicy(const String& policy_str, ...@@ -549,12 +548,4 @@ void InternalSettings::setAutoplayPolicy(const String& policy_str,
GetSettings()->SetAutoplayPolicy(policy); GetSettings()->SetAutoplayPolicy(policy);
} }
void InternalSettings::PrepareForLeakDetection() {
// Prepares for leak detection by removing all InternalSetting objects from
// Pages.
for (Page* page : Page::OrdinaryPages()) {
page->RemoveSupplement<InternalSettings>();
}
}
} // namespace blink } // namespace blink
...@@ -44,15 +44,11 @@ class Page; ...@@ -44,15 +44,11 @@ class Page;
class Settings; class Settings;
class InternalSettings final : public InternalSettingsGenerated, class InternalSettings final : public InternalSettingsGenerated,
public Supplement<Page> { public InternalSettingsPageSupplementStub {
USING_GARBAGE_COLLECTED_MIXIN(InternalSettings); USING_GARBAGE_COLLECTED_MIXIN(InternalSettings);
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: public:
static const char kSupplementName[];
static void PrepareForLeakDetection();
class Backup { class Backup {
DISALLOW_NEW(); DISALLOW_NEW();
......
...@@ -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