Drop ActiveDOMObject::shouldPreventEnteringBackForwardCache_DEPRECATED()
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Nov 2019 01:53:00 +0000 (01:53 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Nov 2019 01:53:00 +0000 (01:53 +0000)
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252894 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/security/navigate-when-restoring-cached-page.html
Source/WebCore/ChangeLog
Source/WebCore/dom/ActiveDOMObject.h
Source/WebCore/dom/Document.h
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/dom/ScriptExecutionContext.h
Source/WebCore/history/BackForwardCache.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebFrame.mm

index 68781f1..0430654 100644 (file)
@@ -1,3 +1,12 @@
+2019-11-26  Chris Dumez  <cdumez@apple.com>
+
+        Drop ActiveDOMObject::shouldPreventEnteringBackForwardCache_DEPRECATED()
+        https://bugs.webkit.org/show_bug.cgi?id=204626
+
+        Reviewed by Ryosuke Niwa.
+
+        * http/tests/security/navigate-when-restoring-cached-page.html:
+
 2019-11-26  Jonathan Bedard  <jbedard@apple.com>
 
         [WebGL] Garden dedicated queue (Part 5)
index dd6f8c1..82f467d 100644 (file)
@@ -61,9 +61,8 @@ function runTest()
           
           clearInterval(interval_id);
 
-          // Prevent entering PageCache.
           if (w.internals)
-            w.internals.preventDocumentForEnteringBackForwardCache();
+            w.internals.preventDocumentFromEnteringBackForwardCache();
 
           child_frame = w.document.body.appendChild(document.createElement('iframe'));
           child_frame.contentWindow.onunload = () => {
index 3522ee5..7546483 100644 (file)
@@ -1,3 +1,30 @@
+2019-11-26  Chris Dumez  <cdumez@apple.com>
+
+        Drop ActiveDOMObject::shouldPreventEnteringBackForwardCache_DEPRECATED()
+        https://bugs.webkit.org/show_bug.cgi?id=204626
+
+        Reviewed by Ryosuke Niwa.
+
+        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:
+
 2019-11-26  Antti Koivisto  <antti@apple.com>
 
         [LFC][Render tree] Add LFC line layout path to RenderBlockFlow
index 929df00..8a42161 100644 (file)
@@ -63,9 +63,8 @@ public:
 
     virtual const char* activeDOMObjectName() const = 0;
 
-    // These three functions must not have a side effect of creating or destroying
+    // These functions must not have a side effect of creating or destroying
     // any ActiveDOMObject. That means they must not result in calls to arbitrary JavaScript.
-    virtual bool shouldPreventEnteringBackForwardCache_DEPRECATED() const { return false; } // Please do not add new overrides for this function.
     virtual void suspend(ReasonForSuspension);
     virtual void resume();
 
index 1aa01c1..8225fd0 100644 (file)
@@ -489,6 +489,9 @@ public:
     StandaloneStatus xmlStandaloneStatus() const { return m_xmlStandalone; }
     bool hasXMLDeclaration() const { return m_hasXMLDeclaration; }
 
+    bool shouldPreventEnteringBackForwardCacheForTesting() const { return m_shouldPreventEnteringBackForwardCacheForTesting; }
+    void preventEnteringBackForwardCacheForTesting() { m_shouldPreventEnteringBackForwardCacheForTesting = true; }
+
     void setXMLEncoding(const String& encoding) { m_xmlEncoding = encoding; } // read-only property, only to be set from XMLDocumentParser
     WEBCORE_EXPORT ExceptionOr<void> setXMLVersion(const String&);
     WEBCORE_EXPORT void setXMLStandalone(bool);
@@ -2078,6 +2081,7 @@ private:
     bool m_hasEvaluatedUserAgentScripts { false };
     bool m_isRunningUserScripts { false };
     bool m_mayBeDetachedFromFrame { true };
+    bool m_shouldPreventEnteringBackForwardCacheForTesting { false };
 #if ENABLE(APPLE_PAY)
     bool m_hasStartedApplePaySession { false };
 #endif
index 63c8542..fa68eb8 100644 (file)
@@ -222,38 +222,11 @@ void ScriptExecutionContext::didLoadResourceSynchronously()
 {
 }
 
-bool ScriptExecutionContext::canSuspendActiveDOMObjectsForDocumentSuspension(Vector<ActiveDOMObject*>* unsuspendableObjects)
-{
-    checkConsistency();
-
-    bool canSuspend = true;
-
-    forEachActiveDOMObject([&](auto& activeDOMObject) {
-        if (activeDOMObject.shouldPreventEnteringBackForwardCache_DEPRECATED()) {
-            canSuspend = false;
-            if (unsuspendableObjects)
-                unsuspendableObjects->append(&activeDOMObject);
-            else
-                return ShouldContinue::No;
-        }
-        return ShouldContinue::Yes;
-    });
-
-    if (unsuspendableObjects) {
-        // Remove activeDOMObjects that have been destroyed while we were iterating above.
-        unsuspendableObjects->removeAllMatching([&](auto* activeDOMObject) {
-            return !m_activeDOMObjects.contains(activeDOMObject);
-        });
-    }
-
-    return canSuspend;
-}
-
 void ScriptExecutionContext::forEachActiveDOMObject(const Function<ShouldContinue(ActiveDOMObject&)>& apply) const
 {
     // It is not allowed to run arbitrary script or construct new ActiveDOMObjects while we are iterating over ActiveDOMObjects.
     // An ASSERT_WITH_SECURITY_IMPLICATION or RELEASE_ASSERT will fire if this happens, but it's important to code
-    // canSuspendActiveDOMObjectsForDocumentSuspension() / suspend() / resume() / stop() functions so it will not happen!
+    // suspend() / resume() / stop() functions so it will not happen!
     ScriptDisallowedScope scriptDisallowedScope;
     SetForScope<bool> activeDOMObjectAdditionForbiddenScope(m_activeDOMObjectAdditionForbidden, true);
 
index 94b6b3c..904747e 100644 (file)
@@ -126,11 +126,6 @@ public:
 
     PublicURLManager& publicURLManager();
 
-    // Active objects are not garbage collected even if inaccessible, e.g. because their activity may result in callbacks being invoked.
-    WEBCORE_EXPORT bool canSuspendActiveDOMObjectsForDocumentSuspension(Vector<ActiveDOMObject*>* unsuspendableObjects = nullptr);
-
-    // Active objects can be asked to suspend even if canSuspendActiveDOMObjectsForDocumentSuspension() returns 'false' -
-    // step-by-step JS debugging is one example.
     virtual void suspendActiveDOMObjects(ReasonForSuspension);
     virtual void resumeActiveDOMObjects(ReasonForSuspension);
     virtual void stopActiveDOMObjects();
index 1dcc06d..52c1ce0 100644 (file)
@@ -96,6 +96,11 @@ static bool canCacheFrame(Frame& frame, DiagnosticLoggingClient& diagnosticLoggi
         return false;
     }
 
+    if (frame.document()->shouldPreventEnteringBackForwardCacheForTesting()) {
+        PCLOG("   -Back/Forward caching is disabled for testing");
+        return false;
+    }
+
     if (!frame.document()->frame()) {
         PCLOG("   -Document is detached from frame");
         ASSERT_NOT_REACHED();
@@ -161,18 +166,6 @@ static bool canCacheFrame(Frame& frame, DiagnosticLoggingClient& diagnosticLoggi
         isCacheable = false;
     }
 
-    Vector<ActiveDOMObject*> unsuspendableObjects;
-    if (frame.document() && !frame.document()->canSuspendActiveDOMObjectsForDocumentSuspension(&unsuspendableObjects)) {
-        PCLOG("   -The document cannot suspend its active DOM Objects");
-        for (auto* activeDOMObject : unsuspendableObjects) {
-            PCLOG("    - Unsuspendable: ", activeDOMObject->activeDOMObjectName());
-            diagnosticLoggingClient.logDiagnosticMessage(DiagnosticLoggingKeys::unsuspendableDOMObjectKey(), activeDOMObject->activeDOMObjectName(), ShouldSample::No);
-            UNUSED_PARAM(activeDOMObject);
-        }
-        logBackForwardCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::cannotSuspendActiveDOMObjectsKey());
-        isCacheable = false;
-    }
-
     // FIXME: We should investigating caching frames that have an associated
     // application cache. <rdar://problem/5917899> tracks that work.
     if (!documentLoader->applicationCacheHost().canCacheInBackForwardCache()) {
index b9d2b53..87f73ad 100644 (file)
@@ -580,8 +580,6 @@ Internals::Internals(Document& document)
     }
 #endif
 
-    m_unsuspendableActiveDOMObject = nullptr;
-
 #if PLATFORM(COCOA) &&  ENABLE(WEB_AUDIO)
     AudioDestinationCocoa::createOverride = nullptr;
 #endif
@@ -938,25 +936,10 @@ unsigned Internals::backForwardCacheSize() const
     return BackForwardCache::singleton().pageCount();
 }
 
-class UnsuspendableActiveDOMObject final : public ActiveDOMObject, public RefCounted<UnsuspendableActiveDOMObject> {
-public:
-    static Ref<UnsuspendableActiveDOMObject> create(ScriptExecutionContext& context) { return adoptRef(*new UnsuspendableActiveDOMObject { &context }); }
-
-private:
-    explicit UnsuspendableActiveDOMObject(ScriptExecutionContext* context)
-        : ActiveDOMObject(context)
-    {
-        suspendIfNeeded();
-    }
-
-    bool shouldPreventEnteringBackForwardCache_DEPRECATED() const final { return true; }
-    const char* activeDOMObjectName() const { return "UnsuspendableActiveDOMObject"; }
-};
-
-void Internals::preventDocumentForEnteringBackForwardCache()
+void Internals::preventDocumentFromEnteringBackForwardCache()
 {
-    if (auto* context = contextDocument())
-        m_unsuspendableActiveDOMObject = UnsuspendableActiveDOMObject::create(*context);
+    if (auto* document = contextDocument())
+        document->preventEnteringBackForwardCacheForTesting();
 }
 
 void Internals::disableTileSizeUpdateDelay()
index de4e64d..443f134 100644 (file)
@@ -172,7 +172,7 @@ public:
 
     void clearBackForwardCache();
     unsigned backForwardCacheSize() const;
-    void preventDocumentForEnteringBackForwardCache();
+    void preventDocumentFromEnteringBackForwardCache();
 
     void disableTileSizeUpdateDelay();
 
@@ -926,8 +926,6 @@ private:
 
     std::unique_ptr<InspectorStubFrontend> m_inspectorFrontend;
     RefPtr<CacheStorageConnection> m_cacheStorageConnection;
-
-    RefPtr<UnsuspendableActiveDOMObject> m_unsuspendableActiveDOMObject;
 };
 
 } // namespace WebCore
index 91b56fa..a5e4233 100644 (file)
@@ -218,7 +218,7 @@ enum CompositingPolicy {
 
     void clearBackForwardCache();
     unsigned long backForwardCacheSize();
-    void preventDocumentForEnteringBackForwardCache();
+    void preventDocumentFromEnteringBackForwardCache();
 
     CSSStyleDeclaration computedStyleIncludingVisitedInfo(Element element);
 
index 6c054b2..17fd7ae 100644 (file)
@@ -1,3 +1,13 @@
+2019-11-26  Chris Dumez  <cdumez@apple.com>
+
+        Drop ActiveDOMObject::shouldPreventEnteringBackForwardCache_DEPRECATED()
+        https://bugs.webkit.org/show_bug.cgi?id=204626
+
+        Reviewed by Ryosuke Niwa.
+
+        * WebView/WebFrame.mm:
+        (-[WebFrame _cacheabilityDictionary]):
+
 2019-11-21  Daniel Bates  <dabates@apple.com>
 
         Remove unneeded code that annotated DOMHTMLElement as conforming to UITextInputTraits protocol
index d677a90..18d3d9e 100644 (file)
@@ -2059,8 +2059,6 @@ static WebFrameLoadType toWebFrameLoadType(WebCore::FrameLoadType frameLoadType)
     if (auto* document = _private->coreFrame->document()) {
         if (WebCore::DatabaseManager::singleton().hasOpenDatabases(*document))
             [result setObject:@YES forKey:WebFrameUsesDatabases];
-        if (!document->canSuspendActiveDOMObjectsForDocumentSuspension())
-            [result setObject:@YES forKey:WebFrameCanSuspendActiveDOMObjects];
     }
     
     return result;