public function CyclicAjaxTest::testCyclicRequest in Automated Logout 8
Test not logging out when ajax cyclic request are bombarding the page.
File
- tests/
src/ FunctionalJavascript/ CyclicAjaxTest.php, line 74
Class
- CyclicAjaxTest
- Test that checks if cyclic ajax request do not prevent logout.
Namespace
Drupal\Tests\autologout\FunctionalJavascriptCode
public function testCyclicRequest() {
// Login.
$this
->drupalLogin($this->privilegedUser);
// Run JS.
self::assertTrue($this
->drupalUserIsLoggedIn($this->privilegedUser));
$this
->getSession()
->executeScript("\n function sendRequest() {\n \$.ajax({\n url: \"{$this->baseUrl}\",\n type: 'GET',\n success:\n function (res) {\n console.log('Request was sent!');\n },\n complete: function () {\n setTimeout(sendRequest, 5000); // The interval set to 5 seconds\n }\n });\n sendRequest();\n }");
sleep(13);
self::assertTrue($this
->drupalUserIsLoggedIn($this->privilegedUser));
sleep(5);
// Logged out.
self::assertFalse($this
->drupalUserIsLoggedIn($this->privilegedUser));
}