file.path
- case file => libCache.materialize(file).getAbsolutePath
- }
- val scriptsURIs =
- scriptsPaths.map(path => new java.io.File(path).toURI.toASCIIString)
- val scriptsURIsAsJSStrings = scriptsURIs.map('"' + escapeJS(_) + '"')
- val jsDOMCode = {
- s"""
- |(function () {
- | var jsdom;
- | try {
- | jsdom = require("jsdom/lib/old-api.js"); // jsdom >= 10.x
- | } catch (e) {
- | jsdom = require("jsdom"); // jsdom <= 9.x
- | }
- |
- | var virtualConsole = jsdom.createVirtualConsole()
- | .sendTo(console, { omitJsdomErrors: true });
- | virtualConsole.on("jsdomError", function (error) {
- | /* This inelegant if + console.error is the only way I found
- | * to make sure the stack trace of the original error is
- | * printed out.
- | */
- | if (error.detail && error.detail.stack)
- | console.error(error.detail.stack);
- |
- | // Throw the error anew to make sure the whole execution fails
- | throw error;
- | });
- |
- | jsdom.env({
- | html: "",
- | url: "http://localhost/",
- | virtualConsole: virtualConsole,
- | created: function (error, window) {
- | if (error == null) {
- | window["__ScalaJSEnv"] = __ScalaJSEnv;
- | window["scalajsCom"] = global.scalajsCom;
- | } else {
- | throw error;
- | }
- | },
- | scripts: [${scriptsURIsAsJSStrings.mkString(", ")}]
- | });
- |})();
- |""".stripMargin
- }
- Seq(new MemVirtualJSFile("codeWithJSDOMContext.js").withContent(jsDOMCode))
- }
-
- /** All the JS files that are passed to the VM.
- *
- * This method can overridden to provide custom behavior in subclasses.
- *
- * This method is overridden in `JSDOMNodeJSEnv` so that user-provided
- * JS files (excluding "init" files) are executed as *scripts* within the
- * jsdom environment, rather than being directly executed by the VM.
- *
- * The value returned by this method in `JSDOMNodeJSEnv` is
- * `initFiles() ++ customInitFiles() ++ codeWithJSDOMContext()`.
- */
- override protected def getJSFiles(): Seq[VirtualJSFile] =
- initFiles() ++ customInitFiles() ++ codeWithJSDOMContext()
-
- /** JS files to be loaded via scripts in the jsdom environment.
- *
- * This method can be overridden to provide a different list of scripts.
- *
- * The default value in `JSDOMNodeJSEnv` is `files`.
- */
- protected def getScriptsJSFiles(): Seq[VirtualJSFile] =
- files
-
- // Send code to Stdin
- override protected def sendVMStdin(out: OutputStream): Unit = {
- /* Do not factor this method out into AbstractNodeRunner or when mixin in
- * the traits it would use AbstractExtRunner.sendVMStdin due to
- * linearization order.
- */
- sendJS(getJSFiles(), out)
- }
- }
-}
-
-object JSDOMNodeJSEnv {
- final class Config private (
- val executable: String,
- val args: List[String],
- val env: Map[String, String]
- ) {
- private def this() = {
- this(
- executable = "node",
- args = Nil,
- env = Map.empty
- )
- }
-
- def withExecutable(executable: String): Config =
- copy(executable = executable)
-
- def withArgs(args: List[String]): Config =
- copy(args = args)
-
- def withEnv(env: Map[String, String]): Config =
- copy(env = env)
-
- private def copy(
- executable: String = executable,
- args: List[String] = args,
- env: Map[String, String] = env
- ): Config = {
- new Config(executable, args, env)
- }
- }
-
- object Config {
- /** Returns a default configuration for a [[JSDOMNodeJSEnv]].
- *
- * The defaults are:
- *
- * - `executable`: `"node"`
- * - `args`: `Nil`
- * - `env`: `Map.empty`
- */
- def apply(): Config = new Config()
- }
-}
diff --git a/jsdom-nodejs-env/src/test/scala/org/scalajs/jsenv/jsdomnodejs/JSDOMNodeJSEnvTest.scala b/jsdom-nodejs-env/src/test/scala/org/scalajs/jsenv/jsdomnodejs/JSDOMNodeJSEnvTest.scala
deleted file mode 100644
index 0957c6e998..0000000000
--- a/jsdom-nodejs-env/src/test/scala/org/scalajs/jsenv/jsdomnodejs/JSDOMNodeJSEnvTest.scala
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.scalajs.jsenv.jsdomnodejs
-
-import org.scalajs.jsenv.test._
-
-import org.junit.Test
-import org.junit.Assert._
-
-class JSDOMNodeJSEnvTest extends TimeoutComTests {
-
- protected def newJSEnv: JSDOMNodeJSEnv = new JSDOMNodeJSEnv()
-
- @Test
- def historyAPI: Unit = {
- """|console.log(window.location.href);
- |window.history.pushState({}, "", "/foo");
- |console.log(window.location.href);
- """.stripMargin hasOutput
- """|http://localhost/
- |http://localhost/foo
- |""".stripMargin
- }
-
-}
diff --git a/package.json b/package.json
index 28a69413e5..9c61a9b571 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,6 @@
"private": true,
"devDependencies": {
"source-map-support": "0.4.15",
- "jszip": "2.4.0",
- "jsdom": "9.12.0"
+ "jszip": "2.4.0"
}
}
diff --git a/project/Build.scala b/project/Build.scala
index 0ad4c95a9e..13196e38f6 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -24,7 +24,6 @@ import org.scalajs.core.ir.Utils.escapeJS
import org.scalajs.sbtplugin._
import org.scalajs.jsenv.{ConsoleJSConsole, JSEnv}
import org.scalajs.jsenv.nodejs.NodeJSEnv
-import org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv
import ScalaJSPlugin.autoImport.{ModuleKind => _, _}
import ExternalCompile.scalaJSExternalCompileSettings
@@ -494,7 +493,6 @@ object Build {
clean in irProject, clean in irProjectJS,
clean in tools, clean in toolsJS,
clean in jsEnvs, clean in jsEnvsTestKit, clean in nodeJSEnv,
- clean in jsdomNodeJSEnv,
clean in testAdapter, clean in plugin,
clean in javalanglib, clean in javalib, clean in scalalib,
clean in libraryAux, clean in library,
@@ -781,16 +779,6 @@ object Build {
previousArtifactSetting
).dependsOn(jsEnvs, jsEnvsTestKit % "test")
- // Node.js with jsdom - to be moved in a separate repository
- lazy val jsdomNodeJSEnv: Project = (project in file("jsdom-nodejs-env")).settings(
- commonSettings,
- fatalWarningsSettings,
- name := "Scala.js JSDOM Node.js env",
- normalizedName := "scalajs-jsdom-nodejs-env",
- libraryDependencies +=
- "com.novocode" % "junit-interface" % "0.9" % "test"
- ).dependsOn(jsEnvs, nodeJSEnv, jsEnvsTestKit % "test")
-
lazy val testAdapter = (project in file("test-adapter")).settings(
commonSettings,
publishSettings,
@@ -1254,7 +1242,12 @@ object Build {
exampleSettings,
name := "Testing - Scala.js example",
moduleName := "testing",
- jsEnv := new JSDOMNodeJSEnv()
+
+ test in Test := {
+ throw new MessageOnlyException(
+ "testingExample/test is not supported because it requires DOM " +
+ "support. Use testingExample/testHtml instead.")
+ }
).withScalaJSCompiler.withScalaJSJUnitPlugin.dependsOn(
library, jUnitRuntime % "test"
)
@@ -1285,9 +1278,6 @@ object Build {
baseArgs
}
- case env: JSDOMNodeJSEnv =>
- Seq("nodejs.jsdom", "typedarray")
-
case _ =>
throw new AssertionError(
s"Unknown JSEnv of class ${env.getClass.getName}: " +
@@ -1409,7 +1399,7 @@ object Build {
// We need to patch the system properties.
scalaJSJavaSystemProperties in Test in testHtml ~= { base =>
val unsupported =
- Seq("nodejs", "nodejs.jsdom", "source-maps")
+ Seq("nodejs", "source-maps")
val supported =
Seq("typedarray", "browser")
diff --git a/project/build.sbt b/project/build.sbt
index b4425ac674..fac9407d39 100644
--- a/project/build.sbt
+++ b/project/build.sbt
@@ -28,7 +28,6 @@ unmanagedSourceDirectories in Compile ++= {
root / "tools/jvm/src/main/scala",
root / "js-envs/src/main/scala",
root / "nodejs-env/src/main/scala",
- root / "jsdom-nodejs-env/src/main/scala",
root / "test-adapter/src/main/scala",
root / "sbt-plugin/src/main/scala",
root / "jsdependencies-core/src/main/scala",
diff --git a/sbt-plugin-test/build.sbt b/sbt-plugin-test/build.sbt
index 1f3293219e..ab178c6ac7 100644
--- a/sbt-plugin-test/build.sbt
+++ b/sbt-plugin-test/build.sbt
@@ -1,5 +1,4 @@
import org.scalajs.core.tools.io._
-import org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv
import org.scalajs.sbtplugin.ScalaJSPluginInternal._
import org.scalajs.sbtplugin.Loggers.sbtLogger2ToolsLogger
@@ -31,7 +30,7 @@ lazy val referencedCrossProjectJS = ProjectRef(file("referencedCrossProject"), "
lazy val referencedCrossProjectJVM = ProjectRef(file("referencedCrossProject"), "referencedCrossProjectJVM")
lazy val root = project.in(file(".")).
- aggregate(noDOM, withDOM, multiTestJS, multiTestJVM, referencedCrossProjectJS, referencedCrossProjectJVM)
+ aggregate(noDOM, multiTestJS, multiTestJVM, referencedCrossProjectJS, referencedCrossProjectJVM)
lazy val noDOM = project.settings(baseSettings: _*).
enablePlugins(ScalaJSPlugin).
@@ -70,15 +69,6 @@ lazy val noDOM = project.settings(baseSettings: _*).
}
)))
-lazy val withDOM = project.settings(baseSettings: _*).
- enablePlugins(ScalaJSPlugin).
- enablePlugins(ScalaJSJUnitPlugin).
- settings(
- name := "Scala.js sbt test w/ DOM",
- jsEnv := new JSDOMNodeJSEnv(),
- scalaJSUseMainModuleInitializer := true
- )
-
lazy val testFramework = crossProject.crossType(CrossType.Pure).
settings(versionSettings: _*).
settings(name := "Dummy cross JS/JVM test framework").
diff --git a/sbt-plugin-test/project/build.sbt b/sbt-plugin-test/project/build.sbt
index 7f835dfb85..6626b7a52e 100644
--- a/sbt-plugin-test/project/build.sbt
+++ b/sbt-plugin-test/project/build.sbt
@@ -1,5 +1,2 @@
addSbtPlugin("org.scala-js" % "sbt-scalajs" %
org.scalajs.core.ir.ScalaJSVersions.current)
-
-libraryDependencies +=
- "org.scala-js" %% "scalajs-jsdom-nodejs-env" % org.scalajs.core.ir.ScalaJSVersions.current
diff --git a/sbt-plugin-test/withDOM/src/main/scala/sbttest/withDOM/Lib.scala b/sbt-plugin-test/withDOM/src/main/scala/sbttest/withDOM/Lib.scala
deleted file mode 100644
index 4c22036338..0000000000
--- a/sbt-plugin-test/withDOM/src/main/scala/sbttest/withDOM/Lib.scala
+++ /dev/null
@@ -1,19 +0,0 @@
-package sbttest.withDOM
-
-import scala.scalajs.js
-
-object Lib {
-
- val document: js.Dynamic = js.Dynamic.global.document
-
- def getElementsByTagName(name: String): js.Array[js.Dynamic] =
- document.getElementsByTagName(name).asInstanceOf[js.Array[js.Dynamic]]
-
- /** appends a with the message to the document */
- def appendDocument(msg: String): Unit = {
- val elem = document.createElement("p")
- elem.appendChild(document.createTextNode(msg))
- document.body.appendChild(elem)
- }
-
-}
diff --git a/sbt-plugin-test/withDOM/src/main/scala/sbttest/withDOM/TestApp.scala b/sbt-plugin-test/withDOM/src/main/scala/sbttest/withDOM/TestApp.scala
deleted file mode 100644
index 08e9cecbf0..0000000000
--- a/sbt-plugin-test/withDOM/src/main/scala/sbttest/withDOM/TestApp.scala
+++ /dev/null
@@ -1,12 +0,0 @@
-package sbttest.withDOM
-
-object TestApp {
-
- def main(args: Array[String]): Unit = {
- Lib.appendDocument("Hello World")
- Lib.appendDocument("Still Here!")
-
- println(Lib.getElementsByTagName("p").head.innerHTML)
- }
-
-}
diff --git a/sbt-plugin-test/withDOM/src/test/scala/sbttest/withDOM/LibTest.scala b/sbt-plugin-test/withDOM/src/test/scala/sbttest/withDOM/LibTest.scala
deleted file mode 100644
index 174ec87af2..0000000000
--- a/sbt-plugin-test/withDOM/src/test/scala/sbttest/withDOM/LibTest.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-package sbttest.withDOM
-
-import scala.scalajs.js
-
-import org.junit.Test
-import org.junit.Assert._
-
-class LibTest {
- @Test def dummy_library_should_append_an_element(): Unit = {
- def count = Lib.getElementsByTagName("p").length
-
- val oldCount = count
- Lib.appendDocument("foo")
- assertEquals(1, count - oldCount)
- }
-}
diff --git a/test-suite/js/src/main/scala/org/scalajs/testsuite/utils/Platform.scala b/test-suite/js/src/main/scala/org/scalajs/testsuite/utils/Platform.scala
index a93dd7e269..a7b8cda5ef 100644
--- a/test-suite/js/src/main/scala/org/scalajs/testsuite/utils/Platform.scala
+++ b/test-suite/js/src/main/scala/org/scalajs/testsuite/utils/Platform.scala
@@ -34,7 +34,6 @@ object Platform {
js.typeOf(js.Dynamic.global.Symbol) != "undefined"
def executingInNodeJS: Boolean = sysProp("nodejs")
- def executingInNodeJSOnJSDOM: Boolean = sysProp("nodejs.jsdom")
def executingInBrowser: Boolean = sysProp("browser")
def typedArrays: Boolean = sysProp("typedarray")
def sourceMaps: Boolean = sysProp("source-maps")
diff --git a/test-suite/js/src/test/scala/org/scalajs/testsuite/javalib/lang/SystemJSTest.scala b/test-suite/js/src/test/scala/org/scalajs/testsuite/javalib/lang/SystemJSTest.scala
index 0b610351ce..b5cb513834 100644
--- a/test-suite/js/src/test/scala/org/scalajs/testsuite/javalib/lang/SystemJSTest.scala
+++ b/test-suite/js/src/test/scala/org/scalajs/testsuite/javalib/lang/SystemJSTest.scala
@@ -105,22 +105,17 @@ class SystemJSTest {
val inBrowser = get("scalajs.browser") == "true"
val inNode = get("scalajs.nodejs") == "true"
- val inNodeWithJSDOM = get("scalajs.nodejs.jsdom") == "true"
if (inBrowser) {
assertNotEquals("undefined", js.typeOf(js.Dynamic.global.window))
- assertFalse(inNode || inNodeWithJSDOM)
+ assertFalse(inNode)
} else if (inNode) {
assertNotEquals("undefined", js.typeOf(js.Dynamic.global.process))
- assertFalse(inBrowser || inNodeWithJSDOM)
- } else if (inNodeWithJSDOM) {
- assertNotEquals("undefined", js.typeOf(js.Dynamic.global.window))
- assertFalse(inBrowser || inNode)
+ assertFalse(inBrowser)
} else {
fail("No known platform tag found.")
}
assertEquals(inBrowser, Platform.executingInBrowser)
assertEquals(inNode, Platform.executingInNodeJS)
- assertEquals(inNodeWithJSDOM, Platform.executingInNodeJSOnJSDOM)
val typedArrays = get("scalajs.typedarray") == "true"
assertEquals(typedArrays, Platform.typedArrays)
diff --git a/test-suite/jvm/src/main/scala/org/scalajs/testsuite/utils/Platform.scala b/test-suite/jvm/src/main/scala/org/scalajs/testsuite/utils/Platform.scala
index 163c87e3f6..da043e5ae6 100644
--- a/test-suite/jvm/src/main/scala/org/scalajs/testsuite/utils/Platform.scala
+++ b/test-suite/jvm/src/main/scala/org/scalajs/testsuite/utils/Platform.scala
@@ -21,7 +21,6 @@ object Platform {
}
def executingInNodeJS: Boolean = false
- def executingInNodeJSOnJSDOM: Boolean = false
def typedArrays: Boolean = false
def sourceMaps: Boolean = false