Browse Source

fix: use sentReadyState4 only for readystatechange

tophf 2 years ago
parent
commit
1d47a8899f
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/background/utils/requests.js

+ 4 - 2
src/background/utils/requests.js

@@ -106,10 +106,12 @@ function xhrCallbackWrapper(req, events, blobbed, chunked, isJson) {
     const shouldNotify = events.includes(type);
     const isEnd = type === 'loadend';
     const readyState4 = xhr.readyState === 4;
-    if ((!shouldNotify || readyState4 && sentReadyState4) && !isEnd) {
+    if (!shouldNotify && !isEnd
+    // Firefox duplicates readystatechange for state=4 randomly, #1862
+    || sentReadyState4 && (tmp = readyState4 && type === 'readystatechange')) {
       return;
     }
-    if (readyState4) { // Firefox duplicates it randomly, #1862
+    if (tmp) {
       sentReadyState4 = true;
     }
     if (!contentType) {