MessageHandler Modules can be initialized before the corresponding MessageHandler is ready
Categories
(Remote Protocol :: WebDriver BiDi, task, P2)
Tracking
(firefox96 fixed)
Tracking | Status | |
---|---|---|
firefox96 | --- | fixed |
People
(Reporter: jdescottes, Assigned: jdescottes)
Details
(Whiteboard: [bidi-m2-mvp])
Attachments
(1 file)
When creating modules to handle initial session data, the MessageHandler instance owning the module will not be fully initialized.
See the constructor for MessageHandler and WindowGlobalMessageHandler
class MessageHandler extends EventEmitter {
constructor(sessionId, context, sessionDataItems) {
super();
// ...
if (Array.isArray(sessionDataItems)) {
this._applyInitialSessionDataItems(sessionDataItems);
}
}
class WindowGlobalMessageHandler extends MessageHandler {
constructor() {
super(...arguments);
this._innerWindowId = this._context.window.windowGlobalChild.innerWindowId;
}
If there is relevant session data, modules will be initialized at the end of the MessageHandler constructor, before the WindowGlobalMessageHandler could create its _innerWindowId. Meaning that if a module tries to access the information in their own constructor, they will get undefined
.
The call to _applyInitialSessionDataItems should only be done after the constructor has returned, so that module are guaranteed to have a fully functional message handler instance.
Assignee | ||
Comment 1•3 years ago
|
||
Considering that MessageHandler are only instantiated from the MessageHandlerRegistry, I would simply suggest updating the following method:
_createMessageHandler(sessionId, sessionDataItems) {
const messageHandler = new this._messageHandlerClass(
sessionId,
this._context,
sessionDataItems
);
to do
_createMessageHandler(sessionId, sessionDataItems) {
const messageHandler = new this._messageHandlerClass(
sessionId,
this._context,
);
messageHandler.applyInitialSessionDataItems(sessionDataItems);
Comment 2•3 years ago
|
||
Yes, that sounds like the right approach to me too.
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Comment 3•3 years ago
|
||
Depends on D132064
Assignee | ||
Updated•3 years ago
|
Comment 5•3 years ago
|
||
bugherder |
Description
•