Commit b6153c40 authored by Findit's avatar Findit

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

This reverts commit 15b15db4.

Reason for revert:

Findit (https://goo.gl/kROfz5) identified CL at revision 587871 as the
culprit for failures in the build cycles as shown on:
https://findit-for-me.appspot.com/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtLzE1YjE1ZGI0NzQ3YzNlOTI2MzgwZTJiZDg4MmNjN2E0OGUzNjRmZTUM

Sample Failed Build: https://ci.chromium.org/buildbot/chromium.gpu/GPU%20Linux%20Builder/128717

Sample Failed Step: compile

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}

Change-Id: Iced35e86429f566d79c2ab7807d34c69b6456a35
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: None
Reviewed-on: https://chromium-review.googlesource.com/1198563
Cr-Commit-Position: refs/heads/master@{#587878}
parent e27112da
...@@ -62,6 +62,10 @@ namespace extensions { ...@@ -62,6 +62,10 @@ 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();
...@@ -145,7 +149,13 @@ class ServiceWorkerTest : public ExtensionApiTest, ...@@ -145,7 +149,13 @@ 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"));
...@@ -161,7 +171,9 @@ class ServiceWorkerTest : public ExtensionApiTest, ...@@ -161,7 +171,9 @@ 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.empty()) if (error_or_null)
*error_or_null = error;
else if (!error.empty())
ADD_FAILURE() << "Got unexpected error " << error; ADD_FAILURE() << "Got unexpected error " << error;
return extension; return extension;
} }
...@@ -520,7 +532,7 @@ class ServiceWorkerLazyBackgroundTest : public ServiceWorkerTest { ...@@ -520,7 +532,7 @@ class ServiceWorkerLazyBackgroundTest : public ServiceWorkerTest {
}; };
IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, RegisterSucceeds) { IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, RegisterSucceeds) {
StartTestFromBackgroundPage("register.js"); StartTestFromBackgroundPage("register.js", kExpectSuccess);
} }
IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, UpdateRefreshesServiceWorker) { IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, UpdateRefreshesServiceWorker) {
...@@ -638,7 +650,8 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, DISABLED_UpdateWithoutSkipWaiting) { ...@@ -638,7 +650,8 @@ 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 = StartTestFromBackgroundPage("fetch.js"); const Extension* extension =
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.
...@@ -679,7 +692,7 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, ...@@ -679,7 +692,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"); StartTestFromBackgroundPage("replace_background.js", kExpectSuccess);
ExtensionHost* background_page = ExtensionHost* background_page =
process_manager()->GetBackgroundHostForExtension(extension->id()); process_manager()->GetBackgroundHostForExtension(extension->id());
ASSERT_TRUE(background_page); ASSERT_TRUE(background_page);
...@@ -704,7 +717,8 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, SWServedBackgroundPageReceivesEvent) { ...@@ -704,7 +717,8 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, SWServedBackgroundPageReceivesEvent) {
} }
IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, SWServedBackgroundPage) { IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, SWServedBackgroundPage) {
const Extension* extension = StartTestFromBackgroundPage("fetch.js"); const Extension* extension =
StartTestFromBackgroundPage("fetch.js", kExpectSuccess);
std::string kExpectedInnerText = "background.html contents for testing."; std::string kExpectedInnerText = "background.html contents for testing.";
...@@ -736,8 +750,8 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, SWServedBackgroundPage) { ...@@ -736,8 +750,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 = const Extension* extension = StartTestFromBackgroundPage(
StartTestFromBackgroundPage("post_message_to_background_client.js"); "post_message_to_background_client.js", kExpectSuccess);
// 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().
...@@ -757,7 +771,7 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, ...@@ -757,7 +771,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"); StartTestFromBackgroundPage("post_message_to_sw.js", kExpectSuccess);
// 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().
...@@ -779,7 +793,8 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, ...@@ -779,7 +793,8 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest,
std::string extension_id; std::string extension_id;
GURL extension_url; GURL extension_url;
{ {
const Extension* extension = StartTestFromBackgroundPage("fetch.js"); const Extension* extension =
StartTestFromBackgroundPage("fetch.js", kExpectSuccess);
extension_id = extension->id(); extension_id = extension->id();
extension_url = extension->url(); extension_url = extension->url();
} }
...@@ -830,7 +845,8 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, ...@@ -830,7 +845,8 @@ IN_PROC_BROWSER_TEST_P(ServiceWorkerTest,
} }
IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, BackgroundPageIsWokenIfAsleep) { IN_PROC_BROWSER_TEST_P(ServiceWorkerTest, BackgroundPageIsWokenIfAsleep) {
const Extension* extension = StartTestFromBackgroundPage("wake_on_fetch.js"); const Extension* extension =
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