contentfiltering tests leak documents
[WebKit-https.git] / Source / WebCore / loader / ContentFilter.cpp
index 7bc6998..628d51d 100644 (file)
@@ -228,13 +228,12 @@ void ContentFilter::didDecide(State state)
 
     ContentFilterUnblockHandler unblockHandler { m_blockingContentFilter->unblockHandler() };
     unblockHandler.setUnreachableURL(m_documentLoader.documentURL());
-    RefPtr<Frame> frame { m_documentLoader.frame() };
+    auto frame { m_documentLoader.frame() };
     String unblockRequestDeniedScript { m_blockingContentFilter->unblockRequestDeniedScript() };
     if (!unblockRequestDeniedScript.isEmpty() && frame) {
-        static_assert(std::is_base_of<ThreadSafeRefCounted<AbstractFrame>, Frame>::value, "AbstractFrame must be ThreadSafeRefCounted.");
-        unblockHandler.wrapWithDecisionHandler([frame = WTFMove(frame), script = unblockRequestDeniedScript.isolatedCopy()](bool unblocked) {
-            if (!unblocked)
-                frame->script().executeScript(script);
+        unblockHandler.wrapWithDecisionHandler([scriptController = makeWeakPtr(frame->script()), script = unblockRequestDeniedScript.isolatedCopy()](bool unblocked) {
+            if (!unblocked && scriptController)
+                scriptController->executeScript(script);
         });
     }
     m_documentLoader.frameLoader()->client().contentFilterDidBlockLoad(WTFMove(unblockHandler));