- From: Kartikaya Gupta <lists.whatwg@stakface.com>
- Date: Thu, 12 Feb 2009 22:25:04 +0000
On Thu, 12 Feb 2009 06:55:18 +0000 (UTC), Ian Hickson <ian at hixie.ch> wrote: > > Could you reannotate the above but with the script nesting level > explicitly given at each step? > Below is an updated annotation including all the script nesting level and parser pause flag changes. (Original annotation at http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2009-January/018289.html) - initially, script nesting level is zero, parser pause flag is false - tokenize/treebuild ext7.html until the first closing script tag is found (for the 7a.js script) - increment the script nesting level to 1 - the 7a.js script tag has a src attribute, so it gets set as the pending external script - decrement the script nesting level to zero - since the script nesting level is zero, set the parser pause flag to false (it was already false) - execute the pending external script (7a.js) (this clears the pending external script pointer) --- insert "<script src=ext7b.js></script>" into the input stream --- tokenize/treebuild the 7b.js script tag until the </script> for 7b.js is found --- increment the script nesting level to 1 --- the 7b.js script tag has a src attribute, so it gets set as the pending external script --- decrement the script nesting level to zero --- since the script nesting level is zero, set the parser pause flag to false (it was already false) --- there is a pending external script (7b.js) but the tree construction stage is re-entrant, so set parser pause flag to true and return --- insert remaining document.write content from 7a.js into the input stream. since there is a pending external script, none of it gets tokenized/treebuilt - 7a.js finishes executing. at this point the script nesting level is zero and the parser pause flag is true - check again for a pending external script. there is one, 7b.js - execute the pending external script (7b.js) (this clears the pending external script pointer) --- throws - 7b.js finishes executing. at this point the script nesting level is zero and the parser pause flag is true - continue processing the input stream (this now has the contents of the document.write calls from 7a.js, line 2 onwards) - tokenize/treebuild the input stream until the </script> at the bottom of 7a.js is encountered - increment the script nesting level to 1 - the script tag does not have a src attribute, so it gets executed --- insert the div into the input stream --- since the parser pause flag is true the div does NOT get tokenized/treebuilt --- run the line that sets .firstChild.data to PASS. since the div isn't in the DOM yet, this throws - the script written from 7a.js finishes executing. at this point the script nesting level is 1 and the parser pause flag is true - decrement the script nesting level to zero - since the script nesting level is zero, set the parser pause flag to false - continue processing the input stream (this now contains just the div tag with FAIL inside) - tokenize/treebuild the input stream, which adds the FAIL div to the DOM - done Cheers, kats
Received on Thursday, 12 February 2009 14:25:04 UTC