Talk about code development, features, specific bugs, enhancements, patches, and similar things.
Forum rules
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific bugs, git, the repositories, etc.
This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Please post issues with specific websites, extensions, etc. in the relevant boards for those topics.
Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
-
noellarkin
- Fanatic

- Posts: 120
- Joined: 2021-07-27, 04:20
Unread post
by noellarkin » 2024-06-15, 06:29
When I run this in the browser console:
Code: Select all
function getEngine() {
const x = [].constructor;
try {
(-1).toFixed(-1);
} catch (err) {
return err.message.length + (x+'').split(x.name).join('').length;
}
}
console.log(getEngine());
in Firefox, I get 58, in Pale Moon it's `undefined`. I'm curious why this is the case.
Why: after a previous thread about Pale Moon emulating Firefox fingerprints (here:
viewtopic.php?f=5&t=31218) , I started looking into the differences between how Pale Moon and Firefox report fingerprints (and how websites/scripts do feature detection). One of the differences seems to be the JS engine reporting in the above example.
Here's a code snippet I found on Github:
Code: Select all
// Detect Browser
function getEngine() {
const x = [].constructor
try {
(-1).toFixed(-1)
} catch (err) {
return err.message.length + (x+'').split(x.name).join('').length
}
}
const ENGINE_IDENTIFIER = getEngine()
const IS_BLINK = ENGINE_IDENTIFIER == 80
const IS_GECKO = ENGINE_IDENTIFIER == 58
const IS_WEBKIT = ENGINE_IDENTIFIER == 77
const JS_ENGINE = ({
80: 'V8',
58: 'SpiderMonkey',
77: 'JavaScriptCore',
})[ENGINE_IDENTIFIER] || null
-
FranklinDM
- Add-ons Team

- Posts: 615
- Joined: 2017-01-14, 02:40
- Location: Philippines
Unread post
by FranklinDM » 2024-06-15, 07:13
Likely
bug 1367791.
We don't throw a range error because we're still accepting a larger negative range. That check fails since it expects that an exception will be thrown and takes the string length of the error message.
-
noellarkin
- Fanatic

- Posts: 120
- Joined: 2021-07-27, 04:20
Unread post
by noellarkin » 2024-06-15, 07:17
Thanks for looking into it. Is the large negative range essential for the engine's functioning? I'm wondering if the edit suggested in
https://hg.mozilla.org/mozilla-central/rev/03533ecbc1af can be applied to Pale Moon as well.
-
FranklinDM
- Add-ons Team

- Posts: 615
- Joined: 2017-01-14, 02:40
- Location: Philippines
Unread post
by FranklinDM » 2024-06-15, 07:27
I've filed
Issue #2531 (UXP) for this.
Updating the allowed range should be a straightforward fix, but I'm not exactly sure if there are any extensions or browser JS code that relies on this specific behavior.
-
Moonchild
- Pale Moon guru

- Posts: 37511
- Joined: 2011-08-28, 17:27
- Location: Motala, SE
Unread post
by Moonchild » 2024-06-15, 07:50
FranklinDM wrote: ↑2024-06-15, 07:13
That check fails since it expects that an exception will be thrown and takes the string length of the error message.
That's a TERRIBLE way of determining which JS engine is in use. Really now? Relying on the length of a plaintext error message thrown...?

"A dead end street is a place to turn around and go into a new direction" - Anonymous
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
-
noellarkin
- Fanatic

- Posts: 120
- Joined: 2021-07-27, 04:20
Unread post
by noellarkin » 2024-06-15, 07:59
Moonchild wrote: ↑2024-06-15, 07:50
That's a TERRIBLE way of determining which JS engine is in use. Really now? Relying on the length of a plaintext error message thrown...?
I agree, but it seems to be in use. A quick synopsis of how I stumbled upon it:
I was trying to understand how different feature detection algorithms respond to Pale Moon's "Native" mode vs "Compatibility" mode.
I went to this site, which has a collection of widely used feature detection methods:
https://abrahamjuliot.github.io/creepjs/
and compared the results between Pale Moon's Native mode, Firefox Compatibility mode and an actual Firefox browser.
Whenever I switched to PM's Compatibility mode I'd get an error saying "null JS runtime and SpiderMonkey user agent do not match" and it would lower the "browser integrity score". I dug into the source code and found the code snippet posted in the thread.
-
noellarkin
- Fanatic

- Posts: 120
- Joined: 2021-07-27, 04:20
Unread post
by noellarkin » 2024-07-01, 18:50
I compiled Pale Moon with the changes mentioned here:
https://hg.mozilla.org/mozilla-central/rev/03533ecbc1af
Binaries removed
Seems to be working fine for me, and the engine is now being recognized as spidermonkey by feature detection tests.
Last edited by noellarkin on 2024-07-02, 03:19, edited 1 time in total.
-
Moonchild
- Pale Moon guru

- Posts: 37511
- Joined: 2011-08-28, 17:27
- Location: Motala, SE
Unread post
by Moonchild » 2024-07-01, 21:47
Issue #2543 (UXP)
Critical note: please remove the Mega.nz hosted binaries. You shouldn't build test versions with official branding and disseminate them with it.
"A dead end street is a place to turn around and go into a new direction" - Anonymous
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
-
Moonchild
- Pale Moon guru

- Posts: 37511
- Joined: 2011-08-28, 17:27
- Location: Motala, SE
Unread post
by Moonchild » 2024-07-01, 22:19
Both spec issues have been fixed now - will be in 33.3.0
"A dead end street is a place to turn around and go into a new direction" - Anonymous
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite
-
noellarkin
- Fanatic

- Posts: 120
- Joined: 2021-07-27, 04:20
Unread post
by noellarkin » 2024-07-02, 03:20
Moonchild wrote: ↑2024-07-01, 21:47
Issue #2543 (UXP)
Critical note: please remove the Mega.nz hosted binaries. You shouldn't build test versions with official branding and disseminate them with it.
ah, sorry about that, didn't know. Removed them.