diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/webappapis/scripting/event-loops/task_microtask_ordering-manual.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/webappapis/scripting/event-loops/task_microtask_ordering-manual.html')
-rw-r--r-- | testing/web-platform/tests/html/webappapis/scripting/event-loops/task_microtask_ordering-manual.html | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/webappapis/scripting/event-loops/task_microtask_ordering-manual.html b/testing/web-platform/tests/html/webappapis/scripting/event-loops/task_microtask_ordering-manual.html new file mode 100644 index 0000000000..ed2f70e196 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/scripting/event-loops/task_microtask_ordering-manual.html @@ -0,0 +1,64 @@ +<!DOCTYPE html> +<title>Task and Microtask Ordering </title> +<link rel=author title="Joshua Bell" href="mailto:jsbell@google.com"> +<link rel=help href="https://html.spec.whatwg.org/multipage/#event-loops"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/common.js"></script> +<style> +.inner { padding: 46px; width: 0; margin: 0 auto; background: #d4d4d4; } +.outer { padding: 25px; width: 92px; background: #f1f1f1; } +</style> + +<p>Click on the inner box:</p> +<div class="outer"> + <div class="inner"></div> +</div> + +<script> + +// Based on: https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/ + +log_test(function(t, log) { + // Let's get hold of those elements + var outer = document.querySelector('.outer'); + var inner = document.querySelector('.inner'); + + // Let's listen for attribute changes on the + // outer element + new MutationObserver(function() { + log('mutate'); + }).observe(outer, { + attributes: true + }); + + // Here's a click listener... + function onClick() { + log('click'); + + setTimeout(function() { + log('timeout'); + }, 0); + + Promise.resolve().then(function() { + log('promise'); + }); + + outer.setAttribute('data-random', Math.random()); + } + + // ...which we'll attach to both elements + inner.addEventListener('click', onClick); + outer.addEventListener('click', onClick); +}, [ + 'click', + 'promise', + 'mutate', + 'click', + 'promise', + 'mutate', + 'timeout', + 'timeout' +], 'Level 1 bossfight (manual click)'); + +</script> |