OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 } | 128 } |
129 | 129 |
130 // Navigates from a page with a given |referrer_policy| and checks that the | 130 // Navigates from a page with a given |referrer_policy| and checks that the |
131 // reported referrer matches the expectation. | 131 // reported referrer matches the expectation. |
132 // Parameters: | 132 // Parameters: |
133 // referrer_policy: The referrer policy to test. | 133 // referrer_policy: The referrer policy to test. |
134 // start_protocol: The protocol the test should start on. | 134 // start_protocol: The protocol the test should start on. |
135 // link_type: The link type that is used to trigger the navigation. | 135 // link_type: The link type that is used to trigger the navigation. |
136 // redirect: Whether the link target should redirect and how. | 136 // redirect: Whether the link target should redirect and how. |
137 // disposition: The disposition for the navigation. | 137 // disposition: The disposition for the navigation. |
138 // button: If not WebMouseEvent::Button::NoButton, click on the | 138 // button: If not WebMouseEvent::ButtonNone, click on the |
139 // link with the specified mouse button. | 139 // link with the specified mouse button. |
140 // expected_referrer: The kind of referrer to expect. | 140 // expected_referrer: The kind of referrer to expect. |
141 // expected_referrer_policy: The expected referrer policy of the activity. | 141 // expected_referrer_policy: The expected referrer policy of the activity. |
142 // | 142 // |
143 // Returns: | 143 // Returns: |
144 // The URL of the first page navigated to. | 144 // The URL of the first page navigated to. |
145 GURL RunReferrerTest(const blink::WebReferrerPolicy referrer_policy, | 145 GURL RunReferrerTest(const blink::WebReferrerPolicy referrer_policy, |
146 StartOnProtocol start_protocol, | 146 StartOnProtocol start_protocol, |
147 LinkType link_type, | 147 LinkType link_type, |
148 RedirectType redirect, | 148 RedirectType redirect, |
149 WindowOpenDisposition disposition, | 149 WindowOpenDisposition disposition, |
150 blink::WebMouseEvent::Button button, | 150 blink::WebMouseEvent::Button button, |
151 ExpectedReferrer expected_referrer, | 151 ExpectedReferrer expected_referrer, |
152 blink::WebReferrerPolicy expected_referrer_policy) { | 152 blink::WebReferrerPolicy expected_referrer_policy) { |
153 std::string relative_url = | 153 std::string relative_url = |
154 std::string("referrer_policy/referrer-policy-start.html?") + "policy=" + | 154 std::string("referrer_policy/referrer-policy-start.html?") + "policy=" + |
155 ReferrerPolicyToString(referrer_policy) + "&redirect=" + | 155 ReferrerPolicyToString(referrer_policy) + "&redirect=" + |
156 RedirectTypeToString(redirect) + "&link=" + | 156 RedirectTypeToString(redirect) + "&link=" + |
157 (button == blink::WebMouseEvent::Button::NoButton ? "false" : "true") + | 157 (button == blink::WebMouseEvent::ButtonNone ? "false" : "true") + |
158 "&target=" + (link_type == LINK_WITH_TARGET_BLANK ? "_blank" : ""); | 158 "&target=" + (link_type == LINK_WITH_TARGET_BLANK ? "_blank" : ""); |
159 | 159 |
160 const GURL start_url = | 160 const GURL start_url = |
161 (start_protocol == START_ON_HTTPS) | 161 (start_protocol == START_ON_HTTPS) |
162 ? net::URLRequestMockHTTPJob::GetMockHttpsUrl(relative_url) | 162 ? net::URLRequestMockHTTPJob::GetMockHttpsUrl(relative_url) |
163 : net::URLRequestMockHTTPJob::GetMockUrl(relative_url); | 163 : net::URLRequestMockHTTPJob::GetMockUrl(relative_url); |
164 | 164 |
165 ui_test_utils::WindowedTabAddedNotificationObserver tab_added_observer( | 165 ui_test_utils::WindowedTabAddedNotificationObserver tab_added_observer( |
166 content::NotificationService::AllSources()); | 166 content::NotificationService::AllSources()); |
167 | 167 |
168 base::string16 expected_title = | 168 base::string16 expected_title = |
169 GetExpectedTitle(start_url, expected_referrer); | 169 GetExpectedTitle(start_url, expected_referrer); |
170 content::WebContents* tab = | 170 content::WebContents* tab = |
171 browser()->tab_strip_model()->GetActiveWebContents(); | 171 browser()->tab_strip_model()->GetActiveWebContents(); |
172 content::TitleWatcher title_watcher(tab, expected_title); | 172 content::TitleWatcher title_watcher(tab, expected_title); |
173 | 173 |
174 // Watch for all possible outcomes to avoid timeouts if something breaks. | 174 // Watch for all possible outcomes to avoid timeouts if something breaks. |
175 AddAllPossibleTitles(start_url, &title_watcher); | 175 AddAllPossibleTitles(start_url, &title_watcher); |
176 | 176 |
177 ui_test_utils::NavigateToURL(browser(), start_url); | 177 ui_test_utils::NavigateToURL(browser(), start_url); |
178 | 178 |
179 if (button != blink::WebMouseEvent::Button::NoButton) { | 179 if (button != blink::WebMouseEvent::ButtonNone) { |
180 blink::WebMouseEvent mouse_event; | 180 blink::WebMouseEvent mouse_event; |
181 mouse_event.type = blink::WebInputEvent::MouseDown; | 181 mouse_event.type = blink::WebInputEvent::MouseDown; |
182 mouse_event.button = button; | 182 mouse_event.button = button; |
183 mouse_event.x = 15; | 183 mouse_event.x = 15; |
184 mouse_event.y = 15; | 184 mouse_event.y = 15; |
185 mouse_event.clickCount = 1; | 185 mouse_event.clickCount = 1; |
186 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); | 186 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); |
187 mouse_event.type = blink::WebInputEvent::MouseUp; | 187 mouse_event.type = blink::WebInputEvent::MouseUp; |
188 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); | 188 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); |
189 } | 189 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // | 237 // |
238 // Some tests are marked as FAILS, see http://crbug.com/124750 | 238 // Some tests are marked as FAILS, see http://crbug.com/124750 |
239 | 239 |
240 // Content initiated navigation, from HTTP to HTTP. | 240 // Content initiated navigation, from HTTP to HTTP. |
241 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Origin) { | 241 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Origin) { |
242 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 242 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
243 START_ON_HTTP, | 243 START_ON_HTTP, |
244 REGULAR_LINK, | 244 REGULAR_LINK, |
245 NO_REDIRECT, | 245 NO_REDIRECT, |
246 CURRENT_TAB, | 246 CURRENT_TAB, |
247 blink::WebMouseEvent::Button::NoButton, | 247 blink::WebMouseEvent::ButtonNone, |
248 EXPECT_ORIGIN_AS_REFERRER); | 248 EXPECT_ORIGIN_AS_REFERRER); |
249 } | 249 } |
250 | 250 |
251 // Content initiated navigation, from HTTPS to HTTP. | 251 // Content initiated navigation, from HTTPS to HTTP. |
252 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsDefault) { | 252 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsDefault) { |
253 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 253 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
254 START_ON_HTTPS, | 254 START_ON_HTTPS, |
255 REGULAR_LINK, | 255 REGULAR_LINK, |
256 NO_REDIRECT, | 256 NO_REDIRECT, |
257 CURRENT_TAB, | 257 CURRENT_TAB, |
258 blink::WebMouseEvent::Button::NoButton, | 258 blink::WebMouseEvent::ButtonNone, |
259 EXPECT_ORIGIN_AS_REFERRER); | 259 EXPECT_ORIGIN_AS_REFERRER); |
260 } | 260 } |
261 | 261 |
262 // User initiated navigation, from HTTP to HTTP. | 262 // User initiated navigation, from HTTP to HTTP. |
263 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, LeftClickOrigin) { | 263 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, LeftClickOrigin) { |
264 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 264 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
265 START_ON_HTTP, | 265 START_ON_HTTP, |
266 REGULAR_LINK, | 266 REGULAR_LINK, |
267 NO_REDIRECT, | 267 NO_REDIRECT, |
268 CURRENT_TAB, | 268 CURRENT_TAB, |
269 blink::WebMouseEvent::Button::Left, | 269 blink::WebMouseEvent::ButtonLeft, |
270 EXPECT_ORIGIN_AS_REFERRER); | 270 EXPECT_ORIGIN_AS_REFERRER); |
271 } | 271 } |
272 | 272 |
273 // User initiated navigation, from HTTPS to HTTP. | 273 // User initiated navigation, from HTTPS to HTTP. |
274 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsLeftClickOrigin) { | 274 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsLeftClickOrigin) { |
275 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 275 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
276 START_ON_HTTPS, | 276 START_ON_HTTPS, |
277 REGULAR_LINK, | 277 REGULAR_LINK, |
278 NO_REDIRECT, | 278 NO_REDIRECT, |
279 CURRENT_TAB, | 279 CURRENT_TAB, |
280 blink::WebMouseEvent::Button::Left, | 280 blink::WebMouseEvent::ButtonLeft, |
281 EXPECT_ORIGIN_AS_REFERRER); | 281 EXPECT_ORIGIN_AS_REFERRER); |
282 } | 282 } |
283 | 283 |
284 // User initiated navigation, middle click, from HTTP to HTTP. | 284 // User initiated navigation, middle click, from HTTP to HTTP. |
285 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickOrigin) { | 285 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickOrigin) { |
286 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 286 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
287 START_ON_HTTP, | 287 START_ON_HTTP, |
288 REGULAR_LINK, | 288 REGULAR_LINK, |
289 NO_REDIRECT, | 289 NO_REDIRECT, |
290 NEW_BACKGROUND_TAB, | 290 NEW_BACKGROUND_TAB, |
291 blink::WebMouseEvent::Button::Middle, | 291 blink::WebMouseEvent::ButtonMiddle, |
292 EXPECT_ORIGIN_AS_REFERRER); | 292 EXPECT_ORIGIN_AS_REFERRER); |
293 } | 293 } |
294 | 294 |
295 // User initiated navigation, middle click, from HTTPS to HTTP. | 295 // User initiated navigation, middle click, from HTTPS to HTTP. |
296 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickOrigin) { | 296 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickOrigin) { |
297 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 297 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
298 START_ON_HTTPS, | 298 START_ON_HTTPS, |
299 REGULAR_LINK, | 299 REGULAR_LINK, |
300 NO_REDIRECT, | 300 NO_REDIRECT, |
301 NEW_BACKGROUND_TAB, | 301 NEW_BACKGROUND_TAB, |
302 blink::WebMouseEvent::Button::Middle, | 302 blink::WebMouseEvent::ButtonMiddle, |
303 EXPECT_ORIGIN_AS_REFERRER); | 303 EXPECT_ORIGIN_AS_REFERRER); |
304 } | 304 } |
305 | 305 |
306 // User initiated navigation, target blank, from HTTP to HTTP. | 306 // User initiated navigation, target blank, from HTTP to HTTP. |
307 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, TargetBlankOrigin) { | 307 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, TargetBlankOrigin) { |
308 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 308 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
309 START_ON_HTTP, | 309 START_ON_HTTP, |
310 LINK_WITH_TARGET_BLANK, | 310 LINK_WITH_TARGET_BLANK, |
311 NO_REDIRECT, | 311 NO_REDIRECT, |
312 NEW_FOREGROUND_TAB, | 312 NEW_FOREGROUND_TAB, |
313 blink::WebMouseEvent::Button::Left, | 313 blink::WebMouseEvent::ButtonLeft, |
314 EXPECT_ORIGIN_AS_REFERRER); | 314 EXPECT_ORIGIN_AS_REFERRER); |
315 } | 315 } |
316 | 316 |
317 // User initiated navigation, target blank, from HTTPS to HTTP. | 317 // User initiated navigation, target blank, from HTTPS to HTTP. |
318 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsTargetBlankOrigin) { | 318 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsTargetBlankOrigin) { |
319 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 319 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
320 START_ON_HTTPS, | 320 START_ON_HTTPS, |
321 LINK_WITH_TARGET_BLANK, | 321 LINK_WITH_TARGET_BLANK, |
322 NO_REDIRECT, | 322 NO_REDIRECT, |
323 NEW_FOREGROUND_TAB, | 323 NEW_FOREGROUND_TAB, |
324 blink::WebMouseEvent::Button::Left, | 324 blink::WebMouseEvent::ButtonLeft, |
325 EXPECT_ORIGIN_AS_REFERRER); | 325 EXPECT_ORIGIN_AS_REFERRER); |
326 } | 326 } |
327 | 327 |
328 // User initiated navigation, middle click, target blank, from HTTP to HTTP. | 328 // User initiated navigation, middle click, target blank, from HTTP to HTTP. |
329 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickTargetBlankOrigin) { | 329 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickTargetBlankOrigin) { |
330 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 330 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
331 START_ON_HTTP, | 331 START_ON_HTTP, |
332 LINK_WITH_TARGET_BLANK, | 332 LINK_WITH_TARGET_BLANK, |
333 NO_REDIRECT, | 333 NO_REDIRECT, |
334 NEW_FOREGROUND_TAB, | 334 NEW_FOREGROUND_TAB, |
335 blink::WebMouseEvent::Button::Middle, | 335 blink::WebMouseEvent::ButtonMiddle, |
336 EXPECT_ORIGIN_AS_REFERRER); | 336 EXPECT_ORIGIN_AS_REFERRER); |
337 } | 337 } |
338 | 338 |
339 // User initiated navigation, middle click, target blank, from HTTPS to HTTP. | 339 // User initiated navigation, middle click, target blank, from HTTPS to HTTP. |
340 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickTargetBlankOrigin) { | 340 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickTargetBlankOrigin) { |
341 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 341 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
342 START_ON_HTTPS, | 342 START_ON_HTTPS, |
343 LINK_WITH_TARGET_BLANK, | 343 LINK_WITH_TARGET_BLANK, |
344 NO_REDIRECT, | 344 NO_REDIRECT, |
345 NEW_FOREGROUND_TAB, | 345 NEW_FOREGROUND_TAB, |
346 blink::WebMouseEvent::Button::Middle, | 346 blink::WebMouseEvent::ButtonMiddle, |
347 EXPECT_ORIGIN_AS_REFERRER); | 347 EXPECT_ORIGIN_AS_REFERRER); |
348 } | 348 } |
349 | 349 |
350 // Context menu, from HTTP to HTTP. | 350 // Context menu, from HTTP to HTTP. |
351 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, ContextMenuOrigin) { | 351 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, ContextMenuOrigin) { |
352 ContextMenuNotificationObserver context_menu_observer( | 352 ContextMenuNotificationObserver context_menu_observer( |
353 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 353 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
354 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 354 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
355 START_ON_HTTP, | 355 START_ON_HTTP, |
356 REGULAR_LINK, | 356 REGULAR_LINK, |
357 NO_REDIRECT, | 357 NO_REDIRECT, |
358 NEW_FOREGROUND_TAB, | 358 NEW_FOREGROUND_TAB, |
359 blink::WebMouseEvent::Button::Right, | 359 blink::WebMouseEvent::ButtonRight, |
360 EXPECT_ORIGIN_AS_REFERRER); | 360 EXPECT_ORIGIN_AS_REFERRER); |
361 } | 361 } |
362 | 362 |
363 // Context menu, from HTTPS to HTTP. | 363 // Context menu, from HTTPS to HTTP. |
364 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsContextMenuOrigin) { | 364 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsContextMenuOrigin) { |
365 ContextMenuNotificationObserver context_menu_observer( | 365 ContextMenuNotificationObserver context_menu_observer( |
366 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 366 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
367 RunReferrerTest(blink::WebReferrerPolicyOrigin, | 367 RunReferrerTest(blink::WebReferrerPolicyOrigin, |
368 START_ON_HTTPS, | 368 START_ON_HTTPS, |
369 REGULAR_LINK, | 369 REGULAR_LINK, |
370 NO_REDIRECT, | 370 NO_REDIRECT, |
371 NEW_FOREGROUND_TAB, | 371 NEW_FOREGROUND_TAB, |
372 blink::WebMouseEvent::Button::Right, | 372 blink::WebMouseEvent::ButtonRight, |
373 EXPECT_ORIGIN_AS_REFERRER); | 373 EXPECT_ORIGIN_AS_REFERRER); |
374 } | 374 } |
375 | 375 |
376 // Content initiated navigation, from HTTP to HTTP via server redirect. | 376 // Content initiated navigation, from HTTP to HTTP via server redirect. |
377 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Redirect) { | 377 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Redirect) { |
378 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, | 378 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, |
379 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, | 379 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, |
380 blink::WebMouseEvent::Button::NoButton, | 380 blink::WebMouseEvent::ButtonNone, EXPECT_ORIGIN_AS_REFERRER); |
381 EXPECT_ORIGIN_AS_REFERRER); | |
382 } | 381 } |
383 | 382 |
384 // Content initiated navigation, from HTTPS to HTTP via server redirect. | 383 // Content initiated navigation, from HTTPS to HTTP via server redirect. |
385 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsRedirect) { | 384 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsRedirect) { |
386 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, | 385 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
387 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, | 386 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, |
388 blink::WebMouseEvent::Button::NoButton, | 387 blink::WebMouseEvent::ButtonNone, EXPECT_ORIGIN_AS_REFERRER); |
389 EXPECT_ORIGIN_AS_REFERRER); | |
390 } | 388 } |
391 | 389 |
392 // User initiated navigation, from HTTP to HTTP via server redirect. | 390 // User initiated navigation, from HTTP to HTTP via server redirect. |
393 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, LeftClickRedirect) { | 391 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, LeftClickRedirect) { |
394 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, | 392 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, |
395 SERVER_REDIRECT_FROM_HTTP_TO_HTTP, CURRENT_TAB, | 393 SERVER_REDIRECT_FROM_HTTP_TO_HTTP, CURRENT_TAB, |
396 blink::WebMouseEvent::Button::Left, | 394 blink::WebMouseEvent::ButtonLeft, EXPECT_ORIGIN_AS_REFERRER); |
397 EXPECT_ORIGIN_AS_REFERRER); | |
398 } | 395 } |
399 | 396 |
400 // User initiated navigation, from HTTPS to HTTP via server redirect. | 397 // User initiated navigation, from HTTPS to HTTP via server redirect. |
401 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsLeftClickRedirect) { | 398 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsLeftClickRedirect) { |
402 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, | 399 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
403 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, | 400 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, |
404 blink::WebMouseEvent::Button::Left, | 401 blink::WebMouseEvent::ButtonLeft, EXPECT_ORIGIN_AS_REFERRER); |
405 EXPECT_ORIGIN_AS_REFERRER); | |
406 } | 402 } |
407 | 403 |
408 // User initiated navigation, middle click, from HTTP to HTTP via server | 404 // User initiated navigation, middle click, from HTTP to HTTP via server |
409 // redirect. | 405 // redirect. |
410 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickRedirect) { | 406 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickRedirect) { |
411 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, | 407 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, |
412 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_BACKGROUND_TAB, | 408 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_BACKGROUND_TAB, |
413 blink::WebMouseEvent::Button::Middle, | 409 blink::WebMouseEvent::ButtonMiddle, |
414 EXPECT_ORIGIN_AS_REFERRER); | 410 EXPECT_ORIGIN_AS_REFERRER); |
415 } | 411 } |
416 | 412 |
417 // User initiated navigation, middle click, from HTTPS to HTTP via server | 413 // User initiated navigation, middle click, from HTTPS to HTTP via server |
418 // redirect. | 414 // redirect. |
419 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickRedirect) { | 415 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsMiddleClickRedirect) { |
420 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, | 416 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
421 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_BACKGROUND_TAB, | 417 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_BACKGROUND_TAB, |
422 blink::WebMouseEvent::Button::Middle, | 418 blink::WebMouseEvent::ButtonMiddle, |
423 EXPECT_ORIGIN_AS_REFERRER); | 419 EXPECT_ORIGIN_AS_REFERRER); |
424 } | 420 } |
425 | 421 |
426 // User initiated navigation, target blank, from HTTP to HTTP via server | 422 // User initiated navigation, target blank, from HTTP to HTTP via server |
427 // redirect. | 423 // redirect. |
428 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, TargetBlankRedirect) { | 424 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, TargetBlankRedirect) { |
429 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, | 425 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, |
430 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, | 426 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, |
431 NEW_FOREGROUND_TAB, blink::WebMouseEvent::Button::Left, | 427 NEW_FOREGROUND_TAB, blink::WebMouseEvent::ButtonLeft, |
432 EXPECT_ORIGIN_AS_REFERRER); | 428 EXPECT_ORIGIN_AS_REFERRER); |
433 } | 429 } |
434 | 430 |
435 // User initiated navigation, target blank, from HTTPS to HTTP via server | 431 // User initiated navigation, target blank, from HTTPS to HTTP via server |
436 // redirect. | 432 // redirect. |
437 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsTargetBlankRedirect) { | 433 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsTargetBlankRedirect) { |
438 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, | 434 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, |
439 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, | 435 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, |
440 NEW_FOREGROUND_TAB, blink::WebMouseEvent::Button::Left, | 436 NEW_FOREGROUND_TAB, blink::WebMouseEvent::ButtonLeft, |
441 EXPECT_ORIGIN_AS_REFERRER); | 437 EXPECT_ORIGIN_AS_REFERRER); |
442 } | 438 } |
443 | 439 |
444 // User initiated navigation, middle click, target blank, from HTTP to HTTP via | 440 // User initiated navigation, middle click, target blank, from HTTP to HTTP via |
445 // server redirect. | 441 // server redirect. |
446 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickTargetBlankRedirect) { | 442 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MiddleClickTargetBlankRedirect) { |
447 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, | 443 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, |
448 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, | 444 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, |
449 NEW_FOREGROUND_TAB, blink::WebMouseEvent::Button::Middle, | 445 NEW_FOREGROUND_TAB, blink::WebMouseEvent::ButtonMiddle, |
450 EXPECT_ORIGIN_AS_REFERRER); | 446 EXPECT_ORIGIN_AS_REFERRER); |
451 } | 447 } |
452 | 448 |
453 // User initiated navigation, middle click, target blank, from HTTPS to HTTP | 449 // User initiated navigation, middle click, target blank, from HTTPS to HTTP |
454 // via server redirect. | 450 // via server redirect. |
455 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, | 451 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, |
456 HttpsMiddleClickTargetBlankRedirect) { | 452 HttpsMiddleClickTargetBlankRedirect) { |
457 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, | 453 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, |
458 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, | 454 LINK_WITH_TARGET_BLANK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, |
459 NEW_FOREGROUND_TAB, blink::WebMouseEvent::Button::Middle, | 455 NEW_FOREGROUND_TAB, blink::WebMouseEvent::ButtonMiddle, |
460 EXPECT_ORIGIN_AS_REFERRER); | 456 EXPECT_ORIGIN_AS_REFERRER); |
461 } | 457 } |
462 | 458 |
463 // Context menu, from HTTP to HTTP via server redirect. | 459 // Context menu, from HTTP to HTTP via server redirect. |
464 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, ContextMenuRedirect) { | 460 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, ContextMenuRedirect) { |
465 ContextMenuNotificationObserver context_menu_observer( | 461 ContextMenuNotificationObserver context_menu_observer( |
466 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 462 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
467 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, | 463 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTP, REGULAR_LINK, |
468 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_FOREGROUND_TAB, | 464 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_FOREGROUND_TAB, |
469 blink::WebMouseEvent::Button::Right, | 465 blink::WebMouseEvent::ButtonRight, EXPECT_ORIGIN_AS_REFERRER); |
470 EXPECT_ORIGIN_AS_REFERRER); | |
471 } | 466 } |
472 | 467 |
473 // Context menu, from HTTPS to HTTP via server redirect. | 468 // Context menu, from HTTPS to HTTP via server redirect. |
474 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsContextMenuRedirect) { | 469 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsContextMenuRedirect) { |
475 ContextMenuNotificationObserver context_menu_observer( | 470 ContextMenuNotificationObserver context_menu_observer( |
476 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); | 471 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); |
477 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, | 472 RunReferrerTest(blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
478 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_FOREGROUND_TAB, | 473 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, NEW_FOREGROUND_TAB, |
479 blink::WebMouseEvent::Button::Right, | 474 blink::WebMouseEvent::ButtonRight, EXPECT_ORIGIN_AS_REFERRER); |
480 EXPECT_ORIGIN_AS_REFERRER); | |
481 } | 475 } |
482 | 476 |
483 // Tests history navigation actions: Navigate from A to B with a referrer | 477 // Tests history navigation actions: Navigate from A to B with a referrer |
484 // policy, then navigate to C, back to B, and reload. | 478 // policy, then navigate to C, back to B, and reload. |
485 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, History) { | 479 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, History) { |
486 // Navigate from A to B. | 480 // Navigate from A to B. |
487 GURL start_url = RunReferrerTest( | 481 GURL start_url = RunReferrerTest( |
488 blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, | 482 blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
489 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, | 483 SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, |
490 blink::WebMouseEvent::Button::Left, EXPECT_ORIGIN_AS_REFERRER); | 484 blink::WebMouseEvent::ButtonLeft, EXPECT_ORIGIN_AS_REFERRER); |
491 | 485 |
492 // Navigate to C. | 486 // Navigate to C. |
493 ui_test_utils::NavigateToURL( | 487 ui_test_utils::NavigateToURL( |
494 browser(), net::URLRequestMockHTTPJob::GetMockUrl(std::string())); | 488 browser(), net::URLRequestMockHTTPJob::GetMockUrl(std::string())); |
495 | 489 |
496 base::string16 expected_title = | 490 base::string16 expected_title = |
497 GetExpectedTitle(start_url, EXPECT_ORIGIN_AS_REFERRER); | 491 GetExpectedTitle(start_url, EXPECT_ORIGIN_AS_REFERRER); |
498 content::WebContents* tab = | 492 content::WebContents* tab = |
499 browser()->tab_strip_model()->GetActiveWebContents(); | 493 browser()->tab_strip_model()->GetActiveWebContents(); |
500 std::unique_ptr<content::TitleWatcher> title_watcher( | 494 std::unique_ptr<content::TitleWatcher> title_watcher( |
(...skipping 20 matching lines...) Expand all Loading... |
521 chrome::ReloadBypassingCache(browser(), CURRENT_TAB); | 515 chrome::ReloadBypassingCache(browser(), CURRENT_TAB); |
522 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); | 516 EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle()); |
523 } | 517 } |
524 | 518 |
525 // Tests that reloading a site for "request tablet version" correctly clears | 519 // Tests that reloading a site for "request tablet version" correctly clears |
526 // the referrer. | 520 // the referrer. |
527 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, RequestTabletSite) { | 521 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, RequestTabletSite) { |
528 GURL start_url = RunReferrerTest( | 522 GURL start_url = RunReferrerTest( |
529 blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, | 523 blink::WebReferrerPolicyOrigin, START_ON_HTTPS, REGULAR_LINK, |
530 SERVER_REDIRECT_FROM_HTTP_TO_HTTP, CURRENT_TAB, | 524 SERVER_REDIRECT_FROM_HTTP_TO_HTTP, CURRENT_TAB, |
531 blink::WebMouseEvent::Button::Left, EXPECT_ORIGIN_AS_REFERRER); | 525 blink::WebMouseEvent::ButtonLeft, EXPECT_ORIGIN_AS_REFERRER); |
532 | 526 |
533 base::string16 expected_title = | 527 base::string16 expected_title = |
534 GetExpectedTitle(start_url, EXPECT_EMPTY_REFERRER); | 528 GetExpectedTitle(start_url, EXPECT_EMPTY_REFERRER); |
535 content::WebContents* tab = | 529 content::WebContents* tab = |
536 browser()->tab_strip_model()->GetActiveWebContents(); | 530 browser()->tab_strip_model()->GetActiveWebContents(); |
537 content::TitleWatcher title_watcher(tab, expected_title); | 531 content::TitleWatcher title_watcher(tab, expected_title); |
538 | 532 |
539 // Watch for all possible outcomes to avoid timeouts if something breaks. | 533 // Watch for all possible outcomes to avoid timeouts if something breaks. |
540 AddAllPossibleTitles(start_url, &title_watcher); | 534 AddAllPossibleTitles(start_url, &title_watcher); |
541 | 535 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 "referrer_policy/referrer-policy-log.html").spec(), | 591 "referrer_policy/referrer-policy-log.html").spec(), |
598 title); | 592 title); |
599 } | 593 } |
600 | 594 |
601 // Origin When Cross-Origin | 595 // Origin When Cross-Origin |
602 | 596 |
603 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, | 597 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, |
604 HttpLeftClickHTTPSRedirectToHTTPOriginWhenCrossOrigin) { | 598 HttpLeftClickHTTPSRedirectToHTTPOriginWhenCrossOrigin) { |
605 RunReferrerTest(blink::WebReferrerPolicyOriginWhenCrossOrigin, START_ON_HTTPS, | 599 RunReferrerTest(blink::WebReferrerPolicyOriginWhenCrossOrigin, START_ON_HTTPS, |
606 REGULAR_LINK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, | 600 REGULAR_LINK, SERVER_REDIRECT_FROM_HTTPS_TO_HTTP, CURRENT_TAB, |
607 blink::WebMouseEvent::Button::Left, | 601 blink::WebMouseEvent::ButtonLeft, EXPECT_ORIGIN_AS_REFERRER); |
608 EXPECT_ORIGIN_AS_REFERRER); | |
609 } | 602 } |
610 | 603 |
611 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, | 604 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, |
612 HttpLeftClickRedirectToHTTPSOriginWhenCrossOrigin) { | 605 HttpLeftClickRedirectToHTTPSOriginWhenCrossOrigin) { |
613 RunReferrerTest(blink::WebReferrerPolicyOriginWhenCrossOrigin, START_ON_HTTP, | 606 RunReferrerTest(blink::WebReferrerPolicyOriginWhenCrossOrigin, START_ON_HTTP, |
614 REGULAR_LINK, SERVER_REDIRECT_FROM_HTTP_TO_HTTPS, CURRENT_TAB, | 607 REGULAR_LINK, SERVER_REDIRECT_FROM_HTTP_TO_HTTPS, CURRENT_TAB, |
615 blink::WebMouseEvent::Button::Left, | 608 blink::WebMouseEvent::ButtonLeft, EXPECT_ORIGIN_AS_REFERRER); |
616 EXPECT_ORIGIN_AS_REFERRER); | |
617 } | 609 } |
618 | 610 |
619 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, | 611 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, |
620 HttpLeftClickRedirectToHTTPOriginWhenCrossOrigin) { | 612 HttpLeftClickRedirectToHTTPOriginWhenCrossOrigin) { |
621 RunReferrerTest(blink::WebReferrerPolicyOriginWhenCrossOrigin, START_ON_HTTP, | 613 RunReferrerTest(blink::WebReferrerPolicyOriginWhenCrossOrigin, START_ON_HTTP, |
622 REGULAR_LINK, SERVER_REDIRECT_FROM_HTTP_TO_HTTP, CURRENT_TAB, | 614 REGULAR_LINK, SERVER_REDIRECT_FROM_HTTP_TO_HTTP, CURRENT_TAB, |
623 blink::WebMouseEvent::Button::Left, EXPECT_FULL_REFERRER); | 615 blink::WebMouseEvent::ButtonLeft, EXPECT_FULL_REFERRER); |
624 } | 616 } |
625 | 617 |
626 // Reduced 'referer' granularity flag tests. | 618 // Reduced 'referer' granularity flag tests. |
627 | 619 |
628 // User initiated navigation, from HTTP to HTTPS via server redirect. | 620 // User initiated navigation, from HTTP to HTTPS via server redirect. |
629 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpLeftClickRedirectDefaultNoFlag) { | 621 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpLeftClickRedirectDefaultNoFlag) { |
630 RunReferrerTest(blink::WebReferrerPolicyDefault, START_ON_HTTP, REGULAR_LINK, | 622 RunReferrerTest(blink::WebReferrerPolicyDefault, START_ON_HTTP, REGULAR_LINK, |
631 SERVER_REDIRECT_FROM_HTTP_TO_HTTPS, CURRENT_TAB, | 623 SERVER_REDIRECT_FROM_HTTP_TO_HTTPS, CURRENT_TAB, |
632 blink::WebMouseEvent::Button::Left, EXPECT_FULL_REFERRER, | 624 blink::WebMouseEvent::ButtonLeft, EXPECT_FULL_REFERRER, |
633 blink::WebReferrerPolicyNoReferrerWhenDowngrade); | 625 blink::WebReferrerPolicyNoReferrerWhenDowngrade); |
634 } | 626 } |
635 | 627 |
636 IN_PROC_BROWSER_TEST_F(ReferrerPolicyWithReduceReferrerGranularityFlagTest, | 628 IN_PROC_BROWSER_TEST_F(ReferrerPolicyWithReduceReferrerGranularityFlagTest, |
637 HttpLeftClickRedirectDefaultFlag) { | 629 HttpLeftClickRedirectDefaultFlag) { |
638 blink::WebReferrerPolicy expected_referrer_policy = | 630 blink::WebReferrerPolicy expected_referrer_policy = |
639 blink::WebReferrerPolicyNoReferrerWhenDowngradeOriginWhenCrossOrigin; | 631 blink::WebReferrerPolicyNoReferrerWhenDowngradeOriginWhenCrossOrigin; |
640 | 632 |
641 RunReferrerTest(blink::WebReferrerPolicyDefault, START_ON_HTTP, REGULAR_LINK, | 633 RunReferrerTest(blink::WebReferrerPolicyDefault, START_ON_HTTP, REGULAR_LINK, |
642 SERVER_REDIRECT_FROM_HTTP_TO_HTTPS, CURRENT_TAB, | 634 SERVER_REDIRECT_FROM_HTTP_TO_HTTPS, CURRENT_TAB, |
643 blink::WebMouseEvent::Button::Left, EXPECT_ORIGIN_AS_REFERRER, | 635 blink::WebMouseEvent::ButtonLeft, EXPECT_ORIGIN_AS_REFERRER, |
644 expected_referrer_policy); | 636 expected_referrer_policy); |
645 } | 637 } |
OLD | NEW |