Fix #3614631 by delegating to script modes, instead of just importing their rules.
The indentation rules for the script mode are only applied if (real) delegation is used. (Some relevant code can be found in JEditBuffer.getIndentRules)
This patch also shortens and simplifies the file nicely, but for the price of reintroducing a corner-case bug: Closing </script> tags may be consumed by script comments, which is inconsistent with the XML plugin and most browsers.
Given that it seems impossible to fix this (in a mode file) while using (real) delegation, I'd say that having correct script mode properties is preferable to not having this bug.
(Thanks to Matthieu Casanova for pointing in the right direction.)