Skip to content

status is null when readyState < 4 #3068

@qsniyg

Description

@qsniyg

For onprogress events (where readyState < 4), status is set to null, even though it's available to the extension (e.g. Violentmonkey works fine).

Test script:

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @include      *
// @grant        GM.xmlHttpRequest
// ==/UserScript==

(function() {
    'use strict';

    var xhr;

    var loadfunc = function(resp) {
        if (resp.readyState < 2)
            return;

        console.log(resp);
        xhr.abort();
    };

    var obj = {
        url: "https://www.google.com/"
    };

    if (true) {
        obj.onprogress = loadfunc; // status == null
    } else {
        obj.onload = loadfunc; // status == 200
    }

    xhr = GM.xmlHttpRequest(obj);
})();

This is problematic for my userscript (https://greasyfork.org/en/scripts/36662-image-max-url), as it believes status == 0/null to mean that the website was blocked via either tracking protection or that the domain/ip couldn't be resolved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions