Changeset 241906 in webkit


Ignore:
Timestamp:
Feb 21, 2019 2:51:13 PM (5 years ago)
Author:
aestes@apple.com
Message:

contentfiltering tests leak documents
https://bugs.webkit.org/show_bug.cgi?id=189434
<rdar://44239943>

Reviewed by Simon Fraser.

Changed ContentFilter to capture the blocked Frame as a WeakPtr to break a reference cycle.

This fixes world leaks in several tests in LayoutTests/contentfiltering/.

  • bindings/js/ScriptController.h:
  • loader/ContentFilter.cpp:

(WebCore::ContentFilter::didDecide):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r241876 r241906  
     12019-02-21  Andy Estes  <aestes@apple.com>
     2
     3        contentfiltering tests leak documents
     4        https://bugs.webkit.org/show_bug.cgi?id=189434
     5        <rdar://44239943>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Changed ContentFilter to capture the blocked Frame as a WeakPtr to break a reference cycle.
     10
     11        This fixes world leaks in several tests in LayoutTests/contentfiltering/.
     12
     13        * bindings/js/ScriptController.h:
     14        * loader/ContentFilter.cpp:
     15        (WebCore::ContentFilter::didDecide):
     16
    1172019-02-21  Don Olmstead  <don.olmstead@sony.com>
    218
  • trunk/Source/WebCore/bindings/js/ScriptController.h

    r238771 r241906  
    2929#include <wtf/Forward.h>
    3030#include <wtf/RefPtr.h>
     31#include <wtf/WeakPtr.h>
    3132#include <wtf/text/TextPosition.h>
    3233
     
    7071};
    7172
    72 class ScriptController {
     73class ScriptController : public CanMakeWeakPtr<ScriptController> {
    7374    WTF_MAKE_FAST_ALLOCATED;
    7475
  • trunk/Source/WebCore/loader/ContentFilter.cpp

    r233668 r241906  
    229229    ContentFilterUnblockHandler unblockHandler { m_blockingContentFilter->unblockHandler() };
    230230    unblockHandler.setUnreachableURL(m_documentLoader.documentURL());
    231     RefPtr<Frame> frame { m_documentLoader.frame() };
     231    auto frame { m_documentLoader.frame() };
    232232    String unblockRequestDeniedScript { m_blockingContentFilter->unblockRequestDeniedScript() };
    233233    if (!unblockRequestDeniedScript.isEmpty() && frame) {
    234         static_assert(std::is_base_of<ThreadSafeRefCounted<AbstractFrame>, Frame>::value, "AbstractFrame must be ThreadSafeRefCounted.");
    235         unblockHandler.wrapWithDecisionHandler([frame = WTFMove(frame), script = unblockRequestDeniedScript.isolatedCopy()](bool unblocked) {
    236             if (!unblocked)
    237                 frame->script().executeScript(script);
     234        unblockHandler.wrapWithDecisionHandler([scriptController = makeWeakPtr(frame->script()), script = unblockRequestDeniedScript.isolatedCopy()](bool unblocked) {
     235            if (!unblocked && scriptController)
     236                scriptController->executeScript(script);
    238237        });
    239238    }
Note: See TracChangeset for help on using the changeset viewer.