<!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>[205409] 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/205409">205409</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-09-03 15:50:55 -0700 (Sat, 03 Sep 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Align cross-Origin Object.getOwnPropertyNames() with the HTML specification
https://bugs.webkit.org/show_bug.cgi?id=161457
Reviewed by Darin Adler.
Source/WebCore:
Align cross-Origin Object.getOwnPropertyNames() with the HTML specification:
- https://html.spec.whatwg.org/#windowproxy-ownpropertykeys
- https://html.spec.whatwg.org/#location-ownpropertykeys
- https://html.spec.whatwg.org/#crossoriginproperties-(-o-)
We should list cross origin properties.
Firefox complies with the specification. However, WebKit was returning an
empty array and logs a security error message.
No new tests, updated existing test.
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::addCrossOriginPropertyNames):
(WebCore::JSDOMWindow::getOwnPropertyNames):
* bindings/js/JSLocationCustom.cpp:
(WebCore::addCrossOriginPropertyNames):
(WebCore::JSLocation::getOwnPropertyNames):
LayoutTests:
Add test coverage.
* http/tests/security/cross-frame-access-enumeration-expected.txt:
* http/tests/security/cross-frame-access-enumeration.html:</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="#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 (205408 => 205409)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-09-03 21:32:45 UTC (rev 205408)
+++ trunk/LayoutTests/ChangeLog        2016-09-03 22:50:55 UTC (rev 205409)
</span><span class="lines">@@ -1,5 +1,17 @@
</span><span class="cx"> 2016-09-03 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><ins>+ Align cross-Origin Object.getOwnPropertyNames() with the HTML specification
+ https://bugs.webkit.org/show_bug.cgi?id=161457
+
+ Reviewed by Darin Adler.
+
+ Add test coverage.
+
+ * http/tests/security/cross-frame-access-enumeration-expected.txt:
+ * http/tests/security/cross-frame-access-enumeration.html:
+
+2016-09-03 Chris Dumez <cdumez@apple.com>
+
</ins><span class="cx"> Object.preventExtensions(window) should throw a TypeError
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=161554
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycrossframeaccessenumerationexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/cross-frame-access-enumeration-expected.txt (205408 => 205409)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/cross-frame-access-enumeration-expected.txt        2016-09-03 21:32:45 UTC (rev 205408)
+++ trunk/LayoutTests/http/tests/security/cross-frame-access-enumeration-expected.txt        2016-09-03 22:50:55 UTC (rev 205409)
</span><span class="lines">@@ -1,13 +1,10 @@
</span><del>-CONSOLE MESSAGE: line 29: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
-CONSOLE MESSAGE: line 29: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
-CONSOLE MESSAGE: line 48: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
-CONSOLE MESSAGE: line 55: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
-CONSOLE MESSAGE: line 29: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
-CONSOLE MESSAGE: line 75: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
-CONSOLE MESSAGE: line 82: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
-This tests that variable names can't be enumerated cross domain (see http://bugs.webkit.org/show_bug.cgi?id=16387)
</del><ins>+CONSOLE MESSAGE: line 28: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
+CONSOLE MESSAGE: line 28: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
+Tests enumeration of Window / Location properties cross origin.
</ins><span class="cx">
</span><ins>+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> PASS: Cross frame access by enumerating the window object was denied.
</span><span class="cx"> PASS: Cross frame access by getting the keys of the window object was denied.
</span><span class="cx"> PASS: Cross frame access by getting the property names of the window object was denied.
</span><span class="lines">@@ -14,4 +11,9 @@
</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><ins>+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.
+PASS: successfullyParsed should be 'true' and is.
</ins><span class="cx">
</span><ins>+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycrossframeaccessenumerationhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/cross-frame-access-enumeration.html (205408 => 205409)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/cross-frame-access-enumeration.html        2016-09-03 21:32:45 UTC (rev 205408)
+++ trunk/LayoutTests/http/tests/security/cross-frame-access-enumeration.html        2016-09-03 22:50:55 UTC (rev 205409)
</span><span class="lines">@@ -1,15 +1,14 @@
</span><span class="cx"> <html>
</span><span class="cx"> <head>
</span><ins>+ <script src='/resources/js-test-pre.js'></script>
</ins><span class="cx"> <script src="resources/cross-frame-access.js"></script>
</span><span class="cx"> <script>
</span><ins>+ description("Tests enumeration of Window / Location properties cross origin.");
+ jsTestIsAsync = true;
+
</ins><span class="cx"> window.onload = function()
</span><span class="cx"> {
</span><span class="cx"> if (window.testRunner) {
</span><del>- testRunner.dumpAsText();
- testRunner.waitUntilDone();
- }
-
- if (window.testRunner) {
</del><span class="cx"> setTimeout(pollForTest, 1);
</span><span class="cx"> } else {
</span><span class="cx"> log("To run the test, click the button below when the frame finishes loading.");
</span><span class="lines">@@ -27,13 +26,13 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx"> runTest();
</span><del>- testRunner.notifyDone();
</del><ins>+ finishJSTest();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> runTest = function()
</span><span class="cx"> {
</span><span class="cx"> // Test enumerating the Window object
</span><del>- var b_win = document.getElementsByTagName("iframe")[0].contentWindow;
</del><ins>+ b_win = document.getElementsByTagName("iframe")[0].contentWindow;
</ins><span class="cx"> try {
</span><span class="cx"> for (var k in b_win) {
</span><span class="cx"> if (k == "customWindowProperty") {
</span><span class="lines">@@ -85,12 +84,16 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx"> log("PASS: Cross frame access by getting the property names of the Location object was denied.");
</span><ins>+
+ whitelistedWindowProperties = ['location', 'postMessage', 'window', 'frames', 'self', 'top', 'parent', 'opener', 'closed', 'close', 'blur', 'focus', 'length'];
+ whitelistedLocationProperties = ['href', 'replace'];
+ shouldBeTrue("areArraysEqual(Object.getOwnPropertyNames(b_win).sort(), whitelistedWindowProperties.sort())");
+ shouldBeTrue("areArraysEqual(Object.getOwnPropertyNames(b_win.location).sort(), whitelistedLocationProperties.sort())");
</ins><span class="cx"> }
</span><span class="cx"> </script>
</span><span class="cx"> </head>
</span><span class="cx"> <body>
</span><del>- <p>This tests that variable names can't be enumerated cross domain (see http://bugs.webkit.org/show_bug.cgi?id=16387)</p>
</del><span class="cx"> <iframe src="http://localhost:8000/security/resources/cross-frame-iframe-for-enumeration-test.html"></iframe>
</span><del>- <pre id="console"></pre>
</del><ins>+ <script src='/resources/js-test-post.js'></script>
</ins><span class="cx"> </body>
</span><span class="cx"> </html>
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (205408 => 205409)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-03 21:32:45 UTC (rev 205408)
+++ trunk/Source/WebCore/ChangeLog        2016-09-03 22:50:55 UTC (rev 205409)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2016-09-03 Chris Dumez <cdumez@apple.com>
+
+ Align cross-Origin Object.getOwnPropertyNames() with the HTML specification
+ https://bugs.webkit.org/show_bug.cgi?id=161457
+
+ Reviewed by Darin Adler.
+
+ Align cross-Origin Object.getOwnPropertyNames() with the HTML specification:
+ - https://html.spec.whatwg.org/#windowproxy-ownpropertykeys
+ - https://html.spec.whatwg.org/#location-ownpropertykeys
+ - https://html.spec.whatwg.org/#crossoriginproperties-(-o-)
+
+ We should list cross origin properties.
+
+ Firefox complies with the specification. However, WebKit was returning an
+ empty array and logs a security error message.
+
+ No new tests, updated existing test.
+
+ * bindings/js/JSDOMWindowCustom.cpp:
+ (WebCore::addCrossOriginPropertyNames):
+ (WebCore::JSDOMWindow::getOwnPropertyNames):
+ * bindings/js/JSLocationCustom.cpp:
+ (WebCore::addCrossOriginPropertyNames):
+ (WebCore::JSLocation::getOwnPropertyNames):
+
</ins><span class="cx"> 2016-09-03 Frédéric Wang <fwang@igalia.com>
</span><span class="cx">
</span><span class="cx"> Constructors of MathML renderers should only accept MathMLPresentationElement-derived classes
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMWindowCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (205408 => 205409)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp        2016-09-03 21:32:45 UTC (rev 205408)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp        2016-09-03 22:50:55 UTC (rev 205409)
</span><span class="lines">@@ -319,12 +319,27 @@
</span><span class="cx"> Base::getPropertyNames(thisObject, exec, propertyNames, mode);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static void addCrossOriginWindowPropertyNames(ExecState& state, PropertyNameArray& propertyNames)
+{
+ // https://html.spec.whatwg.org/#crossoriginproperties-(-o-)
+ static const Identifier* properties[] = {
+ &state.propertyNames().blur, &state.propertyNames().close, &state.propertyNames().closed,
+ &state.propertyNames().focus, &state.propertyNames().frames, &state.propertyNames().length,
+ &state.propertyNames().location, &state.propertyNames().opener, &state.propertyNames().parent,
+ &state.propertyNames().postMessage, &state.propertyNames().self, &state.propertyNames().top,
+ &state.propertyNames().window
+ };
+ for (auto* property : properties)
+ propertyNames.add(*property);
+}
+
</ins><span class="cx"> void JSDOMWindow::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
</span><span class="cx"> {
</span><span class="cx"> JSDOMWindow* thisObject = jsCast<JSDOMWindow*>(object);
</span><del>- // Only allow the window to enumerated by frames in the same origin.
- if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, thisObject->wrapped()))
</del><ins>+ if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, thisObject->wrapped(), DoNotReportSecurityError)) {
+ addCrossOriginWindowPropertyNames(*exec, propertyNames);
</ins><span class="cx"> return;
</span><ins>+ }
</ins><span class="cx"> Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSLocationCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp (205408 => 205409)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp        2016-09-03 21:32:45 UTC (rev 205408)
+++ trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp        2016-09-03 22:50:55 UTC (rev 205409)
</span><span class="lines">@@ -108,12 +108,21 @@
</span><span class="cx"> return Base::deletePropertyByIndex(thisObject, exec, propertyName);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static void addCrossOriginLocationPropertyNames(ExecState& state, PropertyNameArray& propertyNames)
+{
+ // https://html.spec.whatwg.org/#crossoriginproperties-(-o-)
+ static const Identifier* properties[] = { &state.propertyNames().href, &state.propertyNames().replace };
+ for (auto* property : properties)
+ propertyNames.add(*property);
+}
+
</ins><span class="cx"> void JSLocation::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
</span><span class="cx"> {
</span><span class="cx"> JSLocation* thisObject = jsCast<JSLocation*>(object);
</span><del>- // Only allow the location object to enumerated by frames in the same origin.
- if (!shouldAllowAccessToFrame(exec, thisObject->wrapped().frame()))
</del><ins>+ if (!BindingSecurity::shouldAllowAccessToFrame(exec, thisObject->wrapped().frame(), DoNotReportSecurityError)) {
+ addCrossOriginLocationPropertyNames(*exec, propertyNames);
</ins><span class="cx"> return;
</span><ins>+ }
</ins><span class="cx"> Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>