<?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>57906</bug_id>
          
          <creation_ts>2011-04-05 17:02:21 -0700</creation_ts>
          <short_desc>Reload after document.write in new window loads wrong page</short_desc>
          <delta_ts>2011-04-06 17:21:50 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>History</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>50331</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Charles Reis">creis</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>abarth</cc>
    
    <cc>ap</cc>
    
    <cc>creis</cc>
    
    <cc>darin</cc>
    
    <cc>fishd</cc>
    
    <cc>mihaip</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>379970</commentid>
    <comment_count>0</comment_count>
    <who name="Charles Reis">creis</who>
    <bug_when>2011-04-05 17:02:21 -0700</bug_when>
    <thetext>Repro steps:
w = window.open(any_url)
w.document.write(1)
w.location.reload()

The reload() results in the *opener&apos;s* url being loaded into the child window, instead of any_url.  Layout test attached.

Note that in debug builds, it also hits the ASSERT in HistoryController::restoreScrollPositionAndViewState, which is being discussed in bug 50331.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>380096</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2011-04-05 21:06:13 -0700</bug_when>
    <thetext>At the moment, there is no test case attached.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>380445</commentid>
    <comment_count>2</comment_count>
      <attachid>88439</attachid>
    <who name="Charles Reis">creis</who>
    <bug_when>2011-04-06 09:07:08 -0700</bug_when>
    <thetext>Created attachment 88439
Layout test for window.open, document.write, location.reload</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>380710</commentid>
    <comment_count>3</comment_count>
    <who name="Charles Reis">creis</who>
    <bug_when>2011-04-06 12:10:10 -0700</bug_when>
    <thetext>I&apos;ve tracked it down to Document::write, which calls Document::open using the ownerDocument it got from V8HTMLDocument::writeCallback.  In this case, ownerDocument is the opener document, rather than the new window&apos;s document.

All of that code seems pretty intentional, though.  Is this intended behavior?  I found it pretty surprising to have the opener&apos;s page show up in the new window...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>380768</commentid>
    <comment_count>4</comment_count>
    <who name="Charles Reis">creis</who>
    <bug_when>2011-04-06 13:27:46 -0700</bug_when>
    <thetext>Adam Barth points out that this is actually intentional.  The opener page is overwriting the child page with document.write, so its security context takes over.

WebKit&apos;s behavior still differs from Firefox and IE (which simply reload the &quot;1&quot; from the document.write), but at least Firefox replaces the URL of the new window with the opener&apos;s URL.

I&apos;ll mark it won&apos;t fix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>380843</commentid>
    <comment_count>5</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2011-04-06 14:32:34 -0700</bug_when>
    <thetext>Is there a regression test for this? Also, a comment would be better than code that just looks intentional :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>380871</commentid>
    <comment_count>6</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2011-04-06 15:01:50 -0700</bug_when>
    <thetext>&gt; Is there a regression test for this?

Yes.  The test was added when I added this code.

&gt; Also, a comment would be better than code that just looks intentional :)

Comments are good.

There isn&apos;t a test for the root issue Charlie is investigating because the underlying problem is that the embedder isn&apos;t properly handling messages its getting from WebKit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>380966</commentid>
    <comment_count>7</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2011-04-06 16:39:58 -0700</bug_when>
    <thetext>Did this come up on a real world website?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>380988</commentid>
    <comment_count>8</comment_count>
    <who name="Charles Reis">creis</who>
    <bug_when>2011-04-06 17:21:50 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; Did this come up on a real world website?

No, it&apos;s from a toy example page showing incorrect URL bar behavior in Chrome (not Safari).  As Adam mentions, it&apos;s likely an issue in the embedder logic.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>88439</attachid>
            <date>2011-04-06 09:07:08 -0700</date>
            <delta_ts>2011-04-06 09:07:08 -0700</delta_ts>
            <desc>Layout test for window.open, document.write, location.reload</desc>
            <filename>layout-test.zip</filename>
            <type>application/zip</type>
            <size>1816</size>
            <attacher name="Charles Reis">creis</attacher>
            
              <data encoding="base64">UEsDBAoAAAAAAJGGhT4AAAAAAAAAAAAAAAAMABwAbGF5b3V0LXRlc3QvVVQJAANBq5tNQaubTXV4
CwABBDIgAQAEiBMAAFBLAwQUAAAACACAhoU+7ZV/CIIAAADJAAAAMQAcAGxheW91dC10ZXN0L3dp
bmRvdy1vcGVuLXdyaXRlLXJlbG9hZC1leHBlY3RlZC50eHRVVAkAAyCrm00gq5tNdXgLAAEEMiAB
AASIEwAAdcwxDsIwEAXR3qf4J0hHQbrIMjRAkMwFLHtDVphd5Bh8fUCiQYJ+3tjx4Medw955P2xd
j8xCWPfYcFkqHrxwRVXEmXNCY0naOmN/qlUPT1El/WMnei0nLSiUNSSWMwKE2idAmCoVJI33K0nt
WuFKnTE2c7xgpkLvpd5Ivpg5Dt6bJ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