зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1694662 - Remove nsIApplicationCacheChannel usage from docshell r=dragana
Differential Revision: https://phabricator.services.mozilla.com/D106447
This commit is contained in:
Родитель
5c93080204
Коммит
d28637ceaf
|
@ -492,88 +492,6 @@ add_task(async function test_form_entries() {
|
|||
await wh.promiseClosed;
|
||||
});
|
||||
|
||||
// Test for offline cache deletion
|
||||
add_task(async function test_offline_cache() {
|
||||
// Prepare stuff, we will work with www.example.com
|
||||
var URL = "http://www.example.com";
|
||||
var URI = makeURI(URL);
|
||||
var principal = Services.scriptSecurityManager.createContentPrincipal(
|
||||
URI,
|
||||
{}
|
||||
);
|
||||
|
||||
// Give www.example.com privileges to store offline data
|
||||
Services.perms.addFromPrincipal(
|
||||
principal,
|
||||
"offline-app",
|
||||
Ci.nsIPermissionManager.ALLOW_ACTION
|
||||
);
|
||||
Services.perms.addFromPrincipal(
|
||||
principal,
|
||||
"offline-app",
|
||||
Ci.nsIOfflineCacheUpdateService.ALLOW_NO_WARN
|
||||
);
|
||||
|
||||
// Store something to the offline cache
|
||||
var appcacheserv = Cc[
|
||||
"@mozilla.org/network/application-cache-service;1"
|
||||
].getService(Ci.nsIApplicationCacheService);
|
||||
var appcachegroupid = appcacheserv.buildGroupIDForInfo(
|
||||
makeURI(URL + "/manifest"),
|
||||
Services.loadContextInfo.default
|
||||
);
|
||||
var appcache = appcacheserv.createApplicationCache(appcachegroupid);
|
||||
var storage = Services.cache2.appCacheStorage(
|
||||
Services.loadContextInfo.default,
|
||||
appcache
|
||||
);
|
||||
|
||||
// Open the dialog
|
||||
let wh = new WindowHelper();
|
||||
wh.onload = function() {
|
||||
this.selectDuration(Sanitizer.TIMESPAN_EVERYTHING);
|
||||
// Clear only offlineApps
|
||||
this.uncheckAllCheckboxes();
|
||||
this.checkPrefCheckbox("offlineApps", true);
|
||||
this.acceptDialog();
|
||||
};
|
||||
wh.onunload = function() {
|
||||
// Check if the cache has been deleted
|
||||
var size = -1;
|
||||
var visitor = {
|
||||
onCacheStorageInfo(aEntryCount, aConsumption, aCapacity, aDiskDirectory) {
|
||||
size = aConsumption;
|
||||
},
|
||||
};
|
||||
storage.asyncVisitStorage(visitor, false);
|
||||
// Offline cache visit happens synchronously, since it's forwarded to the old code
|
||||
is(size, 0, "offline application cache entries evicted");
|
||||
};
|
||||
|
||||
var cacheListener = {
|
||||
onCacheEntryCheck() {
|
||||
return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED;
|
||||
},
|
||||
onCacheEntryAvailable(entry, isnew, status) {
|
||||
is(status, Cr.NS_OK);
|
||||
var stream = entry.openOutputStream(0, -1);
|
||||
var content = "content";
|
||||
stream.write(content, content.length);
|
||||
stream.close();
|
||||
entry.close();
|
||||
wh.open();
|
||||
},
|
||||
};
|
||||
|
||||
storage.asyncOpenURI(
|
||||
makeURI(URL),
|
||||
"",
|
||||
Ci.nsICacheStorage.OPEN_TRUNCATE,
|
||||
cacheListener
|
||||
);
|
||||
await wh.promiseClosed;
|
||||
});
|
||||
|
||||
// Test for offline apps permission deletion
|
||||
add_task(async function test_offline_apps_permissions() {
|
||||
// Prepare stuff, we will work with www.example.com
|
||||
|
|
|
@ -92,8 +92,6 @@
|
|||
#include "mozilla/net/UrlClassifierFeatureFactory.h"
|
||||
#include "ReferrerInfo.h"
|
||||
|
||||
#include "nsIApplicationCacheChannel.h"
|
||||
#include "nsIApplicationCacheContainer.h"
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsIAuthPrompt2.h"
|
||||
|
@ -656,29 +654,6 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink) {
|
|||
RefPtr<Document> doc = mContentViewer->GetDocument();
|
||||
doc.forget(aSink);
|
||||
return *aSink ? NS_OK : NS_NOINTERFACE;
|
||||
} else if (aIID.Equals(NS_GET_IID(nsIApplicationCacheContainer))) {
|
||||
*aSink = nullptr;
|
||||
|
||||
// Return application cache associated with this docshell, if any
|
||||
|
||||
nsCOMPtr<nsIContentViewer> contentViewer;
|
||||
GetContentViewer(getter_AddRefs(contentViewer));
|
||||
if (!contentViewer) {
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
RefPtr<Document> doc = contentViewer->GetDocument();
|
||||
NS_ASSERTION(doc, "Should have a document.");
|
||||
if (!doc) {
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
MOZ_LOG(
|
||||
gDocShellLog, LogLevel::Debug,
|
||||
("nsDocShell[%p]: returning app cache container %p", this, doc.get()));
|
||||
#endif
|
||||
return doc->QueryInterface(aIID, aSink);
|
||||
} else if (aIID.Equals(NS_GET_IID(nsIPrompt)) &&
|
||||
NS_SUCCEEDED(EnsureScriptEnvironment())) {
|
||||
nsresult rv;
|
||||
|
@ -5999,27 +5974,6 @@ void nsDocShell::OnRedirectStateChange(nsIChannel* aOldChannel,
|
|||
}
|
||||
}
|
||||
|
||||
// check if the new load should go through the application cache.
|
||||
nsCOMPtr<nsIApplicationCacheChannel> appCacheChannel =
|
||||
do_QueryInterface(aNewChannel);
|
||||
if (appCacheChannel && !docChannel) {
|
||||
if (GeckoProcessType_Default != XRE_GetProcessType()) {
|
||||
// Permission will be checked in the parent process.
|
||||
appCacheChannel->SetChooseApplicationCache(true);
|
||||
} else {
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
|
||||
|
||||
if (secMan) {
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
secMan->GetDocShellContentPrincipal(newURI, this,
|
||||
getter_AddRefs(principal));
|
||||
appCacheChannel->SetChooseApplicationCache(
|
||||
NS_ShouldCheckAppCache(principal));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!(aRedirectFlags & nsIChannelEventSink::REDIRECT_INTERNAL) &&
|
||||
mLoadType & (LOAD_CMD_RELOAD | LOAD_CMD_HISTORY)) {
|
||||
mLoadType = LOAD_NORMAL_REPLACE;
|
||||
|
@ -9913,32 +9867,6 @@ nsIPrincipal* nsDocShell::GetInheritedPrincipal(
|
|||
// HTTPS_ONLY_EXEMPT.
|
||||
nsHTTPSOnlyUtils::TestSitePermissionAndPotentiallyAddExemption(channel);
|
||||
|
||||
if (nsCOMPtr<nsIApplicationCacheChannel> appCacheChannel =
|
||||
do_QueryInterface(channel)) {
|
||||
// Any document load should not inherit application cache.
|
||||
appCacheChannel->SetInheritApplicationCache(false);
|
||||
|
||||
// Loads with the correct permissions should check for a matching
|
||||
// application cache.
|
||||
if (GeckoProcessType_Default != XRE_GetProcessType()) {
|
||||
// Permission will be checked in the parent process
|
||||
appCacheChannel->SetChooseApplicationCache(true);
|
||||
} else if (aDocShell) {
|
||||
// TODO: Figure out how to handle this in the parent,
|
||||
// on behalf of a content process.
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);
|
||||
|
||||
if (secMan) {
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
secMan->GetDocShellContentPrincipal(aLoadState->URI(), aDocShell,
|
||||
getter_AddRefs(principal));
|
||||
appCacheChannel->SetChooseApplicationCache(
|
||||
NS_ShouldCheckAppCache(principal));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// hack
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
|
||||
nsCOMPtr<nsIHttpChannelInternal> httpChannelInternal(
|
||||
|
|
Загрузка…
Ссылка в новой задаче