<?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>216149</bug_id>
          
          <creation_ts>2020-09-03 15:27:10 -0700</creation_ts>
          <short_desc>Promises created from async functions don&apos;t resolve when document is detached.</short_desc>
          <delta_ts>2025-06-19 20:58:05 -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>DOM</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <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="John-David Dalton">john.david.dalton</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>arai.unmht</cc>
    
    <cc>ashvayka</cc>
    
    <cc>cyb.ai.815</cc>
    
    <cc>emilio</cc>
    
    <cc>fpizlo</cc>
    
    <cc>keith_miller</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1685463</commentid>
    <comment_count>0</comment_count>
    <who name="John-David Dalton">john.david.dalton</who>
    <bug_when>2020-09-03 15:27:10 -0700</bug_when>
    <thetext>The following snippet works in Chrome:

(async () =&gt; {
  var i = document.createElement(&apos;iframe&apos;);
  document.body.appendChild(i);
  var a = i.contentWindow.eval(&apos;(async () =&gt; await 1)&apos;);
  i.remove(); // someone removes the iframe
  const v = await a();
  console.log(v);
})();

Our use case has code that works when wired up and then someone removes the iframe and `await` no longer resolves.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1685861</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2020-09-04 14:56:44 -0700</bug_when>
    <thetext>&lt;rdar://problem/68367353&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1686190</commentid>
    <comment_count>2</comment_count>
    <who name="Emilio Cobos Álvarez (:emilio)">emilio</who>
    <bug_when>2020-09-06 09:00:30 -0700</bug_when>
    <thetext>This might be a Chrome bug per spec, see: https://bugzilla.mozilla.org/show_bug.cgi?id=1663090#c3

(Though I haven&apos;t double-checked)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1687028</commentid>
    <comment_count>3</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2020-09-09 10:19:01 -0700</bug_when>
    <thetext>Currently, what we should do is not fully clarified in the spec.
It is ongoing discussion. But I think forever-pending promise would make sense since we should stop execution of script, and rejecting promise can involve script execution.
https://github.com/whatwg/html/issues/2621</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2121072</commentid>
    <comment_count>4</comment_count>
    <who name="Tooru Fujisawa [:arai]">arai.unmht</who>
    <bug_when>2025-06-02 03:22:39 -0700</bug_when>
    <thetext>With the latest Safari Technology Preview (Release 220 (Safari 18.4, WebKit 20622.1.14.5)), the equivalent testcase now logs &quot;1&quot;
https://bug1663090.bmoattachments.org/attachment.cgi?id=9174036

Was there any change around how the promise reaction jobs in detached iframe works?
I&apos;d like to see when and how the behavior changed.

Regarding the spec, it looks like there were a bunch of changes around how iframe and related conditions are defined,
but I cannot locate any semantic change that affects the jobs in detached iframes,
and to my understanding the expected behavior is still &quot;the promise reaction job in the testcase is never called&quot;.

https://bugzilla.mozilla.org/show_bug.cgi?id=1663090#c16
https://bugzilla.mozilla.org/show_bug.cgi?id=1663090#c17</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2124803</commentid>
    <comment_count>5</comment_count>
    <who name="Tooru Fujisawa [:arai]">arai.unmht</who>
    <bug_when>2025-06-19 20:58:05 -0700</bug_when>
    <thetext>So it turns out this is causing inter-op issue as mentioned in https://github.com/whatwg/html/issues/11252 .

A WPT testcase for the behavior is going to be added in https://bugzilla.mozilla.org/show_bug.cgi?id=1972990 .
The testcase fails on Safari/WebKit because those promise reaction/thenable jobs in detached iframe gets executed, while the global is considered to be not-fully-active.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>