mw.Title: Rewrite from scratch (porting logic from Title.php)

Changes:

* Add support for fragments.

* Use wgLegalTitleChars instead of the old clean() method
  that stripped out characters instead of throwing an exception.

* Implemented various other parts of Title.php to make it more
  strict like Title.php. It is still slightly looser, but it
  now takes care of the following that Title.php did already:
  - Directory patterns ("../" etc.)
  - Extra initial colons
  - Titles in NS_TALK that don't round-trip to NS_MAIN
  - 3 or more consecutive tildes
  - Limited title size (255 bytes)

* Extracted parsing logic into a private static #parse method
  and introduced mw.Title.newFromText (a constructor that returns
  null|Title instead of throwing an exception).

* Extended test suite to cover the added features and fixed bugs.

* Since the PHP test suite was lacking these, added them there
  as well.

Bug fixes:

* Fragments are now excluded from the title instead of causing
  the input to be invalid or malformed (e.g. "Foo#bar" was being
  normalised to "Foo_bar").

* ".com" now parses and round-trips properly. The extension and
  rest of title are still separated, but only at the very end
  after all other processing, so though title cannot be empty,
  since we only do a lazy split afterwards, it will split into
  title="", ext="com" internally and join back together when
  needed (bug 38081).

* "Example.js " (trailing space after extension) was previously
  incorrectly parsed as title=Example.js,ext=null.

* "Foo    bar" (multiple consecutive spaces) was transformed
  into 1 space correctly, but "Foo___bar" was not. This has been
  fixed to match the PHP implementation (it merges underscores
  and whitespace of any kind).

Clean up:

* Removed various redundant private helper methods.

* Removed fixNsId as getNsIdByName uses wgNamespaceIds which
  always yields a valid value. The fixNsId was verifying
  something that was already valid.

* Yoda conditional in Title.php, got rid of.

* Use newFromText in jquery.byteLimit.test. It was previously
  using a very basic invalid test (=== '') and no try-catch.
  Since we're getting more strict, typing 'User:' results in
  an invalid title, which should result in the same behaviour
  as it previously did for the lazy === '' check.

Bug: 38081
Change-Id: Ief1c11dabadc2f822065c40be91e04d655933e4f
Merge "mw.Title: Rewrite from scratch (porting logic from Title.php)"