<?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>307197</bug_id>
          
          <creation_ts>2026-02-06 13:40:33 -0800</creation_ts>
          <short_desc>NavigationEvent#canIntercept is true when navigating to a different port</short_desc>
          <delta_ts>2026-02-26 14:56:12 -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>Page Loading</component>
          <version>Safari 26</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <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="Dom Christie">christiedom</reporter>
          <assigned_to name="Ahmad Saleem">ahmad.saleem792</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>basuke</cc>
    
    <cc>beidson</cc>
    
    <cc>cdumez</cc>
    
    <cc>rupin</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2178906</commentid>
    <comment_count>0</comment_count>
      <attachid>478272</attachid>
    <who name="Dom Christie">christiedom</who>
    <bug_when>2026-02-06 13:40:33 -0800</bug_when>
    <thetext>Created attachment 478272
A file that spins up 2 node servers: one at port 3000 and the other at 3001. NavigationEvent#canIntercept is logged in the browser console

[The spec](https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigateevent-canintercept-dev) states:

&gt; Generally speaking, this will be true whenever the current Document can have its URL rewritten to the destination URL, except for in the case of cross-document &quot;traverse&quot; navigations, where it will always be false.

and [defining when a document have have it&apos;s URL rewritten](https://html.spec.whatwg.org/multipage/nav-history-apis.html#can-have-its-url-rewritten):

&gt; A Document document can have its URL rewritten to a URL targetURL if the following algorithm returns true:
&gt; …
&gt; If targetURL and documentURL differ in their scheme, username, password, host, or port components, then return false.

In my tests, when navigating from localhost:3000 to localhost:3001, `navigattionEvent.canIntercept` returns `true`.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2178951</commentid>
    <comment_count>1</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2026-02-06 15:47:32 -0800</bug_when>
    <thetext>Navigation::DispatchResult Navigation::innerDispatchNavigateEvent

has:

bool canIntercept = documentCanHaveURLRewritten(*document, destination-&gt;url()) &amp;&amp; (!isTraversal || isSameDocument);

Which is coming from here:

static bool documentCanHaveURLRewritten(const Document&amp; document, const URL&amp; targetURL)
{
    const URL&amp; documentURL = document.url();
    Ref documentOrigin = document.securityOrigin();
    auto targetOrigin = SecurityOrigin::create(targetURL);
    bool isSameSite = documentOrigin-&gt;isSameSiteAs(targetOrigin);
    bool isSameOrigin = documentOrigin-&gt;isSameOriginAs(targetOrigin);

    // For cross-window navigation with document.domain, we need to check same-origin rather than same-site
    // to account for document.domain modifications that make cross-origin windows same-origin-domain
    if (!isSameSite &amp;&amp; !isSameOrigin)
        return false;

    if (targetURL.protocolIsInHTTPFamily())
        return true;

    if (targetURL.protocolIsFile() &amp;&amp; !isEqualIgnoringQueryAndFragments(documentURL, targetURL))
        return false;

    return equalIgnoringFragmentIdentifier(documentURL, targetURL);
}

^ We don&apos;t check this bit here - &gt; If targetURL and documentURL differ in their scheme, username, password, host, or port components, then return false.

So something like this might fix it:

```

    if (documentURL.protocol() != targetURL.protocol()
        || documentURL.user() != targetURL.user()
        || documentURL.password() != targetURL.password()
        || documentURL.host() != targetURL.host()
        || documentURL.port() != targetURL.port())
        return false;

```

I tested above on WPT but WPT does not seems to have coverage.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2178980</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2026-02-06 18:25:23 -0800</bug_when>
    <thetext>&lt;rdar://problem/169845691&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2178982</commentid>
    <comment_count>3</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2026-02-06 18:29:52 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/58094</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2180489</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-02-11 15:47:43 -0800</bug_when>
    <thetext>Committed 307316@main (850ce3163e55): &lt;https://commits.webkit.org/307316@main&gt;

Reviewed commits have been landed. Closing PR #58094 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2185350</commentid>
    <comment_count>5</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2026-02-26 14:56:12 -0800</bug_when>
    <thetext>@Dom - this change is in STP 238 - can you test and confirm, if it has resolved your issue?</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>478272</attachid>
            <date>2026-02-06 13:40:33 -0800</date>
            <delta_ts>2026-02-06 13:40:33 -0800</delta_ts>
            <desc>A file that spins up 2 node servers: one at port 3000 and the other at 3001. NavigationEvent#canIntercept is logged in the browser console</desc>
            <filename>servers.js</filename>
            <type>application/x-javascript</type>
            <size>882</size>
            <attacher name="Dom Christie">christiedom</attacher>
            
              <data encoding="base64">Y29uc3QgaHR0cCA9IHJlcXVpcmUoImh0dHAiKTsKCmNvbnN0IHBhZ2UgPSAobmFtZSwgcG9ydCwg
b3RoZXJQb3J0KSA9PiBgPCFET0NUWVBFIGh0bWw+CjxodG1sIGxh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