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