Closed
Bug 1018900
Opened 10 years ago
Closed 10 years ago
eventListenerService.getListenerInfoFor(node) listenerDebugObject sometimes missing script property
Categories
(Core :: DOM: Events, defect)
Core
DOM: Events
Tracking
()
RESOLVED
INVALID
People
(Reporter: miker, Unassigned)
References
Details
Attachments
(1 file)
42.59 KB,
patch
|
Details | Diff | Splinter Review |
These are the best STR I can come up with:
1. Apply the STR patch.
2. Right-click the globe in about:home and inspect element.
3. Tools -> Web Developer -> Browser Toolbox
4. Allow the incoming connection and click the Inspector tab.
5. Click the inspect button in the browser toolbox.
6. Inspect a CSS value in the Rule View e.g. #brandLogo's 192px, click to lock onto the value.
7. In the browser toolbox click on the selected span's ev button.
An empty event bubble will be displayed.
In the background this is what we are doing:
// A listener is added at browser/devtools/styleinspector/rule-view.js:2156 (this is the event you tried to view):
this.valueSpan.addEventListener("click", (event) => {
let target = event.target;
if (target.nodeName === "a") {
event.stopPropagation();
event.preventDefault();
this.browserWindow.openUILinkIn(target.href, "tab");
}
}, false);
// We try to get the event listeners at toolkit/devtools/server/actors/inspector.js:324:
getEventListeners: function(node) {
let global = node.ownerGlobal || node;
let dbg = new Debugger();
let globalDebugObject = dbg.addDebuggee(global);
let handlers = eventListenerService.getListenerInfoFor(node);
for (let handler of handlers) {
let listener = handler.listenerObject;
if (listener) {
let listenerDebugObject = globalDebugObject.makeDebuggeeValue(listener);
let script = listenerDebugObject.script;
// script is undefined for some listeners in the browser debugger... why?
Sorry we don't have any simpler STR but this is blocking our displaying of events in the inspector.
Comment 1•10 years ago
|
||
Is Cu.getGlobalForObject(listener) === global?
Reporter | ||
Comment 2•10 years ago
|
||
(In reply to Simon Lindholm from comment #1)
> Is Cu.getGlobalForObject(listener) === global?
It returns [object Sandbox]... I am assuming because it is inside an ifame.
Reporter | ||
Comment 3•10 years ago
|
||
It turns out that using node.ownerGlobal doesn't necessarily return the global for the event listener. I just needed to use the following for each listener:
let global = Cu.getGlobalForObject(listener);
let globalDebugObject = dbg.addDebuggee(global);
This code works:
getEventListeners: function(node) {
let dbg = new Debugger();
let handlers = eventListenerService.getListenerInfoFor(node);
let events = [];
for (let handler of handlers) {
let listener = handler.listenerObject;
let global = Cu.getGlobalForObject(listener);
let globalDebugObject = dbg.addDebuggee(global);
if (listener) {
let listenerDebugObject = globalDebugObject.makeDebuggeeValue(listener);
let script = listenerDebugObject.script;
let scriptSource;
if (!script && listener.handleEvent) {
let desc = listenerDebugObject.proto.getOwnPropertyDescriptor("handleEvent");
if (desc) {
script = desc.value.script;
scriptSource = handler.listenerObject.handleEvent.toString();
}
}
if (script) {
Reporter | ||
Updated•10 years ago
|
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•