15f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
25f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// found in the LICENSE file.
45f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
55f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include <stdlib.h>
65f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
75f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "base/command_line.h"
85f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "content/browser/renderer_host/render_widget_host_impl.h"
95f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "content/common/view_messages.h"
105f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "content/public/browser/render_widget_host.h"
115f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "content/public/browser/render_widget_host_view.h"
125f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "content/public/browser/web_contents.h"
135f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "content/public/common/content_switches.h"
145f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "content/public/test/browser_test_utils.h"
155f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "content/public/test/content_browser_test.h"
165f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "content/public/test/content_browser_test_utils.h"
175f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "content/public/test/test_navigation_observer.h"
185f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "content/public/test/test_utils.h"
195f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "content/shell/browser/shell.h"
205f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "content/shell/common/shell_switches.h"
215f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "third_party/WebKit/public/platform/WebScreenInfo.h"
225f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "ui/compositor/compositor_switches.h"
235f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
246e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#if defined(OS_WIN)
256e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "base/win/windows_version.h"
266e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#endif // OS_WIN
276e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
285f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)namespace content {
295f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
305f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class ScreenOrientationBrowserTest : public ContentBrowserTest  {
315f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) public:
325f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  ScreenOrientationBrowserTest() {
335f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  }
345f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
355f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
365f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    command_line->AppendSwitch(
375f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)        switches::kEnableExperimentalWebPlatformFeatures);
385f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  }
395f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
405f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  virtual void SetUp() OVERRIDE {
415f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    // Painting has to happen otherwise the Resize messages will be added on top
425f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    // of each other without properly ack-painting which will fail and crash.
435f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    UseSoftwareCompositing();
445f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
455f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    ContentBrowserTest::SetUp();
465f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  }
475f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
485f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) protected:
495f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  void SendFakeScreenOrientation(unsigned angle, const std::string& strType) {
505f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    RenderWidgetHost* rwh = shell()->web_contents()->GetRenderWidgetHostView()
515f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)        ->GetRenderWidgetHost();
525f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    blink::WebScreenInfo screen_info;
535f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    rwh->GetWebScreenInfo(&screen_info);
545f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    screen_info.orientationAngle = angle;
555f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
565f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    blink::WebScreenOrientationType type = blink::WebScreenOrientationUndefined;
575f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    if (strType == "portrait-primary") {
585f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)      type = blink::WebScreenOrientationPortraitPrimary;
595f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    } else if (strType == "portrait-secondary") {
605f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)      type = blink::WebScreenOrientationPortraitSecondary;
615f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    } else if (strType == "landscape-primary") {
625f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)      type = blink::WebScreenOrientationLandscapePrimary;
635f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    } else if (strType == "landscape-secondary") {
645f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)      type = blink::WebScreenOrientationLandscapeSecondary;
655f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    }
665f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    ASSERT_NE(blink::WebScreenOrientationUndefined, type);
675f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    screen_info.orientationType = type;
685f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
695f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    ViewMsg_Resize_Params params;
705f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    params.screen_info = screen_info;
715f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    params.new_size = gfx::Size(0, 0);
725f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    params.physical_backing_size = gfx::Size(300, 300);
7303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)    params.top_controls_layout_height = 0.f;
745f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    params.resizer_rect = gfx::Rect();
755f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    params.is_fullscreen = false;
765f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    rwh->Send(new ViewMsg_Resize(rwh->GetRoutingID(), params));
775f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  }
785f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
795f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  int GetOrientationAngle() {
805f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    int angle;
815f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(),
825f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                             "screen.orientation.angle")->GetAsInteger(&angle);
835f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    return angle;
845f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  }
855f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
865f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  std::string GetOrientationType() {
875f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    std::string type;
885f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(),
895f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                             "screen.orientation.type")->GetAsString(&type);
905f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    return type;
915f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  }
925f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
936e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  bool ScreenOrientationSupported() {
946e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)    bool support;
956e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)    ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(),
966e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)                             "'orientation' in screen")->GetAsBoolean(&support);
976e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)    return support;
986e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  }
996e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
1005f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  bool WindowOrientationSupported() {
1015f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    bool support;
1025f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(),
1035f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                             "'orientation' in window")->GetAsBoolean(&support);
1045f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    return support;
1055f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  }
1065f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
1075f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  int GetWindowOrientationAngle() {
1085f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    int angle;
1095f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(),
1105f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                             "window.orientation")->GetAsInteger(&angle);
1115f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    return angle;
1125f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  }
1135f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
1145f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) private:
1155f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(ScreenOrientationBrowserTest);
1165f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)};
1175f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
1185f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// This test doesn't work on MacOS X but the reason is mostly because it is not
1195f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// used Aura. It could be set as !defined(OS_MACOSX) but the rule below will
1205f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// actually support MacOS X if and when it switches to Aura.
1215f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#if defined(USE_AURA) || defined(OS_ANDROID)
1225f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(ScreenOrientationBrowserTest, ScreenOrientationChange) {
1235f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  std::string types[] = { "portrait-primary",
1245f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                          "portrait-secondary",
1255f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                          "landscape-primary",
1265f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                          "landscape-secondary" };
1275f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  GURL test_url = GetTestUrl("screen_orientation",
1285f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                             "screen_orientation_screenorientationchange.html");
1295f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
1305f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  TestNavigationObserver navigation_observer(shell()->web_contents(), 1);
1315f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  shell()->LoadURL(test_url);
1325f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  navigation_observer.Wait();
1335f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#if USE_AURA
1345f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  WaitForResizeComplete(shell()->web_contents());
1355f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#endif // USE_AURA
1365f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
1376e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#if defined(OS_WIN)
1386e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Screen Orientation is currently disabled on Windows 8.
1396e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // This test will break, requiring an update when the API will be enabled.
1406e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  if (base::win::OSInfo::GetInstance()->version() >= base::win::VERSION_WIN8) {
1416e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)    EXPECT_EQ(false, ScreenOrientationSupported());
1426e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)    return;
1436e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  }
1446e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#endif // defined(OS_WIN)
1456e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
1465f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  int angle = GetOrientationAngle();
1475f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
1485f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  for (int i = 0; i < 4; ++i) {
1495f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    angle = (angle + 90) % 360;
1505f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    SendFakeScreenOrientation(angle, types[i]);
1515f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
1525f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    TestNavigationObserver navigation_observer(shell()->web_contents());
1535f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    navigation_observer.Wait();
1545f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    EXPECT_EQ(angle, GetOrientationAngle());
1555f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    EXPECT_EQ(types[i], GetOrientationType());
1565f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  }
1575f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)}
1585f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#endif // defined(USE_AURA) || defined(OS_ANDROID)
1595f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
1605f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(ScreenOrientationBrowserTest, WindowOrientationChange) {
1615f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  GURL test_url = GetTestUrl("screen_orientation",
1625f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)                             "screen_orientation_windoworientationchange.html");
1635f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
1645f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  TestNavigationObserver navigation_observer(shell()->web_contents(), 1);
1655f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  shell()->LoadURL(test_url);
1665f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  navigation_observer.Wait();
1676e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#if USE_AURA
1686e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  WaitForResizeComplete(shell()->web_contents());
1696e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#endif // USE_AURA
1705f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
1715f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  if (!WindowOrientationSupported())
1725f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    return;
1735f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
1745f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  int angle = GetWindowOrientationAngle();
1755f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
1765f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  for (int i = 0; i < 4; ++i) {
1775f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    angle = (angle + 90) % 360;
1785f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    SendFakeScreenOrientation(angle, "portrait-primary");
1795f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
1805f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    TestNavigationObserver navigation_observer(shell()->web_contents(), 1);
1815f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    navigation_observer.Wait();
1825f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    EXPECT_EQ(angle == 270 ? -90 : angle, GetWindowOrientationAngle());
1835f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  }
1845f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)}
1855f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
1866e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Chromium Android does not support fullscreen
1876e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(ScreenOrientationBrowserTest, LockSmoke) {
1886e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  GURL test_url = GetTestUrl("screen_orientation",
1896e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)                             "screen_orientation_lock_smoke.html");
1906e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
1916e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  TestNavigationObserver navigation_observer(shell()->web_contents(), 2);
1926e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  shell()->LoadURL(test_url);
1936e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
1946e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#if defined(OS_WIN)
1956e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Screen Orientation is currently disabled on Windows 8.
1966e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // This test will break, requiring an update when the API will be enabled.
1976e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  if (base::win::OSInfo::GetInstance()->version() >= base::win::VERSION_WIN8) {
1986e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)    EXPECT_EQ(false, ScreenOrientationSupported());
1996e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)    return;
2006e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  }
2016e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#endif // defined(OS_WIN)
2026e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
2036e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  navigation_observer.Wait();
2046e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#if USE_AURA
2056e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  WaitForResizeComplete(shell()->web_contents());
2066e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#endif // USE_AURA
2076e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
2086e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  std::string expected =
2096e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#if defined(OS_ANDROID)
2106e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)      "SecurityError"; // WebContents need to be fullscreen.
2116e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#else
2126e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)      "NotSupportedError"; // Locking isn't supported.
2136e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#endif
2146e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
2156e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  EXPECT_EQ(expected, shell()->web_contents()->GetLastCommittedURL().ref());
2166e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)}
2176e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
2185f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)} // namespace content
219