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

Side by Side Diff: Source/core/dom/DOMException.cpp

Issue 22985006: Throw an exception when denying access to 'Frame's 'location' setter. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/DOMException.h ('k') | Source/core/dom/ErrorEvent.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 }; 79 };
80 80
81 static const CoreException* getErrorEntry(ExceptionCode ec) 81 static const CoreException* getErrorEntry(ExceptionCode ec)
82 { 82 {
83 size_t tableSize = WTF_ARRAY_LENGTH(coreExceptions); 83 size_t tableSize = WTF_ARRAY_LENGTH(coreExceptions);
84 size_t tableIndex = ec - IndexSizeError; 84 size_t tableIndex = ec - IndexSizeError;
85 85
86 return tableIndex < tableSize ? &coreExceptions[tableIndex] : 0; 86 return tableIndex < tableSize ? &coreExceptions[tableIndex] : 0;
87 } 87 }
88 88
89 DOMException::DOMException(unsigned short code, const String& name, const String & message) 89 DOMException::DOMException(unsigned short code, const String& name, const String & sanitizedMessage, const String& unsanitizedMessage)
90 { 90 {
91 ASSERT(name); 91 ASSERT(name);
92 m_code = code; 92 m_code = code;
93 m_name = name; 93 m_name = name;
94 m_message = message; 94 m_sanitizedMessage = sanitizedMessage;
95 m_unsanitizedMessage = unsanitizedMessage;
95 ScriptWrappable::init(this); 96 ScriptWrappable::init(this);
96 } 97 }
97 98
98 PassRefPtr<DOMException> DOMException::create(ExceptionCode ec, const String& me ssage) 99 PassRefPtr<DOMException> DOMException::create(ExceptionCode ec, const String& sa nitizedMessage, const String& unsanitizedMessage)
99 { 100 {
100 const CoreException* entry = getErrorEntry(ec); 101 const CoreException* entry = getErrorEntry(ec);
101 ASSERT(entry); 102 ASSERT(entry);
102 return adoptRef(new DOMException(entry->code, 103 return adoptRef(new DOMException(entry->code,
103 entry->name ? entry->name : "Error", 104 entry->name ? entry->name : "Error",
104 message.isNull() ? String(entry->message) : message)); 105 sanitizedMessage.isNull() ? String(entry->message) : sanitizedMessage,
106 unsanitizedMessage));
105 } 107 }
106 108
107 String DOMException::toString() const 109 String DOMException::toString() const
108 { 110 {
109 return name() + ": " + message(); 111 return name() + ": " + message();
110 } 112 }
111 113
114 String DOMException::toStringForConsole() const
115 {
116 return name() + ": " + messageForConsole();
117 }
118
112 String DOMException::getErrorName(ExceptionCode ec) 119 String DOMException::getErrorName(ExceptionCode ec)
113 { 120 {
114 const CoreException* entry = getErrorEntry(ec); 121 const CoreException* entry = getErrorEntry(ec);
115 ASSERT(entry); 122 ASSERT(entry);
116 if (!entry) 123 if (!entry)
117 return "UnknownError"; 124 return "UnknownError";
118 125
119 return entry->name; 126 return entry->name;
120 } 127 }
121 128
122 String DOMException::getErrorMessage(ExceptionCode ec) 129 String DOMException::getErrorMessage(ExceptionCode ec)
123 { 130 {
124 const CoreException* entry = getErrorEntry(ec); 131 const CoreException* entry = getErrorEntry(ec);
125 ASSERT(entry); 132 ASSERT(entry);
126 if (!entry) 133 if (!entry)
127 return "Unknown error."; 134 return "Unknown error.";
128 135
129 return entry->message; 136 return entry->message;
130 } 137 }
131 138
132 unsigned short DOMException::getLegacyErrorCode(ExceptionCode ec) 139 unsigned short DOMException::getLegacyErrorCode(ExceptionCode ec)
133 { 140 {
134 const CoreException* entry = getErrorEntry(ec); 141 const CoreException* entry = getErrorEntry(ec);
135 ASSERT(entry); 142 ASSERT(entry);
136 143
137 return (entry && entry->code) ? entry->code : 0; 144 return (entry && entry->code) ? entry->code : 0;
138 } 145 }
139 146
140 } // namespace WebCore 147 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/DOMException.h ('k') | Source/core/dom/ErrorEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698