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

Side by Side Diff: chrome/browser/extensions/service_worker_apitest.cc

Issue 2886923002: [extension SW]: Support event listener registration and event dispatching. (Closed)
Patch Set: sync Created 3 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
« no previous file with comments | « no previous file | chrome/common/extensions/api/_api_features.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 ASSERT_TRUE(content::ExecuteScriptAndExtractString( 659 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
660 web_contents, "window.runServiceWorker()", &result)); 660 web_contents, "window.runServiceWorker()", &result));
661 ASSERT_EQ("chrome.tabs.create callback", result); 661 ASSERT_EQ("chrome.tabs.create callback", result);
662 EXPECT_EQ(starting_tab_count + 1, browser()->tab_strip_model()->count()); 662 EXPECT_EQ(starting_tab_count + 1, browser()->tab_strip_model()->count());
663 663
664 // Check extension shutdown path. 664 // Check extension shutdown path.
665 UnloadExtension(extension->id()); 665 UnloadExtension(extension->id());
666 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count()); 666 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count());
667 } 667 }
668 668
669 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, Events) {
670 // Extensions APIs from SW are only enabled on trunk.
671 ScopedCurrentChannel current_channel_override(version_info::Channel::UNKNOWN);
672 const Extension* extension = LoadExtensionWithFlags(
673 test_data_dir_.AppendASCII("service_worker/events"), kFlagNone);
674 ASSERT_TRUE(extension);
675 ui_test_utils::NavigateToURL(browser(),
676 extension->GetResourceURL("page.html"));
677 content::WebContents* web_contents =
678 browser()->tab_strip_model()->GetActiveWebContents();
679 std::string result;
680 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
681 web_contents, "window.runEventTest()", &result));
682 ASSERT_EQ("chrome.tabs.onUpdated callback", result);
683 }
684
669 // Tests that worker ref count increments while extension API function is 685 // Tests that worker ref count increments while extension API function is
670 // active. 686 // active.
671 687
672 // Flaky on Linux and ChromeOS, https://crbug.com/702126 688 // Flaky on Linux and ChromeOS, https://crbug.com/702126
673 #if defined(OS_LINUX) 689 #if defined(OS_LINUX)
674 #define MAYBE_WorkerRefCount DISABLED_WorkerRefCount 690 #define MAYBE_WorkerRefCount DISABLED_WorkerRefCount
675 #else 691 #else
676 #define MAYBE_WorkerRefCount WorkerRefCount 692 #define MAYBE_WorkerRefCount WorkerRefCount
677 #endif 693 #endif
678 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, MAYBE_WorkerRefCount) { 694 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, MAYBE_WorkerRefCount) {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 message.sender_id = "1234567890"; 898 message.sender_id = "1234567890";
883 message.raw_data = "testdata"; 899 message.raw_data = "testdata";
884 message.decrypted = true; 900 message.decrypted = true;
885 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); 901 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure());
886 push_service()->OnMessage(app_identifier.app_id(), message); 902 push_service()->OnMessage(app_identifier.app_id(), message);
887 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied()); 903 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied());
888 run_loop.Run(); // Wait until the message is handled by push service. 904 run_loop.Run(); // Wait until the message is handled by push service.
889 } 905 }
890 906
891 } // namespace extensions 907 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/api/_api_features.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698