зеркало из https://github.com/mozilla/gecko-dev.git
automated test for bug 669049, r=sicking
This commit is contained in:
Родитель
e4336a1e42
Коммит
58b364fbd7
|
@ -219,6 +219,7 @@ _TEST_FILES1 = \
|
||||||
file_XHR_fail1.txt^headers^ \
|
file_XHR_fail1.txt^headers^ \
|
||||||
file_XHR_binary1.bin \
|
file_XHR_binary1.bin \
|
||||||
file_XHR_binary1.bin^headers^ \
|
file_XHR_binary1.bin^headers^ \
|
||||||
|
file_XHR_binary2.bin \
|
||||||
test_bug428847.html \
|
test_bug428847.html \
|
||||||
file_bug428847-1.xhtml \
|
file_bug428847-1.xhtml \
|
||||||
file_bug428847-2.xhtml \
|
file_bug428847-2.xhtml \
|
||||||
|
|
Двоичный файл не отображается.
|
@ -178,7 +178,7 @@ checkResponseAccessThrows(xhr); // Check twice to ensure that we still throw
|
||||||
// test response (responseType='blob')
|
// test response (responseType='blob')
|
||||||
var onloadCount = 0;
|
var onloadCount = 0;
|
||||||
function checkOnloadCount() {
|
function checkOnloadCount() {
|
||||||
if (++onloadCount >= 2) SimpleTest.finish();
|
if (++onloadCount >= 3) SimpleTest.finish();
|
||||||
};
|
};
|
||||||
|
|
||||||
// with a simple text file
|
// with a simple text file
|
||||||
|
@ -203,7 +203,8 @@ fr.onload = function() {
|
||||||
fr.readAsBinaryString(b);
|
fr.readAsBinaryString(b);
|
||||||
|
|
||||||
// with a binary file
|
// with a binary file
|
||||||
xhr = new XMLHttpRequest();
|
(function(){
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.onreadystatechange = function() {
|
xhr.onreadystatechange = function() {
|
||||||
switch (xhr.readyState) {
|
switch (xhr.readyState) {
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -228,6 +229,37 @@ xhr.onreadystatechange = function() {
|
||||||
};
|
};
|
||||||
xhr.open("GET", 'file_XHR_binary1.bin', true);
|
xhr.open("GET", 'file_XHR_binary1.bin', true);
|
||||||
xhr.send(null);
|
xhr.send(null);
|
||||||
|
})();
|
||||||
|
|
||||||
|
(function(){
|
||||||
|
// with a larger binary file
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.onreadystatechange = function() {
|
||||||
|
if (xhr.readyState == 4) {
|
||||||
|
b = xhr.response;
|
||||||
|
ok(b != null, "should have a non-null blob");
|
||||||
|
is(b.size, 65536, "wrong blob size");
|
||||||
|
|
||||||
|
var fr = new FileReader();
|
||||||
|
fr.onload = function() {
|
||||||
|
var u8 = new Uint8Array(fr.result);
|
||||||
|
for (var i = 0; i < 65536; i++) {
|
||||||
|
if (u8[i] !== (i & 255)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is(i, 65536, "wrong value at offset " + i);
|
||||||
|
checkOnloadCount();
|
||||||
|
};
|
||||||
|
xhr = null; // kill the XHR object
|
||||||
|
SpecialPowers.gc();
|
||||||
|
fr.readAsArrayBuffer(b);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.open("GET", 'file_XHR_binary2.bin', true);
|
||||||
|
xhr.responseType = 'blob';
|
||||||
|
xhr.send(null);
|
||||||
|
})();
|
||||||
|
|
||||||
var client = new XMLHttpRequest();
|
var client = new XMLHttpRequest();
|
||||||
client.onreadystatechange = function() {
|
client.onreadystatechange = function() {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче