<?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>148690</bug_id>
          
          <creation_ts>2015-09-01 14:51:46 -0700</creation_ts>
          <short_desc>http/tests/navigation/anchor-frames-same-origin.html is flaky</short_desc>
          <delta_ts>2024-07-08 16:36:14 -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>Layout and Rendering</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>REOPENED</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=148615</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=191284</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Chris Dumez">cdumez</reporter>
          <assigned_to name="alan">zalan</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ap</cc>
    
    <cc>cdumez</cc>
    
    <cc>simon.fraser</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1122657</commentid>
    <comment_count>0</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2015-09-01 14:51:46 -0700</bug_when>
    <thetext>http/tests/navigation/anchor-frames-same-origin.html passes when run after http/tests/navigation/anchor-frames-cross-origin.html (case a) but fails when run on its own (case b).

The test uses the following frame structure:
- main Frame
-- child Frame (100x100px)
--- grand-child frame (8000x8000px)
----- anchor is at (0, 2000) px

When debugging it, I found that when we call FrameView::maintainScrollPositionAtAnchor(), we are in the following state:
- case a: Layout is done (renderView-&gt;needsLayout() returns false) so we call FrameView::scrollToAnchor() right away.
- case b: We need a layout, so we call layout() and only call FrameView::scrollToAnchor() after layout is done in performPostLayoutTasks().

scrollToAnchor() calls RenderLayer::scrollRectToVisible(rect) with the visible rect of the anchor we need to scroll to. This is the code that will actually scroll the view if needed and well as its parents. The logic looks like this:
===
                frameView.setScrollPosition(IntPoint(xOffset, yOffset));
                if (frameView.safeToPropagateScrollToParent()) {
                    parentLayer = ownerElement-&gt;renderer()-&gt;enclosingLayer();
                    // FIXME: This doesn&apos;t correctly convert the rect to
                    // absolute coordinates in the parent.
                    newRect.setX(rect.x() - frameView.scrollX() + frameView.x());
                    newRect.setY(rect.y() - frameView.scrollY() + frameView.y());
                    fprintf(stderr, &quot;safeToPropagateScrollToParent, newRect: %d, %d, frameView.scrollY(): %d\n&quot;, newRect.x().toInt(), newRect.y().toInt(), frameView.scrollY());
                }
===

In case a, when we compute the parent&apos;s new Rect, we end up with 2346px as height because frameView.scrollY() returns 0 (as expected given that the content height is smaller than the frame height).
However, in case b, the new Rect has a height of 0 because frameView.scrollY() returns 2008.

For some reason, in case b, FrameView::maximumScrollPosition() returns [77, 2142] instead of [0, 0] as in case a.

Render tree in case a when scrollToAnchor() is called:
(R)elative/A(B)solute/Fi(X)ed/Stick(Y) positioned, (O)verflow clipping, (A)nonymous, (G)enerated, (F)loating, has(L)ayer, (C)omposited, (D)irty layout, Dirty (S)tyle
---G-L- --* RenderView  (0.00, 0.00) (8000.00, 8000.00) renderer-&gt;(0x11629fbe0)
-----L- --    HTML RenderBlock  (0.00, 0.00) (8000.00, 2034.00) renderer-&gt;(0x1163bdc60) node-&gt;(0x1163e52a0)
------- --      BODY RenderBody  (8.00, 8.00) (7984.00, 2018.00) renderer-&gt;(0x1163bdd10) node-&gt;(0x116335a80)
------- --        DIV RenderBlock  (0.00, 0.00) (7984.00, 2000.00) renderer-&gt;(0x1163bddc0) node-&gt;(0x116335ae0)
--AG--- --        RenderBlock  (0.00, 2000.00) (7984.00, 18.00) renderer-&gt;(0x1163bde70)
------- --          RootInlineBox  (0.00, 0.00) (265.88, 18.00) (0x1163f1b40) renderer-&gt;(0x1163bde70)
------- --            InlineTextBox  (0.00, 0.00) (261.88, 18.00) (0x116331160) run(0, 39) &quot;This is an anchor point named &quot;anchor1&quot;&quot;
------- --            InlineTextBox  (261.88, 0.00) (4.00, 18.00) (0x1163311b8) run(0, 1) &quot;.&quot;
------- --          A RenderInline renderer-&gt;(0x116343600) node-&gt;(0x1163ed5a0)
------- --            #text RenderText renderer-&gt;(0x1163a1dc0) node-&gt;(0x11634bea0) length-&gt;(39) &quot;This is an anchor point named &quot;anchor1&quot;&quot;
------- --          #text RenderText renderer-&gt;(0x1163a1f20) node-&gt;(0x11634bee8) length-&gt;(4) &quot;.\n\n\n&quot;

====

Render tree in case b when scrollToAnchor is called:
(R)elative/A(B)solute/Fi(X)ed/Stick(Y) positioned, (O)verflow clipping, (A)nonymous, (G)enerated, (F)loating, has(L)ayer, (C)omposited, (D)irty layout, Dirty (S)tyle
---G-L- --* RenderView  (0.00, 0.00) (0.00, 0.00) renderer-&gt;(0x1152ecbe0)
-----L- --    HTML RenderBlock  (0.00, 0.00) (0.00, 2142.00) renderer-&gt;(0x1153c6840) node-&gt;(0x1153ac4e0)
------- --      BODY RenderBody  (8.00, 8.00) (0.00, 2126.00) renderer-&gt;(0x1153c68f0) node-&gt;(0x1153ac5a0)
------- --        DIV RenderBlock  (0.00, 0.00) (0.00, 2000.00) renderer-&gt;(0x1153c69a0) node-&gt;(0x1153ac600)
--AG--- --        RenderBlock  (0.00, 2000.00) (0.00, 126.00) renderer-&gt;(0x1153c6a50)
------- --          RootInlineBox  (0.00, 0.00) (28.45, 18.00) (0x1153f1aa0) renderer-&gt;(0x1153c6a50)
------- --            InlineTextBox  (0.00, 0.00) (28.45, 18.00) (0x1153460b0) run(0, 4) &quot;This&quot;
------- --          RootInlineBox  (0.00, 18.00) (10.67, 18.00) (0x1153f1b40) renderer-&gt;(0x1153c6a50)
------- --            InlineTextBox  (0.00, 18.00) (10.67, 18.00) (0x115346108) run(5, 7) &quot;is&quot;
------- --          RootInlineBox  (0.00, 36.00) (15.10, 18.00) (0x1153f1be0) renderer-&gt;(0x1153c6a50)
------- --            InlineTextBox  (0.00, 36.00) (15.10, 18.00) (0x115346160) run(8, 10) &quot;an&quot;
------- --          RootInlineBox  (0.00, 54.00) (43.53, 18.00) (0x1153f1c80) renderer-&gt;(0x1153c6a50)
------- --            InlineTextBox  (0.00, 54.00) (43.53, 18.00) (0x1153461b8) run(11, 17) &quot;anchor&quot;
------- --          RootInlineBox  (0.00, 72.00) (32.89, 18.00) (0x1153f1d20) renderer-&gt;(0x1153c6a50)
------- --            InlineTextBox  (0.00, 72.00) (32.89, 18.00) (0x115346210) run(18, 23) &quot;point&quot;
------- --          RootInlineBox  (0.00, 90.00) (42.65, 18.00) (0x1153f1dc0) renderer-&gt;(0x1153c6a50)
------- --            InlineTextBox  (0.00, 90.00) (42.65, 18.00) (0x115346268) run(24, 29) &quot;named&quot;
------- --          RootInlineBox  (0.00, 108.00) (68.59, 18.00) (0x1153f1e60) renderer-&gt;(0x1153c6a50)
------- --            InlineTextBox  (0.00, 108.00) (64.59, 18.00) (0x1153462c0) run(30, 39) &quot;&quot;anchor1&quot;&quot;
------- --            InlineTextBox  (64.59, 108.00) (4.00, 18.00) (0x115346318) run(0, 1) &quot;.&quot;
------- --          A RenderInline renderer-&gt;(0x11534c060) node-&gt;(0x1153ede88)
------- --            #text RenderText renderer-&gt;(0x115380f20) node-&gt;(0x115355dc8) length-&gt;(39) &quot;This is an anchor point named &quot;anchor1&quot;&quot;
------- --          #text RenderText renderer-&gt;(0x115380f78) node-&gt;(0x115355e10) length-&gt;(4) &quot;.\n\n\n&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1122660</commentid>
    <comment_count>1</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2015-09-01 14:56:24 -0700</bug_when>
    <thetext>It looks like it fails when run on its own on WebKit2 as well.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1122661</commentid>
    <comment_count>2</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2015-09-01 15:01:10 -0700</bug_when>
    <thetext>Passes:
Tools/Scripts/run-webkit-tests --release http/tests/navigation/anchor-frames-cross-origin.html  http/tests/navigation/anchor-frames-same-origin.html

Fails:
Tools/Scripts/run-webkit-tests --release http/tests/navigation/anchor-frames-same-origin.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1122767</commentid>
    <comment_count>3</comment_count>
      <attachid>260408</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2015-09-01 22:16:32 -0700</bug_when>
    <thetext>Created attachment 260408
Temporary workaround</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1122768</commentid>
    <comment_count>4</comment_count>
      <attachid>260408</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2015-09-01 22:17:18 -0700</bug_when>
    <thetext>Comment on attachment 260408
Temporary workaround

Zalan, what do you think? Can we land this in the mean time?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1122840</commentid>
    <comment_count>5</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2015-09-02 10:06:39 -0700</bug_when>
    <thetext>Committed r189250: &lt;http://trac.webkit.org/changeset/189250&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1122841</commentid>
    <comment_count>6</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2015-09-02 10:07:18 -0700</bug_when>
    <thetext>Reopening as it is a temporary workaround.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2045198</commentid>
    <comment_count>7</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-07-08 16:36:14 -0700</bug_when>
    <thetext>We still have this workaround - https://searchfox.org/wubkat/rev/df1e46cebe93c020392645e94f67469843cd8063/LayoutTests/http/tests/navigation/resources/grandchild-with-anchor.html#8</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>260408</attachid>
            <date>2015-09-01 22:16:32 -0700</date>
            <delta_ts>2015-09-02 08:22:47 -0700</delta_ts>
            <desc>Temporary workaround</desc>
            <filename>bug-148690-20150901221616.patch</filename>
            <type>text/plain</type>
            <size>1945</size>
            <attacher name="Chris Dumez">cdumez</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTg5MjM5CmRpZmYgLS1naXQgYS9MYXlvdXRUZXN0cy9DaGFu
Z2VMb2cgYi9MYXlvdXRUZXN0cy9DaGFuZ2VMb2cKaW5kZXggNDBkM2Q1ZWU1MGNkNWE3YjRhYTQ0
NzZhOTcwZDQ4ZWFiZDY2OWRhMS4uMTE0MDVlYTBkMThiM2UwZGNmNDBlNDQ3YTJiNjU2NzJlMDY0
MTMyZCAxMDA2NDQKLS0tIGEvTGF5b3V0VGVzdHMvQ2hhbmdlTG9nCisrKyBiL0xheW91dFRlc3Rz
L0NoYW5nZUxvZwpAQCAtMSwzICsxLDIwIEBACisyMDE1LTA5LTAxICBDaHJpcyBEdW1leiAgPGNk
dW1lekBhcHBsZS5jb20+CisKKyAgICAgICAgaHR0cC90ZXN0cy9uYXZpZ2F0aW9uL2FuY2hvci1m
cmFtZXMtc2FtZS1vcmlnaW4uaHRtbCBpcyBmbGFreQorICAgICAgICBodHRwczovL2J1Z3Mud2Vi
a2l0Lm9yZy9zaG93X2J1Zy5jZ2k/aWQ9MTQ4NjkwCisKKyAgICAgICAgUmV2aWV3ZWQgYnkgTk9C
T0RZIChPT1BTISkuCisKKyAgICAgICAgVGhpcyBpcyBhIHRlbXBvcmFyeSB3b3JrYXJvdW5kIGZv
ciBCdWcgMTQ4NjkwLCB1bnRpbCB3ZSBoYXZlIHRpbWUKKyA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zU2NzE4MDk1MzRkMzRjOWYzYTBhMjJhYTA1ODljLi45
OTNlZDNkMGE1MjQ5NGViZWZlZGM0Njg4OWE2Mjg2ZjAxNTVlYjJiIDEwMDY0NAotLS0gYS9MYXlv
dXRUZXN0cy9odHRwL3Rlc3RzL25hdmlnYXRpb24vcmVzb3VyY2VzL2dyYW5kY2hpbGQtd2l0aC1h
bmNob3IuaHRtbAorKysgYi9MYXlvdXRUZXN0cy9odHRwL3Rlc3RzL25hdmlnYXRpb24vcmVzb3Vy
Y2VzL2dyYW5kY2hpbGQtd2l0aC1hbmNob3IuaHRtbApAQCAtNSw1ICs1LDEwIEBACiAgIDwhLS0g
U3BhY2VyIHRvIG1ha2Ugc3VyZSB0aGF0IHRoZSBuYW1lZCBhbmNob3IgYmVsb3cgcmVxdWlyZXMg
c2Nyb2xsaW5nIC0tPgogPC9kaXY+CiA8YSBuYW1lPSJhbmNob3IxIj5UaGlzIGlzIGFuIGFuY2hv
ciBwb2ludCBuYW1lZCAiYW5jaG9yMSI8L2E+LgorPHNjcmlwdD4KKy8vIFRlbXBvcmFyeSB3b3Jr
YXJvdW5kIGZvciBodHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/aWQ9MTQ4Njkw
LgorLy8gTWFrZSBzdXJlIGxheW91dCBpcyBkb25lIGJlZm9yZSB3ZSBzY3JvbGwgdG8gdGhlIGFu
Y2hvci4KK2RvY3VtZW50LmJvZHkub2Zmc2V0SGVpZ2h0OworPC9zY3JpcHQ+CiA8L2JvZHk+CiA8
L2h0bWw+Cg==
</data>
<flag name="review"
          id="285585"
          type_id="1"
          status="+"
          setter="zalan"
    />
          </attachment>
      

    </bug>

</bugzilla>