InvalidStateError raised when setting XMLHttpRequest.responseType while in state UNSENT

Issue #1649320

Details

Created
Feb 11, 2015
Privacy
This issue is public.
Reports
Reported by 0 people

Sign in to watch or report this issue.

Steps to reproduce

URL: http://www.zigarn.com/test-set-responseType.html

Repro Steps:

  1. Set XMLHttpRequest.responseType while in UNSENT
  2. You get an “InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable”

{Source code for repro used}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">

    <title>Test set responsetype</title>
</head>

<body>
    <div id="content" />

    <script>
        var container = document.getElementById('content');
        var req = new XMLHttpRequest();
        function displayState(state) {
            switch(state) {
                case XMLHttpRequest.UNSENT:
                    return 'UNSENT';
                case XMLHttpRequest.OPENED:
                    return 'OPENED';
                case XMLHttpRequest.HEADERS_RECEIVED:
                    return 'HEADERS_RECEIVED';
                case XMLHttpRequest.LOADING:
                    return 'LOADING';
                case XMLHttpRequest.DONE:
                    return 'DONE';
            }
        };
        req.onreadystatechange = function() {
            try {
                req.responseType = 'json';
                container.innerHTML += 'XHR state: ' + displayState(req.readyState) + ' ==> no exception<br />';
            } catch (e) {
                container.innerHTML += 'XHR state: ' + displayState(req.readyState) + ' ==> exception: ' + e + '<br />';
            }
        };
        req.onreadystatechange();
        req.open('GET', '/');
        req.send();
    </script>
</body>

</html>

Expected Results:

No error.

Actual Results:

Dev Channel specific:

No

Attachments

0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “Tony S.”

      Changed Assigned To to “Venkat K.”

      Changed Assigned To from “Venkat K.” to “Brandon M.”

      Changed Status to “Confirmed”

      Changed Assigned To from “Brandon M.” to “IE F.”

      Changed Status from “Confirmed”

    You need to sign in to your Microsoft account to add a comment.

    Sign in