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

Unified Diff: Source/core/dom/DOMException.h

Issue 22829002: Throw an exception when denying access to 'Frame's 'location' setter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Uncaught. 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
Index: Source/core/dom/DOMException.h
diff --git a/Source/core/dom/DOMException.h b/Source/core/dom/DOMException.h
index ca96483b507e852dc1697effc8f3ae8dfea6a799..9e1f103eb997987bcf78457a3c8afd2880b093af 100644
--- a/Source/core/dom/DOMException.h
+++ b/Source/core/dom/DOMException.h
@@ -40,24 +40,34 @@ typedef int ExceptionCode;
class DOMException : public RefCounted<DOMException>, public ScriptWrappable {
public:
- static PassRefPtr<DOMException> create(ExceptionCode, const String& message = String());
+ static PassRefPtr<DOMException> create(ExceptionCode, const String& sanitizedMessage = String(), const String& unsanitizedMessage = String());
unsigned short code() const { return m_code; }
String name() const { return m_name; }
- String message() const { return m_message; }
+ // This is the message that's exposed to JavaScript: if a sanitized message is present, we prefer it.
+ String message() const { return !sanitizedMessage().isEmpty() ? sanitizedMessage() : unsanitizedMessage(); }
String toString() const;
+ // This is the message that's exposed to the console: if an unsanitized message is present, we prefer it.
+ String messageForConsole() const { return !unsanitizedMessage().isEmpty() ? unsanitizedMessage() : sanitizedMessage(); }
+ String toStringForConsole() const;
+
static String getErrorName(ExceptionCode);
static String getErrorMessage(ExceptionCode);
static unsigned short getLegacyErrorCode(ExceptionCode);
private:
- DOMException(unsigned short m_code, const String& name, const String& message);
+ DOMException(unsigned short m_code, const String& name, const String& sanitizedMessage, const String& unsanitizedMessage);
+
+ // These methods are not (and must not be) exposed to JavaScript.
+ String unsanitizedMessage() const { return m_unsanitizedMessage; }
+ String sanitizedMessage() const { return m_sanitizedMessage; }
unsigned short m_code;
String m_name;
- String m_message;
+ String m_sanitizedMessage;
+ String m_unsanitizedMessage;
};
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698