|
@@ -147,15 +147,15 @@ describe('HTTP error should not throw error event', (report, done) => {
|
147
|
147
|
describe('request headers records should be cleared by open()', (report, done) => {
|
148
|
148
|
let xhr = new XMLHttpRequest()
|
149
|
149
|
xhr.open('GET', `${TEST_SERVER_URL}/xhr-header`)
|
150
|
|
- xhr.setRequestHeader('header-test', '100')
|
|
150
|
+ xhr.setRequestHeader('value', '100')
|
151
|
151
|
xhr.open('GET', `${TEST_SERVER_URL}/xhr-header`)
|
152
|
|
- xhr.setRequestHeader('header-test', '200')
|
|
152
|
+ xhr.setRequestHeader('value', '200')
|
153
|
153
|
xhr.send()
|
154
|
154
|
xhr.onreadystatechange = function() {
|
155
|
155
|
if(this.readyState == 4) {
|
156
|
156
|
report(<Assert key="headers should be cleared by open()"
|
157
|
157
|
expect={'200'}
|
158
|
|
- actual={this.response['header-test']}/>)
|
|
158
|
+ actual={this.response['value']}/>)
|
159
|
159
|
done()
|
160
|
160
|
}
|
161
|
161
|
}
|
|
@@ -256,9 +256,13 @@ describe('upload progress event test', (report, done) => {
|
256
|
256
|
|
257
|
257
|
describe('timeout event catchable', (report, done) => {
|
258
|
258
|
let xhr = new XMLHttpRequest()
|
|
259
|
+ let count = 0
|
259
|
260
|
xhr.timeout = 1
|
260
|
261
|
xhr.ontimeout = function() {
|
261
|
262
|
report(
|
|
263
|
+ <Info key="event should only trigger once" uid="1000">
|
|
264
|
+ <Text>{count}</Text>
|
|
265
|
+ </Info>,
|
262
|
266
|
<Assert key="event catchable"
|
263
|
267
|
expect={true}
|
264
|
268
|
actual={true}/>)
|
|
@@ -271,24 +275,33 @@ describe('timeout event catchable', (report, done) => {
|
271
|
275
|
|
272
|
276
|
describe('upload progress event should not be triggered when body is empty', (report, done) => {
|
273
|
277
|
let xhr = new XMLHttpRequest()
|
|
278
|
+ let count = 0
|
274
|
279
|
xhr.upload.onloadstart = function() {
|
275
|
280
|
report(
|
276
|
281
|
<Assert key="loadstart event should not triggered"
|
|
282
|
+ uid="aaa"
|
277
|
283
|
expect={true}
|
278
|
284
|
actual={false}/>)
|
279
|
285
|
}
|
280
|
286
|
xhr.upload.onprogress = function() {
|
281
|
287
|
report(
|
282
|
288
|
<Assert key="progress event should not triggered"
|
|
289
|
+ uid="bbb"
|
283
|
290
|
expect={true}
|
284
|
291
|
actual={false}/>)
|
285
|
292
|
}
|
286
|
293
|
xhr.onreadystatechange = function() {
|
287
|
294
|
if(this.readyState == XMLHttpRequest.DONE) {
|
|
295
|
+ count++
|
288
|
296
|
report(
|
289
|
297
|
<Assert key="Great! upload event not triggered"
|
|
298
|
+ uid="ccc"
|
290
|
299
|
expect={true}
|
291
|
|
- actual={true}/>)
|
|
300
|
+ actual={true}/>,
|
|
301
|
+ <Assert key="This should not triggered multiple times"
|
|
302
|
+ uid="ddd"
|
|
303
|
+ expect={1}
|
|
304
|
+ actual={count}/>)
|
292
|
305
|
done()
|
293
|
306
|
}
|
294
|
307
|
}
|