Auto merge of #7988 - nox:unforgeable, r=jdm

Implement [Unforgeable]

This is mostly stolen from Gecko. As there, we define the unforgeable members
on an object stored in the slots of the prototype object. They are then copied
onto instance objects when they are instantiated. It should be noted that
proxy objects see their unforgeable memebers defined on their expando object.

Unforgeable attributes aren't properly inherited in codegen (in a similar
fashion as getters and setters as filed in #5875) and require to be redefined
in derived interfaces. Fortunately, there are currently no such interfaces.

No unforgeable members can be included into the TestBinding interfaces for good
measure because they are not compatible with setters.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7988)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-12-03 11:03:05 +05:30
commit 20df7fb7c8
11 changed files with 267 additions and 125 deletions

View file

@ -300,9 +300,6 @@
[Window unforgeable attribute: window]
expected: FAIL
[Window unforgeable attribute: document]
expected: FAIL
[Window unforgeable attribute: location]
expected: FAIL

View file

@ -6846,9 +6846,6 @@
[Window interface: window must inherit property "self" with the proper type (1)]
expected: FAIL
[Window interface: window must have own property "document"]
expected: FAIL
[Window interface: window must inherit property "name" with the proper type (3)]
expected: FAIL
@ -8481,18 +8478,9 @@
[Window interface: window must inherit property "localStorage" with the proper type (124)]
expected: FAIL
[Location interface: window.location must have own property "assign"]
expected: FAIL
[Location interface: calling assign(DOMString) on window.location with too few arguments must throw TypeError]
expected: FAIL
[Location interface: window.location must have own property "replace"]
expected: FAIL
[Location interface: window.location must have own property "reload"]
expected: FAIL
[HTMLOptionElement must be primary interface of new Option()]
expected: FAIL
@ -9351,36 +9339,9 @@
[HTMLAreaElement interface: document.createElement("area") must inherit property "hash" with the proper type (19)]
expected: FAIL
[Location interface: window.location must have own property "href"]
expected: FAIL
[Location interface: window.location must have own property "origin"]
expected: FAIL
[Location interface: window.location must have own property "protocol"]
expected: FAIL
[Location interface: window.location must have own property "host"]
expected: FAIL
[Location interface: window.location must have own property "hostname"]
expected: FAIL
[Location interface: window.location must have own property "port"]
expected: FAIL
[Location interface: window.location must have own property "pathname"]
expected: FAIL
[Location interface: window.location must have own property "search"]
expected: FAIL
[Location interface: window.location must have own property "hash"]
expected: FAIL
[Location interface: calling assign(USVString) on window.location with too few arguments must throw TypeError]
expected: FAIL
[Location interface: calling replace(USVString) on window.location with too few arguments must throw TypeError]
expected: FAIL

View file

@ -1,5 +1,5 @@
[windowproxy.html]
type: testharness
[Unforgeable location]
[document.location is the right thing on non-rendered document]
expected: FAIL

View file

@ -5,6 +5,7 @@
</head>
<body>
<div></div>
<img name="location">
<script>
test(function() {
window.abcd = 15;
@ -23,6 +24,18 @@ test(function() {
test(function() {
assert_own_property(window, 'location')
}, "Unforgeable location");
test(function() {
document.foo
assert_equals(document.location, window.location,
'The <img name="location"> should not override the location getter');
}, "document.location is the right thing");
test(function() {
var doc = new DOMParser().parseFromString("<img name='location'>", "text/html");
assert_equals(doc.location, null,
'The <img name="location"> should not override the location getter on a data document');
}, "document.location is the right thing on non-rendered document");
</script>
</body>
</html>