// Confirm the form has more than one input to confirm that focus is moved
// to the first tabbable element in the container.
$this->
assertNotNull($page->
find('css', '#ajax-test-focus-first-command-form #edit-second-input'
));
$has_focus_id =
$this->
getSession()->
evaluateScript('document.activeElement.id'
);
$this->
assertEquals('edit-first-input',
$has_focus_id);
// Confirm that the selector provided will use the first match in the DOM as
// the container.
$page->
pressButton('SelectorMultipleMatches'
);
$this->
assertNotNull($assert_session->
waitForElementVisible('css', '#edit-inside-same-selector-container-1[data-has-focus]'
));
$this->
assertNotNull($page->
findById('edit-inside-same-selector-container-2'
));
$this->
assertNull($assert_session->
waitForElementVisible('css', '#edit-inside-same-selector-container-2[data-has-focus]'
));
$has_focus_id =
$this->
getSession()->
evaluateScript('document.activeElement.id'
);
$this->
assertEquals('edit-inside-same-selector-container-1',
$has_focus_id);
// Confirm that if a container has no tabbable children, but is itself
// focusable, then that container receives focus.
$page->
pressButton('focusableContainerNotTabbableChildren'
);
$this->
assertNotNull($assert_session->
waitForElementVisible('css', '#focusable-container-without-tabbable-children[data-has-focus]'
));
$has_focus_id =
$this->
getSession()->
evaluateScript('document.activeElement.id'
);
$this->
assertEquals('focusable-container-without-tabbable-children',
$has_focus_id);
}}