Sync web-platform-tests up to revision a5b95cb31914507088a4eda16f7674bbc6f3313f
[WebKit-https.git] / LayoutTests / imported / w3c / web-platform-tests / XMLHttpRequest / event-loadstart-upload.htm
1 <!doctype html>
2 <html lang=en>
3 <meta charset=utf-8>
4 <title>XMLHttpRequest: The send() method: Fire a progress event named loadstart on upload object (synchronous flag is unset)</title>
5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 <link rel="help" href="https://xhr.spec.whatwg.org/#handler-xhr-onprogress" data-tested-assertations="../.." />
8 <link rel="help" href="https://xhr.spec.whatwg.org/#event-xhr-progress" data-tested-assertations="../.." />
9 <div id="log"></div>
10 <script>
11   var test = async_test();
12   test.step(function() {
13     var client = new XMLHttpRequest();
14     client.upload.onloadstart = test.step_func(function(e) {
15       assert_true(e instanceof ProgressEvent);
16       assert_equals(e.total, 7, 'upload.onloadstart: event.total');
17       assert_equals(e.loaded, 0, 'upload.onloadstart: event.loaded');
18       assert_equals(e.type, "loadstart");
19       test.done();
20     });
21     client.onreadystatechange = test.step_func(function() {
22       if (client.readyState === 4)
23         assert_unreached("onloadstart not called.");
24     });
25     client.open("POST", "resources/trickle.py?ms=5&count=8");
26     client.send('foo=bar');
27   });
28 </script>