Sync web-platform-tests up to revision a5b95cb31914507088a4eda16f7674bbc6f3313f
[WebKit-https.git] / LayoutTests / imported / w3c / web-platform-tests / XMLHttpRequest / event-load.htm
1 <!doctype html>
2 <meta charset=utf-8>
3 <title>XMLHttpRequest: The send() method: Fire an event named load (synchronous flag is unset)</title>
4 <script src="/resources/testharness.js"></script>
5 <script src="/resources/testharnessreport.js"></script>
6 <link rel="help" href="https://xhr.spec.whatwg.org/#handler-xhr-onload" data-tested-assertations="../.." />
7 <link rel="help" href="https://xhr.spec.whatwg.org/#event-xhr-load" data-tested-assertations="../.." />
8 <div id="log"></div>
9
10 <script>
11   var test = async_test();
12   test.step(function() {
13     var client = new XMLHttpRequest();
14     client.onload = test.step_func(function(e) {
15       assert_true(e instanceof ProgressEvent);
16       assert_equals(e.type, "load");
17       assert_equals(client.readyState, 4);
18       test.done();
19     });
20     client.onreadystatechange = test.step_func(function() {
21       if (client.readyState !== 4) return;
22
23       test.step_timeout(() => {
24           assert_unreached("Didn't get load event within 4ms of readystatechange==4");
25       }, 4);
26     });
27     client.open("GET", "resources/well-formed.xml");
28     client.send(null);
29   });
30 </script>