Strange behaviour of xmlhttprequest

The place to report Pale Moon specific bugs on the Windows operating system.

Moderator: satrow

thosrtanner
Fanatic
Fanatic
Posts: 142
Joined: Sat, 10 May 2014, 18:19
Location: UK

Strange behaviour of xmlhttprequest

Unread postby thosrtanner » Sun, 27 May 2018, 14:25

This snippet:

Code: Select all

    const url = "http://rawrtacular.com/bataneart/";
    const xmlHttpRequest = new XMLHttpRequest();
    xmlHttpRequest.open("GET", url);
    xmlHttpRequest.ontimeout = evt => { console.log("timed out", evt, url) };
    xmlHttpRequest.onabort = evt => { console.log("aborted", evt, url) };
    xmlHttpRequest.onerror = evt => { console.log("error", evt, url) };
    xmlHttpRequest.onload = evt => { console.log("complete", evt, url) };
    xmlHttpRequest.timeout = 10000;
    xmlHttpRequest.send();


works absolutely fine. But replace the url with "http://rawrtacular.com/bataneart" - and the request times out. Typing the url in the browser window without the '/' at the end works fine. Having said which it grows a trailing / in the process and the console says this:

Code: Select all

GET http://rawrtacular.com/bataneart [HTTP/1.1 301 Moved Permanently 250ms]
GET http://rawrtacular.com/bataneart/ [HTTP/1.1 200 OK 250ms]


so maybe the question should be why my XMLHttpRequest isn't behaving the same as the browser, and what should I do?

Addendum: I looked at the value of evt in the timeout and it has had the '/' appended to the responseURL.
Last edited by thosrtanner on Sun, 27 May 2018, 14:38, edited 1 time in total.

User avatar
JustOff
Localization Coordinator
Localization Coordinator
Posts: 1510
Joined: Thu, 03 Sep 2015, 19:47
Location: UA
Contact:

Re: Strange behaviour of xmlhttprequest

Unread postby JustOff » Sun, 27 May 2018, 15:02

I can't reproduce your issue, both urls work just fine:

Code: Select all

17:49:44.676 GET XHR http://rawrtacular.com/bataneart/ [HTTP/1.1 200 OK 1631ms]
17:49:46.280 "complete" load { target: XMLHttpRequest, isTrusted: true, lengthComputable: true, loaded: 28029, total: 28029, currentTarget: XMLHttpRequest, eventPhase: 2, bubbles: false, cancelable: false, defaultPrevented: false, timeStamp: 1527432586280000 } "http://rawrtacular.com/bataneart/" Scratchpad/1:7:37

17:50:01.663 GET XHR http://rawrtacular.com/bataneart [HTTP/1.1 301 Moved Permanently 309ms]
17:50:01.978 GET XHR http://rawrtacular.com/bataneart/ [HTTP/1.1 200 OK 305ms]
17:50:02.259 "complete" load { target: XMLHttpRequest, isTrusted: true, lengthComputable: true, loaded: 28029, total: 28029, currentTarget: XMLHttpRequest, eventPhase: 2, bubbles: false, cancelable: false, defaultPrevented: false, timeStamp: 1527432602259000 } "http://rawrtacular.com/bataneart"
Here are the add-ons I made in a spare time. That was fun!

thosrtanner
Fanatic
Fanatic
Posts: 142
Joined: Sat, 10 May 2014, 18:19
Location: UK

Re: Strange behaviour of xmlhttprequest

Unread postby thosrtanner » Sun, 27 May 2018, 16:36

Oh great. it works consistently in the console but fails consistently in the context of my extension

User avatar
JustOff
Localization Coordinator
Localization Coordinator
Posts: 1510
Joined: Thu, 03 Sep 2015, 19:47
Location: UA
Contact:

Re: Strange behaviour of xmlhttprequest

Unread postby JustOff » Sun, 27 May 2018, 16:39

Just as a guess, try using var/let instead of const.
Here are the add-ons I made in a spare time. That was fun!

thosrtanner
Fanatic
Fanatic
Posts: 142
Joined: Sat, 10 May 2014, 18:19
Location: UK

Re: Strange behaviour of xmlhttprequest

Unread postby thosrtanner » Sun, 27 May 2018, 16:42

no, broken in console. i'd put the wrong name in the request. once i'd fixed the name it times out still.

I had an issue a bit like this once that I think went away when I deleted places db, but that doesn't seem to have worked this time.

Addendum. It works in safe mode so sounds like 'hunt the extension" :-(
Last edited by thosrtanner on Sun, 27 May 2018, 16:55, edited 1 time in total.

thosrtanner
Fanatic
Fanatic
Posts: 142
Joined: Sat, 10 May 2014, 18:19
Location: UK

Re: Strange behaviour of xmlhttprequest

Unread postby thosrtanner » Sun, 27 May 2018, 17:03

and now I commit the sin of replying to myself. It's apparently adblock latitude that is doing this...

User avatar
JustOff
Localization Coordinator
Localization Coordinator
Posts: 1510
Joined: Thu, 03 Sep 2015, 19:47
Location: UA
Contact:

Re: Strange behaviour of xmlhttprequest

Unread postby JustOff » Sun, 27 May 2018, 17:05

Well ... you know ... :twisted:
Here are the add-ons I made in a spare time. That was fun!

thosrtanner
Fanatic
Fanatic
Posts: 142
Joined: Sat, 10 May 2014, 18:19
Location: UK

Re: Strange behaviour of xmlhttprequest

Unread postby thosrtanner » Sun, 27 May 2018, 18:03

:-P Now what do I do about adblock latitude (printable answers only please!)

User avatar
JustOff
Localization Coordinator
Localization Coordinator
Posts: 1510
Joined: Thu, 03 Sep 2015, 19:47
Location: UA
Contact:

Re: Strange behaviour of xmlhttprequest

Unread postby JustOff » Sun, 27 May 2018, 18:13

Perhaps use a clean profile for development? :roll:
Here are the add-ons I made in a spare time. That was fun!

thosrtanner
Fanatic
Fanatic
Posts: 142
Joined: Sat, 10 May 2014, 18:19
Location: UK

Re: Strange behaviour of xmlhttprequest

Unread postby thosrtanner » Mon, 28 May 2018, 21:23

It appears there's a rule that effectively blocks websites that are too short and don't end in a slash...


Return to “Bug reports (Windows)”

Who is online

Users browsing this forum: No registered users and 3 guests