mirror of
https://github.com/servo/servo.git
synced 2025-08-30 01:28:21 +01:00
Doc named getter improvements
This commit is contained in:
parent
4b750ca0d0
commit
e48eac6879
10 changed files with 405 additions and 111 deletions
|
@ -363877,6 +363877,12 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"html/dom/documents/dom-tree-accessors/nameditem-names.html": [
|
||||
[
|
||||
"html/dom/documents/dom-tree-accessors/nameditem-names.html",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"html/dom/documents/resource-metadata-management/document-compatmode-01.html": [
|
||||
[
|
||||
"html/dom/documents/resource-metadata-management/document-compatmode-01.html",
|
||||
|
@ -682171,6 +682177,10 @@
|
|||
"bb024d9e781fc99d4f60d5d50d6a83970c661f6f",
|
||||
"testharness"
|
||||
],
|
||||
"html/dom/documents/dom-tree-accessors/nameditem-names.html": [
|
||||
"3f76d85a1bca783df916b159409a94c30488a2dd",
|
||||
"testharness"
|
||||
],
|
||||
"html/dom/documents/resource-metadata-management/document-compatmode-01.html": [
|
||||
"218a3fe84388111133e493ef50f1dd44f2c60923",
|
||||
"testharness"
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
[nameditem-02.html]
|
||||
type: testharness
|
||||
[If the only named item is an iframe, the contentWindow should be returned.]
|
||||
expected: FAIL
|
||||
|
||||
[If there are two iframes, a collection should be returned.]
|
||||
expected: FAIL
|
||||
|
||||
[If there are an iframe and another element (iframe first), a collection should be returned.]
|
||||
expected: FAIL
|
||||
|
||||
[If there are an iframe and another element (iframe last), a collection should be returned.]
|
||||
expected: FAIL
|
||||
|
||||
[If an iframe has a name and a different id, it should be returned by its name.]
|
||||
expected: FAIL
|
||||
|
||||
[An iframe whose name looks like an array index should work.]
|
||||
expected: FAIL
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
[nameditem-06.html]
|
||||
type: testharness
|
||||
[If there are two imgs, nothing should be returned. (id)]
|
||||
expected: FAIL
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
[nameditem-names.html]
|
||||
type: testharness
|
||||
[An embed name appears in a document's property names if the embed is exposed.]
|
||||
expected: FAIL
|
||||
|
||||
[An object name appears in a document's property names if the object is exposed.]
|
||||
expected: FAIL
|
||||
|
||||
[An object id appears in a document's property names if the object is exposed.]
|
||||
expected: FAIL
|
|
@ -0,0 +1,101 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Named items: supported property names</title>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-nameditem">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<embed name="exposed_embed">
|
||||
<embed name="not_exposed_embed">
|
||||
</embed>
|
||||
</embed>
|
||||
<form name="form">
|
||||
</form>
|
||||
<iframe name="iframe">
|
||||
</iframe>
|
||||
<img name="img">
|
||||
<object name="exposed_object_with_name">
|
||||
<object name="not_exposed_object_with_name">
|
||||
</object>
|
||||
</object>
|
||||
<object id="exposed_object_with_id">
|
||||
<object id="not_exposed_object_with_id">
|
||||
</object>
|
||||
</object>
|
||||
<img name="img_with_id" id="img_id">
|
||||
<img id="img_with_just_id">
|
||||
<template id="template">
|
||||
<img name="img_in_template">
|
||||
</template>
|
||||
<img name="42">
|
||||
<script>
|
||||
var names = Object.getOwnPropertyNames(document);
|
||||
|
||||
test(function() {
|
||||
assert_true(names.includes("exposed_embed"))
|
||||
}, "An embed name appears in a document's property names if the embed is exposed.");
|
||||
|
||||
test(function() {
|
||||
assert_false(names.includes("not_exposed_embed"))
|
||||
}, "An embed name does not appears in a document's property names if the embed is inside another embed.");
|
||||
|
||||
test(function() {
|
||||
assert_true(names.includes("form"))
|
||||
}, "A form name appears in a document's property names.");
|
||||
|
||||
test(function() {
|
||||
assert_true(names.includes("iframe"))
|
||||
}, "An iframe name appears in a document's property names.");
|
||||
|
||||
test(function() {
|
||||
assert_true(names.includes("img"))
|
||||
}, "An img name appears in a document's property names when the img has no id.");
|
||||
|
||||
test(function() {
|
||||
assert_true(names.includes("exposed_object"))
|
||||
}, "An object name appears in a document's property names if the object is exposed.");
|
||||
|
||||
test(function() {
|
||||
assert_true(names.includes("exposed_object_with_id"))
|
||||
}, "An object id appears in a document's property names if the object is exposed.");
|
||||
|
||||
test(function() {
|
||||
assert_false(names.includes("not_exposed_object_with_name"))
|
||||
}, "An object name does not appear in a document's property names if the object is inside another object.");
|
||||
|
||||
test(function() {
|
||||
assert_false(names.includes("not_exposed_object_with_id"))
|
||||
}, "An object id does not appear in a document's property names if the object is inside another object.");
|
||||
|
||||
test(function() {
|
||||
assert_true(names.includes("img_with_id"))
|
||||
}, "An img name appears in a document's property names when the img has an id.");
|
||||
|
||||
test(function() {
|
||||
assert_true(names.includes("img_id"))
|
||||
}, "An img id appears in a document's property names when the img has a name.");
|
||||
|
||||
test(function() {
|
||||
assert_false(names.includes("img_with_just_id"))
|
||||
}, "An img id does not appear in a document's property names when the img has no name.");
|
||||
|
||||
test(function() {
|
||||
assert_true(names.includes("42"))
|
||||
}, "A document's property names can include integer strings.");
|
||||
|
||||
test(function() {
|
||||
assert_false(names.includes("template"))
|
||||
}, "A template name does not appear in a document's property names.");
|
||||
|
||||
test(function() {
|
||||
assert_false(names.includes("img_in_template"))
|
||||
}, "An img name does not appear in a document's property names when the img is in a template's document fragment.");
|
||||
|
||||
test(function() {
|
||||
var form_index = names.indexOf("form");
|
||||
assert_equals(names.indexOf("iframe"), form_index + 1);
|
||||
assert_equals(names.indexOf("img"), form_index + 2);
|
||||
assert_greater_than(names.indexOf("img_id"), names.indexOf("img"));
|
||||
assert_greater_than(names.indexOf("42"), names.indexOf("img_id"));
|
||||
}, "A document's property names appear in tree order.");
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue