Missing window.event in XHR callbacks
Categories
(Core :: DOM: Events, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox126 | --- | fixed |
People
(Reporter: jgraham, Assigned: smaug)
References
(Blocks 2 open bugs, )
Details
Attachments
(1 file)
We don't define window.event
object in XHR callbacks, representing the ProgressEvent that is passed in to the callback function.
From https://bugzilla.mozilla.org/show_bug.cgi?id=1888001#c3:
It seems it's an issue on firefox because of how we handle the global event object on the window ( which is deprecated btw ). Here is a snippet from some code on the website.
function saveDependant() {
var n, t;
validateForm() &&
((n = new XMLHttpRequest()),
n.open("POST", "/CustomerProfile/SaveDependent"),
(n.onload = () => handleSaveDependantReponse(JSON.parse(event.target.response))),
(t = new FormData(document.getElementById("addDependent"))),
n.send(t));
}
This code fails with the error: event
is undefined in this case.
It fails in firefox and passes in chrome/safari. Not sure if we can fix this, but this is really not how you usually access the xhr response. It's passed as an argument to onload
so there is no need to access the global one.
Here is a codepen to reproduce this issue. On firefox you should see an error message in the console.
Assignee | ||
Comment 1•3 months ago
|
||
Updated•3 months ago
|
Pushed by opettay@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/469884ac63bc Missing window.event in XHR callbacks, r=edgar
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/45399 for changes under testing/web-platform/tests
Comment 4•3 months ago
|
||
bugherder |
Upstream PR merged by moz-wptsync-bot
Description
•