Error page on non-existing HTML

Discussions about the development and maturation of the platform code (UXP).
Warning: may contain highly-technical topics.

Moderators: trava90, athenian200

User avatar
UCyborg
Lunatic
Lunatic
Posts: 293
Joined: 2019-01-10, 09:37
Location: Slovenia

Error page on non-existing HTML

Unread post by UCyborg » 2025-01-31, 08:26

Sometimes the web server doesn't send any HTML when returning error code 404 on navigating to non-existent HTML file. I think it would be user friendlier if the browser provided own error page in this case to notify the user what's wrong. At least I would prefer it to plain whiteness.

Similarly, if there are other HTTP errors that result in plain whiteness.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 36973
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Error page on non-existing HTML

Unread post by Moonchild » 2025-01-31, 12:32

This would be something for an extension to do. I don't think it belongs in the core platform because it would essentially break adherence to the http protocol standard. It's up to web servers to provide informative responses in "not-ok" situations. It doesn't matter whether the response is a 200 or 4xx or 5xx response.
"The world will not be destroyed by those who do evil, but by those who watch them without doing anything." - Albert Einstein
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

User avatar
RealityRipple
Keeps coming back
Keeps coming back
Posts: 810
Joined: 2018-05-17, 02:34
Location: Los Berros Canyon, California
Contact:

Re: Error page on non-existing HTML

Unread post by RealityRipple » 2025-01-31, 17:32


User avatar
UCyborg
Lunatic
Lunatic
Posts: 293
Joined: 2019-01-10, 09:37
Location: Slovenia

Re: Error page on non-existing HTML

Unread post by UCyborg » 2025-02-01, 11:35

Thanks, guess it'll have to do.

User avatar
UCyborg
Lunatic
Lunatic
Posts: 293
Joined: 2019-01-10, 09:37
Location: Slovenia

Re: Error page on non-existing HTML

Unread post by UCyborg » 2025-02-05, 21:15

One issue, eg. when you open a PDF on Mobileshop (applies to any site that serves PDF file), it thinks the page is blank and puts an error on top after few seconds, even though the PDF is being rendered just fine with the NPAPI plugin.

Example URL: https://www.mobileshop.eu/si/specifikacije-pdf/4d69e7b48249d4b5acfe43cfb2ab672eeaa546dac9f08f0cf639fc59ea27b7ed/

More permanent URL: https://upload.wikimedia.org/wikipedia/commons/d/d3/Test.pdf

Workaround is manually removing added iframe through dev tools. The issue does not occur if PDF.js extension is used instead of the NPAPI plugin.
Last edited by UCyborg on 2025-02-05, 22:10, edited 1 time in total.

User avatar
RealityRipple
Keeps coming back
Keeps coming back
Posts: 810
Joined: 2018-05-17, 02:34
Location: Los Berros Canyon, California
Contact:

Re: Error page on non-existing HTML

Unread post by RealityRipple » 2025-02-05, 21:36

I'm guessing that means canvas elements can't capture plugin stuff with drawWindow().

User avatar
UCyborg
Lunatic
Lunatic
Posts: 293
Joined: 2019-01-10, 09:37
Location: Slovenia

Re: Error page on non-existing HTML

Unread post by UCyborg » 2025-02-05, 22:39

How about adding this check to BlankPageChecker function?

Code: Select all

if (wnd.contentDocument.plugin !== undefined)
 return;
Last edited by UCyborg on 2025-02-06, 07:42, edited 1 time in total.

User avatar
UCyborg
Lunatic
Lunatic
Posts: 293
Joined: 2019-01-10, 09:37
Location: Slovenia

Re: Error page on non-existing HTML

Unread post by UCyborg » 2025-02-05, 22:53

BTW, about the presence of wnd.contentDocument.body, according to JavaScript wizards, that check could be shortened to:

Code: Select all

if (wnd.contentDocument.body == null) // catches both null and undefined
if this is ever actually null, I'd guess it's either there and usable (not undefined) or not, similarly for plugin. Unless assuming being good practice defending against oddities. :think:

User avatar
RealityRipple
Keeps coming back
Keeps coming back
Posts: 810
Joined: 2018-05-17, 02:34
Location: Los Berros Canyon, California
Contact:

Re: Error page on non-existing HTML

Unread post by RealityRipple » 2025-02-06, 06:06

What check are you talking about? Lines 165 and so on?

User avatar
UCyborg
Lunatic
Lunatic
Posts: 293
Joined: 2019-01-10, 09:37
Location: Slovenia

Re: Error page on non-existing HTML

Unread post by UCyborg » 2025-02-06, 07:30

The one on line 163:

Code: Select all

if (wnd.contentDocument.body === null || wnd.contentDocument.body === undefined)
AFAIK, it's equivalent to:

Code: Select all

if (wnd.contentDocument.body == null)
So if we have to be picky about both null and undefined state, I suppose you can add:

Code: Select all

if (wnd.contentDocument.plugin != null)
 return;
before wnd.contentDocument.body check above or maybe after:

Code: Select all

if (wnd.contentDocument.body.scrollWidth > wnd.contentDocument.documentElement.clientWidth)
 return;
To handle the case when NPAPI plugin is involved.

User avatar
RealityRipple
Keeps coming back
Keeps coming back
Posts: 810
Joined: 2018-05-17, 02:34
Location: Los Berros Canyon, California
Contact:

Re: Error page on non-existing HTML

Unread post by RealityRipple » 2025-02-06, 10:15

UCyborg wrote:
2025-02-06, 07:30
The one on line 163:

Code: Select all

if (wnd.contentDocument.body === null || wnd.contentDocument.body === undefined)
Sorry, that was changed two months ago. I know what to check and where to put it, I was just confused because I wasn't looking at the older released version's code.

User avatar
UCyborg
Lunatic
Lunatic
Posts: 293
Joined: 2019-01-10, 09:37
Location: Slovenia

Re: Error page on non-existing HTML

Unread post by UCyborg » 2025-02-06, 11:34

Oh, I wasn't looking at the repo...aye, it's how I'd do it.

Post Reply