Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- [email protected]
- [email protected]
- [email protected]
ci: [ciJVM, ciJS, ciFirefox, ciChrome]
ci: [ciJVM, ciJS, ciFirefox, ciChrome, ciJSDOMNodeJS]
exclude:
- ci: ciJS
java: [email protected]
Expand Down Expand Up @@ -66,6 +66,18 @@ jobs:
scala: 2.12.14
- os: windows-latest
ci: ciChrome
- ci: ciJSDOMNodeJS
java: [email protected]
- ci: ciJSDOMNodeJS
java: [email protected]
- ci: ciJSDOMNodeJS
java: [email protected]
- os: windows-latest
scala: 3.0.1
- os: windows-latest
scala: 2.12.14
- os: windows-latest
ci: ciJSDOMNodeJS
- java: [email protected]
os: windows-latest
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -98,11 +110,16 @@ jobs:
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Setup NodeJS v14 LTS
if: matrix.ci == 'ciJS'
if: matrix.ci == 'ciJS' || matrix.ci == 'ciJSDOMNodeJS'
uses: actions/[email protected]
with:
node-version: 14

- name: Install jsdom
if: matrix.ci == 'ciJSDOMNodeJS'
shell: bash
run: npm install

- name: Check that workflows are up to date
shell: bash
run: sbt ++${{ matrix.scala }} githubWorkflowCheck
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ tags
.bloop/
metals.sbt
.vscode

# npm
node_modules/
18 changes: 14 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.{ChromeDriver, ChromeOptions}
import org.openqa.selenium.firefox.{FirefoxOptions, FirefoxProfile}
import org.openqa.selenium.remote.server.{DriverFactory, DriverProvider}
import org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv
import org.scalajs.jsenv.selenium.SeleniumJSEnv

import JSEnv._
Expand Down Expand Up @@ -66,12 +67,19 @@ val GraalVM8 = "[email protected]"
ThisBuild / githubWorkflowJavaVersions := Seq(ScalaJSJava, LTSJava, LatestJava, GraalVM8)
ThisBuild / githubWorkflowOSes := Seq(PrimaryOS, Windows)

ThisBuild / githubWorkflowBuildPreamble +=
ThisBuild / githubWorkflowBuildPreamble ++= Seq(
WorkflowStep.Use(
UseRef.Public("actions", "setup-node", "v2.1.2"),
name = Some("Setup NodeJS v14 LTS"),
params = Map("node-version" -> "14"),
cond = Some("matrix.ci == 'ciJS'"))
cond = Some("matrix.ci == 'ciJS' || matrix.ci == 'ciJSDOMNodeJS'")
),
WorkflowStep.Run(
List("npm install"),
name = Some("Install jsdom"),
cond = Some("matrix.ci == 'ciJSDOMNodeJS'")
)
)

ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Sbt(List("${{ matrix.ci }}")),
Expand All @@ -97,7 +105,7 @@ ThisBuild / githubWorkflowBuild := Seq(
)
)

val ciVariants = List("ciJVM", "ciJS", "ciFirefox", "ciChrome")
val ciVariants = List("ciJVM", "ciJS", "ciFirefox", "ciChrome", "ciJSDOMNodeJS")
val jsCiVariants = ciVariants.tail
ThisBuild / githubWorkflowBuildMatrixAdditions += "ci" -> ciVariants

Expand Down Expand Up @@ -132,6 +140,7 @@ ThisBuild / Test / jsEnv := {

useJSEnv.value match {
case NodeJS => old
case JSDOMNodeJS => new JSDOMNodeJSEnv()
case Firefox =>
val profile = new FirefoxProfile()
profile.setPreference("privacy.file_unique_origin", false)
Expand Down Expand Up @@ -177,7 +186,7 @@ val CoopVersion = "1.1.1"

replaceCommandAlias(
"ci",
"; project /; headerCheck; scalafmtSbtCheck; scalafmtCheck; clean; test; coreJVM/mimaReportBinaryIssues; root/unidoc213; set Global / useJSEnv := JSEnv.Firefox; testsJS/test; webWorkerTests/test; set Global / useJSEnv := JSEnv.Chrome; testsJS/test; webWorkerTests/test; set Global / useJSEnv := JSEnv.NodeJS"
"; project /; headerCheck; scalafmtSbtCheck; scalafmtCheck; clean; test; coreJVM/mimaReportBinaryIssues; root/unidoc213; set Global / useJSEnv := JSEnv.Firefox; testsJS/test; webWorkerTests/test; set Global / useJSEnv := JSEnv.Chrome; testsJS/test; webWorkerTests/test; set Global / useJSEnv := JSEnv.JSDOMNodeJS; testsJS/test; set Global / useJSEnv := JSEnv.NodeJS"
)

addCommandAlias(
Expand All @@ -192,6 +201,7 @@ def browserCiCommand(browser: JSEnv) =
s"; set Global / useJSEnv := JSEnv.$browser; project rootJS; headerCheck; scalafmtCheck; clean; testsJS/test; webWorkerTests/test; set Global / useJSEnv := JSEnv.NodeJS"
addCommandAlias("ciFirefox", browserCiCommand(Firefox))
addCommandAlias("ciChrome", browserCiCommand(Chrome))
addCommandAlias("ciJSDOMNodeJS", browserCiCommand(JSDOMNodeJS))

addCommandAlias("prePR", "; root/clean; scalafmtSbt; +root/scalafmtAll; +root/headerCreate")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import scala.collection.mutable
import scala.concurrent.ExecutionContext
import scala.scalajs.js
import scala.util.Random
import scala.util.control.NonFatal

/**
* Based on https://github.com/YuzuJS/setImmediate
Expand Down Expand Up @@ -47,11 +48,16 @@ private[unsafe] object PolyfillExecutionContext extends ExecutionContext {
var postMessageIsAsynchronous = true
val oldOnMessage = js.Dynamic.global.onmessage

js.Dynamic.global.onmessage = { () => postMessageIsAsynchronous = false }

js.Dynamic.global.postMessage("", "*")
js.Dynamic.global.onmessage = oldOnMessage
postMessageIsAsynchronous
try {
// This line throws `ReferenceError: onmessage is not defined` in JSDOMNodeJS environment
js.Dynamic.global.onmessage = { () => postMessageIsAsynchronous = false }
js.Dynamic.global.postMessage("", "*")
js.Dynamic.global.onmessage = oldOnMessage
postMessageIsAsynchronous
} catch {
case NonFatal(_) =>
false
}
} else {
false
}
Expand Down
Loading