Window should have its 'constructor' property on the prototype
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Feb 2016 08:38:27 +0000 (08:38 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Feb 2016 08:38:27 +0000 (08:38 +0000)
commit91ac568cc9a735b314b085b1369e458edd4eab5f
treeccd469e155e327ffad61f5f2f527623acfd096e1
parent3b2d38351924df752c710437d81a74962b5409fc
Window should have its 'constructor' property on the prototype
https://bugs.webkit.org/show_bug.cgi?id=154037
<rdar://problem/24689078>

Reviewed by Gavin Barraclough.

LayoutTests/imported/w3c:

Rebaseline W3C test now that one more check is passing.

* web-platform-tests/html/dom/interfaces-expected.txt:

Source/WebCore:

Window should have its 'constructor' property on the prototype as per
the Web IDL specification:
http://heycam.github.io/webidl/#interface-prototype-object

Firefox and Chrome already match the specification.

No new tests, covered by:
- fast/dom/Window/window-constructor-settable.html
- fast/dom/Window/window-constructor.html
- http/tests/security/cross-origin-window-property-access.html
- imported/w3c/web-platform-tests/html/dom/interfaces.html

* bindings/scripts/CodeGeneratorJS.pm:
(ConstructorShouldBeOnInstance): Deleted.
Drop this routine as all constructors are now on the prototype.

(InstancePropertyCount):
Do not account for constructor properties as these can only be
on the prototype now.

(PrototypePropertyCount):
Increment the property count by 1 if the interface has a constructor
property (e.g. [NoInterfaceObject] interfaces do not have one).

(GeneratePropertiesHashTable):
Stop calling ConstructorShouldBeOnInstance() as it no longer exists.
Always generated the "constructor" property if:
1. We are generating the prototype hash table.
and
2. The interface needs a constructor (i.e. not marked as
   [NoInterfaceObject]).

(GenerateImplementation):
- Drop code handling the case where ConstructorShouldBeOnInstance()
  returns true as constructors are not always on the prototype and
  the ConstructorShouldBeOnInstance() routine has been dropped.
- Drop code handling [CustomProxyToJSObject]. Now that the constructor
  is always on the prototype, we never need to cast thisValue to a
  JSDOMWindow (by calling toJSDOMWindow). In the Window case, thisValue
  is now casted to a JSDOMWindowPrototype*, similarly to other interfaces
  so we don't need a special casting function anymore.
- Stop generating security checks. This only impacts Window as it is the
  only interface marked as [CheckSecurity]. The cross-origin checking code
  as it was would not work when "constructor" is on the prototype because
  thisValue is a JSDOMWindowPrototype, not a JSDOMWindow and we have no
  way of getting the wrapped window. Also, the security check is no longer
  needed because:
  1. Accessing crossOriginWindow.constructor will not work now that
     constructor is on the prototype because
     JSDOMWindow::getOwnPropertySlot() already prevents access to the
     prototype in the cross-origin case.
  2. "constructor" is a value property, not a getter/setter. Therefore,
     it is no possible to use the getter/setter from a same origin window
     instance and call it on a cross origin window.

LayoutTests:

* http/tests/security/cross-origin-window-property-access-expected.txt:
* http/tests/security/cross-origin-window-property-access.html:
Add checks to make sure it still is not possible to access
window.constructor cross-origin.

* js/getOwnPropertyDescriptor-window-attributes-expected.txt:
* js/getOwnPropertyDescriptor-window-attributes.html:
Update test now that window has it's "constructor" attribute
on the prototype.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196690 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/http/tests/security/cross-origin-window-property-access-expected.txt
LayoutTests/http/tests/security/cross-origin-window-property-access.html
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt
LayoutTests/js/getOwnPropertyDescriptor-window-attributes-expected.txt
LayoutTests/js/getOwnPropertyDescriptor-window-attributes.html
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp