Title: [248676] trunk/Source/WebCore
Revision
248676
Author
you...@apple.com
Date
2019-08-14 10:21:15 -0700 (Wed, 14 Aug 2019)

Log Message

Update Worker::notifyFinished to not use emptySessionID
https://bugs.webkit.org/show_bug.cgi?id=200710

Reviewed by Alex Christensen.

No change of behavior.

Exit early if context is gone since we should not dispatch events or create worker.
Make sure to unset pending activity using a ScopeExit.

* workers/Worker.cpp:
(WebCore::Worker::notifyFinished):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (248675 => 248676)


--- trunk/Source/WebCore/ChangeLog	2019-08-14 17:16:58 UTC (rev 248675)
+++ trunk/Source/WebCore/ChangeLog	2019-08-14 17:21:15 UTC (rev 248676)
@@ -1,3 +1,18 @@
+2019-08-14  Youenn Fablet  <you...@apple.com>
+
+        Update Worker::notifyFinished to not use emptySessionID
+        https://bugs.webkit.org/show_bug.cgi?id=200710
+
+        Reviewed by Alex Christensen.
+
+        No change of behavior.
+
+        Exit early if context is gone since we should not dispatch events or create worker.
+        Make sure to unset pending activity using a ScopeExit.
+
+        * workers/Worker.cpp:
+        (WebCore::Worker::notifyFinished):
+
 2019-08-14  Zalan Bujtas  <za...@apple.com>
 
         [LFC][TFC] Implement TableFormattingContext::computePreferredWidthForColumns

Modified: trunk/Source/WebCore/workers/Worker.cpp (248675 => 248676)


--- trunk/Source/WebCore/workers/Worker.cpp	2019-08-14 17:16:58 UTC (rev 248675)
+++ trunk/Source/WebCore/workers/Worker.cpp	2019-08-14 17:21:15 UTC (rev 248676)
@@ -43,6 +43,7 @@
 #include <wtf/IsoMallocInlines.h>
 #include <wtf/MainThread.h>
 #include <wtf/NeverDestroyed.h>
+#include <wtf/Scope.h>
 
 namespace WebCore {
 
@@ -181,20 +182,24 @@
 
 void Worker::notifyFinished()
 {
+    auto clearLoader = makeScopeExit([this] {
+        m_scriptLoader = nullptr;
+        unsetPendingActivity(*this);
+    });
+
     auto* context = scriptExecutionContext();
-    PAL::SessionID sessionID = context ? context->sessionID() : PAL::SessionID::emptySessionID();
+    if (!context)
+        return;
 
-    if (m_scriptLoader->failed() || !sessionID.isValid())
+    if (m_scriptLoader->failed()) {
         dispatchEvent(Event::create(eventNames().errorEvent, Event::CanBubble::No, Event::IsCancelable::Yes));
-    else {
-        bool isOnline = platformStrategies()->loaderStrategy()->isOnLine();
-        const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders = m_contentSecurityPolicyResponseHeaders ? m_contentSecurityPolicyResponseHeaders.value() : scriptExecutionContext()->contentSecurityPolicy()->responseHeaders();
-        m_contextProxy.startWorkerGlobalScope(m_scriptLoader->url(), m_name, scriptExecutionContext()->userAgent(m_scriptLoader->url()), isOnline, m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_workerCreationTime, m_runtimeFlags, sessionID);
-        InspectorInstrumentation::scriptImported(*scriptExecutionContext(), m_scriptLoader->identifier(), m_scriptLoader->script());
+        return;
     }
-    m_scriptLoader = nullptr;
 
-    unsetPendingActivity(*this);
+    bool isOnline = platformStrategies()->loaderStrategy()->isOnLine();
+    const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders = m_contentSecurityPolicyResponseHeaders ? m_contentSecurityPolicyResponseHeaders.value() : context->contentSecurityPolicy()->responseHeaders();
+    m_contextProxy.startWorkerGlobalScope(m_scriptLoader->url(), m_name, context->userAgent(m_scriptLoader->url()), isOnline, m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_workerCreationTime, m_runtimeFlags, context->sessionID());
+    InspectorInstrumentation::scriptImported(*context, m_scriptLoader->identifier(), m_scriptLoader->script());
 }
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to