Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

status is null when readyState < 4 #3068

Closed
qsniyg opened this issue Jan 21, 2020 · 0 comments · Fixed by #3069
Closed

status is null when readyState < 4 #3068

qsniyg opened this issue Jan 21, 2020 · 0 comments · Fixed by #3069
Milestone

Comments

@qsniyg
Copy link
Contributor

qsniyg commented Jan 21, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants