Bug 819475 - Make document.domain non-nullable; r=bz draft
authorKyle Machulis <kyle@nonpolynomial.com>
Thu, 07 Jun 2018 12:29:23 -0700
changeset 806312 606ceb7303bac620f0431ca46abee7ec6326f8f6
parent 805554 6acc9908b0de63a8a0dc5147312d41f521c23f9c
push id112852
push userbmo:kyle@nonpolynomial.com
push dateFri, 08 Jun 2018 22:50:32 +0000
reviewersbz
bugs819475
milestone62.0a1
Bug 819475 - Make document.domain non-nullable; r=bz Make document.domain non-nullable, to conform to the HTML spec. MozReview-Commit-ID: B1YuQekBgZD
dom/html/nsHTMLDocument.cpp
dom/webidl/HTMLDocument.webidl
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -885,28 +885,28 @@ nsHTMLDocument::GetDomainURI()
 
 
 void
 nsHTMLDocument::GetDomain(nsAString& aDomain)
 {
   nsCOMPtr<nsIURI> uri = GetDomainURI();
 
   if (!uri) {
-    SetDOMStringToNull(aDomain);
+    aDomain.Truncate();
     return;
   }
 
   nsAutoCString hostName;
   nsresult rv = nsContentUtils::GetHostOrIPv6WithBrackets(uri, hostName);
   if (NS_SUCCEEDED(rv)) {
     CopyUTF8toUTF16(hostName, aDomain);
   } else {
     // If we can't get the host from the URI (e.g. about:, javascript:,
-    // etc), just return an null string.
-    SetDOMStringToNull(aDomain);
+    // etc), just return an empty string.
+    aDomain.Truncate();
   }
 }
 
 already_AddRefed<nsIURI>
 nsHTMLDocument::CreateInheritingURIForHost(const nsACString& aHostString)
 {
   if (aHostString.IsEmpty()) {
     return nullptr;
--- a/dom/webidl/HTMLDocument.webidl
+++ b/dom/webidl/HTMLDocument.webidl
@@ -2,17 +2,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 [OverrideBuiltins]
 interface HTMLDocument : Document {
            [SetterThrows]
-           attribute DOMString? domain;
+           attribute DOMString domain;
            [Throws]
            attribute DOMString cookie;
   // DOM tree accessors
   [Throws]
   getter object (DOMString name);
 
   // dynamic markup insertion
   [CEReactions, Throws]