Closed Bug 1217790 Opened 9 years ago Closed 7 years ago

String.localeCompare behaves differently in Firefox for Desktop and Android

Categories

(Core :: JavaScript: Internationalization API, defect)

All
Android
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME
Tracking Status
firefox41 --- affected
firefox42 --- affected
firefox43 --- affected
firefox44 --- affected

People

(Reporter: jorgegarciar, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36
Firefox for Android

Steps to reproduce:

1. Setup Firefox for Android and Firefox for Desktop with the same locale configuration.
2. Create a website with this content:

<!DOCTYPE html>
<html>
<head>
	<title>Sorting</title>
</head>
<body>
	<div id='list'></div>
	<div id='sortedList'></div>

	<script>
		var list = ['c', 'd', 'E', 'a', 'B', 'C', 'AA', 'aa'];
		document.getElementById('list').appendChild(document.createTextNode(JSON.stringify(list)));
		var sortedList = list.sort(function (a, b) {
			return a.localeCompare(b);
		});
		document.getElementById('sortedList').appendChild(document.createTextNode(JSON.stringify(list)));
	</script>
</body>
</html>

3. Compare the results


Actual results:

Firefox for Desktop will render:
["c","d","E","a","B","C","AA","aa"]
["a","aa","AA","B","c","C","d","E"]

Firefox for Android will render:
["c","d","E","a","B","C","AA","aa"]
["AA","B","C","E","a","aa","c","d"]


Expected results:

Firefox for Android should render
["c","d","E","a","B","C","AA","aa"]
["a","aa","AA","B","c","C","d","E"]

(it is more consistent with any other browser I have tried).
Keywords: mobile
Confirming, affects both release (41) and nightly (44).
Status: UNCONFIRMED → NEW
Component: Untriaged → General
Ever confirmed: true
Product: Firefox → Firefox for Android
Version: 42 Branch → Firefox 42
See Bug 1097542 Comment 4.

In that bug we used explicit collation, which might be a suitable workaround for this case:

  https://hg.mozilla.org/integration/fx-team/rev/7b527ee5c7dc

To match desktop requires Bug 1215247.
Depends on: 1215247
Keywords: mobile
(In reply to Richard Newman [:rnewman] from comment #2)
> In that bug we used explicit collation, which might be a suitable workaround
> for this case:
> 
>   https://hg.mozilla.org/integration/fx-team/rev/7b527ee5c7dc

This report was for a plain old webpage lacking XPCOM access, so using XPCOM guts directly is probably impossible.

If that's the case, enabling the Intl object and building/shipping ICU on Android per bug 1215247 is the only way to match desktop.  And this would be the first known exemplar of my argument in bug 864843 comment 85.
Component: General → JavaScript: Internationalization API
OS: Unspecified → Android
Product: Firefox for Android → Core
Hardware: Unspecified → All
Version: Firefox 42 → Trunk
I verified this via Fennec Nightly 2017-02-14 that this was fixed.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.