Bug 1308057 - Fix errors. - r=ethlin
MozReview-Commit-ID: I7bd7xOa2YR
--- a/dom/canvas/WebGL2ContextQueries.cpp
+++ b/dom/canvas/WebGL2ContextQueries.cpp
@@ -114,19 +114,22 @@ WebGLContext::BeginQuery(GLenum target,
{
if (!funcName) {
funcName = "beginQuery";
}
if (IsContextLost())
return;
- if (!ValidateObject(funcName, query))
+ if (!ValidateObjectAllowDeleted(funcName, query))
return;
+ if (query->IsDeleted())
+ return ErrorInvalidOperation("%s: Cannot begin a deleted query.", funcName);
+
const auto& slot = ValidateQuerySlotByTarget(funcName, target);
if (!slot)
return;
if (*slot)
return ErrorInvalidOperation("%s: Query target already active.", funcName);
////
@@ -170,16 +173,25 @@ WebGLContext::GetQuery(JSContext* cx, GL
retval.setNull();
if (IsContextLost())
return;
switch (pname) {
case LOCAL_GL_CURRENT_QUERY_EXT:
{
+ if (IsExtensionEnabled(WebGLExtensionID::EXT_disjoint_timer_query) &&
+ target == LOCAL_GL_TIMESTAMP)
+ {
+ // Doesn't seem illegal to ask about, but is always null.
+ // TIMESTAMP has no slot, so ValidateQuerySlotByTarget would generate
+ // INVALID_ENUM.
+ return;
+ }
+
const auto& slot = ValidateQuerySlotByTarget(funcName, target);
if (!slot || !*slot)
return;
JS::Rooted<JS::Value> v(cx);
dom::GetOrCreateDOMReflector(cx, slot->get(), &v);
retval.set(v);
}
@@ -222,15 +234,18 @@ WebGLContext::GetQueryParameter(JSContex
if (!funcName) {
funcName = "getQueryParameter";
}
retval.setNull();
if (IsContextLost())
return;
- if (!ValidateObject(funcName, query))
+ if (!ValidateObjectAllowDeleted(funcName, query))
return;
+ if (query->IsDeleted())
+ return ErrorInvalidOperation("%s: Query must not be deleted.", funcName);
+
query->GetQueryParameter(pname, retval);
}
} // namespace mozilla