Title: [251993] trunk
Revision
251993
Author
cdu...@apple.com
Date
2019-11-04 08:51:22 -0800 (Mon, 04 Nov 2019)

Log Message

MediaKeySession / WebKitMediaKeySession should not prevent entering the back/forward cache
https://bugs.webkit.org/show_bug.cgi?id=203089

Reviewed by Youenn Fablet.

Source/WebCore:

Port MediaKeySession / WebKitMediaKeySession to the HTML5 event loop instead of using its
own GenericEventQueue / GenericTaskQueue. Because the HTML5 event loop plays nicely with
the back/forward cache, we can now let pages using MediaKeySession / WebKitMediaKeySession
into the back/forward cache.

Test: http/tests/navigation/page-cache-mediakeysession.html

* Modules/encryptedmedia/MediaKeySession.cpp:
(WebCore::MediaKeySession::MediaKeySession):
(WebCore::MediaKeySession::generateRequest):
(WebCore::MediaKeySession::load):
(WebCore::MediaKeySession::update):
(WebCore::MediaKeySession::close):
(WebCore::MediaKeySession::remove):
(WebCore::MediaKeySession::enqueueMessage):
(WebCore::MediaKeySession::updateKeyStatuses):
(WebCore::MediaKeySession::hasPendingActivity const):
(WebCore::MediaKeySession::activeDOMObjectName const):
(WebCore::MediaKeySession::enqueueTask):
(WebCore::MediaKeySession::enqueueEvent):
(WebCore::MediaKeySession::shouldPreventEnteringBackForwardCache_DEPRECATED const): Deleted.
(WebCore::MediaKeySession::stop): Deleted.
* Modules/encryptedmedia/MediaKeySession.h:
* Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp:
(WebCore::WebKitMediaKeySession::WebKitMediaKeySession):
(WebCore::WebKitMediaKeySession::~WebKitMediaKeySession):
(WebCore::WebKitMediaKeySession::addKeyTimerFired):
(WebCore::WebKitMediaKeySession::sendMessage):
(WebCore::WebKitMediaKeySession::sendError):
(WebCore::WebKitMediaKeySession::hasPendingActivity const):
(WebCore::WebKitMediaKeySession::enqueueEvent):
(WebCore::WebKitMediaKeySession::shouldPreventEnteringBackForwardCache_DEPRECATED const): Deleted.
* Modules/encryptedmedia/legacy/WebKitMediaKeySession.h:

LayoutTests:

Add layout test coverage.

* http/tests/navigation/page-cache-mediakeysession-expected.txt: Added.
* http/tests/navigation/page-cache-mediakeysession.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (251992 => 251993)


--- trunk/LayoutTests/ChangeLog	2019-11-04 16:42:31 UTC (rev 251992)
+++ trunk/LayoutTests/ChangeLog	2019-11-04 16:51:22 UTC (rev 251993)
@@ -1,3 +1,15 @@
+2019-11-04  Chris Dumez  <cdu...@apple.com>
+
+        MediaKeySession / WebKitMediaKeySession should not prevent entering the back/forward cache
+        https://bugs.webkit.org/show_bug.cgi?id=203089
+
+        Reviewed by Youenn Fablet.
+
+        Add layout test coverage.
+
+        * http/tests/navigation/page-cache-mediakeysession-expected.txt: Added.
+        * http/tests/navigation/page-cache-mediakeysession.html: Added.
+
 2019-11-04  youenn fablet  <you...@apple.com>
 
         Layout Test webrtc/filtering-ice-candidate-after-reload.html is flaky.

Added: trunk/LayoutTests/http/tests/navigation/page-cache-mediakeysession-expected.txt (0 => 251993)


--- trunk/LayoutTests/http/tests/navigation/page-cache-mediakeysession-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/navigation/page-cache-mediakeysession-expected.txt	2019-11-04 16:51:22 UTC (rev 251993)
@@ -0,0 +1,14 @@
+Tests that a page with a MediaKeySession goes into the back/forward cache.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS !!session is true
+pageshow - not from cache
+pagehide - entering cache
+pageshow - from cache
+PASS Page was restored from back/forward cache
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/navigation/page-cache-mediakeysession.html (0 => 251993)


--- trunk/LayoutTests/http/tests/navigation/page-cache-mediakeysession.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/navigation/page-cache-mediakeysession.html	2019-11-04 16:51:22 UTC (rev 251993)
@@ -0,0 +1,39 @@
+<!-- webkit-test-runner [ enableBackForwardCache=true ] -->
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+description('Tests that a page with a MediaKeySession goes into the back/forward cache.');
+jsTestIsAsync = true;
+
+window.addEventListener("pageshow", function(event) {
+    debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache");
+    if (event.persisted) {
+        testPassed("Page was restored from back/forward cache");
+        finishJSTest();
+    }
+});
+
+window.addEventListener("pagehide", function(event) {
+    debug("pagehide - " + (event.persisted ? "" : "not ") + "entering cache");
+    if (!event.persisted) {
+        testFailed("Page failed to enter the back/forward cache");
+        finishJSTest();
+    }
+});
+
+_onload_ = () => {
+    mediaKeys = new WebKitMediaKeys('org.w3c.clearkey');
+    session = mediaKeys.createSession('application/x-mpegurl', new Uint8Array(1));
+    shouldBeTrue("!!session");
+    setTimeout(() => {
+        testLink.click();
+    }, 0);
+}
+</script>
+<a id="testLink" href="" style="display: none">Link</a>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (251992 => 251993)


--- trunk/Source/WebCore/ChangeLog	2019-11-04 16:42:31 UTC (rev 251992)
+++ trunk/Source/WebCore/ChangeLog	2019-11-04 16:51:22 UTC (rev 251993)
@@ -1,3 +1,44 @@
+2019-11-04  Chris Dumez  <cdu...@apple.com>
+
+        MediaKeySession / WebKitMediaKeySession should not prevent entering the back/forward cache
+        https://bugs.webkit.org/show_bug.cgi?id=203089
+
+        Reviewed by Youenn Fablet.
+
+        Port MediaKeySession / WebKitMediaKeySession to the HTML5 event loop instead of using its
+        own GenericEventQueue / GenericTaskQueue. Because the HTML5 event loop plays nicely with
+        the back/forward cache, we can now let pages using MediaKeySession / WebKitMediaKeySession
+        into the back/forward cache.
+
+        Test: http/tests/navigation/page-cache-mediakeysession.html
+
+        * Modules/encryptedmedia/MediaKeySession.cpp:
+        (WebCore::MediaKeySession::MediaKeySession):
+        (WebCore::MediaKeySession::generateRequest):
+        (WebCore::MediaKeySession::load):
+        (WebCore::MediaKeySession::update):
+        (WebCore::MediaKeySession::close):
+        (WebCore::MediaKeySession::remove):
+        (WebCore::MediaKeySession::enqueueMessage):
+        (WebCore::MediaKeySession::updateKeyStatuses):
+        (WebCore::MediaKeySession::hasPendingActivity const):
+        (WebCore::MediaKeySession::activeDOMObjectName const):
+        (WebCore::MediaKeySession::enqueueTask):
+        (WebCore::MediaKeySession::enqueueEvent):
+        (WebCore::MediaKeySession::shouldPreventEnteringBackForwardCache_DEPRECATED const): Deleted.
+        (WebCore::MediaKeySession::stop): Deleted.
+        * Modules/encryptedmedia/MediaKeySession.h:
+        * Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp:
+        (WebCore::WebKitMediaKeySession::WebKitMediaKeySession):
+        (WebCore::WebKitMediaKeySession::~WebKitMediaKeySession):
+        (WebCore::WebKitMediaKeySession::addKeyTimerFired):
+        (WebCore::WebKitMediaKeySession::sendMessage):
+        (WebCore::WebKitMediaKeySession::sendError):
+        (WebCore::WebKitMediaKeySession::hasPendingActivity const):
+        (WebCore::WebKitMediaKeySession::enqueueEvent):
+        (WebCore::WebKitMediaKeySession::shouldPreventEnteringBackForwardCache_DEPRECATED const): Deleted.
+        * Modules/encryptedmedia/legacy/WebKitMediaKeySession.h:
+
 2019-11-04  Eric Carlson  <eric.carl...@apple.com>
 
         enumerateDevices() doesn't return correct list of devices after device was changed by user in a system preferences

Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp (251992 => 251993)


--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp	2019-11-04 16:42:31 UTC (rev 251992)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp	2019-11-04 16:51:22 UTC (rev 251993)
@@ -31,6 +31,7 @@
 
 #if ENABLE(ENCRYPTED_MEDIA)
 
+#include "AbstractEventLoop.h"
 #include "CDM.h"
 #include "CDMInstance.h"
 #include "DOMPromiseProxy.h"
@@ -70,7 +71,6 @@
     , m_sessionType(sessionType)
     , m_implementation(WTFMove(implementation))
     , m_instanceSession(WTFMove(instanceSession))
-    , m_eventQueue(MainThreadGenericEventQueue::create(*this))
 {
     // https://w3c.github.io/encrypted-media/#dom-mediakeys-createsession
     // W3C Editor's Draft 09 November 2016
@@ -157,7 +157,7 @@
     // 8. Let session type be this object's session type.
     // 9. Let promise be a new promise.
     // 10. Run the following steps in parallel:
-    m_taskQueue.enqueueTask([this, initData = SharedBuffer::create(initData.data(), initData.length()), initDataType, promise = WTFMove(promise)] () mutable {
+    enqueueTask([this, initData = SharedBuffer::create(initData.data(), initData.length()), initDataType, promise = WTFMove(promise)] () mutable {
         // 10.1. If the init data is not valid for initDataType, reject promise with a newly created TypeError.
         // 10.2. Let sanitized init data be a validated and sanitized version of init data.
         RefPtr<SharedBuffer> sanitizedInitData = m_implementation->sanitizeInitData(initDataType, initData);
@@ -226,7 +226,7 @@
             }
 
             // 10.10. Queue a task to run the following steps:
-            m_taskQueue.enqueueTask([this, promise = WTFMove(promise), message = WTFMove(message), messageType, sessionId, succeeded] () mutable {
+            enqueueTask([this, promise = WTFMove(promise), message = WTFMove(message), messageType, sessionId, succeeded] () mutable {
                 // 10.10.1. If any of the preceding steps failed, reject promise with a new DOMException whose name is the appropriate error name.
                 if (succeeded == CDMInstanceSession::SuccessValue::Failed) {
                     promise->reject(NotSupportedError);
@@ -277,7 +277,7 @@
 
     // 7. Let promise be a new promise.
     // 8. Run the following steps in parallel:
-    m_taskQueue.enqueueTask([this, sessionId, promise = WTFMove(promise)] () mutable {
+    enqueueTask([this, sessionId, promise = WTFMove(promise)] () mutable {
         // 8.1. Let sanitized session ID be a validated and/or sanitized version of sessionId.
         // 8.2. If the preceding step failed, or if sanitized session ID is empty, reject promise with a newly created TypeError.
         Optional<String> sanitizedSessionId = m_implementation->sanitizeSessionId(sessionId);
@@ -329,7 +329,7 @@
             }
 
             // 8.9. Queue a task to run the following steps:
-            m_taskQueue.enqueueTask([this, knownKeys = WTFMove(knownKeys), expiration = WTFMove(expiration), message = WTFMove(message), sanitizedSessionId, succeeded, promise = WTFMove(promise)] () mutable {
+            enqueueTask([this, knownKeys = WTFMove(knownKeys), expiration = WTFMove(expiration), message = WTFMove(message), sanitizedSessionId, succeeded, promise = WTFMove(promise)] () mutable {
                 // 8.9.1. If any of the preceding steps failed, reject promise with a the appropriate error name.
                 if (succeeded == CDMInstanceSession::SuccessValue::Failed) {
                     promise->reject(NotSupportedError);
@@ -386,7 +386,7 @@
     // 4. Let response copy be a copy of the contents of the response parameter.
     // 5. Let promise be a new promise.
     // 6. Run the following steps in parallel:
-    m_taskQueue.enqueueTask([this, response = SharedBuffer::create(response.data(), response.length()), promise = WTFMove(promise)] () mutable {
+    enqueueTask([this, response = SharedBuffer::create(response.data(), response.length()), promise = WTFMove(promise)] () mutable {
         // 6.1. Let sanitized response be a validated and/or sanitized version of response copy.
         RefPtr<SharedBuffer> sanitizedResponse = m_implementation->sanitizeResponse(response);
 
@@ -437,7 +437,7 @@
             //   6.7.3.1. Let message be that message.
             //   6.7.3.2. Let message type be the appropriate MediaKeyMessageType for the message.
             // 6.8. Queue a task to run the following steps:
-            m_taskQueue.enqueueTask([this, sessionWasClosed, changedKeys = WTFMove(changedKeys), changedExpiration = WTFMove(changedExpiration), message = WTFMove(message), promise = WTFMove(promise)] () mutable {
+            enqueueTask([this, sessionWasClosed, changedKeys = WTFMove(changedKeys), changedExpiration = WTFMove(changedExpiration), message = WTFMove(message), promise = WTFMove(promise)] () mutable {
                 LOG(EME, "EME - updating CDM license succeeded for session %s, sending a message to the license server", m_sessionId.utf8().data());
                 // 6.8.1.
                 if (sessionWasClosed) {
@@ -514,7 +514,7 @@
 
     // 4. Let promise be a new promise.
     // 5. Run the following steps in parallel:
-    m_taskQueue.enqueueTask([this, promise = WTFMove(promise)] () mutable {
+    enqueueTask([this, promise = WTFMove(promise)] () mutable {
         // 5.1. Let cdm be the CDM instance represented by session's cdm instance value.
         // 5.2. Use cdm to close the key session associated with session.
         LOG(EME, "EME - closing CDM session %s", m_sessionId.utf8().data());
@@ -523,7 +523,7 @@
                 return;
 
             // 5.3. Queue a task to run the following steps:
-            m_taskQueue.enqueueTask([this, promise = WTFMove(promise)] () mutable {
+            enqueueTask([this, promise = WTFMove(promise)] () mutable {
                 // 5.3.1. Run the Session Closed algorithm on the session.
                 sessionClosed();
 
@@ -552,7 +552,7 @@
 
     // 3. Let promise be a new promise.
     // 4. Run the following steps in parallel:
-    m_taskQueue.enqueueTask([this, promise = WTFMove(promise)] () mutable {
+    enqueueTask([this, promise = WTFMove(promise)] () mutable {
         // 4.1. Let cdm be the CDM instance represented by this object's cdm instance value.
         // 4.2. Let message be null.
         // 4.3. Let message type be null.
@@ -577,7 +577,7 @@
             // NOTE: Step 4.4.1. should be implemented in CDMInstance.
 
             // 4.5. Queue a task to run the following steps:
-            m_taskQueue.enqueueTask([this, keys = WTFMove(keys), message = WTFMove(message), succeeded, promise = WTFMove(promise)] () mutable {
+            enqueueTask([this, keys = WTFMove(keys), message = WTFMove(message), succeeded, promise = WTFMove(promise)] () mutable {
                 // 4.5.1. Run the Update Key Statuses algorithm on the session, providing all key ID(s) in the session along with the "released" MediaKeyStatus value for each.
                 updateKeyStatuses(WTFMove(keys));
 
@@ -616,7 +616,7 @@
     //    interface with its type attribute set to message and its isTrusted attribute initialized to true, and dispatch it at the
     //    session.
     auto messageEvent = MediaKeyMessageEvent::create(eventNames().messageEvent, {messageType, message.tryCreateArrayBuffer()}, Event::IsTrusted::Yes);
-    m_eventQueue->enqueueEvent(WTFMove(messageEvent));
+    enqueueEvent(WTFMove(messageEvent));
 }
 
 void MediaKeySession::updateKeyStatuses(CDMInstanceSession::KeyStatusVector&& inputStatuses)
@@ -661,10 +661,10 @@
         m_statuses.uncheckedAppend({ WTFMove(status.first), toMediaKeyStatus(status.second) });
 
     // 5. Queue a task to fire a simple event named keystatuseschange at the session.
-    m_eventQueue->enqueueEvent(Event::create(eventNames().keystatuseschangeEvent, Event::CanBubble::No, Event::IsCancelable::No));
+    enqueueEvent(Event::create(eventNames().keystatuseschangeEvent, Event::CanBubble::No, Event::IsCancelable::No));
 
     // 6. Queue a task to run the Attempt to Resume Playback If Necessary algorithm on each of the media element(s) whose mediaKeys attribute is the MediaKeys object that created the session.
-    m_taskQueue.enqueueTask(
+    enqueueTask(
         [this] () mutable {
             if (m_keys)
                 m_keys->attemptToResumePlaybackOnClients();
@@ -733,26 +733,35 @@
 
 bool MediaKeySession::hasPendingActivity() const
 {
-    notImplemented();
-    return false;
+    // A MediaKeySession object SHALL NOT be destroyed and SHALL continue to receive events if it is not closed and the MediaKeys object that created it remains accessible.
+    return (!m_closed && m_keys) || ActiveDOMObject::hasPendingActivity();
 }
 
 const char* MediaKeySession::activeDOMObjectName() const
 {
-    notImplemented();
     return "MediaKeySession";
 }
 
-// FIXME: This should never prevent entering the back/forward cache.
-bool MediaKeySession::shouldPreventEnteringBackForwardCache_DEPRECATED() const
+void MediaKeySession::enqueueTask(Function<void()>&& task)
 {
-    notImplemented();
-    return true;
+    auto* context = scriptExecutionContext();
+    if (!context)
+        return;
+
+    context->eventLoop().queueTask(TaskSource::Networking, *context, [pendingActivity = makePendingActivity(*this), task = WTFMove(task)] {
+        task();
+    });
 }
 
-void MediaKeySession::stop()
+void MediaKeySession::enqueueEvent(Ref<Event>&& event)
 {
-    notImplemented();
+    auto* context = scriptExecutionContext();
+    if (!context)
+        return;
+
+    context->eventLoop().queueTask(TaskSource::Networking, *context, [this, pendingActivity = makePendingActivity(*this), event = WTFMove(event)]() mutable {
+        dispatchEvent(WTFMove(event));
+    });
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h (251992 => 251993)


--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h	2019-11-04 16:42:31 UTC (rev 251992)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h	2019-11-04 16:51:22 UTC (rev 251993)
@@ -33,13 +33,12 @@
 #include "ActiveDOMObject.h"
 #include "CDMInstanceSession.h"
 #include "EventTarget.h"
-#include "GenericEventQueue.h"
-#include "GenericTaskQueue.h"
 #include "IDLTypes.h"
 #include "MediaKeyMessageType.h"
 #include "MediaKeySessionType.h"
 #include "MediaKeyStatus.h"
 #include <wtf/RefCounted.h>
+#include <wtf/UniqueRef.h>
 #include <wtf/Vector.h>
 #include <wtf/WeakPtr.h>
 #include <wtf/text/WTFString.h>
@@ -91,6 +90,9 @@
     void sessionClosed();
     String mediaKeysStorageDirectory() const;
 
+    void enqueueTask(Function<void()>&&);
+    void enqueueEvent(Ref<Event>&&);
+
     // CDMInstanceSessionClient
     void updateKeyStatuses(CDMInstanceSessionClient::KeyStatusVector&&) override;
     void sendMessage(CDMMessageType, Ref<SharedBuffer>&& message) final;
@@ -104,8 +106,6 @@
 
     // ActiveDOMObject
     const char* activeDOMObjectName() const override;
-    bool shouldPreventEnteringBackForwardCache_DEPRECATED() const override;
-    void stop() override;
 
     WeakPtr<MediaKeys> m_keys;
     String m_sessionId;
@@ -119,8 +119,6 @@
     MediaKeySessionType m_sessionType;
     Ref<CDM> m_implementation;
     Ref<CDMInstanceSession> m_instanceSession;
-    UniqueRef<MainThreadGenericEventQueue> m_eventQueue;
-    GenericTaskQueue<Timer> m_taskQueue;
     Vector<Ref<SharedBuffer>> m_recordOfKeyUsage;
     double m_firstDecryptTime { 0 };
     double m_latestDecryptTime { 0 };

Modified: trunk/Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp (251992 => 251993)


--- trunk/Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp	2019-11-04 16:42:31 UTC (rev 251992)
+++ trunk/Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp	2019-11-04 16:51:22 UTC (rev 251993)
@@ -28,6 +28,7 @@
 
 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
 
+#include "AbstractEventLoop.h"
 #include "Document.h"
 #include "EventNames.h"
 #include "Page.h"
@@ -54,7 +55,6 @@
     : ActiveDOMObject(&context)
     , m_keys(&keys)
     , m_keySystem(keySystem)
-    , m_asyncEventQueue(MainThreadGenericEventQueue::create(*this))
     , m_session(keys.cdm().createSession(*this))
     , m_keyRequestTimer(*this, &WebKitMediaKeySession::keyRequestTimerFired)
     , m_addKeyTimer(*this, &WebKitMediaKeySession::addKeyTimerFired)
@@ -67,8 +67,6 @@
 {
     if (m_session)
         m_session->setClient(nullptr);
-
-    m_asyncEventQueue->cancelAllEvents();
 }
 
 void WebKitMediaKeySession::close()
@@ -183,7 +181,7 @@
         if (didStoreKey) {
             auto keyaddedEvent = Event::create(eventNames().webkitkeyaddedEvent, Event::CanBubble::No, Event::IsCancelable::No);
             keyaddedEvent->setTarget(this);
-            m_asyncEventQueue->enqueueEvent(WTFMove(keyaddedEvent));
+            enqueueEvent(WTFMove(keyaddedEvent));
 
             ASSERT(m_keys);
             m_keys->keyAdded();
@@ -207,7 +205,7 @@
 {
     auto event = WebKitMediaKeyMessageEvent::create(eventNames().webkitkeymessageEvent, message, destinationURL);
     event->setTarget(this);
-    m_asyncEventQueue->enqueueEvent(WTFMove(event));
+    enqueueEvent(WTFMove(event));
 }
 
 void WebKitMediaKeySession::sendError(MediaKeyErrorCode errorCode, uint32_t systemCode)
@@ -216,7 +214,7 @@
 
     auto keyerrorEvent = Event::create(eventNames().webkitkeyerrorEvent, Event::CanBubble::No, Event::IsCancelable::No);
     keyerrorEvent->setTarget(this);
-    m_asyncEventQueue->enqueueEvent(WTFMove(keyerrorEvent));
+    enqueueEvent(WTFMove(keyerrorEvent));
 }
 
 String WebKitMediaKeySession::mediaKeysStorageDirectory() const
@@ -238,7 +236,7 @@
 
 bool WebKitMediaKeySession::hasPendingActivity() const
 {
-    return (m_keys && m_session) || m_asyncEventQueue->hasPendingEvents();
+    return (m_keys && m_session) || ActiveDOMObject::hasPendingActivity();
 }
 
 void WebKitMediaKeySession::stop()
@@ -251,10 +249,15 @@
     return "WebKitMediaKeySession";
 }
 
-bool WebKitMediaKeySession::shouldPreventEnteringBackForwardCache_DEPRECATED() const
+void WebKitMediaKeySession::enqueueEvent(Ref<Event>&& event)
 {
-    // FIXME: This should never prevent entering the back/forward cache.
-    return true;
+    auto* context = scriptExecutionContext();
+    if (!context)
+        return;
+
+    context->eventLoop().queueTask(TaskSource::Networking, *context, [this, pendingActivity = makePendingActivity(*this), event = WTFMove(event)]() mutable {
+        dispatchEvent(WTFMove(event));
+    });
 }
 
 }

Modified: trunk/Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.h (251992 => 251993)


--- trunk/Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.h	2019-11-04 16:42:31 UTC (rev 251992)
+++ trunk/Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.h	2019-11-04 16:51:22 UTC (rev 251993)
@@ -30,7 +30,6 @@
 #include "ActiveDOMObject.h"
 #include "EventTarget.h"
 #include "ExceptionOr.h"
-#include "GenericEventQueue.h"
 #include "LegacyCDMSession.h"
 #include "Timer.h"
 #include <_javascript_Core/Uint8Array.h>
@@ -41,7 +40,7 @@
 class WebKitMediaKeyError;
 class WebKitMediaKeys;
 
-class WebKitMediaKeySession final : public RefCounted<WebKitMediaKeySession>, public EventTargetWithInlineData, private ActiveDOMObject, private LegacyCDMSessionClient {
+class WebKitMediaKeySession final : public RefCounted<WebKitMediaKeySession>, public EventTargetWithInlineData, public ActiveDOMObject, private LegacyCDMSessionClient {
     WTF_MAKE_ISO_ALLOCATED(WebKitMediaKeySession);
 public:
     static Ref<WebKitMediaKeySession> create(ScriptExecutionContext&, WebKitMediaKeys&, const String& keySystem);
@@ -74,11 +73,12 @@
     void sendError(MediaKeyErrorCode, uint32_t systemCode) final;
     String mediaKeysStorageDirectory() const final;
 
+    void enqueueEvent(Ref<Event>&&);
+
     void refEventTarget() final { ref(); }
     void derefEventTarget() final { deref(); }
 
     void stop() final;
-    bool shouldPreventEnteringBackForwardCache_DEPRECATED() const final;
     const char* activeDOMObjectName() const final;
 
     EventTargetInterface eventTargetInterface() const final { return WebKitMediaKeySessionEventTargetInterfaceType; }
@@ -88,7 +88,6 @@
     String m_keySystem;
     String m_sessionId;
     RefPtr<WebKitMediaKeyError> m_error;
-    UniqueRef<MainThreadGenericEventQueue> m_asyncEventQueue;
     std::unique_ptr<LegacyCDMSession> m_session;
 
     struct PendingKeyRequest {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to