Commit 93bf47e8 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

leak-detector: Remove InternalSettings supplement from Page

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.

Bug: 843903, 928781
Change-Id: I53458c6eb761a98ddc0e437174a233682e442586
Reviewed-on: https://chromium-review.googlesource.com/c/1456001Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629545}
parent 6f1e0716
......@@ -18,6 +18,7 @@ jumbo_component("controller") {
deps = [
"//skia",
"//third_party/blink/renderer/core",
"//third_party/blink/renderer/core:testing",
"//third_party/blink/renderer/modules",
"//third_party/blink/renderer/platform",
"//v8",
......
......@@ -15,6 +15,7 @@
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/testing/internal_settings.h"
#include "third_party/blink/renderer/core/workers/dedicated_worker_messaging_proxy.h"
#include "third_party/blink/renderer/core/workers/worker_thread.h"
#include "third_party/blink/renderer/platform/bindings/v8_per_isolate_data.h"
......@@ -65,6 +66,11 @@ void BlinkLeakDetector::PerformLeakDetection(
for (auto resource_fetcher : ResourceFetcher::MainThreadFetchers())
resource_fetcher->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.
InternalSettings::PrepareForLeakDetection();
// Task queue may contain delayed object destruction tasks.
// This method is called from navigation hook inside FrameLoader,
// so previous document is still held by the loader until the next event loop.
......
......@@ -549,4 +549,12 @@ void InternalSettings::setAutoplayPolicy(const String& policy_str,
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
......@@ -51,6 +51,8 @@ class InternalSettings final : public InternalSettingsGenerated,
public:
static const char kSupplementName[];
static void PrepareForLeakDetection();
class Backup {
DISALLOW_NEW();
......
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