How to get a certain header on FunctionalJavascript tests
I was getting all wrong. This is the key, copied from https://www.drupal.org/node/2857562


  All assertions within these tests must be done by checking the UI. Assertions that don't relate to UI should be added to other types of tests, a BrowserTestBase for example.


I should break this test in two one Functional to check proper header setting and the other pure FunctionalJavascript to check the element (whereas the token is set or not) is present on the page. Also does not make sense in this specific case to have two Webprofiler bars present on the page so a simple document.querySelector('[id^="sfToolbarMainContent-"]') should do the trick.