Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Unified Diff: Source/core/dom/Document.cpp

Issue 23321002: Convert 'document.domain' exceptions to 'es.throwSecurityError()'. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/http/tests/security/setDomainRelaxationForbiddenForURLScheme-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 9abe48baba00b2f629cdbe1758e65f34139e8011..57b604705a0d15f97a576c025c29e308c5c97515 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -37,6 +37,7 @@
#include "XMLNames.h"
#include "bindings/v8/CustomElementConstructorBuilder.h"
#include "bindings/v8/Dictionary.h"
+#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/ExceptionStatePlaceholder.h"
#include "bindings/v8/ScriptController.h"
@@ -3691,7 +3692,7 @@ String Document::domain() const
void Document::setDomain(const String& newDomain, ExceptionState& es)
{
if (SchemeRegistry::isDomainRelaxationForbiddenForURLScheme(securityOrigin()->protocol())) {
- es.throwDOMException(SecurityError, "'document.domain' assignment is forbidden for the '" + securityOrigin()->protocol() + "' scheme.");
+ es.throwSecurityError(ExceptionMessages::failedToSet("domain", "Document", "assignment is forbidden for the '" + securityOrigin()->protocol() + "' scheme."));
return;
}
@@ -3713,17 +3714,17 @@ void Document::setDomain(const String& newDomain, ExceptionState& es)
int oldLength = domain().length();
int newLength = newDomain.length();
- String exceptionMessage = "'document.domain' assignment failed: '" + newDomain + "' is not a suffix of '" + domain() + "'.";
+ String exceptionMessage = ExceptionMessages::failedToSet("domain", "Document", "'" + newDomain + "' is not a suffix of '" + domain() + "'.");
// e.g. newDomain = subdomain.www.example.com (25) and domain() = www.example.com (15)
if (newLength >= oldLength) {
- es.throwDOMException(SecurityError, exceptionMessage);
+ es.throwSecurityError(exceptionMessage);
return;
}
String test = domain();
// Check that it's a complete suffix, not e.g. "ample.com"
if (test[oldLength - newLength - 1] != '.') {
- es.throwDOMException(SecurityError, exceptionMessage);
+ es.throwSecurityError(exceptionMessage);
return;
}
@@ -3731,7 +3732,7 @@ void Document::setDomain(const String& newDomain, ExceptionState& es)
// and we check that it's the same thing as newDomain
test.remove(0, oldLength - newLength);
if (test != newDomain) {
- es.throwDOMException(SecurityError, exceptionMessage);
+ es.throwSecurityError(exceptionMessage);
return;
}
« no previous file with comments | « LayoutTests/http/tests/security/setDomainRelaxationForbiddenForURLScheme-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698