How does FF chose the Icon for desktop URL shortcut?

When you drag a link to the desktop in Windows, a URL shortcut file is created.

FF stores a local copy of an .ico file to reference in that file, but how does Firefox select the icon to use?

What controls this? Is there any way to trace this logic? I ask since I’m not seeing the results I expect. (Was expecting favicon to be used. Seems not the case.)

If there is a better place to ask this kind of question, please let me know.