Bug 1217571 - fix the imagelib cache to work in e10s; r=seth

nsICachingChannel isn't available in the child process; we have to use
nsICacheInfoChannel instead.
This commit is contained in:
Nathan Froyd 2015-11-12 15:09:52 -05:00
parent a064648b31
commit 70563b2178
6 changed files with 77 additions and 26 deletions

View File

@ -42,11 +42,8 @@
case 2:
is(e.data.url, "image-40px.png", "Correct url expected");
is(e.data.url2, "image-40px.png", "Correct url expected");
// TODO: Uncomment this check when bug 1217571 gets fixed.
// Currently because of bug 1217571, the QI in imgCacheValidator::OnStartRequest()
// to nsICachingChannel fails, which causes the check below to fail in non-e10s.
//is(e.data.width, 40, "Correct width expected");
//is(e.data.width2, 40, "Correct width expected");
is(e.data.width, 40, "Correct width expected");
is(e.data.width2, 40, "Correct width expected");
iframe.src = "/tests/dom/workers/test/serviceworkers/fetch/imagecache-maxage/unregister.html";
break;
default:

View File

@ -25,7 +25,7 @@
#include "nsMimeTypes.h"
#include "nsStreamUtils.h"
#include "nsIHttpChannel.h"
#include "nsICachingChannel.h"
#include "nsICacheInfoChannel.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIProgressEventSink.h"
@ -2346,7 +2346,7 @@ imgLoader::LoadImageWithChannel(nsIChannel* channel,
nullptr, imgIRequest::CORS_NONE)) {
request = entry->GetRequest();
} else {
nsCOMPtr<nsICachingChannel> cacheChan(do_QueryInterface(channel));
nsCOMPtr<nsICacheInfoChannel> cacheChan(do_QueryInterface(channel));
bool bUseCacheCopy;
if (cacheChan) {
@ -2722,7 +2722,7 @@ imgCacheValidator::OnStartRequest(nsIRequest* aRequest, nsISupports* ctxt)
// If this request is coming from cache and has the same URI as our
// imgRequest, the request all our proxies are pointing at is valid, and all
// we have to do is tell them to notify their listeners.
nsCOMPtr<nsICachingChannel> cacheChan(do_QueryInterface(aRequest));
nsCOMPtr<nsICacheInfoChannel> cacheChan(do_QueryInterface(aRequest));
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
if (cacheChan && channel && !mRequest->CacheChanged(aRequest)) {
bool isFromCache = false;

View File

@ -17,7 +17,7 @@
#include "RasterImage.h"
#include "nsIChannel.h"
#include "nsICachingChannel.h"
#include "nsICacheInfoChannel.h"
#include "nsIDocument.h"
#include "nsIThreadRetargetableRequest.h"
#include "nsIInputStream.h"
@ -32,8 +32,6 @@
#include "nsIScriptSecurityManager.h"
#include "nsContentUtils.h"
#include "nsICacheEntry.h"
#include "plstr.h" // PL_strcasestr(...)
#include "nsNetUtil.h"
#include "nsIProtocolHandler.h"
@ -586,17 +584,11 @@ imgRequest::SetCacheValidation(imgCacheEntry* aCacheEntry, nsIRequest* aRequest)
{
/* get the expires info */
if (aCacheEntry) {
nsCOMPtr<nsICachingChannel> cacheChannel(do_QueryInterface(aRequest));
nsCOMPtr<nsICacheInfoChannel> cacheChannel(do_QueryInterface(aRequest));
if (cacheChannel) {
nsCOMPtr<nsISupports> cacheToken;
cacheChannel->GetCacheToken(getter_AddRefs(cacheToken));
if (cacheToken) {
nsCOMPtr<nsICacheEntry> entryDesc(do_QueryInterface(cacheToken));
if (entryDesc) {
uint32_t expiration;
uint32_t expiration = 0;
/* get the expiration time from the caching channel's token */
entryDesc->GetExpirationTime(&expiration);
if (NS_SUCCEEDED(cacheChannel->GetCacheTokenExpirationTime(&expiration))) {
// Expiration time defaults to 0. We set the expiration time on our
// entry if it hasn't been set yet.
if (aCacheEntry->GetExpiryTime() == 0) {
@ -604,7 +596,6 @@ imgRequest::SetCacheValidation(imgCacheEntry* aCacheEntry, nsIRequest* aRequest)
}
}
}
}
// Determine whether the cache entry must be revalidated when we try to use
// it. Currently, only HTTP specifies this information...

View File

@ -0,0 +1,17 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1217571
-->
<head>
<title>iframe for Bug 1217571</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
<img src="damon.jpg">
</div>
</body>
</html>

View File

@ -32,6 +32,7 @@ support-files =
bug900200-ref.png
bug1180105.sjs
bug1180105-waiter.sjs
bug1217571-iframe.html
clear.gif
clear.png
clear2.gif
@ -89,6 +90,7 @@ skip-if = (toolkit == 'android' && processor == 'x86') #x86 only
[test_bug89419-2.html]
skip-if = (toolkit == 'android' && processor == 'x86') #x86 only
[test_bug1180105.html]
[test_bug1217571.html]
[test_animation_operators.html]
[test_drawDiscardedImage.html]
skip-if = toolkit == "gonk" #Bug 997034 - canvas.toDataURL() often causes lost connection to device.

View File

@ -0,0 +1,44 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1217571
-->
<head>
<title>Test for Bug 1217571</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1217571">Mozilla Bug 1217571</a>
<p id="display"></p>
<iframe src="bug1217571-iframe.html"></iframe>
<iframe src="bug1217571-iframe.html"></iframe>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 614392**/
SimpleTest.waitForExplicitFinish();
window.onload = function() {
// Each iframe loads the same image. Both images should share the same
// container from the image cache. Check that this holds true.
var iframes = document.getElementsByTagName("iframe");
var imgs = Array.from(iframes, function (f) {
return SpecialPowers.wrap(f.contentDocument.getElementsByTagName("img")[0]);
});
var containers = imgs.map(function (img) {
return img.QueryInterface(SpecialPowers.Ci.nsIImageLoadingContent)
.getRequest(SpecialPowers.Ci.nsIImageLoadingContent.CURRENT_REQUEST)
.image;
});
ok(SpecialPowers.compare(containers[0], containers[1]),
"containers for identical images in different iframes should be identical");
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>