Title: [250662] trunk
Revision
250662
Author
you...@apple.com
Date
2019-10-03 11:07:25 -0700 (Thu, 03 Oct 2019)

Log Message

http/tests/security/navigate-when-restoring-cached-page.html should not use RTCPeerConnection to not enter in page cache
https://bugs.webkit.org/show_bug.cgi?id=202521

Reviewed by Chris Dumez.

Source/WebCore:

Introduce a dummy ActiveDOMObject which can never be suspended for document suspension.
Allow a page to create this dummy ActiveDOMObject through internals.
Covered by updated test.

* dom/ActiveDOMObject.h:
* testing/Internals.cpp:
(WebCore::Internals::preventDocumentForEnteringPageCache):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

Make use of new internals API to prevent the page to go in page cache.

* http/tests/security/navigate-when-restoring-cached-page.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (250661 => 250662)


--- trunk/LayoutTests/ChangeLog	2019-10-03 17:49:03 UTC (rev 250661)
+++ trunk/LayoutTests/ChangeLog	2019-10-03 18:07:25 UTC (rev 250662)
@@ -1,3 +1,14 @@
+2019-10-03  youenn fablet  <you...@apple.com>
+
+        http/tests/security/navigate-when-restoring-cached-page.html should not use RTCPeerConnection to not enter in page cache
+        https://bugs.webkit.org/show_bug.cgi?id=202521
+
+        Reviewed by Chris Dumez.
+
+        Make use of new internals API to prevent the page to go in page cache.
+
+        * http/tests/security/navigate-when-restoring-cached-page.html:
+
 2019-10-03  Jiewen Tan  <jiewen_...@apple.com>
 
         Support googleLegacyAppidSupport extension

Modified: trunk/LayoutTests/http/tests/security/navigate-when-restoring-cached-page.html (250661 => 250662)


--- trunk/LayoutTests/http/tests/security/navigate-when-restoring-cached-page.html	2019-10-03 17:49:03 UTC (rev 250661)
+++ trunk/LayoutTests/http/tests/security/navigate-when-restoring-cached-page.html	2019-10-03 18:07:25 UTC (rev 250662)
@@ -22,8 +22,8 @@
 
 function runTest()
 {
-  if (window.testRunner && !testRunner.isWebKit2) {
-    // This test does not run (times out) on WebKit1.
+  if (window.testRunner && !testRunner.isWebKit2 && !window.internals) {
+    // This test does not run (times out) on WebKit1 and requires internals API.
     testRunner.notifyDone();
     return;
   }
@@ -62,9 +62,9 @@
           clearInterval(interval_id);
 
           // Prevent entering PageCache.
-          peerConnection = new w.RTCPeerConnection();
-          peerConnection.addEventListener('onicecandidate', (e) => { });
-          
+          if (w.internals)
+            w.internals.preventDocumentForEnteringPageCache();
+
           child_frame = w.document.body.appendChild(document.createElement('iframe'));
           child_frame.contentWindow._onunload_ = () => {
             child_frame.contentWindow._onunload_ = null;

Modified: trunk/Source/WebCore/ChangeLog (250661 => 250662)


--- trunk/Source/WebCore/ChangeLog	2019-10-03 17:49:03 UTC (rev 250661)
+++ trunk/Source/WebCore/ChangeLog	2019-10-03 18:07:25 UTC (rev 250662)
@@ -1,3 +1,20 @@
+2019-10-03  youenn fablet  <you...@apple.com>
+
+        http/tests/security/navigate-when-restoring-cached-page.html should not use RTCPeerConnection to not enter in page cache
+        https://bugs.webkit.org/show_bug.cgi?id=202521
+
+        Reviewed by Chris Dumez.
+
+        Introduce a dummy ActiveDOMObject which can never be suspended for document suspension.
+        Allow a page to create this dummy ActiveDOMObject through internals.
+        Covered by updated test.
+
+        * dom/ActiveDOMObject.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::preventDocumentForEnteringPageCache):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2019-10-03  Tim Horton  <timothy_hor...@apple.com>
 
         WebKit doesn't build with trunk clang

Modified: trunk/Source/WebCore/dom/ActiveDOMObject.h (250661 => 250662)


--- trunk/Source/WebCore/dom/ActiveDOMObject.h	2019-10-03 17:49:03 UTC (rev 250661)
+++ trunk/Source/WebCore/dom/ActiveDOMObject.h	2019-10-03 18:07:25 UTC (rev 250662)
@@ -43,7 +43,7 @@
     PageWillBeSuspended,
 };
 
-class ActiveDOMObject : public ContextDestructionObserver {
+class WEBCORE_EXPORT ActiveDOMObject : public ContextDestructionObserver {
 public:
     // The suspendIfNeeded must be called exactly once after object construction to update
     // the suspended state to match that of the ScriptExecutionContext.

Modified: trunk/Source/WebCore/testing/Internals.cpp (250661 => 250662)


--- trunk/Source/WebCore/testing/Internals.cpp	2019-10-03 17:49:03 UTC (rev 250661)
+++ trunk/Source/WebCore/testing/Internals.cpp	2019-10-03 18:07:25 UTC (rev 250662)
@@ -573,6 +573,8 @@
         frame->page()->setPaymentCoordinator(makeUnique<PaymentCoordinator>(*mockPaymentCoordinator));
     }
 #endif
+
+    m_unsuspendableActiveDOMObject = nullptr;
 }
 
 Document* Internals::contextDocument() const
@@ -926,6 +928,27 @@
     return PageCache::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 canSuspendForDocumentSuspension() const final { return false; }
+    const char* activeDOMObjectName() const { return "UnsuspendableActiveDOMObject"; }
+};
+
+void Internals::preventDocumentForEnteringPageCache()
+{
+    if (auto* context = contextDocument())
+        m_unsuspendableActiveDOMObject = UnsuspendableActiveDOMObject::create(*context);
+}
+
 void Internals::disableTileSizeUpdateDelay()
 {
     Document* document = contextDocument();

Modified: trunk/Source/WebCore/testing/Internals.h (250661 => 250662)


--- trunk/Source/WebCore/testing/Internals.h	2019-10-03 17:49:03 UTC (rev 250661)
+++ trunk/Source/WebCore/testing/Internals.h	2019-10-03 18:07:25 UTC (rev 250662)
@@ -108,6 +108,8 @@
 class ServiceWorker;
 #endif
 
+class UnsuspendableActiveDOMObject;
+
 class Internals final : public RefCounted<Internals>, private ContextDestructionObserver
 #if ENABLE(MEDIA_STREAM)
     , private RealtimeMediaSource::Observer
@@ -165,6 +167,7 @@
 
     void clearPageCache();
     unsigned pageCacheSize() const;
+    void preventDocumentForEnteringPageCache();
 
     void disableTileSizeUpdateDelay();
 
@@ -899,6 +902,8 @@
 
     std::unique_ptr<InspectorStubFrontend> m_inspectorFrontend;
     RefPtr<CacheStorageConnection> m_cacheStorageConnection;
+
+    RefPtr<UnsuspendableActiveDOMObject> m_unsuspendableActiveDOMObject;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/testing/Internals.idl (250661 => 250662)


--- trunk/Source/WebCore/testing/Internals.idl	2019-10-03 17:49:03 UTC (rev 250661)
+++ trunk/Source/WebCore/testing/Internals.idl	2019-10-03 18:07:25 UTC (rev 250662)
@@ -209,6 +209,7 @@
 
     void clearPageCache();
     unsigned long pageCacheSize();
+    void preventDocumentForEnteringPageCache();
 
     CSSStyleDeclaration computedStyleIncludingVisitedInfo(Element element);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to