I'm not sure if this could have something to do with Diazo-Rules? I don't know which Plone Version exactly it was, but we had a Plone 5 where we had to exclude some script and style-Tags on special views in the index or manifest data to use them inline (just a hint/wild guess).
@espenmn I don't understand why your example would have worked at all in previous versions of Plone.
You are using METAL You call use-macro on the outer html tag. And from the called template (main_template/macros/master) you only fill in the content-core slot with fill-slot. Everything else in your template outside that fill-slot (the body tags, and the style/script tags) is not transported into the main_template master macro.
I probably had it inside the fill slot. (as said: I tried all 'places').
I have not had the time to test properly, but it looks like the same 'code' (a script with just 'alert' ) work, so I think the code get stripped out on 'certain occasions).
UPDATE: I think this is related to 'Plone 5.2.2 template issues' ( and $ in javascript confusing chameleon.