| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <set> | 5 #include <set> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 EXPECT_TRUE(success); | 1090 EXPECT_TRUE(success); |
| 1091 Shell* new_shell = new_shell_observer.GetShell(); | 1091 Shell* new_shell = new_shell_observer.GetShell(); |
| 1092 | 1092 |
| 1093 // Wait for the navigation in the new tab to finish, if it hasn't. | 1093 // Wait for the navigation in the new tab to finish, if it hasn't. |
| 1094 WaitForLoadStop(new_shell->web_contents()); | 1094 WaitForLoadStop(new_shell->web_contents()); |
| 1095 EXPECT_EQ("/files/navigate_opener.html", | 1095 EXPECT_EQ("/files/navigate_opener.html", |
| 1096 new_shell->web_contents()->GetLastCommittedURL().path()); | 1096 new_shell->web_contents()->GetLastCommittedURL().path()); |
| 1097 | 1097 |
| 1098 RenderViewHost* rvh = new_shell->web_contents()->GetRenderViewHost(); | 1098 RenderViewHost* rvh = new_shell->web_contents()->GetRenderViewHost(); |
| 1099 | 1099 |
| 1100 LOG(ERROR) << "set visible"; |
| 1100 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 1101 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 1101 rvh, | 1102 rvh, |
| 1102 "window.domAutomationController.send(" | 1103 "window.domAutomationController.send(" |
| 1103 " document.visibilityState == 'visible');", | 1104 " document.visibilityState == 'visible');", |
| 1104 &success)); | 1105 &success)); |
| 1105 EXPECT_TRUE(success); | 1106 EXPECT_TRUE(success); |
| 1106 | 1107 |
| 1107 // Now navigate the new window to a different site. This should swap out the | 1108 // Now navigate the new window to a different site. This should swap out the |
| 1108 // tab's existing RenderView, causing it become hidden. | 1109 // tab's existing RenderView, causing it become hidden. |
| 1109 NavigateToURL(new_shell, GetCrossSiteURL("files/title1.html")); | 1110 NavigateToURL(new_shell, GetCrossSiteURL("files/title1.html")); |
| 1110 | 1111 |
| 1112 LOG(ERROR) << "set hidden"; |
| 1111 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 1113 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 1112 rvh, | 1114 rvh, |
| 1113 "window.domAutomationController.send(" | 1115 "window.domAutomationController.send(" |
| 1114 " document.visibilityState == 'hidden');", | 1116 " document.visibilityState == 'hidden');", |
| 1115 &success)); | 1117 &success)); |
| 1116 EXPECT_TRUE(success); | 1118 EXPECT_TRUE(success); |
| 1117 | 1119 |
| 1118 // Going back should make the previously swapped-out view to become visible | 1120 // Going back should make the previously swapped-out view to become visible |
| 1119 // again. | 1121 // again. |
| 1120 { | 1122 { |
| 1121 TestNavigationObserver back_nav_load_observer(new_shell->web_contents()); | 1123 TestNavigationObserver back_nav_load_observer(new_shell->web_contents()); |
| 1122 new_shell->web_contents()->GetController().GoBack(); | 1124 new_shell->web_contents()->GetController().GoBack(); |
| 1123 back_nav_load_observer.Wait(); | 1125 back_nav_load_observer.Wait(); |
| 1124 } | 1126 } |
| 1125 | 1127 |
| 1126 EXPECT_EQ("/files/navigate_opener.html", | 1128 EXPECT_EQ("/files/navigate_opener.html", |
| 1127 new_shell->web_contents()->GetLastCommittedURL().path()); | 1129 new_shell->web_contents()->GetLastCommittedURL().path()); |
| 1128 | 1130 |
| 1129 EXPECT_EQ(rvh, new_shell->web_contents()->GetRenderViewHost()); | 1131 EXPECT_EQ(rvh, new_shell->web_contents()->GetRenderViewHost()); |
| 1130 | 1132 |
| 1133 LOG(ERROR) << "set visible"; |
| 1131 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 1134 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 1132 rvh, | 1135 rvh, |
| 1133 "window.domAutomationController.send(" | 1136 "window.domAutomationController.send(" |
| 1134 " document.visibilityState == 'visible');", | 1137 " document.visibilityState == 'visible');", |
| 1135 &success)); | 1138 &success)); |
| 1136 EXPECT_TRUE(success); | 1139 EXPECT_TRUE(success); |
| 1137 } | 1140 } |
| 1138 | 1141 |
| 1139 // This class ensures that all the given RenderViewHosts have properly been | 1142 // This class ensures that all the given RenderViewHosts have properly been |
| 1140 // shutdown. | 1143 // shutdown. |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1456 // Navigate to url1 and check bindings. | 1459 // Navigate to url1 and check bindings. |
| 1457 NavigateToURL(new_shell, url1); | 1460 NavigateToURL(new_shell, url1); |
| 1458 // The navigation should have used the first SiteInstance, otherwise | 1461 // The navigation should have used the first SiteInstance, otherwise |
| 1459 // |initial_rvh| did not have a chance to be used. | 1462 // |initial_rvh| did not have a chance to be used. |
| 1460 EXPECT_EQ(new_web_contents->GetSiteInstance(), site_instance1); | 1463 EXPECT_EQ(new_web_contents->GetSiteInstance(), site_instance1); |
| 1461 EXPECT_EQ(BINDINGS_POLICY_WEB_UI, | 1464 EXPECT_EQ(BINDINGS_POLICY_WEB_UI, |
| 1462 new_web_contents->GetRenderViewHost()->GetEnabledBindings()); | 1465 new_web_contents->GetRenderViewHost()->GetEnabledBindings()); |
| 1463 } | 1466 } |
| 1464 | 1467 |
| 1465 } // namespace content | 1468 } // namespace content |
| OLD | NEW |