summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/features_override.gypi1
-rw-r--r--chrome/browser/device_orientation/enable_switch_browsertest.cc34
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc1
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chrome/common/chrome_switches.cc3
-rw-r--r--chrome/common/chrome_switches.h1
-rw-r--r--chrome/renderer/render_thread.cc3
-rw-r--r--chrome/test/data/device_orientation/enable_switch_test.html32
8 files changed, 76 insertions, 0 deletions
diff --git a/build/features_override.gypi b/build/features_override.gypi
index 2e19776..1b77747 100644
--- a/build/features_override.gypi
+++ b/build/features_override.gypi
@@ -16,6 +16,7 @@
'ENABLE_DASHBOARD_SUPPORT=0',
'ENABLE_DATABASE=1',
'ENABLE_DATAGRID=0',
+ 'ENABLE_DEVICE_ORIENTATION=1',
'ENABLE_DIRECTORY_UPLOAD=1',
'ENABLE_DOM_STORAGE=1',
'ENABLE_EVENTSOURCE=1',
diff --git a/chrome/browser/device_orientation/enable_switch_browsertest.cc b/chrome/browser/device_orientation/enable_switch_browsertest.cc
new file mode 100644
index 0000000..debbdf54
--- /dev/null
+++ b/chrome/browser/device_orientation/enable_switch_browsertest.cc
@@ -0,0 +1,34 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/command_line.h"
+#include "base/file_path.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/test/in_process_browser_test.h"
+#include "chrome/test/ui_test_utils.h"
+
+class DeviceOrientationEnableSwitchTest : public InProcessBrowserTest {
+ public:
+ GURL testUrl(const char* filename) {
+ const FilePath kTestDir("device_orientation");
+ return ui_test_utils::GetTestUrl(kTestDir, FilePath(filename));
+ }
+};
+
+IN_PROC_BROWSER_TEST_F(DeviceOrientationEnableSwitchTest, UnavailabilityTest) {
+ // Test that device orientation is not available to a web page if
+ // the runtime switch is disabled.
+
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ bool has_switch = command_line.HasSwitch(switches::kEnableDeviceOrientation);
+ ASSERT_FALSE(has_switch) << "This test does not make sense if "
+ << "--enable-device-orientation is set.";
+
+ GURL test_url = testUrl("enable_switch_test.html");
+ ui_test_utils::NavigateToURL(browser(), test_url);
+ std::string status = browser()->GetSelectedTabContents()->GetURL().ref();
+ EXPECT_EQ("pass", status) << "Page detected device orientation properties.";
+}
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index d6509e8..793e96a 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -549,6 +549,7 @@ void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer(
switches::kDisableSessionStorage,
switches::kDisableSharedWorkers,
switches::kDisableApplicationCache,
+ switches::kEnableDeviceOrientation,
switches::kEnableIndexedDatabase,
switches::kDisableGeolocation,
switches::kShowPaintRects,
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 253b779..f697f29 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1515,6 +1515,7 @@
'browser/chromeos/update_browsertest.cc',
'browser/cocoa/view_id_util_browsertest.mm',
'browser/crash_recovery_browsertest.cc',
+ 'browser/device_orientation/enable_switch_browsertest.cc',
'browser/dom_ui/file_browse_browsertest.cc',
'browser/dom_ui/mediaplayer_browsertest.cc',
'browser/download/save_page_browsertest.cc',
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 3c4255a..93586b5 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -293,6 +293,9 @@ const char kEnableCloudPrintProxy[] = "enable-cloud-print-proxy";
// Enables the Cloud Print dialog hosting code.
const char kEnableCloudPrint[] = "enable-cloud-print";
+// Enables device orientation events.
+const char kEnableDeviceOrientation[] = "enable-device-orientation";
+
// Enables extension APIs that are in development.
const char kEnableExperimentalExtensionApis[] =
"enable-experimental-extension-apis";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 70a8268..ce8a7bc 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -97,6 +97,7 @@ extern const char kEnableBenchmarking[];
extern const char kEnableChromoting[];
extern const char kEnableCloudPrintProxy[];
extern const char kEnableCloudPrint[];
+extern const char kEnableDeviceOrientation[];
extern const char kEnableExperimentalExtensionApis[];
extern const char kEnableExperimentalWebGL[];
extern const char kEnableExtensionTimelineApi[];
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index f63a90e..1ecd13c 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -893,6 +893,9 @@ void RenderThread::EnsureWebKitInitialized() {
WebRuntimeFeatures::enableTouch(
command_line.HasSwitch(switches::kEnableTouch));
+
+ WebRuntimeFeatures::enableDeviceOrientation(
+ command_line.HasSwitch(switches::kEnableDeviceOrientation));
}
void RenderThread::IdleHandler() {
diff --git a/chrome/test/data/device_orientation/enable_switch_test.html b/chrome/test/data/device_orientation/enable_switch_test.html
new file mode 100644
index 0000000..c2f90ac
--- /dev/null
+++ b/chrome/test/data/device_orientation/enable_switch_test.html
@@ -0,0 +1,32 @@
+<html>
+ <head>
+ <title>DeviceOrientationEnableSwitchTest</title>
+ <script type="text/javascript">
+ var failed = false;
+ function pass() {
+ if (failed)
+ return;
+ document.getElementById('status').innerHTML = 'PASS';
+ document.location = '#pass';
+ }
+ function fail() {
+ document.getElementById('status').innerHTML = 'FAIL';
+ document.location = '#fail';
+ failed = true;
+ }
+ function run() {
+ for (var property in window) {
+ if (property == "DeviceOrientationEvent")
+ fail();
+ if (property == "ondeviceorientation")
+ fail();
+ }
+
+ pass();
+ }
+ </script>
+ </head>
+ <body onload="run()">
+ <div id="status">Running...</div>
+ </body>
+</html>