Open Bug 1904057 Opened 1 year ago Updated 1 year ago

error event doesn't fire for link elements with rel="preload"

Categories

(Core :: DOM: Networking, defect, P2)

Firefox 127
defect
Points:
5

Tracking

()

UNCONFIRMED

People

(Reporter: gudvinr+bugzilla, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-triaged][necko-priority-next])

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0

Steps to reproduce:

Example page code:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="Content-Security-Policy"
    content="frame-src http://example.com;">

  <title>Redir Test</title>

  <link rel="preload" href="http://example.com/notfound.html" as="fetch" id="nf-preload"
    onload="console.log('inline onload');"
    onerror="console.log('inline onerror');"
  >

  <script>
    const np = document.getElementById("nf-preload");
    np.addEventListener('load', (evt) => { console.log("load listener", evt) });
    np.addEventListener('error', (evt) => { console.log("error listener", evt) });
  </script>
</head>

<body>

</body>

</html>

Actual results:

I am seeing in console:

inline onload redir_test.html:1:9
load listener redir_test.html:19:52

But GET https://example.com/notfound.html returns 500.

Same will happen if you use https://examplecom/notfound.html (domain that doesn't resolve)

Expected results:

What should've happen and what spec (https://html.spec.whatwg.org/multipage/links.html#link-type-preload) says is error event being fired instead.

At the very least, onload event should not be fired because no load is actually being done at all.

In attachment, there is a screenshot from Chrome which does what you expect.

See Also: → 1765884

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Core & HTML' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core
Component: DOM: Core & HTML → DOM: Networking
Blocks: fetch
Severity: -- → S3
Priority: -- → P2
Whiteboard: [necko-triaged][necko-priority-new]
Points: --- → 5
Whiteboard: [necko-triaged][necko-priority-new] → [necko-triaged][necko-priority-next]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: