/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/** * *@param{string}groupID *@param{string}eventType *@param{Function}condition:OptionalfunctionthattakesaWindowasparameter.When *passed,theeventwillonlybeincludediftheresultofthefunction *callis`true`(See`getAvailableEventBreakpoints`). *@returns{object}
*/ function generalEvent(groupID, eventType, condition) { return {
id: `event.${groupID}.${eventType}`,
type: "event",
name: eventType,
message: `DOM '${eventType}' event`,
eventType, // DOM Events which may fire on the global object, or on DOM Elements
targetTypes: ["global", "node"],
condition,
};
} function nodeEvent(groupID, eventType) { return {
...generalEvent(groupID, eventType),
targetTypes: ["node"],
};
} function mediaNodeEvent(groupID, eventType) { return {
...generalEvent(groupID, eventType),
targetTypes: ["node"],
// Media events need some specific handling in `eventBreakpointForNotification()` // to ensure that the event is fired on either <video> or <audio> tags.
isMediaEvent: true,
};
} function globalEvent(groupID, eventType) { return {
...generalEvent(groupID, eventType),
message: `Global '${eventType}' event`, // DOM Events which are only fired on the global object
targetTypes: ["global"],
};
} function xhrEvent(groupID, eventType) { return {
...generalEvent(groupID, eventType),
message: `XHR '${eventType}' event`,
targetTypes: ["xhr"],
};
}
if (!Array.isArray(targetTypes) || !targetTypes.length) { thrownew Error("Expect a targetTypes array for each event definition");
}
for (const targetType of targetTypes) {
let byEventType = DOM_EVENTS[targetType]; if (!byEventType) {
byEventType = {};
DOM_EVENTS[targetType] = byEventType;
}
if (notification.type === "domEvent") { const domEventNotification = DOM_EVENTS[notification.targetType]; if (!domEventNotification) { returnnull;
}
// The 'event' value is a cross-compartment wrapper for the DOM Event object. // While we could use that directly in the main thread as an Xray wrapper, // when debugging workers we can't, because it is an opaque wrapper. // To make things work, we have to always interact with the Event object via // the Debugger.Object interface. const evt = dbg
.makeGlobalObjectReference(notification.global)
.makeDebuggeeValue(notification.event);
const eventType = evt.getProperty("type").return; const id = domEventNotification[eventType]; if (!id) { returnnull;
} const eventBreakpoint = EVENTS_BY_ID[id];
// Does some additional checks for media events to ensure the DOM Event // was fired on either <audio> or <video> tags. if (eventBreakpoint.isMediaEvent) { const currentTarget = evt.getProperty("currentTarget").return; if (!currentTarget) { returnnull;
}
exports.makeEventBreakpointMessage = makeEventBreakpointMessage; function makeEventBreakpointMessage(id) { return EVENTS_BY_ID[id].message;
}
exports.firstStatementBreakpointId = firstStatementBreakpointId; function firstStatementBreakpointId() { return SCRIPT_FIRST_STATEMENT_BREAKPOINT.id;
}
exports.eventsRequireNotifications = eventsRequireNotifications; function eventsRequireNotifications(ids) { for (const id of ids) { const eventBreakpoint = EVENTS_BY_ID[id];
// Script events are implemented directly in the server and do not require // notifications from Gecko, so there is no need to watch for them. if (eventBreakpoint && eventBreakpoint.type !== "script") { returntrue;
}
} returnfalse;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.