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, |
| 517 false); |
517 content::WebContents* web_contents = browser()->OpenURL(params); | 518 content::WebContents* web_contents = browser()->OpenURL(params); |
518 int tab_id = ExtensionTabUtil::GetTabId(web_contents); | 519 int tab_id = ExtensionTabUtil::GetTabId(web_contents); |
519 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); | 520 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); |
520 int tab_index = -1; | 521 int tab_index = -1; |
521 TabStripModel* tab_strip; | 522 TabStripModel* tab_strip; |
522 ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index); | 523 ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index); |
523 | 524 |
524 scoped_refptr<TabsDuplicateFunction> duplicate_tab_function( | 525 scoped_refptr<TabsDuplicateFunction> duplicate_tab_function( |
525 new TabsDuplicateFunction()); | 526 new TabsDuplicateFunction()); |
526 scoped_ptr<base::DictionaryValue> test_extension_value( | 527 scoped_ptr<base::DictionaryValue> test_extension_value( |
(...skipping 19 matching lines...) Expand all Loading... |
546 EXPECT_NE(tab_id, duplicate_tab_id); | 547 EXPECT_NE(tab_id, duplicate_tab_id); |
547 EXPECT_EQ(window_id, duplicate_tab_window_id); | 548 EXPECT_EQ(window_id, duplicate_tab_window_id); |
548 EXPECT_EQ(tab_index + 1, duplicate_tab_index); | 549 EXPECT_EQ(tab_index + 1, duplicate_tab_index); |
549 // The test empty tab extension has tabs permissions, therefore | 550 // The test empty tab extension has tabs permissions, therefore |
550 // |duplicate_result| should contain url, title, and faviconUrl | 551 // |duplicate_result| should contain url, title, and faviconUrl |
551 // in the function result. | 552 // in the function result. |
552 EXPECT_TRUE(utils::HasPrivacySensitiveFields(duplicate_result.get())); | 553 EXPECT_TRUE(utils::HasPrivacySensitiveFields(duplicate_result.get())); |
553 } | 554 } |
554 | 555 |
555 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTabNoPermission) { | 556 IN_PROC_BROWSER_TEST_F(ExtensionTabsTest, DuplicateTabNoPermission) { |
556 content::OpenURLParams params(GURL(content::kAboutBlankURL), | 557 content::OpenURLParams params(GURL(url::kAboutBlankURL), |
557 content::Referrer(), | 558 content::Referrer(), |
558 NEW_FOREGROUND_TAB, | 559 NEW_FOREGROUND_TAB, |
559 content::PAGE_TRANSITION_LINK, false); | 560 content::PAGE_TRANSITION_LINK, |
| 561 false); |
560 content::WebContents* web_contents = browser()->OpenURL(params); | 562 content::WebContents* web_contents = browser()->OpenURL(params); |
561 int tab_id = ExtensionTabUtil::GetTabId(web_contents); | 563 int tab_id = ExtensionTabUtil::GetTabId(web_contents); |
562 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); | 564 int window_id = ExtensionTabUtil::GetWindowIdOfTab(web_contents); |
563 int tab_index = -1; | 565 int tab_index = -1; |
564 TabStripModel* tab_strip; | 566 TabStripModel* tab_strip; |
565 ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index); | 567 ExtensionTabUtil::GetTabStripModel(web_contents, &tab_strip, &tab_index); |
566 | 568 |
567 scoped_refptr<TabsDuplicateFunction> duplicate_tab_function( | 569 scoped_refptr<TabsDuplicateFunction> duplicate_tab_function( |
568 new TabsDuplicateFunction()); | 570 new TabsDuplicateFunction()); |
569 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); | 571 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); |
(...skipping 13 matching lines...) Expand all Loading... |
583 // Duplicate tab id should be different from the original tab id. | 585 // Duplicate tab id should be different from the original tab id. |
584 EXPECT_NE(tab_id, duplicate_tab_id); | 586 EXPECT_NE(tab_id, duplicate_tab_id); |
585 EXPECT_EQ(window_id, duplicate_tab_window_id); | 587 EXPECT_EQ(window_id, duplicate_tab_window_id); |
586 EXPECT_EQ(tab_index + 1, duplicate_tab_index); | 588 EXPECT_EQ(tab_index + 1, duplicate_tab_index); |
587 // The test empty extension has no permissions, therefore |duplicate_result| | 589 // The test empty extension has no permissions, therefore |duplicate_result| |
588 // should not contain url, title, and faviconUrl in the function result. | 590 // should not contain url, title, and faviconUrl in the function result. |
589 EXPECT_FALSE(utils::HasPrivacySensitiveFields(duplicate_result.get())); | 591 EXPECT_FALSE(utils::HasPrivacySensitiveFields(duplicate_result.get())); |
590 } | 592 } |
591 | 593 |
592 } // namespace extensions | 594 } // namespace extensions |
OLD | NEW |