Bug 1373739 - Disable WebGL in headless mode. r=bdahl

MozReview-Commit-ID: LWe9hRh7zXX

--HG--
extra : rebase_source : b97091b65b22e616fa6b99b819216b5b3f9c5b66
This commit is contained in:
Michael Smith 2017-06-22 10:13:12 -07:00
parent 325b9a25eb
commit f0a3973e54
2 changed files with 15 additions and 1 deletions

View File

@ -681,6 +681,15 @@ bool
WebGLContext::CreateAndInitGL(bool forceEnabled,
std::vector<FailureReason>* const out_failReasons)
{
// Can't use WebGL in headless mode.
if (gfxPlatform::IsHeadless()) {
FailureReason reason;
reason.info = "Can't use WebGL in headless mode (https://bugzil.la/1375585).";
out_failReasons->push_back(reason);
GenerateWarning("%s", reason.info.BeginReading());
return false;
}
// WebGL2 is separately blocked:
if (IsWebGL2()) {
const nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();

View File

@ -110,8 +110,13 @@
test(function() {
var c = self[0].document.createElement("canvas"),
obj = c.getContext(val)
assert_global(obj)
// WebGL might not be enabled in this environment
if (!obj && val === "webgl") {
return;
}
assert_global(obj)
obj = HTMLCanvasElement.prototype.getContext.call(c, val)
assert_global(obj)
}, "getContext " + val)