Commit 39b15590 authored by Fergal Daly's avatar Fergal Daly Committed by Commit Bot

Add queueMicrotask method to Window and Worker APIs.

Bug: 864900
Change-Id: I9228f1d475e19786ce675da93210c08b54bc3988
Reviewed-on: https://chromium-review.googlesource.com/1250523
Commit-Queue: Fergal Daly <fergal@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595705}
parent 6b111a06
This is a testharness.js-based test.
FAIL It rethrows exceptions queueMicrotask is not defined
Harness: the test ran to completion.
This is a testharness.js-based test.
FAIL It rethrows exceptions queueMicrotask is not defined
Harness: the test ran to completion.
This is a testharness.js-based test.
FAIL It rethrows exceptions queueMicrotask is not defined
Harness: the test ran to completion.
This is a testharness.js-based test.
FAIL It rethrows exceptions queueMicrotask is not defined
Harness: the test ran to completion.
This is a testharness.js-based test.
FAIL It exists and is a function assert_equals: expected "function" but got "undefined"
FAIL It throws when given non-functions assert_throws: no argument function "() => queueMicrotask()" threw object "ReferenceError: queueMicrotask is not defined" ("ReferenceError") expected object "TypeError" ("TypeError")
FAIL It calls the callback asynchronously queueMicrotask is not defined
FAIL It does not pass any arguments queueMicrotask is not defined
FAIL It interleaves with promises as expected queueMicrotask is not defined
Harness: the test ran to completion.
This is a testharness.js-based test.
FAIL It exists and is a function assert_equals: expected "function" but got "undefined"
FAIL It throws when given non-functions assert_throws: no argument function "() => queueMicrotask()" threw object "ReferenceError: queueMicrotask is not defined" ("ReferenceError") expected object "TypeError" ("TypeError")
FAIL It calls the callback asynchronously queueMicrotask is not defined
FAIL It does not pass any arguments queueMicrotask is not defined
FAIL It interleaves with promises as expected queueMicrotask is not defined
Harness: the test ran to completion.
This is a testharness.js-based test.
FAIL It exists and is a function assert_equals: expected "function" but got "undefined"
FAIL It throws when given non-functions assert_throws: no argument function "() => queueMicrotask()" threw object "ReferenceError: queueMicrotask is not defined" ("ReferenceError") expected object "TypeError" ("TypeError")
FAIL It calls the callback asynchronously queueMicrotask is not defined
FAIL It does not pass any arguments queueMicrotask is not defined
FAIL It interleaves with promises as expected queueMicrotask is not defined
Harness: the test ran to completion.
This is a testharness.js-based test.
FAIL It exists and is a function assert_equals: expected "function" but got "undefined"
FAIL It throws when given non-functions assert_throws: no argument function "() => queueMicrotask()" threw object "ReferenceError: queueMicrotask is not defined" ("ReferenceError") expected object "TypeError" ("TypeError")
FAIL It calls the callback asynchronously queueMicrotask is not defined
FAIL It does not pass any arguments queueMicrotask is not defined
FAIL It interleaves with promises as expected queueMicrotask is not defined
Harness: the test ran to completion.
This is a testharness.js-based test.
FAIL It interleaves with MutationObservers as expected promise_test: Unhandled rejection with value: object "ReferenceError: queueMicrotask is not defined"
FAIL It interleaves with MutationObservers and promises together as expected promise_test: Unhandled rejection with value: object "ReferenceError: queueMicrotask is not defined"
Harness: the test ran to completion.
......@@ -3440,6 +3440,7 @@ interface WorkerGlobalScope : EventTarget
method createImageBitmap
method fetch
method importScripts
method queueMicrotask
method requestAnimationFrame
method setInterval
method setTimeout
......
......@@ -2439,6 +2439,7 @@ interface WorkerGlobalScope : EventTarget
method createImageBitmap
method fetch
method importScripts
method queueMicrotask
method requestAnimationFrame
method setInterval
method setTimeout
......
......@@ -2484,6 +2484,7 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] method createImageBitmap
[Worker] method fetch
[Worker] method importScripts
[Worker] method queueMicrotask
[Worker] method requestAnimationFrame
[Worker] method setInterval
[Worker] method setTimeout
......
......@@ -8728,6 +8728,7 @@ interface webkitURL
method postMessage
method print
method prompt
method queueMicrotask
method releaseEvents
method requestAnimationFrame
method requestIdleCallback
......
......@@ -2371,6 +2371,7 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] method createImageBitmap
[Worker] method fetch
[Worker] method importScripts
[Worker] method queueMicrotask
[Worker] method requestAnimationFrame
[Worker] method setInterval
[Worker] method setTimeout
......
......@@ -3467,6 +3467,7 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] method createImageBitmap
[Worker] method fetch
[Worker] method importScripts
[Worker] method queueMicrotask
[Worker] method requestAnimationFrame
[Worker] method setInterval
[Worker] method setTimeout
......
......@@ -10686,6 +10686,7 @@ interface webkitURL
method postMessage
method print
method prompt
method queueMicrotask
method releaseEvents
method requestAnimationFrame
method requestIdleCallback
......
......@@ -3339,6 +3339,7 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] method createImageBitmap
[Worker] method fetch
[Worker] method importScripts
[Worker] method queueMicrotask
[Worker] method requestAnimationFrame
[Worker] method setInterval
[Worker] method setTimeout
......
......@@ -37,6 +37,7 @@
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/source_location.h"
#include "third_party/blink/renderer/bindings/core/v8/usv_string_or_trusted_url.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_void_function.h"
#include "third_party/blink/renderer/bindings/core/v8/window_proxy.h"
#include "third_party/blink/renderer/core/accessibility/ax_context.h"
#include "third_party/blink/renderer/core/aom/computed_accessible_node.h"
......@@ -102,6 +103,7 @@
#include "third_party/blink/renderer/core/trustedtypes/trusted_type_policy_factory.h"
#include "third_party/blink/renderer/core/trustedtypes/trusted_types_util.h"
#include "third_party/blink/renderer/platform/bindings/exception_messages.h"
#include "third_party/blink/renderer/platform/bindings/microtask.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/scroll/scroll_types.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
......@@ -1248,6 +1250,12 @@ void LocalDOMWindow::cancelAnimationFrame(int id) {
document->CancelAnimationFrame(id);
}
void LocalDOMWindow::queueMicrotask(V8VoidFunction* callback) {
Microtask::EnqueueMicrotask(WTF::Bind(
&V8PersistentCallbackFunction<V8VoidFunction>::InvokeAndReportException,
WrapPersistent(ToV8PersistentCallbackFunction(callback)), nullptr));
}
int LocalDOMWindow::requestIdleCallback(V8IdleRequestCallback* callback,
const IdleRequestOptions& options) {
if (Document* document = this->document()) {
......
......@@ -73,6 +73,7 @@ class TrustedTypePolicyFactory;
class USVStringOrTrustedURL;
class V8FrameRequestCallback;
class V8IdleRequestCallback;
class V8VoidFunction;
enum PageshowEventPersistence {
kPageshowEventNotPersisted = 0,
......@@ -224,6 +225,9 @@ class CORE_EXPORT LocalDOMWindow final : public DOMWindow,
int webkitRequestAnimationFrame(V8FrameRequestCallback*);
void cancelAnimationFrame(int id);
// https://html.spec.whatwg.org/#windoworworkerglobalscope-mixin
void queueMicrotask(V8VoidFunction*);
// Idle callback extensions
int requestIdleCallback(V8IdleRequestCallback*, const IdleRequestOptions&);
void cancelIdleCallback(int id);
......
......@@ -104,6 +104,9 @@
[CrossOrigin, CallWith=CurrentWindow, RaisesException, RuntimeEnabled=PostMessageOptions] void postMessage(any message, optional WindowPostMessageOptions options);
// https://html.spec.whatwg.org/#windoworworkerglobalscope-mixin
void queueMicrotask(VoidFunction callback);
// Custom elements
// https://w3c.github.io/webcomponents/spec/custom/#custom-elements-api
[CallWith=ScriptState] readonly attribute CustomElementRegistry customElements;
......
......@@ -32,6 +32,7 @@
#include "third_party/blink/public/platform/web_url_request.h"
#include "third_party/blink/renderer/bindings/core/v8/script_source_code.h"
#include "third_party/blink/renderer/bindings/core/v8/source_location.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_void_function.h"
#include "third_party/blink/renderer/bindings/core/v8/worker_or_worklet_script_controller.h"
#include "third_party/blink/renderer/core/css/font_face_set_worker.h"
#include "third_party/blink/renderer/core/css/offscreen_font_selector.h"
......@@ -58,6 +59,7 @@
#include "third_party/blink/renderer/core/workers/worker_reporting_proxy.h"
#include "third_party/blink/renderer/core/workers/worker_thread.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/microtask.h"
#include "third_party/blink/renderer/platform/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/instance_counters.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_client_settings_object_snapshot.h"
......@@ -493,6 +495,12 @@ void WorkerGlobalScope::RemoveURLFromMemoryCache(const KURL& url) {
CrossThreadBind(&RemoveURLFromMemoryCacheInternal, url));
}
void WorkerGlobalScope::queueMicrotask(V8VoidFunction* callback) {
Microtask::EnqueueMicrotask(WTF::Bind(
&V8PersistentCallbackFunction<V8VoidFunction>::InvokeAndReportException,
WrapPersistent(ToV8PersistentCallbackFunction(callback)), nullptr));
}
int WorkerGlobalScope::requestAnimationFrame(V8FrameRequestCallback* callback,
ExceptionState& exception_state) {
FrameRequestCallbackCollection::V8FrameCallback* frame_callback =
......
......@@ -58,6 +58,7 @@ class ExceptionState;
class FetchClientSettingsObjectSnapshot;
class FontFaceSet;
class OffscreenFontSelector;
class V8VoidFunction;
class WorkerLocation;
class WorkerNavigator;
class WorkerThread;
......@@ -157,6 +158,9 @@ class CORE_EXPORT WorkerGlobalScope
// FontFaceSource on the IDL.
FontFaceSet* fonts();
// https://html.spec.whatwg.org/#windoworworkerglobalscope-mixin
void queueMicrotask(V8VoidFunction*);
int requestAnimationFrame(V8FrameRequestCallback* callback, ExceptionState&);
void cancelAnimationFrame(int id);
......
......@@ -66,6 +66,9 @@
// https://html.spec.whatwg.org/#windoworworkerglobalscope-mixin
[Replaceable] readonly attribute DOMString origin;
// https://html.spec.whatwg.org/#windoworworkerglobalscope-mixin
void queueMicrotask(VoidFunction callback);
// TODO(fserb): temporarly until we can enable the interface below.
[RuntimeEnabled=OffscreenCanvasText] readonly attribute FontFaceSet fonts;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment