Skip to content

Upgrade to Scala.js 1.0.0-M5. #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 16, 2018
Merged

Conversation

sjrd
Copy link
Member

@sjrd sjrd commented Jul 4, 2018

No description provided.

@sjrd sjrd requested a review from gzm0 July 4, 2018 13:23
@sjrd sjrd force-pushed the upgrade-scalajs-1.0.0-M5 branch from 21a8746 to e8020fd Compare July 4, 2018 13:24
@@ -0,0 +1,159 @@
package org.scalajs.jsenv.jsdomnodejs

// !!! This entire file is copied from TestKit.scala upstream
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This here is absolutely disgusting. What was I supposed to do, here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need all this? From what I can see is all you want to test is that the window API doesn't fail (I guess that is to check there is a DOM).

Wouldn't it be enough to check:

  • That the code window.history.pushState({}, "", "/foo"); window.close() terminates successfully.
  • That the code window.history.inexistent(); does fail.

That way you only need to rely on the public interface of the Env.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well TestKit only relies on the public API of JSEnv too. I first tried to do it by hand, but quickly ended up redoing several steps already provided by the test kit: handling of futures, comparison of the output, etc. Eventually I decided that I would have less to maintain by copying it over.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well TestKit only relies on the public API of JSEnv too.

Yes, but your test will then also rely on TestKit.

I understand that output handling is difficult, but do you need to read output here? Future handling would be just calling Await.result, or am I missing something?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a commit that shows what the test looks like if I don't use TestKit. It does not read the output, which indeed makes the thing simpler. It would be significantly more complicated if it did have to check the output, though.

Should I proceed with the new test, and rip out the one using TestKit?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's go ahead with this for now and then re-asses whether we need to expose something TestKit like (IMHO TestKit needs better design before we expose it).

| var scalajsComWrapper = scalajsCom === (void 0) ? scalajsCom : ({
| init: function(recvCB) {
| scalajsCom.init(function(msg) {
| process.nextTick(recvCB, msg);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this should be integrated inside ComSupport.scala upstream.

If I don't do this, I get an IllegalStateException because the message for JSEndPoints.detectFrameworks is delivered before TestAdapterBridge.start() gets to setup the handler. Indeed, the messages are delivered during the constructor of TestAdapterBridge, through the constructor of JSRPC.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... Yes, but why does this not happen in the base env :-S

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because in the base Node.js env, there is no return to the event loop between the startup and start(), so the network messages haven't had a chance to be processed by a JS event handler, so they're not yet in the message buffer in JS. They're still in a C++ buffer somewhere. In the jsdom env, there is a come back to the event loop before this code is executed.

It took me a while to figure it out ^^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ah, I see. Fair enough. So yes, it should definitely be moved to ComSupport.

@sjrd sjrd force-pushed the upgrade-scalajs-1.0.0-M5 branch from e8020fd to 9463ff2 Compare July 4, 2018 13:39
/* In Scala 2.10.x, NotImplementedError was considered fatal.
* We need this case for the conformance tests to pass on 2.10.
*/
JSRun.failed(t)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given scala/scala@68f62d7, perhaps the conformance tests should use a different exception than NotImplementedError. Anything else that would be considered NonFatal by 2.10.x, really.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed :-/

@sjrd sjrd force-pushed the upgrade-scalajs-1.0.0-M5 branch from 386de74 to 9403c96 Compare July 16, 2018 08:30
@sjrd sjrd merged commit 21f3334 into scala-js:master Jul 16, 2018
@sjrd sjrd deleted the upgrade-scalajs-1.0.0-M5 branch July 16, 2018 08:48
lolgab pushed a commit to lolgab/scala-js-env-jsdom-nodejs that referenced this pull request Apr 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants