зеркало из https://github.com/mozilla/pjs.git
Merge m-c to s-c
This commit is contained in:
Коммит
3f18bc3c19
|
@ -23,9 +23,11 @@ Tests of DOM Worker Threads XHR(Bug 450452 )
|
|||
|
||||
var worker = new Worker("xhr_worker.js");
|
||||
|
||||
var gotUploadLoad = false, gotLoadend = false;
|
||||
|
||||
worker.onmessage = function(event) {
|
||||
is(event.target, worker);
|
||||
var args = eval(event.data);
|
||||
var args = event.data;
|
||||
switch (args.type) {
|
||||
case "progress": {
|
||||
ok(parseInt(args.current) <= parseInt(args.total));
|
||||
|
@ -33,12 +35,17 @@ Tests of DOM Worker Threads XHR(Bug 450452 )
|
|||
case "error": {
|
||||
ok(false, "XHR error: " + args.error);
|
||||
} break;
|
||||
case "upload.load": {
|
||||
gotUploadLoad = true;
|
||||
} break;
|
||||
case "load": {
|
||||
is(args.data, "A noisy noise annoys an oyster.");
|
||||
ok(gotUploadLoad, "Should have gotten upload load event");
|
||||
gotLoadend = true;
|
||||
is(args.data, "A noisy noise annoys an oyster.", "correct data");
|
||||
document.getElementById("content").textContent = args.data;
|
||||
} break;
|
||||
case "loadend": {
|
||||
ok(true, "Should have got loadend.");
|
||||
ok(gotLoadend, "Should have gotten load.");
|
||||
SimpleTest.finish();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -12,12 +12,12 @@ function onload(event) {
|
|||
if (event.target.status != 200) {
|
||||
var message = { type: "error",
|
||||
error: event.target.status };
|
||||
postMessage(message.toSource());
|
||||
postMessage(message);
|
||||
}
|
||||
|
||||
var message = { type: "load",
|
||||
data: xhr.responseText };
|
||||
postMessage(message.toSource());
|
||||
postMessage(message);
|
||||
}
|
||||
|
||||
xhr.onload = onload;
|
||||
|
@ -26,7 +26,7 @@ xhr.removeEventListener("load", onload, false);
|
|||
if (!xhr.onload) {
|
||||
var message = { type: "error",
|
||||
error: "Lost message listener!" };
|
||||
postMessage(message.toSource());
|
||||
postMessage(message);
|
||||
}
|
||||
|
||||
xhr.addEventListener("error", function(event) {
|
||||
|
@ -35,7 +35,7 @@ xhr.addEventListener("error", function(event) {
|
|||
}
|
||||
var message = { type: "error",
|
||||
error: event.target.status };
|
||||
postMessage(message.toSource());
|
||||
postMessage(message);
|
||||
}, false);
|
||||
|
||||
function onprogress(event) {
|
||||
|
@ -45,7 +45,7 @@ function onprogress(event) {
|
|||
var message = { type: "progress",
|
||||
current: event.loaded,
|
||||
total: event.total };
|
||||
postMessage(message.toSource());
|
||||
postMessage(message);
|
||||
}
|
||||
xhr.addEventListener("progress", onprogress, false);
|
||||
|
||||
|
@ -54,15 +54,19 @@ xhr.removeEventListener("doopety", function(event) {}, false);
|
|||
|
||||
xhr.onloadend = function(event) {
|
||||
var message = { type: "loadend" };
|
||||
postMessage(message.toSource());
|
||||
postMessage(message);
|
||||
}
|
||||
|
||||
var upload = xhr.upload;
|
||||
upload.onprogress = function(event) { };
|
||||
upload.addEventListener("readystatechange", function(event) { }, false);
|
||||
upload.removeEventListener("readystatechange", function(event) { }, false);
|
||||
upload.addEventListener("foo", function(event) { }, false);
|
||||
upload.removeEventListener("foo", function(event) { }, false);
|
||||
upload.addEventListener("load", function(event) { }, false);
|
||||
upload.removeEventListener("readystatechange", function(event) { }, false);
|
||||
upload.removeEventListener("foo", function(event) { }, false);
|
||||
upload.onload = function(event) {
|
||||
var message = { type: "upload.load" };
|
||||
postMessage(message);
|
||||
}
|
||||
|
||||
onmessage = function(event) {
|
||||
if (xhr.DONE != 4 || XMLHttpRequest.DONE != 4) {
|
||||
|
@ -71,6 +75,6 @@ onmessage = function(event) {
|
|||
if (xhr.readystate > xhr.UNSENT) {
|
||||
throw "XHR already running!";
|
||||
}
|
||||
xhr.open("GET", event.data);
|
||||
xhr.send(null);
|
||||
xhr.open("POST", event.data);
|
||||
xhr.send("Data to send");
|
||||
}
|
||||
|
|
|
@ -221,7 +221,10 @@ nsFontFaceLoader::OnStreamComplete(nsIStreamLoader* aLoader,
|
|||
// because HTTP responses such as 404 (Not Found) will still result in
|
||||
// a success code and potentially an HTML error page from the server
|
||||
// as the resulting data. We don't want to use that as a font.
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
|
||||
nsCOMPtr<nsIRequest> request;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel;
|
||||
aLoader->GetRequest(getter_AddRefs(request));
|
||||
httpChannel = do_QueryInterface(request);
|
||||
if (httpChannel) {
|
||||
bool succeeded;
|
||||
nsresult rv = httpChannel->GetRequestSucceeded(&succeeded);
|
||||
|
|
Загрузка…
Ссылка в новой задаче