<?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>209506</bug_id>
          
          <creation_ts>2020-03-24 15:03:35 -0700</creation_ts>
          <short_desc>requestDocumentEditingContext() should bail out if the focused frame does not have a view</short_desc>
          <delta_ts>2024-03-11 17:26:44 -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>WebKit Misc.</component>
          <version>WebKit Local Build</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>iOS 13</op_sys>
          <bug_status>ASSIGNED</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=209493</see_also>
          <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="Daniel Bates">dbates</reporter>
          <assigned_to name="Daniel Bates">dbates</assigned_to>
          <cc>achristensen</cc>
    
    <cc>ahmad.saleem792</cc>
    
    <cc>darin</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1633530</commentid>
    <comment_count>0</comment_count>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2020-03-24 15:03:35 -0700</bug_when>
    <thetext>requestDocumentEditingContext() performs a layout, which can do anything, including document destruction. Ensure that the focused frame has a view before computing the editing context.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1633531</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2020-03-24 15:03:45 -0700</bug_when>
    <thetext>&lt;rdar://problem/60843660&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1633538</commentid>
    <comment_count>2</comment_count>
      <attachid>394419</attachid>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2020-03-24 15:07:03 -0700</bug_when>
    <thetext>Created attachment 394419
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1633630</commentid>
    <comment_count>3</comment_count>
      <attachid>394419</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2020-03-24 16:09:35 -0700</bug_when>
    <thetext>Comment on attachment 394419
Patch

Why no test case?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1633648</commentid>
    <comment_count>4</comment_count>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2020-03-24 16:36:56 -0700</bug_when>
    <thetext>(In reply to Darin Adler from comment #3)
&gt; Comment on attachment 394419 [details]
&gt; Patch
&gt; 
&gt; Why no test case?

It is hard to write one.

I don&apos;t even know how to write such a test. I mean, here&apos;s what I need to do:

1. Write a test that will run JavaScript on layout (so, probably need a resize observer) that performs a synchronous navigation.

2. Write an API test that loads that page, get the page into a state where layout is needed, but **not** performed, then call -requestDocumentContext: (again, hoping that layout timer has not run before message gets to web process; otherwise, need to disable that).

Then -requestDocumentContext will message to requestDocumentEditingContext(), which will update layout =&gt; triggers navigation =&gt; view destroyed and the test will crash without the patch and not crash with it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1633649</commentid>
    <comment_count>5</comment_count>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2020-03-24 16:37:34 -0700</bug_when>
    <thetext>If there is an easier way to write a test I am all ears</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1633676</commentid>
    <comment_count>6</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2020-03-24 17:10:08 -0700</bug_when>
    <thetext>That sounds like the right way to write the test. We should really write it. Otherwise we are just making code changes and crossing our fingers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2020295</commentid>
    <comment_count>7</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-03-11 17:26:44 -0700</bug_when>
    <thetext>This patch was modifying:

https://searchfox.org/wubkat/rev/711120e7edec012527620d07bf63d85713a180fd/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm#4935

Which is:



    RefPtr frame = m_page-&gt;checkedFocusController()-&gt;focusedOrMainFrame();
    if (!frame)
        return completionHandler({ });

__

So I think 275171@main addressed this in bug 269761 and rdar://116201648.

@Alex - above commit was from your side, do you think we need to do anything more here or we can tag this as &apos;Duplicate&apos; to above bug?</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>394419</attachid>
            <date>2020-03-24 15:07:03 -0700</date>
            <delta_ts>2020-03-24 15:07:03 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-209506-20200324150702.patch</filename>
            <type>text/plain</type>
            <size>1894</size>
            <attacher name="Daniel Bates">dbates</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjU4ODAzCmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViS2l0L0No
YW5nZUxvZyBiL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCmluZGV4IGZkYWQyYjk5NDk4ZmVhMDRh
ZDkyOGY0MDU4ODBlZWZiNGY4NmQ4YWEuLmQ0MmE2YWVlZjQ5YzE0YTUyY2I4ZTk3YWZkOTIyZTVi
OGVjMzdlODYgMTAwNjQ0Ci0tLSBhL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCisrKyBiL1NvdXJj
ZS9XZWJLaXQvQ2hhbmdlTG9nCkBAIC0xLDMgKzEsMTkgQEAKKzIwMjAtMDMtMjQgIERhbmllbCBC
YXRlcyAgPGRhYmF0ZXNAYXBwbGUuY29tPgorCisgICAgICAgIHJlcXVlc3REb2N1bWVudEVkaXRp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"
          setter="dbates"
    />
          </attachment>
      

    </bug>

</bugzilla>