Bug 200605

Summary: [iOS] Add a quirk for gmail.com messages on iPhone iOS13
Product: WebKit Reporter: Said Abou-Hallawa <sabouhallawa>
Component: ImagesAssignee: Said Abou-Hallawa <sabouhallawa>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, mitz, mjs, rniwa, simon.fraser, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=182629
https://bugs.webkit.org/show_bug.cgi?id=200948
Bug Depends on:    
Bug Blocks: 260708    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

Description Said Abou-Hallawa 2019-08-09 21:39:25 PDT
On iPhone iOS 13, the images in gmail.com messages are not rendered. The user agent for iOS 13 causes gmail.com to send all the images encapsulated in <iframe> elements whose dimensions are { width: 2px; height: 2px }. The bug was reported to Google. But till it is fixed, we are going to add a quirk which sets the user agent of iPhone iOS 12 for gmail messages only on iPhone iOS 13.
Comment 1 Said Abou-Hallawa 2019-08-09 21:47:40 PDT
Created attachment 375997 [details]
Patch
Comment 2 Said Abou-Hallawa 2019-08-09 21:49:25 PDT
<rdar://problem/52545742>
Comment 3 Ryosuke Niwa 2019-08-10 01:00:26 PDT
Comment on attachment 375997 [details]
Patch

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

> Source/WebCore/page/Quirks.cpp:354
> +bool Quirks::isGoogleMail() const

The pattern of quirks is to define method like shouldAvoidUsingIOS13ForGmail here,
and have the main logic for computing the actual UA where it's used.

> Source/WebCore/page/Quirks.cpp:362
> +    if (!isGoogleMail())

Please add a check for if (!needsQuirks()) first.
This is important so that Google developers, etc... can disable this quirk via Web Inspector.

> Source/WebCore/page/Quirks.cpp:365
> +    static const NeverDestroyed<String> iPhoneOS13 = MAKE_STATIC_STRING_IMPL("iPhone OS 13_1");

All of this logic should really appear in WebPage::platformUserAgent instead.

> Source/WebCore/page/Quirks.h:77
> +#if PLATFORM(IOS_FAMILY)

Member functions of Quirk should never have if-def like this.
If-def should appear in the implementation of this function and should always return false for #else~#endif.

> Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:3788
> +    auto document = m_page->focusController().focusedOrMainFrame().document();

Please use m_frame->coreFrame()'s document instead.
Comment 4 Said Abou-Hallawa 2019-08-10 01:52:23 PDT
Created attachment 376004 [details]
Patch
Comment 5 Said Abou-Hallawa 2019-08-10 03:39:03 PDT
Created attachment 376009 [details]
Patch
Comment 6 Said Abou-Hallawa 2019-08-10 03:52:31 PDT
Created attachment 376010 [details]
Patch
Comment 7 Said Abou-Hallawa 2019-08-10 14:36:47 PDT
Comment on attachment 375997 [details]
Patch

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

>> Source/WebCore/page/Quirks.cpp:354
>> +bool Quirks::isGoogleMail() const
> 
> The pattern of quirks is to define method like shouldAvoidUsingIOS13ForGmail here,
> and have the main logic for computing the actual UA where it's used.

shouldAvoidUsingIOS13ForGmail() was added to Quirks. And the logic for changing the user agent was moved to WebPage::platformUserAgent() in WebPageIOS.mm.

>> Source/WebCore/page/Quirks.cpp:362
>> +    if (!isGoogleMail())
> 
> Please add a check for if (!needsQuirks()) first.
> This is important so that Google developers, etc... can disable this quirk via Web Inspector.

The check was added to Quirks::shouldAvoidUsingIOS13ForGmail().

>> Source/WebCore/page/Quirks.h:77
>> +#if PLATFORM(IOS_FAMILY)
> 
> Member functions of Quirk should never have if-def like this.
> If-def should appear in the implementation of this function and should always return false for #else~#endif.

Done in Quirks::shouldAvoidUsingIOS13ForGmail().

>> Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:3788
>> +    auto document = m_page->focusController().focusedOrMainFrame().document();
> 
> Please use m_frame->coreFrame()'s document instead.

This was changed to:
    auto document = m_mainFrame->coreFrame()->document();
Comment 8 Maciej Stachowiak 2019-08-10 14:51:50 PDT
Comment on attachment 376010 [details]
Patch

Is there a way to add a test case? (I'm not sure if quirks are testable). The code change looks ok and it seems like all the comments from the previous round of review have been addressed.
Comment 9 Said Abou-Hallawa 2019-08-10 14:55:54 PDT
(In reply to Maciej Stachowiak from comment #8)
> Comment on attachment 376010 [details]
> Patch
> 
> Is there a way to add a test case? (I'm not sure if quirks are testable).
> The code change looks ok and it seems like all the comments from the
> previous round of review have been addressed.

I am not aware of a way for doing that especially gmail needs log-in credentials and navigating to a message with images.

I will ask around and if there a way for doing that I will post a follow up patch.
Comment 10 Maciej Stachowiak 2019-08-10 15:23:10 PDT
(In reply to Said Abou-Hallawa from comment #9)
>
> I will ask around and if there a way for doing that I will post a follow up
> patch.

Sounds good.
Comment 11 WebKit Commit Bot 2019-08-10 15:25:54 PDT
Comment on attachment 376010 [details]
Patch

Clearing flags on attachment: 376010

Committed r248501: <https://trac.webkit.org/changeset/248501>
Comment 12 WebKit Commit Bot 2019-08-10 15:25:56 PDT
All reviewed patches have been landed.  Closing bug.