| Index: Source/core/html/canvas/WebGLRenderingContext.cpp
|
| diff --git a/Source/core/html/canvas/WebGLRenderingContext.cpp b/Source/core/html/canvas/WebGLRenderingContext.cpp
|
| index 3f8e375d3e7e675fdaae90f88bce60d3dcb53f31..d8085b7596d12d4ccef82b2d681e457b9bdd3335 100644
|
| --- a/Source/core/html/canvas/WebGLRenderingContext.cpp
|
| +++ b/Source/core/html/canvas/WebGLRenderingContext.cpp
|
| @@ -61,6 +61,8 @@
|
|
|
| namespace blink {
|
|
|
| +static bool shouldFailContextCreationForTesting = false;
|
| +
|
| PassOwnPtrWillBeRawPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTMLCanvasElement* canvas, WebGLContextAttributes* attrs)
|
| {
|
| Document& document = canvas->document();
|
| @@ -87,7 +89,7 @@ PassOwnPtrWillBeRawPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTML
|
| blink::WebGraphicsContext3D::Attributes attributes = attrs->attributes(document.topDocument().url().string(), settings, 1);
|
| blink::WebGLInfo glInfo;
|
| OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::current()->createOffscreenGraphicsContext3D(attributes, 0, &glInfo));
|
| - if (!context) {
|
| + if (!context || shouldFailContextCreationForTesting) {
|
| String statusMessage("Could not create a WebGL context for VendorInfo = ");
|
| statusMessage.append(glInfo.vendorInfo);
|
| statusMessage.append(", RendererInfo = ");
|
| @@ -96,6 +98,7 @@ PassOwnPtrWillBeRawPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTML
|
| statusMessage.append(glInfo.driverVersion);
|
| statusMessage.append(".");
|
| canvas->dispatchEvent(WebGLContextEvent::create(EventTypeNames::webglcontextcreationerror, false, true, statusMessage));
|
| + shouldFailContextCreationForTesting = false;
|
| return nullptr;
|
| }
|
|
|
| @@ -182,4 +185,9 @@ void WebGLRenderingContext::trace(Visitor* visitor)
|
| WebGLRenderingContextBase::trace(visitor);
|
| }
|
|
|
| +void WebGLRenderingContext::forceNextWebGLContextCreationToFail()
|
| +{
|
| + shouldFailContextCreationForTesting = true;
|
| +}
|
| +
|
| } // namespace blink
|
|
|