Commit 93ff7f46 authored by Istiaque Ahmed's avatar Istiaque Ahmed Committed by Commit Bot

Reland "[Extensions] Remove an unused param from StartTestFromBackgroundPage."

This is a reland of 15b15db4
https://chromium-review.googlesource.com/1187856 was in
conflict with the CL. Fixed in patchset #5.

Original change's description:
> [Extensions] Remove an unused param from StartTestFromBackgroundPage.
>
> The param was always passed with nullptr value, so remove it entirely.
>
> Bug: None
> Test: None, test cleanup.
> Change-Id: If8cd3c4c7e0bd77fabbc545dcbd5fda69a9c0703
> Reviewed-on: https://chromium-review.googlesource.com/1196143
> Reviewed-by: Karan Bhatia <karandeepb@chromium.org>
> Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#587871}

Bug: None
Change-Id: Ie25c1f8d87e555ad813c3f044a10b1ce7fad3b00
Reviewed-on: https://chromium-review.googlesource.com/1198483Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Reviewed-by: default avatarKaran Bhatia <karandeepb@chromium.org>
Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587907}
parent f5149004
...@@ -62,10 +62,6 @@ namespace extensions { ...@@ -62,10 +62,6 @@ namespace extensions {
namespace { namespace {
// Pass into ServiceWorkerTest::StartTestFromBackgroundPage to indicate that
// registration is expected to succeed.
std::string* const kExpectSuccess = nullptr;
// Returns the newly added WebContents. // Returns the newly added WebContents.
content::WebContents* AddTab(Browser* browser, const GURL& url) { content::WebContents* AddTab(Browser* browser, const GURL& url) {
int starting_tab_count = browser->tab_strip_model()->count(); int starting_tab_count = browser->tab_strip_model()->count();
...@@ -149,13 +145,7 @@ class ServiceWorkerTest : public ExtensionApiTest, ...@@ -149,13 +145,7 @@ class ServiceWorkerTest : public ExtensionApiTest,
// //
// This registers a service worker with |script_name|, and fetches the // This registers a service worker with |script_name|, and fetches the
// registration result. // registration result.
// const Extension* StartTestFromBackgroundPage(const char* script_name) {
// If |error_or_null| is null (kExpectSuccess), success is expected and this
// will fail if there is an error.
// If |error_or_null| is not null, nothing is assumed, and the error (which
// may be empty) is written to it.
const Extension* StartTestFromBackgroundPage(const char* script_name,
std::string* error_or_null) {
ExtensionTestMessageListener ready_listener("ready", false); ExtensionTestMessageListener ready_listener("ready", false);
const Extension* extension = const Extension* extension =
LoadExtension(test_data_dir_.AppendASCII("service_worker/background")); LoadExtension(test_data_dir_.AppendASCII("service_worker/background"));
...@@ -171,9 +161,7 @@ class ServiceWorkerTest : public ExtensionApiTest, ...@@ -171,9 +161,7 @@ class ServiceWorkerTest : public ExtensionApiTest,
background_host->host_contents(), background_host->host_contents(),
base::StringPrintf("test.registerServiceWorker('%s')", script_name), base::StringPrintf("test.registerServiceWorker('%s')", script_name),
&error)); &error));
if (error_or_null) if (!error.empty())
*error_or_null = error;
else if (!error.empty())
ADD_FAILURE() << "Got unexpected error " << error; ADD_FAILURE() << "Got unexpected error " << error;
return extension; return extension;
} }
...@@ -532,7 +520,7 @@ class ServiceWorkerLazyBackgroundTest : public ServiceWorkerTest { ...@@ -532,7 +520,7 @@ class ServiceWorkerLazyBackgroundTest : public ServiceWorkerTest {
}; };
IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, RegisterSucceeds) { IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, RegisterSucceeds) {
StartTestFromBackgroundPage("register.js", kExpectSuccess); StartTestFromBackgroundPage("register.js");
} }
IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, UpdateRefreshesServiceWorker) { IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, UpdateRefreshesServiceWorker) {
...@@ -650,8 +638,7 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, DISABLED_UpdateWithoutSkipWaiting) { ...@@ -650,8 +638,7 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, DISABLED_UpdateWithoutSkipWaiting) {
} }
IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, FetchArbitraryPaths) { IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, FetchArbitraryPaths) {
const Extension* extension = const Extension* extension = StartTestFromBackgroundPage("fetch.js");
StartTestFromBackgroundPage("fetch.js", kExpectSuccess);
// Open some arbirary paths. Their contents should be what the service worker // Open some arbirary paths. Their contents should be what the service worker
// responds with, which in this case is the path of the fetch. // responds with, which in this case is the path of the fetch.
...@@ -673,8 +660,7 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, FetchArbitraryPaths) { ...@@ -673,8 +660,7 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, FetchArbitraryPaths) {
IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, IN_PROC_BROWSER_TEST_P(ServiceWorkerTest,
FetchExtensionResourceFromServiceWorker) { FetchExtensionResourceFromServiceWorker) {
const Extension* extension = const Extension* extension = StartTestFromBackgroundPage("fetch_from_sw.js");
StartTestFromBackgroundPage("fetch_from_sw.js", kExpectSuccess);
ASSERT_TRUE(extension); ASSERT_TRUE(extension);
// The service worker in this test tries to load 'hello.txt' via fetch() // The service worker in this test tries to load 'hello.txt' via fetch()
...@@ -692,7 +678,7 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, ...@@ -692,7 +678,7 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest,
IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, SWServedBackgroundPageReceivesEvent) { IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, SWServedBackgroundPageReceivesEvent) {
const Extension* extension = const Extension* extension =
StartTestFromBackgroundPage("replace_background.js", kExpectSuccess); StartTestFromBackgroundPage("replace_background.js");
ExtensionHost* background_page = ExtensionHost* background_page =
process_manager()->GetBackgroundHostForExtension(extension->id()); process_manager()->GetBackgroundHostForExtension(extension->id());
ASSERT_TRUE(background_page); ASSERT_TRUE(background_page);
...@@ -717,8 +703,7 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, SWServedBackgroundPageReceivesEvent) { ...@@ -717,8 +703,7 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, SWServedBackgroundPageReceivesEvent) {
} }
IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, SWServedBackgroundPage) { IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, SWServedBackgroundPage) {
const Extension* extension = const Extension* extension = StartTestFromBackgroundPage("fetch.js");
StartTestFromBackgroundPage("fetch.js", kExpectSuccess);
std::string kExpectedInnerText = "background.html contents for testing."; std::string kExpectedInnerText = "background.html contents for testing.";
...@@ -750,8 +735,8 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, SWServedBackgroundPage) { ...@@ -750,8 +735,8 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, SWServedBackgroundPage) {
IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, IN_PROC_BROWSER_TEST_P(ServiceWorkerTest,
ServiceWorkerPostsMessageToBackgroundClient) { ServiceWorkerPostsMessageToBackgroundClient) {
const Extension* extension = StartTestFromBackgroundPage( const Extension* extension =
"post_message_to_background_client.js", kExpectSuccess); StartTestFromBackgroundPage("post_message_to_background_client.js");
// The service worker in this test simply posts a message to the background // The service worker in this test simply posts a message to the background
// client it receives from getBackgroundClient(). // client it receives from getBackgroundClient().
...@@ -771,7 +756,7 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, ...@@ -771,7 +756,7 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest,
IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, IN_PROC_BROWSER_TEST_P(ServiceWorkerTest,
BackgroundPagePostsMessageToServiceWorker) { BackgroundPagePostsMessageToServiceWorker) {
const Extension* extension = const Extension* extension =
StartTestFromBackgroundPage("post_message_to_sw.js", kExpectSuccess); StartTestFromBackgroundPage("post_message_to_sw.js");
// The service worker in this test waits for a message, then echoes it back // The service worker in this test waits for a message, then echoes it back
// by posting a message to the background page via getBackgroundClient(). // by posting a message to the background page via getBackgroundClient().
...@@ -793,8 +778,7 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, ...@@ -793,8 +778,7 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest,
std::string extension_id; std::string extension_id;
GURL extension_url; GURL extension_url;
{ {
const Extension* extension = const Extension* extension = StartTestFromBackgroundPage("fetch.js");
StartTestFromBackgroundPage("fetch.js", kExpectSuccess);
extension_id = extension->id(); extension_id = extension->id();
extension_url = extension->url(); extension_url = extension->url();
} }
...@@ -845,8 +829,7 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, ...@@ -845,8 +829,7 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest,
} }
IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, BackgroundPageIsWokenIfAsleep) { IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, BackgroundPageIsWokenIfAsleep) {
const Extension* extension = const Extension* extension = StartTestFromBackgroundPage("wake_on_fetch.js");
StartTestFromBackgroundPage("wake_on_fetch.js", kExpectSuccess);
// Navigate to special URLs that this test's service worker recognises, each // Navigate to special URLs that this test's service worker recognises, each
// making a check then populating the response with either "true" or "false". // making a check then populating the response with either "true" or "false".
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment