On 10/06/2016 23:01, zbranie...@mozilla.com wrote:
On Friday, June 10, 2016 at 10:37:04 AM UTC-7, Gijs Kruitbosch wrote:

This async-ness will not be acceptable in all circumstances. As a
somewhat random example: how would we localize the 'slow script' dialog,
for which we have to pause script and then show the dialog?

Agree, there are exceptions, and we may have to provide sync version (which 
will have limited functionality) for such cases.

For this particular case, the way we approached it in FxOS was to do something 
like replacing:

window.alert(l10n.get("slowScriptTitle"));

with:

l10n.formatValue("slowScriptTitle").then(val => window.alert(val));


Would that not work?

I don't know, you'd have to ask people who are more intimately familiar with how our slow script interrupt code works. It's in C++, so I'm not sure how your example maps. Intuitively, I am worried it might not work - we're trying to stop script from running, and so waiting on a promise and then running script on the same (UI) thread feels interesting. Maybe it's solvable with *shudder* another nested event loop to wait for that promise, or something.

Another example: in docshell, some error page URLs are currently generated
synchronously in some circumstances (invalid host/uris, for instance).
Making such a location change asynchronous just because of localization
is going to break a *lot* of assumptions, not to mention require
rewriting a bunch of yucky docshell code that will then probably break
some more assumptions...

Yay! :)

If you're saying that we're generating URLs with localized messages in them, 
then I'd question to design...

http://searchfox.org/mozilla-central/rev/ff5673acd6a38a43bc250a2baa47df8fe6ef7859/docshell/base/nsDocShell.cpp#5150-5151

http://searchfox.org/mozilla-central/rev/ff5673acd6a38a43bc250a2baa47df8fe6ef7859/docshell/base/nsDocShell.cpp#5291-5294

Nobody I know of particularly likes this code (I believe this to be true much more generally than this particular quirk of it, for that matter - error page handling is "interesting".), but it does exist, yes. The problem is that the error page is unprivileged and so doesn't have access to the stringbundles one would like to use, so it's not entirely trivial to fix. Certainly not unchangeable, though...

~ Gijs
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to