[SCM] WebKit Debian packaging branch, debian/experimental, updated. debian/1.3.8-1-1049-g2e11a8e

enne at google.com enne at google.com
Fri Jan 21 15:08:37 UTC 2011


The following commit has been merged in the debian/experimental branch:
commit a3de32ec5335fc8c61e955784b882f2d1d000788
Author: enne at google.com <enne at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jan 7 21:41:37 2011 +0000

    2011-01-05  Adrienne Walker  <enne at google.com>
    
            Reviewed by Kenneth Russell.
    
            Add tests for WebGL's lost context events.
            https://bugs.webkit.org/show_bug.cgi?id=51492
    
            * fast/canvas/webgl/context-lost-expected.txt: Added.
            * fast/canvas/webgl/context-lost-restored-expected.txt: Added.
            * fast/canvas/webgl/context-lost-restored.html: Added.
            * fast/canvas/webgl/context-lost.html: Added.
    2011-01-05  Adrienne Walker  <enne at google.com>
    
            Reviewed by Kenneth Russell.
    
            Add WEBKIT_lose_context WebGL extension.
            https://bugs.webkit.org/show_bug.cgi?id=51492
    
            Tests: fast/canvas/webgl/context-lost-restored.html
                   fast/canvas/webgl/context-lost.html
    
            * CMakeLists.txt:
            * DerivedSources.make:
            * GNUmakefile.am:
            * WebCore.gypi:
            * WebCore.pri:
            * WebCore.pro:
            * WebCore.xcodeproj/project.pbxproj:
            * bindings/js/JSWebGLRenderingContextCustom.cpp:
            (WebCore::toJS):
            (WebCore::JSWebGLRenderingContext::getSupportedExtensions):
            * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
            (WebCore::toV8Object):
            (WebCore::V8WebGLRenderingContext::getSupportedExtensionsCallback):
            * html/canvas/WebGLExtension.h:
            * html/canvas/WebGLRenderingContext.cpp:
            (WebCore::WebGLRenderingContext::WebGLRenderingContextRestoreTimer::fired):
            (WebCore::WebGLRenderingContext::getExtension):
            (WebCore::WebGLRenderingContext::getSupportedExtensions):
            (WebCore::WebGLRenderingContext::forceLostContext):
            (WebCore::WebGLRenderingContext::onLostContext):
            (WebCore::WebGLRenderingContext::getNumberOfExtensions):
            (WebCore::WebGLRenderingContext::getExtensionNumber):
            * html/canvas/WebGLRenderingContext.h:
            * html/canvas/WebKitLoseContext.cpp: Copied from WebCore/html/canvas/WebGLExtension.h.
            (WebCore::WebKitLoseContext::WebKitLoseContext):
            (WebCore::WebKitLoseContext::~WebKitLoseContext):
            (WebCore::WebKitLoseContext::getName):
            (WebCore::WebKitLoseContext::create):
            (WebCore::WebKitLoseContext::loseContext):
            * html/canvas/WebKitLoseContext.h: Copied from WebCore/html/canvas/WebGLExtension.h.
            * html/canvas/WebKitLoseContext.idl: Copied from WebCore/html/canvas/WebGLExtension.h.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75271 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 96d3d00..b1f7170 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2011-01-05  Adrienne Walker  <enne at google.com>
+
+        Reviewed by Kenneth Russell.
+
+        Add tests for WebGL's lost context events.
+        https://bugs.webkit.org/show_bug.cgi?id=51492
+
+        * fast/canvas/webgl/context-lost-expected.txt: Added.
+        * fast/canvas/webgl/context-lost-restored-expected.txt: Added.
+        * fast/canvas/webgl/context-lost-restored.html: Added.
+        * fast/canvas/webgl/context-lost.html: Added.
+
 2011-01-07  Stephen White  <senorblanco at chromium.org>
 
         Unreviewed; new test baselines and updated chromium expectations.
diff --git a/LayoutTests/fast/canvas/webgl/context-lost-expected.txt b/LayoutTests/fast/canvas/webgl/context-lost-expected.txt
new file mode 100644
index 0000000..6513e68
--- /dev/null
+++ b/LayoutTests/fast/canvas/webgl/context-lost-expected.txt
@@ -0,0 +1,185 @@
+Tests behavior under a lost context
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Test valid context
+PASS gl.isContextLost() is false
+PASS gl.getError() is gl.NO_ERROR
+PASS gl.enable(gl.BLEND) was expected value: NO_ERROR.
+PASS gl.isBuffer(buffer) is true
+PASS gl.isEnabled(gl.BLEND) is true
+PASS gl.isFramebuffer(framebuffer) is true
+PASS gl.isProgram(program) is true
+PASS gl.isRenderbuffer(renderbuffer) is true
+PASS gl.isShader(shader) is true
+PASS gl.isTexture(texture) is true
+
+Lose context
+PASS extension.loseContext() was expected value: NO_ERROR.
+
+Test lost context
+PASS gl.isContextLost() is true
+PASS gl.getError() is gl.CONTEXT_LOST_WEBGL
+PASS gl.getError() is gl.NO_ERROR
+PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) is gl.FRAMEBUFFER_UNSUPPORTED
+PASS gl.getAttribLocation(program, 'u_modelViewProjMatrix') is -1
+PASS gl.getVertexAttribOffset(0, gl.VERTEX_ATTRIB_ARRAY_POINTER) is 0
+PASS extension.loseContext() was expected value: INVALID_OPERATION.
+PASS gl.activeTexture(gl.TEXTURE0) was expected value: NO_ERROR.
+PASS gl.attachShader(program, shader) was expected value: NO_ERROR.
+PASS gl.bindBuffer(gl.ARRAY_BUFFER, buffer) was expected value: NO_ERROR.
+PASS gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer) was expected value: NO_ERROR.
+PASS gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer) was expected value: NO_ERROR.
+PASS gl.bindTexture(gl.TEXTURE_2D, texture) was expected value: NO_ERROR.
+PASS gl.blendColor(1.0, 1.0, 1.0, 1.0) was expected value: NO_ERROR.
+PASS gl.blendEquation(gl.FUNC_ADD) was expected value: NO_ERROR.
+PASS gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_ADD) was expected value: NO_ERROR.
+PASS gl.blendFunc(gl.ONE) was expected value: NO_ERROR.
+PASS gl.blendFuncSeparate(gl.ONE, gl.ONE) was expected value: NO_ERROR.
+PASS gl.bufferData(gl.ARRAY_BUFFER, 0, gl.STATIC_DRAW) was expected value: NO_ERROR.
+PASS gl.bufferData(gl.ARRAY_BUFFER, arrayBufferView, gl.STATIC_DRAW) was expected value: NO_ERROR.
+PASS gl.bufferData(gl.ARRAY_BUFFER, arrayBuffer, gl.STATIC_DRAW) was expected value: NO_ERROR.
+PASS gl.bufferSubData(gl.ARRAY_BUFFRE, 0, arrayBufferView) was expected value: NO_ERROR.
+PASS gl.bufferSubData(gl.ARRAY_BUFFRE, 0, arrayBuffer) was expected value: NO_ERROR.
+PASS gl.clear(gl.COLOR_BUFFER_BIT) was expected value: NO_ERROR.
+PASS gl.clearColor(1, 1, 1, 1) was expected value: NO_ERROR.
+PASS gl.clearDepth(1) was expected value: NO_ERROR.
+PASS gl.clearStencil(0) was expected value: NO_ERROR.
+PASS gl.colorMask(1, 1, 1, 1) was expected value: NO_ERROR.
+PASS gl.compileShader(shader) was expected value: NO_ERROR.
+PASS gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, 0, 0, 0) was expected value: NO_ERROR.
+PASS gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, 0, 0) was expected value: NO_ERROR.
+PASS gl.cullFace(gl.FRONT) was expected value: NO_ERROR.
+PASS gl.deleteBuffer(buffer) was expected value: NO_ERROR.
+PASS gl.deleteFramebuffer(framebuffer) was expected value: NO_ERROR.
+PASS gl.deleteProgram(program) was expected value: NO_ERROR.
+PASS gl.deleteRenderbuffer(renderbuffer) was expected value: NO_ERROR.
+PASS gl.deleteShader(shader) was expected value: NO_ERROR.
+PASS gl.deleteTexture(texture) was expected value: NO_ERROR.
+PASS gl.depthFunc(gl.NEVER) was expected value: NO_ERROR.
+PASS gl.depthMask(0) was expected value: NO_ERROR.
+PASS gl.depthRange(0, 1) was expected value: NO_ERROR.
+PASS gl.detachShader(program, shader) was expected value: NO_ERROR.
+PASS gl.disable(gl.BLEND) was expected value: NO_ERROR.
+PASS gl.disableVertexAttribArray(0) was expected value: NO_ERROR.
+PASS gl.drawArrays(gl.POINTS, 0, 0) was expected value: NO_ERROR.
+PASS gl.drawElements(gl.POINTS, 0, gl.UNSIGNED_SHORT, 0) was expected value: NO_ERROR.
+PASS gl.enable(gl.BLEND) was expected value: NO_ERROR.
+PASS gl.enableVertexAttribArray(0) was expected value: NO_ERROR.
+PASS gl.finish() was expected value: NO_ERROR.
+PASS gl.flush() was expected value: NO_ERROR.
+PASS gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, renderbuffer) was expected value: NO_ERROR.
+PASS gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0) was expected value: NO_ERROR.
+PASS gl.frontFace(gl.CW) was expected value: NO_ERROR.
+PASS gl.generateMipmap(gl.TEXTURE_2D) was expected value: NO_ERROR.
+PASS gl.hint(gl.GENERATE_MIPMAP_HINT, gl.FASTEST) was expected value: NO_ERROR.
+PASS gl.lineWidth(0) was expected value: NO_ERROR.
+PASS gl.linkProgram(program) was expected value: NO_ERROR.
+PASS gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0) was expected value: NO_ERROR.
+PASS gl.polygonOffset(0, 0) was expected value: NO_ERROR.
+PASS gl.readPixels(0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, arrayBufferView) was expected value: NO_ERROR.
+PASS gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 0, 0) was expected value: NO_ERROR.
+PASS gl.sampleCoverage(0, 0) was expected value: NO_ERROR.
+PASS gl.scissor(0, 0, 0, 0) was expected value: NO_ERROR.
+PASS gl.shaderSource(shader, '') was expected value: NO_ERROR.
+PASS gl.stencilFunc(gl.NEVER, 0, 0) was expected value: NO_ERROR.
+PASS gl.stencilFuncSeparate(gl.FRONT, gl.NEVER, 0, 0) was expected value: NO_ERROR.
+PASS gl.stencilMask(0) was expected value: NO_ERROR.
+PASS gl.stencilMaskSeparate(gl.FRONT, 0) was expected value: NO_ERROR.
+PASS gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP) was expected value: NO_ERROR.
+PASS gl.stencilOpSeparate(gl.FRONT, gl.KEEP, gl.KEEP, gl.KEEP) was expected value: NO_ERROR.
+PASS gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, arrayBufferView) was expected value: NO_ERROR.
+PASS gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, imageData) was expected value: NO_ERROR.
+PASS gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image) was expected value: NO_ERROR.
+PASS gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas) was expected value: NO_ERROR.
+PASS gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, video) was expected value: NO_ERROR.
+PASS gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST) was expected value: NO_ERROR.
+PASS gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST) was expected value: NO_ERROR.
+PASS gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, arrayBufferView) was expected value: NO_ERROR.
+PASS gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, imageData) was expected value: NO_ERROR.
+PASS gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, image) was expected value: NO_ERROR.
+PASS gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, canvas) was expected value: NO_ERROR.
+PASS gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, video) was expected value: NO_ERROR.
+PASS gl.uniform1f(uniformLocation, 0) was expected value: NO_ERROR.
+PASS gl.uniform1fv(uniformLocation, float32array) was expected value: NO_ERROR.
+PASS gl.uniform1fv(uniformLocation, [0]) was expected value: NO_ERROR.
+PASS gl.uniform1i(uniformLocation, 0) was expected value: NO_ERROR.
+PASS gl.uniform1iv(uniformLocation, int32array) was expected value: NO_ERROR.
+PASS gl.uniform1iv(uniformLocation, [0]) was expected value: NO_ERROR.
+PASS gl.uniform2f(uniformLocation, 0, 0) was expected value: NO_ERROR.
+PASS gl.uniform2fv(uniformLocation, float32array) was expected value: NO_ERROR.
+PASS gl.uniform2fv(uniformLocation, [0, 0]) was expected value: NO_ERROR.
+PASS gl.uniform2i(uniformLocation, 0, 0) was expected value: NO_ERROR.
+PASS gl.uniform2iv(uniformLocation, int32array) was expected value: NO_ERROR.
+PASS gl.uniform2iv(uniformLocation, [0, 0]) was expected value: NO_ERROR.
+PASS gl.uniform3f(uniformLocation, 0, 0, 0) was expected value: NO_ERROR.
+PASS gl.uniform3fv(uniformLocation, float32array) was expected value: NO_ERROR.
+PASS gl.uniform3fv(uniformLocation, [0, 0, 0]) was expected value: NO_ERROR.
+PASS gl.uniform3i(uniformLocation, 0, 0, 0) was expected value: NO_ERROR.
+PASS gl.uniform3iv(uniformLocation, int32array) was expected value: NO_ERROR.
+PASS gl.uniform3iv(uniformLocation, [0, 0, 0]) was expected value: NO_ERROR.
+PASS gl.uniform4f(uniformLocation, 0, 0, 0, 0) was expected value: NO_ERROR.
+PASS gl.uniform4fv(uniformLocation, float32array) was expected value: NO_ERROR.
+PASS gl.uniform4fv(uniformLocation, [0, 0, 0, 0]) was expected value: NO_ERROR.
+PASS gl.uniform4i(uniformLocation, 0, 0, 0, 0) was expected value: NO_ERROR.
+PASS gl.uniform4iv(uniformLocation, int32array) was expected value: NO_ERROR.
+PASS gl.uniform4iv(uniformLocation, [0, 0, 0, 0]) was expected value: NO_ERROR.
+PASS gl.uniformMatrix2fv(uniformLocation, false, float32array) was expected value: NO_ERROR.
+PASS gl.uniformMatrix2fv(uniformLocation, false, [0, 0, 0, 0]) was expected value: NO_ERROR.
+PASS gl.uniformMatrix3fv(uniformLocation, false, float32array) was expected value: NO_ERROR.
+PASS gl.uniformMatrix3fv(uniformLocation, false, [0, 0, 0, 0, 0, 0, 0, 0, 0]) was expected value: NO_ERROR.
+PASS gl.uniformMatrix4fv(uniformLocation, false, float32array) was expected value: NO_ERROR.
+PASS gl.uniformMatrix4fv(uniformLocation, false, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) was expected value: NO_ERROR.
+PASS gl.useProgram(program) was expected value: NO_ERROR.
+PASS gl.validateProgram(program) was expected value: NO_ERROR.
+PASS gl.vertexAttrib1f(0, 0) was expected value: NO_ERROR.
+PASS gl.vertexAttrib1fv(0, float32array) was expected value: NO_ERROR.
+PASS gl.vertexAttrib1fv(0, [0]) was expected value: NO_ERROR.
+PASS gl.vertexAttrib2f(0, 0, 0) was expected value: NO_ERROR.
+PASS gl.vertexAttrib2fv(0, float32array) was expected value: NO_ERROR.
+PASS gl.vertexAttrib2fv(0, [0, 0]) was expected value: NO_ERROR.
+PASS gl.vertexAttrib3f(0, 0, 0, 0) was expected value: NO_ERROR.
+PASS gl.vertexAttrib3fv(0, float32array) was expected value: NO_ERROR.
+PASS gl.vertexAttrib3fv(0, [0, 0, 0]) was expected value: NO_ERROR.
+PASS gl.vertexAttrib4f(0, 0, 0, 0, 0) was expected value: NO_ERROR.
+PASS gl.vertexAttrib4fv(0, float32array) was expected value: NO_ERROR.
+PASS gl.vertexAttrib4fv(0, [0, 0, 0, 0]) was expected value: NO_ERROR.
+PASS gl.vertexAttribPointer(0, 0, gl.FLOAT, false, 0, 0) was expected value: NO_ERROR.
+PASS gl.viewport(0, 0, 0, 0) was expected value: NO_ERROR.
+PASS gl.createBuffer() is null
+PASS gl.createFramebuffer() is null
+PASS gl.createProgram() is null
+PASS gl.createRenderbuffer() is null
+PASS gl.createShader(gl.GL_VERTEX_SHADER) is null
+PASS gl.createTexture() is null
+PASS gl.getActiveAttrib(program, 0) is null
+PASS gl.getActiveUniform(program, 0) is null
+PASS gl.getAttachedShaders(program) is null
+PASS gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE) is null
+PASS gl.getContextAttributes() is null
+PASS gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) is null
+PASS gl.getParameter(gl.CURRENT_PROGRAM) is null
+PASS gl.getProgramInfoLog(program) is null
+PASS gl.getProgramParameter(program, gl.LINK_STATUS) is null
+PASS gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_WIDTH) is null
+PASS gl.getShaderInfoLog(shader) is null
+PASS gl.getShaderParameter(shader, gl.SHADER_TYPE) is null
+PASS gl.getShaderSource(shader) is null
+PASS gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S) is null
+PASS gl.getUniform(program, uniformLocation) is null
+PASS gl.getUniformLocation(program, 'vPosition') is null
+PASS gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING) is null
+PASS gl.getSupportedExtensions() is null
+PASS gl.getExtension('WEBKIT_lose_context') is null
+PASS gl.isBuffer(buffer) is false
+PASS gl.isEnabled(gl.BLEND) is false
+PASS gl.isFramebuffer(framebuffer) is false
+PASS gl.isProgram(program) is false
+PASS gl.isRenderbuffer(renderbuffer) is false
+PASS gl.isShader(shader) is false
+PASS gl.isTexture(texture) is false
+PASS gl.getError() is gl.NO_ERROR
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/canvas/webgl/context-lost-restored-expected.txt b/LayoutTests/fast/canvas/webgl/context-lost-restored-expected.txt
new file mode 100644
index 0000000..fd76019
--- /dev/null
+++ b/LayoutTests/fast/canvas/webgl/context-lost-restored-expected.txt
@@ -0,0 +1,31 @@
+Tests behavior under a restored context
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Test valid context
+PASS gl.isContextLost() is false
+PASS gl.getError() is gl.NO_ERROR
+PASS shouldBe 255,10,20
+PASS gl.getError() is gl.NO_ERROR
+
+Test lost context
+PASS gl.isContextLost() is true
+PASS gl.getError() is gl.CONTEXT_LOST_WEBGL
+PASS gl.getError() is gl.NO_ERROR
+
+Test restored context
+PASS gl.isContextLost() is false
+PASS gl.getError() is gl.NO_ERROR
+PASS gl.bindTexture(gl.TEXTURE_2D, texture) was expected value: INVALID_OPERATION.
+PASS gl.useProgram(program) was expected value: INVALID_OPERATION.
+PASS gl.bindBuffer(gl.ARRAY_BUFFER, bufferObjects[0]) was expected value: INVALID_OPERATION.
+PASS shouldBe 255,10,20
+PASS gl.getError() is gl.NO_ERROR
+PASS gl.bindTexture(gl.TEXTURE_2D, texture) was expected value: NO_ERROR.
+PASS gl.useProgram(program) was expected value: NO_ERROR.
+PASS gl.bindBuffer(gl.ARRAY_BUFFER, bufferObjects[0]) was expected value: NO_ERROR.
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/canvas/webgl/context-lost-restored.html b/LayoutTests/fast/canvas/webgl/context-lost-restored.html
new file mode 100644
index 0000000..9756836
--- /dev/null
+++ b/LayoutTests/fast/canvas/webgl/context-lost-restored.html
@@ -0,0 +1,130 @@
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script src="resources/webgl-test.js"></script>
+<script src="resources/webgl-test-utils.js"></script>
+<script>
+var wtu = WebGLTestUtils;
+var canvas;
+var gl;
+var shouldGenerateGLError;
+var extension_name = "WEBKIT_lose_context";
+var extension;
+var bufferObjects;
+var program;
+var texture;
+var texColor = [255, 10, 20, 255];
+
+function init()
+{
+    if (window.initNonKhronosFramework) {
+        window.initNonKhronosFramework(true);
+    }
+
+    description("Tests behavior under a restored context");
+
+    canvas = document.getElementById("canvas");
+    canvas.addEventListener("webglcontextlost", testLostContext);
+    canvas.addEventListener("webglcontextrestored", testRestoredContext);
+
+    gl = wtu.create3DContext(canvas);
+    shouldGenerateGLError = wtu.shouldGenerateGLError;
+
+    extension = gl.getExtension(extension_name);
+    if (!extension) {
+        debug(extension_name + " extension not found.");
+        finish();
+        return;
+    }
+
+    testOriginalContext();
+    extension.loseContext();
+}
+
+function testRendering()
+{
+    gl.clearColor(0, 0, 0, 255);
+    gl.colorMask(1, 1, 1, 0);
+    gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+
+    program = wtu.setupSimpleTextureProgram(gl);
+    bufferObjects = wtu.setupUnitQuad(gl);
+    texture = wtu.createColoredTexture(gl, canvas.width, canvas.height, texColor);
+
+    gl.uniform1i(gl.getUniformLocation(program, "tex"), 0);
+    wtu.drawQuad(gl, [0, 0, 0, 255]);
+
+    var compare = texColor.slice(0, 3);
+    wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, compare, "shouldBe " + compare);
+
+    shouldBe("gl.getError()", "gl.NO_ERROR");
+}
+
+function testOriginalContext()
+{
+    debug("Test valid context");
+    shouldBeFalse("gl.isContextLost()");
+    shouldBe("gl.getError()", "gl.NO_ERROR");
+    testRendering();
+    debug("");
+}
+
+function testLostContext()
+{
+    debug("Test lost context");
+    shouldBeTrue("gl.isContextLost()");
+    shouldBe("gl.getError()", "gl.CONTEXT_LOST_WEBGL");
+    shouldBe("gl.getError()", "gl.NO_ERROR");
+    debug("");
+}
+
+function testResources(expected)
+{
+    var tests = [
+        "gl.bindTexture(gl.TEXTURE_2D, texture)",
+        "gl.useProgram(program)",
+        "gl.bindBuffer(gl.ARRAY_BUFFER, bufferObjects[0])",
+    ];
+
+    for (var i = 0; i < tests.length; ++i)
+        shouldGenerateGLError(gl, expected, tests[i]);
+}
+
+function testRestoredContext()
+{
+    debug("Test restored context");
+    shouldBeFalse("gl.isContextLost()");
+    shouldBe("gl.getError()", "gl.NO_ERROR");
+
+    // Validate that using old resources fails.
+    testResources(gl.INVALID_OPERATION);
+
+    testRendering();
+
+    // Validate new resources created in testRendering().
+    testResources(gl.NO_ERROR);
+    debug("");
+
+    finish();
+}
+
+function finish() {
+    successfullyParsed = true;
+    var epilogue = document.createElement("script");
+    epilogue.onload = function() {
+        if (window.nonKhronosFrameworkNotifyDone)
+            window.nonKhronosFrameworkNotifyDone();
+    };
+    epilogue.src = "../../js/resources/js-test-post.js";
+    document.body.appendChild(epilogue);
+}
+
+</script>
+</head>
+<body onload="init()">
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="canvas" width="1px" height="1px"></canvas>
+</body>
+</html>
diff --git a/LayoutTests/fast/canvas/webgl/context-lost.html b/LayoutTests/fast/canvas/webgl/context-lost.html
new file mode 100644
index 0000000..57d1533
--- /dev/null
+++ b/LayoutTests/fast/canvas/webgl/context-lost.html
@@ -0,0 +1,315 @@
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script src="resources/webgl-test.js"></script>
+<script src="resources/webgl-test-utils.js"></script>
+<script>
+var wtu;
+var canvas;
+var gl;
+var shouldGenerateGLError;
+var extension_name = "WEBKIT_lose_context";
+var extension;
+
+var buffer;
+var framebuffer;
+var program;
+var renderbuffer;
+var shader;
+var texture;
+var uniformLocation;
+var arrayBuffer;
+var arrayBufferView
+var image;
+var video;
+var canvas2d;
+var ctx2d;
+var imageData;
+var float32array;
+var int32array;
+
+function init()
+{
+    wtu = WebGLTestUtils;
+    canvas = document.getElementById("canvas");
+    gl = wtu.create3DContext(canvas);
+    shouldGenerateGLError = wtu.shouldGenerateGLError;
+
+    description("Tests behavior under a lost context");
+
+    if (window.initNonKhronosFramework) {
+        window.initNonKhronosFramework(true);
+    }
+
+    extension = gl.getExtension(extension_name);
+    if (!extension) {
+        debug(extension_name + " extension not found.");
+        finish();
+        return;
+    }
+
+    canvas.addEventListener("webglcontextlost", testLostContext);
+
+    testValidContext();
+    loseContext();
+}
+
+function loseContext()
+{
+    debug("");
+    debug("Lose context");
+    shouldGenerateGLError(gl, gl.NO_ERROR, "extension.loseContext()");
+    debug("");
+}
+
+function testValidContext()
+{
+    debug("Test valid context");
+
+    shouldBeFalse("gl.isContextLost()");
+
+    arrayBuffer = new ArrayBuffer(4);
+    arrayBufferView = new Int8Array(arrayBuffer);
+
+    // Generate resources for testing.
+    buffer = gl.createBuffer();
+    gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
+    framebuffer = gl.createFramebuffer();
+    gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
+    program = wtu.setupSimpleTextureProgram(gl);
+    renderbuffer = gl.createRenderbuffer();
+    gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
+    shader = gl.createShader(gl.VERTEX_SHADER);
+    texture = gl.createTexture();
+    gl.bindTexture(gl.TEXTURE_2D, texture);
+    shouldBe("gl.getError()", "gl.NO_ERROR");
+
+    // Test is queries that will later be false
+    shouldGenerateGLError(gl, gl.NO_ERROR, "gl.enable(gl.BLEND)");
+    shouldBeTrue("gl.isBuffer(buffer)");
+    shouldBeTrue("gl.isEnabled(gl.BLEND)");
+    shouldBeTrue("gl.isFramebuffer(framebuffer)");
+    shouldBeTrue("gl.isProgram(program)");
+    shouldBeTrue("gl.isRenderbuffer(renderbuffer)");
+    shouldBeTrue("gl.isShader(shader)");
+    shouldBeTrue("gl.isTexture(texture)");
+}
+
+function testLostContext()
+{
+    debug("Test lost context");
+
+    // Functions with special return values.
+    shouldBeTrue("gl.isContextLost()");
+    shouldBe("gl.getError()", "gl.CONTEXT_LOST_WEBGL");
+    shouldBe("gl.getError()", "gl.NO_ERROR");
+    shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_UNSUPPORTED");
+    shouldBe("gl.getAttribLocation(program, 'u_modelViewProjMatrix')", "-1");
+    shouldBe("gl.getVertexAttribOffset(0, gl.VERTEX_ATTRIB_ARRAY_POINTER)", "0");
+
+    // Test the extension itself.
+    shouldGenerateGLError(gl, gl.INVALID_OPERATION, "extension.loseContext()");
+
+    image = document.createElement("image");
+    video = document.createElement("video");
+    canvas2d = document.createElement("canvas");
+    ctx2d = canvas2d.getContext("2d");
+    imageData = ctx2d.createImageData(1, 1);
+    float32array = new Float32Array(1);
+    int32array = new Int32Array(1);
+
+    // Functions returning void should return immediately.
+    // This is untestable, but we can at least be sure they cause no errors
+    // and the codepaths are exercised.
+    var voidTests = [
+        "gl.activeTexture(gl.TEXTURE0)",
+        "gl.attachShader(program, shader)",
+        "gl.bindBuffer(gl.ARRAY_BUFFER, buffer)",
+        "gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer)",
+        "gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer)",
+        "gl.bindTexture(gl.TEXTURE_2D, texture)",
+        "gl.blendColor(1.0, 1.0, 1.0, 1.0)",
+        "gl.blendEquation(gl.FUNC_ADD)",
+        "gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_ADD)",
+        "gl.blendFunc(gl.ONE)",
+        "gl.blendFuncSeparate(gl.ONE, gl.ONE)",
+        "gl.bufferData(gl.ARRAY_BUFFER, 0, gl.STATIC_DRAW)",
+        "gl.bufferData(gl.ARRAY_BUFFER, arrayBufferView, gl.STATIC_DRAW)",
+        "gl.bufferData(gl.ARRAY_BUFFER, arrayBuffer, gl.STATIC_DRAW)",
+        "gl.bufferSubData(gl.ARRAY_BUFFRE, 0, arrayBufferView)",
+        "gl.bufferSubData(gl.ARRAY_BUFFRE, 0, arrayBuffer)",
+        "gl.clear(gl.COLOR_BUFFER_BIT)",
+        "gl.clearColor(1, 1, 1, 1)",
+        "gl.clearDepth(1)",
+        "gl.clearStencil(0)",
+        "gl.colorMask(1, 1, 1, 1)",
+        "gl.compileShader(shader)",
+        "gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, 0, 0, 0)",
+        "gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, 0, 0)",
+        "gl.cullFace(gl.FRONT)",
+        "gl.deleteBuffer(buffer)",
+        "gl.deleteFramebuffer(framebuffer)",
+        "gl.deleteProgram(program)",
+        "gl.deleteRenderbuffer(renderbuffer)",
+        "gl.deleteShader(shader)",
+        "gl.deleteTexture(texture)",
+        "gl.depthFunc(gl.NEVER)",
+        "gl.depthMask(0)",
+        "gl.depthRange(0, 1)",
+        "gl.detachShader(program, shader)",
+        "gl.disable(gl.BLEND)",
+        "gl.disableVertexAttribArray(0)",
+        "gl.drawArrays(gl.POINTS, 0, 0)",
+        "gl.drawElements(gl.POINTS, 0, gl.UNSIGNED_SHORT, 0)",
+        "gl.enable(gl.BLEND)",
+        "gl.enableVertexAttribArray(0)",
+        "gl.finish()",
+        "gl.flush()",
+        "gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, renderbuffer)",
+        "gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0)",
+        "gl.frontFace(gl.CW)",
+        "gl.generateMipmap(gl.TEXTURE_2D)",
+        "gl.hint(gl.GENERATE_MIPMAP_HINT, gl.FASTEST)",
+        "gl.lineWidth(0)",
+        "gl.linkProgram(program)",
+        "gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0)",
+        "gl.polygonOffset(0, 0)",
+        "gl.readPixels(0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, arrayBufferView)",
+        "gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 0, 0)",
+        "gl.sampleCoverage(0, 0)",
+        "gl.scissor(0, 0, 0, 0)",
+        "gl.shaderSource(shader, '')",
+        "gl.stencilFunc(gl.NEVER, 0, 0)",
+        "gl.stencilFuncSeparate(gl.FRONT, gl.NEVER, 0, 0)",
+        "gl.stencilMask(0)",
+        "gl.stencilMaskSeparate(gl.FRONT, 0)",
+        "gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP)",
+        "gl.stencilOpSeparate(gl.FRONT, gl.KEEP, gl.KEEP, gl.KEEP)",
+        "gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, arrayBufferView)",
+        "gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, imageData)",
+        "gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image)",
+        "gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas)",
+        "gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, video)",
+        "gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)",
+        "gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)",
+        "gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, arrayBufferView)",
+        "gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, imageData)",
+        "gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, image)",
+        "gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, canvas)",
+        "gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, video)",
+        "gl.uniform1f(uniformLocation, 0)",
+        "gl.uniform1fv(uniformLocation, float32array)",
+        "gl.uniform1fv(uniformLocation, [0])",
+        "gl.uniform1i(uniformLocation, 0)",
+        "gl.uniform1iv(uniformLocation, int32array)",
+        "gl.uniform1iv(uniformLocation, [0])",
+        "gl.uniform2f(uniformLocation, 0, 0)",
+        "gl.uniform2fv(uniformLocation, float32array)",
+        "gl.uniform2fv(uniformLocation, [0, 0])",
+        "gl.uniform2i(uniformLocation, 0, 0)",
+        "gl.uniform2iv(uniformLocation, int32array)",
+        "gl.uniform2iv(uniformLocation, [0, 0])",
+        "gl.uniform3f(uniformLocation, 0, 0, 0)",
+        "gl.uniform3fv(uniformLocation, float32array)",
+        "gl.uniform3fv(uniformLocation, [0, 0, 0])",
+        "gl.uniform3i(uniformLocation, 0, 0, 0)",
+        "gl.uniform3iv(uniformLocation, int32array)",
+        "gl.uniform3iv(uniformLocation, [0, 0, 0])",
+        "gl.uniform4f(uniformLocation, 0, 0, 0, 0)",
+        "gl.uniform4fv(uniformLocation, float32array)",
+        "gl.uniform4fv(uniformLocation, [0, 0, 0, 0])",
+        "gl.uniform4i(uniformLocation, 0, 0, 0, 0)",
+        "gl.uniform4iv(uniformLocation, int32array)",
+        "gl.uniform4iv(uniformLocation, [0, 0, 0, 0])",
+        "gl.uniformMatrix2fv(uniformLocation, false, float32array)",
+        "gl.uniformMatrix2fv(uniformLocation, false, [0, 0, 0, 0])",
+        "gl.uniformMatrix3fv(uniformLocation, false, float32array)",
+        "gl.uniformMatrix3fv(uniformLocation, false, [0, 0, 0, 0, 0, 0, 0, 0, 0])",
+        "gl.uniformMatrix4fv(uniformLocation, false, float32array)",
+        "gl.uniformMatrix4fv(uniformLocation, false, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])",
+        "gl.useProgram(program)",
+        "gl.validateProgram(program)",
+        "gl.vertexAttrib1f(0, 0)",
+        "gl.vertexAttrib1fv(0, float32array)",
+        "gl.vertexAttrib1fv(0, [0])",
+        "gl.vertexAttrib2f(0, 0, 0)",
+        "gl.vertexAttrib2fv(0, float32array)",
+        "gl.vertexAttrib2fv(0, [0, 0])",
+        "gl.vertexAttrib3f(0, 0, 0, 0)",
+        "gl.vertexAttrib3fv(0, float32array)",
+        "gl.vertexAttrib3fv(0, [0, 0, 0])",
+        "gl.vertexAttrib4f(0, 0, 0, 0, 0)",
+        "gl.vertexAttrib4fv(0, float32array)",
+        "gl.vertexAttrib4fv(0, [0, 0, 0, 0])",
+        "gl.vertexAttribPointer(0, 0, gl.FLOAT, false, 0, 0)",
+        "gl.viewport(0, 0, 0, 0)",
+    ];
+    for (var i = 0; i < voidTests.length; ++i) {
+        shouldGenerateGLError(gl, gl.NO_ERROR, voidTests[i]);
+    }
+
+    // Functions return nullable values should all return null.
+    var nullTests = [
+        "gl.createBuffer()",
+        "gl.createFramebuffer()",
+        "gl.createProgram()",
+        "gl.createRenderbuffer()",
+        "gl.createShader(gl.GL_VERTEX_SHADER)",
+        "gl.createTexture()",
+        "gl.getActiveAttrib(program, 0)",
+        "gl.getActiveUniform(program, 0)",
+        "gl.getAttachedShaders(program)",
+        "gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE)",
+        "gl.getContextAttributes()",
+        "gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME)",
+        "gl.getParameter(gl.CURRENT_PROGRAM)",
+        "gl.getProgramInfoLog(program)",
+        "gl.getProgramParameter(program, gl.LINK_STATUS)",
+        "gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_WIDTH)",
+        "gl.getShaderInfoLog(shader)",
+        "gl.getShaderParameter(shader, gl.SHADER_TYPE)",
+        "gl.getShaderSource(shader)",
+        "gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S)",
+        "gl.getUniform(program, uniformLocation)",
+        "gl.getUniformLocation(program, 'vPosition')",
+        "gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING)",
+        "gl.getSupportedExtensions()",
+        "gl.getExtension('" + extension_name + "')",
+    ];
+    for (var i = 0; i < nullTests.length; ++i) {
+        shouldBeNull(nullTests[i]);
+    }
+
+    // "Is" queries should all return false.
+    shouldBeFalse("gl.isBuffer(buffer)");
+    shouldBeFalse("gl.isEnabled(gl.BLEND)");
+    shouldBeFalse("gl.isFramebuffer(framebuffer)");
+    shouldBeFalse("gl.isProgram(program)");
+    shouldBeFalse("gl.isRenderbuffer(renderbuffer)");
+    shouldBeFalse("gl.isShader(shader)");
+    shouldBeFalse("gl.isTexture(texture)");
+
+    shouldBe("gl.getError()", "gl.NO_ERROR");
+
+    finish();
+}
+
+function finish() {
+    successfullyParsed = true;
+    var epilogue = document.createElement("script");
+    epilogue.onload = function() {
+        if (window.nonKhronosFrameworkNotifyDone)
+            window.nonKhronosFrameworkNotifyDone();
+    };
+    epilogue.src = "../../js/resources/js-test-post.js";
+    document.body.appendChild(epilogue);
+}
+</script>
+</head>
+<body onload="init()">
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="canvas">
+</body>
+</html>
diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt
index 5515f0e..b292840 100644
--- a/WebCore/CMakeLists.txt
+++ b/WebCore/CMakeLists.txt
@@ -303,6 +303,7 @@ SET(WebCore_IDL_FILES
     html/canvas/WebGLShader.idl
     html/canvas/WebGLTexture.idl
     html/canvas/WebGLUniformLocation.idl
+    html/canvas/WebKitLoseContext.idl
 
     inspector/InjectedScriptHost.idl
     inspector/InspectorFrontendHost.idl
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 4c9a9e0..3c403c7 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,45 @@
+2011-01-05  Adrienne Walker  <enne at google.com>
+
+        Reviewed by Kenneth Russell.
+
+        Add WEBKIT_lose_context WebGL extension.
+        https://bugs.webkit.org/show_bug.cgi?id=51492
+
+        Tests: fast/canvas/webgl/context-lost-restored.html
+               fast/canvas/webgl/context-lost.html
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * GNUmakefile.am:
+        * WebCore.gypi:
+        * WebCore.pri:
+        * WebCore.pro:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSWebGLRenderingContextCustom.cpp:
+        (WebCore::toJS):
+        (WebCore::JSWebGLRenderingContext::getSupportedExtensions):
+        * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
+        (WebCore::toV8Object):
+        (WebCore::V8WebGLRenderingContext::getSupportedExtensionsCallback):
+        * html/canvas/WebGLExtension.h:
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore::WebGLRenderingContext::WebGLRenderingContextRestoreTimer::fired):
+        (WebCore::WebGLRenderingContext::getExtension):
+        (WebCore::WebGLRenderingContext::getSupportedExtensions):
+        (WebCore::WebGLRenderingContext::forceLostContext):
+        (WebCore::WebGLRenderingContext::onLostContext):
+        (WebCore::WebGLRenderingContext::getNumberOfExtensions):
+        (WebCore::WebGLRenderingContext::getExtensionNumber):
+        * html/canvas/WebGLRenderingContext.h:
+        * html/canvas/WebKitLoseContext.cpp: Copied from WebCore/html/canvas/WebGLExtension.h.
+        (WebCore::WebKitLoseContext::WebKitLoseContext):
+        (WebCore::WebKitLoseContext::~WebKitLoseContext):
+        (WebCore::WebKitLoseContext::getName):
+        (WebCore::WebKitLoseContext::create):
+        (WebCore::WebKitLoseContext::loseContext):
+        * html/canvas/WebKitLoseContext.h: Copied from WebCore/html/canvas/WebGLExtension.h.
+        * html/canvas/WebKitLoseContext.idl: Copied from WebCore/html/canvas/WebGLExtension.h.
+
 2011-01-07  Chris Marrin  <cmarrin at apple.com>
 
         Unreviewed.
diff --git a/WebCore/DerivedSources.make b/WebCore/DerivedSources.make
index fb13afe..ebb92b1 100644
--- a/WebCore/DerivedSources.make
+++ b/WebCore/DerivedSources.make
@@ -508,6 +508,7 @@ DOM_CLASSES = \
     WebKitCSSKeyframesRule \
     WebKitCSSMatrix \
     WebKitCSSTransformValue \
+    WebKitLoseContext \
     WebKitPoint \
     WebKitTransitionEvent \
     WebSocket \
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index de06560..3e0534b 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -594,6 +594,8 @@ webcore_built_sources += \
 	DerivedSources/WebCore/JSWebKitCSSMatrix.h \
 	DerivedSources/WebCore/JSWebKitCSSTransformValue.cpp \
 	DerivedSources/WebCore/JSWebKitCSSTransformValue.h \
+	DerivedSources/WebCore/JSWebKitLoseContext.cpp \
+	DerivedSources/WebCore/JSWebKitLoseContext.h \
 	DerivedSources/WebCore/JSWebKitPoint.cpp \
 	DerivedSources/WebCore/JSWebKitPoint.h \
 	DerivedSources/WebCore/JSWebKitTransitionEvent.cpp \
@@ -1571,6 +1573,8 @@ webcore_sources += \
 	WebCore/html/canvas/Int8Array.h \
 	WebCore/html/canvas/OESTextureFloat.cpp \
 	WebCore/html/canvas/OESTextureFloat.h \
+	WebCore/html/canvas/WebKitLoseContext.cpp \
+	WebCore/html/canvas/WebKitLoseContext.h \
 	WebCore/html/canvas/Uint16Array.cpp \
 	WebCore/html/canvas/Uint16Array.h \
 	WebCore/html/canvas/Uint32Array.cpp \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 14f39d6..b5c24db 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -228,6 +228,7 @@
             'html/canvas/WebGLShader.idl',
             'html/canvas/WebGLTexture.idl',
             'html/canvas/WebGLUniformLocation.idl',
+            'html/canvas/WebKitLoseContext.idl',
             'inspector/InjectedScriptHost.idl',
             'inspector/InspectorFrontendHost.idl',
             'inspector/JavaScriptCallFrame.idl',
@@ -1948,6 +1949,8 @@
             'html/canvas/WebGLTexture.h',
             'html/canvas/WebGLUniformLocation.cpp',
             'html/canvas/WebGLUniformLocation.h',
+            'html/canvas/WebKitLoseContext.cpp',
+            'html/canvas/WebKitLoseContext.h',
             'html/parser/CSSPreloadScanner.cpp',
             'html/parser/CSSPreloadScanner.h',
             'html/parser/HTMLConstructionSite.cpp',
diff --git a/WebCore/WebCore.pri b/WebCore/WebCore.pri
index bc3f595..d111924 100644
--- a/WebCore/WebCore.pri
+++ b/WebCore/WebCore.pri
@@ -204,6 +204,7 @@ IDL_BINDINGS += \
     html/canvas/Int16Array.idl \
     html/canvas/WebGLTexture.idl \
     html/canvas/WebGLUniformLocation.idl \
+    html/canvas/WebKitLoseContext.idl \
     html/canvas/Uint8Array.idl \
     html/canvas/Uint32Array.idl \
     html/canvas/Uint16Array.idl \
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 68723bb..13755a6 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -3797,6 +3797,7 @@ contains(DEFINES, ENABLE_3D_CANVAS=1) {
         html/canvas/OESTextureFloat.h \
         html/canvas/WebGLTexture.h \
         html/canvas/WebGLUniformLocation.h \
+        html/canvas/WebKitLoseContext.h \
         platform/graphics/Extensions3D.h \
         platform/graphics/GraphicsContext3D.h \
         platform/graphics/qt/Extensions3DQt.h
@@ -3820,6 +3821,7 @@ contains(DEFINES, ENABLE_3D_CANVAS=1) {
         html/canvas/OESTextureFloat.cpp \
         html/canvas/WebGLTexture.cpp \
         html/canvas/WebGLUniformLocation.cpp \
+        html/canvas/WebKitLoseContext.cpp \
         platform/graphics/GraphicsContext3D.cpp \
         platform/graphics/qt/Extensions3DQt.cpp \
         platform/graphics/qt/GraphicsContext3DQt.cpp
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 783e1d2..c34c731 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -2959,6 +2959,10 @@
 		93F19B1508245E59001E9ABC /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F5C2869502846DCD018635CA /* Cocoa.framework */; };
 		93F19B1608245E59001E9ABC /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8216299029F4FB501000131 /* JavaScriptCore.framework */; };
 		93F19B1708245E59001E9ABC /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 93F1D31A0558CC5C00821BC0 /* libicucore.dylib */; };
+		93F1D5BA12D532C400832BEC /* WebKitLoseContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1D5B712D532C400832BEC /* WebKitLoseContext.cpp */; };
+		93F1D5BB12D532C400832BEC /* WebKitLoseContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F1D5B812D532C400832BEC /* WebKitLoseContext.h */; };
+		93F1D5C012D5335600832BEC /* JSWebKitLoseContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F1D5BE12D5335600832BEC /* JSWebKitLoseContext.cpp */; };
+		93F1D5C112D5335600832BEC /* JSWebKitLoseContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F1D5BF12D5335600832BEC /* JSWebKitLoseContext.h */; };
 		93F6F1ED127F70B10055CB06 /* WebGLContextEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F6F1EA127F70B10055CB06 /* WebGLContextEvent.cpp */; };
 		93F6F1EE127F70B10055CB06 /* WebGLContextEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F6F1EB127F70B10055CB06 /* WebGLContextEvent.h */; };
 		93F925430F7EF5B8007E37C9 /* CheckedRadioButtons.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F925410F7EF5B8007E37C9 /* CheckedRadioButtons.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -7925,6 +7929,8 @@
 		6EBF0E5312A8929800DB1709 /* WebGLExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGLExtension.h; path = canvas/WebGLExtension.h; sourceTree = "<group>"; };
 		6EBF0E7412A9868800DB1709 /* JSOESTextureFloat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSOESTextureFloat.cpp; sourceTree = "<group>"; };
 		6EBF0E7512A9868800DB1709 /* JSOESTextureFloat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSOESTextureFloat.h; sourceTree = "<group>"; };
+		93F1D5BE12D5335600832BEC /* JSWebKitLoseContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSWebKitLoseContext.cpp; path = JSWebKitLoseContext.cpp; sourceTree = "<group>"; };
+		93F1D5BF12D5335600832BEC /* JSWebKitLoseContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSWebKitLoseContext.h; path = JSWebKitLoseContext.h; sourceTree = "<group>"; };
 		6EE8A77010F803F3005A4A24 /* JSWebGLContextAttributes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLContextAttributes.cpp; sourceTree = "<group>"; };
 		6EE8A77110F803F3005A4A24 /* JSWebGLContextAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLContextAttributes.h; sourceTree = "<group>"; };
 		72626E010EF022FE00A07E20 /* FontFastPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFastPath.cpp; sourceTree = "<group>"; };
@@ -9295,6 +9301,9 @@
 		93F19B1908245E59001E9ABC /* Info.plist */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		93F19B1A08245E5A001E9ABC /* WebCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WebCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		93F1D31A0558CC5C00821BC0 /* libicucore.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libicucore.dylib; path = /usr/lib/libicucore.dylib; sourceTree = "<absolute>"; };
+		93F1D5B712D532C400832BEC /* WebKitLoseContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebKitLoseContext.cpp; path = canvas/WebKitLoseContext.cpp; sourceTree = "<group>"; };
+		93F1D5B812D532C400832BEC /* WebKitLoseContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebKitLoseContext.h; path = canvas/WebKitLoseContext.h; sourceTree = "<group>"; };
+		93F1D5B912D532C400832BEC /* WebKitLoseContext.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebKitLoseContext.idl; path = canvas/WebKitLoseContext.idl; sourceTree = "<group>"; };
 		93F6F1EA127F70B10055CB06 /* WebGLContextEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebGLContextEvent.cpp; path = canvas/WebGLContextEvent.cpp; sourceTree = "<group>"; };
 		93F6F1EB127F70B10055CB06 /* WebGLContextEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGLContextEvent.h; path = canvas/WebGLContextEvent.h; sourceTree = "<group>"; };
 		93F6F1EC127F70B10055CB06 /* WebGLContextEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLContextEvent.idl; path = canvas/WebGLContextEvent.idl; sourceTree = "<group>"; };
@@ -13088,6 +13097,9 @@
 		49484FAE102CF01E00187DD3 /* canvas */ = {
 			isa = PBXGroup;
 			children = (
+				93F1D5B712D532C400832BEC /* WebKitLoseContext.cpp */,
+				93F1D5B812D532C400832BEC /* WebKitLoseContext.h */,
+				93F1D5B912D532C400832BEC /* WebKitLoseContext.idl */,
 				49EECDCA10503C2300099FAB /* ArrayBuffer.cpp */,
 				49EECDCB10503C2300099FAB /* ArrayBuffer.h */,
 				49EECDCC10503C2300099FAB /* ArrayBuffer.idl */,
@@ -15831,6 +15843,8 @@
 		A83B79080CCAFF2B000B0825 /* HTML */ = {
 			isa = PBXGroup;
 			children = (
+				93F1D5BE12D5335600832BEC /* JSWebKitLoseContext.cpp */,
+				93F1D5BF12D5335600832BEC /* JSWebKitLoseContext.h */,
 				49EECEF2105070C400099FAB /* JSArrayBuffer.cpp */,
 				49EECEF3105070C400099FAB /* JSArrayBuffer.h */,
 				49EECF19105072F300099FAB /* JSArrayBufferView.cpp */,
@@ -22276,6 +22290,8 @@
 				7EE6846F12D26E3800E79415 /* ResourceRequestCFNet.h in Headers */,
 				7EE6847012D26E3800E79415 /* ResourceResponse.h in Headers */,
 				493E5E0912D6420500020081 /* PlatformCALayerClient.h in Headers */,
+				93F1D5BB12D532C400832BEC /* WebKitLoseContext.h in Headers */,
+				93F1D5C112D5335600832BEC /* JSWebKitLoseContext.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -24958,6 +24974,8 @@
 				7EE6846E12D26E3800E79415 /* ResourceRequestCFNet.cpp in Sources */,
 				7EE6847112D26E3800E79415 /* ResourceResponseCFNet.cpp in Sources */,
 				7EE6847512D26E7000E79415 /* ResourceLoaderCFNet.cpp in Sources */,
+				93F1D5BA12D532C400832BEC /* WebKitLoseContext.cpp in Sources */,
+				93F1D5C012D5335600832BEC /* JSWebKitLoseContext.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp b/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp
index e1963da..ed4a9ca 100644
--- a/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp
+++ b/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp
@@ -29,9 +29,11 @@
 
 #include "JSWebGLRenderingContext.h"
 
+#include "WebKitLoseContext.h"
 #include "ExceptionCode.h"
 #include "HTMLCanvasElement.h"
 #include "HTMLImageElement.h"
+#include "JSWebKitLoseContext.h"
 #include "JSHTMLCanvasElement.h"
 #include "JSHTMLImageElement.h"
 #include "JSImageData.h"
@@ -169,6 +171,8 @@ static JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, WebGLExten
     if (!extension)
         return jsNull();
     switch (extension->getName()) {
+    case WebGLExtension::WebKitLoseContextName:
+        return toJS(exec, globalObject, static_cast<WebKitLoseContext*>(extension));
     case WebGLExtension::OESTextureFloatName:
         return toJS(exec, globalObject, static_cast<OESTextureFloat*>(extension));
     }
@@ -320,6 +324,8 @@ JSValue JSWebGLRenderingContext::getShaderParameter(ExecState* exec)
 JSValue JSWebGLRenderingContext::getSupportedExtensions(ExecState* exec)
 {
     WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(impl());
+    if (context->isContextLost())
+        return jsNull();
     Vector<String> value = context->getSupportedExtensions();
     MarkedArgumentBuffer list;
     for (size_t ii = 0; ii < value.size(); ++ii)
diff --git a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
index 048cef5..70df7c1 100644
--- a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
@@ -35,35 +35,33 @@
 #include "V8WebGLRenderingContext.h"
 
 #include "ExceptionCode.h"
-
 #include "NotImplemented.h"
-
-#include <wtf/FastMalloc.h>
-
+#include "V8ArrayBufferView.h"
 #include "V8Binding.h"
 #include "V8BindingMacros.h"
-#include "V8ArrayBufferView.h"
-#include "V8WebGLBuffer.h"
-#include "V8Int8Array.h"
+#include "V8WebKitLoseContext.h"
 #include "V8Float32Array.h"
-#include "V8WebGLFramebuffer.h"
-#include "V8Int32Array.h"
-#include "V8WebGLProgram.h"
-#include "V8WebGLRenderbuffer.h"
-#include "V8WebGLShader.h"
-#include "V8Int16Array.h"
-#include "V8WebGLTexture.h"
-#include "V8WebGLUniformLocation.h"
-#include "V8Uint8Array.h"
-#include "V8Uint32Array.h"
-#include "V8Uint16Array.h"
 #include "V8HTMLCanvasElement.h"
 #include "V8HTMLImageElement.h"
 #include "V8HTMLVideoElement.h"
 #include "V8ImageData.h"
+#include "V8Int16Array.h"
+#include "V8Int32Array.h"
+#include "V8Int8Array.h"
 #include "V8OESTextureFloat.h"
 #include "V8Proxy.h"
+#include "V8Uint16Array.h"
+#include "V8Uint32Array.h"
+#include "V8Uint8Array.h"
+#include "V8WebGLBuffer.h"
+#include "V8WebGLFramebuffer.h"
+#include "V8WebGLProgram.h"
+#include "V8WebGLRenderbuffer.h"
+#include "V8WebGLShader.h"
+#include "V8WebGLTexture.h"
+#include "V8WebGLUniformLocation.h"
 #include "WebGLRenderingContext.h"
+#include <wtf/FastMalloc.h>
 
 namespace WebCore {
 
@@ -159,6 +157,9 @@ static v8::Handle<v8::Value> toV8Object(WebGLExtension* extension, v8::Handle<v8
         return v8::Null();
     v8::Handle<v8::Value> extensionObject;
     switch (extension->getName()) {
+    case WebGLExtension::WebKitLoseContextName:
+        extensionObject = toV8(static_cast<WebKitLoseContext*>(extension));
+        break;
     case WebGLExtension::OESTextureFloatName:
         extensionObject = toV8(static_cast<OESTextureFloat*>(extension));
         break;
@@ -375,6 +376,9 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getSupportedExtensionsCallback(co
 {
     INC_STATS("DOM.WebGLRenderingContext.getSupportedExtensionsCallback()");
     WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(args.Holder());
+    if (imp->isContextLost())
+        return v8::Null();
+
     Vector<String> value = imp->getSupportedExtensions();
     v8::Local<v8::Array> array = v8::Array::New(value.size());
     for (size_t ii = 0; ii < value.size(); ++ii)
diff --git a/WebCore/html/canvas/WebGLExtension.h b/WebCore/html/canvas/WebGLExtension.h
index 3df3b73..f2d6b7b 100644
--- a/WebCore/html/canvas/WebGLExtension.h
+++ b/WebCore/html/canvas/WebGLExtension.h
@@ -34,7 +34,8 @@ class WebGLExtension : public RefCounted<WebGLExtension> {
 public:
     // Extension names are needed to properly wrap instances in JavaScript objects.
     enum ExtensionName {
-        OESTextureFloatName
+        WebKitLoseContextName,
+        OESTextureFloatName,
     };
 
     virtual ~WebGLExtension();
diff --git a/WebCore/html/canvas/WebGLRenderingContext.cpp b/WebCore/html/canvas/WebGLRenderingContext.cpp
index 1330b1f..4ffd400 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.cpp
+++ b/WebCore/html/canvas/WebGLRenderingContext.cpp
@@ -32,6 +32,7 @@
 #include "CachedImage.h"
 #include "CanvasPixelArray.h"
 #include "CheckedInt.h"
+#include "WebKitLoseContext.h"
 #include "Console.h"
 #include "DOMWindow.h"
 #include "Extensions3D.h"
@@ -137,11 +138,11 @@ private:
 void WebGLRenderingContext::WebGLRenderingContextRestoreTimer::fired()
 {
     // Timer is started when m_contextLost is false.  It will first call
-    // loseContext, which will set m_contextLost to true.  Then it will keep
+    // onLostContext, which will set m_contextLost to true.  Then it will keep
     // calling restoreContext and reschedule itself until m_contextLost is back
     // to false.
     if (!m_context->m_contextLost) {
-        m_context->loseContext();
+        m_context->onLostContext();
         startOneShot(secondsBetweenRestoreAttempts);
     } else {
         // The rendering context is not restored if there is no handler for
@@ -1573,6 +1574,9 @@ unsigned long WebGLRenderingContext::getError()
 
 WebGLExtension* WebGLRenderingContext::getExtension(const String& name)
 {
+    if (isContextLost())
+        return 0;
+
     if (equalIgnoringCase(name, "OES_texture_float")
         && m_context->getExtensions()->supports("GL_OES_texture_float")) {
         if (!m_oesTextureFloat) {
@@ -1580,6 +1584,10 @@ WebGLExtension* WebGLRenderingContext::getExtension(const String& name)
             m_oesTextureFloat = OESTextureFloat::create();
         }
         return m_oesTextureFloat.get();
+    } else if (equalIgnoringCase(name, "WEBKIT_lose_context")) {
+        if (!m_webkitLoseContext)
+            m_webkitLoseContext = WebKitLoseContext::create(this);
+        return m_webkitLoseContext.get();
     }
 
     return 0;
@@ -1985,6 +1993,7 @@ Vector<String> WebGLRenderingContext::getSupportedExtensions()
     Vector<String> result;
     if (m_context->getExtensions()->supports("GL_OES_texture_float"))
         result.append("OES_texture_float");
+    result.append("WEBKIT_lose_context");
     return result;
 }
 
@@ -3458,7 +3467,17 @@ void WebGLRenderingContext::viewport(long x, long y, long width, long height)
     cleanupAfterGraphicsCall(false);
 }
 
-void WebGLRenderingContext::loseContext()
+void WebGLRenderingContext::forceLostContext()
+{
+    if (isContextLost()) {
+        m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+        return;
+    }
+
+    m_restoreTimer.startOneShot(0);
+}
+
+void WebGLRenderingContext::onLostContext()
 {
     m_contextLost = true;
 
@@ -4345,11 +4364,16 @@ void WebGLRenderingContext::restoreStatesAfterVertexAttrib0Simulation()
 
 int WebGLRenderingContext::getNumberOfExtensions()
 {
-    return (m_oesTextureFloat ? 1 : 0);
+    return (m_webkitLoseContext ? 1 : 0) + (m_oesTextureFloat ? 1 : 0);
 }
 
 WebGLExtension* WebGLRenderingContext::getExtensionNumber(int i)
 {
+    if (m_webkitLoseContext) {
+        if (!i)
+            return m_webkitLoseContext.get();
+        --i;
+    }
     if (m_oesTextureFloat) {
         if (!i)
             return m_oesTextureFloat.get();
diff --git a/WebCore/html/canvas/WebGLRenderingContext.h b/WebCore/html/canvas/WebGLRenderingContext.h
index 1414c7c..c40847f 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.h
+++ b/WebCore/html/canvas/WebGLRenderingContext.h
@@ -51,6 +51,7 @@ class WebGLRenderbuffer;
 class WebGLShader;
 class WebGLTexture;
 class WebGLUniformLocation;
+class WebKitLoseContext;
 class HTMLImageElement;
 class HTMLVideoElement;
 class ImageBuffer;
@@ -284,7 +285,8 @@ public:
 
     void viewport(long x, long y, long width, long height);
 
-    void loseContext();
+    void forceLostContext();
+    void onLostContext();
     void restoreContext();
 
     GraphicsContext3D* graphicsContext3D() const { return m_context.get(); }
@@ -468,6 +470,7 @@ public:
 
     // Enabled extension objects.
     RefPtr<OESTextureFloat> m_oesTextureFloat;
+    RefPtr<WebKitLoseContext> m_webkitLoseContext;
 
     // Helpers for getParameter and others
     WebGLGetInfo getBooleanParameter(unsigned long pname);
diff --git a/WebCore/html/canvas/WebKitLoseContext.cpp b/WebCore/html/canvas/WebKitLoseContext.cpp
new file mode 100644
index 0000000..c7dd078
--- /dev/null
+++ b/WebCore/html/canvas/WebKitLoseContext.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "WebKitLoseContext.h"
+
+#include "WebGLRenderingContext.h"
+
+namespace WebCore {
+
+WebKitLoseContext::WebKitLoseContext(WebGLRenderingContext* context)
+    : WebGLExtension()
+    , m_context(context)
+{
+}
+
+WebKitLoseContext::~WebKitLoseContext()
+{
+}
+
+WebGLExtension::ExtensionName WebKitLoseContext::getName() const
+{
+    return WebKitLoseContextName;
+}
+
+PassRefPtr<WebKitLoseContext> WebKitLoseContext::create(WebGLRenderingContext* context)
+{
+    return adoptRef(new WebKitLoseContext(context));
+}
+
+void WebKitLoseContext::loseContext()
+{
+    m_context->forceLostContext();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/html/canvas/WebKitLoseContext.h b/WebCore/html/canvas/WebKitLoseContext.h
new file mode 100644
index 0000000..e25e084
--- /dev/null
+++ b/WebCore/html/canvas/WebKitLoseContext.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebKitLoseContext_h
+#define WebKitLoseContext_h
+
+#include "WebGLExtension.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class WebGLRenderingContext;
+
+class WebKitLoseContext : public WebGLExtension {
+public:
+    static PassRefPtr<WebKitLoseContext> create(WebGLRenderingContext*);
+
+    virtual ~WebKitLoseContext();
+    virtual ExtensionName getName() const;
+
+    void loseContext();
+
+private:
+    WebKitLoseContext(WebGLRenderingContext*);
+
+    WebGLRenderingContext* m_context;
+};
+
+} // namespace WebCore
+
+#endif // WebKitLoseContext_h
diff --git a/WebCore/html/canvas/WebKitLoseContext.idl b/WebCore/html/canvas/WebKitLoseContext.idl
new file mode 100644
index 0000000..741aa4a
--- /dev/null
+++ b/WebCore/html/canvas/WebKitLoseContext.idl
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module html {
+    interface [Conditional=3D_CANVAS, OmitConstructor] WebKitLoseContext {
+        [StrictTypeChecking] void loseContext();
+    };
+}

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list