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

Side by Side Diff: ios/web/navigation/window_location_inttest.mm

Issue 2597133003: Created a test for window.location.reload(). (Closed)
Patch Set: rebase Created 3 years, 11 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 | « no previous file | 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/mac/bind_objc_block.h" 5 #import "base/mac/bind_objc_block.h"
6 #include "base/mac/foundation_util.h" 6 #include "base/mac/foundation_util.h"
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #import "base/strings/sys_string_conversions.h" 8 #import "base/strings/sys_string_conversions.h"
9 #include "base/test/ios/wait_util.h" 9 #include "base/test/ios/wait_util.h"
10 #import "ios/web/public/navigation_item.h" 10 #import "ios/web/public/navigation_item.h"
(...skipping 20 matching lines...) Expand all
31 // present on the page. This string is added to the page in the onload event 31 // present on the page. This string is added to the page in the onload event
32 // and is removed once a button is tapped. Verifying that the onload text is 32 // and is removed once a button is tapped. Verifying that the onload text is
33 // visible after tapping a button is equivalent to checking that a load has 33 // visible after tapping a button is equivalent to checking that a load has
34 // occurred as the result of the button tap. 34 // occurred as the result of the button tap.
35 const char kWindowLocationTestURL[] = 35 const char kWindowLocationTestURL[] =
36 "http://ios/testing/data/http_server_files/window_location.html"; 36 "http://ios/testing/data/http_server_files/window_location.html";
37 37
38 // Button IDs used in the window.location test page. 38 // Button IDs used in the window.location test page.
39 const char kWindowLocationAssignID[] = "location-assign"; 39 const char kWindowLocationAssignID[] = "location-assign";
40 const char kWindowLocationReplaceID[] = "location-replace"; 40 const char kWindowLocationReplaceID[] = "location-replace";
41 const char kWindowLocationReloadID[] = "location-reload";
41 42
42 // JavaScript functions on the window.location test page. 43 // JavaScript functions on the window.location test page.
43 NSString* const kUpdateURLScriptFormat = @"updateUrlToLoadText('%s')"; 44 NSString* const kUpdateURLScriptFormat = @"updateUrlToLoadText('%s')";
44 NSString* const kGetURLScript = @"getUrl()"; 45 NSString* const kGetURLScript = @"getUrl()";
45 NSString* const kOnLoadCheckScript = @"isOnLoadTextVisible()"; 46 NSString* const kOnLoadCheckScript = @"isOnLoadTextVisible()";
46 47
47 // URL of a sample file-based page. 48 // URL of a sample file-based page.
48 const char kSampleFileBasedURL[] = 49 const char kSampleFileBasedURL[] =
49 "http://ios/testing/data/http_server_files/chromium_logo_page.html"; 50 "http://ios/testing/data/http_server_files/chromium_logo_page.html";
50 51
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 SetWindowLocationUrl(unresolvable_url); 180 SetWindowLocationUrl(unresolvable_url);
180 ExecuteBlockAndWaitForLoad(about_blank, ^{ 181 ExecuteBlockAndWaitForLoad(about_blank, ^{
181 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), 182 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(),
182 kWindowLocationReplaceID)); 183 kWindowLocationReplaceID));
183 }); 184 });
184 185
185 // Verify that about:blank was actually loaded. 186 // Verify that about:blank was actually loaded.
186 EXPECT_EQ(about_blank, 187 EXPECT_EQ(about_blank,
187 navigation_manager()->GetLastCommittedItem()->GetURL()); 188 navigation_manager()->GetLastCommittedItem()->GetURL());
188 } 189 }
190
191 // Tests that calling window.location.reload() causes an onload event to occur.
192 TEST_F(WindowLocationTest, WindowLocationReload) {
193 // Tap the window.location.reload() button.
194 ExecuteBlockAndWaitForLoad(window_location_url(), ^{
195 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(),
196 kWindowLocationReloadID));
197 });
198
199 // Verify that |kOnLoadText| is displayed and that no additional
200 // NavigationItems are added.
201 EXPECT_TRUE(IsOnLoadTextVisible());
202 EXPECT_EQ(1, navigation_manager()->GetItemCount());
203 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698