Bug 1308057 - Fix errors. - r=ethlin a=gchang
authorJeff Gilbert (:jgilbert) <jgilbert@mozilla.com>
Mon, 07 Nov 2016 19:35:47 -0800
changeset 352956 2f70bfc49114f7a5b30513d64f13e0652fefae32
parent 352955 f1eabab447ab9435d2588304271c4a66408a805f
child 352957 6ab791de5580c300db5e03687fc19276906cf3bb
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersethlin, gchang
bugs1308057
milestone52.0a2
Bug 1308057 - Fix errors. - r=ethlin a=gchang 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