<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>22413</bug_id>
          
          <creation_ts>2013-06-20 04:24:37 +0000</creation_ts>
          <short_desc>[imports]: Imported documents should execute script</short_desc>
          <delta_ts>2013-08-22 05:55:59 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>HISTORICAL - Component Model</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>20683</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Morrita Hajime">morrita</reporter>
          <assigned_to name="Dimitri Glazkov">dglazkov</assigned_to>
          <cc>simonjam</cc>
    
    <cc>tonyg</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>89626</commentid>
    <comment_count>0</comment_count>
    <who name="Morrita Hajime">morrita</who>
    <bug_when>2013-06-20 04:24:37 +0000</bug_when>
    <thetext>If imported document has &lt;script&gt;s, they should be executed.

The question is, which executio environment/global objecdt/browsing context/etc
should be used to the execution.

Actually, many more questions will follow.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89634</commentid>
    <comment_count>1</comment_count>
    <who name="Morrita Hajime">morrita</who>
    <bug_when>2013-06-20 06:08:17 +0000</bug_when>
    <thetext>My strawman here is to use master document as the document of the execution.

Specifically, we need to patch HTML so that the created script gets 
associated documents/browsing context/etc from the master document.
 * http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#creating-scripts

This should work as if it is loaded through XHR and eval()-ed,
except that the script is kicked by the HTML parser thus script execution
happens during parsing, not after the parsing finished.

Also, we shouldn&apos;t explicitly execute sub-imports in &quot;import fetching algorithm&quot;.
Instead, we could modify &apos;4 Link Type &quot;import&quot;&apos; section to ensure that
it loads linked import regardless if the document is a master or not.

By doing this, the execution order is guaranteed recursively.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89662</commentid>
    <comment_count>2</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-06-20 20:45:44 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; Also, we shouldn&apos;t explicitly execute sub-imports in &quot;import fetching
&gt; algorithm&quot;.
&gt; Instead, we could modify &apos;4 Link Type &quot;import&quot;&apos; section to ensure that
&gt; it loads linked import regardless if the document is a master or not.
&gt; 
&gt; By doing this, the execution order is guaranteed recursively.

Right. I wondered if we should zap the &quot;processing sub-imports&quot; step altogether, and instead monkeypatch HTML spec to allow running scripts, loading stylesheets and registering element declarations when parsing an imported document.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89669</commentid>
    <comment_count>3</comment_count>
    <who name="Morrita Hajime">morrita</who>
    <bug_when>2013-06-21 00:06:27 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; 
&gt; Right. I wondered if we should zap the &quot;processing sub-imports&quot; step
&gt; altogether, and instead monkeypatch HTML spec to allow running scripts,
&gt; loading stylesheets and registering element declarations when parsing an
&gt; imported document.

We surely need a patch for running script.

For stylesheet, it look it&apos;s just a metadata for HTML and loading it (especially
if it doesn&apos;t affect rendering at that timing) can taken as just an implementation
detail. 

For element registration, we could patch Custom Element...
Or Custom Element could provide some hook for that.
I have no clear idea how the hook looks like though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90998</commentid>
    <comment_count>4</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-07-19 17:46:12 +0000</bug_when>
    <thetext>I wonder if Tony or James have thoughts/opinions on this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92450</commentid>
    <comment_count>5</comment_count>
    <who name="Morrita Hajime">morrita</who>
    <bug_when>2013-08-22 05:55:59 +0000</bug_when>
    <thetext>Mark as fixed for now: https://dvcs.w3.org/hg/webcomponents/rev/b51a8826c617
Any feedback is appreciated.
I&apos;d like to rather polish it than exploring alternate approach
unless the whole direction is wrong.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>