Bug 1355147 - Expose IsHeadless on GfxInfo. r?jrmuizel
Allows marionette to check if the browser is in headless mode.
MozReview-Commit-ID: 2kaqO3HO9Ke
--- a/widget/GfxInfoBase.cpp
+++ b/widget/GfxInfoBase.cpp
@@ -1468,16 +1468,23 @@ GfxInfoBase::GetActiveCrashGuards(JSCont
NS_IMETHODIMP
GfxInfoBase::GetWebRenderEnabled(bool* aWebRenderEnabled)
{
*aWebRenderEnabled = gfxVars::UseWebRender();
return NS_OK;
}
NS_IMETHODIMP
+GfxInfoBase::GetIsHeadless(bool* aIsHeadless)
+{
+ *aIsHeadless = gfxPlatform::IsHeadless();
+ return NS_OK;
+}
+
+NS_IMETHODIMP
GfxInfoBase::GetContentBackend(nsAString & aContentBackend)
{
BackendType backend = gfxPlatform::GetPlatform()->GetDefaultContentBackend();
nsString outStr;
switch (backend) {
case BackendType::DIRECT2D1_1: {
outStr.AppendPrintf("Direct2D 1.1");
--- a/widget/GfxInfoBase.h
+++ b/widget/GfxInfoBase.h
@@ -57,16 +57,17 @@ public:
NS_IMETHOD_(void) LogFailure(const nsACString &failure) override;
NS_IMETHOD GetInfo(JSContext*, JS::MutableHandle<JS::Value>) override;
NS_IMETHOD GetFeatures(JSContext*, JS::MutableHandle<JS::Value>) override;
NS_IMETHOD GetFeatureLog(JSContext*, JS::MutableHandle<JS::Value>) override;
NS_IMETHOD GetActiveCrashGuards(JSContext*, JS::MutableHandle<JS::Value>) override;
NS_IMETHOD GetContentBackend(nsAString & aContentBackend) override;
NS_IMETHOD GetUsingGPUProcess(bool *aOutValue) override;
NS_IMETHOD GetWebRenderEnabled(bool* aWebRenderEnabled) override;
+ NS_IMETHOD GetIsHeadless(bool* aIsHeadless) override;
// Initialization function. If you override this, you must call this class's
// version of Init first.
// We need Init to be called separately from the constructor so we can
// register as an observer after all derived classes have been constructed
// and we know we have a non-zero refcount.
// Ideally, Init() would be void-return, but the rules of
// NS_GENERIC_FACTORY_CONSTRUCTOR_INIT require it be nsresult return.
--- a/widget/nsIGfxInfo.idl
+++ b/widget/nsIGfxInfo.idl
@@ -19,16 +19,17 @@ interface nsIGfxInfo : nsISupports
readonly attribute DOMString DWriteVersion;
readonly attribute DOMString cleartypeParameters;
/*
* These are valid across all platforms.
*/
readonly attribute DOMString ContentBackend;
readonly attribute boolean WebRenderEnabled;
+ readonly attribute boolean isHeadless;
// XXX: Switch to a list of devices, rather than explicitly numbering them.
/**
* The name of the display adapter.
*/
readonly attribute DOMString adapterDescription;
readonly attribute DOMString adapterDescription2;