Closed
Bug 1764688
Opened 3 years ago
Closed 3 years ago
Misuse of arrow function + this in MessageHandlerFrameActor.jsm
Categories
(Remote Protocol :: WebDriver BiDi, defect, P3)
Remote Protocol
WebDriver BiDi
Tracking
(firefox101 fixed)
RESOLVED
FIXED
101 Branch
Tracking | Status | |
---|---|---|
firefox101 | --- | fixed |
People
(Reporter: arai, Assigned: arai)
References
Details
Attachments
(1 file)
const MessageHandlerFrameActor = {
registered: false,
register: () => {
if (this.registered) {
return;
}
...
this.registered = true;
arrow function inherits this
from the enclosing scope, and the this
there is not the this
value for the function call (so, MessageHandlerFrameActor
for MessageHandlerFrameActor.register()
), but the global this
value.
The code work as expected because there's only one MessageHandlerFrameActor
, and the global registered
variable is falsy (undefined
) at the beginning, and no other code touches it.
the code should use method definition instead.
Assignee | ||
Updated•3 years ago
|
Assignee: nobody → arai.unmht
Status: NEW → ASSIGNED
Comment 1•3 years ago
|
||
Good point, thanks for filing :arai (and for taking the bug :) )
Assignee | ||
Comment 2•3 years ago
|
||
Pushed by arai_a@mac.com:
https://hg.mozilla.org/integration/autoland/rev/52c74d875e24
Fix this variable in MessageHandlerFrameActor.register. r=jdescottes,webdriver-reviewers
Comment 4•3 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
status-firefox101:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → 101 Branch
You need to log in
before you can comment on or make changes to this bug.
Description
•