Bug 1301671 - Cannot bind deleted objects. - r=jgilbert a=gchang
authorEmilio Cobos Álvarez <ecoal95@gmail.com>
Tue, 15 Nov 2016 18:12:10 -0800
changeset 352945 d4aeb0562cba37ec836a6da62b43fe9dfa262c46
parent 352944 cdd0426d595119113eecf3f9eb63eaab2bfa0171
child 352946 57792070436ea7a032ca062a4deb326278287aa0
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)
reviewersjgilbert, gchang
bugs1301671
milestone52.0a2
Bug 1301671 - Cannot bind deleted objects. - r=jgilbert a=gchang MozReview-Commit-ID: DV6a2pYMyIU
dom/canvas/WebGLContextBuffers.cpp
dom/canvas/WebGLContextGL.cpp
dom/canvas/WebGLTexture.cpp
--- a/dom/canvas/WebGLContextBuffers.cpp
+++ b/dom/canvas/WebGLContextBuffers.cpp
@@ -114,19 +114,18 @@ WebGLContext::BindBuffer(GLenum target, 
 {
     const char funcName[] = "bindBuffer";
     if (IsContextLost())
         return;
 
     if (!ValidateObjectAllowDeletedOrNull(funcName, buffer))
         return;
 
-    // silently ignore a deleted buffer
     if (buffer && buffer->IsDeleted())
-        return;
+        return ErrorInvalidOperation("%s: Cannot bind a deleted object.", funcName);
 
     const auto& slot = ValidateBufferSlot(funcName, target);
     if (!slot)
         return;
 
     if (buffer && !buffer->ValidateCanBindToTarget(funcName, target))
         return;
 
@@ -179,19 +178,18 @@ WebGLContext::BindBufferBase(GLenum targ
 {
     const char funcName[] = "bindBufferBase";
     if (IsContextLost())
         return;
 
     if (!ValidateObjectAllowDeletedOrNull(funcName, buffer))
         return;
 
-    // silently ignore a deleted buffer
     if (buffer && buffer->IsDeleted())
-        return;
+        return ErrorInvalidOperation("%s: Cannot bind a deleted object.", funcName);
 
     WebGLRefPtr<WebGLBuffer>* genericBinding;
     IndexedBufferBinding* indexedBinding;
     if (!ValidateIndexedBufferBinding(funcName, target, index, &genericBinding,
                                       &indexedBinding))
     {
         return;
     }
@@ -222,19 +220,18 @@ WebGLContext::BindBufferRange(GLenum tar
 {
     const char funcName[] = "bindBufferRange";
     if (IsContextLost())
         return;
 
     if (!ValidateObjectAllowDeletedOrNull(funcName, buffer))
         return;
 
-    // silently ignore a deleted buffer
     if (buffer && buffer->IsDeleted())
-        return;
+        return ErrorInvalidOperation("%s: Cannot bind a deleted object.", funcName);
 
     if (!ValidateNonNegative(funcName, "offset", offset) ||
         !ValidateNonNegative(funcName, "size", size))
     {
         return;
     }
 
     WebGLRefPtr<WebGLBuffer>* genericBinding;
--- a/dom/canvas/WebGLContextGL.cpp
+++ b/dom/canvas/WebGLContextGL.cpp
@@ -121,19 +121,18 @@ WebGLContext::BindFramebuffer(GLenum tar
         return;
 
     if (!ValidateFramebufferTarget(target, "bindFramebuffer"))
         return;
 
     if (!ValidateObjectAllowDeletedOrNull("bindFramebuffer", wfb))
         return;
 
-    // silently ignore a deleted frame buffer
     if (wfb && wfb->IsDeleted())
-        return;
+        return ErrorInvalidOperation("bindFramebuffer: Cannot bind a deleted object.");
 
     MakeContextCurrent();
 
     if (!wfb) {
         gl->fBindFramebuffer(target, 0);
     } else {
         GLuint framebuffername = wfb->mGLName;
         gl->fBindFramebuffer(target, framebuffername);
@@ -165,19 +164,18 @@ WebGLContext::BindRenderbuffer(GLenum ta
         return;
 
     if (target != LOCAL_GL_RENDERBUFFER)
         return ErrorInvalidEnumInfo("bindRenderbuffer: target", target);
 
     if (!ValidateObjectAllowDeletedOrNull("bindRenderbuffer", wrb))
         return;
 
-    // silently ignore a deleted buffer
     if (wrb && wrb->IsDeleted())
-        return;
+        return ErrorInvalidOperation("bindRenderbuffer: Cannot bind a deleted object.");
 
     // Usually, we would now call into glBindRenderbuffer. However, since we have to
     // potentially emulate packed-depth-stencil, there's not a specific renderbuffer that
     // we know we should bind here.
     // Instead, we do all renderbuffer binding lazily.
 
     if (wrb) {
         wrb->mHasBeenBound = true;
--- a/dom/canvas/WebGLTexture.cpp
+++ b/dom/canvas/WebGLTexture.cpp
@@ -659,19 +659,20 @@ WebGLTexture::PopulateMipChain(uint32_t 
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
 // GL calls
 
 bool
 WebGLTexture::BindTexture(TexTarget texTarget)
 {
-    // silently ignore a deleted texture
-    if (IsDeleted())
+    if (IsDeleted()) {
+        mContext->ErrorInvalidOperation("bindTexture: Cannot bind a deleted object.");
         return false;
+    }
 
     const bool isFirstBinding = !HasEverBeenBound();
     if (!isFirstBinding && mTarget != texTarget) {
         mContext->ErrorInvalidOperation("bindTexture: This texture has already been bound"
                                         " to a different target.");
         return false;
     }