| 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 | 5 |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 kArgs, | 386 kArgs, |
| 387 incognito_browser), | 387 incognito_browser), |
| 388 keys::kIncognitoModeIsDisabled)); | 388 keys::kIncognitoModeIsDisabled)); |
| 389 } | 389 } |
| 390 | 390 |
| 391 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryCurrentWindowTabs) { | 391 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, QueryCurrentWindowTabs) { |
| 392 const size_t kExtraWindows = 3; | 392 const size_t kExtraWindows = 3; |
| 393 for (size_t i = 0; i < kExtraWindows; ++i) | 393 for (size_t i = 0; i < kExtraWindows; ++i) |
| 394 CreateBrowser(browser()->profile()); | 394 CreateBrowser(browser()->profile()); |
| 395 | 395 |
| 396 GURL url(content::kAboutBlankURL); | 396 GURL url(url::kAboutBlankURL); |
| 397 AddTabAtIndexToBrowser(browser(), 0, url, content::PAGE_TRANSITION_LINK); | 397 AddTabAtIndexToBrowser(browser(), 0, url, content::PAGE_TRANSITION_LINK); |
| 398 int window_id = ExtensionTabUtil::GetWindowId(browser()); | 398 int window_id = ExtensionTabUtil::GetWindowId(browser()); |
| 399 | 399 |
| 400 // Get tabs in the 'current' window called from non-focused browser. | 400 // Get tabs in the 'current' window called from non-focused browser. |
| 401 scoped_refptr<TabsQueryFunction> function = new TabsQueryFunction(); | 401 scoped_refptr<TabsQueryFunction> function = new TabsQueryFunction(); |
| 402 function->set_extension(utils::CreateEmptyExtension().get()); | 402 function->set_extension(utils::CreateEmptyExtension().get()); |
| 403 scoped_ptr<base::ListValue> result(utils::ToList( | 403 scoped_ptr<base::ListValue> result(utils::ToList( |
| 404 utils::RunFunctionAndReturnSingleResult(function.get(), | 404 utils::RunFunctionAndReturnSingleResult(function.get(), |
| 405 "[{\"currentWindow\":true}]", | 405 "[{\"currentWindow\":true}]", |
| 406 browser()))); | 406 browser()))); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 function->set_extension(extension.get()); | 503 function->set_extension(extension.get()); |
| 504 EXPECT_TRUE(MatchPattern( | 504 EXPECT_TRUE(MatchPattern( |
| 505 utils::RunFunctionAndReturnError( | 505 utils::RunFunctionAndReturnError( |
| 506 function.get(), | 506 function.get(), |
| 507 base::StringPrintf(kArgsMaximizedWithBounds, window_id), | 507 base::StringPrintf(kArgsMaximizedWithBounds, window_id), |
| 508 browser()), | 508 browser()), |
| 509 keys::kInvalidWindowStateError)); | 509 keys::kInvalidWindowStateError)); |
| 510 } | 510 } |
| 511 | 511 |
| 512 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTab) { | 512 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTab) { |
| 513 content::OpenURLParams params(GURL(content::kAboutBlankURL), | 513 content::OpenURLParams params(GURL(url::kAboutBlankURL), |
| 514 content::Referrer(), | 514 content::Referrer(), |
| 515 NEW_FOREGROUND_TAB, | 515 NEW_FOREGROUND_TAB, |
| 516 content::PAGE_TRANSITION_LINK, false); | 516 content::PAGE_TRANSITION_LINK, false); |
| 517 content::WebContents* web_contents = browser()->OpenURL(params); | 517 content::WebContents* web_contents = browser()->OpenURL(params); |
| 518 int tab_id = ExtensionTabUtil::GetTabId(web_contents); | 518 int tab_id = ExtensionTabUtil::GetTabId(web_contents); |
| 519 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); | 519 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); |
| 520 int tab_index = -1; | 520 int tab_index = -1; |
| 521 TabStripModel* tab_strip; | 521 TabStripModel* tab_strip; |
| 522 ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index); | 522 ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index); |
| 523 | 523 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 546 EXPECT_NE(tab_id, duplicate_tab_id); | 546 EXPECT_NE(tab_id, duplicate_tab_id); |
| 547 EXPECT_EQ(window_id, duplicate_tab_window_id); | 547 EXPECT_EQ(window_id, duplicate_tab_window_id); |
| 548 EXPECT_EQ(tab_index + 1, duplicate_tab_index); | 548 EXPECT_EQ(tab_index + 1, duplicate_tab_index); |
| 549 // The test empty tab extension has tabs permissions, therefore | 549 // The test empty tab extension has tabs permissions, therefore |
| 550 // |duplicate_result| should contain url, title, and faviconUrl | 550 // |duplicate_result| should contain url, title, and faviconUrl |
| 551 // in the function result. | 551 // in the function result. |
| 552 EXPECT_TRUE(utils::HasPrivacySensitiveFields(duplicate_result.get())); | 552 EXPECT_TRUE(utils::HasPrivacySensitiveFields(duplicate_result.get())); |
| 553 } | 553 } |
| 554 | 554 |
| 555 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTabNoPermission) { | 555 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTabNoPermission) { |
| 556 content::OpenURLParams params(GURL(content::kAboutBlankURL), | 556 content::OpenURLParams params(GURL(url::kAboutBlankURL), |
| 557 content::Referrer(), | 557 content::Referrer(), |
| 558 NEW_FOREGROUND_TAB, | 558 NEW_FOREGROUND_TAB, |
| 559 content::PAGE_TRANSITION_LINK, false); | 559 content::PAGE_TRANSITION_LINK, false); |
| 560 content::WebContents* web_contents = browser()->OpenURL(params); | 560 content::WebContents* web_contents = browser()->OpenURL(params); |
| 561 int tab_id = ExtensionTabUtil::GetTabId(web_contents); | 561 int tab_id = ExtensionTabUtil::GetTabId(web_contents); |
| 562 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); | 562 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); |
| 563 int tab_index = -1; | 563 int tab_index = -1; |
| 564 TabStripModel* tab_strip; | 564 TabStripModel* tab_strip; |
| 565 ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index); | 565 ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index); |
| 566 | 566 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 583 // Duplicate tab id should be different from the original tab id. | 583 // Duplicate tab id should be different from the original tab id. |
| 584 EXPECT_NE(tab_id, duplicate_tab_id); | 584 EXPECT_NE(tab_id, duplicate_tab_id); |
| 585 EXPECT_EQ(window_id, duplicate_tab_window_id); | 585 EXPECT_EQ(window_id, duplicate_tab_window_id); |
| 586 EXPECT_EQ(tab_index + 1, duplicate_tab_index); | 586 EXPECT_EQ(tab_index + 1, duplicate_tab_index); |
| 587 // The test empty extension has no permissions, therefore |duplicate_result| | 587 // The test empty extension has no permissions, therefore |duplicate_result| |
| 588 // should not contain url, title, and faviconUrl in the function result. | 588 // should not contain url, title, and faviconUrl in the function result. |
| 589 EXPECT_FALSE(utils::HasPrivacySensitiveFields(duplicate_result.get())); | 589 EXPECT_FALSE(utils::HasPrivacySensitiveFields(duplicate_result.get())); |
| 590 } | 590 } |
| 591 | 591 |
| 592 } // namespace extensions | 592 } // namespace extensions |
| OLD | NEW |