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

Side by Side Diff: Source/bindings/v8/V8Initializer.cpp

Issue 20351002: Add 'error' parameter to 'window.onerror' handlers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. 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 11 matching lines...) Expand all
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE. 23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "bindings/v8/V8Initializer.h" 27 #include "bindings/v8/V8Initializer.h"
28 28
29 #include "V8History.h" 29 #include "V8History.h"
30 #include "V8Location.h" 30 #include "V8Location.h"
31 #include "V8Window.h" 31 #include "V8Window.h"
32 #include "bindings/v8/DOMWrapperWorld.h"
32 #include "bindings/v8/ScriptCallStackFactory.h" 33 #include "bindings/v8/ScriptCallStackFactory.h"
33 #include "bindings/v8/ScriptProfiler.h" 34 #include "bindings/v8/ScriptProfiler.h"
34 #include "bindings/v8/V8Binding.h" 35 #include "bindings/v8/V8Binding.h"
35 #include "bindings/v8/V8GCController.h" 36 #include "bindings/v8/V8GCController.h"
37 #include "bindings/v8/V8HiddenPropertyName.h"
36 #include "bindings/v8/V8PerContextData.h" 38 #include "bindings/v8/V8PerContextData.h"
37 #include "core/dom/Document.h" 39 #include "core/dom/Document.h"
38 #include "core/dom/ExceptionCode.h" 40 #include "core/dom/ExceptionCode.h"
39 #include "core/inspector/ScriptCallStack.h" 41 #include "core/inspector/ScriptCallStack.h"
40 #include "core/page/ConsoleTypes.h" 42 #include "core/page/ConsoleTypes.h"
41 #include "core/page/ContentSecurityPolicy.h" 43 #include "core/page/ContentSecurityPolicy.h"
42 #include "core/page/DOMWindow.h" 44 #include "core/page/DOMWindow.h"
43 #include "core/page/Frame.h" 45 #include "core/page/Frame.h"
44 #include "core/platform/MemoryUsageSupport.h" 46 #include "core/platform/MemoryUsageSupport.h"
45 #include <v8-debug.h> 47 #include <v8-debug.h>
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 89
88 v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace(); 90 v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace();
89 RefPtr<ScriptCallStack> callStack; 91 RefPtr<ScriptCallStack> callStack;
90 // Currently stack trace is only collected when inspector is open. 92 // Currently stack trace is only collected when inspector is open.
91 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) 93 if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0)
92 callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallSt ackSizeToCapture); 94 callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallSt ackSizeToCapture);
93 95
94 v8::Handle<v8::Value> resourceName = message->GetScriptResourceName(); 96 v8::Handle<v8::Value> resourceName = message->GetScriptResourceName();
95 bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsStrin g(); 97 bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsStrin g();
96 String resource = shouldUseDocumentURL ? firstWindow->document()->url() : to WebCoreString(resourceName); 98 String resource = shouldUseDocumentURL ? firstWindow->document()->url() : to WebCoreString(resourceName);
97 firstWindow->document()->reportException(errorMessage, message->GetLineNumbe r(), message->GetStartColumn(), resource, callStack); 99 data->ToObject()->SetHiddenValue(V8HiddenPropertyName::worldId(), v8::Intege r::New(DOMWrapperWorld::current()->worldId()));
100 firstWindow->document()->reportException(errorMessage, message->GetLineNumbe r(), message->GetStartColumn(), resource, callStack, ScriptValue(data));
98 } 101 }
99 102
100 static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8 ::AccessType type, v8::Local<v8::Value> data) 103 static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8 ::AccessType type, v8::Local<v8::Value> data)
101 { 104 {
102 Frame* target = findFrame(host, data, v8::Isolate::GetCurrent()); 105 Frame* target = findFrame(host, data, v8::Isolate::GetCurrent());
103 if (!target) 106 if (!target)
104 return; 107 return;
105 DOMWindow* targetWindow = target->domWindow(); 108 DOMWindow* targetWindow = target->domWindow();
106 109
107 setDOMException(SecurityError, targetWindow->crossDomainAccessErrorMessage(a ctiveDOMWindow()), v8::Isolate::GetCurrent()); 110 setDOMException(SecurityError, targetWindow->crossDomainAccessErrorMessage(a ctiveDOMWindow()), v8::Isolate::GetCurrent());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 if (isReportingException) 161 if (isReportingException)
159 return; 162 return;
160 isReportingException = true; 163 isReportingException = true;
161 164
162 // During the frame teardown, there may not be a valid context. 165 // During the frame teardown, there may not be a valid context.
163 if (ScriptExecutionContext* context = getScriptExecutionContext()) { 166 if (ScriptExecutionContext* context = getScriptExecutionContext()) {
164 String errorMessage = toWebCoreString(message->Get()); 167 String errorMessage = toWebCoreString(message->Get());
165 int lineNumber = message->GetLineNumber(); 168 int lineNumber = message->GetLineNumber();
166 int columnNumber = message->GetStartColumn(); 169 int columnNumber = message->GetStartColumn();
167 String sourceURL = toWebCoreString(message->GetScriptResourceName()); 170 String sourceURL = toWebCoreString(message->GetScriptResourceName());
168 context->reportException(errorMessage, lineNumber, columnNumber, sourceU RL, 0); 171 data->ToObject()->SetHiddenValue(V8HiddenPropertyName::worldId(), v8::In teger::New(DOMWrapperWorld::current()->worldId()));
172 context->reportException(errorMessage, lineNumber, columnNumber, sourceU RL, 0, ScriptValue(data));
169 } 173 }
170 174
171 isReportingException = false; 175 isReportingException = false;
172 } 176 }
173 177
174 static const int kWorkerMaxStackSize = 500 * 1024; 178 static const int kWorkerMaxStackSize = 500 * 1024;
175 179
176 void V8Initializer::initializeWorker(v8::Isolate* isolate) 180 void V8Initializer::initializeWorker(v8::Isolate* isolate)
177 { 181 {
178 initializeV8Common(); 182 initializeV8Common();
179 183
180 v8::V8::AddMessageListener(messageHandlerInWorker); 184 v8::V8::AddMessageListener(messageHandlerInWorker);
181 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); 185 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker);
182 186
183 v8::ResourceConstraints resourceConstraints; 187 v8::ResourceConstraints resourceConstraints;
184 uint32_t here; 188 uint32_t here;
185 resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uin t32_t*)); 189 resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uin t32_t*));
186 v8::SetResourceConstraints(&resourceConstraints); 190 v8::SetResourceConstraints(&resourceConstraints);
187 191
188 V8PerIsolateData::ensureInitialized(isolate); 192 V8PerIsolateData::ensureInitialized(isolate);
189 } 193 }
190 194
191 } // namespace WebCore 195 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698