Title: [228060] branches/safari-605-branch

Diff

Modified: branches/safari-605-branch/LayoutTests/imported/w3c/ChangeLog (228059 => 228060)


--- branches/safari-605-branch/LayoutTests/imported/w3c/ChangeLog	2018-02-05 02:18:53 UTC (rev 228059)
+++ branches/safari-605-branch/LayoutTests/imported/w3c/ChangeLog	2018-02-05 02:18:56 UTC (rev 228060)
@@ -1,3 +1,19 @@
+2018-02-04  Jason Marcell  <jmarc...@apple.com>
+
+        Cherry-pick r227959. rdar://problem/37145559
+
+    2018-02-01  Chris Dumez  <cdu...@apple.com>
+
+            Queue a microtask when a waitUntil() promise is settled
+            https://bugs.webkit.org/show_bug.cgi?id=182372
+            <rdar://problem/37101019>
+
+            Reviewed by Mark Lam.
+
+            Reaseline WPT test now that all checks are passing.
+
+            * web-platform-tests/service-workers/service-worker/extendable-event-async-waituntil.https-expected.txt:
+
 2018-01-31  Jason Marcell  <jmarc...@apple.com>
 
         Cherry-pick r227898. rdar://problem/37079009

Modified: branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/extendable-event-async-waituntil.https-expected.txt (228059 => 228060)


--- branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/extendable-event-async-waituntil.https-expected.txt	2018-02-05 02:18:53 UTC (rev 228059)
+++ branches/safari-605-branch/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/extendable-event-async-waituntil.https-expected.txt	2018-02-05 02:18:56 UTC (rev 228060)
@@ -3,11 +3,11 @@
 PASS Test calling waitUntil in a different task without an existing extension throws 
 PASS Test calling waitUntil in a different microtask without an existing extension throws 
 PASS Test calling waitUntil in a different task with an existing extension succeeds 
-FAIL Test calling waitUntil with an existing extension promise handler succeeds assert_unreached: unexpected rejection: assert_equals: expected "OK" but got "InvalidStateError" Reached unreachable code
+PASS Test calling waitUntil with an existing extension promise handler succeeds 
 PASS Test calling waitUntil at the end of the microtask turn throws 
 PASS Test calling waitUntil after the current extension expired in a different task fails 
 PASS Test calling waitUntil on a script constructed ExtendableEvent throws exception 
 PASS Test calling waitUntil asynchronously with pending respondWith promise. 
-FAIL Test calling waitUntil synchronously inside microtask of respondWith promise. assert_unreached: unexpected rejection: assert_equals: expected "OK" but got "InvalidStateError" Reached unreachable code
+PASS Test calling waitUntil synchronously inside microtask of respondWith promise. 
 PASS Test calling waitUntil asynchronously inside microtask of respondWith promise. 
 

Modified: branches/safari-605-branch/Source/_javascript_Core/ChangeLog (228059 => 228060)


--- branches/safari-605-branch/Source/_javascript_Core/ChangeLog	2018-02-05 02:18:53 UTC (rev 228059)
+++ branches/safari-605-branch/Source/_javascript_Core/ChangeLog	2018-02-05 02:18:56 UTC (rev 228060)
@@ -1,5 +1,21 @@
 2018-02-04  Jason Marcell  <jmarc...@apple.com>
 
+        Cherry-pick r227959. rdar://problem/37145559
+
+    2018-02-01  Chris Dumez  <cdu...@apple.com>
+
+            Queue a microtask when a waitUntil() promise is settled
+            https://bugs.webkit.org/show_bug.cgi?id=182372
+            <rdar://problem/37101019>
+
+            Reviewed by Mark Lam.
+
+            Export a symbol so it can be used in WebCore.
+
+            * runtime/JSGlobalObject.h:
+
+2018-02-04  Jason Marcell  <jmarc...@apple.com>
+
         Cherry-pick r227951. rdar://problem/37145493
 
     2018-01-31  Saam Barati  <sbar...@apple.com>

Modified: branches/safari-605-branch/Source/_javascript_Core/runtime/JSGlobalObject.h (228059 => 228060)


--- branches/safari-605-branch/Source/_javascript_Core/runtime/JSGlobalObject.h	2018-02-05 02:18:53 UTC (rev 228059)
+++ branches/safari-605-branch/Source/_javascript_Core/runtime/JSGlobalObject.h	2018-02-05 02:18:56 UTC (rev 228060)
@@ -832,7 +832,7 @@
     static bool shouldInterruptScriptBeforeTimeout(const JSGlobalObject*) { return false; }
     static RuntimeFlags _javascript_RuntimeFlags(const JSGlobalObject*) { return RuntimeFlags(); }
 
-    void queueMicrotask(Ref<Microtask>&&);
+    JS_EXPORT_PRIVATE void queueMicrotask(Ref<Microtask>&&);
 
     bool evalEnabled() const { return m_evalEnabled; }
     bool webAssemblyEnabled() const { return m_webAssemblyEnabled; }

Modified: branches/safari-605-branch/Source/WebCore/ChangeLog (228059 => 228060)


--- branches/safari-605-branch/Source/WebCore/ChangeLog	2018-02-05 02:18:53 UTC (rev 228059)
+++ branches/safari-605-branch/Source/WebCore/ChangeLog	2018-02-05 02:18:56 UTC (rev 228060)
@@ -1,5 +1,28 @@
 2018-02-04  Jason Marcell  <jmarc...@apple.com>
 
+        Cherry-pick r227959. rdar://problem/37145559
+
+    2018-02-01  Chris Dumez  <cdu...@apple.com>
+
+            Queue a microtask when a waitUntil() promise is settled
+            https://bugs.webkit.org/show_bug.cgi?id=182372
+            <rdar://problem/37101019>
+
+            Reviewed by Mark Lam.
+
+            Queue a microtask when a waitUntil() promise is settled, as per:
+            - https://w3c.github.io/ServiceWorker/#dom-extendableevent-waituntil (step 5)
+
+            Otherwise, we decrement m_pendingPromiseCount too quickly and it may cause
+            following calls to waitUntil() to throw when they shouldn't.
+
+            No new tests, rebaselined existing test.
+
+            * workers/service/ExtendableEvent.cpp:
+            (WebCore::ExtendableEvent::addExtendLifetimePromise):
+
+2018-02-04  Jason Marcell  <jmarc...@apple.com>
+
         Cherry-pick r227948. rdar://problem/37145473
 
     2018-01-31  Per Arne Vollan  <pvol...@apple.com>

Modified: branches/safari-605-branch/Source/WebCore/workers/service/ExtendableEvent.cpp (228059 => 228060)


--- branches/safari-605-branch/Source/WebCore/workers/service/ExtendableEvent.cpp	2018-02-05 02:18:53 UTC (rev 228059)
+++ branches/safari-605-branch/Source/WebCore/workers/service/ExtendableEvent.cpp	2018-02-05 02:18:56 UTC (rev 228060)
@@ -29,6 +29,7 @@
 #if ENABLE(SERVICE_WORKER)
 
 #include "JSDOMPromise.h"
+#include <runtime/Microtask.h>
 
 namespace WebCore {
 
@@ -60,21 +61,44 @@
     return { };
 }
 
+class FunctionMicrotask final : public JSC::Microtask {
+public:
+    static Ref<FunctionMicrotask> create(Function<void()>&& function)
+    {
+        return adoptRef(*new FunctionMicrotask(WTFMove(function)));
+    }
+
+private:
+    explicit FunctionMicrotask(Function<void()>&& function)
+        : m_function(WTFMove(function))
+    {
+    }
+
+    void run(JSC::ExecState*) final
+    {
+        m_function();
+    }
+
+    Function<void()> m_function;
+};
+
 void ExtendableEvent::addExtendLifetimePromise(Ref<DOMPromise>&& promise)
 {
-    promise->whenSettled([this, protectedThis = makeRefPtr(this), settledPromise = promise.ptr()] () {
-        --m_pendingPromiseCount;
+    promise->whenSettled([this, protectedThis = makeRefPtr(this), settledPromise = promise.ptr()] () mutable {
+        settledPromise->globalObject()->queueMicrotask(FunctionMicrotask::create([this, protectedThis = WTFMove(protectedThis)] {
+            --m_pendingPromiseCount;
 
-        // FIXME: Let registration be the context object's relevant global object's associated service worker's containing service worker registration.
-        // FIXME: If registration's uninstalling flag is set, invoke Try Clear Registration with registration.
-        // FIXME: If registration is not null, invoke Try Activate with registration.
+            // FIXME: Let registration be the context object's relevant global object's associated service worker's containing service worker registration.
+            // FIXME: If registration's uninstalling flag is set, invoke Try Clear Registration with registration.
+            // FIXME: If registration is not null, invoke Try Activate with registration.
 
-        if (m_pendingPromiseCount)
-            return;
+            if (m_pendingPromiseCount)
+                return;
 
-        auto settledPromises = WTFMove(m_extendLifetimePromises);
-        if (auto handler = WTFMove(m_whenAllExtendLifetimePromisesAreSettledHandler))
-            handler(WTFMove(settledPromises));
+            auto settledPromises = WTFMove(m_extendLifetimePromises);
+            if (auto handler = WTFMove(m_whenAllExtendLifetimePromisesAreSettledHandler))
+                handler(WTFMove(settledPromises));
+        }));
     });
 
     m_extendLifetimePromises.add(WTFMove(promise));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to