TokenAccums: Handle push, append via receiveToksFromSibling.

* TokenAccumulator push and append were handled differently and
  were adding tokens to the buffer which effectively treats them
  as being received in 'waitForChild' state which is buggy because
  the accum might have transitioned out of that state.  This can
  lead to tokens being lost since the buffer is ignored after the
  accum exits the 'waitForChild' state.

* Fixed the bug by treating push and append methods as equivalent
  to receiveToksFromSibling and using the tokens 'waitForSibling'
  state as the async state for the receive.

* This bug fix fixes lost-token-errors in the chunky tokenizer
  patch and eliminates the last of the async-related errors there.

* Left around from easy-debugging commented-out console.warn stmts.
  which should help us quickly see how tokens are progressing through
  the accum chains and cbs (at least helped me find this bug :-)).

* No change in parser test results.
* Verified errorless, diffless rting of en:Barack Obama.

Change-Id: I0400a941cb7a39d11072738681a5cce4587e82af
Use Node.childNodes instead of Element.children.

jsdom defines 'children' on Node, but that's not in the DOM; the DOM
(and domino) specifies that only Element nodes have the 'children'
property.  Use 'childNodes' instead, which really is defined on Node.

Change-Id: Ie3dc5b5f6c9c8b695ab78c04a9db632bd1133947
Update HTML5.TreeBuilder.copyAttributeToElement to handle DOM 4 API.

setAttributeNode is deprecated in DOM 4; we use setAttribute() instead.

Change-Id: I8bdfb726df3780e885eaba55e4e685228cdc82e7
Update normalizeOut() to handle <meta> the same as <meta /> and <meta >.

The regexp used to normalize <meta> and <link> tags forced there to be
a space after the tag name... which there might not be after we normalize
out all the attributes of the meta tag.

(E.g. domino's HTML serializer doesn't add a space before the close tag.)

Change-Id: Id01a70dca569772c11f53e88043248db1ab646d5
Tweak normalization regexps to allow > in attribute values.

HTML serialization allows > in attribute values; see:
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#serializing-html-fragments

And in fact we tend to get "<nowiki>" and other similar things in
attribute values.  Update the regular expressions used in
normalization to more accurately match HTML elements which may
contain quoted > in attributes.

Change-Id: I5ec8c3b79618205b7575e102a48fcd16f7479fad
Clone Wt2Html result before letting it become asynchronous.

The parser pipeline is handled asynchronously; ie the list of testTasks
is processed with async.waterfall() which defers work to process.nextTick().
The DOMPostProcessor is going to reset its parser as soon as it emits the
'document' event, which will clear parser.document.body.  We need to clone
the result before returning from the event handler to ensure that later
stages of the pipeline aren't affected by the imminent parser reset.

(This is necessary for domino and standards-compliant DOM implementations;
jsdom creates a new <body> when the parser is reset so the existing
<body> doesn't get stomped on.)

Change-Id: Ia372c5614a0b1aae846250a80374f2cabce6f202
Merge "TokenAccums: Handle push, append via receiveToksFromSibling."
Tokenizer fixes for pre and nowiki parsing.

* pre_indent_in_tags production was incrementing the 'pre' stop
  late in the production but decrementing it if the production
  failed to match. This led to the stops counter going pretty
  negative (-5 in some cases) even when the pre-tags weren't
  unbalanced.  Fixed it by moving the increment as the first
  thing the production does.

* Split the nowiki production from 2 rules to 3 rules:
  - <nowiki> .. </nowiki>
     -- treated as nowiki
  - <nowiki />
     -- treated as nowiki with mw:Placeholder meta
  - unbalanced <nowiki> or </nowiki> tags in pre-context.
     -- treated as plain text with mw:Placeholder span tags.
     -- Fixed rule to explictly required stops.counter.pre to
        be > 0 (in case it is negative -- although not sure
        if this going to be the case anymore with the fix
        above)

* Minor syntactic fixes (added missing ; in a few places and
  replace foo['bar'] with foo.bar accessor).

* No change in parser test results, but there are diffs.
  in parser test output.  The diffs are all for the better and
  could result in more tests passing with other unrelated fixes.

* These fixes also brings the test results in the chunky tokenizer
  patch to parity with the a full-tokenizing-in-one-pass runs.

Change-Id: If3d461195431883c718d0becb3264fc270fdaf82
Use .item() accessor for DOM attributes.

Avoid using array-access notation for DOM attribute lists.

Also fixed up some instances where we tried to use array-access notation
to look up an attribute by name.  Use node.getAttribute() for this instead.

Change-Id: Idb38d07b6e56901860faa9a2c0f8ceadea09654f
Escape a single quote so we don't screw up emacs' syntax coloring.

Change-Id: I706eca7b0f44ac8d443a8d695e19a8f85667bb5d