Bug 184345 - importScripts() should throw exception with a reason when it fails to load a script from the network
Summary: importScripts() should throw exception with a reason when it fails to load a ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Local Build
Hardware: All All
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-04-05 17:12 PDT by Daniel Bates
Modified: 2018-04-06 12:14 PDT (History)
5 users (show)

See Also:


Attachments
Patch (5.70 KB, patch)
2018-04-05 17:12 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews100 for mac-sierra (2.42 MB, application/zip)
2018-04-05 18:12 PDT, EWS Watchlist
no flags Details
Archive of layout-test-results from ews107 for mac-sierra-wk2 (3.00 MB, application/zip)
2018-04-05 18:17 PDT, EWS Watchlist
no flags Details
Archive of layout-test-results from ews200 for win-future (12.40 MB, application/zip)
2018-04-05 18:43 PDT, EWS Watchlist
no flags Details
Archive of layout-test-results from ews124 for ios-simulator-wk2 (2.22 MB, application/zip)
2018-04-05 18:45 PDT, EWS Watchlist
no flags Details
Archive of layout-test-results from ews115 for mac-sierra (3.06 MB, application/zip)
2018-04-05 19:12 PDT, EWS Watchlist
no flags Details
Patch (5.70 KB, patch)
2018-04-06 09:21 PDT, Daniel Bates
ap: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2018-04-05 17:12:21 PDT
importScripts() should throw exception with a reason when it fails to load a script from the network.
Comment 1 Daniel Bates 2018-04-05 17:12:58 PDT
Created attachment 337315 [details]
Patch
Comment 2 EWS Watchlist 2018-04-05 18:12:28 PDT Comment hidden (obsolete)
Comment 3 EWS Watchlist 2018-04-05 18:12:29 PDT Comment hidden (obsolete)
Comment 4 EWS Watchlist 2018-04-05 18:17:17 PDT Comment hidden (obsolete)
Comment 5 EWS Watchlist 2018-04-05 18:17:18 PDT Comment hidden (obsolete)
Comment 6 EWS Watchlist 2018-04-05 18:43:22 PDT Comment hidden (obsolete)
Comment 7 EWS Watchlist 2018-04-05 18:43:33 PDT Comment hidden (obsolete)
Comment 8 EWS Watchlist 2018-04-05 18:45:31 PDT Comment hidden (obsolete)
Comment 9 EWS Watchlist 2018-04-05 18:45:32 PDT Comment hidden (obsolete)
Comment 10 EWS Watchlist 2018-04-05 19:12:14 PDT Comment hidden (obsolete)
Comment 11 EWS Watchlist 2018-04-05 19:12:15 PDT Comment hidden (obsolete)
Comment 12 Daniel Bates 2018-04-06 09:21:18 PDT
Created attachment 337368 [details]
Patch
Comment 13 Alexey Proskuryakov 2018-04-06 09:37:41 PDT
Comment on attachment 337368 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=337368&action=review

> Source/WebCore/workers/WorkerGlobalScope.cpp:292
> +            return Exception { NetworkError, String { scriptLoader->error().localizedDescription() } };

I thought that the policy was that developer facing error messages were not localized. Is that incorrect?

Also, why is constructing a String necessary here?
Comment 14 Daniel Bates 2018-04-06 09:48:47 PDT
(In reply to Alexey Proskuryakov from comment #13)
> Comment on attachment 337368 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=337368&action=review
> 
> > Source/WebCore/workers/WorkerGlobalScope.cpp:292
> > +            return Exception { NetworkError, String { scriptLoader->error().localizedDescription() } };
> 
> I thought that the policy was that developer facing error messages were not
> localized. Is that incorrect?
> 

As I wrote on IRC today (04/06):

[09:40am] dydx: ap: ResourceError extends ResourceErrorBase and ResourceErrorBase owns a single string ResourceErrorBase::m_localizedDescription

As far as I can tell ResourceErrorBase::m_localizedDescription is a misnomer. It always represents a non-localized string. We should consider renaming it.


> Also, why is constructing a String necessary here?

[09:41am] dydx: ap: Exception takes an optional message as its second argument by rvalue reference; => we need to copy the String 
[09:41am] dydx: ap: We should change Exception to take a String then it will support both moving and copying semantics based on how the caller passes the String
Comment 15 Alexey Proskuryakov 2018-04-06 10:25:46 PDT
Comment on attachment 337368 [details]
Patch

> As far as I can tell ResourceErrorBase::m_localizedDescription is a misnomer. It always represents a non-localized string. We should consider renaming it.

How did you come to this conclusion? On Mac at least, it's calling an SPI which performs localization work.

However, there is a lot of precedent for using this particular ResourceError function. I think that it is unfortunate that we are mixing localized platform error strings with non-localized WebCore strings. As mentioned before, my understanding is that we want both non-localized, but I don't really know.
Comment 16 Daniel Bates 2018-04-06 10:41:27 PDT
(In reply to Alexey Proskuryakov from comment #15)
> Comment on attachment 337368 [details]
> Patch
> 
> > As far as I can tell ResourceErrorBase::m_localizedDescription is a misnomer. It always represents a non-localized string. We should consider renaming it.
> 
> How did you come to this conclusion? On Mac at least, it's calling an SPI
> which performs localization work.
> 

I'm blind.
Comment 17 Daniel Bates 2018-04-06 12:12:40 PDT
Committed r230345: <https://trac.webkit.org/changeset/230345>
Comment 18 Daniel Bates 2018-04-06 12:13:52 PDT
(In reply to Daniel Bates from comment #14)
> > Also, why is constructing a String necessary here?
> 
> [09:41am] dydx: ap: Exception takes an optional message as its second
> argument by rvalue reference; => we need to copy the String 
> [09:41am] dydx: ap: We should change Exception to take a String then it will
> support both moving and copying semantics based on how the caller passes the
> String

For completeness, I chose to teach Exception to take a String by value in the patch for bug #184360 and updated this patch to remove the explicit call to the String constructor.
Comment 19 Radar WebKit Bug Importer 2018-04-06 12:14:23 PDT
<rdar://problem/39245413>