OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
7 #include "chrome/app/chrome_dll_resource.h" | 7 #include "chrome/app/chrome_dll_resource.h" |
8 #include "chrome/browser/worker_host/worker_service.h" | 8 #include "chrome/browser/worker_host/worker_service.h" |
9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 FilePath(kShutdownSharedWorkerFile)); | 625 FilePath(kShutdownSharedWorkerFile)); |
626 url2 = GURL(url2.spec() + "?id=0"); | 626 url2 = GURL(url2.spec() + "?id=0"); |
627 ASSERT_TRUE(window->AppendTab(url2)); | 627 ASSERT_TRUE(window->AppendTab(url2)); |
628 | 628 |
629 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, | 629 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, |
630 kTestCompleteCookie, action_max_timeout_ms()); | 630 kTestCompleteCookie, action_max_timeout_ms()); |
631 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); | 631 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); |
632 ASSERT_TRUE(WaitForProcessCountToBe(3, max_workers_per_tab)); | 632 ASSERT_TRUE(WaitForProcessCountToBe(3, max_workers_per_tab)); |
633 } | 633 } |
634 | 634 |
635 // Only flaky on Mac http://crbug.com/48148 | 635 // Flaky: http://crbug.com/48148 |
636 #if defined(OS_MACOSX) | 636 TEST_F(WorkerTest, FLAKY_QueuedSharedWorkerStartedFromOtherTab) { |
637 #define MAYBE_QueuedSharedWorkerStartedFromOtherTab \ | |
638 FLAKY_QueuedSharedWorkerStartedFromOtherTab | |
639 #else | |
640 #define MAYBE_QueuedSharedWorkerStartedFromOtherTab \ | |
641 QueuedSharedWorkerStartedFromOtherTab | |
642 #endif | |
643 TEST_F(WorkerTest, MAYBE_QueuedSharedWorkerStartedFromOtherTab) { | |
644 // Tests to make sure that queued shared workers are started up when | 637 // Tests to make sure that queued shared workers are started up when |
645 // an instance is launched from another tab. | 638 // an instance is launched from another tab. |
646 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; | 639 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; |
647 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), | 640 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), |
648 FilePath(kManySharedWorkersFile)); | 641 FilePath(kManySharedWorkersFile)); |
649 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab+1)); | 642 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab+1)); |
650 | 643 |
651 scoped_refptr<TabProxy> tab(GetActiveTab()); | 644 scoped_refptr<TabProxy> tab(GetActiveTab()); |
652 ASSERT_TRUE(tab.get()); | 645 ASSERT_TRUE(tab.get()); |
653 ASSERT_TRUE(tab->NavigateToURL(url)); | 646 ASSERT_TRUE(tab->NavigateToURL(url)); |
654 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab)); | 647 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab)); |
655 // First window has hit its limit. Now launch second window which creates | 648 // First window has hit its limit. Now launch second window which creates |
656 // the same worker that was queued in the first window, to ensure it gets | 649 // the same worker that was queued in the first window, to ensure it gets |
657 // connected to the first window too. | 650 // connected to the first window too. |
658 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 651 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
659 ASSERT_TRUE(window.get()); | 652 ASSERT_TRUE(window.get()); |
660 GURL url2 = ui_test_utils::GetTestUrl(FilePath(kTestDir), | 653 GURL url2 = ui_test_utils::GetTestUrl(FilePath(kTestDir), |
661 FilePath(kSingleSharedWorkersFile)); | 654 FilePath(kSingleSharedWorkersFile)); |
662 url2 = GURL(url2.spec() + StringPrintf("?id=%d", max_workers_per_tab)); | 655 url2 = GURL(url2.spec() + StringPrintf("?id=%d", max_workers_per_tab)); |
663 ASSERT_TRUE(window->AppendTab(url2)); | 656 ASSERT_TRUE(window->AppendTab(url2)); |
664 | 657 |
665 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, | 658 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, |
666 kTestCompleteCookie, action_max_timeout_ms()); | 659 kTestCompleteCookie, action_max_timeout_ms()); |
667 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); | 660 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); |
668 ASSERT_TRUE(WaitForProcessCountToBe(2, max_workers_per_tab+1)); | 661 ASSERT_TRUE(WaitForProcessCountToBe(2, max_workers_per_tab+1)); |
669 } | 662 } |
OLD | NEW |