Commit 303d5c72 authored by Devlin Cronin's avatar Devlin Cronin Committed by Commit Bot

[Extensions] Maybe de-flake ExtensionBindingsApiTest.LastError

Attempt to deflake ExtensionBindingsApiTest.LastError. The test was
failing with a segmentation fault, which most likely happened when
trying to de-reference an ExtensionHost that could be null. Try to
fix this by:
- ASSERTing the ExtensionHost exists (at least giving us a good error
  message if it does not)
- Waiting for a "ready" message from the extension, which guarantees
  the background page has been created.

Bug: 1035011

Change-Id: I13510ea649f6488f216bf50bd4cf00bb9d521292
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1972263Reviewed-by: default avatarKaran Bhatia <karandeepb@chromium.org>
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726000}
parent bfeae890
...@@ -87,15 +87,17 @@ IN_PROC_BROWSER_TEST_F(ExtensionBindingsApiTest, ...@@ -87,15 +87,17 @@ IN_PROC_BROWSER_TEST_F(ExtensionBindingsApiTest,
// Tests that an error raised during an async function still fires // Tests that an error raised during an async function still fires
// the callback, but sets chrome.runtime.lastError. // the callback, but sets chrome.runtime.lastError.
// Flaky on all platforms: https://crbug.com/1035011 IN_PROC_BROWSER_TEST_F(ExtensionBindingsApiTest, LastError) {
IN_PROC_BROWSER_TEST_F(ExtensionBindingsApiTest, DISABLED_LastError) { ExtensionTestMessageListener ready_listener("ready", /*will_reply=*/false);
ASSERT_TRUE(LoadExtension( ASSERT_TRUE(LoadExtension(
test_data_dir_.AppendASCII("bindings").AppendASCII("last_error"))); test_data_dir_.AppendASCII("bindings").AppendASCII("last_error")));
ASSERT_TRUE(ready_listener.WaitUntilSatisfied());
// Get the ExtensionHost that is hosting our background page. // Get the ExtensionHost that is hosting our background page.
extensions::ProcessManager* manager = extensions::ProcessManager* manager =
extensions::ProcessManager::Get(browser()->profile()); extensions::ProcessManager::Get(browser()->profile());
extensions::ExtensionHost* host = FindHostWithPath(manager, "/bg.html", 1); extensions::ExtensionHost* host = FindHostWithPath(manager, "/bg.html", 1);
ASSERT_TRUE(host);
bool result = false; bool result = false;
ASSERT_TRUE(content::ExecuteScriptAndExtractBool(host->host_contents(), ASSERT_TRUE(content::ExecuteScriptAndExtractBool(host->host_contents(),
......
...@@ -54,6 +54,4 @@ function finish() { ...@@ -54,6 +54,4 @@ function finish() {
succeed(); succeed();
} }
document.documentElement.addEventListener("click", function() { chrome.test.sendMessage('ready');
testLastError();
}, true);
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