Chromium Code Reviews| Index: third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp |
| diff --git a/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp b/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp |
| index 5feed2b53378580d95ed3c82e61b9a35f98fa700..393f7436ef191ac04f44aec4ace5d637a015dd68 100644 |
| --- a/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp |
| +++ b/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp |
| @@ -298,10 +298,26 @@ void ThreadDebugger::getEventListenersCallback(const v8::FunctionCallbackInfo<v8 |
| v8::Isolate* isolate = info.GetIsolate(); |
| v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| + EventListenerFilter filterMask = static_cast<EventListenerFilter>(EventListenerFilter::ShowPassive | EventListenerFilter::ShowBlocking); |
| + if (info.Length() > 1 && info[1]->IsObject()) { |
| + v8::Local<v8::Object> options = v8::Local<v8::Object>::Cast(info[1]); |
| + |
| + v8::Local<v8::Value> setting; |
| + if (options->Get(context, v8String(isolate, "descendants")).ToLocal(&setting) && setting->IsTrue()) |
| + filterMask = static_cast<EventListenerFilter>(filterMask | EventListenerFilter::ShowDescendants); |
| + |
| + if (options->Get(context, v8String(isolate, "passive")).ToLocal(&setting) && !setting->IsUndefined()) { |
| + if (setting->IsFalse()) |
| + filterMask = static_cast<EventListenerFilter>(filterMask & ~EventListenerFilter::ShowPassive); |
| + else |
| + filterMask = static_cast<EventListenerFilter>(filterMask & ~EventListenerFilter::ShowBlocking); |
| + } |
| + } |
| + |
| V8EventListenerInfoList listenerInfo; |
| // eventListeners call can produce message on ErrorEvent during lazy event listener compilation. |
| debugger->muteWarningsAndDeprecations(); |
| - InspectorDOMDebuggerAgent::eventListenersInfoForTarget(isolate, info[0], listenerInfo); |
| + InspectorDOMDebuggerAgent::eventListenersInfoForTarget(isolate, info[0], filterMask, listenerInfo); |
| debugger->unmuteWarningsAndDeprecations(); |
| v8::Local<v8::Object> result = v8::Object::New(isolate); |
| @@ -315,11 +331,20 @@ void ThreadDebugger::getEventListenersCallback(const v8::FunctionCallbackInfo<v8 |
| v8::Local<v8::Array> listeners; |
| size_t outputIndex = 0; |
| for (auto& info : listenerInfo) { |
| + // Skip contexts not associated with the current context. |
| + if (info.handler->CreationContext() != context) |
|
caseq
2016/05/31 21:36:49
I think this is the right places for this check to
|
| + continue; |
| if (currentEventType != info.eventType) { |
| currentEventType = info.eventType; |
| - listeners = v8::Array::New(isolate); |
| - outputIndex = 0; |
| - result->Set(v8String(isolate, currentEventType), listeners); |
| + v8::Local<v8::Value> matchingList; |
| + if (result->Get(context, v8String(isolate, currentEventType)).ToLocal(&matchingList) && matchingList->IsArray()) { |
| + listeners = v8::Local<v8::Array>::Cast(matchingList); |
| + outputIndex = listeners->Length(); |
| + } else { |
| + listeners = v8::Array::New(isolate); |
| + outputIndex = 0; |
| + result->Set(v8String(isolate, currentEventType), listeners); |
| + } |
| } |
| v8::Local<v8::Object> listenerObject = v8::Object::New(isolate); |