@@ -10,6 +10,7 @@ import scala.util.control.NonFatal
10
10
11
11
import java .util .concurrent .{ConcurrentLinkedQueue , Executors }
12
12
import java .util .function .Consumer
13
+ import java .nio .file .Path
13
14
14
15
private sealed class SeleniumRun (
15
16
driver : WebDriver with JavascriptExecutor ,
@@ -129,9 +130,13 @@ private[selenium] object SeleniumRun {
129
130
newRun : Ctor [T ], failed : Throwable => T ): T = {
130
131
validator.validate(runConfig)
131
132
132
- val scripts = input.map {
133
- case Input .Script (s) => s
134
- case _ => throw new UnsupportedInputException (input)
133
+ var scripts : Seq [Path ] = Seq .empty
134
+ var modules : Seq [Path ] = Seq .empty
135
+
136
+ input.foreach {
137
+ case Input .Script (s) => scripts :+= s
138
+ case Input .ESModule (s) => modules :+= s
139
+ case _ => throw new UnsupportedInputException (input)
135
140
}
136
141
137
142
try {
@@ -141,7 +146,9 @@ private[selenium] object SeleniumRun {
141
146
scripts.map(m.materialize)
142
147
)
143
148
144
- val page = m.materialize(" scalajsRun.html" , htmlPage(allScriptURLs))
149
+ val allModuleURLs = modules.map(m.materialize)
150
+
151
+ val page = m.materialize(" scalajsRun.html" , htmlPage(allScriptURLs, allModuleURLs))
145
152
146
153
withCleanup(newDriver())(maybeCleanupDriver(_, config)) { driver =>
147
154
driver.navigate().to(page)
@@ -171,13 +178,14 @@ private[selenium] object SeleniumRun {
171
178
private def maybeCleanupDriver (d : WebDriver , config : SeleniumJSEnv .Config ) =
172
179
if (! config.keepAlive) d.close()
173
180
174
- private def htmlPage (scripts : Seq [java.net.URL ]): String = {
175
- val scriptTags =
176
- scripts.map(path => s " <script src=' ${path.toString}'></script> " )
181
+ private def htmlPage (scripts : Seq [java.net.URL ], modules : Seq [java.net.URL ]): String = {
182
+ val scriptTags = scripts.map(path => s " <script src=' ${path.toString}'></script> " )
183
+ val moduleTags = modules.map(path => s " <script type='module' src=' ${path.toString}'></script> " )
184
+ val allTags = scriptTags ++ moduleTags
177
185
s """ <html>
178
186
| <meta charset="UTF-8">
179
187
| <body>
180
- | ${scriptTags .mkString(" \n " )}
188
+ | ${allTags .mkString(" \n " )}
181
189
| </body>
182
190
|</html>
183
191
""" .stripMargin
0 commit comments