Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1321)

Unified Diff: chrome/browser/extensions/extension_webstore_private_apitest.cc

Issue 8772031: Add a JS API for detecting WebGL availability. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_webstore_private_apitest.cc
===================================================================
--- chrome/browser/extensions/extension_webstore_private_apitest.cc (revision 112998)
+++ chrome/browser/extensions/extension_webstore_private_apitest.cc (working copy)
@@ -17,10 +17,13 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/test/base/test_launcher_utils.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "content/browser/gpu/gpu_blacklist.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "net/base/mock_host_resolver.h"
+#include "ui/gfx/gl/gl_switches.h"
namespace {
@@ -86,6 +89,13 @@
ExtensionApiTest::SetUpCommandLine(command_line);
command_line->AppendSwitchASCII(switches::kAppsGalleryURL,
"http://www.example.com");
+
+ // In linux, we need to launch GPU process to decide if WebGL is allowed.
+ // Run it on top of osmesa to avoid bot driver issues.
+#if defined(OS_LINUX)
+ test_launcher_utils::OverrideGLImplementation(
+ command_line, gfx::kGLImplementationOSMesaName);
+#endif
}
void SetUpInProcessBrowserTestFixture() OVERRIDE {
@@ -229,3 +239,41 @@
WebstorePrivateApi::SetTrustTestIDsForTesting(true);
ASSERT_TRUE(RunPageTest(GetTestServerURL("silently_install.html").spec()));
}
+
+// Tests getWebGLStatus function when webgl is allowed.
Mihai Parparita -not on Chrome 2011/12/06 02:58:11 Nit: Capitalize WebGL (applies below too).
Zhenyao Mo 2011/12/06 20:00:15 Done.
+IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateBundleTest,
+ GetWebGLStatusAllowed) {
+ ASSERT_TRUE(
+ RunPageTest(GetTestServerURL("get_webgl_status_allowed.html").spec()));
Mihai Parparita -not on Chrome 2011/12/06 02:58:11 For testing single function behavior, rather than
Zhenyao Mo 2011/12/06 20:00:15 I tried, but it didn't work because RunFunctionAnd
Zhenyao Mo 2011/12/06 20:19:57 Never mind. It's a bug in my own code. I switche
+}
+
+// Tests getWebGLStatus function when webgl is blacklisted.
+IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateBundleTest,
+ GetWebGLStatusBlocked) {
+ const std::string json_blacklist =
+ "{\n"
+ " \"name\": \"gpu blacklist\",\n"
+ " \"version\": \"1.0\",\n"
+ " \"entries\": [\n"
+ " {\n"
+ " \"id\": 1,\n"
+ " \"blacklist\": [\n"
+ " \"webgl\"\n"
+ " ]\n"
+ " }\n"
+ " ]\n"
+ "}";
+ scoped_ptr<Version> os_version(Version::GetVersionFromString("1.0"));
+ GpuBlacklist* blacklist = new GpuBlacklist("1.0");
+
+ ASSERT_TRUE(blacklist->LoadGpuBlacklist(
+ json_blacklist, GpuBlacklist::kAllOs));
+ GpuDataManager::GetInstance()->SetGpuBlacklist(blacklist);
+ GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags();
+ EXPECT_EQ(
+ flags.flags(), static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl));
+
+ ASSERT_TRUE(
+ RunPageTest(GetTestServerURL("get_webgl_status_blocked.html").spec()));
+}
+

Powered by Google App Engine
This is Rietveld 408576698