<!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>[211756] 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/211756">211756</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2017-02-06 15:50:39 -0800 (Mon, 06 Feb 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Align [[OwnPropertyKeys]] with the HTML specification for cross-origin Window / Location objects
https://bugs.webkit.org/show_bug.cgi?id=167647
&lt;rdar://problem/30339489&gt;

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

Rebaseline web platform test now that more checks are passing.

* web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt:

Source/WebCore:

Align [[OwnPropertyKeys]] with the HTML specification for cross-origin Window / Location objects:
- https://html.spec.whatwg.org/#windowproxy-ownpropertykeys [1]
- https://html.spec.whatwg.org/#crossoriginownpropertykeys-(-o-) [2]
- https://html.spec.whatwg.org/#crossoriginproperties-(-o-) [3]

In particular, the following changes were made:
- Location:
  - We now return the following symbols as well: @@toStringTag, @@hasInstance,
    @@isConcatSpreadable as per [2].
- Window:
  - We now return the following symbols as well: @@toStringTag, @@hasInstance,
    @@isConcatSpreadable as per [2].
  - We now return the indices of the child browsing contexts as per [1].
  - We now return the names of the child browsing contexts as per [3].

No new tests, updated / rebaselined existing tests.

* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::getOwnPropertySlotByIndex):
Index properties should be configurable as per:
- https://html.spec.whatwg.org/#windowproxy-getownproperty (step 2.5)

(WebCore::inScope):
(WebCore::addScopedChildrenNames):
(WebCore::addCrossOriginPropertyNames):
(WebCore::addScopedChildrenIndexes):
(WebCore::addCrossOriginOwnPropertyNames):
(WebCore::JSDOMWindow::getOwnPropertyNames):
* bindings/js/JSLocationCustom.cpp:
(WebCore::addCrossOriginPropertyNames):
(WebCore::addCrossOriginOwnPropertyNames):
(WebCore::JSLocation::getOwnPropertyNames):

LayoutTests:

Extend test coverage for [[OwnPropertyKeys]] for cross-origin Window / Location objects.

* http/tests/security/cross-frame-access-enumeration-expected.txt:
* http/tests/security/cross-frame-access-enumeration.html:
* http/tests/security/resources/cross-frame-iframe-for-enumeration-test.html:
* js/dom/getOwnPropertyDescriptor-expected.txt:
* js/resources/getOwnPropertyDescriptor.js:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycrossframeaccessenumerationexpectedtxt">trunk/LayoutTests/http/tests/security/cross-frame-access-enumeration-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycrossframeaccessenumerationhtml">trunk/LayoutTests/http/tests/security/cross-frame-access-enumeration.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityresourcescrossframeiframeforenumerationtesthtml">trunk/LayoutTests/http/tests/security/resources/cross-frame-iframe-for-enumeration-test.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersorigincrossoriginobjectscrossoriginobjectsexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsdomgetOwnPropertyDescriptorexpectedtxt">trunk/LayoutTests/js/dom/getOwnPropertyDescriptor-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsresourcesgetOwnPropertyDescriptorjs">trunk/LayoutTests/js/resources/getOwnPropertyDescriptor.js</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMWindowCustomcpp">trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSLocationCustomcpp">trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (211755 => 211756)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-02-06 23:47:51 UTC (rev 211755)
+++ trunk/LayoutTests/ChangeLog        2017-02-06 23:50:39 UTC (rev 211756)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2017-02-06  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Align [[OwnPropertyKeys]] with the HTML specification for cross-origin Window / Location objects
+        https://bugs.webkit.org/show_bug.cgi?id=167647
+        &lt;rdar://problem/30339489&gt;
+
+        Reviewed by Sam Weinig.
+
+        Extend test coverage for [[OwnPropertyKeys]] for cross-origin Window / Location objects.
+
+        * http/tests/security/cross-frame-access-enumeration-expected.txt:
+        * http/tests/security/cross-frame-access-enumeration.html:
+        * http/tests/security/resources/cross-frame-iframe-for-enumeration-test.html:
+        * js/dom/getOwnPropertyDescriptor-expected.txt:
+        * js/resources/getOwnPropertyDescriptor.js:
+
</ins><span class="cx"> 2017-02-06  Yoav Weiss  &lt;yoav@yoav.ws&gt;
</span><span class="cx"> 
</span><span class="cx">         http/tests/preload/dynamic_removing_preload.html fails to test what it should
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycrossframeaccessenumerationexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/cross-frame-access-enumeration-expected.txt (211755 => 211756)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/cross-frame-access-enumeration-expected.txt        2017-02-06 23:47:51 UTC (rev 211755)
+++ trunk/LayoutTests/http/tests/security/cross-frame-access-enumeration-expected.txt        2017-02-06 23:50:39 UTC (rev 211756)
</span><span class="lines">@@ -11,8 +11,10 @@
</span><span class="cx"> PASS: Cross frame access by enumerating the Location object was denied.
</span><span class="cx"> PASS: Cross frame access by getting the keys of the Location object was denied.
</span><span class="cx"> PASS: Cross frame access by getting the property names of the Location object was denied.
</span><del>-PASS: areArraysEqual(Object.getOwnPropertyNames(b_win).sort(), whitelistedWindowProperties.sort()) should be 'true' and is.
-PASS: areArraysEqual(Object.getOwnPropertyNames(b_win.location).sort(), whitelistedLocationProperties.sort()) should be 'true' and is.
</del><ins>+PASS: areArraysEqual(Object.getOwnPropertyNames(b_win), whitelistedWindowProperties) should be 'true' and is.
+PASS: areArraysEqual(Reflect.ownKeys(b_win), whitelistedWindowProperties.concat(whitelistedSymbols)) should be 'true' and is.
+PASS: areArraysEqual(Object.getOwnPropertyNames(b_win.location), whitelistedLocationProperties) should be 'true' and is.
+PASS: areArraysEqual(Reflect.ownKeys(b_win.location), whitelistedLocationProperties.concat(whitelistedSymbols)) should be 'true' and is.
</ins><span class="cx"> PASS: successfullyParsed should be 'true' and is.
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycrossframeaccessenumerationhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/cross-frame-access-enumeration.html (211755 => 211756)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/cross-frame-access-enumeration.html        2017-02-06 23:47:51 UTC (rev 211755)
+++ trunk/LayoutTests/http/tests/security/cross-frame-access-enumeration.html        2017-02-06 23:50:39 UTC (rev 211756)
</span><span class="lines">@@ -85,10 +85,13 @@
</span><span class="cx">             }
</span><span class="cx">             log(&quot;PASS: Cross frame access by getting the property names of the Location object was denied.&quot;);
</span><span class="cx"> 
</span><del>-            whitelistedWindowProperties = ['location', 'postMessage', 'window', 'frames', 'self', 'top', 'parent', 'opener', 'closed', 'close', 'blur', 'focus', 'length'];
</del><ins>+            whitelistedWindowProperties = ['0', '1', '2', 'blur', 'close', 'closed', 'focus', 'frames', 'length', 'location', 'opener', 'parent', 'postMessage', 'self', 'top', 'window', 'frameA', 'frameC'];
</ins><span class="cx">             whitelistedLocationProperties = ['href', 'replace'];
</span><del>-            shouldBeTrue(&quot;areArraysEqual(Object.getOwnPropertyNames(b_win).sort(), whitelistedWindowProperties.sort())&quot;);
-            shouldBeTrue(&quot;areArraysEqual(Object.getOwnPropertyNames(b_win.location).sort(), whitelistedLocationProperties.sort())&quot;);
</del><ins>+            whitelistedSymbols = [Symbol.toStringTag, Symbol.hasInstance, Symbol.isConcatSpreadable];
+            shouldBeTrue(&quot;areArraysEqual(Object.getOwnPropertyNames(b_win), whitelistedWindowProperties)&quot;);
+            shouldBeTrue(&quot;areArraysEqual(Reflect.ownKeys(b_win), whitelistedWindowProperties.concat(whitelistedSymbols))&quot;);
+            shouldBeTrue(&quot;areArraysEqual(Object.getOwnPropertyNames(b_win.location), whitelistedLocationProperties)&quot;);
+            shouldBeTrue(&quot;areArraysEqual(Reflect.ownKeys(b_win.location), whitelistedLocationProperties.concat(whitelistedSymbols))&quot;);
</ins><span class="cx">         }
</span><span class="cx">     &lt;/script&gt;
</span><span class="cx"> &lt;/head&gt;
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityresourcescrossframeiframeforenumerationtesthtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/resources/cross-frame-iframe-for-enumeration-test.html (211755 => 211756)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/resources/cross-frame-iframe-for-enumeration-test.html        2017-02-06 23:47:51 UTC (rev 211755)
+++ trunk/LayoutTests/http/tests/security/resources/cross-frame-iframe-for-enumeration-test.html        2017-02-06 23:50:39 UTC (rev 211756)
</span><span class="lines">@@ -1,3 +1,6 @@
</span><ins>+&lt;iframe src=&quot;blank.html&quot; name=&quot;frameA&quot;&gt;&lt;/iframe&gt;
+&lt;iframe src=&quot;blank.html&quot;&gt;&lt;/iframe&gt;
+&lt;iframe src=&quot;blank.html&quot; name=&quot;frameC&quot;&gt;&lt;/iframe&gt;
</ins><span class="cx"> &lt;script&gt;
</span><span class="cx">     window.customWindowProperty = 1;
</span><span class="cx">     window.history.customHistoryProperty = 1;
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (211755 => 211756)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2017-02-06 23:47:51 UTC (rev 211755)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2017-02-06 23:50:39 UTC (rev 211756)
</span><span class="lines">@@ -1,5 +1,17 @@
</span><span class="cx"> 2017-02-06  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Align [[OwnPropertyKeys]] with the HTML specification for cross-origin Window / Location objects
+        https://bugs.webkit.org/show_bug.cgi?id=167647
+        &lt;rdar://problem/30339489&gt;
+
+        Reviewed by Sam Weinig.
+
+        Rebaseline web platform test now that more checks are passing.
+
+        * web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt:
+
+2017-02-06  Chris Dumez  &lt;cdumez@apple.com&gt;
+
</ins><span class="cx">         Re-sync html/browsers/origin/cross-origin-objects tests
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=167881
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlbrowsersorigincrossoriginobjectscrossoriginobjectsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt (211755 => 211756)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt        2017-02-06 23:47:51 UTC (rev 211755)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt        2017-02-06 23:50:39 UTC (rev 211756)
</span><span class="lines">@@ -15,7 +15,7 @@
</span><span class="cx"> FAIL [[PreventExtensions]] should throw for cross-origin objects (exception type) assert_throws: preventExtensions on cross-origin Location should throw function &quot;function () { Object.preventExtensions(C.location) }&quot; threw object &quot;SecurityError (DOM Exception 18): Blocked a frame with or...&quot; (&quot;SecurityError&quot;) expected object &quot;TypeError&quot; (&quot;TypeError&quot;)
</span><span class="cx"> PASS [[GetOwnProperty]] - Properties on cross-origin objects should be reported |own| 
</span><span class="cx"> PASS [[GetOwnProperty]] - Properties on cross-origin objects should be reported |own| (exception type) 
</span><del>-FAIL [[GetOwnProperty]] - Property descriptors for cross-origin properties should be set up correctly assert_equals: property descriptor for 0 should be configurable expected true but got false
</del><ins>+FAIL [[GetOwnProperty]] - Property descriptors for cross-origin properties should be set up correctly assert_equals: property descriptor for Symbol(Symbol.toStringTag) should be configurable expected true but got false
</ins><span class="cx"> FAIL [[GetOwnProperty]] - Property descriptors for cross-origin properties should be set up correctly (exception type) assert_unreached: Main test failed Reached unreachable code
</span><span class="cx"> PASS [[Delete]] Should throw on cross-origin objects 
</span><span class="cx"> PASS [[Delete]] Should throw on cross-origin objects (exception type) 
</span><span class="lines">@@ -23,12 +23,12 @@
</span><span class="cx"> PASS [[DefineOwnProperty]] Should throw for cross-origin objects (exception type) 
</span><span class="cx"> PASS [[Enumerate]] should return an empty iterator 
</span><span class="cx"> PASS [[Enumerate]] should return an empty iterator (exception type) 
</span><del>-FAIL [[OwnPropertyKeys]] should return all properties from cross-origin objects assert_array_equals: Object.getOwnPropertyNames() gives the right answer for cross-origin Window lengths differ, expected 15 got 13
-FAIL [[OwnPropertyKeys]] should return all properties from cross-origin objects (exception type) assert_unreached: Main test failed Reached unreachable code
-FAIL [[OwnPropertyKeys]] should return the right symbol-named properties for cross-origin objects assert_array_equals: Object.getOwnPropertySymbols() should return the three symbol-named properties that are exposed on a cross-origin Window lengths differ, expected 3 got 0
-FAIL [[OwnPropertyKeys]] should return the right symbol-named properties for cross-origin objects (exception type) assert_unreached: Main test failed Reached unreachable code
-FAIL [[OwnPropertyKeys]] should place the symbols after the property names after the subframe indices assert_array_equals: Reflect.ownKeys should start with the indices exposed on the cross-origin window. property 0, expected &quot;0&quot; but got &quot;blur&quot;
-FAIL [[OwnPropertyKeys]] should place the symbols after the property names after the subframe indices (exception type) assert_unreached: Main test failed Reached unreachable code
</del><ins>+PASS [[OwnPropertyKeys]] should return all properties from cross-origin objects 
+PASS [[OwnPropertyKeys]] should return all properties from cross-origin objects (exception type) 
+PASS [[OwnPropertyKeys]] should return the right symbol-named properties for cross-origin objects 
+PASS [[OwnPropertyKeys]] should return the right symbol-named properties for cross-origin objects (exception type) 
+PASS [[OwnPropertyKeys]] should place the symbols after the property names after the subframe indices 
+PASS [[OwnPropertyKeys]] should place the symbols after the property names after the subframe indices (exception type) 
</ins><span class="cx"> PASS A and B jointly observe the same identity for cross-origin Window and Location 
</span><span class="cx"> PASS A and B jointly observe the same identity for cross-origin Window and Location (exception type) 
</span><span class="cx"> PASS Cross-origin functions get local Function.prototype 
</span></span></pre></div>
<a id="trunkLayoutTestsjsdomgetOwnPropertyDescriptorexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/dom/getOwnPropertyDescriptor-expected.txt (211755 => 211756)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/getOwnPropertyDescriptor-expected.txt        2017-02-06 23:47:51 UTC (rev 211755)
+++ trunk/LayoutTests/js/dom/getOwnPropertyDescriptor-expected.txt        2017-02-06 23:50:39 UTC (rev 211756)
</span><span class="lines">@@ -129,7 +129,7 @@
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 0).hasOwnProperty('get') is false
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 0).hasOwnProperty('set') is false
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(global, 0).enumerable is false
</span><del>-PASS Object.getOwnPropertyDescriptor(global, 0).configurable is false
</del><ins>+PASS Object.getOwnPropertyDescriptor(global, 0).configurable is true
</ins><span class="cx"> PASS Object.getOwnPropertyDescriptor(document.getElementsByTagName('div'), 0).value is document.getElementsByTagName('div')[0]
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(document.getElementsByTagName('div'), 0).hasOwnProperty('get') is false
</span><span class="cx"> PASS Object.getOwnPropertyDescriptor(document.getElementsByTagName('div'), 0).hasOwnProperty('set') is false
</span></span></pre></div>
<a id="trunkLayoutTestsjsresourcesgetOwnPropertyDescriptorjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/resources/getOwnPropertyDescriptor.js (211755 => 211756)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/resources/getOwnPropertyDescriptor.js        2017-02-06 23:47:51 UTC (rev 211755)
+++ trunk/LayoutTests/js/resources/getOwnPropertyDescriptor.js        2017-02-06 23:50:39 UTC (rev 211756)
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx"> var globalWindowGetter = Object.getOwnPropertyDescriptor(global, 'window').get;
</span><span class="cx"> descriptorShouldBe(&quot;global&quot;, &quot;'window'&quot;, {get: 'globalWindowGetter', set: undefined, enumerable: true, configurable: false});
</span><span class="cx"> descriptorShouldBe(&quot;global&quot;, &quot;'XMLHttpRequest'&quot;, {writable: true, enumerable: false, configurable: true, value:&quot;XMLHttpRequest&quot;});
</span><del>-descriptorShouldBe(&quot;global&quot;, &quot;0&quot;, {writable: true, enumerable: false, configurable: false, value:&quot;global[0]&quot;});
</del><ins>+descriptorShouldBe(&quot;global&quot;, &quot;0&quot;, {writable: true, enumerable: false, configurable: true, value:&quot;global[0]&quot;});
</ins><span class="cx"> descriptorShouldBe(&quot;document.getElementsByTagName('div')&quot;, &quot;0&quot;, {writable: false, enumerable: true, configurable: true, value:&quot;document.getElementsByTagName('div')[0]&quot;});
</span><span class="cx"> descriptorShouldBe(&quot;document.getElementsByClassName('pass')&quot;, &quot;0&quot;, {writable: false, enumerable: true, configurable: true, value:&quot;document.getElementsByClassName('pass')[0]&quot;});
</span><span class="cx"> var canvas = document.createElement(&quot;canvas&quot;);
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (211755 => 211756)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-02-06 23:47:51 UTC (rev 211755)
+++ trunk/Source/WebCore/ChangeLog        2017-02-06 23:50:39 UTC (rev 211756)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2017-02-06  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Align [[OwnPropertyKeys]] with the HTML specification for cross-origin Window / Location objects
+        https://bugs.webkit.org/show_bug.cgi?id=167647
+        &lt;rdar://problem/30339489&gt;
+
+        Reviewed by Sam Weinig.
+
+        Align [[OwnPropertyKeys]] with the HTML specification for cross-origin Window / Location objects:
+        - https://html.spec.whatwg.org/#windowproxy-ownpropertykeys [1]
+        - https://html.spec.whatwg.org/#crossoriginownpropertykeys-(-o-) [2]
+        - https://html.spec.whatwg.org/#crossoriginproperties-(-o-) [3]
+
+        In particular, the following changes were made:
+        - Location:
+          - We now return the following symbols as well: @@toStringTag, @@hasInstance,
+            @@isConcatSpreadable as per [2].
+        - Window:
+          - We now return the following symbols as well: @@toStringTag, @@hasInstance,
+            @@isConcatSpreadable as per [2].
+          - We now return the indices of the child browsing contexts as per [1].
+          - We now return the names of the child browsing contexts as per [3].
+
+        No new tests, updated / rebaselined existing tests.
+
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::JSDOMWindow::getOwnPropertySlotByIndex):
+        Index properties should be configurable as per:
+        - https://html.spec.whatwg.org/#windowproxy-getownproperty (step 2.5)
+
+        (WebCore::inScope):
+        (WebCore::addScopedChildrenNames):
+        (WebCore::addCrossOriginPropertyNames):
+        (WebCore::addScopedChildrenIndexes):
+        (WebCore::addCrossOriginOwnPropertyNames):
+        (WebCore::JSDOMWindow::getOwnPropertyNames):
+        * bindings/js/JSLocationCustom.cpp:
+        (WebCore::addCrossOriginPropertyNames):
+        (WebCore::addCrossOriginOwnPropertyNames):
+        (WebCore::JSLocation::getOwnPropertyNames):
+
</ins><span class="cx"> 2017-02-06  Yoav Weiss  &lt;yoav@yoav.ws&gt;
</span><span class="cx"> 
</span><span class="cx">         http/tests/preload/dynamic_removing_preload.html fails to test what it should
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMWindowCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (211755 => 211756)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp        2017-02-06 23:47:51 UTC (rev 211755)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp        2017-02-06 23:50:39 UTC (rev 211756)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> #include &quot;Frame.h&quot;
</span><span class="cx"> #include &quot;HTMLCollection.h&quot;
</span><span class="cx"> #include &quot;HTMLDocument.h&quot;
</span><ins>+#include &quot;HTMLFrameOwnerElement.h&quot;
</ins><span class="cx"> #include &quot;JSDOMBindingSecurity.h&quot;
</span><span class="cx"> #include &quot;JSEvent.h&quot;
</span><span class="cx"> #include &quot;JSEventListener.h&quot;
</span><span class="lines">@@ -223,7 +224,7 @@
</span><span class="cx">     // (1) First, indexed properties.
</span><span class="cx">     // These are also allowed cross-orgin, so come before the access check.
</span><span class="cx">     if (frame &amp;&amp; index &lt; frame-&gt;tree().scopedChildCount()) {
</span><del>-        slot.setValue(thisObject, ReadOnly | DontDelete | DontEnum, toJS(state, frame-&gt;tree().scopedChild(index)-&gt;document()-&gt;domWindow()));
</del><ins>+        slot.setValue(thisObject, ReadOnly | DontEnum, toJS(state, frame-&gt;tree().scopedChild(index)-&gt;document()-&gt;domWindow()));
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -324,9 +325,36 @@
</span><span class="cx">     Base::getPropertyNames(thisObject, exec, propertyNames, mode);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void addCrossOriginWindowPropertyNames(ExecState&amp; state, PropertyNameArray&amp; propertyNames)
</del><ins>+static bool inScope(Frame&amp; frame, TreeScope&amp; scope)
</ins><span class="cx"> {
</span><del>-    // https://html.spec.whatwg.org/#crossoriginproperties-(-o-)
</del><ins>+    auto* document = frame.document();
+    if (!document)
+        return false;
+    auto* owner = document-&gt;ownerElement();
+    return owner &amp;&amp; &amp;owner-&gt;treeScope() == &amp;scope;
+}
+
+static void addScopedChildrenNames(ExecState&amp; state, DOMWindow&amp; window, PropertyNameArray&amp; propertyNames)
+{
+    auto* document = window.document();
+    if (!document)
+        return;
+
+    auto* frame = document-&gt;frame();
+    if (!frame)
+        return;
+
+    for (auto* child = frame-&gt;tree().firstChild(); child; child = child-&gt;tree().nextSibling()) {
+        if (!inScope(*child, *document))
+            continue;
+        if (!child-&gt;tree().name().isEmpty())
+            propertyNames.add(Identifier::fromString(&amp;state, child-&gt;tree().name()));
+    }
+}
+
+// https://html.spec.whatwg.org/#crossoriginproperties-(-o-)
+static void addCrossOriginPropertyNames(ExecState&amp; state, DOMWindow&amp; window, PropertyNameArray&amp; propertyNames)
+{
</ins><span class="cx">     static const Identifier* const properties[] = {
</span><span class="cx">         &amp;state.propertyNames().blur, &amp;state.propertyNames().close, &amp;state.propertyNames().closed,
</span><span class="cx">         &amp;state.propertyNames().focus, &amp;state.propertyNames().frames, &amp;state.propertyNames().length,
</span><span class="lines">@@ -336,14 +364,46 @@
</span><span class="cx">     };
</span><span class="cx">     for (auto* property : properties)
</span><span class="cx">         propertyNames.add(*property);
</span><ins>+
+    addScopedChildrenNames(state, window, propertyNames);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void addScopedChildrenIndexes(ExecState&amp; state, DOMWindow&amp; window, PropertyNameArray&amp; propertyNames)
+{
+    auto* document = window.document();
+    if (!document)
+        return;
+
+    auto* frame = document-&gt;frame();
+    if (!frame)
+        return;
+
+    unsigned scopedChildCount = frame-&gt;tree().scopedChildCount();
+    for (unsigned i = 0; i &lt; scopedChildCount; ++i)
+        propertyNames.add(Identifier::from(&amp;state, i));
+}
+
+// https://html.spec.whatwg.org/#crossoriginownpropertykeys-(-o-)
+static void addCrossOriginOwnPropertyNames(ExecState&amp; state, DOMWindow&amp; window, PropertyNameArray&amp; propertyNames)
+{
+    addCrossOriginPropertyNames(state, window, propertyNames);
+
+    propertyNames.add(state.propertyNames().toStringTagSymbol);
+    propertyNames.add(state.propertyNames().hasInstanceSymbol);
+    propertyNames.add(state.propertyNames().isConcatSpreadableSymbol);
+}
+
+// https://html.spec.whatwg.org/#windowproxy-ownpropertykeys
</ins><span class="cx"> void JSDOMWindow::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray&amp; propertyNames, EnumerationMode mode)
</span><span class="cx"> {
</span><span class="cx">     JSDOMWindow* thisObject = jsCast&lt;JSDOMWindow*&gt;(object);
</span><ins>+
+    if (mode.includeDontEnumProperties())
+        addScopedChildrenIndexes(*exec, thisObject-&gt;wrapped(), propertyNames);
+
</ins><span class="cx">     if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, thisObject-&gt;wrapped(), DoNotReportSecurityError)) {
</span><span class="cx">         if (mode.includeDontEnumProperties())
</span><del>-            addCrossOriginWindowPropertyNames(*exec, propertyNames);
</del><ins>+            addCrossOriginOwnPropertyNames(*exec, thisObject-&gt;wrapped(), propertyNames);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSLocationCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp (211755 => 211756)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp        2017-02-06 23:47:51 UTC (rev 211755)
+++ trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp        2017-02-06 23:50:39 UTC (rev 211756)
</span><span class="lines">@@ -121,20 +121,30 @@
</span><span class="cx">     return Base::deletePropertyByIndex(thisObject, exec, propertyName);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void addCrossOriginLocationPropertyNames(ExecState&amp; state, PropertyNameArray&amp; propertyNames)
</del><ins>+// https://html.spec.whatwg.org/#crossoriginproperties-(-o-)
+static void addCrossOriginPropertyNames(ExecState&amp; state, PropertyNameArray&amp; propertyNames)
</ins><span class="cx"> {
</span><del>-    // https://html.spec.whatwg.org/#crossoriginproperties-(-o-)
</del><span class="cx">     static const Identifier* const properties[] = { &amp;state.propertyNames().href, &amp;state.propertyNames().replace };
</span><span class="cx">     for (auto* property : properties)
</span><span class="cx">         propertyNames.add(*property);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// https://html.spec.whatwg.org/#crossoriginownpropertykeys-(-o-)
+static void addCrossOriginOwnPropertyNames(ExecState&amp; state, PropertyNameArray&amp; propertyNames)
+{
+    addCrossOriginPropertyNames(state, propertyNames);
+
+    propertyNames.add(state.propertyNames().toStringTagSymbol);
+    propertyNames.add(state.propertyNames().hasInstanceSymbol);
+    propertyNames.add(state.propertyNames().isConcatSpreadableSymbol);
+}
+
</ins><span class="cx"> void JSLocation::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray&amp; propertyNames, EnumerationMode mode)
</span><span class="cx"> {
</span><span class="cx">     JSLocation* thisObject = jsCast&lt;JSLocation*&gt;(object);
</span><span class="cx">     if (!BindingSecurity::shouldAllowAccessToFrame(exec, thisObject-&gt;wrapped().frame(), DoNotReportSecurityError)) {
</span><span class="cx">         if (mode.includeDontEnumProperties())
</span><del>-            addCrossOriginLocationPropertyNames(*exec, propertyNames);
</del><ins>+            addCrossOriginOwnPropertyNames(*exec, propertyNames);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
</span></span></pre>
</div>
</div>

</body>
</html>