Title: [227959] trunk
- Revision
- 227959
- Author
- [email protected]
- Date
- 2018-02-01 03:50:47 -0800 (Thu, 01 Feb 2018)
Log Message
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.
LayoutTests/imported/w3c:
Reaseline WPT test now that all checks are passing.
* web-platform-tests/service-workers/service-worker/extendable-event-async-waituntil.https-expected.txt:
Source/_javascript_Core:
Export a symbol so it can be used in WebCore.
* runtime/JSGlobalObject.h:
Source/WebCore:
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):
Modified Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (227958 => 227959)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2018-02-01 11:16:09 UTC (rev 227958)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2018-02-01 11:50:47 UTC (rev 227959)
@@ -1,3 +1,15 @@
+2018-02-01 Chris Dumez <[email protected]>
+
+ 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-02-01 Ms2ger <[email protected]>
Update imagebitmap tests.
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/extendable-event-async-waituntil.https-expected.txt (227958 => 227959)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/extendable-event-async-waituntil.https-expected.txt 2018-02-01 11:16:09 UTC (rev 227958)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/extendable-event-async-waituntil.https-expected.txt 2018-02-01 11:50:47 UTC (rev 227959)
@@ -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: trunk/Source/_javascript_Core/ChangeLog (227958 => 227959)
--- trunk/Source/_javascript_Core/ChangeLog 2018-02-01 11:16:09 UTC (rev 227958)
+++ trunk/Source/_javascript_Core/ChangeLog 2018-02-01 11:50:47 UTC (rev 227959)
@@ -1,3 +1,15 @@
+2018-02-01 Chris Dumez <[email protected]>
+
+ 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-01-31 Don Olmstead <[email protected]>
[CMake] Make _javascript_Core headers copies
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.h (227958 => 227959)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.h 2018-02-01 11:16:09 UTC (rev 227958)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.h 2018-02-01 11:50:47 UTC (rev 227959)
@@ -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: trunk/Source/WebCore/ChangeLog (227958 => 227959)
--- trunk/Source/WebCore/ChangeLog 2018-02-01 11:16:09 UTC (rev 227958)
+++ trunk/Source/WebCore/ChangeLog 2018-02-01 11:50:47 UTC (rev 227959)
@@ -1,3 +1,22 @@
+2018-02-01 Chris Dumez <[email protected]>
+
+ 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-01 Antti Koivisto <[email protected]>
Invalidate style for sibling combinators accurately on class change
Modified: trunk/Source/WebCore/workers/service/ExtendableEvent.cpp (227958 => 227959)
--- trunk/Source/WebCore/workers/service/ExtendableEvent.cpp 2018-02-01 11:16:09 UTC (rev 227958)
+++ trunk/Source/WebCore/workers/service/ExtendableEvent.cpp 2018-02-01 11:50:47 UTC (rev 227959)
@@ -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
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes