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.

Given the unforgeable holder object has the same prototype as actual instances
of the interface, the finalize hook needs to check its slot pointer for nullity
before dropping it.

The new failing test isn't related to Unforgeable attributes, but to the fact
that all Document instances currently have a Location, even if their window
isn't in a browsing context.
This commit is contained in:
Anthony Ramine 2015-10-12 14:50:07 +02:00
parent 29c42a9f78
commit 60976406cc
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

@ -6855,9 +6855,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
@ -8490,18 +8487,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
@ -9363,36 +9351,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>