<!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>[204953] 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/204953">204953</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-08-24 20:06:50 -0700 (Wed, 24 Aug 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Location.toString() should be enumerable
https://bugs.webkit.org/show_bug.cgi?id=161179

Reviewed by Geoffrey Garen.

Source/WebCore:

Location.toString() should be enumerable as per:
- https://html.spec.whatwg.org/#location
- http://heycam.github.io/webidl/#es-stringifier

This patch stops hard-coding the toString() operation on the Location
interface and makes the 'href' attribute a stringifier attribute instead,
as per the specification. The generated toString() has the same behavior
as it used to but it is now enumerable, as it should.

No new tests, updated existing test.

* bindings/js/JSLocationCustom.cpp:
(WebCore::JSLocation::toStringFunction): Deleted.
* page/Location.idl:

LayoutTests:

Update existing tests and add layout test coverage.

* fast/dom/Window/window-appendages-cleared-expected.txt:
* fast/dom/toString_attributes-expected.txt:
* fast/dom/toString_attributes.html:
* js/dom/toString-dontEnum-expected.txt:
* js/dom/toString-dontEnum.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastdomWindowwindowappendagesclearedexpectedtxt">trunk/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomtoString_attributesexpectedtxt">trunk/LayoutTests/fast/dom/toString_attributes-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomtoString_attributeshtml">trunk/LayoutTests/fast/dom/toString_attributes.html</a></li>
<li><a href="#trunkLayoutTestsjsdomtoStringdontEnumexpectedtxt">trunk/LayoutTests/js/dom/toString-dontEnum-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsdomtoStringdontEnumhtml">trunk/LayoutTests/js/dom/toString-dontEnum.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSLocationCustomcpp">trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorepageLocationidl">trunk/Source/WebCore/page/Location.idl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (204952 => 204953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-08-25 02:40:55 UTC (rev 204952)
+++ trunk/LayoutTests/ChangeLog        2016-08-25 03:06:50 UTC (rev 204953)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-08-24  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Location.toString() should be enumerable
+        https://bugs.webkit.org/show_bug.cgi?id=161179
+
+        Reviewed by Geoffrey Garen.
+
+        Update existing tests and add layout test coverage.
+
+        * fast/dom/Window/window-appendages-cleared-expected.txt:
+        * fast/dom/toString_attributes-expected.txt:
+        * fast/dom/toString_attributes.html:
+        * js/dom/toString-dontEnum-expected.txt:
+        * js/dom/toString-dontEnum.html:
+
</ins><span class="cx"> 2016-08-24  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Implement `CSS.escape` as per CSSOM
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomWindowwindowappendagesclearedexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt (204952 => 204953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt        2016-08-25 02:40:55 UTC (rev 204952)
+++ trunk/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt        2016-08-25 03:06:50 UTC (rev 204953)
</span><span class="lines">@@ -18,6 +18,7 @@
</span><span class="cx"> PASS location.reload == &quot;LEFTOVER&quot; is false
</span><span class="cx"> PASS location.replace == &quot;LEFTOVER&quot; is false
</span><span class="cx"> PASS location.search == &quot;LEFTOVER&quot; is false
</span><ins>+PASS location.toString == &quot;LEFTOVER&quot; is false
</ins><span class="cx"> PASS locationbar.visible == &quot;LEFTOVER&quot; is false
</span><span class="cx"> PASS menubar.visible == &quot;LEFTOVER&quot; is false
</span><span class="cx"> PASS personalbar.visible == &quot;LEFTOVER&quot; is false
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomtoString_attributesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/toString_attributes-expected.txt (204952 => 204953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/toString_attributes-expected.txt        2016-08-25 02:40:55 UTC (rev 204952)
+++ trunk/LayoutTests/fast/dom/toString_attributes-expected.txt        2016-08-25 03:06:50 UTC (rev 204953)
</span><span class="lines">@@ -5,15 +5,21 @@
</span><span class="cx"> 
</span><span class="cx"> * HTMLAnchorElement
</span><span class="cx"> PASS descriptor.value is an instance of Function
</span><del>-PASS descriptor.writable is true
</del><ins>+PASS descriptor.writable is !unforgeable
</ins><span class="cx"> PASS descriptor.enumerable is true
</span><del>-PASS descriptor.configurable is true
</del><ins>+PASS descriptor.configurable is !unforgeable
</ins><span class="cx"> 
</span><span class="cx"> * HTMLAreaElement
</span><span class="cx"> PASS descriptor.value is an instance of Function
</span><del>-PASS descriptor.writable is true
</del><ins>+PASS descriptor.writable is !unforgeable
</ins><span class="cx"> PASS descriptor.enumerable is true
</span><del>-PASS descriptor.configurable is true
</del><ins>+PASS descriptor.configurable is !unforgeable
+
+* Location
+PASS descriptor.value is an instance of Function
+PASS descriptor.writable is !unforgeable
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is !unforgeable
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomtoString_attributeshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/toString_attributes.html (204952 => 204953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/toString_attributes.html        2016-08-25 02:40:55 UTC (rev 204952)
+++ trunk/LayoutTests/fast/dom/toString_attributes.html        2016-08-25 03:06:50 UTC (rev 204953)
</span><span class="lines">@@ -5,23 +5,28 @@
</span><span class="cx"> &lt;script&gt;
</span><span class="cx"> description(&quot;Test that the toString() stringifier has the right attributes&quot;);
</span><span class="cx"> 
</span><del>-function testStringifier(object)
</del><ins>+function testStringifier(object, isUnforgeable)
</ins><span class="cx"> {
</span><del>-    descriptor = Object.getOwnPropertyDescriptor(object.__proto__, &quot;toString&quot;);
</del><ins>+    unforgeable = isUnforgeable;
+    descriptor = Object.getOwnPropertyDescriptor(unforgeable ? object : object.__proto__, &quot;toString&quot;);
</ins><span class="cx">     shouldBeType(&quot;descriptor.value&quot;, &quot;Function&quot;);
</span><del>-    shouldBeTrue(&quot;descriptor.writable&quot;);
</del><ins>+    shouldBe(&quot;descriptor.writable&quot;, &quot;!unforgeable&quot;);
</ins><span class="cx">     shouldBeTrue(&quot;descriptor.enumerable&quot;);
</span><del>-    shouldBeTrue(&quot;descriptor.configurable&quot;);
</del><ins>+    shouldBe(&quot;descriptor.configurable&quot;, &quot;!unforgeable&quot;);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> debug(&quot;* HTMLAnchorElement&quot;);
</span><span class="cx"> var anchor = document.createElement(&quot;a&quot;);
</span><del>-testStringifier(anchor);
</del><ins>+testStringifier(anchor, false);
</ins><span class="cx"> 
</span><span class="cx"> debug(&quot;&quot;);
</span><span class="cx"> debug(&quot;* HTMLAreaElement&quot;);
</span><span class="cx"> var area = document.createElement(&quot;area&quot;);
</span><del>-testStringifier(area);
</del><ins>+testStringifier(area, false);
+
+debug(&quot;&quot;);
+debug(&quot;* Location&quot;);
+testStringifier(window.location, true);
</ins><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
</span><span class="cx"> &lt;/body&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsjsdomtoStringdontEnumexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/dom/toString-dontEnum-expected.txt (204952 => 204953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/toString-dontEnum-expected.txt        2016-08-25 02:40:55 UTC (rev 204952)
+++ trunk/LayoutTests/js/dom/toString-dontEnum-expected.txt        2016-08-25 03:06:50 UTC (rev 204953)
</span><span class="lines">@@ -1,6 +1,5 @@
</span><span class="cx"> This tests that the toString() function does not enumerate.
</span><span class="cx"> 
</span><del>-PASS: the toString function is not enumerable for Location.
</del><span class="cx"> PASS: the toString function is not enumerable for Selection.
</span><span class="cx"> PASS: the toString function is not enumerable for HTMLDivElement.
</span><span class="cx"> PASS: the toString function is not enumerable for HTMLDocument.
</span></span></pre></div>
<a id="trunkLayoutTestsjsdomtoStringdontEnumhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/dom/toString-dontEnum.html (204952 => 204953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/toString-dontEnum.html        2016-08-25 02:40:55 UTC (rev 204952)
+++ trunk/LayoutTests/js/dom/toString-dontEnum.html        2016-08-25 03:06:50 UTC (rev 204953)
</span><span class="lines">@@ -25,7 +25,6 @@
</span><span class="cx">                 testRunner.dumpAsText();
</span><span class="cx"> 
</span><span class="cx">             // DOM objects with custom toString() functions
</span><del>-            test(window.location, &quot;Location&quot;);
</del><span class="cx">             test(window.getSelection(), &quot;Selection&quot;);
</span><span class="cx"> 
</span><span class="cx">             // Other DOM objects
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (204952 => 204953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-08-25 02:40:55 UTC (rev 204952)
+++ trunk/Source/WebCore/ChangeLog        2016-08-25 03:06:50 UTC (rev 204953)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2016-08-24  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Location.toString() should be enumerable
+        https://bugs.webkit.org/show_bug.cgi?id=161179
+
+        Reviewed by Geoffrey Garen.
+
+        Location.toString() should be enumerable as per:
+        - https://html.spec.whatwg.org/#location
+        - http://heycam.github.io/webidl/#es-stringifier
+
+        This patch stops hard-coding the toString() operation on the Location
+        interface and makes the 'href' attribute a stringifier attribute instead,
+        as per the specification. The generated toString() has the same behavior
+        as it used to but it is now enumerable, as it should.
+
+        No new tests, updated existing test.
+
+        * bindings/js/JSLocationCustom.cpp:
+        (WebCore::JSLocation::toStringFunction): Deleted.
+        * page/Location.idl:
+
</ins><span class="cx"> 2016-08-24  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Implement `CSS.escape` as per CSSOM
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSLocationCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp (204952 => 204953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp        2016-08-25 02:40:55 UTC (rev 204952)
+++ trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp        2016-08-25 03:06:50 UTC (rev 204953)
</span><span class="lines">@@ -113,15 +113,6 @@
</span><span class="cx">     return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSValue JSLocation::toStringFunction(ExecState&amp; state)
-{
-    Frame* frame = wrapped().frame();
-    if (!frame || !shouldAllowAccessToFrame(&amp;state, frame))
-        return jsUndefined();
-
-    return jsStringWithCache(&amp;state, wrapped().toString());
-}
-
</del><span class="cx"> bool JSLocationPrototype::putDelegate(ExecState* exec, PropertyName propertyName, JSValue, PutPropertySlot&amp;, bool&amp; putResult)
</span><span class="cx"> {
</span><span class="cx">     putResult = false;
</span></span></pre></div>
<a id="trunkSourceWebCorepageLocationidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Location.idl (204952 => 204953)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Location.idl        2016-08-25 02:40:55 UTC (rev 204952)
+++ trunk/Source/WebCore/page/Location.idl        2016-08-25 03:06:50 UTC (rev 204953)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx">     JSCustomNamedGetterOnPrototype,
</span><span class="cx">     Unforgeable,
</span><span class="cx"> ] interface Location {
</span><del>-    [SetterCallWith=ActiveWindow&amp;FirstWindow] attribute USVString href;
</del><ins>+    [SetterCallWith=ActiveWindow&amp;FirstWindow] stringifier attribute USVString href;
</ins><span class="cx"> 
</span><span class="cx">     [CallWith=ActiveWindow&amp;FirstWindow, ForwardDeclareInHeader] void assign(USVString url);
</span><span class="cx">     [DoNotCheckSecurity, CallWith=ActiveWindow&amp;FirstWindow, ForwardDeclareInHeader] void replace(USVString url);
</span><span class="lines">@@ -57,8 +57,4 @@
</span><span class="cx"> 
</span><span class="cx">     // FIXME: Add support for SameObject
</span><span class="cx">     [Unforgeable, CachedAttribute] readonly attribute FrozenArray&lt;USVString&gt; ancestorOrigins;
</span><del>-
-#if !(defined(LANGUAGE_GOBJECT) &amp;&amp; LANGUAGE_GOBJECT)
-    [NotEnumerable, Custom, ImplementedAs=toStringFunction] DOMString toString();
-#endif
</del><span class="cx"> };
</span></span></pre>
</div>
</div>

</body>
</html>