OLD | NEW |
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 23 matching lines...) Expand all Loading... |
34 #include "bindings/core/v8/V8DOMException.h" | 34 #include "bindings/core/v8/V8DOMException.h" |
35 #include "bindings/core/v8/V8ErrorEvent.h" | 35 #include "bindings/core/v8/V8ErrorEvent.h" |
36 #include "bindings/core/v8/V8ErrorHandler.h" | 36 #include "bindings/core/v8/V8ErrorHandler.h" |
37 #include "bindings/core/v8/V8GCController.h" | 37 #include "bindings/core/v8/V8GCController.h" |
38 #include "bindings/core/v8/V8History.h" | 38 #include "bindings/core/v8/V8History.h" |
39 #include "bindings/core/v8/V8Location.h" | 39 #include "bindings/core/v8/V8Location.h" |
40 #include "bindings/core/v8/V8PerContextData.h" | 40 #include "bindings/core/v8/V8PerContextData.h" |
41 #include "bindings/core/v8/V8Window.h" | 41 #include "bindings/core/v8/V8Window.h" |
42 #include "core/dom/Document.h" | 42 #include "core/dom/Document.h" |
43 #include "core/dom/ExceptionCode.h" | 43 #include "core/dom/ExceptionCode.h" |
44 #include "core/dom/NoEventDispatchAssertion.h" | |
45 #include "core/frame/ConsoleTypes.h" | 44 #include "core/frame/ConsoleTypes.h" |
46 #include "core/frame/LocalDOMWindow.h" | 45 #include "core/frame/LocalDOMWindow.h" |
47 #include "core/frame/LocalFrame.h" | 46 #include "core/frame/LocalFrame.h" |
48 #include "core/frame/csp/ContentSecurityPolicy.h" | 47 #include "core/frame/csp/ContentSecurityPolicy.h" |
49 #include "core/inspector/ScriptCallStack.h" | 48 #include "core/inspector/ScriptCallStack.h" |
| 49 #include "platform/EventDispatchForbiddenScope.h" |
50 #include "platform/TraceEvent.h" | 50 #include "platform/TraceEvent.h" |
51 #include "public/platform/Platform.h" | 51 #include "public/platform/Platform.h" |
52 #include "wtf/RefPtr.h" | 52 #include "wtf/RefPtr.h" |
53 #include "wtf/text/WTFString.h" | 53 #include "wtf/text/WTFString.h" |
54 #include <v8-debug.h> | 54 #include <v8-debug.h> |
55 | 55 |
56 namespace blink { | 56 namespace blink { |
57 | 57 |
58 static LocalFrame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> da
ta, v8::Isolate* isolate) | 58 static LocalFrame* findFrame(v8::Local<v8::Object> host, v8::Local<v8::Value> da
ta, v8::Isolate* isolate) |
59 { | 59 { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 126 |
127 // This method might be called while we're creating a new context. In this c
ase, we | 127 // This method might be called while we're creating a new context. In this c
ase, we |
128 // avoid storing the exception object, as we can't create a wrapper during c
ontext creation. | 128 // avoid storing the exception object, as we can't create a wrapper during c
ontext creation. |
129 // FIXME: Can we even get here during initialization now that we bail out wh
en GetEntered returns an empty handle? | 129 // FIXME: Can we even get here during initialization now that we bail out wh
en GetEntered returns an empty handle? |
130 LocalFrame* frame = enteredWindow->document()->frame(); | 130 LocalFrame* frame = enteredWindow->document()->frame(); |
131 if (frame && frame->script().existingWindowShell(scriptState->world())) { | 131 if (frame && frame->script().existingWindowShell(scriptState->world())) { |
132 V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, scr
iptState->context()->Global(), isolate); | 132 V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, scr
iptState->context()->Global(), isolate); |
133 } | 133 } |
134 | 134 |
135 if (scriptState->world().isPrivateScriptIsolatedWorld()) { | 135 if (scriptState->world().isPrivateScriptIsolatedWorld()) { |
136 // We allow a private script to dispatch error events even in a NoEventD
ispatchAssertion scope. | 136 // We allow a private script to dispatch error events even in a EventDis
patchForbiddenScope scope. |
137 // Without having this ability, it's hard to debug the private script be
cause syntax errors | 137 // Without having this ability, it's hard to debug the private script be
cause syntax errors |
138 // in the private script are not reported to console (the private script
just crashes silently). | 138 // in the private script are not reported to console (the private script
just crashes silently). |
139 // Allowing error events in private scripts is safe because error events
don't propagate to | 139 // Allowing error events in private scripts is safe because error events
don't propagate to |
140 // other isolated worlds (which means that the error events won't fire a
ny event listeners | 140 // other isolated worlds (which means that the error events won't fire a
ny event listeners |
141 // in user's scripts). | 141 // in user's scripts). |
142 NoEventDispatchAssertion::AllowUserAgentEvents allowUserAgentEvents; | 142 EventDispatchForbiddenScope::AllowUserAgentEvents allowUserAgentEvents; |
143 enteredWindow->document()->reportException(event.release(), callStack, c
orsStatus); | 143 enteredWindow->document()->reportException(event.release(), callStack, c
orsStatus); |
144 } else { | 144 } else { |
145 enteredWindow->document()->reportException(event.release(), callStack, c
orsStatus); | 145 enteredWindow->document()->reportException(event.release(), callStack, c
orsStatus); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8
::AccessType type, v8::Local<v8::Value> data) | 149 static void failedAccessCheckCallbackInMainThread(v8::Local<v8::Object> host, v8
::AccessType type, v8::Local<v8::Value> data) |
150 { | 150 { |
151 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 151 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
152 LocalFrame* target = findFrame(host, data, isolate); | 152 LocalFrame* target = findFrame(host, data, isolate); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 v8::V8::AddMessageListener(messageHandlerInWorker); | 259 v8::V8::AddMessageListener(messageHandlerInWorker); |
260 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); | 260 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); |
261 | 261 |
262 v8::ResourceConstraints resourceConstraints; | 262 v8::ResourceConstraints resourceConstraints; |
263 uint32_t here; | 263 uint32_t here; |
264 resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uin
t32_t*)); | 264 resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uin
t32_t*)); |
265 v8::SetResourceConstraints(isolate, &resourceConstraints); | 265 v8::SetResourceConstraints(isolate, &resourceConstraints); |
266 } | 266 } |
267 | 267 |
268 } // namespace blink | 268 } // namespace blink |
OLD | NEW |