This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 22413 - [imports]: Imported documents should execute script
Summary: [imports]: Imported documents should execute script
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Component Model (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Dimitri Glazkov
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 20683
  Show dependency treegraph
 
Reported: 2013-06-20 04:24 UTC by Morrita Hajime
Modified: 2013-08-22 05:55 UTC (History)
2 users (show)

See Also:


Attachments

Description Morrita Hajime 2013-06-20 04:24:37 UTC
If imported document has <script>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.
Comment 1 Morrita Hajime 2013-06-20 06:08:17 UTC
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't explicitly execute sub-imports in "import fetching algorithm".
Instead, we could modify '4 Link Type "import"' 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.
Comment 2 Dimitri Glazkov 2013-06-20 20:45:44 UTC
(In reply to comment #1)
> Also, we shouldn't explicitly execute sub-imports in "import fetching
> algorithm".
> Instead, we could modify '4 Link Type "import"' 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.

Right. I wondered if we should zap the "processing sub-imports" step altogether, and instead monkeypatch HTML spec to allow running scripts, loading stylesheets and registering element declarations when parsing an imported document.
Comment 3 Morrita Hajime 2013-06-21 00:06:27 UTC
(In reply to comment #2)
> 
> Right. I wondered if we should zap the "processing sub-imports" step
> altogether, and instead monkeypatch HTML spec to allow running scripts,
> loading stylesheets and registering element declarations when parsing an
> imported document.

We surely need a patch for running script.

For stylesheet, it look it's just a metadata for HTML and loading it (especially
if it doesn'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.
Comment 4 Dimitri Glazkov 2013-07-19 17:46:12 UTC
I wonder if Tony or James have thoughts/opinions on this.
Comment 5 Morrita Hajime 2013-08-22 05:55:59 UTC
Mark as fixed for now: https://dvcs.w3.org/hg/webcomponents/rev/b51a8826c617
Any feedback is appreciated.
I'd like to rather polish it than exploring alternate approach
unless the whole direction is wrong.