mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-08 20:28:42 +02:00
--HG-- rename : testing/web-platform/meta/websockets/interfaces/WebSocket/events/011.html.ini => testing/web-platform/meta/IndexedDB/idbcursor_update_index5.htm.ini rename : testing/web-platform/meta/websockets/interfaces/WebSocket/events/011.html.ini => testing/web-platform/meta/IndexedDB/idbindex_get7.htm.ini rename : testing/web-platform/meta/websockets/interfaces/WebSocket/events/011.html.ini => testing/web-platform/meta/IndexedDB/idbindex_openCursor2.htm.ini rename : testing/web-platform/meta/websockets/interfaces/WebSocket/events/011.html.ini => testing/web-platform/meta/IndexedDB/idbindex_openKeyCursor3.htm.ini rename : testing/web-platform/moz.build => testing/web-platform/mozilla/tests/placeholder rename : testing/web-platform/moz.build => testing/web-platform/outbound/tests/placeholder rename : testing/web-platform/tests/dom/nodes/Document-createProcessingInstruction-literal-1.xhtml => testing/web-platform/tests/dom/nodes/ProcessingInstruction-literal-1.xhtml rename : testing/web-platform/tests/dom/nodes/Document-createProcessingInstruction-literal-2.xhtml => testing/web-platform/tests/dom/nodes/ProcessingInstruction-literal-2.xhtml rename : testing/web-platform/tests/pointerevents/pointerevent_lostpointercapture_for_disconnected_node.html => testing/web-platform/tests/pointerevents/pointerevent_lostpointercapture_for_disconnected_node-manual.html rename : testing/web-platform/tests/pointerevents/pointerevent_pointerleave_after_pointercancel_touch.html => testing/web-platform/tests/pointerevents/pointerevent_pointerleave_after_pointercancel_touch-manual.html rename : testing/web-platform/tests/pointerevents/pointerevent_pointerleave_after_pointerup_nohover.html => testing/web-platform/tests/pointerevents/pointerevent_pointerleave_after_pointerup_nohover-manual.html rename : testing/web-platform/tests/pointerevents/pointerevent_pointerout_after_pointercancel_touch.html => testing/web-platform/tests/pointerevents/pointerevent_pointerout_after_pointercancel_touch-manual.html rename : testing/web-platform/tests/pointerevents/pointerevent_pointerout_after_pointerup_nohover.html => testing/web-platform/tests/pointerevents/pointerevent_pointerout_after_pointerup_nohover-manual.html rename : testing/web-platform/tests/pointerevents/pointerevent_pointerout_pen.html => testing/web-platform/tests/pointerevents/pointerevent_pointerout_pen-manual.html rename : testing/web-platform/tests/pointerevents/pointerevent_setpointercapture_disconnected.html => testing/web-platform/tests/pointerevents/pointerevent_setpointercapture_disconnected-manual.html rename : testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-null.html => testing/web-platform/tests/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-undefined.html extra : rebase_source : 1fb6206eb45537037d28bebf5bc9de02791c4a17
77 lines
3.6 KiB
HTML
77 lines
3.6 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>XMLHttpRequest: progress events and GZIP encoding</title>
|
|
<meta name="timeout" content="long">
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<link rel="help" href="https://xhr.spec.whatwg.org/#firing-events-using-the-progressevent-interface-for-http" data-tested-assertations="following::p[contains(text(),'content-encodings')]" />
|
|
<!-- TODO: find better spec reference when https://www.w3.org/Bugs/Public/show_bug.cgi?id=25587 is fixed -->
|
|
</head>
|
|
<body>
|
|
<div id="log"></div>
|
|
<script>
|
|
var test = async_test()
|
|
test.step(function() {
|
|
var client = new XMLHttpRequest()
|
|
/*
|
|
|
|
Two behaviours are considered acceptable, so there are two ways to
|
|
pass this test
|
|
|
|
a) Set data for the compressed resource:
|
|
* event.total reflects the Content-length of the gzipp'ed resource
|
|
* event.loaded how many gzipped bytes have arrived over the wire so far
|
|
* lengthComputable is true
|
|
|
|
or
|
|
|
|
b) If the implementation does not provide progress details for the compressed
|
|
resource, set
|
|
* lengthComputable to false
|
|
* event.total to 0
|
|
* event.loaded to the number of bytes available so far after gzip decoding
|
|
|
|
Implications of this are tested here as follows:
|
|
|
|
* If lengthComputable is true:
|
|
* Event.total must match Content-length header
|
|
* event.loaded should be a smaller number while resource is loading
|
|
and match Content-length when loading is finished
|
|
* Setting event.loaded to equal event.total for each progress event if the
|
|
resource is not fully downloaded would be cheating
|
|
|
|
* If lengthComputable is false:
|
|
* event.total should be 0
|
|
* event.loaded should be the length of the decompressed content, i.e.
|
|
bigger than Content-length header value when finished loading
|
|
|
|
*/
|
|
client.addEventListener('loadend', test.step_func(function(e){
|
|
var len = parseInt(client.getResponseHeader('content-length'), 10)
|
|
if(e.lengthComputable){
|
|
assert_equals(e.total, len, 'event.total is content-length')
|
|
assert_equals(e.loaded, len, 'event.loaded should be content-length at loadend')
|
|
}else{
|
|
assert_equals(e.total, 0, 'if implementation can\'t compute event.total for gzipped content it is 0')
|
|
assert_true(e.loaded >= len, 'event.loaded should be set even if total is not computable')
|
|
}
|
|
test.done();
|
|
}), false)
|
|
client.addEventListener('progress', test.step_func(function(e){
|
|
if(e.lengthComputable && e.total && e.loaded && e.target.readyState < 4){
|
|
assert_not_equals(e.total, e.loaded, 'total should not equal loaded while download/decode is incomplete')
|
|
// We should only do this assertation once
|
|
// it's theoretically possible that all the data would get in
|
|
// and a progress event fire before the readyState switches from 3 to 4 -
|
|
// in this case we might report bogus and random failures. Better to remove the event listener again..
|
|
client.removeEventListener('progress', arguments.callee, false);
|
|
}
|
|
}), false)
|
|
// image.gif is 165375 bytes compressed. Sending 45000 bytes at a time with 1 second delay will load it in 4 seconds
|
|
client.open("GET", "resources/image.gif?pipe=gzip|trickle(45000:d1:r2)", true)
|
|
client.send()
|
|
})
|
|
</script>
|
|
</body>
|
|
</html>
|