| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdlib.h> | 5 #include <stdlib.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/stringprintf.h" |
| 9 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 10 #include "content/browser/frame_host/frame_tree.h" | 11 #include "content/browser/frame_host/frame_tree.h" |
| 11 #include "content/browser/frame_host/render_frame_host_impl.h" | 12 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 12 #include "content/browser/renderer_host/render_widget_host_impl.h" | 13 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 13 #include "content/browser/web_contents/web_contents_impl.h" | 14 #include "content/browser/web_contents/web_contents_impl.h" |
| 14 #include "content/common/page_messages.h" | 15 #include "content/common/page_messages.h" |
| 15 #include "content/common/view_messages.h" | 16 #include "content/common/view_messages.h" |
| 16 #include "content/public/browser/render_widget_host.h" | 17 #include "content/public/browser/render_widget_host.h" |
| 17 #include "content/public/browser/render_widget_host_view.h" | 18 #include "content/public/browser/render_widget_host_view.h" |
| 18 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 &orientation_type)); | 349 &orientation_type)); |
| 349 EXPECT_EQ(types[i], orientation_type); | 350 EXPECT_EQ(types[i], orientation_type); |
| 350 EXPECT_TRUE(ExecuteScriptAndExtractString( | 351 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 351 child->current_frame_host(), | 352 child->current_frame_host(), |
| 352 "window.domAutomationController.send(screen.orientation.type)", | 353 "window.domAutomationController.send(screen.orientation.type)", |
| 353 &orientation_type)); | 354 &orientation_type)); |
| 354 EXPECT_EQ(types[i], orientation_type); | 355 EXPECT_EQ(types[i], orientation_type); |
| 355 } | 356 } |
| 356 } | 357 } |
| 357 | 358 |
| 359 #ifdef OS_ANDROID |
| 360 // This test is disabled because th trybots run in system portrait lock, which |
| 361 // prevents the test from changing the screen orientation. |
| 362 IN_PROC_BROWSER_TEST_F(ScreenOrientationOOPIFBrowserTest, |
| 363 DISABLED_ScreenOrientationLock) { |
| 364 GURL main_url(embedded_test_server()->GetURL( |
| 365 "a.com", "/cross_site_iframe_factory.html?a(b)")); |
| 366 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 367 WaitForResizeComplete(shell()->web_contents()); |
| 368 |
| 369 const char* types[] = {"portrait-primary", "portrait-secondary", |
| 370 "landscape-primary", "landscape-secondary"}; |
| 371 |
| 372 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| 373 FrameTreeNode* child = root->child_at(0); |
| 374 RenderFrameHostImpl* frames[] = {root->current_frame_host(), |
| 375 child->current_frame_host()}; |
| 376 |
| 377 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), |
| 378 "document.body.webkitRequestFullscreen()")); |
| 379 for (const char* type : types) { |
| 380 std::string script = |
| 381 base::StringPrintf("screen.orientation.lock('%s')", type); |
| 382 EXPECT_TRUE(ExecuteScript(child->current_frame_host(), script)); |
| 383 |
| 384 for (auto* frame : frames) { |
| 385 std::string orientation_type; |
| 386 while (type != orientation_type) { |
| 387 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 388 frame, |
| 389 "window.domAutomationController.send(screen.orientation.type)", |
| 390 &orientation_type)); |
| 391 } |
| 392 } |
| 393 |
| 394 EXPECT_TRUE(ExecuteScript(child->current_frame_host(), |
| 395 "screen.orientation.unlock()")); |
| 396 } |
| 397 } |
| 398 #endif // OS_ANDROID |
| 399 |
| 358 } // namespace content | 400 } // namespace content |
| OLD | NEW |