The "initialization" steps for Web browsers

Ian Hickson ian at hixie.ch
Tue Jul 22 12:32:26 PDT 2014


On Mon, 21 Jul 2014, Allen Wirfs-Brock wrote:
> 
> So if there is no ES code to execution prior to that first user action 
> then you might defer the whole 8.5 initialization process until then.

Well, loading an HTML file involves manipulating the Window global object, 
so I need the realm initialised before I start that.


> However, if there is some other way to acquire and execute ES code prior 
> to such a user action (for example, FF chrome code, a startup script, 
> etc.) when you would have to do 8.5 initialization earlier.  You might 
> use the "first Realm" for that code or you might use the "first Realm" 
> as sort of system utility realm, if you have a use for such a thing.

Those are out of scope of the HTML spec. I think the realm created by 8.5, 
in the context of HTML, will never be used. (I expect implementations just 
won't create one, in practice, but that's an implementation detail.)


> It sounds like I need to give InitializeFirstRealm a better name, such 
> as InitializeHostDefinedRealm. [...] Again, walking through this I can 
> see that I should probably do a little refactoring to make these steps 
> clearer.

Thanks, that would be great.


> For each <script> that is ready to be processed (the source code has 
> been retrieved) you just enqueue a PendingJob record for a 
> ScriptEvaluationJob (15.1.9) with the realm for the job set to the realm 
> that the <script> runs within.

Do you have any opinion on how I should handle attribute event handlers? 
They are conceptually FunctionBodys with specific parameters, and they are 
parsed the first time they are invoked, but can be reinvoked later without 
being reparsed. Currently the HTML spec hand-waves this using "code entry 
points" but those don't really map to anything in ES.

These are the relevant algorithms:

Parsing:
http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#getting-the-current-value-of-the-event-handler

Execution:
http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#the-event-handler-processing-algorithm

How should I map this to ES6?

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'


More information about the es-discuss mailing list