From 815361421e90ad01edffa0016510693ea46e9692 Mon Sep 17 00:00:00 2001 From: John Daggett Date: Fri, 11 Nov 2011 08:38:23 +0900 Subject: [PATCH 1/2] Bug 701262. Fix font redirect request failures. r=sicking --- layout/style/nsFontFaceLoader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/layout/style/nsFontFaceLoader.cpp b/layout/style/nsFontFaceLoader.cpp index d2add2628de..db32efd4bf6 100644 --- a/layout/style/nsFontFaceLoader.cpp +++ b/layout/style/nsFontFaceLoader.cpp @@ -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 httpChannel = do_QueryInterface(mChannel); + nsCOMPtr request; + nsCOMPtr httpChannel; + aLoader->GetRequest(getter_AddRefs(request)); + httpChannel = do_QueryInterface(request); if (httpChannel) { bool succeeded; nsresult rv = httpChannel->GetRequestSucceeded(&succeeded); From 1154a4a9faabd999c16cf377eba5cd8dd8446646 Mon Sep 17 00:00:00 2001 From: Jonas Sicking Date: Thu, 10 Nov 2011 16:29:34 -0800 Subject: [PATCH 2/2] Bug 687220: Add test for event handlers on the xhr.upload object in workers. r=bent --- dom/workers/test/test_xhr.html | 13 ++++++++++--- dom/workers/test/xhr_worker.js | 26 +++++++++++++++----------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/dom/workers/test/test_xhr.html b/dom/workers/test/test_xhr.html index 12ed32c93c2..b4161f34ed8 100644 --- a/dom/workers/test/test_xhr.html +++ b/dom/workers/test/test_xhr.html @@ -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; } diff --git a/dom/workers/test/xhr_worker.js b/dom/workers/test/xhr_worker.js index 4f53a522a9d..5e3e74a3ec8 100644 --- a/dom/workers/test/xhr_worker.js +++ b/dom/workers/test/xhr_worker.js @@ -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"); }