Chromium Code Reviews| 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: | |
|
sky
2015/08/31 15:57:27
run git cl format as your spacing is off.
Mikhail
2015/09/01 08:13:46
Done.
| |
| 3129 void OnJsExecutionDone(base::Closure callback, const base::Value* value) { | |
| 3130 js_result_.reset(value->DeepCopy()); | |
| 3131 callback.Run(); | |
| 3132 } | |
| 3133 bool GetResult() const { | |
| 3134 bool res; | |
| 3135 CHECK(js_result_); | |
| 3136 CHECK(js_result_->GetAsBoolean(&res)); | |
| 3137 return res; | |
| 3138 } | |
| 3139 | |
| 3140 private: | |
| 3141 scoped_ptr<base::Value> js_result_; | |
| 3142 }; | |
|
sky
2015/08/31 15:57:27
DISALLOW...
Mikhail
2015/09/01 08:13:46
Done.
| |
| 3143 | |
| 3144 void CheckDisplayModeMQ( | |
| 3145 const base::string16& display_mode, | |
| 3146 content::WebContents* web_contents) { | |
| 3147 | |
|
sky
2015/08/31 15:57:27
remove newline.
Mikhail
2015/09/01 08:13:46
Done.
| |
| 3148 base::string16 js_funtcion = | |
|
sky
2015/08/31 15:57:27
function
Mikhail
2015/09/01 08:13:46
Done.
| |
| 3149 ASCIIToUTF16("(function() {return window.matchMedia('(display-mode: ") + | |
| 3150 display_mode + ASCIIToUTF16(")').matches;})();"); | |
| 3151 scoped_ptr<JSBooleanResultGetter> js_result_getter( | |
|
sky
2015/08/31 15:57:27
Create on stack.
Mikhail
2015/09/01 08:13:46
Done.
| |
| 3152 new JSBooleanResultGetter); | |
| 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 js_funtcion, | |
| 3157 base::Bind(&JSBooleanResultGetter::OnJsExecutionDone, | |
| 3158 base::Unretained(js_result_getter.get()), 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 |