| ronkorving | 5a4ba02 | 2013-06-08 07:34:56 | [diff] [blame] | 1 | <!doctype html> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <meta charset="utf-8"> |
| Hallvord Reiar M. Steen | ee396df | 2013-06-10 13:27:40 | [diff] [blame] | 5 | <title>XMLHttpRequest: the LOADING state change should only happen once</title> |
| ronkorving | 5a4ba02 | 2013-06-08 07:34:56 | [diff] [blame] | 6 | <script src="/resources/testharness.js"></script> |
| 7 | <script src="/resources/testharnessreport.js"></script> |
| Hallvord Reiar M. Steen | c136f2b | 2013-06-10 13:51:45 | [diff] [blame] | 8 | <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-send()-method" data-tested-assertations="following::ol[1]/li[10]/dt[1]"> |
| 9 | <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#infrastructure-for-the-send()-method" data-tested-assertations="following::dt[7] following::a[contains(@href,'#switch-loading')]/.."> |
| 10 | <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#switch-loading" data-tested-assertations="following::ol[1]/li[1] following::ol[1]/li[2]"> |
| ronkorving | 5a4ba02 | 2013-06-08 07:34:56 | [diff] [blame] | 11 | </head> |
| 12 | |
| 13 | <div id="log"></div> |
| 14 | |
| 15 | <script> |
| 16 | |
| 17 | var test = async_test(); |
| 18 | |
| 19 | test.step(function() { |
| 20 | var client = new XMLHttpRequest(); |
| 21 | var countedLoading = 0; |
| 22 | |
| 23 | client.onreadystatechange = test.step_func(function() { |
| 24 | if (client.readyState === 3) { |
| 25 | countedLoading += 1; |
| 26 | } |
| 27 | |
| 28 | if (client.readyState === 4) { |
| ronkorving | 05650d8 | 2013-06-08 07:36:47 | [diff] [blame] | 29 | assert_equals(countedLoading, 1, "LOADING state change may only be emitted once"); |
| ronkorving | 5a4ba02 | 2013-06-08 07:34:56 | [diff] [blame] | 30 | |
| 31 | test.done(); |
| 32 | } |
| 33 | }); |
| 34 | |
| James Graham | 234a672 | 2013-09-17 17:54:38 | [diff] [blame^] | 35 | client.open("GET", "resources/trickle.py?count=1000"); |
| ronkorving | 5a4ba02 | 2013-06-08 07:34:56 | [diff] [blame] | 36 | client.send(null); |
| 37 | }); |
| 38 | </script> |