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

Side by Side Diff: Source/bindings/v8/V8ThrowException.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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 26 matching lines...) Expand all
37 ASSERT(info.Data()->IsObject()); 37 ASSERT(info.Data()->IsObject());
38 v8SetReturnValue(info, info.Data()->ToObject()->Get(v8::String::NewSymbol("s tack"))); 38 v8SetReturnValue(info, info.Data()->ToObject()->Get(v8::String::NewSymbol("s tack")));
39 } 39 }
40 40
41 static void domExceptionStackSetter(v8::Local<v8::String> name, v8::Local<v8::Va lue> value, const v8::PropertyCallbackInfo<void>& info) 41 static void domExceptionStackSetter(v8::Local<v8::String> name, v8::Local<v8::Va lue> value, const v8::PropertyCallbackInfo<void>& info)
42 { 42 {
43 ASSERT(info.Data()->IsObject()); 43 ASSERT(info.Data()->IsObject());
44 info.Data()->ToObject()->Set(v8::String::NewSymbol("stack"), value); 44 info.Data()->ToObject()->Set(v8::String::NewSymbol("stack"), value);
45 } 45 }
46 46
47 v8::Handle<v8::Value> V8ThrowException::createDOMException(int ec, const String& message, v8::Isolate* isolate) 47 v8::Handle<v8::Value> V8ThrowException::createDOMException(int ec, const String& sanitizedMessage, const String& unsanitizedMessage, v8::Isolate* isolate)
48 { 48 {
49 if (ec <= 0 || v8::V8::IsExecutionTerminating()) 49 if (ec <= 0 || v8::V8::IsExecutionTerminating())
50 return v8Undefined(); 50 return v8Undefined();
51 51
52 ASSERT(ec == SecurityError || unsanitizedMessage.isEmpty());
53
52 // FIXME: Handle other WebIDL exception types. 54 // FIXME: Handle other WebIDL exception types.
53 if (ec == TypeError) 55 if (ec == TypeError)
54 return V8ThrowException::createTypeError(message, isolate); 56 return V8ThrowException::createTypeError(sanitizedMessage, isolate);
55 57
56 RefPtr<DOMException> domException = DOMException::create(ec, message); 58 RefPtr<DOMException> domException = DOMException::create(ec, sanitizedMessag e, unsanitizedMessage);
57 v8::Handle<v8::Value> exception = toV8(domException, v8::Handle<v8::Object>( ), isolate); 59 v8::Handle<v8::Value> exception = toV8(domException, v8::Handle<v8::Object>( ), isolate);
58 60
59 if (exception.IsEmpty()) 61 if (exception.IsEmpty())
60 return v8Undefined(); 62 return v8Undefined();
61 63
62 // Attach an Error object to the DOMException. This is then lazily used to g et the stack value. 64 // Attach an Error object to the DOMException. This is then lazily used to g et the stack value.
63 v8::Handle<v8::Value> error = v8::Exception::Error(v8String(domException->me ssage(), isolate)); 65 v8::Handle<v8::Value> error = v8::Exception::Error(v8String(domException->me ssage(), isolate));
64 ASSERT(!error.IsEmpty()); 66 ASSERT(!error.IsEmpty());
65 ASSERT(exception->IsObject()); 67 ASSERT(exception->IsObject());
66 exception->ToObject()->SetAccessor(v8::String::NewSymbol("stack"), domExcept ionStackGetter, domExceptionStackSetter, error); 68 exception->ToObject()->SetAccessor(v8::String::NewSymbol("stack"), domExcept ionStackGetter, domExceptionStackSetter, error);
67 69
68 return exception; 70 return exception;
69 } 71 }
70 72
71 v8::Handle<v8::Value> V8ThrowException::throwDOMException(int ec, const String& message, v8::Isolate* isolate) 73 v8::Handle<v8::Value> V8ThrowException::throwDOMException(int ec, const String& sanitizedMessage, const String& unsanitizedMessage, v8::Isolate* isolate)
72 { 74 {
73 v8::Handle<v8::Value> exception = createDOMException(ec, message, isolate); 75 ASSERT(ec == SecurityError || unsanitizedMessage.isEmpty());
76 v8::Handle<v8::Value> exception = createDOMException(ec, sanitizedMessage, u nsanitizedMessage, isolate);
74 if (exception.IsEmpty()) 77 if (exception.IsEmpty())
75 return v8Undefined(); 78 return v8Undefined();
76 79
77 return V8ThrowException::throwError(exception); 80 return V8ThrowException::throwError(exception);
78 } 81 }
79 82
80 v8::Handle<v8::Value> V8ThrowException::createError(V8ErrorType type, const Stri ng& message, v8::Isolate* isolate) 83 v8::Handle<v8::Value> V8ThrowException::createError(V8ErrorType type, const Stri ng& message, v8::Isolate* isolate)
81 { 84 {
82 switch (type) { 85 switch (type) {
83 case v8RangeError: 86 case v8RangeError:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 125 }
123 126
124 v8::Handle<v8::Value> V8ThrowException::throwError(v8::Handle<v8::Value> excepti on) 127 v8::Handle<v8::Value> V8ThrowException::throwError(v8::Handle<v8::Value> excepti on)
125 { 128 {
126 if (!v8::V8::IsExecutionTerminating()) 129 if (!v8::V8::IsExecutionTerminating())
127 v8::ThrowException(exception); 130 v8::ThrowException(exception);
128 return v8::Undefined(); 131 return v8::Undefined();
129 } 132 }
130 133
131 } // namespace WebCore 134 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8ThrowException.h ('k') | Source/bindings/v8/custom/V8HTMLFrameElementCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698