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

Side by Side Diff: chrome/browser/referrer_policy_browsertest.cc

Issue 326043002: Cleanup: Remove more dead GTK code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
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/prefs/pref_service.h" 6 #include "base/prefs/pref_service.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"
11 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" 11 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h"
12 #include "chrome/browser/renderer_context_menu/render_view_context_menu_browsert est_util.h" 12 #include "chrome/browser/renderer_context_menu/render_view_context_menu_browsert est_util.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_commands.h" 14 #include "chrome/browser/ui/browser_commands.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" 15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
17 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
18 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
19 #include "content/public/browser/navigation_controller.h" 19 #include "content/public/browser/navigation_controller.h"
20 #include "content/public/browser/navigation_entry.h" 20 #include "content/public/browser/navigation_entry.h"
21 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
22 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
23 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
24 #include "content/public/test/browser_test_utils.h" 24 #include "content/public/test/browser_test_utils.h"
25 #include "net/test/spawned_test_server/spawned_test_server.h" 25 #include "net/test/spawned_test_server/spawned_test_server.h"
26 #include "third_party/WebKit/public/web/WebInputEvent.h" 26 #include "third_party/WebKit/public/web/WebInputEvent.h"
27 27
28 // GTK requires a X11-level mouse event to open a context menu correctly.
29 #if defined(TOOLKIT_GTK)
30 #define MAYBE_ContextMenuOrigin DISABLED_ContextMenuOrigin
31 #define MAYBE_HttpsContextMenuOrigin DISABLED_HttpsContextMenuOrigin
32 #define MAYBE_ContextMenuRedirect DISABLED_ContextMenuRedirect
33 #define MAYBE_HttpsContextMenuRedirect DISABLED_HttpsContextMenuRedirect
34 #else
35 #define MAYBE_ContextMenuOrigin ContextMenuOrigin
36 #define MAYBE_HttpsContextMenuOrigin HttpsContextMenuOrigin
37 #define MAYBE_ContextMenuRedirect ContextMenuRedirect
38 #define MAYBE_HttpsContextMenuRedirect HttpsContextMenuRedirect
39 #endif
40
41 namespace { 28 namespace {
42 29
43 const base::FilePath::CharType kDocRoot[] = 30 const base::FilePath::CharType kDocRoot[] =
44 FILE_PATH_LITERAL("chrome/test/data/referrer_policy"); 31 FILE_PATH_LITERAL("chrome/test/data/referrer_policy");
45 32
46 } // namespace 33 } // namespace
47 34
48 class ReferrerPolicyTest : public InProcessBrowserTest { 35 class ReferrerPolicyTest : public InProcessBrowserTest {
49 public: 36 public:
50 ReferrerPolicyTest() {} 37 ReferrerPolicyTest() {}
51 virtual ~ReferrerPolicyTest() {} 38 virtual ~ReferrerPolicyTest() {}
52 39
53 virtual void SetUp() OVERRIDE { 40 virtual void SetUp() OVERRIDE {
54 test_server_.reset(new net::SpawnedTestServer( 41 test_server_.reset(new net::SpawnedTestServer(
55 net::SpawnedTestServer::TYPE_HTTP, 42 net::SpawnedTestServer::TYPE_HTTP,
56 net::SpawnedTestServer::kLocalhost, 43 net::SpawnedTestServer::kLocalhost,
57 base::FilePath(kDocRoot))); 44 base::FilePath(kDocRoot)));
58 ASSERT_TRUE(test_server_->Start()); 45 ASSERT_TRUE(test_server_->Start());
59 ssl_test_server_.reset(new net::SpawnedTestServer( 46 ssl_test_server_.reset(new net::SpawnedTestServer(
60 net::SpawnedTestServer::TYPE_HTTPS, 47 net::SpawnedTestServer::TYPE_HTTPS,
61 net::SpawnedTestServer::kLocalhost, 48 net::SpawnedTestServer::kLocalhost,
62 base::FilePath(kDocRoot))); 49 base::FilePath(kDocRoot)));
63 ASSERT_TRUE(ssl_test_server_->Start()); 50 ASSERT_TRUE(ssl_test_server_->Start());
64 51
65 InProcessBrowserTest::SetUp(); 52 InProcessBrowserTest::SetUp();
66 } 53 }
67 54
68 protected: 55 protected:
69 enum ExpectedReferrer { 56 enum ExpectedReferrer {
70 EXPECT_EMPTY_REFERRER, 57 EXPECT_EMPTY_REFERRER,
71 EXPECT_FULL_REFERRER, 58 EXPECT_FULL_REFERRER,
72 EXPECT_ORIGIN_AS_REFERRER 59 EXPECT_ORIGIN_AS_REFERRER
73 }; 60 };
74 61
75 // Returns the expected title for the tab with the given (full) referrer and 62 // Returns the expected title for the tab with the given (full) referrer and
76 // the expected modification of it. 63 // the expected modification of it.
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 RunReferrerTest(blink::WebReferrerPolicyOrigin, 322 RunReferrerTest(blink::WebReferrerPolicyOrigin,
336 START_ON_HTTPS, 323 START_ON_HTTPS,
337 LINk_WITH_TARGET_BLANK, 324 LINk_WITH_TARGET_BLANK,
338 NO_REDIRECT, 325 NO_REDIRECT,
339 NEW_FOREGROUND_TAB, 326 NEW_FOREGROUND_TAB,
340 blink::WebMouseEvent::ButtonMiddle, 327 blink::WebMouseEvent::ButtonMiddle,
341 EXPECT_ORIGIN_AS_REFERRER); 328 EXPECT_ORIGIN_AS_REFERRER);
342 } 329 }
343 330
344 // Context menu, from HTTP to HTTP. 331 // Context menu, from HTTP to HTTP.
345 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_ContextMenuOrigin) { 332 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, ContextMenuOrigin) {
346 ContextMenuNotificationObserver context_menu_observer( 333 ContextMenuNotificationObserver context_menu_observer(
347 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); 334 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB);
348 RunReferrerTest(blink::WebReferrerPolicyOrigin, 335 RunReferrerTest(blink::WebReferrerPolicyOrigin,
349 START_ON_HTTP, 336 START_ON_HTTP,
350 REGULAR_LINK, 337 REGULAR_LINK,
351 NO_REDIRECT, 338 NO_REDIRECT,
352 NEW_FOREGROUND_TAB, 339 NEW_FOREGROUND_TAB,
353 blink::WebMouseEvent::ButtonRight, 340 blink::WebMouseEvent::ButtonRight,
354 EXPECT_ORIGIN_AS_REFERRER); 341 EXPECT_ORIGIN_AS_REFERRER);
355 } 342 }
356 343
357 // Context menu, from HTTPS to HTTP. 344 // Context menu, from HTTPS to HTTP.
358 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_HttpsContextMenuOrigin) { 345 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsContextMenuOrigin) {
359 ContextMenuNotificationObserver context_menu_observer( 346 ContextMenuNotificationObserver context_menu_observer(
360 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); 347 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB);
361 RunReferrerTest(blink::WebReferrerPolicyOrigin, 348 RunReferrerTest(blink::WebReferrerPolicyOrigin,
362 START_ON_HTTPS, 349 START_ON_HTTPS,
363 REGULAR_LINK, 350 REGULAR_LINK,
364 NO_REDIRECT, 351 NO_REDIRECT,
365 NEW_FOREGROUND_TAB, 352 NEW_FOREGROUND_TAB,
366 blink::WebMouseEvent::ButtonRight, 353 blink::WebMouseEvent::ButtonRight,
367 EXPECT_ORIGIN_AS_REFERRER); 354 EXPECT_ORIGIN_AS_REFERRER);
368 } 355 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 RunReferrerTest(blink::WebReferrerPolicyOrigin, 465 RunReferrerTest(blink::WebReferrerPolicyOrigin,
479 START_ON_HTTPS, 466 START_ON_HTTPS,
480 LINk_WITH_TARGET_BLANK, 467 LINk_WITH_TARGET_BLANK,
481 SERVER_REDIRECT, 468 SERVER_REDIRECT,
482 NEW_FOREGROUND_TAB, 469 NEW_FOREGROUND_TAB,
483 blink::WebMouseEvent::ButtonMiddle, 470 blink::WebMouseEvent::ButtonMiddle,
484 EXPECT_ORIGIN_AS_REFERRER); 471 EXPECT_ORIGIN_AS_REFERRER);
485 } 472 }
486 473
487 // Context menu, from HTTP to HTTP via server redirect. 474 // Context menu, from HTTP to HTTP via server redirect.
488 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_ContextMenuRedirect) { 475 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, ContextMenuRedirect) {
489 ContextMenuNotificationObserver context_menu_observer( 476 ContextMenuNotificationObserver context_menu_observer(
490 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); 477 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB);
491 RunReferrerTest(blink::WebReferrerPolicyOrigin, 478 RunReferrerTest(blink::WebReferrerPolicyOrigin,
492 START_ON_HTTP, 479 START_ON_HTTP,
493 REGULAR_LINK, 480 REGULAR_LINK,
494 SERVER_REDIRECT, 481 SERVER_REDIRECT,
495 NEW_FOREGROUND_TAB, 482 NEW_FOREGROUND_TAB,
496 blink::WebMouseEvent::ButtonRight, 483 blink::WebMouseEvent::ButtonRight,
497 EXPECT_ORIGIN_AS_REFERRER); 484 EXPECT_ORIGIN_AS_REFERRER);
498 } 485 }
499 486
500 // Context menu, from HTTPS to HTTP via server redirect. 487 // Context menu, from HTTPS to HTTP via server redirect.
501 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, MAYBE_HttpsContextMenuRedirect) { 488 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsContextMenuRedirect) {
502 ContextMenuNotificationObserver context_menu_observer( 489 ContextMenuNotificationObserver context_menu_observer(
503 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB); 490 IDC_CONTENT_CONTEXT_OPENLINKNEWTAB);
504 RunReferrerTest(blink::WebReferrerPolicyOrigin, 491 RunReferrerTest(blink::WebReferrerPolicyOrigin,
505 START_ON_HTTPS, 492 START_ON_HTTPS,
506 REGULAR_LINK, 493 REGULAR_LINK,
507 SERVER_REDIRECT, 494 SERVER_REDIRECT,
508 NEW_FOREGROUND_TAB, 495 NEW_FOREGROUND_TAB,
509 blink::WebMouseEvent::ButtonRight, 496 blink::WebMouseEvent::ButtonRight,
510 EXPECT_ORIGIN_AS_REFERRER); 497 EXPECT_ORIGIN_AS_REFERRER);
511 } 498 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 611
625 // Verify that the full url of the iframe was used as referrer. 612 // Verify that the full url of the iframe was used as referrer.
626 EXPECT_TRUE(content::ExecuteScriptAndExtractString( 613 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
627 frame, 614 frame,
628 "window.domAutomationController.send(document.title)", 615 "window.domAutomationController.send(document.title)",
629 &title)); 616 &title));
630 EXPECT_EQ("Referrer is " + 617 EXPECT_EQ("Referrer is " +
631 test_server_->GetURL("files/referrer-policy-log.html").spec(), 618 test_server_->GetURL("files/referrer-policy-log.html").spec(),
632 title); 619 title);
633 } 620 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698