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

Side by Side Diff: ios/web/web_state/ui/crw_web_controller_unittest.mm

Issue 2873063002: Use the current title for items created by same document navigations. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #import "ios/web/web_state/ui/crw_web_controller.h" 5 #import "ios/web/web_state/ui/crw_web_controller.h"
6 6
7 #import <WebKit/WebKit.h> 7 #import <WebKit/WebKit.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 // Expect at least one more TitleWasSet callback after changing title via 844 // Expect at least one more TitleWasSet callback after changing title via
845 // JavaScript. On iOS 10 WKWebView fires 3 callbacks after JS excucution 845 // JavaScript. On iOS 10 WKWebView fires 3 callbacks after JS excucution
846 // with the following title changes: "Title2", "" and "Title2". 846 // with the following title changes: "Title2", "" and "Title2".
847 // TODO(crbug.com/696104): There should be only 2 calls of TitleWasSet. 847 // TODO(crbug.com/696104): There should be only 2 calls of TitleWasSet.
848 // Fix expecteation when WKWebView stops sending extra KVO calls. 848 // Fix expecteation when WKWebView stops sending extra KVO calls.
849 ExecuteJavaScript(@"window.document.title = 'Title2';"); 849 ExecuteJavaScript(@"window.document.title = 'Title2';");
850 EXPECT_EQ("Title2", base::UTF16ToUTF8(web_state()->GetTitle())); 850 EXPECT_EQ("Title2", base::UTF16ToUTF8(web_state()->GetTitle()));
851 EXPECT_GE(observer.title_change_count(), 2); 851 EXPECT_GE(observer.title_change_count(), 2);
852 }; 852 };
853 853
854 // Tests that fragment change navigations use title from the previous page.
855 TEST_F(CRWWebControllerTitleTest, FragmentChangeNavigationsUsePreviousTitle) {
856 LoadHtml(@"<title>Title1</title>");
857 ASSERT_EQ("Title1", base::UTF16ToUTF8(web_state()->GetTitle()));
858 ExecuteJavaScript(@"window.location.hash = '#1'");
859 EXPECT_EQ("Title1", base::UTF16ToUTF8(web_state()->GetTitle()));
860 }
861
854 // Test fixture for JavaScript execution. 862 // Test fixture for JavaScript execution.
855 class ScriptExecutionTest : public web::WebTestWithWebController { 863 class ScriptExecutionTest : public web::WebTestWithWebController {
856 protected: 864 protected:
857 // Calls |executeUserJavaScript:completionHandler:|, waits for script 865 // Calls |executeUserJavaScript:completionHandler:|, waits for script
858 // execution completion, and synchronously returns the result. 866 // execution completion, and synchronously returns the result.
859 id ExecuteUserJavaScript(NSString* java_script, NSError** error) { 867 id ExecuteUserJavaScript(NSString* java_script, NSError** error) {
860 __block id script_result = nil; 868 __block id script_result = nil;
861 __block NSError* script_error = nil; 869 __block NSError* script_error = nil;
862 __block bool script_executed = false; 870 __block bool script_executed = false;
863 [web_controller() 871 [web_controller()
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 web::TestWebStateObserver* observer_ptr = &observer; 947 web::TestWebStateObserver* observer_ptr = &observer;
940 web::SimulateWKWebViewCrash(webView_); 948 web::SimulateWKWebViewCrash(webView_);
941 base::test::ios::WaitUntilCondition(^bool() { 949 base::test::ios::WaitUntilCondition(^bool() {
942 return observer_ptr->render_process_gone_info(); 950 return observer_ptr->render_process_gone_info();
943 }); 951 });
944 EXPECT_EQ(web_state(), observer.render_process_gone_info()->web_state); 952 EXPECT_EQ(web_state(), observer.render_process_gone_info()->web_state);
945 EXPECT_FALSE([web_controller() isViewAlive]); 953 EXPECT_FALSE([web_controller() isViewAlive]);
946 }; 954 };
947 955
948 } // namespace 956 } // namespace
OLDNEW
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698