thewca / tnoodle

Development for the official WCA scramble server
https://www.worldcubeassociation.org/regulations/scrambles/
GNU Affero General Public License v3.0
393 stars 93 forks source link

XMLHttpRequestProgressEvent is not defined #217

Closed coder13 closed 7 years ago

coder13 commented 8 years ago

This happens on chrome Version 52.0.2743.33 beta (64-bit) I downloaded TNoodle-WCA-0.11.1.jar, ran it and after opening up the webpage in chrome, it says this Uncaught ReferenceError from line 333 of scrambleserver.js. This should be a frontend problem I believe but for what it's worth, I'm running ubuntu 16.04. I

This is my java version:

$ java -version
openjdk version "9-internal"
OpenJDK Runtime Environment (build 9-internal+0-2016-04-14-195246.buildd.src)
OpenJDK 64-Bit Server VM (build 9-internal+0-2016-04-14-195246.buildd.src, mixed mode)
jfly commented 8 years ago

This appears to be two-fold:

``` Object {error: "java.lang.reflect.InaccessibleObjectException: Una…Thread.run(java.base@9-internal/Thread.java:804)↵"} error : "java.lang.reflect.InaccessibleObjectException: Unable to make member of class sun.security.provider.Sun accessible: module java.base does not export sun.security.provider to unnamed module @45b9a632↵ at sun.reflect.Reflection.throwInaccessibleObjectException(java.base@9-internal/Reflection.java:420)↵ at java.lang.reflect.AccessibleObject.checkCanSetAccessible(java.base@9-internal/AccessibleObject.java:174)↵ at java.lang.reflect.Constructor.checkCanSetAccessible(java.base@9-internal/Constructor.java:183)↵ at java.lang.reflect.Constructor.setAccessible(java.base@9-internal/Constructor.java:176)↵ at com.google.gson.internal.ConstructorConstructor.newDefaultConstructor(ConstructorConstructor.java:97)↵ at com.google.gson.internal.ConstructorConstructor.get(ConstructorConstructor.java:79)↵ at com.google.gson.internal.bind.MapTypeAdapterFactory.create(MapTypeAdapterFactory.java:127)↵ at com.google.gson.Gson.getAdapter(Gson.java:356)↵ at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:55)↵ at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:89)↵ at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:195)↵ at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:68)↵ at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:89)↵ at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:195)↵ at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:68)↵ at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:89)↵ at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:195)↵ at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:68)↵ at com.google.gson.internal.bind.ArrayTypeAdapter.write(ArrayTypeAdapter.java:93)↵ at com.google.gson.Gson.toJson(Gson.java:593)↵ at com.google.gson.Gson.toJson(Gson.java:572)↵ at com.google.gson.Gson.toJson(Gson.java:527)↵ at com.google.gson.Gson.toJson(Gson.java:507)↵ at net.gnehzr.tnoodle.server.webscrambles.ScrambleHandler.wrappedService(ScrambleHandler.java:71)↵ at net.gnehzr.tnoodle.server.SafeHttpServlet.service(SafeHttpServlet.java:41)↵ at javax.servlet.http.HttpServlet.service(HttpServlet.java:45)↵ at winstone.ServletConfiguration.execute(ServletConfiguration.java:249)↵ at winstone.RequestDispatcher.forward(RequestDispatcher.java:335)↵ at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:378)↵ at net.gnehzr.tnoodle.server.HtmlInjectFilter.doFilter(HtmlInjectFilter.java:40)↵ at winstone.FilterConfiguration.execute(FilterConfiguration.java:195)↵ at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:368)↵ at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)↵ at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)↵ at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)↵ at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:389)↵ at winstone.FilterConfiguration.execute(FilterConfiguration.java:195)↵ at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:368)↵ at winstone.RequestDispatcher.forward(RequestDispatcher.java:333)↵ at winstone.RequestHandlerThread.processRequest(RequestHandlerThread.java:244)↵ at winstone.RequestHandlerThread.run(RequestHandlerThread.java:150)↵ at java.lang.Thread.run(java.base@9-internal/Thread.java:804)↵ ```
gyroninja commented 7 years ago

@jfly I don't know about other browser but at least on firefox (55.1.0) https://github.com/jfly/tnoodle/blob/b18452a361679dcff9b557e1feb8119b510aa203/webscrambles/WebContent/wca/scrambleserver.js#L333 can simply be changed to if(json.error instanceof XMLHttpRequest) {

I was able to test that by killing the java backend during initialization. Can we confirm it works properly in other browsers?

jfly commented 7 years ago

I just tried this out on Chrome, and I can tell you that XMLHttpRequest would not work for us there. See:

image

As you can see, in Chrome, json.error is of type ProgressEvent. The type of it is really XMLHttpRequest in Firefox? That's unfortunate...

gyroninja commented 7 years ago

I'll try playing around with it tomorrow. The fields on the objects look similar so maybe we can use some form of duck typing to determine if it's what we want.

gyroninja commented 7 years ago

My new proposal for checking it is now: json.error.currentTarget.constructor.name === "XMLHttpRequest"

Note that you'll probably need to check if some of those properties are defined (most notably currentTarget)

Firefox 50.1.0 https://i.gyazo.com/f2331bedb0f5831255100bab9ba5cdb7.png Google Chrome 55.0.2883.87 https://i.gyazo.com/47eaabe5236644efc507cc751b6b2608.png

jfly commented 7 years ago

Cool! I will accept a PR that changes this =)