<?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>215589</bug_id>
          
          <creation_ts>2020-08-17 15:24:05 -0700</creation_ts>
          <short_desc>Sandboxed iframes don&apos;t fire DOMContentLoaded</short_desc>
          <delta_ts>2025-12-04 05:49:06 -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>Safari 13</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>macOS 10.15</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=33604</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=209653</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=276467</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="Matt Bierner">matb</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>cdumez</cc>
    
    <cc>me</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wilander</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1680943</commentid>
    <comment_count>0</comment_count>
      <attachid>406747</attachid>
    <who name="Matt Bierner">matb</who>
    <bug_when>2020-08-17 15:24:05 -0700</bug_when>
    <thetext>Created attachment 406747
Example test case

Sandboxed iframes that do not set `allow-scripts` do not seem to fire `DOMContentLoaded`. Here&apos;s a quick example

        const iframe = document.createElement(&apos;iframe&apos;)

        iframe.setAttribute(&apos;sandbox&apos;, &apos;allow-same-origin&apos;)
        iframe.src = &apos;./other&apos;
        document.body.append(iframe)

        iframe.contentWindow.addEventListener(&apos;DOMContentLoaded&apos;, () =&gt; {
            console.log(&apos;loaded&apos;);
        });


The event is fired if the iframe is not sandboxed or if `allow-scripts` is included in the sandbox. The sandboxed iframe does fire events in Chrome and Firefox. 

This is similar to https://bugs.webkit.org/show_bug.cgi?id=33604 but for sandboxed iframes</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1680946</commentid>
    <comment_count>1</comment_count>
    <who name="Matt Bierner">matb</who>
    <bug_when>2020-08-17 15:25:48 -0700</bug_when>
    <thetext>The same also seems to happen for the `load` event.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1681109</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2020-08-18 09:57:26 -0700</bug_when>
    <thetext>&lt;rdar://problem/67334351&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1893499</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2022-08-24 10:06:54 -0700</bug_when>
    <thetext>This continues to behave as reported. Chrome says &quot;Blocked script execution&quot; in console, but the event actually gets dispatched.

Seems pretty bad, as there is no reasonable way to detect that a sandboxed frame is done loading in WebKit, so this just prompts authors to add otherwise unnecessary allow-scripts.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>406747</attachid>
            <date>2020-08-17 15:24:05 -0700</date>
            <delta_ts>2020-08-17 15:24:05 -0700</delta_ts>
            <desc>Example test case</desc>
            <filename>example.zip</filename>
            <type>application/zip</type>
            <size>751</size>
            <attacher name="Matt Bierner">matb</attacher>
            
              <data encoding="base64">UEsDBBQACAAIAId6EVEAAAAAAAAAAM4BAAAKACAAaW5kZXguaHRtbFVUDQAHnwI7X7QCO1+fAjtf
dXgLAAEE9QEAAAQUAAAAZVHBTsQgFLz3K7AX2sS2VxNpE7OtpzXrYY3xyMKzJaHQwFtXY/x3IXR7
UC4w7808hoHd9Ifd8e15IBPOustY3IjmZmxzMHmXhQpw2WUkLDYDciIm7jxgm78cH6u7fG2hQg1d
b8V5BoOsSThjTZJn7GTl18r1wqkFE4hLWOORqHfHZyAtkeuQWjjgCIOGiAqaCLTMNmGq1MHNA6JT
pzNCQT038mQ/6S2hXGt7qXzgVNapUZkg/qt1IlxJ68biBI5u7c1E9F3zZQEji6T5byA8AAP3VRlp
LzWXcvgIcK98qIIraH942iXK3nIJMngrStJ25HubdM3Baqi1HQuqE7O83yg/65k11wBZk1KNMcfv
+wVQSwcIuMU07RABAADOAQAAUEsDBBQACAAIAKJ5EVEAAAAAAAAAAIcAAAAKACAAb3RoZXIuaHRt
bFVUDQAH8AA7X/gAO1/wADtfdXgLAAEE9QEAAAQUAAAAs1F08XcOiQxwVcgoyc2x47IBUQo5iXnp
tkqpeUoggdTEFDsuBSCwyU0tSVRIzkgsKk4tsVUKDXHTtVCCSpVkluSk2rnkJ5fmpuaV2OhD+Fw2
+hDtNkn5KZUQpf4lGalFQAmICFAByF4AUEsHCIzdwTNpAAAAhwAAAFBLAQIUAxQACAAIAId6EVG4
xTTtEAEAAM4BAAAKACAAAAAAAAAAAACkgQAAAABpbmRleC5odG1sVVQNAAefAjtftAI7X58CO191
eAsAAQT1AQAABBQAAABQSwECFAMUAAgACACieRFRjN3BM2kAAACHAAAACgAgAAAAAAAAAAAApIFo
AQAAb3RoZXIuaHRtbFVUDQAH8AA7X/gAO1/wADtfdXgLAAEE9QEAAAQUAAAAUEsFBgAAAAACAAIA
sAAAACkCAAAAAA==
</data>

          </attachment>
      

    </bug>

</bugzilla>