Bug 1308057 - Fix errors. - r=ethlin draft
authorJeff Gilbert (:jgilbert) <jgilbert@mozilla.com>
Mon, 07 Nov 2016 19:35:47 -0800
changeset 437534 82a0648a3e7296041f4e27db7d981744ea99b032
parent 437533 25a7c20812ceb908da084cce724055042f5b3705
child 437535 fb7eaa78e6efc77e79cbbad783117a369679a3f7
push id35436
push userbmo:jgilbert@mozilla.com
push dateFri, 11 Nov 2016 01:52:22 +0000
reviewersethlin
bugs1308057
milestone52.0a1
Bug 1308057 - Fix errors. - r=ethlin MozReview-Commit-ID: I7bd7xOa2YR
dom/canvas/WebGL2ContextQueries.cpp
--- 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