There was a change (gerrit 152122 / 9272bc6c472122548199865c5175185bdaa469c3) which wraps a whole module in a function, but this is not done when using the preview while editing a javascript page. Makes the preview useless to see all the errors, which may generated when using Firefox (T71924).
Description
Details
- Reference
- bz70526
Related Objects
Event Timeline
The described behavior still exist. When you make a preview of your common.js with the content
alert();
the preview contains:
<script> alert('x'); </script>
Because T71924 is fixed the necessary for a preview with a encapsulated function is not very high.
User modules are transported as a string that is invoked with globalEval. Previews are called the same way by OutputPage in case of previews.
This used to be consistent. 9272bc6c4721225 temporarily made it inconsistent by wrapping them normally (but forgot about preview). However various problems with this kind of conditional wrapping were discovered in 2015 which is why I reverted my commit and gave up on this idea.
Conditional wrapping was admittedly a bad idea because conditionally executing code that is potentially incompatible with the current browser is next to impossible. We since solved this problem by instead making the download itself conditional. This was done sometime in 2016.