mirror of
https://github.com/servo/servo.git
synced 2025-08-16 02:45:36 +01:00
Implement DOMStringMap::SupportedPropertyNames and NamedNodeMap::SupportedPropertyNames
This commit is contained in:
parent
f6e3146de2
commit
73c4af626a
7 changed files with 145 additions and 12 deletions
|
@ -13281,6 +13281,14 @@
|
|||
"path": "dom/collections/HTMLCollection-supported-property-names.html",
|
||||
"url": "/dom/collections/HTMLCollection-supported-property-names.html"
|
||||
},
|
||||
{
|
||||
"path": "dom/collections/domstringmap-supported-property-names.html",
|
||||
"url": "/dom/collections/domstringmap-supported-property-names.html"
|
||||
},
|
||||
{
|
||||
"path": "dom/collections/namednodemap-supported-property-names.html",
|
||||
"url": "/dom/collections/namednodemap-supported-property-names.html"
|
||||
},
|
||||
{
|
||||
"path": "dom/events/Event-constants.html",
|
||||
"url": "/dom/events/Event-constants.html"
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
[dataset-enumeration.html]
|
||||
type: testharness
|
||||
[A dataset should be enumeratable.]
|
||||
expected: FAIL
|
||||
|
||||
[Only attributes who qualify as dataset properties should be enumeratable in the dataset.]
|
||||
expected: FAIL
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>DOMStringMap Test: Supported property names</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
|
||||
<div id="edge1" data-="012">Simple</div>
|
||||
|
||||
<div id="edge2" data-id-="012">Simple</div>
|
||||
|
||||
<div id="user" data-id="1234567890" data-user="johndoe" data-date-of-birth>
|
||||
John Doe
|
||||
</div>
|
||||
|
||||
<div id="user2" data-unique-id="1234567890"> Jane Doe </div>
|
||||
|
||||
<div id="user3" data-unique-id="4324324241"> Jim Doe </div>
|
||||
|
||||
<script>
|
||||
|
||||
test(function() {
|
||||
var element = document.querySelector('#edge1');
|
||||
assert_array_equals(Object.getOwnPropertyNames(element.dataset),
|
||||
[""]);
|
||||
}, "Object.getOwnPropertyNames on DOMStringMap, empty data attribute");
|
||||
|
||||
test(function() {
|
||||
var element = document.querySelector('#edge2');
|
||||
assert_array_equals(Object.getOwnPropertyNames(element.dataset),
|
||||
["id-"]);
|
||||
}, "Object.getOwnPropertyNames on DOMStringMap, data attribute trailing hyphen");
|
||||
|
||||
test(function() {
|
||||
var element = document.querySelector('#user');
|
||||
assert_array_equals(Object.getOwnPropertyNames(element.dataset),
|
||||
['id', 'user', 'dateOfBirth']);
|
||||
}, "Object.getOwnPropertyNames on DOMStringMap, multiple data attributes");
|
||||
|
||||
test(function() {
|
||||
var element = document.querySelector('#user2');
|
||||
element.dataset.middleName = "mark";
|
||||
assert_array_equals(Object.getOwnPropertyNames(element.dataset),
|
||||
['uniqueId', 'middleName']);
|
||||
}, "Object.getOwnPropertyNames on DOMStringMap, attribute set on dataset in JS");
|
||||
|
||||
test(function() {
|
||||
var element = document.querySelector('#user3');
|
||||
element.setAttribute("data-age", 30);
|
||||
assert_array_equals(Object.getOwnPropertyNames(element.dataset),
|
||||
['uniqueId', 'age']);
|
||||
}, "Object.getOwnPropertyNames on DOMStringMap, attribute set on element in JS");
|
||||
|
||||
</script>
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>NamedNodeMap Test: Supported property names</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<div id="simple" class="fancy">Simple</div>
|
||||
<input id="result" type="text" value="" width="200px">
|
||||
<script>
|
||||
|
||||
test(function() {
|
||||
var elt = document.querySelector('#simple');
|
||||
assert_array_equals(Object.getOwnPropertyNames(elt.attributes),
|
||||
['0','1','id','class']);
|
||||
}, "Object.getOwnPropertyNames on NamedNodeMap");
|
||||
|
||||
test(function() {
|
||||
var result = document.getElementById("result");
|
||||
assert_array_equals(Object.getOwnPropertyNames(result.attributes),
|
||||
['0','1','2','3','id','type','value','width']);
|
||||
}, "Object.getOwnPropertyNames on NamedNodeMap of input");
|
||||
|
||||
test(function() {
|
||||
var result = document.getElementById("result");
|
||||
result.removeAttribute("width");
|
||||
assert_array_equals(Object.getOwnPropertyNames(result.attributes),
|
||||
['0','1','2','id','type','value']);
|
||||
}, "Object.getOwnPropertyNames on NamedNodeMap after attribute removal");
|
||||
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue