forked from servo/servo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of ownPropertyKeys proxy handler
Generates `SupportedPropertyNames` on DOM structs that should implement it. Most of them are unimplemented now (which can be implemented in later PRs), with the exception of `HTMLCollection`. Also added a couple relevant WPT tests. Closes servo#6390 Closes servo#2215
- Loading branch information
Showing
13 changed files
with
203 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tests/wpt/web-platform-tests/dom/collections/HTMLCollection-supported-property-names.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<link rel=help href=https://dom.spec.whatwg.org/#interface-htmlcollection> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
|
||
<div id=log></div> | ||
|
||
<!-- with no attribute --> | ||
<span></span> | ||
|
||
<!-- with `id` attribute --> | ||
<span id=''></span> | ||
<span id='some-id'></span> | ||
<span id='some-id'></span><!-- to ensure no duplicates --> | ||
|
||
<!-- with `name` attribute --> | ||
<span name=''></span> | ||
<span name='some-name'></span> | ||
<span name='some-name'></span><!-- to ensure no duplicates --> | ||
|
||
<!-- with `name` and `id` attribute --> | ||
<span id='another-id' name='another-name'></span> | ||
|
||
<!-- TODO: test element with `name` that is not in HTML namespace --> | ||
|
||
<script> | ||
test(function () { | ||
var elements = document.getElementsByTagName("span"); | ||
assert_array_equals( | ||
Object.getOwnPropertyNames(elements).sort(), | ||
['0', '1', '2', '3', '4', '5', '6', '7', 'another-id', 'another-name', 'some-id', 'some-name'] | ||
); | ||
}, 'Object.getOwnPropertyNames on HTMLCollection'); | ||
</script> |
56 changes: 56 additions & 0 deletions
56
tests/wpt/web-platform-tests/js/builtins/Object.prototype.getOwnPropertyNames.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<!doctype html> | ||
<title>Object.prototype.getOwnPropertyNames</title> | ||
<link rel=help href=http://es5.github.io/#x15.2.3.4> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
|
||
<div id=log></div> | ||
<script> | ||
test(function () { | ||
var obj = {0: 'a', 1: 'b', 2: 'c'}; | ||
assert_array_equals( | ||
Object.getOwnPropertyNames(obj).sort(), | ||
['0', '1', '2'] | ||
); | ||
}, "object"); | ||
|
||
test(function () { | ||
var arr = ['a', 'b', 'c']; | ||
assert_array_equals( | ||
Object.getOwnPropertyNames(arr).sort(), | ||
['0', '1', '2', 'length'] | ||
); | ||
}, "array-like"); | ||
|
||
test(function () { | ||
var obj = Object.create({}, { | ||
getFoo: { | ||
value: function() { return this.foo; }, | ||
enumerable: false | ||
} | ||
}); | ||
obj.foo = 1; | ||
assert_array_equals( | ||
Object.getOwnPropertyNames(obj).sort(), | ||
['foo', 'getFoo'] | ||
); | ||
}, "non-enumerable property"); | ||
|
||
test(function() { | ||
function ParentClass() {} | ||
ParentClass.prototype.inheritedMethod = function() {}; | ||
|
||
function ChildClass() { | ||
this.prop = 5; | ||
this.method = function() {}; | ||
} | ||
ChildClass.prototype = new ParentClass; | ||
ChildClass.prototype.prototypeMethod = function() {}; | ||
|
||
var obj = new ChildClass; | ||
assert_array_equals( | ||
Object.getOwnPropertyNames(obj).sort(), | ||
['method', 'prop'] | ||
); | ||
}, 'items on the prototype chain are not listed'); | ||
</script> |