Commit 58af5106 authored by David Bertoni's avatar David Bertoni Committed by Commit Bot

[Extensions] Re-enable a declarativeContent API for on Windows.

The UninstallWhileActivePageAction test was disabled for flakiness
on Windows. It turns out this test was flaky on multiple platforms,
because it would occasionally try to execute a JavaScript function
defined in the extension's script before the script was finished
initializing. The simple fix is to use TestExtensionMessageListener
instances to wait for the extension script to finish initializing.

Bug: 515717
Change-Id: Icc8e3accbbd6bf5e47524b1b34501eba2fe0fd41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2229416Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Commit-Queue: David Bertoni <dbertoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776851}
parent ee59b5e6
......@@ -712,22 +712,17 @@ IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest, DISABLED_RulesPersistence) {
}
// http://crbug.com/304373
#if defined(OS_WIN)
// Fails on XP: http://crbug.com/515717
#define MAYBE_UninstallWhileActivePageAction \
DISABLED_UninstallWhileActivePageAction
#else
#define MAYBE_UninstallWhileActivePageAction UninstallWhileActivePageAction
#endif
IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest,
MAYBE_UninstallWhileActivePageAction) {
UninstallWhileActivePageAction) {
ext_dir_.WriteManifest(kDeclarativeContentManifest);
ext_dir_.WriteFile(FILE_PATH_LITERAL("background.js"), kBackgroundHelpers);
std::string script =
kBackgroundHelpers + std::string("\nchrome.test.sendMessage('ready');");
ext_dir_.WriteFile(FILE_PATH_LITERAL("background.js"), script);
ExtensionTestMessageListener ready_listener("ready", false);
const Extension* extension = LoadExtension(ext_dir_.UnpackedPath());
ASSERT_TRUE(extension);
// Wait for declarative rules to be set up.
content::BrowserContext::GetDefaultStoragePartition(profile())
->FlushNetworkInterfaceForTesting();
ASSERT_TRUE(ready_listener.WaitUntilSatisfied());
const std::string extension_id = extension->id();
const ExtensionAction* action =
ExtensionActionManager::Get(browser()->profile())
......@@ -754,10 +749,10 @@ IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest,
EXPECT_EQ(1u, extension_action_test_util::GetVisiblePageActionCount(tab));
EXPECT_EQ(1u, extension_action_test_util::GetTotalPageActionCount(tab));
ExtensionTestMessageListener reload_ready_listener("ready", false);
ReloadExtension(extension_id); // Invalidates action and extension.
// Wait for declarative rules to be removed.
content::BrowserContext::GetDefaultStoragePartition(profile())
->FlushNetworkInterfaceForTesting();
ASSERT_TRUE(reload_ready_listener.WaitUntilSatisfied());
EXPECT_EQ("test_rule",
ExecuteScriptInBackgroundPage(extension_id, kTestRule));
// TODO(jyasskin): Apply new rules to existing tabs, without waiting for a
......
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