summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/xhr/abort-event-loadend.any.js
blob: 7c19c6d4f3f2e31485909f475d726217b02056a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// META: title=XMLHttpRequest: The abort() method: Fire a progress event named loadend

        var test = async_test(function(test)
        {
            var xhr = new XMLHttpRequest();

            xhr.onloadstart = function()
            {
                test.step(function()
                {
                    if (xhr.readyState == 1)
                    {
                        xhr.abort();
                    }
                });
            };

            xhr.onloadend = function(e)
            {
                test.step(function()
                {
                    assert_true(e instanceof ProgressEvent);
                    assert_equals(e.type, "loadend");
                    test.done();
                });
            };

            xhr.open("GET", "resources/content.py", true);
            xhr.send();
        });