<?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>21413</bug_id>
          
          <creation_ts>2008-10-06 15:09:08 -0700</creation_ts>
          <short_desc>DOMWindow.cpp DOMWindow::moveTo offsets moves by 22 (menu bar height)</short_desc>
          <delta_ts>2023-11-30 13:23:58 -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>DOM</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>UNCONFIRMED</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=250800</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>0</everconfirmed>
          <reporter name="Eric Simenel">esimenel</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ap</cc>
    
    <cc>bfulgham</cc>
    
    <cc>esimenel</cc>
    
    <cc>rniwa</cc>
    
    <cc>yevseytsev</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>94278</commentid>
    <comment_count>0</comment_count>
    <who name="Eric Simenel">esimenel</who>
    <bug_when>2008-10-06 15:09:08 -0700</bug_when>
    <thetext>Easy to reproduce:
Using the following HTML code:
&lt;html&gt;
&lt;script&gt;
    function M(dx, dy) {

        window.moveTo(window.screenX+dx, window.screenY+dy);
    }
    
&lt;/script&gt;
&lt;body&gt;
&lt;input type=&quot;button&quot; value=&quot;move me&quot; onclick=&quot;M(0, -50)&quot;&gt;
&lt;/body&gt;
&lt;/html&gt;

Safari/Webkit windows move up 28 pixels, Firefox windows move up 50 pixels.

Tentative fix:

Instead of:
    FloatRect fr = page-&gt;chrome()-&gt;windowRect();
    FloatRect sr = screenAvailableRect(page-&gt;mainFrame()-&gt;view());
    fr.setLocation(sr.location());
    FloatRect update = fr;
    update.move(x, y);     

We should have:
    FloatRect fr = page-&gt;chrome()-&gt;windowRect();
    FloatRect sr = screenAvailableRect(page-&gt;mainFrame()-&gt;view());
    x -= fr.x();
    y -= fr.y();
    FloatRect update = fr;
    update.move(x, y);     

That change seems to fix the problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1506682</commentid>
    <comment_count>1</comment_count>
    <who name="yevseytsev">yevseytsev</who>
    <bug_when>2019-02-15 11:24:53 -0800</bug_when>
    <thetext>Tried to reproduce a bug in Safari and Firefox using the code provided, but windows are not moving at all. As well Firefox is no longer uses WebKit, so I am not sure it is a bug nowadays.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1506756</commentid>
    <comment_count>2</comment_count>
    <who name="yevseytsev">yevseytsev</who>
    <bug_when>2019-02-15 13:40:23 -0800</bug_when>
    <thetext> Please ignore the second part of my previous comment, Firefox uses WebKit only on iOS</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1509056</commentid>
    <comment_count>3</comment_count>
    <who name="yevseytsev">yevseytsev</who>
    <bug_when>2019-02-22 10:48:24 -0800</bug_when>
    <thetext>in webkit/Source/WebCore/page/DOMWindow.cpp file there is a code that prevents window geometry to be changed

void DOMWindow::moveTo(float x, float y) const
{
    if (!allowedToChangeWindowGeometry())
        return;


    Page* page = m_frame-&gt;page();
    FloatRect fr = page-&gt;chrome().windowRect();
    FloatRect sr = screenAvailableRect(page-&gt;mainFrame().view());
    fr.setLocation(sr.location());
    FloatRect update = fr;
    update.move(x, y);
    page-&gt;chrome().setWindowRect(adjustWindowRect(*page, update));
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1892432</commentid>
    <comment_count>4</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-08-19 09:33:08 -0700</bug_when>
    <thetext>I am not able to reproduce anything from the test case in Comment 0 and all browsers (Safari 15.6, Safari Technology Preview 151, Chrome Canary 106, Firefox Nightly 105) ignore the &quot;Move Me&quot; input and also don&apos;t show anything in console.

Link - https://jsfiddle.net/3gowr4c5/


The referencee code in Comment 03, is still present in slightly changed / refactor format:

https://github.com/WebKit/WebKit/blob/64f843f962fd4b62b95fb3c3c53127b6f526fbcd/Source/WebCore/page/DOMWindow.cpp#L1758

rniwa@webkit.org - Is something still needed? Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1892454</commentid>
    <comment_count>5</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2022-08-19 10:31:37 -0700</bug_when>
    <thetext>As documented in &lt;https://developer.mozilla.org/en-US/docs/Web/API/Window/moveTo&gt;, Firefox only performs a moveTo if the window was created by window.open(). 

Looking at allowedToChangeWindowGeometry(), WebKit appears to have a different policy, it blocks moveTo if invoked from a mouse event handler. It also needs to be the main frame, not a subframe.

The test needs to be adjusted accordingly to verify if this is still an issue.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>