Changeset 252894 in webkit


Ignore:
Timestamp:
Nov 26, 2019 5:53:00 PM (4 years ago)
Author:
Chris Dumez
Message:

Drop ActiveDOMObject::shouldPreventEnteringBackForwardCache_DEPRECATED()
https://bugs.webkit.org/show_bug.cgi?id=204626

Reviewed by Ryosuke Niwa.

Source/WebCore:

Drop ActiveDOMObject::shouldPreventEnteringBackForwardCache_DEPRECATED() now that it is no longer
used.

  • dom/ActiveDOMObject.h:
  • dom/Document.h:

(WebCore::Document::shouldPreventEnteringBackForwardCacheForTesting const):
(WebCore::Document::preventEnteringBackForwardCacheForTesting):

  • dom/ScriptExecutionContext.cpp:

(WebCore::ScriptExecutionContext::forEachActiveDOMObject const):
(WebCore::ScriptExecutionContext::canSuspendActiveDOMObjectsForDocumentSuspension): Deleted.

  • dom/ScriptExecutionContext.h:
  • history/BackForwardCache.cpp:

(WebCore::canCacheFrame):

  • testing/Internals.cpp:

(WebCore::Internals::Internals):
(WebCore::Internals::preventDocumentFromEnteringBackForwardCache):
(WebCore::Internals::preventDocumentForEnteringBackForwardCache): Deleted.

  • testing/Internals.h:
  • testing/Internals.idl:

Source/WebKitLegacy/mac:

  • WebView/WebFrame.mm:

(-[WebFrame _cacheabilityDictionary]):

LayoutTests:

  • http/tests/security/navigate-when-restoring-cached-page.html:
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r252892 r252894  
     12019-11-26  Chris Dumez  <cdumez@apple.com>
     2
     3        Drop ActiveDOMObject::shouldPreventEnteringBackForwardCache_DEPRECATED()
     4        https://bugs.webkit.org/show_bug.cgi?id=204626
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * http/tests/security/navigate-when-restoring-cached-page.html:
     9
    1102019-11-26  Jonathan Bedard  <jbedard@apple.com>
    211
  • trunk/LayoutTests/http/tests/security/navigate-when-restoring-cached-page.html

    r251220 r252894  
    6262          clearInterval(interval_id);
    6363
    64           // Prevent entering PageCache.
    6564          if (w.internals)
    66             w.internals.preventDocumentForEnteringBackForwardCache();
     65            w.internals.preventDocumentFromEnteringBackForwardCache();
    6766
    6867          child_frame = w.document.body.appendChild(document.createElement('iframe'));
  • trunk/Source/WebCore/ChangeLog

    r252893 r252894  
     12019-11-26  Chris Dumez  <cdumez@apple.com>
     2
     3        Drop ActiveDOMObject::shouldPreventEnteringBackForwardCache_DEPRECATED()
     4        https://bugs.webkit.org/show_bug.cgi?id=204626
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Drop ActiveDOMObject::shouldPreventEnteringBackForwardCache_DEPRECATED() now that it is no longer
     9        used.
     10
     11        * dom/ActiveDOMObject.h:
     12        * dom/Document.h:
     13        (WebCore::Document::shouldPreventEnteringBackForwardCacheForTesting const):
     14        (WebCore::Document::preventEnteringBackForwardCacheForTesting):
     15        * dom/ScriptExecutionContext.cpp:
     16        (WebCore::ScriptExecutionContext::forEachActiveDOMObject const):
     17        (WebCore::ScriptExecutionContext::canSuspendActiveDOMObjectsForDocumentSuspension): Deleted.
     18        * dom/ScriptExecutionContext.h:
     19        * history/BackForwardCache.cpp:
     20        (WebCore::canCacheFrame):
     21        * testing/Internals.cpp:
     22        (WebCore::Internals::Internals):
     23        (WebCore::Internals::preventDocumentFromEnteringBackForwardCache):
     24        (WebCore::Internals::preventDocumentForEnteringBackForwardCache): Deleted.
     25        * testing/Internals.h:
     26        * testing/Internals.idl:
     27
    1282019-11-26  Antti Koivisto  <antti@apple.com>
    229
  • trunk/Source/WebCore/dom/ActiveDOMObject.h

    r252607 r252894  
    6464    virtual const char* activeDOMObjectName() const = 0;
    6565
    66     // These three functions must not have a side effect of creating or destroying
     66    // These functions must not have a side effect of creating or destroying
    6767    // any ActiveDOMObject. That means they must not result in calls to arbitrary JavaScript.
    68     virtual bool shouldPreventEnteringBackForwardCache_DEPRECATED() const { return false; } // Please do not add new overrides for this function.
    6968    virtual void suspend(ReasonForSuspension);
    7069    virtual void resume();
  • trunk/Source/WebCore/dom/Document.h

    r252828 r252894  
    490490    bool hasXMLDeclaration() const { return m_hasXMLDeclaration; }
    491491
     492    bool shouldPreventEnteringBackForwardCacheForTesting() const { return m_shouldPreventEnteringBackForwardCacheForTesting; }
     493    void preventEnteringBackForwardCacheForTesting() { m_shouldPreventEnteringBackForwardCacheForTesting = true; }
     494
    492495    void setXMLEncoding(const String& encoding) { m_xmlEncoding = encoding; } // read-only property, only to be set from XMLDocumentParser
    493496    WEBCORE_EXPORT ExceptionOr<void> setXMLVersion(const String&);
     
    20792082    bool m_isRunningUserScripts { false };
    20802083    bool m_mayBeDetachedFromFrame { true };
     2084    bool m_shouldPreventEnteringBackForwardCacheForTesting { false };
    20812085#if ENABLE(APPLE_PAY)
    20822086    bool m_hasStartedApplePaySession { false };
  • trunk/Source/WebCore/dom/ScriptExecutionContext.cpp

    r251425 r252894  
    223223}
    224224
    225 bool ScriptExecutionContext::canSuspendActiveDOMObjectsForDocumentSuspension(Vector<ActiveDOMObject*>* unsuspendableObjects)
    226 {
    227     checkConsistency();
    228 
    229     bool canSuspend = true;
    230 
    231     forEachActiveDOMObject([&](auto& activeDOMObject) {
    232         if (activeDOMObject.shouldPreventEnteringBackForwardCache_DEPRECATED()) {
    233             canSuspend = false;
    234             if (unsuspendableObjects)
    235                 unsuspendableObjects->append(&activeDOMObject);
    236             else
    237                 return ShouldContinue::No;
    238         }
    239         return ShouldContinue::Yes;
    240     });
    241 
    242     if (unsuspendableObjects) {
    243         // Remove activeDOMObjects that have been destroyed while we were iterating above.
    244         unsuspendableObjects->removeAllMatching([&](auto* activeDOMObject) {
    245             return !m_activeDOMObjects.contains(activeDOMObject);
    246         });
    247     }
    248 
    249     return canSuspend;
    250 }
    251 
    252225void ScriptExecutionContext::forEachActiveDOMObject(const Function<ShouldContinue(ActiveDOMObject&)>& apply) const
    253226{
    254227    // It is not allowed to run arbitrary script or construct new ActiveDOMObjects while we are iterating over ActiveDOMObjects.
    255228    // An ASSERT_WITH_SECURITY_IMPLICATION or RELEASE_ASSERT will fire if this happens, but it's important to code
    256     // canSuspendActiveDOMObjectsForDocumentSuspension() / suspend() / resume() / stop() functions so it will not happen!
     229    // suspend() / resume() / stop() functions so it will not happen!
    257230    ScriptDisallowedScope scriptDisallowedScope;
    258231    SetForScope<bool> activeDOMObjectAdditionForbiddenScope(m_activeDOMObjectAdditionForbidden, true);
  • trunk/Source/WebCore/dom/ScriptExecutionContext.h

    r252824 r252894  
    127127    PublicURLManager& publicURLManager();
    128128
    129     // Active objects are not garbage collected even if inaccessible, e.g. because their activity may result in callbacks being invoked.
    130     WEBCORE_EXPORT bool canSuspendActiveDOMObjectsForDocumentSuspension(Vector<ActiveDOMObject*>* unsuspendableObjects = nullptr);
    131 
    132     // Active objects can be asked to suspend even if canSuspendActiveDOMObjectsForDocumentSuspension() returns 'false' -
    133     // step-by-step JS debugging is one example.
    134129    virtual void suspendActiveDOMObjects(ReasonForSuspension);
    135130    virtual void resumeActiveDOMObjects(ReasonForSuspension);
  • trunk/Source/WebCore/history/BackForwardCache.cpp

    r252301 r252894  
    9797    }
    9898
     99    if (frame.document()->shouldPreventEnteringBackForwardCacheForTesting()) {
     100        PCLOG("   -Back/Forward caching is disabled for testing");
     101        return false;
     102    }
     103
    99104    if (!frame.document()->frame()) {
    100105        PCLOG("   -Document is detached from frame");
     
    159164        PCLOG("   -DocumentLoader is in the middle of stopping");
    160165        logBackForwardCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::documentLoaderStoppingKey());
    161         isCacheable = false;
    162     }
    163 
    164     Vector<ActiveDOMObject*> unsuspendableObjects;
    165     if (frame.document() && !frame.document()->canSuspendActiveDOMObjectsForDocumentSuspension(&unsuspendableObjects)) {
    166         PCLOG("   -The document cannot suspend its active DOM Objects");
    167         for (auto* activeDOMObject : unsuspendableObjects) {
    168             PCLOG("    - Unsuspendable: ", activeDOMObject->activeDOMObjectName());
    169             diagnosticLoggingClient.logDiagnosticMessage(DiagnosticLoggingKeys::unsuspendableDOMObjectKey(), activeDOMObject->activeDOMObjectName(), ShouldSample::No);
    170             UNUSED_PARAM(activeDOMObject);
    171         }
    172         logBackForwardCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::cannotSuspendActiveDOMObjectsKey());
    173166        isCacheable = false;
    174167    }
  • trunk/Source/WebCore/testing/Internals.cpp

    r252820 r252894  
    581581#endif
    582582
    583     m_unsuspendableActiveDOMObject = nullptr;
    584 
    585583#if PLATFORM(COCOA) &&  ENABLE(WEB_AUDIO)
    586584    AudioDestinationCocoa::createOverride = nullptr;
     
    939937}
    940938
    941 class UnsuspendableActiveDOMObject final : public ActiveDOMObject, public RefCounted<UnsuspendableActiveDOMObject> {
    942 public:
    943     static Ref<UnsuspendableActiveDOMObject> create(ScriptExecutionContext& context) { return adoptRef(*new UnsuspendableActiveDOMObject { &context }); }
    944 
    945 private:
    946     explicit UnsuspendableActiveDOMObject(ScriptExecutionContext* context)
    947         : ActiveDOMObject(context)
    948     {
    949         suspendIfNeeded();
    950     }
    951 
    952     bool shouldPreventEnteringBackForwardCache_DEPRECATED() const final { return true; }
    953     const char* activeDOMObjectName() const { return "UnsuspendableActiveDOMObject"; }
    954 };
    955 
    956 void Internals::preventDocumentForEnteringBackForwardCache()
    957 {
    958     if (auto* context = contextDocument())
    959         m_unsuspendableActiveDOMObject = UnsuspendableActiveDOMObject::create(*context);
     939void Internals::preventDocumentFromEnteringBackForwardCache()
     940{
     941    if (auto* document = contextDocument())
     942        document->preventEnteringBackForwardCacheForTesting();
    960943}
    961944
  • trunk/Source/WebCore/testing/Internals.h

    r252221 r252894  
    173173    void clearBackForwardCache();
    174174    unsigned backForwardCacheSize() const;
    175     void preventDocumentForEnteringBackForwardCache();
     175    void preventDocumentFromEnteringBackForwardCache();
    176176
    177177    void disableTileSizeUpdateDelay();
     
    927927    std::unique_ptr<InspectorStubFrontend> m_inspectorFrontend;
    928928    RefPtr<CacheStorageConnection> m_cacheStorageConnection;
    929 
    930     RefPtr<UnsuspendableActiveDOMObject> m_unsuspendableActiveDOMObject;
    931929};
    932930
  • trunk/Source/WebCore/testing/Internals.idl

    r252221 r252894  
    219219    void clearBackForwardCache();
    220220    unsigned long backForwardCacheSize();
    221     void preventDocumentForEnteringBackForwardCache();
     221    void preventDocumentFromEnteringBackForwardCache();
    222222
    223223    CSSStyleDeclaration computedStyleIncludingVisitedInfo(Element element);
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r252746 r252894  
     12019-11-26  Chris Dumez  <cdumez@apple.com>
     2
     3        Drop ActiveDOMObject::shouldPreventEnteringBackForwardCache_DEPRECATED()
     4        https://bugs.webkit.org/show_bug.cgi?id=204626
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * WebView/WebFrame.mm:
     9        (-[WebFrame _cacheabilityDictionary]):
     10
    1112019-11-21  Daniel Bates  <dabates@apple.com>
    212
  • trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm

    r251425 r252894  
    20602060        if (WebCore::DatabaseManager::singleton().hasOpenDatabases(*document))
    20612061            [result setObject:@YES forKey:WebFrameUsesDatabases];
    2062         if (!document->canSuspendActiveDOMObjectsForDocumentSuspension())
    2063             [result setObject:@YES forKey:WebFrameCanSuspendActiveDOMObjects];
    20642062    }
    20652063   
Note: See TracChangeset for help on using the changeset viewer.