- Revision
- 203487
- Author
- cdu...@apple.com
- Date
- 2016-07-20 20:30:48 -0700 (Wed, 20 Jul 2016)
Log Message
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 "null", thus setting the
document title to "null". This matches Firefox and Chrome.
- cookie: adds a "null" cookie instead of being a no-op. This matches
both Firefox and Chrome.
- domain: Calls setDomain(String("null")) instead of
setDomain(String()). This throws an exception because "null"
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:
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (203486 => 203487)
--- trunk/LayoutTests/ChangeLog 2016-07-21 03:25:59 UTC (rev 203486)
+++ trunk/LayoutTests/ChangeLog 2016-07-21 03:30:48 UTC (rev 203487)
@@ -1,3 +1,17 @@
+2016-07-20 Chris Dumez <cdu...@apple.com>
+
+ 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:
+
2016-07-20 Commit Queue <commit-qu...@webkit.org>
Unreviewed, rolling out r203471.
Modified: trunk/LayoutTests/fast/dom/document-attribute-js-null-expected.txt (203486 => 203487)
--- 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)
@@ -3,7 +3,7 @@
TEST SUCCEEDED: Got the expected exception (9). [tested Document.xmlVersion]
TEST SUCCEEDED: The value was null. [tested Document.selectedStylesheetSet]
-TEST SUCCEEDED: The value was the empty string. [tested HTMLDocument.title]
+TEST SUCCEEDED: The value was the string 'null'. [tested HTMLDocument.title]
TEST SUCCEEDED: The value was the empty string. [tested HTMLDocument.cookie]
TEST SUCCEEDED: The value was the empty string. [tested HTMLDocument.bgColor]
TEST SUCCEEDED: The value was the empty string. [tested HTMLDocument.fgColor]
Modified: trunk/LayoutTests/fast/dom/document-attribute-js-null.html (203486 => 203487)
--- 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)
@@ -72,7 +72,7 @@
typeName: 'HTMLDocument',
docToUse: htmlDoc,
attributes: [
- {name: 'title', expectedNull: ''},
+ {name: 'title', expectedNull: 'null'},
{name: 'cookie', expectedNull: ''},
{name: 'bgColor', expectedNull: ''},
{name: 'fgColor', expectedNull: ''},
Added: trunk/LayoutTests/http/tests/dom/document-attributes-null-handling-expected.txt (0 => 203487)
--- 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)
@@ -0,0 +1,25 @@
+Test null handling of several Document attributes
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+* cookie attribute
+PASS document.cookie is ""
+document.cookie = 'key=value'
+PASS document.cookie is "key=value"
+document.cookie = null
+PASS document.cookie is "key=value; null="
+
+* title attribute
+PASS document.title is ""
+document.title = null
+PASS document.title is "null"
+
+* domain attribute
+PASS document.domain is "127.0.0.1"
+PASS document.domain = null threw exception SecurityError (DOM Exception 18): The operation is insecure..
+PASS document.domain is "127.0.0.1"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/dom/document-attributes-null-handling.html (0 => 203487)
--- 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)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Test null handling of several Document attributes");
+
+debug("* cookie attribute");
+shouldBeEqualToString("document.cookie", "");
+evalAndLog("document.cookie = 'key=value'");
+shouldBeEqualToString("document.cookie", "key=value");
+evalAndLog("document.cookie = null");
+shouldBeEqualToString("document.cookie", "key=value; null=");
+
+debug("");
+debug("* title attribute");
+shouldBeEqualToString("document.title", "");
+evalAndLog("document.title = null");
+shouldBeEqualToString("document.title", "null");
+
+debug("");
+debug("* domain attribute");
+shouldBeEqualToString("document.domain", "127.0.0.1");
+shouldThrow("document.domain = null");
+shouldBeEqualToString("document.domain", "127.0.0.1");
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (203486 => 203487)
--- 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)
@@ -1,3 +1,33 @@
+2016-07-20 Chris Dumez <cdu...@apple.com>
+
+ 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 "null", thus setting the
+ document title to "null". This matches Firefox and Chrome.
+ - cookie: adds a "null" cookie instead of being a no-op. This matches
+ both Firefox and Chrome.
+ - domain: Calls setDomain(String("null")) instead of
+ setDomain(String()). This throws an exception because "null"
+ 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:
+
2016-07-20 Commit Queue <commit-qu...@webkit.org>
Unreviewed, rolling out r203471.
Modified: trunk/Source/WebCore/dom/Document.idl (203486 => 203487)
--- 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)
@@ -166,20 +166,17 @@
// Moved down from HTMLDocument
- // FIXME: Should not have [TreatNullAs=EmptyString].
- [TreatNullAs=EmptyString, SetterRaisesException] attribute DOMString title;
+ [SetterRaisesException] attribute DOMString title;
readonly attribute DOMString referrer;
#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
- // FIXME: Should not have [TreatNullAs=EmptyString].
- [TreatNullAs=EmptyString, SetterRaisesException] attribute DOMString domain;
+ [SetterRaisesException] attribute DOMString domain;
#else
readonly attribute DOMString domain;
#endif
[ImplementedAs=urlForBindings] readonly attribute DOMString URL;
- // FIXME: Should not have [TreatNullAs=EmptyString].
- [TreatNullAs=EmptyString, GetterRaisesException, SetterRaisesException] attribute DOMString cookie;
+ [GetterRaisesException, SetterRaisesException] attribute DOMString cookie;
[SetterRaisesException, ImplementedAs=bodyOrFrameset, StrictTypeChecking] attribute HTMLElement? body;