Skip to content
Snippets Groups Projects

Issue #3238915: Refactor (if feasible) uses of the jQuery ready function to use VanillaJS

Closed Issue #3238915: Refactor (if feasible) uses of the jQuery ready function to use VanillaJS
Closed Harumi Jang requested to merge issue/drupal-3238915:3238915-refactor-if-feasible into 9.3.x
1 file
+ 58
5
Compare changes
  • Side-by-side
  • Inline
@@ -6,15 +6,66 @@
@@ -6,15 +6,66 @@
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\BrowserTestBase;
/**
/**
* Tests that anonymous users are not served any JavaScript in the Standard
* Tests that anonymous users are not served any JavaScript.
* installation profile.
*
 
* This is tested with the core modules that are enabled in the 'standard'
 
* profile.
*
*
* @group Common
* @group Common
*/
*/
class NoJavaScriptAnonymousTest extends BrowserTestBase {
class NoJavaScriptAnonymousTest extends BrowserTestBase {
protected $profile = 'standard';
/**
 
* {@inheritdoc}
 
*/
 
protected $defaultTheme = 'stark';
 
 
/**
 
* Modules to enable.
 
*
 
* This is a list of modules that are enabled in the 'standard' profile.
 
*
 
* @var array
 
*/
 
protected static $modules = [
 
'node',
 
'history',
 
'block',
 
'breakpoint',
 
'ckeditor',
 
'config',
 
'comment',
 
'contextual',
 
'contact',
 
'menu_link_content',
 
'datetime',
 
'block_content',
 
'editor',
 
'help',
 
'image',
 
'menu_ui',
 
'options',
 
'path',
 
'page_cache',
 
'dynamic_page_cache',
 
'big_pipe',
 
'taxonomy',
 
'dblog',
 
'search',
 
'shortcut',
 
'toolbar',
 
'field_ui',
 
'file',
 
'rdf',
 
'views',
 
'views_ui',
 
'tour',
 
'automated_cron',
 
];
 
/**
 
* {@inheritdoc}
 
*/
protected function setUp(): void {
protected function setUp(): void {
parent::setUp();
parent::setUp();
@@ -26,11 +77,12 @@ protected function setUp(): void {
@@ -26,11 +77,12 @@ protected function setUp(): void {
* Tests that anonymous users are not served any JavaScript.
* Tests that anonymous users are not served any JavaScript.
*/
*/
public function testNoJavaScript() {
public function testNoJavaScript() {
// Create a node that is listed on the frontpage.
// Create a node of content type 'article' that is listed on the frontpage.
 
$this->drupalCreateContentType(['type' => 'article']);
$this->drupalCreateNode([
$this->drupalCreateNode([
 
'type' => 'article',
'promote' => NodeInterface::PROMOTED,
'promote' => NodeInterface::PROMOTED,
]);
]);
$user = $this->drupalCreateUser();
// Test frontpage.
// Test frontpage.
$this->drupalGet('');
$this->drupalGet('');
@@ -41,6 +93,7 @@ public function testNoJavaScript() {
@@ -41,6 +93,7 @@ public function testNoJavaScript() {
$this->assertNoJavaScript();
$this->assertNoJavaScript();
// Test user profile page.
// Test user profile page.
 
$user = $this->drupalCreateUser();
$this->drupalGet('user/' . $user->id());
$this->drupalGet('user/' . $user->id());
$this->assertNoJavaScript();
$this->assertNoJavaScript();
}
}
Loading