Commit fc7898ba authored by David Tseng's avatar David Tseng Committed by Chromium LUCI CQ

Fix and re-enable various chrome.automation api tests

Update these fairly old tests, removing code that's obsolete.

Try this change on bots and hopefully most if not all will stick.

R=akihiroota@chromium.org

Fixed: 754870, 622387, 892960, 894016, 833318
Change-Id: I345385f0c538346ea993f2a79a3196402857d020
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2582529Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835669}
parent e793507d
......@@ -157,8 +157,7 @@ IN_PROC_BROWSER_TEST_F(AutomationApiTest, ImageLabels) {
EXPECT_EQ(expected_mode, web_contents->GetAccessibilityMode());
}
// TODO(aboxhall): Fix flakiness
IN_PROC_BROWSER_TEST_F(AutomationApiTest, DISABLED_GetTreeByTabId) {
IN_PROC_BROWSER_TEST_F(AutomationApiTest, GetTreeByTabId) {
StartEmbeddedTestServer();
ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "tab_id.html"))
<< message_;
......@@ -237,15 +236,13 @@ IN_PROC_BROWSER_TEST_F(AutomationApiTest, TabsAutomationHostsPermissions) {
}
#if defined(USE_AURA)
// TODO(https://crbug.com/754870): Disabled due to flakiness.
IN_PROC_BROWSER_TEST_F(AutomationApiTest, DISABLED_Desktop) {
IN_PROC_BROWSER_TEST_F(AutomationApiTest, Desktop) {
ASSERT_TRUE(RunExtensionSubtest("automation/tests/desktop", "desktop.html"))
<< message_;
}
#if BUILDFLAG(IS_CHROMEOS_ASH)
// TODO(https://crbug.com/754870): Flaky on CrOS sanitizers.
IN_PROC_BROWSER_TEST_F(AutomationApiTest, DISABLED_DesktopInitialFocus) {
IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopInitialFocus) {
ASSERT_TRUE(
RunExtensionSubtest("automation/tests/desktop", "initial_focus.html"))
<< message_;
......@@ -257,24 +254,21 @@ IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopFocusWeb) {
<< message_;
}
// TODO(https://crbug.com/622387): flaky.
IN_PROC_BROWSER_TEST_F(AutomationApiTest, DISABLED_DesktopFocusIframe) {
IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopFocusIframe) {
StartEmbeddedTestServer();
ASSERT_TRUE(
RunExtensionSubtest("automation/tests/desktop", "focus_iframe.html"))
<< message_;
}
// TODO(https://crbug.com/622387): flaky.
IN_PROC_BROWSER_TEST_F(AutomationApiTest, DISABLED_DesktopHitTestIframe) {
IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopHitTestIframe) {
StartEmbeddedTestServer();
ASSERT_TRUE(
RunExtensionSubtest("automation/tests/desktop", "hit_test_iframe.html"))
<< message_;
}
// TODO(https://crbug.com/892960): flaky.
IN_PROC_BROWSER_TEST_F(AutomationApiTest, DISABLED_DesktopFocusViews) {
IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopFocusViews) {
AutomationManagerAura::GetInstance()->Enable();
// Trigger the shelf subtree to be computed.
ash::AcceleratorController::Get()->PerformActionIfEnabled(ash::FOCUS_SHELF,
......@@ -292,13 +286,7 @@ IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopGetNextTextMatch) {
<< message_;
}
#if BUILDFLAG(IS_CHROMEOS_ASH) && defined(MEMORY_SANITIZER)
// TODO(http://crbug.com/1113853): flaky on ChromeOS.
#define MAYBE_LocationInWebView DISABLED_LocationInWebView
#else
#define MAYBE_LocationInWebView LocationInWebView
#endif
IN_PROC_BROWSER_TEST_F(AutomationApiTest, MAYBE_LocationInWebView) {
IN_PROC_BROWSER_TEST_F(AutomationApiTest, LocationInWebView) {
StartEmbeddedTestServer();
ASSERT_TRUE(RunPlatformAppTest("automation/tests/webview")) << message_;
}
......@@ -310,8 +298,7 @@ IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopNotRequested) {
}
#if BUILDFLAG(IS_CHROMEOS_ASH)
// TODO(https://crbug.com/894016): flaky.
IN_PROC_BROWSER_TEST_F(AutomationApiTest, DISABLED_DesktopActions) {
IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopActions) {
AutomationManagerAura::GetInstance()->Enable();
// Trigger the shelf subtree to be computed.
ash::AcceleratorController::Get()->PerformActionIfEnabled(ash::FOCUS_SHELF,
......@@ -326,8 +313,7 @@ IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopHitTest) {
<< message_;
}
// TODO(https://crbug.com/754870): flaky.
IN_PROC_BROWSER_TEST_F(AutomationApiTest, DISABLED_DesktopLoadTabs) {
IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopLoadTabs) {
ASSERT_TRUE(RunExtensionSubtest("automation/tests/desktop", "load_tabs.html"))
<< message_;
}
......@@ -340,8 +326,7 @@ IN_PROC_BROWSER_TEST_F(AutomationApiTest, DesktopNotSupported) {
}
#endif // defined(USE_AURA)
// Flaky test on site_per_browser_tests: https://crbug.com/833318
IN_PROC_BROWSER_TEST_F(AutomationApiTest, DISABLED_CloseTab) {
IN_PROC_BROWSER_TEST_F(AutomationApiTest, CloseTab) {
StartEmbeddedTestServer();
ASSERT_TRUE(RunExtensionSubtest("automation/tests/tabs", "close_tab.html"))
<< message_;
......
......@@ -15,15 +15,6 @@ var allTests = [
firstTextField.doDefault();
},
function testDoDefaultViews() {
listenOnce(rootNode, 'focus', function(node) {
chrome.test.succeed();
}, true);
var button = rootNode.find(
{role: 'button', attributes: {name: 'Bookmark this page'}});
button.doDefault();
},
function testContextMenu() {
var addressBar = rootNode.find({role: 'textField'});
listenOnce(rootNode, EventType.MENU_START, function(e) {
......
......@@ -6,7 +6,6 @@ var allTests = [
function testGetDesktop() {
chrome.automation.getDesktop(function(rootNode) {
assertEq(RoleType.DESKTOP, rootNode.role);
assertEq(undefined, rootNode.firstChild);
chrome.test.succeed();
});
},
......@@ -31,15 +30,6 @@ var allTests = [
chrome.test.succeed();
});
});
},
function testAutomationNodeToString() {
chrome.automation.getDesktop(function(rootNode) {
assertEq(RoleType.DESKTOP, rootNode.role);
var prefix = 'tree id=0';
assertEq(prefix, rootNode.toString().substring(0, prefix.length));
chrome.test.succeed();
});
}
];
......
......@@ -7,8 +7,6 @@ var allTests = [
var url = 'data:text/html,<!doctype html>' +
encodeURI('<input autofocus title=abc>');
chrome.automation.getDesktop(function(rootNode) {
chrome.tabs.create({url: url});
rootNode.addEventListener('focus', function(event) {
if (event.target.root.url == url) {
chrome.automation.getFocus(function(focus) {
......@@ -19,6 +17,8 @@ var allTests = [
}
}, false);
});
chrome.tabs.create({url: url});
},
];
......
......@@ -24,9 +24,9 @@ var allTests = [
function testLoadTabs() {
runWithDocument(html, function() {
var webViews = getAllWebViews();
assertEq(2, webViews.length);
var subroot = webViews[1].firstChild;
assertEq(webViews[1], subroot.parent);
assertEq(1, webViews.length);
var subroot = webViews[0].firstChild;
assertEq(webViews[0], subroot.parent);
assertEq(subroot, subroot.parent.children[0]);
var button = subroot.firstChild.firstChild;
assertEq(chrome.automation.RoleType.BUTTON, button.role);
......@@ -40,12 +40,12 @@ var allTests = [
runWithDocument(html, function(subroot) {
var button = null;
rootNode.addEventListener(chrome.automation.EventType.FOCUS,
function(evt) {
assertEq(button, evt.target);
chrome.test.succeed();
},
false);
rootNode.addEventListener(
chrome.automation.EventType.FOCUS, function(evt) {
if (button == evt.target) {
chrome.test.succeed();
}
}, false);
button = subroot.firstChild.firstChild;
button.focus();
......
......@@ -11,20 +11,18 @@ var allTests = [
var button = rootNode.find({role: 'button'});
assertEq(rootNode, button.root);
rootNode.addEventListener('destroyed', function() {
// Poll until the root node doesn't have a role anymore
// indicating that it really did get cleaned up.
function checkSuccess() {
if (rootNode.role === undefined && rootNode.root === null) {
assertEq(null, button.root);
if (rootNode.role === undefined && button.role === undefined &&
button.root === null) {
chrome.test.succeed();
}
else
} else {
window.setTimeout(checkSuccess, 10);
}
}
chrome.tabs.remove(tab.id);
checkSuccess();
});
chrome.tabs.remove(tab.id);
}
if (rootNode.docLoaded) {
......
......@@ -48,3 +48,13 @@ function getUrlFromConfig(path, callback) {
callback(url)
});
}
function createTabAndWaitUntilLoaded(url, callback) {
chrome.tabs.create({'url': url}, function(tab) {
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) {
if (tabId == tab.id && changeInfo.status == 'complete') {
callback(tab);
}
});
});
}
......@@ -46,9 +46,6 @@ var allTests = [
chrome.automation.getTree(backgroundTab.id, function(rootNode) {
chrome.test.assertFalse(rootNode === undefined,
"Got automation tree for background tab");
chrome.test.assertFalse(
rootNode.docLoaded,
"Load complete never fires unless tab is foregrounded");
chrome.tabs.update(backgroundTab.id, { active: true }, function() {
if (rootNode.docLoaded) {
......
......@@ -1773,7 +1773,6 @@ AutomationRootNodeImpl.prototype = {
},
destroy: function() {
this.dispatchEvent('destroyed', 'none');
for (var id in this.axNodeDataCache_)
this.remove(id);
this.detach();
......
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