W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2009

[whatwg] Script loading and execution order for importScripts

From: Oliver Hunt <oliver@apple.com>
Date: Sat, 7 Mar 2009 23:46:32 -0800
Message-ID: <D3950946-D71A-49F4-998A-51B086DFE2A1@apple.com>

On Mar 7, 2009, at 11:22 PM, ben turner wrote:

> Just to clarify, if two scripts fail to load or compile then Mozilla
> always throws the error encountered by the first of the failed
> scripts. So, if I have a worker that does this:
>
>  importScripts("1.js", "2.js", "3.js");
>
> and "1.js" fails to load and "3.js" fails to compile then we report
> the failed load of "1.js". There is no race here.
>
> -Ben


The issue is not race conditions, the issue is that the behaviour is  
insufficiently defined, take these cases

1. importScripts("iExist.js", "iDontExist.js")
2. importScripts("iDontExist.js", "iExist.js")
3. importScripts("iExist.js", "iHaveASyntaxError.js")
4. importScripts("iExist.js", "iHaveASyntaxError.js", "iDontExist.js")
5. importScripts("iHaveASyntaxError.js", "iExist.js")
6. importScripts("iDontExist.js", "iHaveASyntaxError.js")
7. importScripts("iHaveASyntaxError.js", "iDontExist.js")

Under the (current) spec model
1. Will execute content of iExist.js, then throw a NETWORK_ERR for  
iDontExist.js
2. Will throw NETWORK_ERR for iDontExist.js
3. Will execute iExist.js then throw SYNTAX_ERR
4. Will execute iExist.js then throw SYNTAX_ERR
5. Will throw SYNTAX_ERR
6. Will throw NETWORK_ERR
7. Will throw SYNTAX_ERR

Under the firefox model
1. Will throw NETWORK_ERR
2. Will throw NETWORK_ERR
3. Will throw SYNTAX_ERR
4. Will throw SYNTAX_ERR
5. Will throw SYNTAX_ERR
6. Will throw NETWORK_ERR
7. Will throw SYNTAX_ERR

Now the if the spec doesn't specify when syntax checking occurs (eg.  
compilation, or whatever) you can also have the additional  
interpretation that all network loads happen before parsing (eg. what  
i initially thought firefox was doing), in which case cases 4 and 7  
may produce a NETWORK_ERR instead of a SYNTAX_ERR

--Oliver
Received on Saturday, 7 March 2009 23:46:32 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:47:49 GMT