Commit 62699476 authored by Nate Chapin's avatar Nate Chapin Committed by Commit Bot

Add onprioritychange event to TaskSignal

Bug: 979017
Change-Id: I5011e209ed57110a33ae7a49b2dc083815abc8c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2091637
Commit-Queue: Nate Chapin <japhet@chromium.org>
Reviewed-by: default avatarScott Haseley <shaseley@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748346}
parent e52d14be
......@@ -221,6 +221,7 @@
"pointerup",
"popstate",
"portalactivate",
"prioritychange",
"progress",
"processorerror",
"push",
......
......@@ -8,6 +8,7 @@
#include "base/callback.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/modules/scheduler/dom_scheduler.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/heap/visitor.h"
......@@ -43,6 +44,7 @@ void DOMTaskSignal::SignalPriorityChange(WebSchedulingPriority priority) {
priority_ = priority;
if (web_scheduling_task_queue_)
web_scheduling_task_queue_->SetPriority(priority);
DispatchEvent(*Event::Create(event_type_names::kPrioritychange));
}
base::SingleThreadTaskRunner* DOMTaskSignal::GetTaskRunner() {
......
......@@ -31,6 +31,7 @@ class MODULES_EXPORT DOMTaskSignal final
// task_signal.idl
AtomicString priority();
DEFINE_ATTRIBUTE_EVENT_LISTENER(prioritychange, kPrioritychange)
void ContextDestroyed() override;
......
......@@ -10,4 +10,5 @@
RuntimeEnabled=WebScheduler
] interface TaskSignal : AbortSignal {
[MeasureAs=TaskSignalPriority] readonly attribute TaskPriority priority;
attribute EventHandler onprioritychange;
};
......@@ -8212,8 +8212,10 @@ interface TaskController : AbortController
method setPriority
interface TaskSignal : AbortSignal
attribute @@toStringTag
getter onprioritychange
getter priority
method constructor
setter onprioritychange
interface Text : CharacterData
attribute @@toStringTag
getter assignedSlot
......
<!doctype html>
<title>Scheduling API: TaskController.setPriority()</title>
<link rel="author" title="Nate Chapin" href="mailto:japhet@chromium.org">
<link rel="help" href="https://github.com/WICG/main-thread-scheduling">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
'use strict';
async_test(t => {
let tc = new TaskController("user-visible");
tc.signal.onprioritychange = t.step_func_done(() => {
assert_equals(tc.signal.priority, "background");
});
tc.setPriority("background");
}, 'Test that TaskController.setPriority() triggers an onprioritychange event on the signal');
</script>
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