Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2024-11-21 21:09:29 +08:00
commit 310c05b97a
177 changed files with 514 additions and 4888 deletions

View file

@ -334,19 +334,6 @@ bool nsMediaFragmentURIParser::ParseXYWH(nsDependentSubstring aString)
return false;
}
bool nsMediaFragmentURIParser::ParseMozSampleSize(nsDependentSubstring aString)
{
int32_t sampleSize;
// Read and validate coordinates.
if (ParseInteger(aString, sampleSize) && sampleSize > 0) {
mSampleSize.emplace(sampleSize);
return true;
}
return false;
}
void nsMediaFragmentURIParser::Parse(nsACString& aRef)
{
// Create an array of possibly-invalid media fragments.
@ -367,9 +354,9 @@ void nsMediaFragmentURIParser::Parse(nsACString& aRef)
}
// Parse the media fragment values.
bool gotTemporal = false, gotSpatial = false, gotSampleSize = false;
bool gotTemporal = false, gotSpatial = false;
for (int i = fragments.Length() - 1 ; i >= 0 ; --i) {
if (gotTemporal && gotSpatial && gotSampleSize) {
if (gotTemporal && gotSpatial) {
// We've got one of each possible type. No need to look at the rest.
break;
} else if (!gotTemporal && fragments[i].first.EqualsLiteral("t")) {
@ -378,9 +365,6 @@ void nsMediaFragmentURIParser::Parse(nsACString& aRef)
} else if (!gotSpatial && fragments[i].first.EqualsLiteral("xywh")) {
nsAutoString value = NS_ConvertUTF8toUTF16(fragments[i].second);
gotSpatial = ParseXYWH(nsDependentSubstring(value, 0));
} else if (!gotSampleSize && fragments[i].first.EqualsLiteral("-moz-samplesize")) {
nsAutoString value = NS_ConvertUTF8toUTF16(fragments[i].second);
gotSampleSize = ParseMozSampleSize(nsDependentSubstring(value, 0));
}
}
}

View file

@ -63,10 +63,6 @@ public:
// returns the unit used.
ClipUnit GetClipUnit() const { return mClipUnit; }
bool HasSampleSize() const { return mSampleSize.isSome(); }
int GetSampleSize() const { return *mSampleSize; }
private:
// Parse the URI ref provided, looking for media fragments. This is
// the top-level parser the invokes the others below.
@ -88,14 +84,12 @@ private:
bool ParseNPTMM(nsDependentSubstring& aString, uint32_t& aMinute);
bool ParseNPTSS(nsDependentSubstring& aString, uint32_t& aSecond);
bool ParseXYWH(nsDependentSubstring aString);
bool ParseMozSampleSize(nsDependentSubstring aString);
// Media fragment information.
Maybe<double> mStart;
Maybe<double> mEnd;
Maybe<nsIntRect> mClip;
ClipUnit mClipUnit;
Maybe<int> mSampleSize;
};
} // namespace net

View file

@ -12,7 +12,6 @@
#include "mozilla/Preferences.h"
#include "nsNetUtil.h"
#include "nsNetUtilInlines.h"
#include "mozIApplicationClearPrivateDataParams.h"
#include "nsCategoryCache.h"
#include "nsContentUtils.h"
#include "nsHashKeys.h"
@ -568,16 +567,7 @@ NS_LoadGroupMatchesPrincipal(nsILoadGroup *aLoadGroup,
getter_AddRefs(loadContext));
NS_ENSURE_TRUE(loadContext, false);
// Verify load context appId and browser flag match the principal
uint32_t contextAppId;
bool contextInIsolatedBrowser;
nsresult rv = loadContext->GetAppId(&contextAppId);
NS_ENSURE_SUCCESS(rv, false);
rv = loadContext->GetIsInIsolatedMozBrowserElement(&contextInIsolatedBrowser);
NS_ENSURE_SUCCESS(rv, false);
return contextAppId == aPrincipal->GetAppId() &&
contextInIsolatedBrowser == aPrincipal->GetIsInIsolatedMozBrowserElement();
return true;
}
nsresult
@ -1333,39 +1323,6 @@ NS_HasBeenCrossOrigin(nsIChannel* aChannel, bool aReport)
return NS_FAILED(loadingPrincipal->CheckMayLoad(uri, aReport, dataInherits));
}
nsresult
NS_GetAppInfoFromClearDataNotification(nsISupports *aSubject,
uint32_t *aAppID,
bool *aBrowserOnly)
{
nsresult rv;
nsCOMPtr<mozIApplicationClearPrivateDataParams>
clearParams(do_QueryInterface(aSubject));
MOZ_ASSERT(clearParams);
if (!clearParams) {
return NS_ERROR_UNEXPECTED;
}
uint32_t appId;
rv = clearParams->GetAppId(&appId);
MOZ_ASSERT(NS_SUCCEEDED(rv));
MOZ_ASSERT(appId != NECKO_UNKNOWN_APP_ID);
NS_ENSURE_SUCCESS(rv, rv);
if (appId == NECKO_UNKNOWN_APP_ID) {
return NS_ERROR_UNEXPECTED;
}
bool browserOnly = false;
rv = clearParams->GetBrowserOnly(&browserOnly);
MOZ_ASSERT(NS_SUCCEEDED(rv));
NS_ENSURE_SUCCESS(rv, rv);
*aAppID = appId;
*aBrowserOnly = browserOnly;
return NS_OK;
}
bool
NS_ShouldCheckAppCache(nsIURI *aURI, bool usePrivateBrowsing)
{
@ -2385,39 +2342,18 @@ NS_CompareLoadInfoAndLoadContext(nsIChannel *aChannel)
return NS_OK;
}
uint32_t loadContextAppId = 0;
nsresult rv = loadContext->GetAppId(&loadContextAppId);
if (NS_FAILED(rv)) {
return NS_ERROR_UNEXPECTED;
}
bool loadContextIsInBE = false;
rv = loadContext->GetIsInIsolatedMozBrowserElement(&loadContextIsInBE);
if (NS_FAILED(rv)) {
return NS_ERROR_UNEXPECTED;
}
OriginAttributes originAttrsLoadInfo = loadInfo->GetOriginAttributes();
DocShellOriginAttributes originAttrsLoadContext;
loadContext->GetOriginAttributes(originAttrsLoadContext);
LOG(("NS_CompareLoadInfoAndLoadContext - loadInfo: %d, %d, %d, %d; "
"loadContext: %d %d, %d, %d. [channel=%p]",
originAttrsLoadInfo.mAppId, originAttrsLoadInfo.mInIsolatedMozBrowser,
originAttrsLoadInfo.mUserContextId, originAttrsLoadInfo.mPrivateBrowsingId,
loadContextAppId, loadContextIsInBE,
originAttrsLoadContext.mUserContextId, originAttrsLoadContext.mPrivateBrowsingId,
LOG(("NS_CompareLoadInfoAndLoadContext - loadInfo: %d, %d; "
"loadContext: %d, %d. [channel=%p]",
originAttrsLoadInfo.mUserContextId,
originAttrsLoadInfo.mPrivateBrowsingId,
originAttrsLoadContext.mUserContextId,
originAttrsLoadContext.mPrivateBrowsingId,
aChannel));
MOZ_ASSERT(originAttrsLoadInfo.mAppId == loadContextAppId,
"AppId in the loadContext and in the loadInfo are not the "
"same!");
MOZ_ASSERT(originAttrsLoadInfo.mInIsolatedMozBrowser ==
loadContextIsInBE,
"The value of InIsolatedMozBrowser in the loadContext and in "
"the loadInfo are not the same!");
MOZ_ASSERT(originAttrsLoadInfo.mUserContextId ==
originAttrsLoadContext.mUserContextId,
"The value of mUserContextId in the loadContext and in the "

View file

@ -682,15 +682,6 @@ bool NS_GetAppInfo(nsIChannel *aChannel,
uint32_t *aAppID,
bool *aIsInIsolatedMozBrowserElement);
/**
* Gets appId and browserOnly parameters from the TOPIC_WEB_APP_CLEAR_DATA
* nsIObserverService notification. Used when clearing user data or
* uninstalling web apps.
*/
nsresult NS_GetAppInfoFromClearDataNotification(nsISupports *aSubject,
uint32_t *aAppID,
bool *aBrowserOnly);
/**
* Determines whether appcache should be checked for a given URI.
*/

View file

@ -612,8 +612,7 @@ nsUDPSocket::InitWithAddress(const NetAddr *aAddr, nsIPrincipal *aPrincipal,
if (aPrincipal) {
mAppId = aPrincipal->GetAppId();
mIsInIsolatedMozBrowserElement =
aPrincipal->GetIsInIsolatedMozBrowserElement();
mIsInIsolatedMozBrowserElement = false;
}
uint16_t port;

View file

@ -7,7 +7,6 @@
#include "nsCacheService.h"
#include "nsApplicationCacheService.h"
#include "nsCRT.h"
#include "mozIApplicationClearPrivateDataParams.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "nsIObserverService.h"
@ -253,14 +252,3 @@ private:
NS_IMPL_ISUPPORTS(AppCacheClearDataObserver, nsIObserver)
} // namespace
// Instantiates and registers AppCacheClearDataObserver for notifications
void
nsApplicationCacheService::AppClearDataObserverInit()
{
nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
if (observerService) {
RefPtr<AppCacheClearDataObserver> obs = new AppCacheClearDataObserver();
observerService->AddObserver(obs, "clear-origin-attributes-data", /*ownsWeak=*/ false);
}
}

View file

@ -18,8 +18,6 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIAPPLICATIONCACHESERVICE
static void AppClearDataObserverInit();
private:
~nsApplicationCacheService();
RefPtr<nsCacheService> mCacheService;

View file

@ -48,9 +48,6 @@
#include "mozilla/storage.h"
#include "mozilla/AutoRestore.h"
#include "mozilla/FileUtils.h"
#include "nsIAppsService.h"
#include "mozIApplication.h"
#include "mozIApplicationClearPrivateDataParams.h"
#include "nsIConsoleService.h"
#include "nsVariant.h"
@ -675,15 +672,6 @@ nsCookieService::GetSingleton()
return gCookieService;
}
/* static */ void
nsCookieService::AppClearDataObserverInit()
{
nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
nsCOMPtr<nsIObserver> obs = new AppClearDataObserver();
observerService->AddObserver(obs, TOPIC_CLEAR_ORIGIN_DATA,
/* ownsWeak= */ false);
}
/******************************************************************************
* nsCookieService impl:
* public methods

View file

@ -260,14 +260,6 @@ class nsCookieService final : public nsICookieService
static nsICookieService* GetXPCOMSingleton();
nsresult Init();
/**
* Start watching the observer service for messages indicating that an app has
* been uninstalled. When an app is uninstalled, we get the cookie service
* (thus instantiating it, if necessary) and clear all the cookies for that
* app.
*/
static void AppClearDataObserverInit();
protected:
virtual ~nsCookieService();

View file

@ -202,6 +202,13 @@ ChildDNSService::GetDNSCacheEntries(nsTArray<mozilla::net::DNSCacheEntries> *arg
return NS_ERROR_NOT_AVAILABLE;
}
NS_IMETHODIMP
ChildDNSService::ClearCache()
{
// Not available in IPC children.
return NS_ERROR_NOT_AVAILABLE;
}
NS_IMETHODIMP
ChildDNSService::GetMyHostName(nsACString &result)
{

View file

@ -1052,6 +1052,12 @@ nsDNSService::GetDNSCacheEntries(nsTArray<mozilla::net::DNSCacheEntries> *args)
return NS_OK;
}
NS_IMETHODIMP
nsDNSService::ClearCache() {
mResolver->FlushCache();
return NS_OK;
}
size_t
nsDNSService::SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const
{

View file

@ -115,6 +115,11 @@ interface nsIDNSService : nsISupports
*/
[noscript] void getDNSCacheEntries(in EntriesArray args);
/**
* Clears the DNS cache.
*/
void clearCache();
/**
* @return the hostname of the operating system.
*/

View file

@ -34,7 +34,6 @@
#include "mozilla/AppProcessChecker.h"
#include "nsPrintfCString.h"
#include "nsHTMLDNSPrefetch.h"
#include "nsIAppsService.h"
#include "nsEscape.h"
#include "SerializedLoadContext.h"
#include "nsAuthInformationHolder.h"

View file

@ -3010,12 +3010,8 @@ HttpBaseChannel::SetupReplacementChannel(nsIURI *newURI,
NeckoOriginAttributes attrs = newLoadInfo->GetOriginAttributes();
MOZ_ASSERT(docShellAttrs.mAppId == attrs.mAppId,
"docshell and necko should have the same appId attribute.");
MOZ_ASSERT(docShellAttrs.mUserContextId == attrs.mUserContextId,
"docshell and necko should have the same userContextId attribute.");
MOZ_ASSERT(docShellAttrs.mInIsolatedMozBrowser == attrs.mInIsolatedMozBrowser,
"docshell and necko should have the same inIsolatedMozBrowser attribute.");
MOZ_ASSERT(docShellAttrs.mPrivateBrowsingId == attrs.mPrivateBrowsingId,
"docshell and necko should have the same privateBrowsingId attribute.");

View file

@ -13,7 +13,6 @@
#include "mozilla/Attributes.h"
#include "nsString.h"
#include "nsCRT.h"
#include "mozIApplicationClearPrivateDataParams.h"
#include "nsIObserverService.h"
#include "mozilla/Services.h"
#include "mozilla/DebugOnly.h"

View file

@ -33,7 +33,6 @@
#include "nsSocketTransportService2.h"
#include "nsAlgorithm.h"
#include "ASpdySession.h"
#include "mozIApplicationClearPrivateDataParams.h"
#include "EventTokenBucket.h"
#include "Tickler.h"
#include "nsIXULAppInfo.h"
@ -404,7 +403,6 @@ nsHttpHandler::Init()
obsService->AddObserver(this, "net:prune-all-connections", true);
obsService->AddObserver(this, "net:failed-to-process-uri-content", true);
obsService->AddObserver(this, "last-pb-context-exited", true);
obsService->AddObserver(this, "webapps-clear-data", true);
obsService->AddObserver(this, "browser:purge-session-history", true);
obsService->AddObserver(this, NS_NETWORK_LINK_TOPIC, true);
obsService->AddObserver(this, "application-background", true);
@ -2288,10 +2286,6 @@ nsHttpHandler::Observe(nsISupports *subject,
if (mConnMgr) {
mConnMgr->ClearAltServiceMappings();
}
} else if (!strcmp(topic, "webapps-clear-data")) {
if (mConnMgr) {
mConnMgr->ClearAltServiceMappings();
}
} else if (!strcmp(topic, "browser:purge-session-history")) {
if (mConnMgr) {
if (gSocketTransportService) {

View file

@ -11,7 +11,6 @@
#include "nsServiceManagerUtils.h"
#include "plstr.h"
#include "nsIObserverService.h"
#include "mozIApplicationClearPrivateDataParams.h"
#include "nsIURI.h"
#include "mozilla/net/NeckoChild.h"

View file

@ -1,43 +0,0 @@
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function is_app_offline(appId) {
let ioservice = Cc['@mozilla.org/network/io-service;1'].
getService(Ci.nsIIOService);
return ioservice.isAppOffline(appId);
}
var events_observed_no = 0;
// Holds the last observed app-offline event
var info = null;
function observer(aSubject, aTopic, aData) {
events_observed_no++;
info = aSubject.QueryInterface(Ci.nsIAppOfflineInfo);
dump("ChildObserver - subject: {" + aSubject.appId + ", " + aSubject.mode + "} ");
}
// Add observer for the app-offline notification
function run_test() {
Services.obs.addObserver(observer, "network:app-offline-status-changed", false);
}
// Chech that the app has the proper offline status
function check_status(appId, status)
{
do_check_eq(is_app_offline(appId), status == Ci.nsIAppOfflineInfo.OFFLINE);
}
// Check that the app has the proper offline status
// and that the correct notification has been received
function check_notification_and_status(appId, status) {
do_check_eq(info.appId, appId);
do_check_eq(info.mode, status);
do_check_eq(is_app_offline(appId), status == Ci.nsIAppOfflineInfo.OFFLINE);
}
// Remove the observer from the child process
function finished() {
Services.obs.removeObserver(observer, "network:app-offline-status-changed");
do_check_eq(events_observed_no, 2);
}