mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255
This commit is contained in:
parent
b2a5225831
commit
1a81b18b9f
12321 changed files with 544385 additions and 6 deletions
|
@ -0,0 +1,47 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML details element API</title>
|
||||
<style>#one, #two { visibility: hidden; }</style>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
|
||||
<!-- Used in parsing tests -->
|
||||
<div id='one'><details></details><details></details></div>
|
||||
<div id='two'><p><details></details></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function makeDetails () {
|
||||
return document.createElement('details');
|
||||
}
|
||||
|
||||
|
||||
// <details>
|
||||
test(function () {
|
||||
var times = document.getElementById('one').getElementsByTagName('details');
|
||||
assert_equals( times.length, 2 );
|
||||
}, 'HTML parsing should locate 2 details elements in this document');
|
||||
|
||||
test(function () {
|
||||
assert_equals( document.getElementById('two').getElementsByTagName('p')[0].innerHTML, '' );
|
||||
}, 'HTML parsing should close an unclosed <p> before <details>');
|
||||
|
||||
test(function () {
|
||||
assert_true( !!window.HTMLDetailsElement );
|
||||
}, 'HTMLDetailsElement should be exposed for prototyping');
|
||||
|
||||
test(function () {
|
||||
assert_true( makeDetails() instanceof window.HTMLDetailsElement);
|
||||
}, 'a dynamically created details element should be instanceof HTMLDetailsElement');
|
||||
|
||||
test(function () {
|
||||
assert_true( document.getElementById('one').getElementsByTagName('details')[0] instanceof window.HTMLDetailsElement);
|
||||
}, 'a details element from the parser should be instanceof HTMLDetailsElement');
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,93 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>The details element</title>
|
||||
<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org">
|
||||
<link rel=help href="https://html.spec.whatwg.org/multipage/#the-details-element">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<details id=details1>
|
||||
<summary>Lorem ipsum</summary>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
|
||||
</details>
|
||||
<details id=details2 open>
|
||||
<summary>Lorem ipsum</summary>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
|
||||
</details>
|
||||
<details id=details3 style="display:none;">
|
||||
<summary>Lorem ipsum</summary>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
|
||||
</details>
|
||||
<details id=details4>
|
||||
</details>
|
||||
<details id=details6>
|
||||
<summary>Lorem ipsum</summary>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
|
||||
</details>
|
||||
<script>
|
||||
var t1 = async_test("Adding open to 'details' should fire a toggle event at the 'details' element"),
|
||||
t2 = async_test("Removing open from 'details' should fire a toggle event at the 'details' element"),
|
||||
t3 = async_test("Adding open to 'details' (display:none) should fire a toggle event at the 'details' element"),
|
||||
t4 = async_test("Adding open from 'details' (no children) should fire a toggle event at the 'details' element"),
|
||||
t6 = async_test("Calling open twice on 'details' fires only one toggle event"),
|
||||
details1 = document.getElementById('details1'),
|
||||
details2 = document.getElementById('details2'),
|
||||
details3 = document.getElementById('details3'),
|
||||
details4 = document.getElementById('details4'),
|
||||
details6 = document.getElementById('details6'),
|
||||
loop=false;
|
||||
|
||||
function testEvent(evt) {
|
||||
assert_true(evt.isTrusted, "event is trusted");
|
||||
assert_false(evt.bubbles, "event doesn't bubble");
|
||||
assert_false(evt.cancelable, "event is not cancelable");
|
||||
assert_equals(Object.getPrototypeOf(evt), Event.prototype, "Prototype of toggle event is Event.prototype");
|
||||
}
|
||||
|
||||
details1.ontoggle = t1.step_func_done(function(evt) {
|
||||
assert_true(details1.open);
|
||||
testEvent(evt)
|
||||
});
|
||||
details1.open = true; // opens details1
|
||||
|
||||
details2.ontoggle = t2.step_func_done(function(evt) {
|
||||
assert_false(details2.open);
|
||||
testEvent(evt);
|
||||
});
|
||||
details2.open = false; // closes details2
|
||||
|
||||
details3.ontoggle = t3.step_func_done(function(evt) {
|
||||
assert_true(details3.open);
|
||||
testEvent(evt);
|
||||
});
|
||||
details3.open = true; // opens details3
|
||||
|
||||
details4.ontoggle = t4.step_func_done(function(evt) {
|
||||
assert_true(details4.open);
|
||||
testEvent(evt);
|
||||
});
|
||||
details4.open = true; // opens details4
|
||||
|
||||
async_test(function(t) {
|
||||
var details5 = document.createElement("details");
|
||||
details5.ontoggle = t.step_func_done(function(evt) {
|
||||
assert_true(details5.open);
|
||||
testEvent(evt);
|
||||
})
|
||||
details5.open = true;
|
||||
}, "Adding open to 'details' (not in the document) should fire a toggle event at the 'details' element");
|
||||
|
||||
details6.open = true;
|
||||
details6.open = false;
|
||||
details6.ontoggle = t6.step_func(function() {
|
||||
if (loop) {
|
||||
assert_unreached("toggle event fired twice");
|
||||
} else {
|
||||
loop = true;
|
||||
}
|
||||
});
|
||||
setTimeout(t6.step_func(function() {
|
||||
assert_true(loop);
|
||||
t6.done();
|
||||
}), 0);
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue