summarylogtreecommitdiffstats
path: root/chromium-omnibox-unescape-fragment.patch
blob: 59ab04003022264cc20334dc357a64ab768b87fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
commit 03f9a90d8a783f9d1a94935ac298338a1e694380
Author: Eric Lawrence <elawrence@chromium.org>
Date:   Sat Dec 16 04:48:11 2017 +0000

    Reland of 'Unescape fragment for display in Omnibox'
    
    The original landing broke EGTests for iOS Simulator and Device which
    were not run by the CQ. This change includes updated EGTests.
    
    TBR=pkasting@chromium.org
    
    Bug: 789163, 643458
    Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
    Change-Id: Ie30afcb7bcba5affc7266d72a10b7f8dc0074314
    Reviewed-on: https://chromium-review.googlesource.com/830093
    Reviewed-by: Eric Lawrence <elawrence@chromium.org>
    Reviewed-by: Peter Kasting <pkasting@chromium.org>
    Reviewed-by: Eugene But <eugenebut@chromium.org>
    Commit-Queue: Eric Lawrence <elawrence@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#524591}

diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc
index 6e5dff47f7ec..24f1056d49d5 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc
@@ -462,3 +462,13 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, TextElideStatus) {
   EXPECT_EQ(omnibox_view_views->GetRenderText()->elide_behavior(),
             gfx::NO_ELIDE);
 }
+ 
+IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, FragmentUnescapedForDisplay) {
+  OmniboxView* view = nullptr;
+  ASSERT_NO_FATAL_FAILURE(GetOmniboxViewForBrowser(browser(), &view));
+  ui_test_utils::NavigateToURL(browser(),
+                               GURL("https://www.google.com/#%E2%98%83"));
+
+  EXPECT_EQ(view->GetText(),
+            base::UTF8ToUTF16("https://www.google.com/#\u2603"));
+}
diff --git a/components/url_formatter/elide_url_unittest.cc b/components/url_formatter/elide_url_unittest.cc
index 5e0384af72a2..d403ce065f45 100644
--- a/components/url_formatter/elide_url_unittest.cc
+++ b/components/url_formatter/elide_url_unittest.cc
@@ -347,15 +347,16 @@ TEST(TextEliderTest, TestElisionSpecialCases) {
        kEllipsisStr + "berkeley.edu:4430/" + kEllipsisStr + "/arbitfilename"},
 
       // Unescaping.
-      {"http://www/%E4%BD%A0%E5%A5%BD?q=%E4%BD%A0%E5%A5%BD#\xe4\xbd\xa0",
-       "www/\xe4\xbd\xa0\xe5\xa5\xbd?q=\xe4\xbd\xa0\xe5\xa5\xbd#" +
+      {"http://www/%E4%BD%A0%E5%A5%BD?"
+       "q=%E4%BD%A0%E5%A5%BD#\xe4\xbd\xa0\xe4\xbd\xa0\xe4\xbd\xa0",
+       "www/\xe4\xbd\xa0\xe5\xa5\xbd?q=\xe4\xbd\xa0\xe5\xa5\xbd#\xe4\xbd\xa0" +
            kEllipsisStr},
 
       // Invalid unescaping for path. The ref will always be valid UTF-8. We
       // don't bother to do too many edge cases, since these are handled by the
       // escaper unittest.
       {"http://www/%E4%A0%E5%A5%BD?q=%E4%BD%A0%E5%A5%BD#\xe4\xbd\xa0",
-       "www/%E4%A0%E5%A5%BD?q=\xe4\xbd\xa0\xe5\xa5\xbd#" + kEllipsisStr},
+       "www/%E4%A0%E5%A5%BD?q=\xe4\xbd\xa0\xe5\xa5\xbd#\xe4\xbd\xa0"},
   };
 
   RunElisionTest(testcases);
diff --git a/components/url_formatter/url_formatter.cc b/components/url_formatter/url_formatter.cc
index d5c0d314a5de..c422e3d98a72 100644
--- a/components/url_formatter/url_formatter.cc
+++ b/components/url_formatter/url_formatter.cc
@@ -586,11 +586,10 @@ base::string16 FormatUrlWithAdjustments(
                              NonHostComponentTransform(unescape_rules),
                              &url_string, &new_parsed->query, adjustments);
 
-    // Ref.  This is valid, unescaped UTF-8, so we can just convert.
     if (parsed.ref.is_valid())
       url_string.push_back('#');
     AppendFormattedComponent(spec, parsed.ref,
-                             NonHostComponentTransform(net::UnescapeRule::NONE),
+                             NonHostComponentTransform(unescape_rules),
                              &url_string, &new_parsed->ref, adjustments);
   }
 
diff --git a/components/url_formatter/url_formatter_unittest.cc b/components/url_formatter/url_formatter_unittest.cc
index 6fd3ece50f7d..5aaf31105a43 100644
--- a/components/url_formatter/url_formatter_unittest.cc
+++ b/components/url_formatter/url_formatter_unittest.cc
@@ -828,7 +828,7 @@ TEST(UrlFormatterTest, FormatUrl) {
 
       {"With a port number and a reference",
        "http://www.google.com:8080/#\xE3\x82\xB0", default_format_type,
-       net::UnescapeRule::NORMAL, L"http://www.google.com:8080/#%E3%82%B0", 7},
+       net::UnescapeRule::NORMAL, L"http://www.google.com:8080/#\x30B0", 7},
 
       // -------- IDN tests --------
       {"Japanese IDN with ja", "http://xn--l8jvb1ey91xtjb.jp",
@@ -1119,7 +1119,7 @@ TEST(UrlFormatterTest, FormatUrlParsed) {
                 kFormatUrlOmitNothing, net::UnescapeRule::NORMAL, &parsed,
                 nullptr, nullptr);
   EXPECT_EQ(WideToUTF16(L"http://\x30B0:\x30FC@\x30B0\x30FC\x30B0\x30EB.jp:8080"
-                        L"/\x30B0/?q=\x30B0#%E3%82%B0"),
+                        L"/\x30B0/?q=\x30B0#\x30B0"),
             formatted);
   EXPECT_EQ(WideToUTF16(L"\x30B0"),
       formatted.substr(parsed.username.begin, parsed.username.len));
@@ -1133,7 +1133,7 @@ TEST(UrlFormatterTest, FormatUrlParsed) {
       formatted.substr(parsed.path.begin, parsed.path.len));
   EXPECT_EQ(WideToUTF16(L"q=\x30B0"),
       formatted.substr(parsed.query.begin, parsed.query.len));
-  EXPECT_EQ(WideToUTF16(L"%E3%82%B0"),
+  EXPECT_EQ(WideToUTF16(L"\x30B0"),
             formatted.substr(parsed.ref.begin, parsed.ref.len));
 
   // Omit_username_password + unescape case.
@@ -1143,7 +1143,7 @@ TEST(UrlFormatterTest, FormatUrlParsed) {
                 kFormatUrlOmitUsernamePassword, net::UnescapeRule::NORMAL,
                 &parsed, nullptr, nullptr);
   EXPECT_EQ(WideToUTF16(L"http://\x30B0\x30FC\x30B0\x30EB.jp:8080"
-                        L"/\x30B0/?q=\x30B0#%E3%82%B0"),
+                        L"/\x30B0/?q=\x30B0#\x30B0"),
             formatted);
   EXPECT_FALSE(parsed.username.is_valid());
   EXPECT_FALSE(parsed.password.is_valid());
@@ -1155,7 +1155,7 @@ TEST(UrlFormatterTest, FormatUrlParsed) {
       formatted.substr(parsed.path.begin, parsed.path.len));
   EXPECT_EQ(WideToUTF16(L"q=\x30B0"),
       formatted.substr(parsed.query.begin, parsed.query.len));
-  EXPECT_EQ(WideToUTF16(L"%E3%82%B0"),
+  EXPECT_EQ(WideToUTF16(L"\x30B0"),
             formatted.substr(parsed.ref.begin, parsed.ref.len));
 
   // View-source case.
@@ -1389,9 +1389,12 @@ TEST(UrlFormatterTest, FormatUrlWithOffsets) {
       kFormatUrlOmitNothing, net::UnescapeRule::SPACES, unescape_offsets);
 
   const size_t ref_offsets[] = {
-      0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15, 16,
-      17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
-      34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49};
+      0,  1,     2,     3,     4,     5,     6,     7,     8,     9,
+      10, 11,    12,    13,    14,    15,    16,    17,    18,    19,
+      20, 21,    22,    23,    24,    25,    26,    27,    28,    29,
+      30, 31,    kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos,
+      32, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 33};
+
   // Unescape to "http://www.google.com/foo.html#\x30B0\x30B0z".
   CheckAdjustedOffsets("http://www.google.com/foo.html#%E3%82%B0%E3%82%B0z",
                        kFormatUrlOmitNothing, net::UnescapeRule::NORMAL,
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
index b67f2a08d0a0..431ad368f07d 100644
--- a/ios/chrome/browser/web/push_and_replace_state_navigation_egtest.mm
+++ b/ios/chrome/browser/web/push_and_replace_state_navigation_egtest.mm
@@ -59,40 +59,42 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace";
   // Push 3 URLs. Verify that the URL changed and the status was updated.
   [ChromeEarlGrey tapWebViewElementWithID:@"pushStateHashWithObject"];
   [self assertStatusText:@"pushStateHashWithObject"
-                 withURL:pushStateHashWithObjectURL
+         withOmniboxText:pushStateHashWithObjectURL.GetContent()
               pageLoaded:NO];
 
   [ChromeEarlGrey tapWebViewElementWithID:@"pushStateRootPath"];
   [self assertStatusText:@"pushStateRootPath"
-                 withURL:pushStateRootPathURL
+         withOmniboxText:pushStateRootPathURL.GetContent()
               pageLoaded:NO];
 
   [ChromeEarlGrey tapWebViewElementWithID:@"pushStatePathSpace"];
   [self assertStatusText:@"pushStatePathSpace"
-                 withURL:pushStatePathSpaceURL
+         withOmniboxText:pushStatePathSpaceURL.GetContent()
               pageLoaded:NO];
 
   // Go back and check that the page doesn't load and the status text is updated
   // by the popstate event.
   [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()];
   [self assertStatusText:@"pushStateRootPath"
-                 withURL:pushStateRootPathURL
+         withOmniboxText:pushStateRootPathURL.GetContent()
               pageLoaded:NO];
 
   [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()];
   [self assertStatusText:@"pushStateHashWithObject"
-                 withURL:pushStateHashWithObjectURL
+         withOmniboxText:pushStateHashWithObjectURL.GetContent()
               pageLoaded:NO];
 
   [ChromeEarlGrey tapWebViewElementWithID:@"goBack"];
   const GURL historyTestURL = web::test::HttpServer::MakeUrl(kHistoryTestUrl);
-  [self assertStatusText:NULL withURL:historyTestURL pageLoaded:NO];
+  [self assertStatusText:nil
+         withOmniboxText:historyTestURL.GetContent()
+              pageLoaded:NO];
 
   // Go forward 2 pages and check that the page doesn't load and the status text
   // is updated by the popstate event.
   [ChromeEarlGrey tapWebViewElementWithID:@"goForward2"];
   [self assertStatusText:@"pushStateRootPath"
-                 withURL:pushStateRootPathURL
+         withOmniboxText:pushStateRootPathURL.GetContent()
               pageLoaded:NO];
 }
 
@@ -108,7 +110,7 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace";
       web::test::HttpServer::MakeUrl(kReplaceStateHashWithObjectURL);
   [ChromeEarlGrey tapWebViewElementWithID:@"replaceStateHashWithObject"];
   [self assertStatusText:@"replaceStateHashWithObject"
-                 withURL:replaceStateHashWithObjectURL
+         withOmniboxText:replaceStateHashWithObjectURL.GetContent()
               pageLoaded:NO];
 
   [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()];
@@ -119,7 +121,7 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace";
   [[EarlGrey selectElementWithMatcher:ForwardButton()]
       performAction:grey_tap()];
   [self assertStatusText:@"replaceStateHashWithObject"
-                 withURL:replaceStateHashWithObjectURL
+         withOmniboxText:replaceStateHashWithObjectURL.GetContent()
               pageLoaded:YES];
 
   // Push URL then replace it. Do this twice.
@@ -127,44 +129,44 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace";
       web::test::HttpServer::MakeUrl(kPushStateHashStringURL);
   [ChromeEarlGrey tapWebViewElementWithID:@"pushStateHashString"];
   [self assertStatusText:@"pushStateHashString"
-                 withURL:pushStateHashStringURL
+         withOmniboxText:pushStateHashStringURL.GetContent()
               pageLoaded:NO];
 
   const GURL replaceStateHashStringURL =
       web::test::HttpServer::MakeUrl(kReplaceStateHashStringURL);
   [ChromeEarlGrey tapWebViewElementWithID:@"replaceStateHashString"];
   [self assertStatusText:@"replaceStateHashString"
-                 withURL:replaceStateHashStringURL
+         withOmniboxText:replaceStateHashStringURL.GetContent()
               pageLoaded:NO];
 
   const GURL pushStatePathURL =
       web::test::HttpServer::MakeUrl(kPushStatePathURL);
   [ChromeEarlGrey tapWebViewElementWithID:@"pushStatePath"];
   [self assertStatusText:@"pushStatePath"
-                 withURL:pushStatePathURL
+         withOmniboxText:pushStatePathURL.GetContent()
               pageLoaded:NO];
 
   const GURL replaceStateRootPathSpaceURL =
       web::test::HttpServer::MakeUrl(kReplaceStateRootPathSpaceURL);
   [ChromeEarlGrey tapWebViewElementWithID:@"replaceStateRootPathSpace"];
   [self assertStatusText:@"replaceStateRootPathSpace"
-                 withURL:replaceStateRootPathSpaceURL
+         withOmniboxText:replaceStateRootPathSpaceURL.GetContent()
               pageLoaded:NO];
 
   // Go back and check URLs.
   [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()];
   [self assertStatusText:@"replaceStateHashString"
-                 withURL:replaceStateHashStringURL
+         withOmniboxText:replaceStateHashStringURL.GetContent()
               pageLoaded:NO];
   [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()];
   [self assertStatusText:@"replaceStateHashWithObject"
-                 withURL:replaceStateHashWithObjectURL
+         withOmniboxText:replaceStateHashWithObjectURL.GetContent()
               pageLoaded:NO];
 
   // Go forward and check URL.
   [ChromeEarlGrey tapWebViewElementWithID:@"goForward2"];
   [self assertStatusText:@"replaceStateRootPathSpace"
-                 withURL:replaceStateRootPathSpaceURL
+         withOmniboxText:replaceStateRootPathSpaceURL.GetContent()
               pageLoaded:NO];
 }
 
@@ -180,11 +182,11 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace";
       web::test::HttpServer::MakeUrl(kPushStateHashStringURL);
   [ChromeEarlGrey tapWebViewElementWithID:@"pushStateHashString"];
   [self assertStatusText:@"pushStateHashString"
-                 withURL:pushStateHashStringURL
+         withOmniboxText:pushStateHashStringURL.GetContent()
               pageLoaded:NO];
   [ChromeEarlGrey tapWebViewElementWithID:@"pushStateHashString"];
   [self assertStatusText:@"pushStateHashString"
-                 withURL:pushStateHashStringURL
+         withOmniboxText:pushStateHashStringURL.GetContent()
               pageLoaded:NO];
 
   // Load a non-pushed URL.
@@ -194,7 +196,7 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace";
   [ChromeEarlGrey loadURL:historyTestURL];
   [ChromeEarlGrey tapWebViewElementWithID:@"pushStateHashString"];
   [self assertStatusText:@"pushStateHashString"
-                 withURL:pushStateHashStringURL
+         withOmniboxText:pushStateHashStringURL.GetContent()
               pageLoaded:NO];
 
   // At this point the history looks like this:
@@ -202,38 +204,54 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace";
 
   // Go back (to second history.html) and verify page did not load.
   [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()];
-  [self assertStatusText:nil withURL:historyTestURL pageLoaded:NO];
+  [self assertStatusText:nil
+         withOmniboxText:historyTestURL.GetContent()
+              pageLoaded:NO];
 
   // Go back twice (to second #string) and verify page did load.
   [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()];
   [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()];
-  [self assertStatusText:nil withURL:pushStateHashStringURL pageLoaded:YES];
+  [self assertStatusText:nil
+         withOmniboxText:pushStateHashStringURL.GetContent()
+              pageLoaded:YES];
 
   // Go back once (to first #string) and verify page did not load.
   [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()];
   [self assertStatusText:@"pushStateHashString"
-                 withURL:pushStateHashStringURL
+         withOmniboxText:pushStateHashStringURL.GetContent()
               pageLoaded:NO];
 
   // Go forward 4 entries at once (to third #string) and verify page did load.
   [ChromeEarlGrey tapWebViewElementWithID:@"goForward4"];
 
-  [self assertStatusText:nil withURL:pushStateHashStringURL pageLoaded:YES];
+  [self assertStatusText:nil
+         withOmniboxText:pushStateHashStringURL.GetContent()
+              pageLoaded:YES];
 
   // Go back 4 entries at once (to first #string) and verify page did load.
   [ChromeEarlGrey tapWebViewElementWithID:@"goBack4"];
 
-  [self assertStatusText:NULL withURL:pushStateHashStringURL pageLoaded:YES];
+  [self assertStatusText:nil
+         withOmniboxText:pushStateHashStringURL.GetContent()
+              pageLoaded:YES];
 }
 
 // Tests calling pushState with unicode characters.
 - (void)testHtml5HistoryPushUnicodeCharacters {
-  const GURL pushStateUnicodeURLEncoded = web::test::HttpServer::MakeUrl(
-      "http://ios/testing/data/http_server_files/"
-      "history.html#unicode%E1%84%91");
-  const GURL pushStateUnicode2URLEncoded = web::test::HttpServer::MakeUrl(
-      "http://ios/testing/data/http_server_files/"
-      "history.html#unicode2%E2%88%A2");
+  // The GURL object %-escapes Unicode characters in the URL's fragment,
+  // but the omnibox decodes them back to Unicode for display.
+  std::string pushStateUnicode =
+      web::test::HttpServer::MakeUrl(
+          "http://ios/testing/data/http_server_files/"
+          "history.html#unicode")
+          .GetContent() +
+      "\xe1\x84\x91";
+  std::string pushStateUnicode2 =
+      web::test::HttpServer::MakeUrl(
+          "http://ios/testing/data/http_server_files/"
+          "history.html#unicode2")
+          .GetContent() +
+      "\xe2\x88\xa2";
   const char pushStateUnicodeLabel[] = "Action: pushStateUnicodeá„‘";
   NSString* pushStateUnicodeStatus = @"pushStateUnicodeá„‘";
   const char pushStateUnicode2Label[] = "Action: pushStateUnicode2∢";
@@ -242,21 +260,16 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace";
   web::test::SetUpFileBasedHttpServer();
   [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kHistoryTestUrl)];
 
-  // TODO(crbug.com/643458): The fact that the URL shows %-escaped is due to
-  // NSURL escaping to make UIWebView/JS happy. See if it's possible to
-  // represent differently such that it displays unescaped.
   // Do 2 push states with unicode characters.
   [ChromeEarlGrey tapWebViewElementWithID:@"pushStateUnicode"];
   [[EarlGrey
-      selectElementWithMatcher:chrome_test_util::OmniboxText(
-                                   pushStateUnicodeURLEncoded.GetContent())]
+      selectElementWithMatcher:chrome_test_util::OmniboxText(pushStateUnicode)]
       assertWithMatcher:grey_notNil()];
   [ChromeEarlGrey waitForWebViewContainingText:pushStateUnicodeLabel];
 
   [ChromeEarlGrey tapWebViewElementWithID:@"pushStateUnicode2"];
   [[EarlGrey
-      selectElementWithMatcher:chrome_test_util::OmniboxText(
-                                   pushStateUnicode2URLEncoded.GetContent())]
+      selectElementWithMatcher:chrome_test_util::OmniboxText(pushStateUnicode2)]
       assertWithMatcher:grey_notNil()];
   [ChromeEarlGrey waitForWebViewContainingText:pushStateUnicode2Label];
 
@@ -266,18 +279,18 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace";
   [ChromeEarlGrey tapWebViewElementWithID:@"pushStatePath"];
 
   [self assertStatusText:@"pushStatePath"
-                 withURL:pushStatePathURL
+         withOmniboxText:pushStatePathURL.GetContent()
               pageLoaded:NO];
 
   // Go back and check the unicode in the URL and status.
   [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()];
   [self assertStatusText:pushStateUnicode2Status
-                 withURL:pushStateUnicode2URLEncoded
+         withOmniboxText:pushStateUnicode2
               pageLoaded:NO];
 
   [[EarlGrey selectElementWithMatcher:BackButton()] performAction:grey_tap()];
   [self assertStatusText:pushStateUnicodeStatus
-                 withURL:pushStateUnicodeURLEncoded
+         withOmniboxText:pushStateUnicode
               pageLoaded:NO];
 }
 
@@ -321,10 +334,11 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace";
 
 #pragma mark - Utility methods
 
-// Assert that status text |status| is displayed in the webview, that "onloaded"
-// text is displayed if pageLoaded is YES, and that the URL is as expected.
+// Assert that status text |status|, if non-nil, is displayed in the webview,
+// that the omnibox text is as expected, and that "onload" text is displayed if
+// pageLoaded is YES.
 - (void)assertStatusText:(NSString*)status
-                 withURL:(const GURL&)urlToVerify
+         withOmniboxText:(const std::string&)omniboxText
               pageLoaded:(BOOL)pageLoaded {
   if (pageLoaded) {
     [ChromeEarlGrey waitForWebViewContainingText:"onload"];
@@ -332,14 +346,14 @@ const char* kReplaceStateRootPathSpaceURL = "http://ios/rep lace";
     [ChromeEarlGrey waitForWebViewNotContainingText:"onload"];
   }
 
-  if (status != NULL) {
+  if (status != nil) {
     NSString* statusLabel = [NSString stringWithFormat:@"Action: %@", status];
     [ChromeEarlGrey
         waitForWebViewContainingText:base::SysNSStringToUTF8(statusLabel)];
   }
 
-  [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
-                                          urlToVerify.GetContent())]
+  [[EarlGrey
+      selectElementWithMatcher:chrome_test_util::OmniboxText(omniboxText)]
       assertWithMatcher:grey_notNil()];
 }