Bug 228008

Summary: Add support for MediaError.message
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: MediaAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, calvaris, changseok, darin, eric.carlson, esprehn+autocc, ews-watchlist, glenn, gyuyoung.kim, jer.noble, kondapallykalyan, peng.liu6, philip, philipj, sam, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Chris Dumez 2021-07-15 16:11:52 PDT
Add support for MediaError.message:
- https://html.spec.whatwg.org/multipage/media.html#mediaerror

Both Chrome and Firefox already support this.
Comment 1 Chris Dumez 2021-07-15 16:18:37 PDT
Created attachment 433634 [details]
Patch
Comment 2 Alex Christensen 2021-07-15 17:26:15 PDT
Comment on attachment 433634 [details]
Patch

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

> Source/WebCore/html/HTMLMediaElement.cpp:2072
> +    m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED, "Unsupported source type"_s);

Do Chrome and Firefox use these same strings?
Comment 3 Alex Christensen 2021-07-15 17:27:20 PDT
Comment on attachment 433634 [details]
Patch

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

>> Source/WebCore/html/HTMLMediaElement.cpp:2072
>> +    m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED, "Unsupported source type"_s);
> 
> Do Chrome and Firefox use these same strings?

Can these strings be derived from m_code instead of storing an additional String an increasing the size of MediaError?
Comment 4 Chris Dumez 2021-07-15 17:29:13 PDT
(In reply to Alex Christensen from comment #3)
> Comment on attachment 433634 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=433634&action=review
> 
> >> Source/WebCore/html/HTMLMediaElement.cpp:2072
> >> +    m_error = MediaError::create(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED, "Unsupported source type"_s);
> > 
> > Do Chrome and Firefox use these same strings?
> 
> Can these strings be derived from m_code instead of storing an additional
> String an increasing the size of MediaError?

While I did the strict minimum in this patch, you could imagine providing more useful error messages in the future. What's the point of having a message attribute if it brings nothing more than the error code attribute?
Comment 5 Alex Christensen 2021-07-15 17:32:20 PDT
Comment on attachment 433634 [details]
Patch

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

> Source/WebCore/html/MediaError.h:46
> +    static Ref<MediaError> create(Code code, const String& message)

This could at least be an r-value then.
Comment 6 Chris Dumez 2021-07-15 17:32:42 PDT
(In reply to Alex Christensen from comment #5)
> Comment on attachment 433634 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=433634&action=review
> 
> > Source/WebCore/html/MediaError.h:46
> > +    static Ref<MediaError> create(Code code, const String& message)
> 
> This could at least be an r-value then.

Sure.
Comment 7 Chris Dumez 2021-07-15 17:39:13 PDT
Created attachment 433644 [details]
Patch
Comment 8 Chris Dumez 2021-07-15 22:24:48 PDT
Created attachment 433658 [details]
Patch
Comment 9 EWS 2021-07-15 23:15:55 PDT
Committed r279978 (239721@main): <https://commits.webkit.org/239721@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 433658 [details].
Comment 10 Radar WebKit Bug Importer 2021-07-15 23:16:16 PDT
<rdar://problem/80669971>
Comment 11 Ahmad Saleem 2022-09-03 05:03:18 PDT
*** Bug 170761 has been marked as a duplicate of this bug. ***