Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Test cases often need to check if the JavaScript settings on a returned page are correct. WebTestBase from SimpleTest had a method for that, we also want it on BrowserTestBase.
Proposed resolution
Implement the method getDrupalSettings() on BrowserTestBase.
Remaining tasks
Patch.
User interface changes
None.
API changes
None,
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#2 | js-settings-2759859-2.patch | 2.03 KB | klausi |
Comments
Comment #2
klausiPatch.
Comment #3
jibranNice and easy. Thanks @klausi
Comment #4
larowlanAre we sure we want to go down this route? Shouldn't we be deferring all JavaScript functionality to JTB?
We deliberately avoided adding drupalPostAjaxForm to BTB for the same reason. If you want ajax, you use JTB instead of using poorman's emulation.
Comment #5
klausiThis is just for asserting that JS settings are on the page, it is not necessary to execute any js in the browser for that. I agree that any Ajax testing should be in JavascriptTestBase, but this check is fine here.
Comment #6
dawehnerCan we move this to the webassert?
Comment #7
klausiIt is not an assertion method, so I think we should keep it on BrowserTestBase itself. Same as we have getUrl() or xpath() there.
Comment #8
dawehnerAh you are right.
Comment #9
alexpottCommitted da9cb25 and pushed to 8.1.x and 8.2.x. Thanks!