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

Side by Side Diff: Source/bindings/core/v8/V8ThrowException.cpp

Issue 871403007: Make exception throwing more robust in V8 out-of-stack situations (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « Source/bindings/core/v8/V8PerContextData.cpp ('k') | no next file » | 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) 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 if (ec == V8ReferenceError) 63 if (ec == V8ReferenceError)
64 return V8ThrowException::createReferenceError(isolate, sanitizedMessage) ; 64 return V8ThrowException::createReferenceError(isolate, sanitizedMessage) ;
65 65
66 v8::Handle<v8::Object> sanitizedCreationContext = creationContext; 66 v8::Handle<v8::Object> sanitizedCreationContext = creationContext;
67 67
68 // FIXME: Is the current context always the right choice? 68 // FIXME: Is the current context always the right choice?
69 Frame* frame = toFrameIfNotDetached(creationContext->CreationContext()); 69 Frame* frame = toFrameIfNotDetached(creationContext->CreationContext());
70 if (!frame || !BindingSecurity::shouldAllowAccessToFrame(isolate, frame, DoN otReportSecurityError)) 70 if (!frame || !BindingSecurity::shouldAllowAccessToFrame(isolate, frame, DoN otReportSecurityError))
71 sanitizedCreationContext = isolate->GetCurrentContext()->Global(); 71 sanitizedCreationContext = isolate->GetCurrentContext()->Global();
72 72
73 v8::TryCatch tryCatch;
73 74
74 RefPtrWillBeRawPtr<DOMException> domException = DOMException::create(ec, san itizedMessage, unsanitizedMessage); 75 RefPtrWillBeRawPtr<DOMException> domException = DOMException::create(ec, san itizedMessage, unsanitizedMessage);
75 v8::Handle<v8::Value> exception = toV8(domException.get(), sanitizedCreation Context, isolate); 76 v8::Handle<v8::Value> exception = toV8(domException.get(), sanitizedCreation Context, isolate);
76 77
77 if (exception.IsEmpty()) 78 if (!exception.IsEmpty()) {
79 if (tryCatch.HasCaught())
80 return tryCatch.Exception();
78 return v8Undefined(); 81 return v8Undefined();
82 }
haraken 2015/02/04 09:41:41 I might be misunderstanding but why is this not li
Jens Widell 2015/02/04 09:48:01 Oups, this was meant to be "if (exception.IsEmpty(
Jens Widell 2015/02/04 09:50:52 Done.
79 83
80 // Attach an Error object to the DOMException. This is then lazily used to g et the stack value. 84 // Attach an Error object to the DOMException. This is then lazily used to g et the stack value.
81 v8::Handle<v8::Value> error = v8::Exception::Error(v8String(isolate, domExce ption->message())); 85 v8::Handle<v8::Value> error = v8::Exception::Error(v8String(isolate, domExce ption->message()));
82 ASSERT(!error.IsEmpty()); 86 ASSERT(!error.IsEmpty());
83 ASSERT(exception->IsObject()); 87 ASSERT(exception->IsObject());
84 exception->ToObject(isolate)->SetAccessor(v8AtomicString(isolate, "stack"), domExceptionStackGetter, domExceptionStackSetter, error); 88 exception->ToObject(isolate)->SetAccessor(v8AtomicString(isolate, "stack"), domExceptionStackGetter, domExceptionStackSetter, error);
85 V8HiddenValue::setHiddenValue(isolate, exception->ToObject(isolate), V8Hidde nValue::error(isolate), error); 89 V8HiddenValue::setHiddenValue(isolate, exception->ToObject(isolate), V8Hidde nValue::error(isolate), error);
86 90
87 return exception; 91 return exception;
88 } 92 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 157 }
154 158
155 v8::Handle<v8::Value> V8ThrowException::throwException(v8::Handle<v8::Value> exc eption, v8::Isolate* isolate) 159 v8::Handle<v8::Value> V8ThrowException::throwException(v8::Handle<v8::Value> exc eption, v8::Isolate* isolate)
156 { 160 {
157 if (!v8::V8::IsExecutionTerminating()) 161 if (!v8::V8::IsExecutionTerminating())
158 isolate->ThrowException(exception); 162 isolate->ThrowException(exception);
159 return v8::Undefined(isolate); 163 return v8::Undefined(isolate);
160 } 164 }
161 165
162 } // namespace blink 166 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8PerContextData.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698