$this->
drupalGet('user'
);
$this->
assertSession()->
assertWaitOnAjaxRequest();
$current_page_string = 'NOT_RELOADED_IF_ON_PAGE';
$this->
getSession()->
executeScript('document.body.appendChild(document.createTextNode("' .
$current_page_string . '"));'
);
// Move the pointer over the branding block so the contextual link appears
// as it would with a real user interaction. Otherwise clickContextualLink()
// does not open the dialog in a manner that is opener-aware, and it isn't
// possible to reliably test focus management.
$driver_session =
$this->
getSession()->
getDriver()->
getWebDriverSession();
$element =
$driver_session->
element('css selector', '#block-branding'
);
$driver_session->
moveto(['element' =>
$element->
getID()]);
$this->
clickContextualLink('#block-branding', 'Test Link with Ajax', FALSE
);
$this->
assertNotEmpty($this->
assertSession()->
waitForElementVisible('css', '#drupal-modal'
));
$this->
assertSession()->
elementContains('css', '#drupal-modal', 'Everything is contextual!'
);
$this->
getSession()->
executeScript('document.querySelector("#block-branding .trigger").addEventListener("focus", (e) => e.target.classList.add("i-am-focused"))'
);
$this->
getSession()->
getPage()->
pressButton('Close'
);
$this->
assertSession()->
assertNoElementAfterWait('css', 'ui.dialog'
);
// When the dialog is closed, the opening contextual link is now inside a
// collapsed container, so focus should be routed to the contextual link
// toggle button.
$this->
assertNotNull($this->
assertSession()->
waitForElement('css', '.trigger.i-am-focused'
),
$this->
getSession()->
getPage()->
find('css', '#block-branding'
)->
getOuterHtml());