<!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>[203487] 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/203487">203487</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-07-20 20:30:48 -0700 (Wed, 20 Jul 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix null handling of several Document attributes
https://bugs.webkit.org/show_bug.cgi?id=159997

Reviewed by Ryosuke Niwa.

Source/WebCore:

Fix null handling of the following Document attributes: title, cookie
and domain.

In WebKit, they were all marked as [TreatNullAs=EmptyString], which
does not match the specification:
- https://html.spec.whatwg.org/multipage/dom.html#document

Details for each attribute:
- title: null is now treated as the string &quot;null&quot;, thus setting the
  document title to &quot;null&quot;. This matches Firefox and Chrome.
- cookie: adds a &quot;null&quot; cookie instead of being a no-op. This matches
          both Firefox and Chrome.
- domain: Calls setDomain(String(&quot;null&quot;)) instead of
          setDomain(String()). This throws an exception because &quot;null&quot;
          is not a suffix of the effective domain name. The behavior
          is the same in Firefox and Chrome. Previously, we were
          already throwing an exception since setting the domain to
          the empty string throws, as per the specification.

Test: http/tests//dom/document-attributes-null-handling.html

* dom/Document.idl:

LayoutTests:

Add test coverage.

* http/tests/dom/document-attributes-null-handling-expected.txt: Added.
* http/tests/dom/document-attributes-null-handling.html: Added.
* fast/dom/document-attribute-js-null-expected.txt:
* fast/dom/document-attribute-js-null.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastdomdocumentattributejsnullexpectedtxt">trunk/LayoutTests/fast/dom/document-attribute-js-null-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastdomdocumentattributejsnullhtml">trunk/LayoutTests/fast/dom/document-attribute-js-null.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomDocumentidl">trunk/Source/WebCore/dom/Document.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestsdomdocumentattributesnullhandlingexpectedtxt">trunk/LayoutTests/http/tests/dom/document-attributes-null-handling-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsdomdocumentattributesnullhandlinghtml">trunk/LayoutTests/http/tests/dom/document-attributes-null-handling.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (203486 => 203487)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-07-21 03:25:59 UTC (rev 203486)
+++ trunk/LayoutTests/ChangeLog        2016-07-21 03:30:48 UTC (rev 203487)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-07-20  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Fix null handling of several Document attributes
+        https://bugs.webkit.org/show_bug.cgi?id=159997
+
+        Reviewed by Ryosuke Niwa.
+
+        Add test coverage.
+
+        * http/tests/dom/document-attributes-null-handling-expected.txt: Added.
+        * http/tests/dom/document-attributes-null-handling.html: Added.
+        * fast/dom/document-attribute-js-null-expected.txt:
+        * fast/dom/document-attribute-js-null.html:
+
</ins><span class="cx"> 2016-07-20  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r203471.
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomdocumentattributejsnullexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/document-attribute-js-null-expected.txt (203486 => 203487)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/document-attribute-js-null-expected.txt        2016-07-21 03:25:59 UTC (rev 203486)
+++ trunk/LayoutTests/fast/dom/document-attribute-js-null-expected.txt        2016-07-21 03:30:48 UTC (rev 203487)
</span><span class="lines">@@ -3,7 +3,7 @@
</span><span class="cx"> TEST SUCCEEDED: Got the expected exception (9). [tested Document.xmlVersion]
</span><span class="cx"> TEST SUCCEEDED: The value was null. [tested Document.selectedStylesheetSet]
</span><span class="cx"> 
</span><del>-TEST SUCCEEDED: The value was the empty string. [tested HTMLDocument.title]
</del><ins>+TEST SUCCEEDED: The value was the string 'null'. [tested HTMLDocument.title]
</ins><span class="cx"> TEST SUCCEEDED: The value was the empty string. [tested HTMLDocument.cookie]
</span><span class="cx"> TEST SUCCEEDED: The value was the empty string. [tested HTMLDocument.bgColor]
</span><span class="cx"> TEST SUCCEEDED: The value was the empty string. [tested HTMLDocument.fgColor]
</span></span></pre></div>
<a id="trunkLayoutTestsfastdomdocumentattributejsnullhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/dom/document-attribute-js-null.html (203486 => 203487)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/dom/document-attribute-js-null.html        2016-07-21 03:25:59 UTC (rev 203486)
+++ trunk/LayoutTests/fast/dom/document-attribute-js-null.html        2016-07-21 03:30:48 UTC (rev 203487)
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx">                     typeName: 'HTMLDocument',
</span><span class="cx">                     docToUse: htmlDoc,
</span><span class="cx">                     attributes: [
</span><del>-                        {name: 'title', expectedNull: ''},
</del><ins>+                        {name: 'title', expectedNull: 'null'},
</ins><span class="cx">                         {name: 'cookie', expectedNull: ''},
</span><span class="cx">                         {name: 'bgColor', expectedNull: ''},
</span><span class="cx">                         {name: 'fgColor', expectedNull: ''},
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsdomdocumentattributesnullhandlingexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/dom/document-attributes-null-handling-expected.txt (0 => 203487)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/dom/document-attributes-null-handling-expected.txt                                (rev 0)
+++ trunk/LayoutTests/http/tests/dom/document-attributes-null-handling-expected.txt        2016-07-21 03:30:48 UTC (rev 203487)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+Test null handling of several Document attributes
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+* cookie attribute
+PASS document.cookie is &quot;&quot;
+document.cookie = 'key=value'
+PASS document.cookie is &quot;key=value&quot;
+document.cookie = null
+PASS document.cookie is &quot;key=value; null=&quot;
+
+* title attribute
+PASS document.title is &quot;&quot;
+document.title = null
+PASS document.title is &quot;null&quot;
+
+* domain attribute
+PASS document.domain is &quot;127.0.0.1&quot;
+PASS document.domain = null threw exception SecurityError (DOM Exception 18): The operation is insecure..
+PASS document.domain is &quot;127.0.0.1&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsdomdocumentattributesnullhandlinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/dom/document-attributes-null-handling.html (0 => 203487)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/dom/document-attributes-null-handling.html                                (rev 0)
+++ trunk/LayoutTests/http/tests/dom/document-attributes-null-handling.html        2016-07-21 03:30:48 UTC (rev 203487)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+&lt;script src=&quot;/js-test-resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+description(&quot;Test null handling of several Document attributes&quot;);
+
+debug(&quot;* cookie attribute&quot;);
+shouldBeEqualToString(&quot;document.cookie&quot;, &quot;&quot;);
+evalAndLog(&quot;document.cookie = 'key=value'&quot;);
+shouldBeEqualToString(&quot;document.cookie&quot;, &quot;key=value&quot;);
+evalAndLog(&quot;document.cookie = null&quot;);
+shouldBeEqualToString(&quot;document.cookie&quot;, &quot;key=value; null=&quot;);
+
+debug(&quot;&quot;);
+debug(&quot;* title attribute&quot;);
+shouldBeEqualToString(&quot;document.title&quot;, &quot;&quot;);
+evalAndLog(&quot;document.title = null&quot;);
+shouldBeEqualToString(&quot;document.title&quot;, &quot;null&quot;);
+
+debug(&quot;&quot;);
+debug(&quot;* domain attribute&quot;);
+shouldBeEqualToString(&quot;document.domain&quot;, &quot;127.0.0.1&quot;);
+shouldThrow(&quot;document.domain = null&quot;);
+shouldBeEqualToString(&quot;document.domain&quot;, &quot;127.0.0.1&quot;);
+&lt;/script&gt;
+&lt;script src=&quot;/js-test-resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (203486 => 203487)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-07-21 03:25:59 UTC (rev 203486)
+++ trunk/Source/WebCore/ChangeLog        2016-07-21 03:30:48 UTC (rev 203487)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2016-07-20  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Fix null handling of several Document attributes
+        https://bugs.webkit.org/show_bug.cgi?id=159997
+
+        Reviewed by Ryosuke Niwa.
+
+        Fix null handling of the following Document attributes: title, cookie
+        and domain.
+
+        In WebKit, they were all marked as [TreatNullAs=EmptyString], which
+        does not match the specification:
+        - https://html.spec.whatwg.org/multipage/dom.html#document
+
+        Details for each attribute:
+        - title: null is now treated as the string &quot;null&quot;, thus setting the
+          document title to &quot;null&quot;. This matches Firefox and Chrome.
+        - cookie: adds a &quot;null&quot; cookie instead of being a no-op. This matches
+                  both Firefox and Chrome.
+        - domain: Calls setDomain(String(&quot;null&quot;)) instead of
+                  setDomain(String()). This throws an exception because &quot;null&quot;
+                  is not a suffix of the effective domain name. The behavior
+                  is the same in Firefox and Chrome. Previously, we were
+                  already throwing an exception since setting the domain to
+                  the empty string throws, as per the specification.
+
+        Test: http/tests//dom/document-attributes-null-handling.html
+
+        * dom/Document.idl:
+
</ins><span class="cx"> 2016-07-20  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r203471.
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.idl (203486 => 203487)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.idl        2016-07-21 03:25:59 UTC (rev 203486)
+++ trunk/Source/WebCore/dom/Document.idl        2016-07-21 03:30:48 UTC (rev 203487)
</span><span class="lines">@@ -166,20 +166,17 @@
</span><span class="cx"> 
</span><span class="cx">     // Moved down from HTMLDocument
</span><span class="cx"> 
</span><del>-    // FIXME: Should not have [TreatNullAs=EmptyString].
-    [TreatNullAs=EmptyString, SetterRaisesException] attribute DOMString title;
</del><ins>+    [SetterRaisesException] attribute DOMString title;
</ins><span class="cx"> 
</span><span class="cx">     readonly attribute DOMString referrer;
</span><span class="cx"> #if defined(LANGUAGE_JAVASCRIPT) &amp;&amp; LANGUAGE_JAVASCRIPT
</span><del>-    // FIXME: Should not have [TreatNullAs=EmptyString].
-    [TreatNullAs=EmptyString, SetterRaisesException] attribute DOMString domain;
</del><ins>+    [SetterRaisesException] attribute DOMString domain;
</ins><span class="cx"> #else
</span><span class="cx">     readonly attribute DOMString domain;
</span><span class="cx"> #endif
</span><span class="cx">     [ImplementedAs=urlForBindings] readonly attribute DOMString URL;
</span><span class="cx"> 
</span><del>-    // FIXME: Should not have [TreatNullAs=EmptyString].
-    [TreatNullAs=EmptyString, GetterRaisesException, SetterRaisesException] attribute DOMString cookie;
</del><ins>+    [GetterRaisesException, SetterRaisesException] attribute DOMString cookie;
</ins><span class="cx"> 
</span><span class="cx">     [SetterRaisesException, ImplementedAs=bodyOrFrameset, StrictTypeChecking] attribute HTMLElement? body;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>