[Webgl-blink] Add test function to force fail the webgl-context.

In order to test whether the  GPU(Vendor,Renderer,Driver info)
is getting fetched properly when creating the context,
we need to provide a function to force fail the context on 
creation, which can be used by test-runner. 

This patch implements the forceNextWebGLContextCreationToFail.
Test-runner can use this further.

test-runner-cl which uses forceNextWebGLContextCreationToFail
@https://codereview.chromium.org/706193003/

BUG=412440

Review URL: https://codereview.chromium.org/703903002

git-svn-id: svn://svn.chromium.org/blink/trunk@185272 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 7b3f0551
...@@ -61,6 +61,8 @@ ...@@ -61,6 +61,8 @@
namespace blink { namespace blink {
static bool shouldFailContextCreationForTesting = false;
PassOwnPtrWillBeRawPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTMLCanvasElement* canvas, WebGLContextAttributes* attrs) PassOwnPtrWillBeRawPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTMLCanvasElement* canvas, WebGLContextAttributes* attrs)
{ {
Document& document = canvas->document(); Document& document = canvas->document();
...@@ -87,7 +89,8 @@ PassOwnPtrWillBeRawPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTML ...@@ -87,7 +89,8 @@ PassOwnPtrWillBeRawPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTML
blink::WebGraphicsContext3D::Attributes attributes = attrs->attributes(document.topDocument().url().string(), settings, 1); blink::WebGraphicsContext3D::Attributes attributes = attrs->attributes(document.topDocument().url().string(), settings, 1);
blink::WebGLInfo glInfo; blink::WebGLInfo glInfo;
OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::current()->createOffscreenGraphicsContext3D(attributes, 0, &glInfo)); OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::current()->createOffscreenGraphicsContext3D(attributes, 0, &glInfo));
if (!context) { if (!context || shouldFailContextCreationForTesting) {
shouldFailContextCreationForTesting = false;
String statusMessage("Could not create a WebGL context for VendorInfo = "); String statusMessage("Could not create a WebGL context for VendorInfo = ");
statusMessage.append(glInfo.vendorInfo); statusMessage.append(glInfo.vendorInfo);
statusMessage.append(", RendererInfo = "); statusMessage.append(", RendererInfo = ");
...@@ -182,4 +185,9 @@ void WebGLRenderingContext::trace(Visitor* visitor) ...@@ -182,4 +185,9 @@ void WebGLRenderingContext::trace(Visitor* visitor)
WebGLRenderingContextBase::trace(visitor); WebGLRenderingContextBase::trace(visitor);
} }
void WebGLRenderingContext::forceNextWebGLContextCreationToFail()
{
shouldFailContextCreationForTesting = true;
}
} // namespace blink } // namespace blink
...@@ -35,6 +35,7 @@ class WebGLRenderingContext final : public WebGLRenderingContextBase, public Scr ...@@ -35,6 +35,7 @@ class WebGLRenderingContext final : public WebGLRenderingContextBase, public Scr
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: public:
static PassOwnPtrWillBeRawPtr<WebGLRenderingContext> create(HTMLCanvasElement*, WebGLContextAttributes*); static PassOwnPtrWillBeRawPtr<WebGLRenderingContext> create(HTMLCanvasElement*, WebGLContextAttributes*);
static void forceNextWebGLContextCreationToFail();
virtual ~WebGLRenderingContext(); virtual ~WebGLRenderingContext();
virtual unsigned version() const override { return 1; } virtual unsigned version() const override { return 1; }
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
#include "core/html/HTMLMediaElement.h" #include "core/html/HTMLMediaElement.h"
#include "core/html/HTMLPlugInElement.h" #include "core/html/HTMLPlugInElement.h"
#include "core/html/HTMLTextAreaElement.h" #include "core/html/HTMLTextAreaElement.h"
#include "core/html/canvas/WebGLRenderingContext.h"
#include "core/html/ime/InputMethodContext.h" #include "core/html/ime/InputMethodContext.h"
#include "core/inspector/InspectorController.h" #include "core/inspector/InspectorController.h"
#include "core/loader/DocumentLoader.h" #include "core/loader/DocumentLoader.h"
...@@ -4500,4 +4501,9 @@ bool WebViewImpl::shouldDisableDesktopWorkarounds() ...@@ -4500,4 +4501,9 @@ bool WebViewImpl::shouldDisableDesktopWorkarounds()
|| (constraints.minimumScale == constraints.maximumScale && constraints.minimumScale != -1); || (constraints.minimumScale == constraints.maximumScale && constraints.minimumScale != -1);
} }
void WebViewImpl::forceNextWebGLContextCreationToFail()
{
WebGLRenderingContext::forceNextWebGLContextCreationToFail();
}
} // namespace blink } // namespace blink
...@@ -508,6 +508,8 @@ public: ...@@ -508,6 +508,8 @@ public:
virtual void setTopControlsLayoutHeight(float) override; virtual void setTopControlsLayoutHeight(float) override;
virtual void forceNextWebGLContextCreationToFail() override;
private: private:
void didUpdateTopControls(); void didUpdateTopControls();
void setTopControlsContentOffset(float); void setTopControlsContentOffset(float);
......
...@@ -493,6 +493,10 @@ public: ...@@ -493,6 +493,10 @@ public:
// Testing functionality for TestRunner --------------------------------- // Testing functionality for TestRunner ---------------------------------
// Force the webgl context to fail so that webglcontextcreationerror
// event gets generated/tested.
virtual void forceNextWebGLContextCreationToFail() = 0;
protected: protected:
~WebView() {} ~WebView() {}
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment