Bug 144652

Summary: baseURI getter returns bogus values in some cases
Product: WebKit Reporter: Boris Zbarsky <bzbarsky>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: ahmad.saleem792, ap, bfulgham, rniwa, sam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   

Description Boris Zbarsky 2015-05-05 18:34:24 PDT
Consider this web page:

  <iframe></iframe>
  <script>
    onload = function() {
      var doc = frames[0].document;
      doc.body.innerHTML = '<a href=""></a>'
      alert("Document base URI: " + doc.baseURI);
      alert("Anchor base URI: " + doc.querySelector('a').baseURI);
      alert("Anchor href: " + doc.querySelector('a').href);    }
  </script>

This should alert the URI of the web page three times.  In Safari it instead alerts "about:blank", "null", and the URI of the web page, respectively.
Comment 1 Boris Zbarsky 2015-05-05 18:34:54 PDT
A live demo of this is available at http://jsfiddle.net/n0gdh5y4/5/
Comment 2 Ahmad Saleem 2022-07-30 07:16:54 PDT
Here are updated test results across all browsers (using test case from Comment 01):

*** Safari 15.6 on macOS 12.5 ***

JSFiddle changed to "show":

Document base URI: https://fiddle.jshell.net/n0gdh5y4/5/show/light/
Anchor base URI: https://fiddle.jshell.net/n0gdh5y4/5/show/light/
Anchor href: https://fiddle.jshell.net/n0gdh5y4/5/show/light/

JSFiddle with "show" in URL (not Standalone but Editor mode):

Document base URI: https://fiddle.jshell.net/n0gdh5y4/5/show/?editor_console=
Anchor base URI: https://fiddle.jshell.net/n0gdh5y4/5/show/?editor_console=
Anchor href: https://fiddle.jshell.net/n0gdh5y4/5/show/?editor_console=

*** Chrome Canary 106 ***

Document base URI: https://fiddle.jshell.net/n0gdh5y4/5/show/light/
Anchor base URI: https://fiddle.jshell.net/n0gdh5y4/5/show/light/
Anchor href: https://fiddle.jshell.net/n0gdh5y4/5/show/light/

Document base URI: https://fiddle.jshell.net/n0gdh5y4/5/show/?editor_console=
Anchor base URI: https://fiddle.jshell.net/n0gdh5y4/5/show/?editor_console=
Anchor href: https://fiddle.jshell.net/n0gdh5y4/5/show/?editor_console=

*** Firefox Nightly 105 ***

Document base URI: https://fiddle.jshell.net/n0gdh5y4/5/show/light/
Anchor base URI: https://fiddle.jshell.net/n0gdh5y4/5/show/light/
Anchor href: https://fiddle.jshell.net/n0gdh5y4/5/show/light/

Document base URI: https://fiddle.jshell.net/n0gdh5y4/5/show/?editor_console=
Anchor base URI: https://fiddle.jshell.net/n0gdh5y4/5/show/?editor_console=
Anchor href: https://fiddle.jshell.net/n0gdh5y4/5/show/?editor_console=

_______________

I think it was fixed along the way since, I don't see any "about:blank", "null" etc. as mentioned from Comment 0. I think this can be marked as "RESOLVED CONFIGURATION CHANGED". Thanks!
Comment 3 Ryosuke Niwa 2022-07-30 13:24:10 PDT
Nice. Thanks for testing!