mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Update web-platform-tests to revision 71a0d51d14d8b0f1b53cda3a7d39ef8765164485
This commit is contained in:
parent
d504015496
commit
163009575a
290 changed files with 2928 additions and 972 deletions
|
@ -0,0 +1,20 @@
|
|||
// Helper for tests that just want to verify the ordering of a series of events.
|
||||
// Usage:
|
||||
// log_test(function(t, log) {
|
||||
// log('first');
|
||||
// log('second');
|
||||
// }, ['first', 'second'], 'Ordinal numbers are ordinal');
|
||||
|
||||
function log_test(func, expected, description) {
|
||||
async_test(function(t) {
|
||||
var actual = [];
|
||||
function log(entry) {
|
||||
actual.push(entry);
|
||||
if (expected.length <= actual.length) {
|
||||
assert_array_equals(actual, expected);
|
||||
t.done();
|
||||
}
|
||||
}
|
||||
func(t, t.step_func(log));
|
||||
}, description);
|
||||
}
|
|
@ -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/webappapis.html#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>
|
|
@ -0,0 +1,85 @@
|
|||
<!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/webappapis.html#event-loops">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/common.js"></script>
|
||||
|
||||
<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) {
|
||||
log('script start');
|
||||
|
||||
setTimeout(function() {
|
||||
log('setTimeout');
|
||||
}, 0);
|
||||
|
||||
Promise.resolve().then(function() {
|
||||
log('promise1');
|
||||
}).then(function() {
|
||||
log('promise2');
|
||||
});
|
||||
|
||||
log('script end');
|
||||
}, [
|
||||
'script start',
|
||||
'script end',
|
||||
'promise1',
|
||||
'promise2',
|
||||
'setTimeout'
|
||||
], 'Basic task and microtask ordering');
|
||||
|
||||
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);
|
||||
|
||||
// Note that this will behave differently than a real click,
|
||||
// since the dispatch is synchronous and microtasks will not
|
||||
// run between event bubbling steps.
|
||||
inner.click();
|
||||
}, [
|
||||
'click',
|
||||
'click',
|
||||
'promise',
|
||||
'mutate',
|
||||
'promise',
|
||||
'timeout',
|
||||
'timeout'
|
||||
], 'Level 1 bossfight (synthetic click)');
|
||||
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue