Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
0dd08e66
Commit
0dd08e66
authored
9 years ago
by
Alex Bronstein
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2497115
by melvinlouwerse: ajax_page_state is not taken into account for normal GET requests
parent
35fa9676
No related branches found
No related tags found
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
+1
-2
1 addition, 2 deletions
...b/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
core/modules/system/src/Tests/Render/AjaxPageStateTest.php
+115
-0
115 additions, 0 deletions
core/modules/system/src/Tests/Render/AjaxPageStateTest.php
with
116 additions
and
2 deletions
core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php
+
1
−
2
View file @
0dd08e66
...
...
@@ -277,8 +277,7 @@ protected function processAssetLibraries(array $attached, array $placeholders) {
// Take Ajax page state into account, to allow for something like Turbolinks
// to be implemented without altering core.
// @see https://github.com/rails/turbolinks/
// @todo https://www.drupal.org/node/2497115 - Below line is broken due to ->request.
$ajax_page_state
=
$this
->
requestStack
->
getCurrentRequest
()
->
request
->
get
(
'ajax_page_state'
);
$ajax_page_state
=
$this
->
requestStack
->
getCurrentRequest
()
->
get
(
'ajax_page_state'
);
$assets
->
setAlreadyLoadedLibraries
(
isset
(
$ajax_page_state
)
?
explode
(
','
,
$ajax_page_state
[
'libraries'
])
:
[]);
$variables
=
[];
...
...
This diff is collapsed.
Click to expand it.
core/modules/system/src/Tests/Render/AjaxPageStateTest.php
0 → 100644
+
115
−
0
View file @
0dd08e66
<?php
/**
* @file
* Contains \Drupal\system\Tests\Render\AjaxPageStateTest.
*/
namespace
Drupal\system\Tests\Render
;
use
Drupal\simpletest\AssertContentTrait
;
use
Drupal\simpletest\WebTestBase
;
/**
* Performs tests for the effects of the ajax_page_state query parameter.
*
* @group Render
*/
class
AjaxPageStateTest
extends
WebTestBase
{
use
AssertContentTrait
;
/**
* User account with all available permissions
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected
$adminUser
;
protected
function
setUp
()
{
parent
::
setUp
();
// Create an administrator with all permissions.
$this
->
adminUser
=
$this
->
drupalCreateUser
(
array_keys
(
\Drupal
::
service
(
'user.permissions'
)
->
getPermissions
()));
// Login so there are more libraries to test with otherwise only html5shiv
// is the only one in the source we can easily test for.
$this
->
drupalLogin
(
$this
->
adminUser
);
}
/**
* Default functionality without the param ajax_page_state[libraries].
*
* The libraries html5shiv and drupalSettings are loaded default from core
* and available in code as scripts. Do this as the base test.
*/
public
function
testLibrariesAvailable
()
{
$this
->
drupalGet
(
'node'
,
array
());
$this
->
assertRaw
(
'/core/assets/vendor/html5shiv/html5shiv.min.js'
,
'The html5shiv library from core should be loaded.'
);
$this
->
assertRaw
(
'/core/misc/drupalSettingsLoader.js'
,
'The Dupalsettings library from core should be loaded.'
);
}
/**
* Give ajax_page_state[libraries]=core/html5shiv to exclude the library.
*
* When called with ajax_page_state[libraries]=core/html5shiv the library
* should be excluded as it is already loaded. This should not affect other
* libraries so test if drupalSettings is still available.
*
*/
public
function
testHtml5ShivIsNotLoaded
()
{
$this
->
drupalGet
(
'node'
,
array
(
"query"
=>
array
(
'ajax_page_state'
=>
array
(
'libraries'
=>
'core/html5shiv'
)
)
)
);
$this
->
assertNoRaw
(
'/core/assets/vendor/html5shiv/html5shiv.min.js'
,
'The html5shiv library from core should be excluded from loading'
);
$this
->
assertRaw
(
'/core/misc/drupalSettingsLoader.js'
,
'The Dupalsettings library from core should be loaded.'
);
}
/**
* Test if multiple libaries can be excluded.
*
* ajax_page_state[libraries] should be able to support multiple libraries
* comma separated.
*
*/
public
function
testMultipleLibrariesAreNotLoaded
()
{
$this
->
drupalGet
(
'node'
,
array
(
"query"
=>
array
(
'ajax_page_state'
=>
array
(
'libraries'
=>
'core/html5shiv,core/drupalSettings'
)
)
)
);
$this
->
assertNoRaw
(
'/core/assets/vendor/html5shiv/html5shiv.min.js'
,
'The html5shiv library from core should be excluded from loading.'
);
$this
->
assertNoRaw
(
'/core/misc/drupalSettingsLoader.js'
,
'The Dupalsettings library from core should be excluded from loading.'
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment