Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_match.h" | 10 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 | 67 |
| 68 int count_; | 68 int count_; |
| 69 | 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(CountRenderViewHosts); | 70 DISALLOW_COPY_AND_ASSIGN(CountRenderViewHosts); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 class PopupBlockerBrowserTest : public InProcessBrowserTest { | 73 class PopupBlockerBrowserTest : public InProcessBrowserTest { |
| 74 public: | 74 public: |
| 75 PopupBlockerBrowserTest() {} | 75 PopupBlockerBrowserTest() {} |
| 76 | 76 |
| 77 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | |
| 78 InProcessBrowserTest::SetUpCommandLine(command_line); | |
| 79 command_line->AppendSwitch(switches::kDisableBetterPopupBlocking); | |
| 80 } | |
| 81 | |
| 77 // Returns a url that shows one popup. | 82 // Returns a url that shows one popup. |
| 78 GURL GetTestURL() { | 83 GURL GetTestURL() { |
| 79 return ui_test_utils::GetTestUrl( | 84 return ui_test_utils::GetTestUrl( |
| 80 base::FilePath(kTestDir), | 85 base::FilePath(kTestDir), |
| 81 base::FilePath(FILE_PATH_LITERAL("popup-blocked-to-post-blank.html"))); | 86 base::FilePath(FILE_PATH_LITERAL("popup-blocked-to-post-blank.html"))); |
| 82 } | 87 } |
| 83 | 88 |
| 84 std::vector<WebContents*> GetBlockedContents(Browser* browser) { | 89 std::vector<WebContents*> GetBlockedContents(Browser* browser) { |
| 85 // Do a round trip to the renderer first to flush any in-flight IPCs to | 90 // Do a round trip to the renderer first to flush any in-flight IPCs to |
| 86 // create a to-be-blocked window. | 91 // create a to-be-blocked window. |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 OmniboxEditModel* model = location_bar->GetLocationEntry()->model(); | 216 OmniboxEditModel* model = location_bar->GetLocationEntry()->model(); |
| 212 EXPECT_EQ(GURL(search_string), model->CurrentMatch(NULL).destination_url); | 217 EXPECT_EQ(GURL(search_string), model->CurrentMatch(NULL).destination_url); |
| 213 EXPECT_EQ(ASCIIToUTF16(search_string), model->CurrentMatch(NULL).contents); | 218 EXPECT_EQ(ASCIIToUTF16(search_string), model->CurrentMatch(NULL).contents); |
| 214 } | 219 } |
| 215 | 220 |
| 216 class BetterPopupBlockerBrowserTest : public PopupBlockerBrowserTest { | 221 class BetterPopupBlockerBrowserTest : public PopupBlockerBrowserTest { |
| 217 public: | 222 public: |
| 218 BetterPopupBlockerBrowserTest() {} | 223 BetterPopupBlockerBrowserTest() {} |
| 219 virtual ~BetterPopupBlockerBrowserTest() {} | 224 virtual ~BetterPopupBlockerBrowserTest() {} |
| 220 | 225 |
| 221 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 226 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
|
marja
2013/07/25 13:42:51
This overridden func is now unnecessary.
marja
2013/07/25 13:47:11
I was fooled by the code! This is for bypassing th
| |
| 222 PopupBlockerBrowserTest::SetUpCommandLine(command_line); | 227 InProcessBrowserTest::SetUpCommandLine(command_line); |
| 223 command_line->AppendSwitch(switches::kEnableBetterPopupBlocking); | |
| 224 } | 228 } |
| 225 | 229 |
| 226 private: | 230 private: |
| 227 DISALLOW_COPY_AND_ASSIGN(BetterPopupBlockerBrowserTest); | 231 DISALLOW_COPY_AND_ASSIGN(BetterPopupBlockerBrowserTest); |
| 228 }; | 232 }; |
| 229 | 233 |
| 230 IN_PROC_BROWSER_TEST_F(BetterPopupBlockerBrowserTest, | 234 IN_PROC_BROWSER_TEST_F(BetterPopupBlockerBrowserTest, |
| 231 BlockWebContentsCreation) { | 235 BlockWebContentsCreation) { |
| 232 CountRenderViewHosts counter; | 236 CountRenderViewHosts counter; |
| 233 | 237 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 433 Browser* new_browser = browser_observer.WaitForSingleNewBrowser(); | 437 Browser* new_browser = browser_observer.WaitForSingleNewBrowser(); |
| 434 | 438 |
| 435 // Check that the referrer was correctly set. | 439 // Check that the referrer was correctly set. |
| 436 web_contents = new_browser->tab_strip_model()->GetActiveWebContents(); | 440 web_contents = new_browser->tab_strip_model()->GetActiveWebContents(); |
| 437 base::string16 expected_title(base::ASCIIToUTF16("PASS")); | 441 base::string16 expected_title(base::ASCIIToUTF16("PASS")); |
| 438 content::TitleWatcher title_watcher(web_contents, expected_title); | 442 content::TitleWatcher title_watcher(web_contents, expected_title); |
| 439 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 443 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
| 440 } | 444 } |
| 441 | 445 |
| 442 } // namespace | 446 } // namespace |
| OLD | NEW |