<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[196690] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/196690">196690</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-02-17 00:38:27 -0800 (Wed, 17 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Window should have its 'constructor' property on the prototype
https://bugs.webkit.org/show_bug.cgi?id=154037
&lt;rdar://problem/24689078&gt;

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 &quot;constructor&quot; 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 &quot;constructor&quot; 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. &quot;constructor&quot; 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 &quot;constructor&quot; attribute
on the prototype.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycrossoriginwindowpropertyaccessexpectedtxt">trunk/LayoutTests/http/tests/security/cross-origin-window-property-access-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycrossoriginwindowpropertyaccesshtml">trunk/LayoutTests/http/tests/security/cross-origin-window-property-access.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmldominterfacesexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsgetOwnPropertyDescriptorwindowattributesexpectedtxt">trunk/LayoutTests/js/getOwnPropertyDescriptor-window-attributes-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsgetOwnPropertyDescriptorwindowattributeshtml">trunk/LayoutTests/js/getOwnPropertyDescriptor-window-attributes.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestActiveDOMObjectcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (196689 => 196690)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-02-17 07:18:34 UTC (rev 196689)
+++ trunk/LayoutTests/ChangeLog        2016-02-17 08:38:27 UTC (rev 196690)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2016-02-17  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Window should have its 'constructor' property on the prototype
+        https://bugs.webkit.org/show_bug.cgi?id=154037
+        &lt;rdar://problem/24689078&gt;
+
+        Reviewed by Gavin Barraclough.
+
+        * 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 &quot;constructor&quot; attribute
+        on the prototype.
+
</ins><span class="cx"> 2016-02-16  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add a way to test ScrollAnimator
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycrossoriginwindowpropertyaccessexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/cross-origin-window-property-access-expected.txt (196689 => 196690)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/cross-origin-window-property-access-expected.txt        2016-02-17 07:18:34 UTC (rev 196689)
+++ trunk/LayoutTests/http/tests/security/cross-origin-window-property-access-expected.txt        2016-02-17 08:38:27 UTC (rev 196690)
</span><span class="lines">@@ -3,6 +3,8 @@
</span><span class="cx"> CONSOLE MESSAGE: line 1: Blocked a frame with origin &quot;http://127.0.0.1:8000&quot; from accessing a frame with origin &quot;http://localhost:8000&quot;. Protocols, domains, and ports must match.
</span><span class="cx"> CONSOLE MESSAGE: line 1: Blocked a frame with origin &quot;http://127.0.0.1:8000&quot; from accessing a frame with origin &quot;http://localhost:8000&quot;. Protocols, domains, and ports must match.
</span><span class="cx"> CONSOLE MESSAGE: line 1: Blocked a frame with origin &quot;http://127.0.0.1:8000&quot; from accessing a frame with origin &quot;http://localhost:8000&quot;. Protocols, domains, and ports must match.
</span><ins>+CONSOLE MESSAGE: line 15: Blocked a frame with origin &quot;http://127.0.0.1:8000&quot; from accessing a frame with origin &quot;http://localhost:8000&quot;. Protocols, domains, and ports must match.
+CONSOLE MESSAGE: line 15: Blocked a frame with origin &quot;http://127.0.0.1:8000&quot; from accessing a frame with origin &quot;http://localhost:8000&quot;. Protocols, domains, and ports must match.
</ins><span class="cx"> Tests that using another window's property getter does not bypass cross-origin checks.
</span><span class="cx"> 
</span><span class="cx"> On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
</span><span class="lines">@@ -14,6 +16,10 @@
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(window, &quot;scrollbars&quot;).get.call(crossOriginWindow) returned undefined.
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(window, &quot;navigator&quot;).get.call(crossOriginWindow) returned undefined.
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(window, &quot;screenX&quot;).get.call(crossOriginWindow) returned undefined.
</span><ins>+PASS Object.getOwnPropertyDescriptor(window.__proto__, &quot;constructor&quot;).get.call(crossOriginWindow) threw exception TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(window.__proto__, &quot;constructor&quot;).get.call').
+PASS Object.getOwnPropertyDescriptor(window.__proto__, &quot;constructor&quot;).get.call(crossOriginWindow.__proto__) threw exception TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(window.__proto__, &quot;constructor&quot;).get.call').
+PASS crossOriginWindow.constructor returned undefined.
+PASS Object.getOwnPropertyDescriptor(crossOriginWindow.__proto__, &quot;constructor&quot;).value threw exception TypeError: undefined is not an object (evaluating 'Object.getOwnPropertyDescriptor(crossOriginWindow.__proto__, &quot;constructor&quot;)').
</ins><span class="cx"> PASS Object.getOwnPropertyDescriptor(window, &quot;location&quot;).get.call(crossOriginWindow) === crossOriginWindow.location is true
</span><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycrossoriginwindowpropertyaccesshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/cross-origin-window-property-access.html (196689 => 196690)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/cross-origin-window-property-access.html        2016-02-17 07:18:34 UTC (rev 196689)
+++ trunk/LayoutTests/http/tests/security/cross-origin-window-property-access.html        2016-02-17 08:38:27 UTC (rev 196690)
</span><span class="lines">@@ -32,6 +32,10 @@
</span><span class="cx">     shouldThrowOrReturnUndefined('Object.getOwnPropertyDescriptor(window, &quot;scrollbars&quot;).get.call(crossOriginWindow)');
</span><span class="cx">     shouldThrowOrReturnUndefined('Object.getOwnPropertyDescriptor(window, &quot;navigator&quot;).get.call(crossOriginWindow)');
</span><span class="cx">     shouldThrowOrReturnUndefined('Object.getOwnPropertyDescriptor(window, &quot;screenX&quot;).get.call(crossOriginWindow)');
</span><ins>+    shouldThrowOrReturnUndefined('Object.getOwnPropertyDescriptor(window.__proto__, &quot;constructor&quot;).get.call(crossOriginWindow)');
+    shouldThrowOrReturnUndefined('Object.getOwnPropertyDescriptor(window.__proto__, &quot;constructor&quot;).get.call(crossOriginWindow.__proto__)');
+    shouldThrowOrReturnUndefined('crossOriginWindow.constructor');
+    shouldThrowOrReturnUndefined('Object.getOwnPropertyDescriptor(crossOriginWindow.__proto__, &quot;constructor&quot;).value');
</ins><span class="cx">     shouldBeTrue('Object.getOwnPropertyDescriptor(window, &quot;location&quot;).get.call(crossOriginWindow) === crossOriginWindow.location');
</span><span class="cx">     finishJSTest();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (196689 => 196690)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-02-17 07:18:34 UTC (rev 196689)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-02-17 08:38:27 UTC (rev 196690)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-02-17  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Window should have its 'constructor' property on the prototype
+        https://bugs.webkit.org/show_bug.cgi?id=154037
+        &lt;rdar://problem/24689078&gt;
+
+        Reviewed by Gavin Barraclough.
+
+        Rebaseline W3C test now that one more check is passing.
+
+        * web-platform-tests/html/dom/interfaces-expected.txt:
+
</ins><span class="cx"> 2016-02-16  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Navigator.geolocation should not be marked a [Replaceable] and should be on the prototype
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmldominterfacesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt (196689 => 196690)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt        2016-02-17 07:18:34 UTC (rev 196689)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt        2016-02-17 08:38:27 UTC (rev 196690)
</span><span class="lines">@@ -3811,7 +3811,7 @@
</span><span class="cx"> PASS Window interface object length 
</span><span class="cx"> PASS Window interface object name 
</span><span class="cx"> FAIL Window interface: existence and properties of interface prototype object assert_equals: Class name for prototype of Window.prototype is not &quot;WindowProperties&quot; expected &quot;[object WindowProperties]&quot; but got &quot;[object EventTargetPrototype]&quot;
</span><del>-FAIL Window interface: existence and properties of interface prototype object's &quot;constructor&quot; property assert_own_property: Window.prototype does not have own property &quot;constructor&quot; expected property &quot;constructor&quot; missing
</del><ins>+PASS Window interface: existence and properties of interface prototype object's &quot;constructor&quot; property 
</ins><span class="cx"> PASS Window interface: attribute self 
</span><span class="cx"> PASS Window interface: attribute name 
</span><span class="cx"> FAIL Window interface: attribute history assert_equals: setter must be undefined for readonly attributes expected (undefined) undefined but got (function) function &quot;function history() {
</span></span></pre></div>
<a id="trunkLayoutTestsjsgetOwnPropertyDescriptorwindowattributesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/getOwnPropertyDescriptor-window-attributes-expected.txt (196689 => 196690)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/getOwnPropertyDescriptor-window-attributes-expected.txt        2016-02-17 07:18:34 UTC (rev 196689)
+++ trunk/LayoutTests/js/getOwnPropertyDescriptor-window-attributes-expected.txt        2016-02-17 08:38:27 UTC (rev 196690)
</span><span class="lines">@@ -54,7 +54,7 @@
</span><span class="cx"> PASS descriptor.configurable is true
</span><span class="cx"> PASS descriptor.value is window.Node
</span><span class="cx"> 
</span><del>-* window.constructor
</del><ins>+* window.__proto__.constructor
</ins><span class="cx"> PASS descriptor.enumerable is false
</span><span class="cx"> PASS descriptor.writable is true
</span><span class="cx"> PASS descriptor.configurable is true
</span></span></pre></div>
<a id="trunkLayoutTestsjsgetOwnPropertyDescriptorwindowattributeshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/getOwnPropertyDescriptor-window-attributes.html (196689 => 196690)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/getOwnPropertyDescriptor-window-attributes.html        2016-02-17 07:18:34 UTC (rev 196689)
+++ trunk/LayoutTests/js/getOwnPropertyDescriptor-window-attributes.html        2016-02-17 08:38:27 UTC (rev 196690)
</span><span class="lines">@@ -62,9 +62,8 @@
</span><span class="cx"> shouldBe(&quot;descriptor.value&quot;, &quot;window.Node&quot;);
</span><span class="cx"> 
</span><span class="cx"> debug(&quot;&quot;);
</span><del>-// FIXME: 'constructor' should be on the prototype.
-debug(&quot;* window.constructor&quot;);
-descriptor = Object.getOwnPropertyDescriptor(window, &quot;constructor&quot;);
</del><ins>+debug(&quot;* window.__proto__.constructor&quot;);
+descriptor = Object.getOwnPropertyDescriptor(window.__proto__, &quot;constructor&quot;);
</ins><span class="cx"> shouldBeFalse(&quot;descriptor.enumerable&quot;);
</span><span class="cx"> shouldBeTrue(&quot;descriptor.writable&quot;);
</span><span class="cx"> shouldBeTrue(&quot;descriptor.configurable&quot;);
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (196689 => 196690)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-02-17 07:18:34 UTC (rev 196689)
+++ trunk/Source/WebCore/ChangeLog        2016-02-17 08:38:27 UTC (rev 196690)
</span><span class="lines">@@ -1,3 +1,66 @@
</span><ins>+2016-02-17  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Window should have its 'constructor' property on the prototype
+        https://bugs.webkit.org/show_bug.cgi?id=154037
+        &lt;rdar://problem/24689078&gt;
+
+        Reviewed by Gavin Barraclough.
+
+        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 &quot;constructor&quot; 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 &quot;constructor&quot; 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. &quot;constructor&quot; 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.
+
</ins><span class="cx"> 2016-02-16  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add a way to test ScrollAnimator
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (196689 => 196690)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-02-17 07:18:34 UTC (rev 196689)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2016-02-17 08:38:27 UTC (rev 196690)
</span><span class="lines">@@ -681,16 +681,6 @@
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-sub ConstructorShouldBeOnInstance
-{
-    my $interface = shift;
-
-    # FIXME: constructor should always be on the prototype:
-    # http://www.w3.org/TR/WebIDL/#interface-prototype-object
-    return 1 if $interface-&gt;extendedAttributes-&gt;{&quot;CheckSecurity&quot;};
-    return 0;
-}
-
</del><span class="cx"> sub AttributeShouldBeOnInstanceForCompatibility
</span><span class="cx"> {
</span><span class="cx">     my $interface = shift;
</span><span class="lines">@@ -790,7 +780,6 @@
</span><span class="cx">         $count++ if AttributeShouldBeOnInstance($interface, $attribute);
</span><span class="cx">     }
</span><span class="cx">     $count += InstanceFunctionCount($interface);
</span><del>-    $count++ if ConstructorShouldBeOnInstance($interface);
</del><span class="cx">     return $count;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -802,7 +791,7 @@
</span><span class="cx">         $count++ if !AttributeShouldBeOnInstance($interface, $attribute);
</span><span class="cx">     }
</span><span class="cx">     $count += PrototypeFunctionCount($interface);
</span><del>-    $count++ if !ConstructorShouldBeOnInstance($interface);
</del><ins>+    $count++ if NeedsConstructorProperty($interface);
</ins><span class="cx">     return $count;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1388,18 +1377,15 @@
</span><span class="cx">     # - Add all properties in a hashtable definition
</span><span class="cx">     my $propertyCount = $isInstance ? InstancePropertyCount($interface) : PrototypePropertyCount($interface);
</span><span class="cx"> 
</span><del>-    if (ConstructorShouldBeOnInstance($interface) == $isInstance) {
</del><ins>+    if (!$isInstance &amp;&amp; NeedsConstructorProperty($interface)) {
+        die if !$propertyCount;
+        push(@$hashKeys, &quot;constructor&quot;);
+        my $getter = &quot;js&quot; . $interfaceName . &quot;Constructor&quot;;
+        push(@$hashValue1, $getter);
</ins><span class="cx"> 
</span><del>-        if (NeedsConstructorProperty($interface)) {
-            die if !$propertyCount;
-            push(@$hashKeys, &quot;constructor&quot;);
-            my $getter = &quot;js&quot; . $interfaceName . &quot;Constructor&quot;;
-            push(@$hashValue1, $getter);
-
-            my $setter = &quot;setJS&quot; . $interfaceName . &quot;Constructor&quot;;
-            push(@$hashValue2, $setter);
-            push(@$hashSpecials, &quot;DontEnum&quot;);
-        }
</del><ins>+        my $setter = &quot;setJS&quot; . $interfaceName . &quot;Constructor&quot;;
+        push(@$hashValue2, $setter);
+        push(@$hashSpecials, &quot;DontEnum&quot;);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return 0 if !$propertyCount;
</span><span class="lines">@@ -2523,28 +2509,12 @@
</span><span class="cx">         if (NeedsConstructorProperty($interface)) {
</span><span class="cx">             my $constructorFunctionName = &quot;js&quot; . $interfaceName . &quot;Constructor&quot;;
</span><span class="cx"> 
</span><del>-            if ($interface-&gt;extendedAttributes-&gt;{&quot;CustomProxyToJSObject&quot;}) {
-                push(@implContent, &quot;EncodedJSValue ${constructorFunctionName}(ExecState* state, EncodedJSValue thisValue, PropertyName)\n&quot;);
-                push(@implContent, &quot;{\n&quot;);
-                push(@implContent, &quot;    ${className}* domObject = to${className}(JSValue::decode(thisValue));\n&quot;);
-            } elsif (ConstructorShouldBeOnInstance($interface)) {
-                push(@implContent, &quot;EncodedJSValue ${constructorFunctionName}(ExecState* state, EncodedJSValue thisValue, PropertyName)\n&quot;);
-                push(@implContent, &quot;{\n&quot;);
-                push(@implContent, &quot;    ${className}* domObject = &quot; . GetCastingHelperForThisObject($interface) . &quot;(JSValue::decode(thisValue));\n&quot;);
-            } else {
-                push(@implContent, &quot;EncodedJSValue ${constructorFunctionName}(ExecState* state, EncodedJSValue thisValue, PropertyName)\n&quot;);
-                push(@implContent, &quot;{\n&quot;);
-                push(@implContent, &quot;    ${className}Prototype* domObject = jsDynamicCast&lt;${className}Prototype*&gt;(JSValue::decode(thisValue));\n&quot;);
-            }
</del><ins>+            push(@implContent, &quot;EncodedJSValue ${constructorFunctionName}(ExecState* state, EncodedJSValue thisValue, PropertyName)\n&quot;);
+            push(@implContent, &quot;{\n&quot;);
+            push(@implContent, &quot;    ${className}Prototype* domObject = jsDynamicCast&lt;${className}Prototype*&gt;(JSValue::decode(thisValue));\n&quot;);
</ins><span class="cx">             push(@implContent, &quot;    if (!domObject)\n&quot;);
</span><span class="cx">             push(@implContent, &quot;        return throwVMTypeError(state);\n&quot;);
</span><span class="cx"> 
</span><del>-            if ($interface-&gt;extendedAttributes-&gt;{&quot;CheckSecurity&quot;}) {
-                die if !ConstructorShouldBeOnInstance($interface);
-                push(@implContent, &quot;    if (!BindingSecurity::shouldAllowAccessToDOMWindow(state, domObject-&gt;wrapped()))\n&quot;);
-                push(@implContent, &quot;        return JSValue::encode(jsUndefined());\n&quot;);
-            }
-
</del><span class="cx">             if (!$interface-&gt;extendedAttributes-&gt;{&quot;NoInterfaceObject&quot;}) {
</span><span class="cx">                 push(@implContent, &quot;    return JSValue::encode(${className}::getConstructor(state-&gt;vm(), domObject-&gt;globalObject()));\n&quot;);
</span><span class="cx">             } else {
</span><span class="lines">@@ -2561,25 +2531,11 @@
</span><span class="cx">         push(@implContent, &quot;void ${constructorFunctionName}(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)\n&quot;);
</span><span class="cx">         push(@implContent, &quot;{\n&quot;);
</span><span class="cx">         push(@implContent, &quot;    JSValue value = JSValue::decode(encodedValue);\n&quot;);
</span><del>-        if ($interface-&gt;extendedAttributes-&gt;{&quot;CustomProxyToJSObject&quot;}) {
-            push(@implContent, &quot;    ${className}* domObject = to${className}(JSValue::decode(thisValue));\n&quot;);
-        } elsif (ConstructorShouldBeOnInstance($interface)) {
-            push(@implContent, &quot;    ${className}* domObject = &quot; . GetCastingHelperForThisObject($interface) . &quot;(JSValue::decode(thisValue));\n&quot;);
-        } else {
-            push(@implContent, &quot;    ${className}Prototype* domObject = jsDynamicCast&lt;${className}Prototype*&gt;(JSValue::decode(thisValue));\n&quot;);
-        }
</del><ins>+        push(@implContent, &quot;    ${className}Prototype* domObject = jsDynamicCast&lt;${className}Prototype*&gt;(JSValue::decode(thisValue));\n&quot;);
</ins><span class="cx">         push(@implContent, &quot;    if (UNLIKELY(!domObject)) {\n&quot;);
</span><span class="cx">         push(@implContent, &quot;        throwVMTypeError(state);\n&quot;);
</span><span class="cx">         push(@implContent, &quot;        return;\n&quot;);
</span><span class="cx">         push(@implContent, &quot;    }\n&quot;);
</span><del>-        if ($interface-&gt;extendedAttributes-&gt;{&quot;CheckSecurity&quot;}) {
-            if ($interfaceName eq &quot;DOMWindow&quot;) {
-                push(@implContent, &quot;    if (!BindingSecurity::shouldAllowAccessToDOMWindow(state, domObject-&gt;wrapped()))\n&quot;);
-            } else {
-                push(@implContent, &quot;    if (!shouldAllowAccessToFrame(state, domObject-&gt;wrapped().frame()))\n&quot;);
-            }
-            push(@implContent, &quot;        return;\n&quot;);
-        }
</del><span class="cx"> 
</span><span class="cx">         push(@implContent, &quot;    // Shadowing a built-in constructor\n&quot;);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestActiveDOMObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp (196689 => 196690)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp        2016-02-17 07:18:34 UTC (rev 196689)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp        2016-02-17 08:38:27 UTC (rev 196690)
</span><span class="lines">@@ -73,21 +73,18 @@
</span><span class="cx"> 
</span><span class="cx"> /* Hash table */
</span><span class="cx"> 
</span><del>-static const struct CompactHashIndex JSTestActiveDOMObjectTableIndex[4] = {
-    { 1, -1 },
</del><ins>+static const struct CompactHashIndex JSTestActiveDOMObjectTableIndex[2] = {
</ins><span class="cx">     { 0, -1 },
</span><span class="cx">     { -1, -1 },
</span><del>-    { -1, -1 },
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> static const HashTableValue JSTestActiveDOMObjectTableValues[] =
</span><span class="cx"> {
</span><del>-    { &quot;constructor&quot;, DontEnum, NoIntrinsic, { (intptr_t)static_cast&lt;PropertySlot::GetValueFunc&gt;(jsTestActiveDOMObjectConstructor), (intptr_t) static_cast&lt;PutPropertySlot::PutValueFunc&gt;(setJSTestActiveDOMObjectConstructor) } },
</del><span class="cx">     { &quot;excitingAttr&quot;, ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast&lt;PropertySlot::GetValueFunc&gt;(jsTestActiveDOMObjectExcitingAttr), (intptr_t) static_cast&lt;PutPropertySlot::PutValueFunc&gt;(0) } },
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-static const HashTable JSTestActiveDOMObjectTable = { 2, 3, true, JSTestActiveDOMObjectTableValues, JSTestActiveDOMObjectTableIndex };
</del><ins>+static const HashTable JSTestActiveDOMObjectTable = { 1, 1, true, JSTestActiveDOMObjectTableValues, JSTestActiveDOMObjectTableIndex };
</ins><span class="cx"> template&lt;&gt; JSValue JSTestActiveDOMObjectConstructor::prototypeForStructure(JSC::VM&amp; vm, const JSDOMGlobalObject&amp; globalObject)
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(vm);
</span><span class="lines">@@ -107,6 +104,7 @@
</span><span class="cx"> 
</span><span class="cx"> static const HashTableValue JSTestActiveDOMObjectPrototypeTableValues[] =
</span><span class="cx"> {
</span><ins>+    { &quot;constructor&quot;, DontEnum, NoIntrinsic, { (intptr_t)static_cast&lt;PropertySlot::GetValueFunc&gt;(jsTestActiveDOMObjectConstructor), (intptr_t) static_cast&lt;PutPropertySlot::PutValueFunc&gt;(setJSTestActiveDOMObjectConstructor) } },
</ins><span class="cx">     { &quot;excitingFunction&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestActiveDOMObjectPrototypeFunctionExcitingFunction), (intptr_t) (1) } },
</span><span class="cx">     { &quot;postMessage&quot;, JSC::Function, NoIntrinsic, { (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestActiveDOMObjectPrototypeFunctionPostMessage), (intptr_t) (1) } },
</span><span class="cx"> };
</span><span class="lines">@@ -170,24 +168,20 @@
</span><span class="cx"> 
</span><span class="cx"> EncodedJSValue jsTestActiveDOMObjectConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
</span><span class="cx"> {
</span><del>-    JSTestActiveDOMObject* domObject = jsDynamicCast&lt;JSTestActiveDOMObject*&gt;(JSValue::decode(thisValue));
</del><ins>+    JSTestActiveDOMObjectPrototype* domObject = jsDynamicCast&lt;JSTestActiveDOMObjectPrototype*&gt;(JSValue::decode(thisValue));
</ins><span class="cx">     if (!domObject)
</span><span class="cx">         return throwVMTypeError(state);
</span><del>-    if (!BindingSecurity::shouldAllowAccessToDOMWindow(state, domObject-&gt;wrapped()))
-        return JSValue::encode(jsUndefined());
</del><span class="cx">     return JSValue::encode(JSTestActiveDOMObject::getConstructor(state-&gt;vm(), domObject-&gt;globalObject()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void setJSTestActiveDOMObjectConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
</span><span class="cx"> {
</span><span class="cx">     JSValue value = JSValue::decode(encodedValue);
</span><del>-    JSTestActiveDOMObject* domObject = jsDynamicCast&lt;JSTestActiveDOMObject*&gt;(JSValue::decode(thisValue));
</del><ins>+    JSTestActiveDOMObjectPrototype* domObject = jsDynamicCast&lt;JSTestActiveDOMObjectPrototype*&gt;(JSValue::decode(thisValue));
</ins><span class="cx">     if (UNLIKELY(!domObject)) {
</span><span class="cx">         throwVMTypeError(state);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    if (!shouldAllowAccessToFrame(state, domObject-&gt;wrapped().frame()))
-        return;
</del><span class="cx">     // Shadowing a built-in constructor
</span><span class="cx">     domObject-&gt;putDirect(state-&gt;vm(), state-&gt;propertyNames().constructor, value);
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>