Commit | Line | Data |
---|---|---|
bd70e9dd VM |
1 | commit 03f9a90d8a783f9d1a94935ac298338a1e694380 |
2 | Author: Eric Lawrence <elawrence@chromium.org> | |
3 | Date: Sat Dec 16 04:48:11 2017 +0000 | |
4 | ||
5 | Reland of 'Unescape fragment for display in Omnibox' | |
6 | ||
7 | The original landing broke EGTests for iOS Simulator and Device which | |
8 | were not run by the CQ. This change includes updated EGTests. | |
9 | ||
10 | TBR=pkasting@chromium.org | |
11 | ||
12 | Bug: 789163, 643458 | |
13 | Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs | |
14 | Change-Id: Ie30afcb7bcba5affc7266d72a10b7f8dc0074314 | |
15 | Reviewed-on: https://chromium-review.googlesource.com/830093 | |
16 | Reviewed-by: Eric Lawrence <elawrence@chromium.org> | |
17 | Reviewed-by: Peter Kasting <pkasting@chromium.org> | |
18 | Reviewed-by: Eugene But <eugenebut@chromium.org> | |
19 | Commit-Queue: Eric Lawrence <elawrence@chromium.org> | |
20 | Cr-Commit-Position: refs/heads/master@{#524591} | |
21 | ||
22 | diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc | |
23 | index 6e5dff47f7ec..24f1056d49d5 100644 | |
24 | --- a/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc | |
25 | +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc | |
26 | @@ -462,3 +462,13 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, TextElideStatus) { | |
27 | EXPECT_EQ(omnibox_view_views->GetRenderText()->elide_behavior(), | |
28 | gfx::NO_ELIDE); | |
29 | } | |
30 | + | |
31 | +IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, FragmentUnescapedForDisplay) { | |
32 | + OmniboxView* view = nullptr; | |
33 | + ASSERT_NO_FATAL_FAILURE(GetOmniboxViewForBrowser(browser(), &view)); | |
34 | + ui_test_utils::NavigateToURL(browser(), | |
35 | + GURL("https://www.google.com/#%E2%98%83")); | |
36 | + | |
37 | + EXPECT_EQ(view->GetText(), | |
38 | + base::UTF8ToUTF16("https://www.google.com/#\u2603")); | |
39 | +} | |
40 | diff --git a/components/url_formatter/elide_url_unittest.cc b/components/url_formatter/elide_url_unittest.cc | |
41 | index 5e0384af72a2..d403ce065f45 100644 | |
42 | --- a/components/url_formatter/elide_url_unittest.cc | |
43 | +++ b/components/url_formatter/elide_url_unittest.cc | |
44 | @@ -347,15 +347,16 @@ TEST(TextEliderTest, TestElisionSpecialCases) { | |
45 | kEllipsisStr + "berkeley.edu:4430/" + kEllipsisStr + "/arbitfilename"}, | |
46 | ||
47 | // Unescaping. | |
48 | - {"http://www/%E4%BD%A0%E5%A5%BD?q=%E4%BD%A0%E5%A5%BD#\xe4\xbd\xa0", | |
49 | - "www/\xe4\xbd\xa0\xe5\xa5\xbd?q=\xe4\xbd\xa0\xe5\xa5\xbd#" + | |
50 | + {"http://www/%E4%BD%A0%E5%A5%BD?" | |
51 | + "q=%E4%BD%A0%E5%A5%BD#\xe4\xbd\xa0\xe4\xbd\xa0\xe4\xbd\xa0", | |
52 | + "www/\xe4\xbd\xa0\xe5\xa5\xbd?q=\xe4\xbd\xa0\xe5\xa5\xbd#\xe4\xbd\xa0" + | |
53 | kEllipsisStr}, | |
54 | ||
55 | // Invalid unescaping for path. The ref will always be valid UTF-8. We | |
56 | // don't bother to do too many edge cases, since these are handled by the | |
57 | // escaper unittest. | |
58 | {"http://www/%E4%A0%E5%A5%BD?q=%E4%BD%A0%E5%A5%BD#\xe4\xbd\xa0", | |
59 | - "www/%E4%A0%E5%A5%BD?q=\xe4\xbd\xa0\xe5\xa5\xbd#" + kEllipsisStr}, | |
60 | + "www/%E4%A0%E5%A5%BD?q=\xe4\xbd\xa0\xe5\xa5\xbd#\xe4\xbd\xa0"}, | |
61 | }; | |
62 | ||
63 | RunElisionTest(testcases); | |
64 | diff --git a/components/url_formatter/url_formatter.cc b/components/url_formatter/url_formatter.cc | |
65 | index d5c0d314a5de..c422e3d98a72 100644 | |
66 | --- a/components/url_formatter/url_formatter.cc | |
67 | +++ b/components/url_formatter/url_formatter.cc | |
68 | @@ -586,11 +586,10 @@ base::string16 FormatUrlWithAdjustments( | |
69 | NonHostComponentTransform(unescape_rules), | |
70 | &url_string, &new_parsed->query, adjustments); | |
71 | ||
72 | - // Ref. This is valid, unescaped UTF-8, so we can just convert. | |
73 | if (parsed.ref.is_valid()) | |
74 | url_string.push_back('#'); | |
75 | AppendFormattedComponent(spec, parsed.ref, | |
76 | - NonHostComponentTransform(net::UnescapeRule::NONE), | |
77 | + NonHostComponentTransform(unescape_rules), | |
78 | &url_string, &new_parsed->ref, adjustments); | |
79 | } | |
80 | ||
81 | diff --git a/components/url_formatter/url_formatter_unittest.cc b/components/url_formatter/url_formatter_unittest.cc | |
82 | index 6fd3ece50f7d..5aaf31105a43 100644 | |
83 | --- a/components/url_formatter/url_formatter_unittest.cc | |
84 | +++ b/components/url_formatter/url_formatter_unittest.cc | |
85 | @@ -828,7 +828,7 @@ TEST(UrlFormatterTest, FormatUrl) { | |
86 | ||
87 | {"With a port number and a reference", | |
88 | "http://www.google.com:8080/#\xE3\x82\xB0", default_format_type, | |
89 | - net::UnescapeRule::NORMAL, L"http://www.google.com:8080/#%E3%82%B0", 7}, | |
90 | + net::UnescapeRule::NORMAL, L"http://www.google.com:8080/#\x30B0", 7}, | |
91 | ||
92 | // -------- IDN tests -------- | |
93 | {"Japanese IDN with ja", "http://xn--l8jvb1ey91xtjb.jp", | |
94 | @@ -1119,7 +1119,7 @@ TEST(UrlFormatterTest, FormatUrlParsed) { | |
95 | kFormatUrlOmitNothing, net::UnescapeRule::NORMAL, &parsed, | |
96 | nullptr, nullptr); | |
97 | EXPECT_EQ(WideToUTF16(L"http://\x30B0:\x30FC@\x30B0\x30FC\x30B0\x30EB.jp:8080" | |
98 | - L"/\x30B0/?q=\x30B0#%E3%82%B0"), | |
99 | + L"/\x30B0/?q=\x30B0#\x30B0"), | |
100 | formatted); | |
101 | EXPECT_EQ(WideToUTF16(L"\x30B0"), | |
102 | formatted.substr(parsed.username.begin, parsed.username.len)); | |
103 | @@ -1133,7 +1133,7 @@ TEST(UrlFormatterTest, FormatUrlParsed) { | |
104 | formatted.substr(parsed.path.begin, parsed.path.len)); | |
105 | EXPECT_EQ(WideToUTF16(L"q=\x30B0"), | |
106 | formatted.substr(parsed.query.begin, parsed.query.len)); | |
107 | - EXPECT_EQ(WideToUTF16(L"%E3%82%B0"), | |
108 | + EXPECT_EQ(WideToUTF16(L"\x30B0"), | |
109 | formatted.substr(parsed.ref.begin, parsed.ref.len)); | |
110 | ||
111 | // Omit_username_password + unescape case. | |
112 | @@ -1143,7 +1143,7 @@ TEST(UrlFormatterTest, FormatUrlParsed) { | |
113 | kFormatUrlOmitUsernamePassword, net::UnescapeRule::NORMAL, | |
114 | &parsed, nullptr, nullptr); | |
115 | EXPECT_EQ(WideToUTF16(L"http://\x30B0\x30FC\x30B0\x30EB.jp:8080" | |
116 | - L"/\x30B0/?q=\x30B0#%E3%82%B0"), | |
117 | + L"/\x30B0/?q=\x30B0#\x30B0"), | |
118 | formatted); | |
119 | EXPECT_FALSE(parsed.username.is_valid()); | |
120 | EXPECT_FALSE(parsed.password.is_valid()); | |
121 | @@ -1155,7 +1155,7 @@ TEST(UrlFormatterTest, FormatUrlParsed) { | |
122 | formatted.substr(parsed.path.begin, parsed.path.len)); | |
123 | EXPECT_EQ(WideToUTF16(L"q=\x30B0"), | |
124 | formatted.substr(parsed.query.begin, parsed.query.len)); | |
125 | - EXPECT_EQ(WideToUTF16(L"%E3%82%B0"), | |
126 | + EXPECT_EQ(WideToUTF16(L"\x30B0"), | |
127 | formatted.substr(parsed.ref.begin, parsed.ref.len)); | |
128 | ||
129 | // View-source case. | |
130 | @@ -1389,9 +1389,12 @@ TEST(UrlFormatterTest, FormatUrlWithOffsets) { | |
131 | kFormatUrlOmitNothing, net::UnescapeRule::SPACES, unescape_offsets); | |
132 | ||
133 | const size_t ref_offsets[] = { | |
134 | - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, | |
135 | - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, | |
136 | - 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49}; | |
137 | + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, | |
138 | + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, | |
139 | + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, | |
140 | + 30, 31, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, | |
141 | + 32, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 33}; | |
142 | + | |
143 | // Unescape to "http://www.google.com/foo.html#\x30B0\x30B0z". | |
144 | CheckAdjustedOffsets("http://www.google.com/foo.html#%E3%82%B0%E3%82%B0z", | |
145 | kFormatUrlOmitNothing, net::UnescapeRule::NORMAL, | |
146 | diff --git a/ios/chrome/browser/web/push_and_replace_state_navigation_egtest.mm b/ios/chrome/browser/web/push_and_replace_state_navigation_egtest.mm | |
147 | index b67f2a08d0a0..431ad368f07d 100644 | |
148 | --- a/ios/chrome/browser/web/push_and_replace_state_navigation_egtest.mm | |
149 | +++ b/ios/chrome/browser/web/push_and_replace_state_navigation_egtest.mm | |
150 | @@ -59,40 +59,42 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace"; | |
151 | // Push 3 URLs. Verify that the URL changed and the status was updated. | |
152 | [ChromeEarlGrey tapWebViewElementWithID:@"pushStateHashWithObject"]; | |
153 | [self assertStatusText:@"pushStateHashWithObject" | |
154 | - withURL:pushStateHashWithObjectURL | |
155 | + withOmniboxText:pushStateHashWithObjectURL.GetContent() | |
156 | pageLoaded:NO]; | |
157 | ||
158 | [ChromeEarlGrey tapWebViewElementWithID:@"pushStateRootPath"]; | |
159 | [self assertStatusText:@"pushStateRootPath" | |
160 | - withURL:pushStateRootPathURL | |
161 | + withOmniboxText:pushStateRootPathURL.GetContent() | |
162 | pageLoaded:NO]; | |
163 | ||
164 | [ChromeEarlGrey tapWebViewElementWithID:@"pushStatePathSpace"]; | |
165 | [self assertStatusText:@"pushStatePathSpace" | |
166 | - withURL:pushStatePathSpaceURL | |
167 | + withOmniboxText:pushStatePathSpaceURL.GetContent() | |
168 | pageLoaded:NO]; | |
169 | ||
170 | // Go back and check that the page doesn't load and the status text is updated | |
171 | // by the popstate event. | |
172 | [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; | |
173 | [self assertStatusText:@"pushStateRootPath" | |
174 | - withURL:pushStateRootPathURL | |
175 | + withOmniboxText:pushStateRootPathURL.GetContent() | |
176 | pageLoaded:NO]; | |
177 | ||
178 | [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; | |
179 | [self assertStatusText:@"pushStateHashWithObject" | |
180 | - withURL:pushStateHashWithObjectURL | |
181 | + withOmniboxText:pushStateHashWithObjectURL.GetContent() | |
182 | pageLoaded:NO]; | |
183 | ||
184 | [ChromeEarlGrey tapWebViewElementWithID:@"goBack"]; | |
185 | const GURL historyTestURL = web::test::HttpServer::MakeUrl(kHistoryTestUrl); | |
186 | - [self assertStatusText:NULL withURL:historyTestURL pageLoaded:NO]; | |
187 | + [self assertStatusText:nil | |
188 | + withOmniboxText:historyTestURL.GetContent() | |
189 | + pageLoaded:NO]; | |
190 | ||
191 | // Go forward 2 pages and check that the page doesn't load and the status text | |
192 | // is updated by the popstate event. | |
193 | [ChromeEarlGrey tapWebViewElementWithID:@"goForward2"]; | |
194 | [self assertStatusText:@"pushStateRootPath" | |
195 | - withURL:pushStateRootPathURL | |
196 | + withOmniboxText:pushStateRootPathURL.GetContent() | |
197 | pageLoaded:NO]; | |
198 | } | |
199 | ||
200 | @@ -108,7 +110,7 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace"; | |
201 | web::test::HttpServer::MakeUrl(kReplaceStateHashWithObjectURL); | |
202 | [ChromeEarlGrey tapWebViewElementWithID:@"replaceStateHashWithObject"]; | |
203 | [self assertStatusText:@"replaceStateHashWithObject" | |
204 | - withURL:replaceStateHashWithObjectURL | |
205 | + withOmniboxText:replaceStateHashWithObjectURL.GetContent() | |
206 | pageLoaded:NO]; | |
207 | ||
208 | [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; | |
209 | @@ -119,7 +121,7 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace"; | |
210 | [[EarlGrey selectElementWithMatcher:ForwardButton()] | |
211 | performAction:grey_tap()]; | |
212 | [self assertStatusText:@"replaceStateHashWithObject" | |
213 | - withURL:replaceStateHashWithObjectURL | |
214 | + withOmniboxText:replaceStateHashWithObjectURL.GetContent() | |
215 | pageLoaded:YES]; | |
216 | ||
217 | // Push URL then replace it. Do this twice. | |
218 | @@ -127,44 +129,44 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace"; | |
219 | web::test::HttpServer::MakeUrl(kPushStateHashStringURL); | |
220 | [ChromeEarlGrey tapWebViewElementWithID:@"pushStateHashString"]; | |
221 | [self assertStatusText:@"pushStateHashString" | |
222 | - withURL:pushStateHashStringURL | |
223 | + withOmniboxText:pushStateHashStringURL.GetContent() | |
224 | pageLoaded:NO]; | |
225 | ||
226 | const GURL replaceStateHashStringURL = | |
227 | web::test::HttpServer::MakeUrl(kReplaceStateHashStringURL); | |
228 | [ChromeEarlGrey tapWebViewElementWithID:@"replaceStateHashString"]; | |
229 | [self assertStatusText:@"replaceStateHashString" | |
230 | - withURL:replaceStateHashStringURL | |
231 | + withOmniboxText:replaceStateHashStringURL.GetContent() | |
232 | pageLoaded:NO]; | |
233 | ||
234 | const GURL pushStatePathURL = | |
235 | web::test::HttpServer::MakeUrl(kPushStatePathURL); | |
236 | [ChromeEarlGrey tapWebViewElementWithID:@"pushStatePath"]; | |
237 | [self assertStatusText:@"pushStatePath" | |
238 | - withURL:pushStatePathURL | |
239 | + withOmniboxText:pushStatePathURL.GetContent() | |
240 | pageLoaded:NO]; | |
241 | ||
242 | const GURL replaceStateRootPathSpaceURL = | |
243 | web::test::HttpServer::MakeUrl(kReplaceStateRootPathSpaceURL); | |
244 | [ChromeEarlGrey tapWebViewElementWithID:@"replaceStateRootPathSpace"]; | |
245 | [self assertStatusText:@"replaceStateRootPathSpace" | |
246 | - withURL:replaceStateRootPathSpaceURL | |
247 | + withOmniboxText:replaceStateRootPathSpaceURL.GetContent() | |
248 | pageLoaded:NO]; | |
249 | ||
250 | // Go back and check URLs. | |
251 | [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; | |
252 | [self assertStatusText:@"replaceStateHashString" | |
253 | - withURL:replaceStateHashStringURL | |
254 | + withOmniboxText:replaceStateHashStringURL.GetContent() | |
255 | pageLoaded:NO]; | |
256 | [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; | |
257 | [self assertStatusText:@"replaceStateHashWithObject" | |
258 | - withURL:replaceStateHashWithObjectURL | |
259 | + withOmniboxText:replaceStateHashWithObjectURL.GetContent() | |
260 | pageLoaded:NO]; | |
261 | ||
262 | // Go forward and check URL. | |
263 | [ChromeEarlGrey tapWebViewElementWithID:@"goForward2"]; | |
264 | [self assertStatusText:@"replaceStateRootPathSpace" | |
265 | - withURL:replaceStateRootPathSpaceURL | |
266 | + withOmniboxText:replaceStateRootPathSpaceURL.GetContent() | |
267 | pageLoaded:NO]; | |
268 | } | |
269 | ||
270 | @@ -180,11 +182,11 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace"; | |
271 | web::test::HttpServer::MakeUrl(kPushStateHashStringURL); | |
272 | [ChromeEarlGrey tapWebViewElementWithID:@"pushStateHashString"]; | |
273 | [self assertStatusText:@"pushStateHashString" | |
274 | - withURL:pushStateHashStringURL | |
275 | + withOmniboxText:pushStateHashStringURL.GetContent() | |
276 | pageLoaded:NO]; | |
277 | [ChromeEarlGrey tapWebViewElementWithID:@"pushStateHashString"]; | |
278 | [self assertStatusText:@"pushStateHashString" | |
279 | - withURL:pushStateHashStringURL | |
280 | + withOmniboxText:pushStateHashStringURL.GetContent() | |
281 | pageLoaded:NO]; | |
282 | ||
283 | // Load a non-pushed URL. | |
284 | @@ -194,7 +196,7 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace"; | |
285 | [ChromeEarlGrey loadURL:historyTestURL]; | |
286 | [ChromeEarlGrey tapWebViewElementWithID:@"pushStateHashString"]; | |
287 | [self assertStatusText:@"pushStateHashString" | |
288 | - withURL:pushStateHashStringURL | |
289 | + withOmniboxText:pushStateHashStringURL.GetContent() | |
290 | pageLoaded:NO]; | |
291 | ||
292 | // At this point the history looks like this: | |
293 | @@ -202,38 +204,54 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace"; | |
294 | ||
295 | // Go back (to second history.html) and verify page did not load. | |
296 | [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; | |
297 | - [self assertStatusText:nil withURL:historyTestURL pageLoaded:NO]; | |
298 | + [self assertStatusText:nil | |
299 | + withOmniboxText:historyTestURL.GetContent() | |
300 | + pageLoaded:NO]; | |
301 | ||
302 | // Go back twice (to second #string) and verify page did load. | |
303 | [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; | |
304 | [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; | |
305 | - [self assertStatusText:nil withURL:pushStateHashStringURL pageLoaded:YES]; | |
306 | + [self assertStatusText:nil | |
307 | + withOmniboxText:pushStateHashStringURL.GetContent() | |
308 | + pageLoaded:YES]; | |
309 | ||
310 | // Go back once (to first #string) and verify page did not load. | |
311 | [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; | |
312 | [self assertStatusText:@"pushStateHashString" | |
313 | - withURL:pushStateHashStringURL | |
314 | + withOmniboxText:pushStateHashStringURL.GetContent() | |
315 | pageLoaded:NO]; | |
316 | ||
317 | // Go forward 4 entries at once (to third #string) and verify page did load. | |
318 | [ChromeEarlGrey tapWebViewElementWithID:@"goForward4"]; | |
319 | ||
320 | - [self assertStatusText:nil withURL:pushStateHashStringURL pageLoaded:YES]; | |
321 | + [self assertStatusText:nil | |
322 | + withOmniboxText:pushStateHashStringURL.GetContent() | |
323 | + pageLoaded:YES]; | |
324 | ||
325 | // Go back 4 entries at once (to first #string) and verify page did load. | |
326 | [ChromeEarlGrey tapWebViewElementWithID:@"goBack4"]; | |
327 | ||
328 | - [self assertStatusText:NULL withURL:pushStateHashStringURL pageLoaded:YES]; | |
329 | + [self assertStatusText:nil | |
330 | + withOmniboxText:pushStateHashStringURL.GetContent() | |
331 | + pageLoaded:YES]; | |
332 | } | |
333 | ||
334 | // Tests calling pushState with unicode characters. | |
335 | - (void)testHtml5HistoryPushUnicodeCharacters { | |
336 | - const GURL pushStateUnicodeURLEncoded = web::test::HttpServer::MakeUrl( | |
337 | - "http://ios/testing/data/http_server_files/" | |
338 | - "history.html#unicode%E1%84%91"); | |
339 | - const GURL pushStateUnicode2URLEncoded = web::test::HttpServer::MakeUrl( | |
340 | - "http://ios/testing/data/http_server_files/" | |
341 | - "history.html#unicode2%E2%88%A2"); | |
342 | + // The GURL object %-escapes Unicode characters in the URL's fragment, | |
343 | + // but the omnibox decodes them back to Unicode for display. | |
344 | + std::string pushStateUnicode = | |
345 | + web::test::HttpServer::MakeUrl( | |
346 | + "http://ios/testing/data/http_server_files/" | |
347 | + "history.html#unicode") | |
348 | + .GetContent() + | |
349 | + "\xe1\x84\x91"; | |
350 | + std::string pushStateUnicode2 = | |
351 | + web::test::HttpServer::MakeUrl( | |
352 | + "http://ios/testing/data/http_server_files/" | |
353 | + "history.html#unicode2") | |
354 | + .GetContent() + | |
355 | + "\xe2\x88\xa2"; | |
356 | const char pushStateUnicodeLabel[] = "Action: pushStateUnicodeá„‘"; | |
357 | NSString* pushStateUnicodeStatus = @"pushStateUnicodeá„‘"; | |
358 | const char pushStateUnicode2Label[] = "Action: pushStateUnicode2∢"; | |
359 | @@ -242,21 +260,16 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace"; | |
360 | web::test::SetUpFileBasedHttpServer(); | |
361 | [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kHistoryTestUrl)]; | |
362 | ||
363 | - // TODO(crbug.com/643458): The fact that the URL shows %-escaped is due to | |
364 | - // NSURL escaping to make UIWebView/JS happy. See if it's possible to | |
365 | - // represent differently such that it displays unescaped. | |
366 | // Do 2 push states with unicode characters. | |
367 | [ChromeEarlGrey tapWebViewElementWithID:@"pushStateUnicode"]; | |
368 | [[EarlGrey | |
369 | - selectElementWithMatcher:chrome_test_util::OmniboxText( | |
370 | - pushStateUnicodeURLEncoded.GetContent())] | |
371 | + selectElementWithMatcher:chrome_test_util::OmniboxText(pushStateUnicode)] | |
372 | assertWithMatcher:grey_notNil()]; | |
373 | [ChromeEarlGrey waitForWebViewContainingText:pushStateUnicodeLabel]; | |
374 | ||
375 | [ChromeEarlGrey tapWebViewElementWithID:@"pushStateUnicode2"]; | |
376 | [[EarlGrey | |
377 | - selectElementWithMatcher:chrome_test_util::OmniboxText( | |
378 | - pushStateUnicode2URLEncoded.GetContent())] | |
379 | + selectElementWithMatcher:chrome_test_util::OmniboxText(pushStateUnicode2)] | |
380 | assertWithMatcher:grey_notNil()]; | |
381 | [ChromeEarlGrey waitForWebViewContainingText:pushStateUnicode2Label]; | |
382 | ||
383 | @@ -266,18 +279,18 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace"; | |
384 | [ChromeEarlGrey tapWebViewElementWithID:@"pushStatePath"]; | |
385 | ||
386 | [self assertStatusText:@"pushStatePath" | |
387 | - withURL:pushStatePathURL | |
388 | + withOmniboxText:pushStatePathURL.GetContent() | |
389 | pageLoaded:NO]; | |
390 | ||
391 | // Go back and check the unicode in the URL and status. | |
392 | [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; | |
393 | [self assertStatusText:pushStateUnicode2Status | |
394 | - withURL:pushStateUnicode2URLEncoded | |
395 | + withOmniboxText:pushStateUnicode2 | |
396 | pageLoaded:NO]; | |
397 | ||
398 | [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()]; | |
399 | [self assertStatusText:pushStateUnicodeStatus | |
400 | - withURL:pushStateUnicodeURLEncoded | |
401 | + withOmniboxText:pushStateUnicode | |
402 | pageLoaded:NO]; | |
403 | } | |
404 | ||
405 | @@ -321,10 +334,11 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace"; | |
406 | ||
407 | #pragma mark - Utility methods | |
408 | ||
409 | -// Assert that status text |status| is displayed in the webview, that "onloaded" | |
410 | -// text is displayed if pageLoaded is YES, and that the URL is as expected. | |
411 | +// Assert that status text |status|, if non-nil, is displayed in the webview, | |
412 | +// that the omnibox text is as expected, and that "onload" text is displayed if | |
413 | +// pageLoaded is YES. | |
414 | - (void)assertStatusText:(NSString*)status | |
415 | - withURL:(const GURL&)urlToVerify | |
416 | + withOmniboxText:(const std::string&)omniboxText | |
417 | pageLoaded:(BOOL)pageLoaded { | |
418 | if (pageLoaded) { | |
419 | [ChromeEarlGrey waitForWebViewContainingText:"onload"]; | |
420 | @@ -332,14 +346,14 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace"; | |
421 | [ChromeEarlGrey waitForWebViewNotContainingText:"onload"]; | |
422 | } | |
423 | ||
424 | - if (status != NULL) { | |
425 | + if (status != nil) { | |
426 | NSString* statusLabel = [NSString stringWithFormat:@"Action: %@", status]; | |
427 | [ChromeEarlGrey | |
428 | waitForWebViewContainingText:base::SysNSStringToUTF8(statusLabel)]; | |
429 | } | |
430 | ||
431 | - [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( | |
432 | - urlToVerify.GetContent())] | |
433 | + [[EarlGrey | |
434 | + selectElementWithMatcher:chrome_test_util::OmniboxText(omniboxText)] | |
435 | assertWithMatcher:grey_notNil()]; | |
436 | } | |
437 |