<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>265575</bug_id>
          
          <creation_ts>2023-11-30 05:50:24 -0800</creation_ts>
          <short_desc>Web Inspector: When there is a UA override on Safari, choosing a UA override in Develop Menu is not working</short_desc>
          <delta_ts>2024-01-12 17:49:37 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Web Inspector</component>
          <version>Safari 17</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=263619</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Karl Dubost">karlcow</reporter>
          <assigned_to name="Abrar Rahman Protyasha">a_protyasha</assigned_to>
          <cc>a_protyasha</cc>
    
    <cc>inspector-bugzilla-changes</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1995869</commentid>
    <comment_count>0</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2023-11-30 05:50:24 -0800</bug_when>
    <thetext>0. With STP 183
1. Go to a website with a UA override created for webcompat reason (the list is currently in Safari, Bug 263619 will make this list public at a point).
2. check the navigator.userAgent in the console. You should get the UA which has been forced
3. Choose Develop Menu -&gt; User Agent and change it to a different UA
4. check the navigator.userAgent in the console.

Result:
The User Agent has not changed. It didn&apos;t overrule the UA override from Safari. 

Do the same thing after disabling Site Specific Hacks, and this is working.
Disabling Site Specific Hacks, in addition to disable the quirks, will also disable the UA overrides.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1995870</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-11-30 05:50:32 -0800</bug_when>
    <thetext>&lt;rdar://problem/118981832&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2004384</commentid>
    <comment_count>2</comment_count>
    <who name="Abrar Rahman Protyasha">a_protyasha</who>
    <bug_when>2024-01-11 02:42:44 -0800</bug_when>
    <thetext>Ah, I see what&apos;s happening here.

In `FrameLoader::userAgent()`, after we assign the UA string to a site-specific quirk, we don&apos;t consult the `WebLocalFrameLoaderClient` for the UA string anymore. Notice the `userAgent.isEmpty()` check, which is false if we have a site-specific quirk:

```
    // From FrameLoader::userAgent()
    if (userAgent.isEmpty())
        userAgent = m_client-&gt;userAgent(url);
```

`WebLocalFrameLoaderClient::userAgent` gives us the UA string set on the web page, which happens to be either the default UA string or a custom UA string (such as the UA override from Safari&apos;s develop menu).

So, it seems like we need to jiggle around our logic in `FrameLoader::userAgent()`, but I don&apos;t think we have enough fidelity to tell when we should be consulting the site-specific quirk and when we should instead be consulting `WebLocalFrameLoader::userAgent` because it will tell us a custom UA string set using the `WKPageSetCustomUserAgent` API (again, such as the UA override from Safari&apos;s develop menu).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2004612</commentid>
    <comment_count>3</comment_count>
    <who name="Abrar Rahman Protyasha">a_protyasha</who>
    <bug_when>2024-01-11 20:45:11 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/22694</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2004812</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-01-12 17:49:35 -0800</bug_when>
    <thetext>Committed 273001@main (65e9ef262a03): &lt;https://commits.webkit.org/273001@main&gt;

Reviewed commits have been landed. Closing PR #22694 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>