Bug 1457689 - Fix documain.domain setting exception type; r=bz draft
authorKyle Machulis <kyle@nonpolynomial.com>
Thu, 07 Jun 2018 11:45:09 -0700
changeset 806313 66868e2222e9d35de275619782461bd82f9f6599
parent 805204 199a085199815cc99daa658956a7c9436e1d436b
child 806314 ea8700db22ae55ec88df73bc9adacc0d9d3a0a61
push id112853
push userbmo:kyle@nonpolynomial.com
push dateFri, 08 Jun 2018 22:57:57 +0000
reviewersbz
bugs1457689
milestone62.0a1
Bug 1457689 - Fix documain.domain setting exception type; r=bz Change exception type to comply with HTML spec, which uses security error instead of bad document domain. MozReview-Commit-ID: Iefkeskn9bM
dom/html/nsHTMLDocument.cpp
testing/web-platform/meta/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain_setter.html.ini
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -1014,34 +1014,34 @@ nsHTMLDocument::SetDomain(const nsAStrin
 {
   if (mSandboxFlags & SANDBOXED_DOMAIN) {
     // We're sandboxed; disallow setting domain
     rv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
   }
 
   if (aDomain.IsEmpty()) {
-    rv.Throw(NS_ERROR_DOM_BAD_DOCUMENT_DOMAIN);
+    rv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
   }
 
   nsCOMPtr<nsIURI> uri = GetDomainURI();
   if (!uri) {
     rv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   // Check new domain - must be a superdomain of the current host
   // For example, a page from foo.bar.com may set domain to bar.com,
   // but not to ar.com, baz.com, or fi.foo.bar.com.
 
   nsCOMPtr<nsIURI> newURI = RegistrableDomainSuffixOfInternal(aDomain, uri);
   if (!newURI) {
     // Error: illegal domain
-    rv.Throw(NS_ERROR_DOM_BAD_DOCUMENT_DOMAIN);
+    rv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
   }
 
   rv = NodePrincipal()->SetDomain(newURI);
 }
 
 already_AddRefed<nsIChannel>
 nsHTMLDocument::CreateDummyChannelForCookies(nsIURI* aCodebaseURI)
deleted file mode 100644
--- a/testing/web-platform/meta/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain_setter.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[document_domain_setter.html]
-  [failed setting of document.domain]
-    expected: FAIL
-