Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: chrome/browser/apps/web_view_browsertest.cc

Issue 440463002: Fix display:none issue for <webview>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix back the merge change Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/renderer/resources/extensions/web_view.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/path_service.h" 5 #include "base/path_service.h"
6 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/apps/app_browsertest_util.h" 8 #include "chrome/browser/apps/app_browsertest_util.h"
9 #include "chrome/browser/chrome_content_browser_client.h" 9 #include "chrome/browser/chrome_content_browser_client.h"
10 #include "chrome/browser/extensions/extension_test_message_listener.h" 10 #include "chrome/browser/extensions/extension_test_message_listener.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 TestInterstitialPageDelegate() { 91 TestInterstitialPageDelegate() {
92 } 92 }
93 virtual ~TestInterstitialPageDelegate() {} 93 virtual ~TestInterstitialPageDelegate() {}
94 virtual std::string GetHTMLContents() OVERRIDE { return std::string(); } 94 virtual std::string GetHTMLContents() OVERRIDE { return std::string(); }
95 }; 95 };
96 96
97 class TestGuestViewManager : public extensions::GuestViewManager { 97 class TestGuestViewManager : public extensions::GuestViewManager {
98 public: 98 public:
99 explicit TestGuestViewManager(content::BrowserContext* context) : 99 explicit TestGuestViewManager(content::BrowserContext* context) :
100 GuestViewManager(context), 100 GuestViewManager(context),
101 seen_guest_removed_(false),
101 web_contents_(NULL) {} 102 web_contents_(NULL) {}
102 103
103 content::WebContents* WaitForGuestCreated() { 104 content::WebContents* WaitForGuestCreated() {
104 if (web_contents_) 105 if (web_contents_)
105 return web_contents_; 106 return web_contents_;
106 107
107 message_loop_runner_ = new content::MessageLoopRunner; 108 created_message_loop_runner_ = new content::MessageLoopRunner;
108 message_loop_runner_->Run(); 109 created_message_loop_runner_->Run();
109 return web_contents_; 110 return web_contents_;
110 } 111 }
111 112
113 void WaitForGuestDeleted() {
114 if (seen_guest_removed_)
115 return;
116
117 deleted_message_loop_runner_ = new content::MessageLoopRunner;
118 deleted_message_loop_runner_->Run();
119 }
120
112 private: 121 private:
113 // GuestViewManager override: 122 // GuestViewManager override:
114 virtual void AddGuest(int guest_instance_id, 123 virtual void AddGuest(int guest_instance_id,
115 content::WebContents* guest_web_contents) OVERRIDE{ 124 content::WebContents* guest_web_contents) OVERRIDE{
116 extensions::GuestViewManager::AddGuest( 125 extensions::GuestViewManager::AddGuest(
117 guest_instance_id, guest_web_contents); 126 guest_instance_id, guest_web_contents);
118 web_contents_ = guest_web_contents; 127 web_contents_ = guest_web_contents;
128 seen_guest_removed_ = false;
119 129
120 if (message_loop_runner_.get()) 130 if (created_message_loop_runner_.get())
121 message_loop_runner_->Quit(); 131 created_message_loop_runner_->Quit();
122 } 132 }
123 133
134 virtual void RemoveGuest(int guest_instance_id) OVERRIDE {
135 extensions::GuestViewManager::RemoveGuest(guest_instance_id);
136 web_contents_ = NULL;
137 seen_guest_removed_ = true;
138
139 if (deleted_message_loop_runner_.get())
140 deleted_message_loop_runner_->Quit();
141 }
142
143 bool seen_guest_removed_;
124 content::WebContents* web_contents_; 144 content::WebContents* web_contents_;
125 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 145 scoped_refptr<content::MessageLoopRunner> created_message_loop_runner_;
146 scoped_refptr<content::MessageLoopRunner> deleted_message_loop_runner_;
126 }; 147 };
127 148
128 // Test factory for creating test instances of GuestViewManager. 149 // Test factory for creating test instances of GuestViewManager.
129 class TestGuestViewManagerFactory : 150 class TestGuestViewManagerFactory :
130 public extensions::GuestViewManagerFactory { 151 public extensions::GuestViewManagerFactory {
131 public: 152 public:
132 TestGuestViewManagerFactory() : 153 TestGuestViewManagerFactory() :
133 test_guest_view_manager_(NULL) {} 154 test_guest_view_manager_(NULL) {}
134 155
135 virtual ~TestGuestViewManagerFactory() {} 156 virtual ~TestGuestViewManagerFactory() {}
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 scoped_refptr<content::MessageLoopRunner> loop_runner( 693 scoped_refptr<content::MessageLoopRunner> loop_runner(
673 new content::MessageLoopRunner); 694 new content::MessageLoopRunner);
674 InterstitialObserver observer(web_contents, 695 InterstitialObserver observer(web_contents,
675 loop_runner->QuitClosure(), 696 loop_runner->QuitClosure(),
676 base::Closure()); 697 base::Closure());
677 if (!content::InterstitialPage::GetInterstitialPage(web_contents)) 698 if (!content::InterstitialPage::GetInterstitialPage(web_contents))
678 loop_runner->Run(); 699 loop_runner->Run();
679 } 700 }
680 701
681 void LoadAppWithGuest(const std::string& app_path) { 702 void LoadAppWithGuest(const std::string& app_path) {
682
683 ExtensionTestMessageListener launched_listener("WebViewTest.LAUNCHED", 703 ExtensionTestMessageListener launched_listener("WebViewTest.LAUNCHED",
684 false); 704 false);
685 launched_listener.set_failure_message("WebViewTest.FAILURE"); 705 launched_listener.set_failure_message("WebViewTest.FAILURE");
686 LoadAndLaunchPlatformApp(app_path.c_str(), &launched_listener); 706 LoadAndLaunchPlatformApp(app_path.c_str(), &launched_listener);
687 707
688 guest_web_contents_ = GetGuestViewManager()->WaitForGuestCreated(); 708 guest_web_contents_ = GetGuestViewManager()->WaitForGuestCreated();
689 } 709 }
690 710
691 void SendMessageToEmbedder(const std::string& message) { 711 void SendMessageToEmbedder(const std::string& message) {
692 EXPECT_TRUE( 712 EXPECT_TRUE(
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 #if defined(OS_WIN) 855 #if defined(OS_WIN)
836 // Flaky on XP bot http://crbug.com/299507 856 // Flaky on XP bot http://crbug.com/299507
837 if (base::win::GetVersion() <= base::win::VERSION_XP) 857 if (base::win::GetVersion() <= base::win::VERSION_XP)
838 return; 858 return;
839 #endif 859 #endif
840 860
841 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/autosize")) 861 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/autosize"))
842 << message_; 862 << message_;
843 } 863 }
844 864
865 // Tests that a <webview> that is set to "display: none" after load and then
866 // setting "display: block" re-renders the plugin properly.
867 //
868 // Initially after loading the <webview> and the test sets <webview> to
869 // "display: none".
870 // This causes the browser plugin to be destroyed, we then set the
871 // style.display of the <webview> to block again and check that loadstop
872 // fires properly.
873 IN_PROC_BROWSER_TEST_F(WebViewTest, DisplayNoneAndBack) {
874 LoadAppWithGuest("web_view/display_none_and_back");
875
876 scoped_refptr<content::MessageLoopRunner> loop_runner(
877 new content::MessageLoopRunner);
878 WebContentsHiddenObserver observer(GetGuestWebContents(),
879 loop_runner->QuitClosure());
880
881 // Handled in platform_apps/web_view/display_none_and_back/main.js
882 SendMessageToEmbedder("hide-guest");
883 GetGuestViewManager()->WaitForGuestDeleted();
884 ExtensionTestMessageListener test_passed_listener("WebViewTest.PASSED",
885 false);
886
887 SendMessageToEmbedder("show-guest");
888 GetGuestViewManager()->WaitForGuestCreated();
889 EXPECT_TRUE(test_passed_listener.WaitUntilSatisfied());
890 }
891
845 // http://crbug.com/326332 892 // http://crbug.com/326332
846 IN_PROC_BROWSER_TEST_F(WebViewTest, DISABLED_Shim_TestAutosizeAfterNavigation) { 893 IN_PROC_BROWSER_TEST_F(WebViewTest, DISABLED_Shim_TestAutosizeAfterNavigation) {
847 TestHelper("testAutosizeAfterNavigation", "web_view/shim", NO_TEST_SERVER); 894 TestHelper("testAutosizeAfterNavigation", "web_view/shim", NO_TEST_SERVER);
848 } 895 }
849 896
850 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestAutosizeBeforeNavigation) { 897 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestAutosizeBeforeNavigation) {
851 TestHelper("testAutosizeBeforeNavigation", "web_view/shim", NO_TEST_SERVER); 898 TestHelper("testAutosizeBeforeNavigation", "web_view/shim", NO_TEST_SERVER);
852 } 899 }
853 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestAutosizeRemoveAttributes) { 900 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestAutosizeRemoveAttributes) {
854 TestHelper("testAutosizeRemoveAttributes", "web_view/shim", NO_TEST_SERVER); 901 TestHelper("testAutosizeRemoveAttributes", "web_view/shim", NO_TEST_SERVER);
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after
2258 // http://crbug.com/403325 2305 // http://crbug.com/403325
2259 #define MAYBE_WebViewInBackgroundPage \ 2306 #define MAYBE_WebViewInBackgroundPage \
2260 DISABLED_WebViewInBackgroundPage 2307 DISABLED_WebViewInBackgroundPage
2261 #else 2308 #else
2262 #define MAYBE_WebViewInBackgroundPage WebViewInBackgroundPage 2309 #define MAYBE_WebViewInBackgroundPage WebViewInBackgroundPage
2263 #endif 2310 #endif
2264 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_WebViewInBackgroundPage) { 2311 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_WebViewInBackgroundPage) {
2265 ASSERT_TRUE(RunExtensionTest("platform_apps/web_view/background")) 2312 ASSERT_TRUE(RunExtensionTest("platform_apps/web_view/background"))
2266 << message_; 2313 << message_;
2267 } 2314 }
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/resources/extensions/web_view.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698