зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1508310 - Implement Report-to header support - part 8 - ChromeUtils methods for testing, r=smaug
This commit is contained in:
Родитель
1326941932
Коммит
f759361b23
|
@ -19,6 +19,7 @@
|
|||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/dom/BrowsingContext.h"
|
||||
#include "mozilla/dom/IdleDeadline.h"
|
||||
#include "mozilla/dom/ReportingHeader.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/dom/WindowBinding.h" // For IdleRequestCallback/Options
|
||||
#include "IOActivityMonitor.h"
|
||||
|
@ -726,5 +727,16 @@ constexpr auto kSkipSelfHosted = JS::SavedFrameSelfHosted::Exclude;
|
|||
BrowsingContext::GetRootBrowsingContexts(aBrowsingContexts);
|
||||
}
|
||||
|
||||
/* static */ bool ChromeUtils::HasReportingHeaderForOrigin(
|
||||
GlobalObject& global, const nsAString& aOrigin, ErrorResult& aRv) {
|
||||
if (!XRE_IsParentProcess()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
}
|
||||
|
||||
return ReportingHeader::HasReportingHeaderForOrigin(
|
||||
NS_ConvertUTF16toUTF8(aOrigin));
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -165,6 +165,10 @@ class ChromeUtils {
|
|||
static void GetRootBrowsingContexts(
|
||||
GlobalObject& aGlobal,
|
||||
nsTArray<RefPtr<BrowsingContext>>& aBrowsingContexts);
|
||||
|
||||
static bool HasReportingHeaderForOrigin(GlobalObject& global,
|
||||
const nsAString& aOrigin,
|
||||
ErrorResult& aRv);
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -364,6 +364,9 @@ partial namespace ChromeUtils {
|
|||
*/
|
||||
[ChromeOnly]
|
||||
sequence<BrowsingContext> getRootBrowsingContexts();
|
||||
|
||||
[ChromeOnly, Throws]
|
||||
boolean hasReportingHeaderForOrigin(DOMString aOrigin);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -653,6 +653,15 @@ void ReportingHeader::RemoveOriginsFromOriginAttributesPattern(
|
|||
|
||||
void ReportingHeader::RemoveOrigins() { mOrigins.Clear(); }
|
||||
|
||||
/* static */ bool ReportingHeader::HasReportingHeaderForOrigin(
|
||||
const nsACString& aOrigin) {
|
||||
if (!gReporting) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return gReporting->mOrigins.Contains(aOrigin);
|
||||
}
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(ReportingHeader)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
||||
|
|
|
@ -65,6 +65,10 @@ class ReportingHeader final : public nsIObserver {
|
|||
const nsACString& aEndpointURL,
|
||||
const mozilla::ipc::PrincipalInfo& aPrincipalInfo);
|
||||
|
||||
// ChromeOnly-WebIDL methods
|
||||
|
||||
static bool HasReportingHeaderForOrigin(const nsACString& aOrigin);
|
||||
|
||||
private:
|
||||
ReportingHeader();
|
||||
~ReportingHeader();
|
||||
|
|
Загрузка…
Ссылка в новой задаче