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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ScriptState.h

Issue 2420223002: Dispatching errors across iframes don't match webplatform tests
Patch Set: Refactored ScriptStateForErrorEvent, added error handler to the test." Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/ScriptState.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptState.h b/third_party/WebKit/Source/bindings/core/v8/ScriptState.h
index b0b0fd8530be5f9b3711f8272a63d42d98737c63..f17e013cbaf08e0f7655bd9434ce25eddc46dd0b 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptState.h
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptState.h
@@ -183,6 +183,40 @@ class ScriptStateProtectingContext {
ScopedPersistent<v8::Context> m_context;
};
+class ScriptStateForErrorEvent {
+ STACK_ALLOCATED();
+ WTF_MAKE_NONCOPYABLE(ScriptStateForErrorEvent);
+
+ public:
+ static ScriptStateForErrorEvent* current() { return s_topOfStack; }
+
+ ScriptStateForErrorEvent(v8::Local<v8::Context> context)
haraken 2016/11/02 01:40:18 Add explicit.
+ : m_prev(s_topOfStack),
+ m_isolate(context->GetIsolate()),
+ m_context(m_isolate, context) {
+ s_topOfStack = this;
+ }
+
+ ~ScriptStateForErrorEvent() {
+ s_topOfStack = s_topOfStack->m_prev;
+ }
+
+ ScriptState* scriptState() {
+ return ScriptState::from(m_context.newLocal(m_isolate));
+ }
+
+ v8::Local<v8::Context> context() const {
+ return m_context.newLocal(m_isolate);
+ }
+
+ private:
+ static ScriptStateForErrorEvent* s_topOfStack;
+ ScriptStateForErrorEvent* m_prev;
+
+ v8::Isolate* m_isolate;
+ ScopedPersistent<v8::Context> m_context;
haraken 2016/11/02 01:40:18 You can use v8::Local<v8::Context> because ScriptS
+};
+
} // namespace blink
#endif // ScriptState_h

Powered by Google App Engine
This is Rietveld 408576698