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

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

Issue 22887017: Revert "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 & sanitizedMessage, const String& unsanitizedMessage) 89 DOMException::DOMException(unsigned short code, const String& name, const String & message)
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_sanitizedMessage = sanitizedMessage; 94 m_message = message;
95 m_unsanitizedMessage = unsanitizedMessage;
96 ScriptWrappable::init(this); 95 ScriptWrappable::init(this);
97 } 96 }
98 97
99 PassRefPtr<DOMException> DOMException::create(ExceptionCode ec, const String& sa nitizedMessage, const String& unsanitizedMessage) 98 PassRefPtr<DOMException> DOMException::create(ExceptionCode ec, const String& me ssage)
100 { 99 {
101 const CoreException* entry = getErrorEntry(ec); 100 const CoreException* entry = getErrorEntry(ec);
102 ASSERT(entry); 101 ASSERT(entry);
103 return adoptRef(new DOMException(entry->code, 102 return adoptRef(new DOMException(entry->code,
104 entry->name ? entry->name : "Error", 103 entry->name ? entry->name : "Error",
105 sanitizedMessage.isNull() ? String(entry->message) : sanitizedMessage, 104 message.isNull() ? String(entry->message) : message));
106 unsanitizedMessage));
107 } 105 }
108 106
109 String DOMException::toString() const 107 String DOMException::toString() const
110 { 108 {
111 return name() + ": " + message(); 109 return name() + ": " + message();
112 } 110 }
113 111
114 String DOMException::toStringForConsole() const
115 {
116 return name() + ": " + messageForConsole();
117 }
118
119 String DOMException::getErrorName(ExceptionCode ec) 112 String DOMException::getErrorName(ExceptionCode ec)
120 { 113 {
121 const CoreException* entry = getErrorEntry(ec); 114 const CoreException* entry = getErrorEntry(ec);
122 ASSERT(entry); 115 ASSERT(entry);
123 if (!entry) 116 if (!entry)
124 return "UnknownError"; 117 return "UnknownError";
125 118
126 return entry->name; 119 return entry->name;
127 } 120 }
128 121
129 String DOMException::getErrorMessage(ExceptionCode ec) 122 String DOMException::getErrorMessage(ExceptionCode ec)
130 { 123 {
131 const CoreException* entry = getErrorEntry(ec); 124 const CoreException* entry = getErrorEntry(ec);
132 ASSERT(entry); 125 ASSERT(entry);
133 if (!entry) 126 if (!entry)
134 return "Unknown error."; 127 return "Unknown error.";
135 128
136 return entry->message; 129 return entry->message;
137 } 130 }
138 131
139 unsigned short DOMException::getLegacyErrorCode(ExceptionCode ec) 132 unsigned short DOMException::getLegacyErrorCode(ExceptionCode ec)
140 { 133 {
141 const CoreException* entry = getErrorEntry(ec); 134 const CoreException* entry = getErrorEntry(ec);
142 ASSERT(entry); 135 ASSERT(entry);
143 136
144 return (entry && entry->code) ? entry->code : 0; 137 return (entry && entry->code) ? entry->code : 0;
145 } 138 }
146 139
147 } // namespace WebCore 140 } // 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