Add --run-disabled and --run-php options.

These parallel the --run-disabled and --run-parsoid options for the
PHP parser tests (see https://gerrit.wikimedia.org/r/50476 ).

At the moment --run-disabled is true by default (so use --run-disabled=no
or --no-run-disabled to turn it off) because many parsoid-specific tests
are still marked with the 'disabled' option.  Once those are all switched
over to using the 'parsoid' options, the default for --run-disabled should
switch to false.

The test-running logic for parsoid's parserTests now matches the
PHP parserTests logic (see tests/testHelpers.inc in the above change set).

Change-Id: Ia2dc633cf49e6daec59662901ed65731efb8a064
Fixes to WikiConfig: don't alias namespaces, magic words, etc.

By mutating {} and [] assigned to WikiConfig.prototype, all languages were
effectively sharing the same namespaceNames, namespaceIds, magicWords, etc.
Create these hashes and arrays in the constructor instead so they are
unique per-instance.

Change-Id: Idef86eae95c21d694ac02e519ed16b6596386350
Merge "Parse "options" sections in parserTests.txt test cases (take 2)."
Merge "User-friendly boolean options for parserTests.js."
Merge "Add --run-disabled and --run-php options."
Merge "Fixes to WikiConfig: don't alias namespaces, magic words, etc."
Make jshint happy by renaming WikiConfig._init -> WikiConfig.init.

Change-Id: I4a5f968b2d7d28bd984fc4cd614516597a00200a
Removed author names from individual files and updated AUTHORS.txt

Change-Id: I6eba8acb530f9d52492e5afd1747f6176b80e7f2
Test conf.parsoid.apiURI instead of conf.wiki.apiURI

* "echo '<math>3</math>' | node parse" was not parsing extension
  output whereas "... | node parse --fetchConfig" was doing this.

* Turned out that the extension and template handlers were still
  testing the wrong URI before making api requests.

* Fixes commandline parser tests.

Change-Id: I0703fe39dafba4c9a5a4db3c9f4ccf00ffa876a3
Fix some minor bugs in the link neighbour code

The traverser will now use Node:firstChild and Node:nextSibling to
traverse, and our link neighbour handler will now bail out correctly
if it's handling a non-wikilink link.

Test case:

echo "Writing 40 [[Greasemonkey]] scripts[http://userscripts.org/users/21031/scripts] for fix websites and support Firefox" | node parse --apiURL "https://en.wikipedia.org/w/api.php" --wt2wt

Also:

node roundtrip-test.js 'August Penguin'

Change-Id: I736b794a2b916350c148f419b5153190fcaecbcf
Merge "Fix some minor bugs in the link neighbour code"
Merge "Test conf.parsoid.apiURI instead of conf.wiki.apiURI"
Merge "Removed author names from individual files and updated AUTHORS.txt"
Bug fix in trivial special case in token-and-attr-collector.

* In wikitext like this: {{echo|<math>a=b</math>}}, the tokenizer
  parses this as:

  {"type":"SelfclosingTagTk",
   "name":"template",
   "attribs":[{"k":"echo","v":""},
              {"k":[{"type":"TagTk","name":"math","attribs":[]},"a"],
               "v":["b",{"type":"EndTagTk","name":"math","attribs":[]}]}
             ]
  }

  The <math> and </math> tags end up in the attributes of the template.
  TokenAndAttrCollector attempts to merge this into a single array of
  tokens.  But, it didn't correctly handle the special/trivial case 
  where the opening and closing tags ended up in the same attribute (in 
  this case, the second attribute).

  This patch fixes this.

  Note that this bug does not do anything bad for this code snippet,
  or for other examples probably, but it does lead to duplicate content
  in the merged token (evident in debug/trace mode), and could possibly
  cause problems on other non-html tags that show in tpl-arg positions 
  (I couldn't easily come up with  an example where parsed/RT output is 
  fixed by this patch).

Change-Id: I6789439cd3629aca6002ab964fad5582ae48a928
Clone KV or use orig srcOffsets when replacing a token's attr (kv).

* An alternate patch for https://gerrit.wikimedia.org/r/50345

  During token transformations, a token's attributes are sometimes
  replaced.  But, this would lose src-offsets from the original KV
  object.  This commit fixes that by cloning the original KV in
  most places before replacing the k/v value, and where cloning is
  cumbersome/excessive (ex: new KV([], []), it passes along the
  srcOffsets field from the original KV.

* Sample snippet to test: {{echo|<math>a=3</math>}}

* Eliminates crasher from: roundtrip-test.js 'Homographic function'

* Verified that mw:TemplateParams continue to be recorded and
  output correctly on a few different pages.

* No change in parser tests results.

* Unrelated fixes in ext.core.AttributeExpander.js:
  - Dont clone attributes when cloning the token since they will
    be replaced.
  - Other minor code cleanup.

Change-Id: I97e98e0e9e035b573d48a8dc9214e29add769a39
Handle flipped tpl-ranges in findTopLevelNonOverlappingRanges

* Because of fostered of end-tags, a range's end and start tags
  might be flipped.  In such a scenario, two ranges A and B
  might have exactly identical ranges.

     A = {start: e1, end: e2}
     B = {start: e2, end: e1} where B is the flipped range.

  With these two ranges, it doesn't matter how we handle nesting.
  It is okay to consider A nested in B or the other other way
  round as long as we dont introduce a nesting loop.

  The logic in findTopLevelNonOverlappingRanges was missing a
  check to handle this scenario. When testing if B is nested
  in A, it wasn't checking if A was already nested in B.  Without
  this check, we will record that A is nested in B and B is nested
  in A which will introduce a loop in findToplevelEnclosingRange!

* Here is a reduced example extracted from Dogma_studio:

    <table>
    {{echo|<div>}}
    foo
    {{echo|</div>}}
    </table>

  Before this patch, this snippet sent the code into an infinite
  loop.  With this patch, the code terminates.  There is an
  unrelated error that this snippet exposes -- the fostering of
  the entire content in the table tags doesn't get encapsulated
  properly becausing of missing DSR information.  So, this snippet
  doesn't RT yet.  That will be addressed in a different commit.

  As expected, this content is fostered out in the PHP parser as
  well, but the PHP parser doesn't have to deal with RTing these
  buggy wikitext snippets exactly as they were.

* No change in parser test results.

* en:Dogma studio parses and isn't stuck in an infinite loop.

Change-Id: I32f643dbc6ae156726c490fbcf04fd86f44df82e
Error handling crashers/fixes to roundtrip-test.js

* Error handling code was crashing (!!) :)
* Console-logging error handler was not emitting useful info
  on does-not-exists errors for wiki pages.
* Fixed and tested.

Change-Id: I9a4183761bc79d7c5e577e9485031408d1f6ffe9
Async TTM: Clone frozen incoming tokens if necessary.

* transformTokens code sets eltIndex property on token chunks
  pushed on the work-stack for efficiently processing them.
  However, the incoming token array might be frozen which means
  it has to be cloned before the property can be set.

* No change in parser test results.

* Fixes crashers in local client-server RT testing.

Change-Id: Iafa18189a6f8312f7e20a050d22e6c3f017a8679
Insert a failure stat if a page is retried more than maxTries.

* This patch has commented out queries that slow down the server.
  This is the version that is currently serving rt-tests.

* dbGetTitle and dbGetTitleRandom queries fetch a page if
  num_tries <= maxTries rather than num_tries < maxTries.
  On that last try, the server inserts a failure stat entry
  so that these pages show up on the top in the topfails/* pages.

* Also reduced retry time to 10 minutes instead of an hour.
  10 minutes should be long enough for a client to return a
  result for the page it has claimed.

Change-Id: I1905739a4359942a0c0270ecc351fa5fc6e99219
Merge "Insert a failure stat if a page is retried more than maxTries."