mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 912606 - Warn on webgl context requests with mismatched ids. - r=bjacob
This commit is contained in:
parent
a650c85e02
commit
40da9960b1
@ -671,6 +671,14 @@ HTMLCanvasElement::GetContext(const nsAString& aContextId,
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
static bool
|
||||
IsContextIdWebGL(const nsAString& str)
|
||||
{
|
||||
return str.EqualsLiteral("webgl") ||
|
||||
str.EqualsLiteral("experimental-webgl") ||
|
||||
str.EqualsLiteral("moz-webgl");
|
||||
}
|
||||
|
||||
already_AddRefed<nsISupports>
|
||||
HTMLCanvasElement::GetContext(JSContext* aCx,
|
||||
const nsAString& aContextId,
|
||||
@ -702,6 +710,20 @@ HTMLCanvasElement::GetContext(JSContext* aCx,
|
||||
}
|
||||
|
||||
if (!mCurrentContextId.Equals(aContextId)) {
|
||||
if (IsContextIdWebGL(aContextId) &&
|
||||
IsContextIdWebGL(mCurrentContextId))
|
||||
{
|
||||
// Warn when we get a request for a webgl context with an id that differs
|
||||
// from the id it was created with.
|
||||
nsCString creationId = NS_LossyConvertUTF16toASCII(mCurrentContextId);
|
||||
nsCString requestId = NS_LossyConvertUTF16toASCII(aContextId);
|
||||
JS_ReportWarning(aCx, "WebGL: Retrieving a WebGL context from a canvas "
|
||||
"via a request id ('%s') different from the id used "
|
||||
"to create the context ('%s') is not allowed.",
|
||||
requestId.get(),
|
||||
creationId.get());
|
||||
}
|
||||
|
||||
//XXX eventually allow for more than one active context on a given canvas
|
||||
return nullptr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user