Bug 911856 - Remove the custom concept of "stable context" in favor of the standard concept of "lost context" - r=jgilbert
authorBenoit Jacob <bjacob@mozilla.com>
Wed, 04 Sep 2013 08:14:44 -0400
changeset 145450 dc6759deb5e1feb35ab0b032be47cc0b9eb0fd13
parent 145449 f40f6fb9d98cffdefa4ef92c0313e2d8608ab1ae
child 145451 4e538175f5e843b7ede0097b52f09c72f508d033
push id25213
push userkwierso@gmail.com
push dateWed, 04 Sep 2013 23:18:26 +0000
treeherdermozilla-central@dffedf20a02d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs911856
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 911856 - Remove the custom concept of "stable context" in favor of the standard concept of "lost context" - r=jgilbert
content/canvas/src/WebGLContext.cpp
content/canvas/src/WebGLContext.h
content/canvas/src/WebGLContextAsyncQueries.cpp
content/canvas/src/WebGLContextBuffers.cpp
content/canvas/src/WebGLContextExtensions.cpp
content/canvas/src/WebGLContextFramebufferOperations.cpp
content/canvas/src/WebGLContextGL.cpp
content/canvas/src/WebGLContextState.cpp
content/canvas/src/WebGLContextValidate.cpp
content/canvas/src/WebGLContextVertexArray.cpp
content/canvas/src/WebGLContextVertices.cpp
content/canvas/src/WebGLTypes.h
--- a/content/canvas/src/WebGLContext.cpp
+++ b/content/canvas/src/WebGLContext.cpp
@@ -179,17 +179,17 @@ WebGLContext::WebGLContext()
     mPixelStoreUnpackAlignment = 4;
 
     WebGLMemoryMultiReporterWrapper::AddWebGLContext(this);
 
     mAllowRestore = true;
     mContextLossTimerRunning = false;
     mDrawSinceContextLossTimerSet = false;
     mContextRestorer = do_CreateInstance("@mozilla.org/timer;1");
-    mContextStatus = ContextStable;
+    mContextStatus = ContextNotLost;
     mContextLostErrorSet = false;
     mLoseContextOnHeapMinimize = false;
     mCanLoseContextInForeground = true;
 
     mAlreadyGeneratedWarnings = 0;
     mAlreadyWarnedAboutFakeVertexAttrib0 = false;
     mMaxWarnings = Preferences::GetInt("webgl.max-warnings-per-context", 32);
     if (mMaxWarnings < -1)
@@ -839,17 +839,17 @@ private:
 
 } // end namespace mozilla
 
 already_AddRefed<layers::CanvasLayer>
 WebGLContext::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
                              CanvasLayer *aOldLayer,
                              LayerManager *aManager)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return nullptr;
 
     if (!mResetLayer && aOldLayer &&
         aOldLayer->HasUserData(&gWebGLLayerUserData)) {
         nsRefPtr<layers::CanvasLayer> ret = aOldLayer;
         return ret.forget();
     }
 
@@ -894,17 +894,17 @@ WebGLContext::GetCanvasLayer(nsDisplayLi
 
     return canvasLayer.forget();
 }
 
 void
 WebGLContext::GetContextAttributes(Nullable<dom::WebGLContextAttributesInitializer> &retval)
 {
     retval.SetNull();
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     dom::WebGLContextAttributes& result = retval.SetValue();
 
     const PixelBufferFormat& format = gl->GetPixelFormat();
 
     result.mAlpha.Construct(format.alpha > 0);
     result.mDepth = format.depth > 0;
@@ -913,17 +913,17 @@ WebGLContext::GetContextAttributes(Nulla
     result.mPremultipliedAlpha = mOptions.premultipliedAlpha;
     result.mPreserveDrawingBuffer = mOptions.preserveDrawingBuffer;
 }
 
 /* [noscript] DOMString mozGetUnderlyingParamString(in GLenum pname); */
 NS_IMETHODIMP
 WebGLContext::MozGetUnderlyingParamString(uint32_t pname, nsAString& retval)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return NS_OK;
 
     retval.SetIsVoid(true);
 
     MakeContextCurrent();
 
     switch (pname) {
     case LOCAL_GL_VENDOR:
@@ -1215,17 +1215,17 @@ WebGLContext::RobustnessTimerCallback(ns
             mContextStatus = ContextLost;
         }
     } else if (mContextStatus == ContextLostAwaitingRestore) {
         // Try to restore the context. If it fails, try again later.
         if (NS_FAILED(SetDimensions(mWidth, mHeight))) {
             SetupContextLossTimer();
             return;
         }
-        mContextStatus = ContextStable;
+        mContextStatus = ContextNotLost;
         nsContentUtils::DispatchTrustedEvent(mCanvasElement->OwnerDoc(),
                                              static_cast<nsIDOMHTMLCanvasElement*>(mCanvasElement),
                                              NS_LITERAL_STRING("webglcontextrestored"),
                                              true,
                                              true);
         // Set all flags back to the state they were in before the context was
         // lost.
         mContextLostErrorSet = false;
@@ -1235,17 +1235,17 @@ WebGLContext::RobustnessTimerCallback(ns
     MaybeRestoreContext();
     return;
 }
 
 void
 WebGLContext::MaybeRestoreContext()
 {
     // Don't try to handle it if we already know it's busted.
-    if (mContextStatus != ContextStable || gl == nullptr)
+    if (mContextStatus != ContextNotLost || gl == nullptr)
         return;
 
     bool isEGL = gl->GetContextType() == GLContext::ContextTypeEGL,
          isANGLE = gl->IsANGLE();
 
     GLContext::ContextResetARB resetStatus = GLContext::CONTEXT_NO_ERROR;
     if (mHasRobustness) {
         gl->MakeCurrent();
--- a/content/canvas/src/WebGLContext.h
+++ b/content/canvas/src/WebGLContext.h
@@ -292,40 +292,40 @@ public:
         }
     }
 
     // WebIDL WebGLRenderingContext API
     dom::HTMLCanvasElement* GetCanvas() const {
         return mCanvasElement;
     }
     GLsizei DrawingBufferWidth() const {
-        if (!IsContextStable())
+        if (IsContextLost())
             return 0;
         return mWidth;
     }
     GLsizei DrawingBufferHeight() const {
-        if (!IsContextStable())
+        if (IsContextLost())
             return 0;
         return mHeight;
     }
-        
+
     void GetContextAttributes(dom::Nullable<dom::WebGLContextAttributesInitializer>& retval);
-    bool IsContextLost() const { return !IsContextStable(); }
+    bool IsContextLost() const { return mContextStatus != ContextNotLost; }
     void GetSupportedExtensions(JSContext *cx, dom::Nullable< nsTArray<nsString> > &retval);
     JSObject* GetExtension(JSContext* cx, const nsAString& aName, ErrorResult& rv);
     void ActiveTexture(GLenum texture);
     void AttachShader(WebGLProgram* program, WebGLShader* shader);
     void BindAttribLocation(WebGLProgram* program, GLuint location,
                             const nsAString& name);
     void BindFramebuffer(GLenum target, WebGLFramebuffer* wfb);
     void BindRenderbuffer(GLenum target, WebGLRenderbuffer* wrb);
     void BindTexture(GLenum target, WebGLTexture *tex);
     void BindVertexArray(WebGLVertexArray *vao);
     void BlendColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a) {
-        if (!IsContextStable())
+        if (IsContextLost())
             return;
         MakeContextCurrent();
         gl->fBlendColor(r, g, b, a);
     }
     void BlendEquation(GLenum mode);
     void BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
     void BlendFunc(GLenum sfactor, GLenum dfactor);
     void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB,
@@ -366,23 +366,23 @@ public:
     void DeleteVertexArray(WebGLVertexArray *vao);
     void DeleteTexture(WebGLTexture *tex);
     void DepthFunc(GLenum func);
     void DepthMask(WebGLboolean b);
     void DepthRange(GLclampf zNear, GLclampf zFar);
     void DetachShader(WebGLProgram *program, WebGLShader *shader);
     void DrawBuffers(const dom::Sequence<GLenum>& buffers);
     void Flush() {
-        if (!IsContextStable())
+        if (IsContextLost())
             return;
         MakeContextCurrent();
         gl->fFlush();
     }
     void Finish() {
-        if (!IsContextStable())
+        if (IsContextLost())
             return;
         MakeContextCurrent();
         gl->fFinish();
     }
     void FramebufferRenderbuffer(GLenum target, GLenum attachment,
                                  GLenum rbtarget, WebGLRenderbuffer *wrb);
     void FramebufferTexture2D(GLenum target, GLenum attachment,
                               GLenum textarget, WebGLTexture *tobj,
@@ -441,37 +441,37 @@ public:
     void Hint(GLenum target, GLenum mode);
     bool IsFramebuffer(WebGLFramebuffer *fb);
     bool IsProgram(WebGLProgram *prog);
     bool IsRenderbuffer(WebGLRenderbuffer *rb);
     bool IsShader(WebGLShader *shader);
     bool IsTexture(WebGLTexture *tex);
     bool IsVertexArray(WebGLVertexArray *vao);
     void LineWidth(GLfloat width) {
-        if (!IsContextStable())
+        if (IsContextLost())
             return;
         MakeContextCurrent();
         gl->fLineWidth(width);
     }
     void LinkProgram(WebGLProgram *program);
     void PixelStorei(GLenum pname, GLint param);
     void PolygonOffset(GLfloat factor, GLfloat units) {
-        if (!IsContextStable())
+        if (IsContextLost())
             return;
         MakeContextCurrent();
         gl->fPolygonOffset(factor, units);
     }
     void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
                     GLenum format, GLenum type,
                     const Nullable<dom::ArrayBufferView> &pixels,
                     ErrorResult& rv);
     void RenderbufferStorage(GLenum target, GLenum internalformat,
                              GLsizei width, GLsizei height);
     void SampleCoverage(GLclampf value, WebGLboolean invert) {
-        if (!IsContextStable())
+        if (IsContextLost())
             return;
         MakeContextCurrent();
         gl->fSampleCoverage(value, invert);
     }
     void Scissor(GLint x, GLint y, GLsizei width, GLsizei height);
     void ShaderSource(WebGLShader *shader, const nsAString& source);
     void StencilFunc(GLenum func, GLint ref, GLuint mask);
     void StencilFuncSeparate(GLenum face, GLenum func, GLint ref,
@@ -492,17 +492,17 @@ public:
                     dom::ImageData* pixels, ErrorResult& rv);
     // Allow whatever element types the bindings are willing to pass
     // us in TexImage2D
     template<class ElementType>
     void TexImage2D(GLenum target, GLint level,
                     GLenum internalformat, GLenum format, GLenum type,
                     ElementType& elt, ErrorResult& rv)
     {
-        if (!IsContextStable())
+        if (IsContextLost())
             return;
         nsRefPtr<gfxImageSurface> isurf;
         WebGLTexelFormat srcFormat;
         nsLayoutUtils::SurfaceFromElementResult res = SurfaceFromElement(elt);
         rv = SurfaceFromElementResultToImageSurface(res, getter_AddRefs(isurf),
                                                     &srcFormat);
         if (rv.Failed())
             return;
@@ -531,17 +531,17 @@ public:
                        GLenum type, dom::ImageData* pixels, ErrorResult& rv);
     // Allow whatever element types the bindings are willing to pass
     // us in TexSubImage2D
     template<class ElementType>
     void TexSubImage2D(GLenum target, GLint level,
                        GLint xoffset, GLint yoffset, GLenum format,
                        GLenum type, ElementType& elt, ErrorResult& rv)
     {
-        if (!IsContextStable())
+        if (IsContextLost())
             return;
         nsRefPtr<gfxImageSurface> isurf;
         WebGLTexelFormat srcFormat;
         nsLayoutUtils::SurfaceFromElementResult res = SurfaceFromElement(elt);
         rv = SurfaceFromElementResultToImageSurface(res, getter_AddRefs(isurf),
                                                     &srcFormat);
         if (rv.Failed())
             return;
@@ -938,23 +938,24 @@ protected:
     int32_t mGLMaxVertexTextureImageUnits;
     int32_t mGLMaxVaryingVectors;
     int32_t mGLMaxFragmentUniformVectors;
     int32_t mGLMaxVertexUniformVectors;
     int32_t mGLMaxColorAttachments;
     int32_t mGLMaxDrawBuffers;
     uint32_t mGLMaxTransformFeedbackSeparateAttribs;
 
-    // Represents current status, or state, of the context. That is, is it lost
-    // or stable and what part of the context lost process are we currently at.
+    // Represents current status of the context with respect to context loss.
+    // That is, whether the context is lost, and what part of the context loss
+    // process we currently are at.
     // This is used to support the WebGL spec's asyncronous nature in handling
     // context loss.
     enum ContextStatus {
         // The context is stable; there either are none or we don't know of any.
-        ContextStable,
+        ContextNotLost,
         // The context has been lost, but we have not yet sent an event to the
         // script informing it of this.
         ContextLostAwaitingEvent,
         // The context has been lost, and we have sent the script an event
         // informing it of this.
         ContextLost,
         // The context is lost, an event has been sent to the script, and the
         // script correctly handled the event. We are waiting for the context to
@@ -1134,19 +1135,16 @@ protected:
                              GLsizei width,
                              GLsizei height,
                              GLint border,
                              GLenum format,
                              GLenum type,
                              const GLvoid *data);
 
     void MaybeRestoreContext();
-    bool IsContextStable() const {
-        return mContextStatus == ContextStable;
-    }
     void ForceLoseContext();
     void ForceRestoreContext();
 
     nsTArray<WebGLRefPtr<WebGLTexture> > mBound2DTextures;
     nsTArray<WebGLRefPtr<WebGLTexture> > mBoundCubeMapTextures;
 
     WebGLRefPtr<WebGLProgram> mCurrentProgram;
 
--- a/content/canvas/src/WebGLContextAsyncQueries.cpp
+++ b/content/canvas/src/WebGLContextAsyncQueries.cpp
@@ -51,17 +51,17 @@ SimulateOcclusionQueryTarget(const gl::G
     }
 
     return LOCAL_GL_SAMPLES_PASSED;
 }
 
 already_AddRefed<WebGLQuery>
 WebGLContext::CreateQuery()
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return nullptr;
 
     if (mActiveOcclusionQuery && !gl->IsGLES2()) {
         /* http://www.opengl.org/registry/specs/ARB/occlusion_query.txt
          * Calling either GenQueriesARB or DeleteQueriesARB while any query of
          * any target is active causes an INVALID_OPERATION error to be
          * generated.
          */
@@ -76,17 +76,17 @@ WebGLContext::CreateQuery()
     nsRefPtr<WebGLQuery> globj = new WebGLQuery(this);
 
     return globj.forget();
 }
 
 void
 WebGLContext::DeleteQuery(WebGLQuery *query)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!query)
         return;
 
     if (query->IsDeleted())
         return;
 
@@ -105,17 +105,17 @@ WebGLContext::DeleteQuery(WebGLQuery *qu
     }
 
     query->RequestDelete();
 }
 
 void
 WebGLContext::BeginQuery(GLenum target, WebGLQuery *query)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     WebGLRefPtr<WebGLQuery>* targetSlot = GetQueryTargetSlot(target, "beginQuery");
     if (!targetSlot) {
         return;
     }
 
     if (!query) {
@@ -175,17 +175,17 @@ WebGLContext::BeginQuery(GLenum target, 
     }
 
     *targetSlot = query;
 }
 
 void
 WebGLContext::EndQuery(GLenum target)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     WebGLRefPtr<WebGLQuery>* targetSlot = GetQueryTargetSlot(target, "endQuery");
     if (!targetSlot) {
         return;
     }
 
     if (!*targetSlot ||
@@ -217,31 +217,31 @@ WebGLContext::EndQuery(GLenum target)
     }
 
     *targetSlot = nullptr;
 }
 
 bool
 WebGLContext::IsQuery(WebGLQuery *query)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return false;
 
     if (!query)
         return false;
 
     return ValidateObjectAllowDeleted("isQuery", query) &&
            !query->IsDeleted() &&
            query->HasEverBeenActive();
 }
 
 already_AddRefed<WebGLQuery>
 WebGLContext::GetQuery(GLenum target, GLenum pname)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return nullptr;
 
     WebGLRefPtr<WebGLQuery>* targetSlot = GetQueryTargetSlot(target, "getQuery");
     if (!targetSlot) {
         return nullptr;
     }
 
     if (pname != LOCAL_GL_CURRENT_QUERY) {
@@ -254,17 +254,17 @@ WebGLContext::GetQuery(GLenum target, GL
 
     nsRefPtr<WebGLQuery> tmp = targetSlot->get();
     return tmp.forget();
 }
 
 JS::Value
 WebGLContext::GetQueryObject(JSContext* cx, WebGLQuery *query, GLenum pname)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return JS::NullValue();
 
     if (!query) {
         /* OpenGL ES 3.0 spec 6.1.7 (spec getQueryObject 1)
          *  If id is not the name of a query object, or if the query object named by id is
          *  currently active, then an INVALID_OPERATION error is generated. pname must be
          *  QUERY_RESULT or QUERY_RESULT_AVAILABLE.
          */
--- a/content/canvas/src/WebGLContextBuffers.cpp
+++ b/content/canvas/src/WebGLContextBuffers.cpp
@@ -8,17 +8,17 @@
 #include "WebGLVertexArray.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 void
 WebGLContext::BindBuffer(GLenum target, WebGLBuffer *buffer)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObjectAllowDeletedOrNull("bindBuffer", buffer))
         return;
 
     // silently ignore a deleted buffer
     if (buffer && buffer->IsDeleted())
         return;
@@ -43,17 +43,17 @@ WebGLContext::BindBuffer(GLenum target, 
     MakeContextCurrent();
 
     gl->fBindBuffer(target, buffer ? buffer->GLName() : 0);
 }
 
 void
 WebGLContext::BindBufferBase(GLenum target, GLuint index, WebGLBuffer* buffer)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObjectAllowDeletedOrNull("bindBufferBase", buffer))
         return;
 
     // silently ignore a deleted buffer
     if (buffer && buffer->IsDeleted()) {
         return;
@@ -85,17 +85,17 @@ WebGLContext::BindBufferBase(GLenum targ
 
     gl->fBindBufferBase(target, index, buffer ? buffer->GLName() : 0);
 }
 
 void
 WebGLContext::BindBufferRange(GLenum target, GLuint index, WebGLBuffer* buffer,
                               WebGLintptr offset, WebGLsizeiptr size)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObjectAllowDeletedOrNull("bindBufferRange", buffer))
         return;
 
     // silently ignore a deleted buffer
     if (buffer && buffer->IsDeleted())
         return;
@@ -132,17 +132,17 @@ WebGLContext::BindBufferRange(GLenum tar
 
     gl->fBindBufferRange(target, index, buffer ? buffer->GLName() : 0, offset, size);
 }
 
 void
 WebGLContext::BufferData(GLenum target, WebGLsizeiptr size,
                          GLenum usage)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     WebGLRefPtr<WebGLBuffer>* bufferSlot = GetBufferSlotByTarget(target, "bufferData");
 
     if (!bufferSlot) {
         return;
     }
 
@@ -182,17 +182,17 @@ WebGLContext::BufferData(GLenum target, 
     }
 }
 
 void
 WebGLContext::BufferData(GLenum target,
                          const Nullable<ArrayBuffer> &maybeData,
                          GLenum usage)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (maybeData.IsNull()) {
         // see http://www.khronos.org/bugzilla/show_bug.cgi?id=386
         return ErrorInvalidValue("bufferData: null object passed");
     }
 
     WebGLRefPtr<WebGLBuffer>* bufferSlot = GetBufferSlotByTarget(target, "bufferData");
@@ -230,17 +230,17 @@ WebGLContext::BufferData(GLenum target,
         return ErrorOutOfMemory("bufferData: out of memory");
     }
 }
 
 void
 WebGLContext::BufferData(GLenum target, const ArrayBufferView& data,
                          GLenum usage)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     WebGLRefPtr<WebGLBuffer>* bufferSlot = GetBufferSlotByTarget(target, "bufferSubData");
 
     if (!bufferSlot) {
         return;
     }
 
@@ -270,17 +270,17 @@ WebGLContext::BufferData(GLenum target, 
         return ErrorOutOfMemory("bufferData: out of memory");
     }
 }
 
 void
 WebGLContext::BufferSubData(GLenum target, WebGLsizeiptr byteOffset,
                             const Nullable<ArrayBuffer> &maybeData)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (maybeData.IsNull()) {
         // see http://www.khronos.org/bugzilla/show_bug.cgi?id=386
         return;
     }
 
     WebGLRefPtr<WebGLBuffer>* bufferSlot = GetBufferSlotByTarget(target, "bufferSubData");
@@ -313,17 +313,17 @@ WebGLContext::BufferSubData(GLenum targe
 
     gl->fBufferSubData(target, byteOffset, data.Length(), data.Data());
 }
 
 void
 WebGLContext::BufferSubData(GLenum target, WebGLsizeiptr byteOffset,
                             const ArrayBufferView& data)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     WebGLRefPtr<WebGLBuffer>* bufferSlot = GetBufferSlotByTarget(target, "bufferSubData");
 
     if (!bufferSlot) {
         return;
     }
 
@@ -347,27 +347,27 @@ WebGLContext::BufferSubData(GLenum targe
 
     MakeContextCurrent();
     gl->fBufferSubData(target, byteOffset, data.Length(), data.Data());
 }
 
 already_AddRefed<WebGLBuffer>
 WebGLContext::CreateBuffer()
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return nullptr;
 
     nsRefPtr<WebGLBuffer> globj = new WebGLBuffer(this);
     return globj.forget();
 }
 
 void
 WebGLContext::DeleteBuffer(WebGLBuffer *buffer)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObjectAllowDeletedOrNull("deleteBuffer", buffer))
         return;
 
     if (!buffer || buffer->IsDeleted())
         return;
 
@@ -387,17 +387,17 @@ WebGLContext::DeleteBuffer(WebGLBuffer *
     }
 
     buffer->RequestDelete();
 }
 
 bool
 WebGLContext::IsBuffer(WebGLBuffer *buffer)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return false;
 
     return ValidateObjectAllowDeleted("isBuffer", buffer) &&
            !buffer->IsDeleted() &&
            buffer->HasEverBeenBound();
 }
 
 bool
--- a/content/canvas/src/WebGLContextExtensions.cpp
+++ b/content/canvas/src/WebGLContextExtensions.cpp
@@ -131,17 +131,17 @@ static bool
 CompareWebGLExtensionName(const nsACString& name, const char *other)
 {
     return name.Equals(other, nsCaseInsensitiveCStringComparator());
 }
 
 JSObject*
 WebGLContext::GetExtension(JSContext *cx, const nsAString& aName, ErrorResult& rv)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return nullptr;
 
     NS_LossyConvertUTF16toASCII name(aName);
 
     WebGLExtensionID ext = WebGLExtensionID_unknown_extension;
 
     // step 1: figure what extension is wanted
     for (size_t i = 0; i < size_t(WebGLExtensionID_max); i++)
@@ -252,17 +252,17 @@ WebGLContext::EnableExtension(WebGLExten
 
     mExtensions[ext] = obj;
 }
 
 void
 WebGLContext::GetSupportedExtensions(JSContext *cx, Nullable< nsTArray<nsString> > &retval)
 {
     retval.SetNull();
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     nsTArray<nsString>& arr = retval.SetValue();
 
     for (size_t i = 0; i < size_t(WebGLExtensionID_max); i++)
     {
         WebGLExtensionID extension = WebGLExtensionID(i);
 
--- a/content/canvas/src/WebGLContextFramebufferOperations.cpp
+++ b/content/canvas/src/WebGLContextFramebufferOperations.cpp
@@ -8,17 +8,17 @@
 #include "WebGLRenderbuffer.h"
 #include "WebGLFramebuffer.h"
 
 using namespace mozilla;
 
 void
 WebGLContext::Clear(GLbitfield mask)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     MakeContextCurrent();
 
     uint32_t m = mask & (LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT | LOCAL_GL_STENCIL_BUFFER_BIT);
     if (mask != m)
         return ErrorInvalidValue("clear: invalid mask bits");
 
@@ -87,67 +87,67 @@ GLClampFloat(GLclampf val)
 
     return val;
 }
 
 void
 WebGLContext::ClearColor(GLclampf r, GLclampf g,
                              GLclampf b, GLclampf a)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     MakeContextCurrent();
     mColorClearValue[0] = GLClampFloat(r);
     mColorClearValue[1] = GLClampFloat(g);
     mColorClearValue[2] = GLClampFloat(b);
     mColorClearValue[3] = GLClampFloat(a);
     gl->fClearColor(r, g, b, a);
 }
 
 void
 WebGLContext::ClearDepth(GLclampf v)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     MakeContextCurrent();
     mDepthClearValue = GLClampFloat(v);
     gl->fClearDepth(v);
 }
 
 void
 WebGLContext::ClearStencil(GLint v)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     MakeContextCurrent();
     mStencilClearValue = v;
     gl->fClearStencil(v);
 }
 
 void
 WebGLContext::ColorMask(WebGLboolean r, WebGLboolean g, WebGLboolean b, WebGLboolean a)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     MakeContextCurrent();
     mColorWriteMask[0] = r;
     mColorWriteMask[1] = g;
     mColorWriteMask[2] = b;
     mColorWriteMask[3] = a;
     gl->fColorMask(r, g, b, a);
 }
 
 void
 WebGLContext::DepthMask(WebGLboolean b)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     MakeContextCurrent();
     mDepthWriteMask = b;
     gl->fDepthMask(b);
 }
 
 void
@@ -224,30 +224,30 @@ WebGLContext::DrawBuffers(const dom::Seq
     MakeContextCurrent();
 
     gl->fDrawBuffers(buffersLength, buffers.Elements());
 }
 
 void
 WebGLContext::StencilMask(GLuint mask)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     mStencilWriteMaskFront = mask;
     mStencilWriteMaskBack = mask;
 
     MakeContextCurrent();
     gl->fStencilMask(mask);
 }
 
 void
 WebGLContext::StencilMaskSeparate(GLenum face, GLuint mask)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateFaceEnum(face, "stencilMaskSeparate: face"))
         return;
 
     switch (face) {
         case LOCAL_GL_FRONT_AND_BACK:
             mStencilWriteMaskFront = mask;
--- a/content/canvas/src/WebGLContextGL.cpp
+++ b/content/canvas/src/WebGLContextGL.cpp
@@ -58,17 +58,17 @@ static GLenum InternalFormatForFormatAnd
 inline const WebGLRectangleObject *WebGLContext::FramebufferRectangleObject() const {
     return mBoundFramebuffer ? mBoundFramebuffer->RectangleObject()
                              : static_cast<const WebGLRectangleObject*>(this);
 }
 
 void
 WebGLContext::ActiveTexture(GLenum texture)
 {
-    if (!IsContextStable()) 
+    if (IsContextLost()) 
         return;
 
     if (texture < LOCAL_GL_TEXTURE0 ||
         texture >= LOCAL_GL_TEXTURE0 + uint32_t(mGLMaxTextureUnits))
     {
         return ErrorInvalidEnum(
             "ActiveTexture: texture unit %d out of range. "
             "Accepted values range from TEXTURE0 to TEXTURE0 + %d. "
@@ -79,17 +79,17 @@ WebGLContext::ActiveTexture(GLenum textu
     MakeContextCurrent();
     mActiveTexture = texture - LOCAL_GL_TEXTURE0;
     gl->fActiveTexture(texture);
 }
 
 void
 WebGLContext::AttachShader(WebGLProgram *program, WebGLShader *shader)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObject("attachShader: program", program) ||
         !ValidateObject("attachShader: shader", shader))
         return;
 
     // Per GLSL ES 2.0, we can only have one of each type of shader
     // attached.  This renders the next test somewhat moot, but we'll
@@ -101,17 +101,17 @@ WebGLContext::AttachShader(WebGLProgram 
         return ErrorInvalidOperation("attachShader: shader is already attached");
 }
 
 
 void
 WebGLContext::BindAttribLocation(WebGLProgram *prog, GLuint location,
                                  const nsAString& name)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObject("bindAttribLocation: program", prog))
         return;
 
     GLuint progname = prog->GLName();
 
     if (!ValidateGLSLVariableName(name, "bindAttribLocation"))
@@ -126,17 +126,17 @@ WebGLContext::BindAttribLocation(WebGLPr
     
     MakeContextCurrent();
     gl->fBindAttribLocation(progname, location, mappedName.get());
 }
 
 void
 WebGLContext::BindFramebuffer(GLenum target, WebGLFramebuffer *wfb)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (target != LOCAL_GL_FRAMEBUFFER)
         return ErrorInvalidEnum("bindFramebuffer: target must be GL_FRAMEBUFFER");
 
     if (!ValidateObjectAllowDeletedOrNull("bindFramebuffer", wfb))
         return;
 
@@ -155,17 +155,17 @@ WebGLContext::BindFramebuffer(GLenum tar
     }
 
     mBoundFramebuffer = wfb;
 }
 
 void
 WebGLContext::BindRenderbuffer(GLenum target, WebGLRenderbuffer *wrb)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (target != LOCAL_GL_RENDERBUFFER)
         return ErrorInvalidEnumInfo("bindRenderbuffer: target", target);
 
     if (!ValidateObjectAllowDeletedOrNull("bindRenderbuffer", wrb))
         return;
 
@@ -182,17 +182,17 @@ WebGLContext::BindRenderbuffer(GLenum ta
     gl->fBindRenderbuffer(target, renderbuffername);
 
     mBoundRenderbuffer = wrb;
 }
 
 void
 WebGLContext::BindTexture(GLenum target, WebGLTexture *tex)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObjectAllowDeletedOrNull("bindTexture", tex))
         return;
 
     // silently ignore a deleted texture
     if (tex && tex->IsDeleted())
         return;
@@ -211,42 +211,42 @@ WebGLContext::BindTexture(GLenum target,
     if (tex)
         tex->Bind(target);
     else
         gl->fBindTexture(target, 0 /* == texturename */);
 }
 
 void WebGLContext::BlendEquation(GLenum mode)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateBlendEquationEnum(mode, "blendEquation: mode"))
         return;
 
     MakeContextCurrent();
     gl->fBlendEquation(mode);
 }
 
 void WebGLContext::BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateBlendEquationEnum(modeRGB, "blendEquationSeparate: modeRGB") ||
         !ValidateBlendEquationEnum(modeAlpha, "blendEquationSeparate: modeAlpha"))
         return;
 
     MakeContextCurrent();
     gl->fBlendEquationSeparate(modeRGB, modeAlpha);
 }
 
 void WebGLContext::BlendFunc(GLenum sfactor, GLenum dfactor)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateBlendFuncSrcEnum(sfactor, "blendFunc: sfactor") ||
         !ValidateBlendFuncDstEnum(dfactor, "blendFunc: dfactor"))
         return;
 
     if (!ValidateBlendFuncEnumsCompatibility(sfactor, dfactor, "blendFuncSeparate: srcRGB and dstRGB"))
         return;
@@ -254,17 +254,17 @@ void WebGLContext::BlendFunc(GLenum sfac
     MakeContextCurrent();
     gl->fBlendFunc(sfactor, dfactor);
 }
 
 void
 WebGLContext::BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB,
                                 GLenum srcAlpha, GLenum dstAlpha)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateBlendFuncSrcEnum(srcRGB, "blendFuncSeparate: srcRGB") ||
         !ValidateBlendFuncSrcEnum(srcAlpha, "blendFuncSeparate: srcAlpha") ||
         !ValidateBlendFuncDstEnum(dstRGB, "blendFuncSeparate: dstRGB") ||
         !ValidateBlendFuncDstEnum(dstAlpha, "blendFuncSeparate: dstAlpha"))
         return;
 
@@ -310,17 +310,17 @@ GLenum WebGLContext::CheckedBufferData(G
         gl->fBufferData(target, size, data, usage);
         return LOCAL_GL_NO_ERROR;
     }
 }
 
 GLenum
 WebGLContext::CheckFramebufferStatus(GLenum target)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
     {
         return LOCAL_GL_FRAMEBUFFER_UNSUPPORTED;
     }
 
     MakeContextCurrent();
     if (target != LOCAL_GL_FRAMEBUFFER) {
         ErrorInvalidEnum("checkFramebufferStatus: target must be FRAMEBUFFER");
         return 0;
@@ -467,17 +467,17 @@ WebGLContext::CopyTexImage2D(GLenum targ
                              GLint level,
                              GLenum internalformat,
                              GLint x,
                              GLint y,
                              GLsizei width,
                              GLsizei height,
                              GLint border)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     switch (target) {
         case LOCAL_GL_TEXTURE_2D:
         case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X:
         case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
         case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
         case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
@@ -576,17 +576,17 @@ WebGLContext::CopyTexSubImage2D(GLenum t
                                 GLint level,
                                 GLint xoffset,
                                 GLint yoffset,
                                 GLint x,
                                 GLint y,
                                 GLsizei width,
                                 GLsizei height)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     switch (target) {
         case LOCAL_GL_TEXTURE_2D:
         case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X:
         case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
         case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
         case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
@@ -649,56 +649,56 @@ WebGLContext::CopyTexSubImage2D(GLenum t
 
     return CopyTexSubImage2D_base(target, level, format, xoffset, yoffset, x, y, width, height, true);
 }
 
 
 already_AddRefed<WebGLProgram>
 WebGLContext::CreateProgram()
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return nullptr;
     nsRefPtr<WebGLProgram> globj = new WebGLProgram(this);
     return globj.forget();
 }
 
 already_AddRefed<WebGLShader>
 WebGLContext::CreateShader(GLenum type)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return nullptr;
 
     if (type != LOCAL_GL_VERTEX_SHADER &&
         type != LOCAL_GL_FRAGMENT_SHADER)
     {
         ErrorInvalidEnumInfo("createShader: type", type);
         return nullptr;
     }
 
     nsRefPtr<WebGLShader> shader = new WebGLShader(this, type);
     return shader.forget();
 }
 
 void
 WebGLContext::CullFace(GLenum face)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateFaceEnum(face, "cullFace"))
         return;
 
     MakeContextCurrent();
     gl->fCullFace(face);
 }
 
 void
 WebGLContext::DeleteFramebuffer(WebGLFramebuffer* fbuf)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObjectAllowDeletedOrNull("deleteFramebuffer", fbuf))
         return;
 
     if (!fbuf || fbuf->IsDeleted())
         return;
 
@@ -707,17 +707,17 @@ WebGLContext::DeleteFramebuffer(WebGLFra
     if (mBoundFramebuffer == fbuf)
         BindFramebuffer(LOCAL_GL_FRAMEBUFFER,
                         static_cast<WebGLFramebuffer*>(nullptr));
 }
 
 void
 WebGLContext::DeleteRenderbuffer(WebGLRenderbuffer *rbuf)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObjectAllowDeletedOrNull("deleteRenderbuffer", rbuf))
         return;
 
     if (!rbuf || rbuf->IsDeleted())
         return;
 
@@ -729,17 +729,17 @@ WebGLContext::DeleteRenderbuffer(WebGLRe
                          static_cast<WebGLRenderbuffer*>(nullptr));
 
     rbuf->RequestDelete();
 }
 
 void
 WebGLContext::DeleteTexture(WebGLTexture *tex)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObjectAllowDeletedOrNull("deleteTexture", tex))
         return;
 
     if (!tex || tex->IsDeleted())
         return;
 
@@ -758,76 +758,76 @@ WebGLContext::DeleteTexture(WebGLTexture
     ActiveTexture(LOCAL_GL_TEXTURE0 + activeTexture);
 
     tex->RequestDelete();
 }
 
 void
 WebGLContext::DeleteProgram(WebGLProgram *prog)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObjectAllowDeletedOrNull("deleteProgram", prog))
         return;
 
     if (!prog || prog->IsDeleted())
         return;
 
     prog->RequestDelete();
 }
 
 void
 WebGLContext::DeleteShader(WebGLShader *shader)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObjectAllowDeletedOrNull("deleteShader", shader))
         return;
 
     if (!shader || shader->IsDeleted())
         return;
 
     shader->RequestDelete();
 }
 
 void
 WebGLContext::DetachShader(WebGLProgram *program, WebGLShader *shader)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObject("detachShader: program", program) ||
         // it's valid to attempt to detach a deleted shader, since it's
         // still a shader
         !ValidateObjectAllowDeleted("detashShader: shader", shader))
         return;
 
     if (!program->DetachShader(shader))
         return ErrorInvalidOperation("detachShader: shader is not attached");
 }
 
 void
 WebGLContext::DepthFunc(GLenum func)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateComparisonEnum(func, "depthFunc"))
         return;
 
     MakeContextCurrent();
     gl->fDepthFunc(func);
 }
 
 void
 WebGLContext::DepthRange(GLfloat zNear, GLfloat zFar)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (zNear > zFar)
         return ErrorInvalidOperation("depthRange: the near value is greater than the far value!");
 
     MakeContextCurrent();
     gl->fDepthRange(zNear, zFar);
 }
@@ -1048,45 +1048,45 @@ WebGLContext::UnbindFakeBlackTextures()
     }
 
     gl->fActiveTexture(LOCAL_GL_TEXTURE0 + mActiveTexture);
 }
 
 void
 WebGLContext::FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum rbtarget, WebGLRenderbuffer *wrb)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!mBoundFramebuffer)
         return ErrorInvalidOperation("framebufferRenderbuffer: cannot modify framebuffer 0");
 
     return mBoundFramebuffer->FramebufferRenderbuffer(target, attachment, rbtarget, wrb);
 }
 
 void
 WebGLContext::FramebufferTexture2D(GLenum target,
                                    GLenum attachment,
                                    GLenum textarget,
                                    WebGLTexture *tobj,
                                    GLint level)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!mBoundFramebuffer)
         return ErrorInvalidOperation("framebufferRenderbuffer: cannot modify framebuffer 0");
 
     return mBoundFramebuffer->FramebufferTexture2D(target, attachment, textarget, tobj, level);
 }
 
 void
 WebGLContext::FrontFace(GLenum mode)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     switch (mode) {
         case LOCAL_GL_CW:
         case LOCAL_GL_CCW:
             break;
         default:
             return ErrorInvalidEnumInfo("frontFace: mode", mode);
@@ -1094,17 +1094,17 @@ WebGLContext::FrontFace(GLenum mode)
 
     MakeContextCurrent();
     gl->fFrontFace(mode);
 }
 
 already_AddRefed<WebGLActiveInfo>
 WebGLContext::GetActiveAttrib(WebGLProgram *prog, uint32_t index)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return nullptr;
 
     if (!ValidateObject("getActiveAttrib: program", prog))
         return nullptr;
 
     MakeContextCurrent();
 
     GLint len = 0;
@@ -1128,17 +1128,17 @@ WebGLContext::GetActiveAttrib(WebGLProgr
     nsRefPtr<WebGLActiveInfo> retActiveInfo =
         new WebGLActiveInfo(attrsize, attrtype, reverseMappedName);
     return retActiveInfo.forget();
 }
 
 void
 WebGLContext::GenerateMipmap(GLenum target)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateTextureTargetEnum(target, "generateMipmap"))
         return;
 
     WebGLTexture *tex = activeBoundTextureForTarget(target);
 
     if (!tex)
@@ -1179,17 +1179,17 @@ WebGLContext::GenerateMipmap(GLenum targ
     } else {
         gl->fGenerateMipmap(target);
     }
 }
 
 already_AddRefed<WebGLActiveInfo>
 WebGLContext::GetActiveUniform(WebGLProgram *prog, uint32_t index)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return nullptr;
 
     if (!ValidateObject("getActiveUniform: program", prog))
         return nullptr;
 
     MakeContextCurrent();
 
     GLint len = 0;
@@ -1232,17 +1232,17 @@ WebGLContext::GetActiveUniform(WebGLProg
     return retActiveInfo.forget();
 }
 
 void
 WebGLContext::GetAttachedShaders(WebGLProgram *prog,
                                  Nullable< nsTArray<WebGLShader*> > &retval)
 {
     retval.SetNull();
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObjectAllowNull("getAttachedShaders", prog))
         return;
 
     MakeContextCurrent();
 
     if (!prog) {
@@ -1253,17 +1253,17 @@ WebGLContext::GetAttachedShaders(WebGLPr
     } else {
         retval.SetValue().AppendElements(prog->AttachedShaders());
     }
 }
 
 GLint
 WebGLContext::GetAttribLocation(WebGLProgram *prog, const nsAString& name)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return -1;
 
     if (!ValidateObject("getAttribLocation: program", prog))
         return -1;
 
     if (!ValidateGLSLVariableName(name, "getAttribLocation"))
         return -1; 
 
@@ -1275,17 +1275,17 @@ WebGLContext::GetAttribLocation(WebGLPro
 
     MakeContextCurrent();
     return gl->fGetAttribLocation(progname, mappedName.get());
 }
 
 JS::Value
 WebGLContext::GetBufferParameter(GLenum target, GLenum pname)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return JS::NullValue();
 
     if (target != LOCAL_GL_ARRAY_BUFFER && target != LOCAL_GL_ELEMENT_ARRAY_BUFFER) {
         ErrorInvalidEnumInfo("getBufferParameter: target", target);
         return JS::NullValue();
     }
 
     MakeContextCurrent();
@@ -1314,17 +1314,17 @@ WebGLContext::GetBufferParameter(GLenum 
 
 JS::Value
 WebGLContext::GetFramebufferAttachmentParameter(JSContext* cx,
                                                 GLenum target,
                                                 GLenum attachment,
                                                 GLenum pname,
                                                 ErrorResult& rv)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return JS::NullValue();
 
     if (target != LOCAL_GL_FRAMEBUFFER) {
         ErrorInvalidEnumInfo("getFramebufferAttachmentParameter: target", target);
         return JS::NullValue();
     }
 
     if (attachment != LOCAL_GL_DEPTH_ATTACHMENT &&
@@ -1404,17 +1404,17 @@ WebGLContext::GetFramebufferAttachmentPa
     }
 
     return JS::NullValue();
 }
 
 JS::Value
 WebGLContext::GetRenderbufferParameter(GLenum target, GLenum pname)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return JS::NullValue();
 
     if (target != LOCAL_GL_RENDERBUFFER) {
         ErrorInvalidEnumInfo("getRenderbufferParameter: target", target);
         return JS::NullValue();
     }
 
     if (!mBoundRenderbuffer) {
@@ -1447,42 +1447,42 @@ WebGLContext::GetRenderbufferParameter(G
     }
 
     return JS::NullValue();
 }
 
 already_AddRefed<WebGLTexture>
 WebGLContext::CreateTexture()
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return nullptr;
     nsRefPtr<WebGLTexture> globj = new WebGLTexture(this);
     return globj.forget();
 }
 
 GLenum
 WebGLContext::GetError()
 {
-    if (mContextStatus == ContextStable) {
+    if (mContextStatus == ContextNotLost) {
         MakeContextCurrent();
         UpdateWebGLErrorAndClearGLError();
     } else if (!mContextLostErrorSet) {
         mWebGLError = LOCAL_GL_CONTEXT_LOST;
         mContextLostErrorSet = true;
     }
 
     GLenum err = mWebGLError;
     mWebGLError = LOCAL_GL_NO_ERROR;
     return err;
 }
 
 JS::Value
 WebGLContext::GetProgramParameter(WebGLProgram *prog, GLenum pname)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return JS::NullValue();
 
     if (!ValidateObjectAllowDeleted("getProgramParameter: program", prog))
         return JS::NullValue();
 
     GLuint progname = prog->GLName();
 
     MakeContextCurrent();
@@ -1534,17 +1534,17 @@ WebGLContext::GetProgramInfoLog(WebGLPro
         retval.SetIsVoid(true);
     else
         CopyASCIItoUTF16(s, retval);
 }
 
 void
 WebGLContext::GetProgramInfoLog(WebGLProgram *prog, nsACString& retval)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
     {
         retval.SetIsVoid(true);
         return;
     }
 
     if (!ValidateObject("getProgramInfoLog: program", prog)) {
         retval.Truncate();
         return;
@@ -1578,17 +1578,17 @@ WebGLContext::GetProgramInfoLog(WebGLPro
 // See this discussion:
 //  https://www.khronos.org/webgl/public-mailing-list/archives/1008/msg00014.html
 void WebGLContext::TexParameter_base(GLenum target, GLenum pname,
                                      GLint *intParamPtr,
                                      GLfloat *floatParamPtr)
 {
     MOZ_ASSERT(intParamPtr || floatParamPtr);
 
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     GLint intParam = intParamPtr ? *intParamPtr : GLint(*floatParamPtr);
     GLfloat floatParam = floatParamPtr ? *floatParamPtr : GLfloat(*intParamPtr);
 
     if (!ValidateTextureTargetEnum(target, "texParameter: target"))
         return;
 
@@ -1681,17 +1681,17 @@ void WebGLContext::TexParameter_base(GLe
         gl->fTexParameteri(target, pname, intParam);
     else
         gl->fTexParameterf(target, pname, floatParam);
 }
 
 JS::Value
 WebGLContext::GetTexParameter(GLenum target, GLenum pname)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return JS::NullValue();
 
     MakeContextCurrent();
 
     if (!ValidateTextureTargetEnum(target, "getTexParameter: target"))
         return JS::NullValue();
 
     if (!activeBoundTextureForTarget(target)) {
@@ -1725,17 +1725,17 @@ WebGLContext::GetTexParameter(GLenum tar
 
     return JS::NullValue();
 }
 
 JS::Value
 WebGLContext::GetUniform(JSContext* cx, WebGLProgram *prog,
                          WebGLUniformLocation *location, ErrorResult& rv)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return JS::NullValue();
 
     if (!ValidateObject("getUniform: program", prog))
         return JS::NullValue();
 
     if (!ValidateObject("getUniform: location", location))
         return JS::NullValue();
 
@@ -1857,17 +1857,17 @@ WebGLContext::GetUniform(JSContext* cx, 
 
     // Else preserving behavior, but I'm not sure this is correct per spec
     return JS::UndefinedValue();
 }
 
 already_AddRefed<WebGLUniformLocation>
 WebGLContext::GetUniformLocation(WebGLProgram *prog, const nsAString& name)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return nullptr;
 
     if (!ValidateObject("getUniformLocation: program", prog))
         return nullptr;
 
     if (!ValidateGLSLVariableName(name, "getUniformLocation"))
         return nullptr;
 
@@ -1888,17 +1888,17 @@ WebGLContext::GetUniformLocation(WebGLPr
                                        info);
     }
     return loc.forget();
 }
 
 void
 WebGLContext::Hint(GLenum target, GLenum mode)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     bool isValid = false;
 
     switch (target) {
         case LOCAL_GL_GENERATE_MIPMAP_HINT:
             isValid = true;
             break;
@@ -1912,58 +1912,58 @@ WebGLContext::Hint(GLenum target, GLenum
         return ErrorInvalidEnum("hint: invalid hint");
 
     gl->fHint(target, mode);
 }
 
 bool
 WebGLContext::IsFramebuffer(WebGLFramebuffer *fb)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return false;
 
     return ValidateObjectAllowDeleted("isFramebuffer", fb) &&
         !fb->IsDeleted() &&
         fb->HasEverBeenBound();
 }
 
 bool
 WebGLContext::IsProgram(WebGLProgram *prog)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return false;
 
     return ValidateObjectAllowDeleted("isProgram", prog) && !prog->IsDeleted();
 }
 
 bool
 WebGLContext::IsRenderbuffer(WebGLRenderbuffer *rb)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return false;
 
     return ValidateObjectAllowDeleted("isRenderBuffer", rb) &&
         !rb->IsDeleted() &&
         rb->HasEverBeenBound();
 }
 
 bool
 WebGLContext::IsShader(WebGLShader *shader)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return false;
 
     return ValidateObjectAllowDeleted("isShader", shader) &&
         !shader->IsDeleted();
 }
 
 bool
 WebGLContext::IsTexture(WebGLTexture *tex)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return false;
 
     return ValidateObjectAllowDeleted("isTexture", tex) &&
         !tex->IsDeleted() &&
         tex->HasEverBeenBound();
 }
 
 // Try to bind an attribute that is an array to location 0:
@@ -1994,17 +1994,17 @@ bool WebGLContext::BindArrayAttribToLoca
         return true;
     }
     return false;
 }
 
 void
 WebGLContext::LinkProgram(WebGLProgram *program)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObject("linkProgram", program))
         return;
 
     InvalidateBufferFetching(); // we do it early in this function
     // as some of the validation below changes program state
 
@@ -2124,17 +2124,17 @@ WebGLContext::LinkProgram(WebGLProgram *
             }
         }
     }
 }
 
 void
 WebGLContext::PixelStorei(GLenum pname, GLint param)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     switch (pname) {
         case UNPACK_FLIP_Y_WEBGL:
             mPixelStoreFlipY = (param != 0);
             break;
         case UNPACK_PREMULTIPLY_ALPHA_WEBGL:
             mPixelStorePremultiplyAlpha = (param != 0);
@@ -2165,17 +2165,17 @@ WebGLContext::PixelStorei(GLenum pname, 
 }
 
 void
 WebGLContext::ReadPixels(GLint x, GLint y, GLsizei width,
                          GLsizei height, GLenum format,
                          GLenum type, const Nullable<ArrayBufferView> &pixels,
                          ErrorResult& rv)
 {
-    if (!IsContextStable()) {
+    if (IsContextLost()) {
         return;
     }
 
     if (mCanvasElement->IsWriteOnly() && !nsContentUtils::IsCallerChrome()) {
         GenerateWarning("readPixels: Not allowed");
         return rv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     }
 
@@ -2388,17 +2388,17 @@ WebGLContext::ReadPixels(GLint x, GLint 
             }
         }            
     }
 }
 
 void
 WebGLContext::RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!mBoundRenderbuffer || !mBoundRenderbuffer->GLName())
         return ErrorInvalidOperation("renderbufferStorage called on renderbuffer 0");
 
     if (target != LOCAL_GL_RENDERBUFFER)
         return ErrorInvalidEnumInfo("renderbufferStorage: target", target);
 
@@ -2465,30 +2465,30 @@ WebGLContext::RenderbufferStorage(GLenum
     mBoundRenderbuffer->SetInternalFormatForGL(internalformatForGL);
     mBoundRenderbuffer->setDimensions(width, height);
     mBoundRenderbuffer->SetInitialized(false);
 }
 
 void
 WebGLContext::Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (width < 0 || height < 0)
         return ErrorInvalidValue("scissor: negative size");
 
     MakeContextCurrent();
     gl->fScissor(x, y, width, height);
 }
 
 void
 WebGLContext::StencilFunc(GLenum func, GLint ref, GLuint mask)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateComparisonEnum(func, "stencilFunc: func"))
         return;
 
     mStencilRefFront = ref;
     mStencilRefBack = ref;
     mStencilValueMaskFront = mask;
@@ -2496,17 +2496,17 @@ WebGLContext::StencilFunc(GLenum func, G
 
     MakeContextCurrent();
     gl->fStencilFunc(func, ref, mask);
 }
 
 void
 WebGLContext::StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateFaceEnum(face, "stencilFuncSeparate: face") ||
         !ValidateComparisonEnum(func, "stencilFuncSeparate: func"))
         return;
 
     switch (face) {
         case LOCAL_GL_FRONT_AND_BACK:
@@ -2527,32 +2527,32 @@ WebGLContext::StencilFuncSeparate(GLenum
 
     MakeContextCurrent();
     gl->fStencilFuncSeparate(face, func, ref, mask);
 }
 
 void
 WebGLContext::StencilOp(GLenum sfail, GLenum dpfail, GLenum dppass)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateStencilOpEnum(sfail, "stencilOp: sfail") ||
         !ValidateStencilOpEnum(dpfail, "stencilOp: dpfail") ||
         !ValidateStencilOpEnum(dppass, "stencilOp: dppass"))
         return;
 
     MakeContextCurrent();
     gl->fStencilOp(sfail, dpfail, dppass);
 }
 
 void
 WebGLContext::StencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateFaceEnum(face, "stencilOpSeparate: face") ||
         !ValidateStencilOpEnum(sfail, "stencilOpSeparate: sfail") ||
         !ValidateStencilOpEnum(dpfail, "stencilOpSeparate: dpfail") ||
         !ValidateStencilOpEnum(dppass, "stencilOpSeparate: dppass"))
         return;
 
@@ -2931,17 +2931,17 @@ WebGLContext::UniformMatrix4fv_base(WebG
     }
     MakeContextCurrent();
     gl->fUniformMatrix4fv(location, numElementsToUpload, false, data);
 }
 
 void
 WebGLContext::UseProgram(WebGLProgram *prog)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObjectAllowNull("useProgram", prog))
         return;
 
     MakeContextCurrent();
 
     InvalidateBufferFetching();
@@ -2954,17 +2954,17 @@ WebGLContext::UseProgram(WebGLProgram *p
     gl->fUseProgram(progname);
 
     mCurrentProgram = prog;
 }
 
 void
 WebGLContext::ValidateProgram(WebGLProgram *prog)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObject("validateProgram", prog))
         return;
 
     MakeContextCurrent();
 
 #ifdef XP_MACOSX
@@ -2977,48 +2977,48 @@ WebGLContext::ValidateProgram(WebGLProgr
 
     GLuint progname = prog->GLName();
     gl->fValidateProgram(progname);
 }
 
 already_AddRefed<WebGLFramebuffer>
 WebGLContext::CreateFramebuffer()
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return nullptr;
     nsRefPtr<WebGLFramebuffer> globj = new WebGLFramebuffer(this);
     return globj.forget();
 }
 
 already_AddRefed<WebGLRenderbuffer>
 WebGLContext::CreateRenderbuffer()
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return nullptr;
     nsRefPtr<WebGLRenderbuffer> globj = new WebGLRenderbuffer(this);
     return globj.forget();
 }
 
 void
 WebGLContext::Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (width < 0 || height < 0)
         return ErrorInvalidValue("viewport: negative size");
 
     MakeContextCurrent();
     gl->fViewport(x, y, width, height);
 }
 
 void
 WebGLContext::CompileShader(WebGLShader *shader)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObject("compileShader", shader))
         return;
 
     GLuint shadername = shader->GLName();
 
     shader->SetCompileStatus(false);
@@ -3278,17 +3278,17 @@ WebGLContext::CompileShader(WebGLShader 
     }
 }
 
 void
 WebGLContext::CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
                                    GLsizei width, GLsizei height, GLint border,
                                    const ArrayBufferView& view)
 {
-    if (!IsContextStable()) {
+    if (IsContextLost()) {
         return;
     }
 
     if (!ValidateTexImage2DTarget(target, width, height, "compressedTexImage2D")) {
         return;
     }
 
     WebGLTexture *tex = activeBoundTextureForTarget(target);
@@ -3318,17 +3318,17 @@ WebGLContext::CompressedTexImage2D(GLenu
     ReattachTextureToAnyFramebufferToWorkAroundBugs(tex, level);
 }
 
 void
 WebGLContext::CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset,
                                       GLint yoffset, GLsizei width, GLsizei height,
                                       GLenum format, const ArrayBufferView& view)
 {
-    if (!IsContextStable()) {
+    if (IsContextLost()) {
         return;
     }
 
     switch (target) {
         case LOCAL_GL_TEXTURE_2D:
         case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X:
         case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
         case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
@@ -3416,17 +3416,17 @@ WebGLContext::CompressedTexSubImage2D(GL
     gl->fCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, byteLength, view.Data());
 
     return;
 }
 
 JS::Value
 WebGLContext::GetShaderParameter(WebGLShader *shader, GLenum pname)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return JS::NullValue();
 
     if (!ValidateObject("getShaderParameter: shader", shader))
         return JS::NullValue();
 
     GLuint shadername = shader->GLName();
 
     MakeContextCurrent();
@@ -3465,17 +3465,17 @@ WebGLContext::GetShaderInfoLog(WebGLShad
         retval.SetIsVoid(true);
     else
         CopyASCIItoUTF16(s, retval);
 }
 
 void
 WebGLContext::GetShaderInfoLog(WebGLShader *shader, nsACString& retval)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
     {
         retval.SetIsVoid(true);
         return;
     }
 
     if (!ValidateObject("getShaderInfoLog: shader", shader))
         return;
 
@@ -3502,17 +3502,17 @@ WebGLContext::GetShaderInfoLog(WebGLShad
     retval.SetCapacity(k);
     gl->fGetShaderInfoLog(shadername, k, &k, (char*) retval.BeginWriting());
     retval.SetLength(k);
 }
 
 already_AddRefed<WebGLShaderPrecisionFormat>
 WebGLContext::GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return nullptr;
 
     switch (shadertype) {
         case LOCAL_GL_FRAGMENT_SHADER:
         case LOCAL_GL_VERTEX_SHADER:
             break;
         default:
             ErrorInvalidEnumInfo("getShaderPrecisionFormat: shadertype", shadertype);
@@ -3550,32 +3550,32 @@ WebGLContext::GetShaderPrecisionFormat(G
     nsRefPtr<WebGLShaderPrecisionFormat> retShaderPrecisionFormat
         = new WebGLShaderPrecisionFormat(this, range[0], range[1], precision);
     return retShaderPrecisionFormat.forget();
 }
 
 void
 WebGLContext::GetShaderSource(WebGLShader *shader, nsAString& retval)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
     {
         retval.SetIsVoid(true);
         return;
     }
 
     if (!ValidateObject("getShaderSource: shader", shader))
         return;
 
     retval.Assign(shader->Source());
 }
 
 void
 WebGLContext::ShaderSource(WebGLShader *shader, const nsAString& source)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObject("shaderSource: shader", shader))
         return;
 
     // We're storing an actual instance of StripComments because, if we don't, the 
     // cleanSource nsAString instance will be destroyed before the reference is
     // actually used.
@@ -3771,32 +3771,32 @@ WebGLContext::TexImage2D_base(GLenum tar
 }
 
 void
 WebGLContext::TexImage2D(GLenum target, GLint level,
                          GLenum internalformat, GLsizei width,
                          GLsizei height, GLint border, GLenum format,
                          GLenum type, const Nullable<ArrayBufferView> &pixels, ErrorResult& rv)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     return TexImage2D_base(target, level, internalformat, width, height, 0, border, format, type,
                            pixels.IsNull() ? 0 : pixels.Value().Data(),
                            pixels.IsNull() ? 0 : pixels.Value().Length(),
                            pixels.IsNull() ? -1 : (int)JS_GetArrayBufferViewType(pixels.Value().Obj()),
                            WebGLTexelConversions::Auto, false);
 }
 
 void
 WebGLContext::TexImage2D(GLenum target, GLint level,
                          GLenum internalformat, GLenum format,
                          GLenum type, ImageData* pixels, ErrorResult& rv)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!pixels) {
         // Spec says to generate an INVALID_VALUE error
         return ErrorInvalidValue("texImage2D: null ImageData");
     }
     
     Uint8ClampedArray arr(pixels->GetDataObject());
@@ -3922,17 +3922,17 @@ WebGLContext::TexSubImage2D_base(GLenum 
 void
 WebGLContext::TexSubImage2D(GLenum target, GLint level,
                             GLint xoffset, GLint yoffset,
                             GLsizei width, GLsizei height,
                             GLenum format, GLenum type,
                             const Nullable<ArrayBufferView> &pixels,
                             ErrorResult& rv)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (pixels.IsNull())
         return ErrorInvalidValue("texSubImage2D: pixels must not be null!");
 
     return TexSubImage2D_base(target, level, xoffset, yoffset,
                               width, height, 0, format, type,
                               pixels.Value().Data(), pixels.Value().Length(),
@@ -3941,17 +3941,17 @@ WebGLContext::TexSubImage2D(GLenum targe
 }
 
 void
 WebGLContext::TexSubImage2D(GLenum target, GLint level,
                             GLint xoffset, GLint yoffset,
                             GLenum format, GLenum type, ImageData* pixels,
                             ErrorResult& rv)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!pixels)
         return ErrorInvalidValue("texSubImage2D: pixels must not be null!");
 
     Uint8ClampedArray arr(pixels->GetDataObject());
     return TexSubImage2D_base(target, level, xoffset, yoffset,
                               pixels->Width(), pixels->Height(),
@@ -3959,28 +3959,28 @@ WebGLContext::TexSubImage2D(GLenum targe
                               arr.Data(), arr.Length(),
                               -1,
                               WebGLTexelConversions::RGBA8, false);
 }
 
 bool
 WebGLContext::LoseContext()
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return false;
 
     ForceLoseContext();
 
     return true;
 }
 
 bool
 WebGLContext::RestoreContext()
 {
-    if (IsContextStable() || !mAllowRestore) {
+    if (!IsContextLost() || !mAllowRestore) {
         return false;
     }
 
     ForceRestoreContext();
 
     return true;
 }
 
--- a/content/canvas/src/WebGLContextState.cpp
+++ b/content/canvas/src/WebGLContextState.cpp
@@ -14,17 +14,17 @@
 #include "WebGLVertexArray.h"
 
 using namespace mozilla;
 using namespace dom;
 
 void
 WebGLContext::Disable(GLenum cap)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateCapabilityEnum(cap, "disable"))
         return;
 
     realGLboolean* trackingSlot = GetStateTrackingSlot(cap);
 
     if (trackingSlot)
@@ -34,17 +34,17 @@ WebGLContext::Disable(GLenum cap)
 
     MakeContextCurrent();
     gl->fDisable(cap);
 }
 
 void
 WebGLContext::Enable(GLenum cap)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateCapabilityEnum(cap, "enable"))
         return;
 
     realGLboolean* trackingSlot = GetStateTrackingSlot(cap);
 
     if (trackingSlot)
@@ -66,17 +66,17 @@ StringValue(JSContext* cx, const char* c
     }
 
     return JS::StringValue(str);
 }
 
 JS::Value
 WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return JS::NullValue();
 
     MakeContextCurrent();
 
     if (MinCapabilityMode()) {
         switch(pname) {
             //
             // Single-value params
@@ -481,17 +481,17 @@ WebGLContext::GetParameter(JSContext* cx
     }
 
     return JS::NullValue();
 }
 
 JS::Value
 WebGLContext::GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return JS::NullValue();
 
     MakeContextCurrent();
 
     switch (pname) {
         case LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
         {
             if (index >= mGLMaxTransformFeedbackSeparateAttribs) {
@@ -507,17 +507,17 @@ WebGLContext::GetParameterIndexed(JSCont
 
     ErrorInvalidEnumInfo("getParameterIndexed: parameter", pname);
     return JS::NullValue();
 }
 
 bool
 WebGLContext::IsEnabled(GLenum cap)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return false;
 
     if (!ValidateCapabilityEnum(cap, "isEnabled"))
         return false;
 
     MakeContextCurrent();
     return gl->fIsEnabled(cap);
 }
--- a/content/canvas/src/WebGLContextValidate.cpp
+++ b/content/canvas/src/WebGLContextValidate.cpp
@@ -649,31 +649,31 @@ WebGLContext::ValidateSamplerUniformSett
     ErrorInvalidValue("%s: this uniform location is a sampler, but %d is not a valid texture unit",
                       info, value);
     return false;
 }
 
 bool
 WebGLContext::ValidateAttribArraySetter(const char* name, uint32_t cnt, uint32_t arrayLength)
 {
-    if (!IsContextStable()) {
+    if (IsContextLost()) {
         return false;
     }
     if (arrayLength < cnt) {
         ErrorInvalidOperation("%s: array must be >= %d elements", name, cnt);
         return false;
     }
     return true;
 }
 
 bool
 WebGLContext::ValidateUniformArraySetter(const char* name, uint32_t expectedElemSize, WebGLUniformLocation *location_object,
                                          GLint& location, uint32_t& numElementsToUpload, uint32_t arrayLength)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return false;
     if (!ValidateUniformLocation(name, location_object))
         return false;
     location = location_object->Location();
     uint32_t uniformElemSize = location_object->ElementSize();
     if (expectedElemSize != uniformElemSize) {
         ErrorInvalidOperation("%s: this function expected a uniform of element size %d,"
                               " got a uniform of element size %d", name,
@@ -706,17 +706,17 @@ WebGLContext::ValidateUniformArraySetter
 }
 
 bool
 WebGLContext::ValidateUniformMatrixArraySetter(const char* name, int dim, WebGLUniformLocation *location_object,
                                               GLint& location, uint32_t& numElementsToUpload, uint32_t arrayLength,
                                               WebGLboolean aTranspose)
 {
     uint32_t expectedElemSize = (dim)*(dim);
-    if (!IsContextStable())
+    if (IsContextLost())
         return false;
     if (!ValidateUniformLocation(name, location_object))
         return false;
     location = location_object->Location();
     uint32_t uniformElemSize = location_object->ElementSize();
     if (expectedElemSize != uniformElemSize) {
         ErrorInvalidOperation("%s: this function expected a uniform of element size %d,"
                               " got a uniform of element size %d", name,
@@ -751,17 +751,17 @@ WebGLContext::ValidateUniformMatrixArray
     numElementsToUpload =
         std::min(info.arraySize, arrayLength / (expectedElemSize));
     return true;
 }
 
 bool
 WebGLContext::ValidateUniformSetter(const char* name, WebGLUniformLocation *location_object, GLint& location)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return false;
     if (!ValidateUniformLocation(name, location_object))
         return false;
     location = location_object->Location();
     return true;
 }
 
 bool WebGLContext::ValidateAttribIndex(GLuint index, const char *info)
--- a/content/canvas/src/WebGLContextVertexArray.cpp
+++ b/content/canvas/src/WebGLContextVertexArray.cpp
@@ -8,17 +8,17 @@
 #include "WebGLVertexAttribData.h"
 #include "WebGLVertexArray.h"
 
 using namespace mozilla;
 
 void
 WebGLContext::BindVertexArray(WebGLVertexArray *array)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateObjectAllowDeletedOrNull("bindVertexArrayObject", array))
         return;
 
     if (array && array->IsDeleted()) {
         /* http://www.khronos.org/registry/gles/extensions/OES/OES_vertex_array_object.txt
          * BindVertexArrayOES fails and an INVALID_OPERATION error is
@@ -43,33 +43,33 @@ WebGLContext::BindVertexArray(WebGLVerte
         gl->fBindVertexArray(0);
         mBoundVertexArray = mDefaultVertexArray;
     }
 }
 
 already_AddRefed<WebGLVertexArray>
 WebGLContext::CreateVertexArray()
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return nullptr;
 
     nsRefPtr<WebGLVertexArray> globj = new WebGLVertexArray(this);
 
     MakeContextCurrent();
     gl->fGenVertexArrays(1, &globj->mGLName);
 
     mVertexArrays.insertBack(globj);
 
     return globj.forget();
 }
 
 void
 WebGLContext::DeleteVertexArray(WebGLVertexArray *array)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (array == nullptr)
         return;
 
     if (array->IsDeleted())
         return;
 
@@ -77,17 +77,17 @@ WebGLContext::DeleteVertexArray(WebGLVer
         BindVertexArray(static_cast<WebGLVertexArray*>(nullptr));
 
     array->RequestDelete();
 }
 
 bool
 WebGLContext::IsVertexArray(WebGLVertexArray *array)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return false;
 
     if (!array)
         return false;
 
     return ValidateObjectAllowDeleted("isVertexArray", array) &&
            !array->IsDeleted() &&
            array->HasEverBeenBound();
--- a/content/canvas/src/WebGLContextVertices.cpp
+++ b/content/canvas/src/WebGLContextVertices.cpp
@@ -18,17 +18,17 @@ using namespace mozilla;
 using namespace dom;
 
 // For a Tegra workaround.
 static const int MAX_DRAW_CALLS_SINCE_FLUSH = 100;
 
 void
 WebGLContext::VertexAttrib1f(GLuint index, GLfloat x0)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     MakeContextCurrent();
 
     if (index) {
         gl->fVertexAttrib1f(index, x0);
     } else {
         mVertexAttrib0Vector[0] = x0;
@@ -38,17 +38,17 @@ WebGLContext::VertexAttrib1f(GLuint inde
         if (gl->IsGLES2())
             gl->fVertexAttrib1f(index, x0);
     }
 }
 
 void
 WebGLContext::VertexAttrib2f(GLuint index, GLfloat x0, GLfloat x1)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     MakeContextCurrent();
 
     if (index) {
         gl->fVertexAttrib2f(index, x0, x1);
     } else {
         mVertexAttrib0Vector[0] = x0;
@@ -58,17 +58,17 @@ WebGLContext::VertexAttrib2f(GLuint inde
         if (gl->IsGLES2())
             gl->fVertexAttrib2f(index, x0, x1);
     }
 }
 
 void
 WebGLContext::VertexAttrib3f(GLuint index, GLfloat x0, GLfloat x1, GLfloat x2)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     MakeContextCurrent();
 
     if (index) {
         gl->fVertexAttrib3f(index, x0, x1, x2);
     } else {
         mVertexAttrib0Vector[0] = x0;
@@ -79,17 +79,17 @@ WebGLContext::VertexAttrib3f(GLuint inde
             gl->fVertexAttrib3f(index, x0, x1, x2);
     }
 }
 
 void
 WebGLContext::VertexAttrib4f(GLuint index, GLfloat x0, GLfloat x1,
                              GLfloat x2, GLfloat x3)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     MakeContextCurrent();
 
     if (index) {
         gl->fVertexAttrib4f(index, x0, x1, x2, x3);
     } else {
         mVertexAttrib0Vector[0] = x0;
@@ -180,33 +180,33 @@ WebGLContext::VertexAttrib4fv_base(GLuin
         if (gl->IsGLES2())
             gl->fVertexAttrib4fv(idx, ptr);
     }
 }
 
 void
 WebGLContext::EnableVertexAttribArray(GLuint index)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateAttribIndex(index, "enableVertexAttribArray"))
         return;
 
     MakeContextCurrent();
     InvalidateBufferFetching();
 
     gl->fEnableVertexAttribArray(index);
     mBoundVertexArray->mAttribBuffers[index].enabled = true;
 }
 
 void
 WebGLContext::DisableVertexAttribArray(GLuint index)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateAttribIndex(index, "disableVertexAttribArray"))
         return;
 
     MakeContextCurrent();
     InvalidateBufferFetching();
 
@@ -216,17 +216,17 @@ WebGLContext::DisableVertexAttribArray(G
     mBoundVertexArray->mAttribBuffers[index].enabled = false;
 }
 
 
 JS::Value
 WebGLContext::GetVertexAttrib(JSContext* cx, GLuint index, GLenum pname,
                               ErrorResult& rv)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return JS::NullValue();
 
     if (!mBoundVertexArray->EnsureAttribIndex(index, "getVertexAttrib"))
         return JS::NullValue();
 
     MakeContextCurrent();
 
     switch (pname) {
@@ -304,17 +304,17 @@ WebGLContext::GetVertexAttrib(JSContext*
     ErrorInvalidEnumInfo("getVertexAttrib: parameter", pname);
 
     return JS::NullValue();
 }
 
 WebGLsizeiptr
 WebGLContext::GetVertexAttribOffset(GLuint index, GLenum pname)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return 0;
 
     if (!ValidateAttribIndex(index, "getVertexAttribOffset"))
         return 0;
 
     if (pname != LOCAL_GL_VERTEX_ATTRIB_ARRAY_POINTER) {
         ErrorInvalidEnum("getVertexAttribOffset: bad parameter");
         return 0;
@@ -323,17 +323,17 @@ WebGLContext::GetVertexAttribOffset(GLui
     return mBoundVertexArray->mAttribBuffers[index].byteOffset;
 }
 
 void
 WebGLContext::VertexAttribPointer(GLuint index, GLint size, GLenum type,
                                   WebGLboolean normalized, GLsizei stride,
                                   WebGLintptr byteOffset)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (mBoundArrayBuffer == nullptr)
         return ErrorInvalidOperation("vertexAttribPointer: must have valid GL_ARRAY_BUFFER binding");
 
     GLsizei requiredAlignment = 1;
     switch (type) {
         case LOCAL_GL_BYTE:
@@ -400,17 +400,17 @@ WebGLContext::VertexAttribPointer(GLuint
     gl->fVertexAttribPointer(index, size, type, normalized,
                              stride,
                              reinterpret_cast<void*>(byteOffset));
 }
 
 void
 WebGLContext::VertexAttribDivisor(GLuint index, GLuint divisor)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if ( !mBoundVertexArray->EnsureAttribIndex(index, "vertexAttribDivisor") ) {
         return;
     }
 
     WebGLVertexAttribData& vd = mBoundVertexArray->mAttribBuffers[index];
     vd.divisor = divisor;
@@ -495,17 +495,17 @@ bool WebGLContext::DrawArrays_check(GLin
     BindFakeBlackTextures();
 
     return true;
 }
 
 void
 WebGLContext::DrawArrays(GLenum mode, GLint first, GLsizei count)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateDrawModeEnum(mode, "drawArrays: mode"))
         return;
 
     if (!DrawArrays_check(first, count, 1, "drawArrays"))
         return;
 
@@ -513,17 +513,17 @@ WebGLContext::DrawArrays(GLenum mode, GL
     gl->fDrawArrays(mode, first, count);
 
     Draw_cleanup();
 }
 
 void
 WebGLContext::DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateDrawModeEnum(mode, "drawArraysInstanced: mode"))
         return;
 
     if (!DrawArrays_check(first, count, primcount, "drawArraysInstanced"))
         return;
 
@@ -660,17 +660,17 @@ WebGLContext::DrawElements_check(GLsizei
 
     return true;
 }
 
 void
 WebGLContext::DrawElements(GLenum mode, GLsizei count, GLenum type,
                                WebGLintptr byteOffset)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateDrawModeEnum(mode, "drawElements: mode"))
         return;
 
     if (!DrawElements_check(count, type, byteOffset, 1, "drawElements"))
         return;
 
@@ -679,17 +679,17 @@ WebGLContext::DrawElements(GLenum mode, 
 
     Draw_cleanup();
 }
 
 void
 WebGLContext::DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
                                         WebGLintptr byteOffset, GLsizei primcount)
 {
-    if (!IsContextStable())
+    if (IsContextLost())
         return;
 
     if (!ValidateDrawModeEnum(mode, "drawElementsInstanced: mode"))
         return;
 
     if (!DrawElements_check(count, type, byteOffset, primcount, "drawElementsInstanced"))
         return;
 
--- a/content/canvas/src/WebGLTypes.h
+++ b/content/canvas/src/WebGLTypes.h
@@ -1,18 +1,21 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef WEBGLTYPES_H_
 #define WEBGLTYPES_H_
 
-// Manual reflection of WebIDL typedefs that are different from the
-// corresponding OpenGL typedefs.
+// Most WebIDL typedefs are identical to their OpenGL counterparts.
+#include "GLTypes.h"
+
+// Manual reflection of WebIDL typedefs that are different from their
+// OpenGL counterparts.
 typedef int64_t WebGLsizeiptr;
 typedef int64_t WebGLintptr;
 typedef bool WebGLboolean;
 
 namespace mozilla {
 
 enum FakeBlackStatus { DoNotNeedFakeBlack, DoNeedFakeBlack, DontKnowIfNeedFakeBlack };