title: Unable to run scala.js on PhantomJSEnv, requiresDOM setting is forced to false
body: <p>I'd like to use websockets : </p>
  
  <pre><code>import org.scalajs.dom
  import scala.scalajs.js.JSApp
  import org.scalajs.dom.{CloseEvent, ErrorEvent, Event, MessageEvent}
  
  object ExampleJS extends JSApp {
  
    def main(): Unit = {
      val data = ""
  
      val ws = new dom.WebSocket("ws://127.0.0.1:8182")
   // val ws = new dom.WebSocket("ws://127.0.0.1:8182, "whatever")
  
      ws.onmessage = (x: MessageEvent) =&gt; Console.println(x.data.toString)
      ws.onopen = (x: Event) =&gt; {}
      ws.onerror = (x: ErrorEvent) =&gt; Console.println("some error has occurred " + x.message)
      ws.onclose = (x: CloseEvent) =&gt; {}
  
      ws.send(data)
    }
  
  }
  </code></pre>
  
  <p>But I'm still getting error like this :</p>
  
  <pre><code>[error] /home/lisak/src/viagraphs/scalajs-gremlin-client/js/target/scala-2.11/js-fastopt.js:1221
  [error]   var ws = new ScalaJS.g["WebSocket"]("ws://127.0.0.1:8081");
  [error]            ^
  [error] TypeError: undefined is not a function
  [error]     at ScalaJS.c.Lcom_viagraphs_ExampleJS$.main__V (/home/lisak/src/viagraphs/scalajs-gremlin-client/js/target/scala-2.11/js-fastopt.js:1221:12)
  [error]     at ScalaJS.c.Lcom_viagraphs_ExampleJS$.$$js$exported$meth$main__O (/home/lisak/src/viagraphs/scalajs-gremlin-client/js/target/scala-2.11/js-fastopt.js:1243:16)
  [error]     at ScalaJS.c.Lcom_viagraphs_ExampleJS$.main (/home/lisak/src/viagraphs/scalajs-gremlin-client/js/target/scala-2.11/js-fastopt.js:1246:15)
  [error]     at [stdin]:17:91
  [error]     at Object.&lt;anonymous&gt; ([stdin]-wrapper:6:22)
  [error]     at Module._compile (module.js:456:26)
  [error]     at evalScript (node.js:532:25)
  [error]     at Socket.&lt;anonymous&gt; (node.js:154:11)
  [error]     at Socket.EventEmitter.emit (events.js:117:20)
  [error]     at _stream_readable.js:920:16
  
  &gt; last fastOptStage::run
  [info] Running com.viagraphs.ExampleJS
  [debug] with JSEnv of type class scala.scalajs.sbtplugin.env.nodejs.NodeJSEnv
  [debug] with classpath of type class scala.scalajs.tools.classpath.CompleteCIClasspath$SimpleCompleteCIClasspath
  [error] 
  [error] /home/lisak/src/viagraphs/scalajs-gremlin-client/js/target/scala-2.11/js-fastopt.js:1221
  [error]   var ws = new ScalaJS.g["WebSocket"]("ws://127.0.0.1:8081");
  [error]            ^
  [error] TypeError: undefined is not a function
  [error]     at ScalaJS.c.Lcom_viagraphs_ExampleJS$.main__V (/home/lisak/src/viagraphs/scalajs-gremlin-client/js/target/scala-2.11/js-fastopt.js:1221:12)
  [error]     at ScalaJS.c.Lcom_viagraphs_ExampleJS$.$$js$exported$meth$main__O (/home/lisak/src/viagraphs/scalajs-gremlin-client/js/target/scala-2.11/js-fastopt.js:1243:16)
  [error]     at ScalaJS.c.Lcom_viagraphs_ExampleJS$.main (/home/lisak/src/viagraphs/scalajs-gremlin-client/js/target/scala-2.11/js-fastopt.js:1246:15)
  [error]     at [stdin]:17:91
  [error]     at Object.&lt;anonymous&gt; ([stdin]-wrapper:6:22)
  [error]     at Module._compile (module.js:456:26)
  [error]     at evalScript (node.js:532:25)
  [error]     at Socket.&lt;anonymous&gt; (node.js:154:11)
  [error]     at Socket.EventEmitter.emit (events.js:117:20)
  [error]     at _stream_readable.js:920:16
  java.lang.RuntimeException: node.js exited with code 8
          at scala.sys.package$.error(package.scala:27)
          at scala.scalajs.sbtplugin.env.ExternalJSEnv.runJS(ExternalJSEnv.scala:65)
          at scala.scalajs.sbtplugin.env.nodejs.NodeJSEnv.scala$scalajs$sbtplugin$env$nodejs$NodeJSEnv$$super$runJS(NodeJSEnv.scala:76)
          at scala.scalajs.sbtplugin.env.nodejs.NodeJSEnv$$anonfun$runJS$1.apply$mcV$sp(NodeJSEnv.scala:76)
          at scala.scalajs.sbtplugin.env.nodejs.NodeJSEnv$$anonfun$runJS$1.apply(NodeJSEnv.scala:76)
          at scala.scalajs.sbtplugin.env.nodejs.NodeJSEnv$$anonfun$runJS$1.apply(NodeJSEnv.scala:76)
          at scala.scalajs.sbtplugin.env.nodejs.NodeJSEnv$$anonfun$withLibCache$1.apply(NodeJSEnv.scala:43)
          at scala.util.DynamicVariable.withValue(DynamicVariable.scala:57)
          at scala.scalajs.sbtplugin.env.nodejs.NodeJSEnv.withLibCache(NodeJSEnv.scala:42)
          at scala.scalajs.sbtplugin.env.nodejs.NodeJSEnv.runJS(NodeJSEnv.scala:76)
          at scala.scalajs.sbtplugin.ScalaJSPluginInternal$.scala$scalajs$sbtplugin$ScalaJSPluginInternal$$jsRun(ScalaJSPluginInternal.scala:356)
          at scala.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$48$$anonfun$apply$18$$anonfun$apply$19.apply(ScalaJSPluginInternal.scala:420)
          at scala.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$48$$anonfun$apply$18$$anonfun$apply$19.apply(ScalaJSPluginInternal.scala:414)
          at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
          at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
          at sbt.std.Transform$$anon$4.work(System.scala:64)
          at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
          at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
          at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
          at sbt.Execute.work(Execute.scala:244)
          at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
          at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
          at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
          at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
          at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
          at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          at java.lang.Thread.run(Thread.java:745)
  [error] (js/compile:fastOptStage::run) node.js exited with code 8
  </code></pre>
  
  <p>I tried RhinoJSEnv and NodeJSEnv, both end with an error like this. I can't run it on PhantomJSEnv, I have it installed on linux, it is on PATH and working. The problem is that <code>requiresDOM</code> setting is always <code>false</code> even though I explicitly set it to <code>true</code> thuse PhantomJSEnv is never chosen as a runtime :</p>
  
  <pre><code>  override lazy val settings =
      super.settings ++ Seq(
        version := "0.0.1",
        scalaVersion := "2.11.2",
        resolvers += Resolver.mavenLocal,
        offline := true
      )
  
    lazy val js = project.in(file("js")).settings(
      Seq(
        libraryDependencies ++= Seq(
          "org.scala-lang.modules.scalajs" %%% "scalajs-dom" % "0.7-SNAPSHOT",
          "com.lihaoyi" %%% "utest" % "0.2.0" % "test"
        ),
        test in Test := (test in (Test, fastOptStage)).value,
        testFrameworks += new TestFramework("utest.runner.JvmFramework"),
        requiresDOM := true
      ) ++ Plugin.internal.utestJsSettings ++ scalaJSSettings:_*
    )
  </code></pre>