fx-compat: Wait until request completion in WebProgressFinishListener
`nsIWebProgressListener.onStateChange()` gets called twice at the end of requests, once with `stateFlags` set to `327696` and once with it set to `262160`, which corresponds to `STATE_STOP + STATE_IS_NETWORK + STATE_IS_REQUEST` and `STATE_STOP + STATE_IS_NETWORK`. httpd.js debug logging shows that the connection is closed between the two calls. In WebProgressFinishListener, we were previously calling `onFinish` after the first one, but in Zotero 7, at least on Linux (or maybe just on slower machines due to a race condition), the file from `saveURI()` doesn't appear to be reliably written after the first call, causing `Attachments.downloadFile()` to fail in `_enforcePDF()` due to an empty file. This changes WebProgressFinishListener to wait until the second `STATE_STOP` call. We'll have to confirm whether this is the state-change pattern for all requests, but it fixes our Find Available PDF tests in CI.
This commit is contained in:
parent
e6776fd922
commit
febc2fcc7d
1 changed files with 2 additions and 1 deletions
|
@ -2003,7 +2003,8 @@ Zotero.WebProgressFinishListener = function(onFinish) {
|
|||
this.onStateChange = function(wp, req, stateFlags, status) {
|
||||
//Zotero.debug('onStateChange: ' + stateFlags);
|
||||
if (stateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP
|
||||
&& stateFlags & Components.interfaces.nsIWebProgressListener.STATE_IS_NETWORK) {
|
||||
&& stateFlags & Components.interfaces.nsIWebProgressListener.STATE_IS_NETWORK
|
||||
&& !(stateFlags & Components.interfaces.nsIWebProgressListener.STATE_IS_REQUEST)) {
|
||||
if (_finished) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue