OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 3104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3115 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, | 3115 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, |
3116 observer.latest_security_style()); | 3116 observer.latest_security_style()); |
3117 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); | 3117 EXPECT_EQ(0u, observer.latest_explanations().warning_explanations.size()); |
3118 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); | 3118 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); |
3119 CheckSecureExplanations(observer.latest_explanations().secure_explanations, | 3119 CheckSecureExplanations(observer.latest_explanations().secure_explanations, |
3120 VALID_CERTIFICATE); | 3120 VALID_CERTIFICATE); |
3121 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); | 3121 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); |
3122 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 3122 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
3123 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 3123 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
3124 } | 3124 } |
| 3125 |
| 3126 namespace { |
| 3127 class JSBooleanResultGetter { |
| 3128 public: |
| 3129 JSBooleanResultGetter() = default; |
| 3130 void OnJsExecutionDone(base::Closure callback, const base::Value* value) { |
| 3131 js_result_.reset(value->DeepCopy()); |
| 3132 callback.Run(); |
| 3133 } |
| 3134 bool GetResult() const { |
| 3135 bool res; |
| 3136 CHECK(js_result_); |
| 3137 CHECK(js_result_->GetAsBoolean(&res)); |
| 3138 return res; |
| 3139 } |
| 3140 |
| 3141 private: |
| 3142 scoped_ptr<base::Value> js_result_; |
| 3143 DISALLOW_COPY_AND_ASSIGN(JSBooleanResultGetter); |
| 3144 }; |
| 3145 |
| 3146 void CheckDisplayModeMQ( |
| 3147 const base::string16& display_mode, |
| 3148 content::WebContents* web_contents) { |
| 3149 base::string16 funtcion = |
| 3150 ASCIIToUTF16("(function() {return window.matchMedia('(display-mode: ") + |
| 3151 display_mode + ASCIIToUTF16(")').matches;})();"); |
| 3152 JSBooleanResultGetter js_result_getter; |
| 3153 // Execute the JS to run the tests, and wait until it has finished. |
| 3154 base::RunLoop run_loop; |
| 3155 web_contents->GetMainFrame()->ExecuteJavaScriptForTests( |
| 3156 funtcion, |
| 3157 base::Bind(&JSBooleanResultGetter::OnJsExecutionDone, |
| 3158 base::Unretained(&js_result_getter), run_loop.QuitClosure())); |
| 3159 run_loop.Run(); |
| 3160 EXPECT_TRUE(js_result_getter.GetResult()); |
| 3161 } |
| 3162 } // namespace |
| 3163 |
| 3164 IN_PROC_BROWSER_TEST_F(BrowserTest, ChangeDisplayMode) { |
| 3165 CheckDisplayModeMQ( |
| 3166 ASCIIToUTF16("browser"), |
| 3167 browser()->tab_strip_model()->GetActiveWebContents()); |
| 3168 |
| 3169 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 3170 ui_test_utils::BrowserAddedObserver browser_added_observer; |
| 3171 Browser* app_browser = CreateBrowserForApp("blah", profile); |
| 3172 browser_added_observer.WaitForSingleNewBrowser(); |
| 3173 auto app_contents = app_browser->tab_strip_model()->GetActiveWebContents(); |
| 3174 CheckDisplayModeMQ(ASCIIToUTF16("standalone"), app_contents); |
| 3175 |
| 3176 app_browser->window()->EnterFullscreen( |
| 3177 GURL(), EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION, |
| 3178 false); |
| 3179 |
| 3180 // Sync navigation just to make sure IPC has passed (updated |
| 3181 // display mode is delivered to RP). |
| 3182 content::TestNavigationObserver observer(app_contents, 1); |
| 3183 ui_test_utils::NavigateToURL(app_browser, GURL(url::kAboutBlankURL)); |
| 3184 observer.Wait(); |
| 3185 |
| 3186 CheckDisplayModeMQ(ASCIIToUTF16("fullscreen"), app_contents); |
| 3187 } |
| 3188 |
OLD | NEW |