Merge "Make protect.php maintenance script not ignore --user and --reason parameters"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 30 Nov 2016 00:05:06 +0000 (00:05 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 30 Nov 2016 00:05:06 +0000 (00:05 +0000)
44 files changed:
RELEASE-NOTES-1.29
autoload.php
includes/api/ApiClearHasMsg.php
includes/debug/logger/monolog/LogstashFormatter.php [new file with mode: 0644]
includes/debug/logger/monolog/WikiProcessor.php
includes/media/MediaTransformOutput.php
includes/specials/SpecialListgrants.php
includes/user/User.php
languages/i18n/af.json
languages/i18n/be-tarask.json
languages/i18n/be.json
languages/i18n/bn.json
languages/i18n/cs.json
languages/i18n/diq.json
languages/i18n/dty.json
languages/i18n/en.json
languages/i18n/et.json
languages/i18n/kk-cyrl.json
languages/i18n/mr.json
languages/i18n/qqq.json
languages/i18n/sah.json
languages/i18n/sl.json
languages/i18n/tr.json
languages/i18n/udm.json
languages/i18n/uk.json
resources/Resources.php
resources/lib/qunitjs/qunit.css
resources/lib/qunitjs/qunit.js
resources/src/mediawiki.less/mediawiki.ui/variables.less
resources/src/mediawiki.widgets/MediaSearch/broken-image.png [new file with mode: 0644]
resources/src/mediawiki.widgets/MediaSearch/mw.widgets.APIResultsProvider.js [new file with mode: 0644]
resources/src/mediawiki.widgets/MediaSearch/mw.widgets.APIResultsQueue.js [new file with mode: 0644]
resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResourceProvider.js [new file with mode: 0644]
resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResourceQueue.js [new file with mode: 0644]
resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResultWidget.css [new file with mode: 0644]
resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResultWidget.js [new file with mode: 0644]
resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchProvider.js [new file with mode: 0644]
resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchQueue.js [new file with mode: 0644]
resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchWidget.css [new file with mode: 0644]
resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchWidget.js [new file with mode: 0644]
resources/src/mediawiki.widgets/mw.widgets.SearchInputWidget.js
resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
tests/phpunit/includes/debug/logger/monolog/LogstashFormatterTest.php [new file with mode: 0644]
thumb.php

index a5b2feb..5b5640f 100644 (file)
@@ -22,6 +22,7 @@ production.
 === External library changes in 1.29 ===
 
 ==== Upgraded external libraries ====
+* Updated QUnit from v1.22.0 to v1.23.1.
 
 ==== New external libraries ====
 
@@ -35,6 +36,7 @@ production.
   in the query string is now an error. They should be submitted in the POST
   body instead.
 * The capture option for action=resetpassword has been removed
+* action=clearhasmsg now requires a POST.
 
 === Action API internal changes in 1.29 ===
 
index 30ef985..f0bbe92 100644 (file)
@@ -875,6 +875,7 @@ $wgAutoloadLocalClasses = [
        'MediaWiki\\Logger\\Monolog\\LegacyFormatter' => __DIR__ . '/includes/debug/logger/monolog/LegacyFormatter.php',
        'MediaWiki\\Logger\\Monolog\\LegacyHandler' => __DIR__ . '/includes/debug/logger/monolog/LegacyHandler.php',
        'MediaWiki\\Logger\\Monolog\\LineFormatter' => __DIR__ . '/includes/debug/logger/monolog/LineFormatter.php',
+       'MediaWiki\\Logger\\Monolog\\LogstashFormatter' => __DIR__ . '/includes/debug/logger/monolog/LogstashFormatter.php',
        'MediaWiki\\Logger\\Monolog\\SyslogHandler' => __DIR__ . '/includes/debug/logger/monolog/SyslogHandler.php',
        'MediaWiki\\Logger\\Monolog\\WikiProcessor' => __DIR__ . '/includes/debug/logger/monolog/WikiProcessor.php',
        'MediaWiki\\Logger\\NullSpi' => __DIR__ . '/includes/debug/logger/NullSpi.php',
index 13b3577..99242a8 100644 (file)
@@ -45,7 +45,7 @@ class ApiClearHasMsg extends ApiBase {
        }
 
        public function mustBePosted() {
-               return false;
+               return true;
        }
 
        protected function getExamplesMessages() {
diff --git a/includes/debug/logger/monolog/LogstashFormatter.php b/includes/debug/logger/monolog/LogstashFormatter.php
new file mode 100644 (file)
index 0000000..553cbf6
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+
+namespace MediaWiki\Logger\Monolog;
+
+/**
+ * LogstashFormatter squashes the base message array and the context and extras subarrays into one.
+ * This can result in unfortunately named context fields overwriting other data (T145133).
+ * This class modifies the standard LogstashFormatter to rename such fields and flag the message.
+ *
+ * Compatible with Monolog 1.x only.
+ *
+ * @since 1.29
+ */
+class LogstashFormatter extends \Monolog\Formatter\LogstashFormatter {
+       /** @var array Keys which should not be used in log context */
+       protected $reservedKeys = [
+               // from LogstashFormatter
+               'message', 'channel', 'level', 'type',
+               // from WebProcessor
+               'url', 'ip', 'http_method', 'server', 'referrer',
+               // from WikiProcessor
+               'host', 'wiki', 'reqId', 'mwversion',
+               // from config magic
+               'normalized_message',
+       ];
+
+       /**
+        * Prevent key conflicts
+        * @param array $record
+        * @return array
+        */
+       protected function formatV0( array $record ) {
+               if ( $this->contextPrefix ) {
+                       return parent::formatV0( $record );
+               }
+
+               $context = !empty( $record['context'] ) ? $record['context'] : [];
+               $record['context'] = [];
+               $formatted = parent::formatV0( $record );
+
+               $formatted['@fields'] = $this->fixKeyConflicts( $formatted['@fields'], $context );
+               return $formatted;
+       }
+
+       /**
+        * Prevent key conflicts
+        * @param array $record
+        * @return array
+        */
+       protected function formatV1( array $record ) {
+               if ( $this->contextPrefix ) {
+                       return parent::formatV1( $record );
+               }
+
+               $context = !empty( $record['context'] ) ? $record['context'] : [];
+               $record['context'] = [];
+               $formatted = parent::formatV1( $record );
+
+               $formatted = $this->fixKeyConflicts( $formatted, $context );
+               return $formatted;
+       }
+
+       /**
+        * Check whether some context field would overwrite another message key. If so, rename
+        * and flag.
+        * @param array $fields Fields to be sent to logstash
+        * @param array $context Copy of the original $record['context']
+        * @return array Updated version of $fields
+        */
+       protected function fixKeyConflicts( array $fields, array $context ) {
+               foreach ( $context as $key => $val ) {
+                       if (
+                               in_array( $key, $this->reservedKeys, true ) &&
+                               isset( $fields[$key] ) && $fields[$key] !== $val
+                       ) {
+                               $fields['logstash_formatter_key_conflict'][] = $key;
+                               $key = 'c_' . $key;
+                       }
+                       $fields[$key] = $val;
+               }
+               return $fields;
+       }
+}
index 81e1e14..ad939a0 100644 (file)
@@ -29,17 +29,6 @@ namespace MediaWiki\Logger\Monolog;
  * @copyright © 2013 Bryan Davis and Wikimedia Foundation.
  */
 class WikiProcessor {
-       /** @var array Keys which should not be used in log context */
-       protected $reservedKeys = [
-               // from monolog:src/Monolog/Formatter/LogstashFormatter.php#L71-L88
-               'message', 'channel', 'level', 'type',
-               // from WebProcessor
-               'url', 'ip', 'http_method', 'server', 'referrer',
-               // from WikiProcessor
-               'host', 'wiki', 'reqId', 'mwversion',
-               // from config magic
-               'normalized_message',
-       ];
 
        /**
         * @param array $record
@@ -47,15 +36,6 @@ class WikiProcessor {
         */
        public function __invoke( array $record ) {
                global $wgVersion;
-
-               // some log aggregators such as Logstash will merge the log context into the main
-               // metadata and end up overwriting the data coming from processors
-               foreach ( $this->reservedKeys as $key ) {
-                       if ( isset( $record['context'][$key] ) ) {
-                               wfLogWarning( __METHOD__ . ": '$key' key overwritten in log context." );
-                       }
-               }
-
                $record['extra'] = array_merge(
                        $record['extra'],
                        [
@@ -67,4 +47,5 @@ class WikiProcessor {
                );
                return $record;
        }
+
 }
index b3a555a..46b9674 100644 (file)
@@ -476,6 +476,10 @@ class MediaTransformError extends MediaTransformOutput {
        function isError() {
                return true;
        }
+
+       function getHttpStatusCode() {
+               return 500;
+       }
 }
 
 /**
@@ -490,6 +494,10 @@ class TransformParameterError extends MediaTransformError {
                        max( isset( $params['height'] ) ? $params['height'] : 0, 120 ),
                        wfMessage( 'thumbnail_invalid_params' )->text() );
        }
+
+       function getHttpStatusCode() {
+               return 400;
+       }
 }
 
 /**
@@ -511,4 +519,8 @@ class TransformTooBigImageAreaError extends MediaTransformError {
                                )->text()
                        );
        }
+
+       function getHttpStatusCode() {
+               return 400;
+       }
 }
index 39c8ae8..2c92410 100644 (file)
@@ -71,8 +71,14 @@ class SpecialListGrants extends SpecialPage {
 
                        $id = \Sanitizer::escapeId( $grant );
                        $out->addHTML( \Html::rawElement( 'tr', [ 'id' => $id ],
-                               "<td>" . $this->msg( "grant-$grant" )->escaped() . "</td>" .
-                               "<td>" . $grantCellHtml . '</td>'
+                               "<td>" .
+                               $this->msg(
+                                       "listgrants-grant-display",
+                                       \User::getGrantName( $grant ),
+                                       "<span class='mw-listgrants-grant-name'>" . $id . "</span>"
+                               )->parse() .
+                               "</td>" .
+                               "<td>" . $grantCellHtml . "</td>"
                        ) );
                }
 
index 82d8806..f07db0e 100644 (file)
@@ -5066,13 +5066,27 @@ class User implements IDBAccessObject {
        /**
         * Get the description of a given right
         *
+        * @since 1.29
         * @param string $right Right to query
         * @return string Localized description of the right
         */
        public static function getRightDescription( $right ) {
                $key = "right-$right";
                $msg = wfMessage( $key );
-               return $msg->isBlank() ? $right : $msg->text();
+               return $msg->isDisabled() ? $right : $msg->text();
+       }
+
+       /**
+        * Get the name of a given grant
+        *
+        * @since 1.29
+        * @param string $grant Grant to query
+        * @return string Localized name of the grant
+        */
+       public static function getGrantName( $grant ) {
+               $key = "grant-$grant";
+               $msg = wfMessage( $key );
+               return $msg->isDisabled() ? $grant : $msg->text();
        }
 
        /**
index a905b3c..d435dbb 100644 (file)
        "passwordreset-emaildisabled": "E-posfunksies is afgeskakel op hierdie wiki.",
        "passwordreset-username": "Gebruiker:",
        "passwordreset-domain": "Domein:",
-       "passwordreset-capture": "Wys resulterende e-pos?",
-       "passwordreset-capture-help": "As u die boks merk, word die e-pos (met die tydelike wagwoord) aan u getoon en aan die gebruiker gestuur.",
        "passwordreset-email": "E-posadres:",
        "passwordreset-emailtitle": "Gebruiker se details op {{site name}}",
        "passwordreset-emailtext-ip": "Iemand, waarskynlik u vanaf die IP-adres $1, het u gebruikersgegewens vir {{SITENAME}} ($4) opgevra.\nDie volgende {{PLURAL:$3|gebruiker is|gebruikers is}} aan die e-posadres gekoppel:\n\n$2\n\n{{PLURAL:$3|Die tydelike wagwoord verval|Hierdie tydelike wagwoorde verval}} oor {{PLURAL:$5|een dag|$5 dae}}.\nMeld asseblief nou aan en wysig u wagwoord. As u dit nie versoek het nie, of as u die oorspronklike wagwoord nog ken en dit nie wil verander nie, ignoreer die berig en hou aan om u ou wagwoord te gebruik.",
        "userrights-reason": "Rede:",
        "userrights-no-interwiki": "U het nie toestemming om gebruikersregte op ander wiki's te verander nie.",
        "userrights-nodatabase": "Databasis $1 bestaan nie of is nie hier beskikbaar nie.",
-       "userrights-nologin": "U moet as 'n administrateur [[Special:UserLogin|aanmeld]] om gebruikersregte te kan toeken.",
-       "userrights-notallowed": "U het nie magtiging om gebruikersregte by te sit of weg te neem nie.",
        "userrights-changeable-col": "Groepe wat u kan verander",
        "userrights-unchangeable-col": "Groepe wat u nie kan verander nie",
        "userrights-conflict": "Konflik met gebruikersregte! Pas asseblief weer u wysigings toe.",
-       "userrights-removed-self": "U het u eie regte suksesvol verwyder. Gevolglik het u nie meer toegang tot hierdie bladsy nie.",
        "group": "Groep:",
        "group-user": "Gebruikers",
        "group-autoconfirmed": "Bevestigde gebruikers",
        "right-siteadmin": "Sluit en ontsluit die datbasis",
        "right-override-export-depth": "Eksporteer bladsye insluitend geskakelde bladsye tot 'n diepte van 5",
        "right-sendemail": "Stuur e-pos aan ander gebruikers",
-       "right-passwordreset": "Wys e-posse vir herstel van wagwoord",
        "newuserlogpage": "Logboek van nuwe gebruikers",
        "newuserlogpagetext": "Dit is 'n logboek van gebruikers wat onlangs ingeteken het.",
        "rightslog": "Gebruikersregtelogboek",
        "trackingcategories-disabled": "Kategorie is gedeaktiveer",
        "mailnologin": "Geen versendadres beskikbaar",
        "mailnologintext": "U moet [[Special:UserLogin|ingeteken]] wees en 'n geldige e-posadres in u [[Special:Preferences|voorkeure]] hê om e-pos aan ander gebruikers te kan stuur.",
-       "emailuser": "Stuur e-pos na hierdie gebruiker",
+       "emailuser": "Stuur e-pos na dié gebruiker",
        "emailuser-title-target": "E-pos die {{GENDER:$1|gebruiker}}",
        "emailuser-title-notarget": "E-pos gebruiker",
        "emailpagetext": "As {{GENDER:$1|dié gebruiker}} 'n geldige e-posadres in sy/haar gebruikersvoorkeure het, sal hierdie vorm 'n enkele boodskap stuur. Die e-posadres in u [[Special:Preferences|gebruikersvoorkeure]] sal verskyn as die \"Van\"-adres van die pos. Dus sal die ontvanger kan terug antwoord.",
        "namespace_association": "Gekoppelde naamruimte",
        "tooltip-namespace_association": "Merk die boks om die besprekings- en onderwerpnaamruimte die by die geselekteerde naamruimte in te sluit",
        "blanknamespace": "(Hoof)",
-       "contributions": "{{GENDER:$1|Gebruikersbydraes}}",
+       "contributions": "{{GENDER:$1|Gebruikers­bydraes}}",
        "contributions-title": "$1 se bydraes",
        "mycontris": "Bydraes",
        "anoncontribs": "Bydraes",
        "specialpage-securitylevel-not-allowed-title": "Nie toegestaan",
        "cannotauth-not-allowed-title": "Geen toegang",
        "cannotauth-not-allowed": "U word nie toegelaat om die bladsy te gebruik nie",
-       "credentialsform-account": "Gebruikersnaam:",
-       "edit-error-short": "Fout: $1",
-       "edit-error-long": "Foute:\n\n$1"
+       "credentialsform-account": "Gebruikersnaam:"
 }
index 7624ef0..73e2397 100644 (file)
        "movelogpagetext": "Ніжэй пададзены сьпіс перанесеных старонак.",
        "movesubpage": "{{PLURAL:$1|1=Падстаронка|Падстаронкі}}",
        "movesubpagetext": "Гэтая старонка мае $1 {{PLURAL:$1|падстаронку|падстаронкі|падстаронак}}, {{PLURAL:$1|1=якая паказаная ніжэй|якія паказаныя ніжэй}}.",
+       "movesubpagetalktext": "Адпаведная старонка абмеркаваньня мае $1 {{PLURAL:$1|падстаронку, паказаную|падстаронкі, паказаныя|падстаронак, паказаныя}} ніжэй.",
        "movenosubpage": "Гэтая старонка ня мае падстаронак.",
        "movereason": "Прычына:",
        "revertmove": "адкат",
index 26175b3..734d773 100644 (file)
        "feedback-submit": "Даслаць",
        "feedback-thanks": "Дзякуй! Ваш водгук размешчаны на старонцы «[$2 $1]».",
        "feedback-thanks-title": "Дзякуем!",
-       "searchsuggest-search": "Шукаць у {{SITENAME}}",
+       "searchsuggest-search": "Шукаць у {{GRAMMAR:месны|{{SITENAME}}}}",
        "searchsuggest-containing": "змяшчае...",
        "api-error-badaccess-groups": "У Вас няма дазволу загружаць файлы ў гэтую вікі.",
        "api-error-badtoken": "Унутраная памылка: няслушны ключ.",
index dbf7814..8b22db4 100644 (file)
        "pageinfo-header-restrictions": "পাতা সুরক্ষা",
        "pageinfo-header-properties": "পাতা বৈশিষ্টসমূহ",
        "pageinfo-display-title": "শিরনাম প্রদর্শন",
-       "pageinfo-default-sort": "ডিফলà§\8dà¦\9f à¦¸à¦°à§\8dà¦\9f à¦\95ি",
+       "pageinfo-default-sort": "পà§\82রà§\8dবনিরà§\8dধারিত à¦¬à¦¾à¦\9bাà¦\87য়à§\87র à¦\9aাবি",
        "pageinfo-length": "পাতার দৈর্ঘ্য (বাইটে)",
        "pageinfo-article-id": "পাতার আইডি",
        "pageinfo-language": "পাতার তথ্যের ভাষা",
index d9bc4a6..10f39b4 100644 (file)
        "apisandbox-continue-clear": "Vymazat",
        "apisandbox-continue-help": "{{int:apisandbox-continue}} bude [https://www.mediawiki.org/wiki/API:Query#Continuing_queries pokračovat] v posledním požadavku; {{int:apisandbox-continue-clear}} vymaže parametry související s pokračováním.",
        "apisandbox-param-limit": "Pro použití maximálního limitu zadejte <kbd>max</kbd>.",
+       "apisandbox-multivalue-all-namespaces": "$1 (všechny jmenné prostory)",
+       "apisandbox-multivalue-all-values": "$1 (všechny hodnoty)",
        "booksources": "Zdroje knih",
        "booksources-search-legend": "Vyhledat knižní zdroje",
        "booksources-search": "Hledat",
        "mw-widgets-dateinput-placeholder-month": "RRRR-MM",
        "mw-widgets-titleinput-description-new-page": "stránka zatím neexistuje",
        "mw-widgets-titleinput-description-redirect": "přesměrování na $1",
+       "mw-widgets-categoryselector-add-category-placeholder": "Přidat kategorii…",
        "sessionmanager-tie": "Nelze kombinovat několik typů autentizace požadavků: $1.",
        "sessionprovider-generic": "relace pomocí $1",
        "sessionprovider-mediawiki-session-cookiesessionprovider": "relace pomocí cookies",
index 6137af4..110d9b5 100644 (file)
        "mainpage": "Pela Seri",
        "mainpage-description": "Pela seri",
        "policy-url": "Project:Terzê hereketi",
-       "portal": "Portalê cemaeti",
+       "portal": "Meydanê cemaeti",
        "portal-url": "Project:Portalë şëlıgi",
        "privacy": "Politikaya nımıteyiye",
        "privacypage": "Project:Xısusiyetê nımıtışi",
        "sort-descending": "Rêzkerdışo kêmbiyaye",
        "sort-ascending": "Rêzkerdışo zêdiyaye",
        "nstab-main": "Pele",
-       "nstab-user": "Pela karberi",
+       "nstab-user": "Pella karberi",
        "nstab-media": "Pela medya",
        "nstab-special": "Pella xısusi",
        "nstab-project": "Pela proceyi",
        "mainpage-nstab": "Pera esas",
        "nosuchaction": "Fealiyeto wınasi çıniyo",
        "nosuchactiontext": "URL ra kar qebul nêbı.\nŞıma belka URL şaş nuşt, ya zi gıreyi şaş ra ameyi.\nKeyepelê {{SITENAME}} eşkeno xeta eşkera bıkero.",
-       "nosuchspecialpage": "Pela xasa wınasiye çıniya",
+       "nosuchspecialpage": "Pella xısusi ya unasin çınya",
        "nospecialpagetext": "<strong>To yew pela xasa nêvêrdiye waşte.</strong>\n\nSeba lista pelanê xasanê vêrdeyan reca kena: [[Special:SpecialPages|{{int:specialpages}}]].",
        "error": "Xeta",
        "databaseerror": "Ğetay ardoği",
        "summary": "Xulasa:",
        "subject": "Mewzu:",
        "minoredit": "No yew vurnayışo werdiyo",
-       "watchthis": "Na pele seyr ke",
+       "watchthis": "Ena pele bıewne",
        "savearticle": "Peller qeyd kı",
        "savechanges": "Vuryayışa qeyd kerê",
        "publishpage": "Perer bıhesırne",
        "datedefault": "Tercih çıniyo",
        "prefs-labs": "Xacetê labs",
        "prefs-user-pages": "Pelê karberi",
-       "prefs-personal": "Pela karberi",
+       "prefs-personal": "Profilê karberi",
        "prefs-rc": "Vurriyayışê peyêni",
        "prefs-watchlist": "Lista seyrkerdışi",
        "prefs-editwatchlist": "Lista seyrkerdışi bıvurne",
        "uncategorizedcategories": "Kategoriyê ke kategorize nêbiyê",
        "uncategorizedimages": "Dosye yê  bêkategori",
        "uncategorizedtemplates": "Şablonê ke bêkategoriyê",
-       "unusedcategories": "Kategoriyê ke nêgureniyê",
+       "unusedcategories": "Kategoriyê ke nêkarênê",
        "unusedimages": "Dosyeyê ke nêguriyenê",
        "wantedcategories": "Kategoriyê ke waziyayê",
        "wantedpages": "Pelê ke waziyayê",
        "mostimages": "Dosyayan ke tewr zaf link estê.",
        "mostinterwikis": "Pelan ke tewr zaf interwiki biyê.",
        "mostrevisions": "Pelan ke tewr zaf revizyonî biyê.",
-       "prefixindex": "Veroleya peley pêro",
+       "prefixindex": "Verbenda pelli heme",
        "prefixindex-namespace": "Peleyê Veroleyıni ($1 cay nami)",
        "prefixindex-submit": "Bımocne",
        "prefixindex-strip": "Listeya réz bıyayışi",
        "longpages": "Perrê  dergeki",
        "deadendpages": "Perrê kı perranê binan rê grey c çıni yo",
        "deadendpagestext": "Ena pelan ke {{SITENAME}} de zerrî ey de link çini yo.",
-       "protectedpages": "Pelê pawıteyi",
+       "protectedpages": "Pellê kı pawıyayeyè",
        "protectedpages-indef": "têna pawıteyê bêmuddeti",
        "protectedpages-summary": "Listeya ena peler newke pawıtiya.Sername de  ena lista rê pawıte vıraştışi rê [[{{#special:ProtectedTitles}}|{{int:protectedtitles}}]] bıvinê.",
        "protectedpages-cascade": "Kilit biyaye ke teyna cascadiye",
        "checkbox-all": "Pêro",
        "checkbox-none": "Temam",
        "checkbox-invert": "Rageyre",
-       "allpages": "Peli pêro",
+       "allpages": "Pelli pêro",
        "nextpage": "Pela badê cû ($1)",
        "prevpage": "Pela verêne ($1)",
        "allpagesfrom": "Pera liste kerdışi bıasne:",
        "removedwatchtext": "Ena pela \"[[:$1]]\" biya wedariya [[Special:Watchlist|listeyê seyr-kerdışi şıma]].",
        "removedwatchtext-short": "Pera $1`i listeya seyran de şıma ra wedari yê",
        "watch": "Seyr ke",
-       "watchthispage": "Na pele seyr ke",
+       "watchthispage": "Peller seyr kı",
        "unwatch": "Teqib meke",
        "unwatchthispage": "temaşa kerdışê peli vındarn.",
        "notanarticle": "mebhesê peli niyo",
        "rollback-success": "vurnayişê no kesi $1 tepiya geriyayo u hetê no\n$2 kesi ra cıwa ver o ke revizyon biyo no revizyon tepiya anciyayo.",
        "sessionfailure-title": "Seans xeripiya",
        "sessionfailure": "cıkewtışê hesabê şıma de yew problem aseno;\nno kar semedê dızdiyê hesabi ibtal biyo.\nkerem kerê \"tepiya\" şiyerê u pel o ke şıma tera ameyî u o pel newe ra bar kerê , newe ra tesel/cereb kerê.",
+       "changecontentmodel": "Modelê zerrekê pele bıvurne",
        "changecontentmodel-title-label": "Sernameyê pele",
        "changecontentmodel-model-label": "Modelê zerrekiyo newe",
        "changecontentmodel-reason-label": "Sebeb:",
        "specialpages-group-login": "Dekew / hesab vıraz",
        "specialpages-group-changes": "Vurnayışê peyêni û qeydi",
        "specialpages-group-media": "Raporê medya û barkerdışi",
-       "specialpages-group-users": "Karberi û heqi",
+       "specialpages-group-users": "Karberi u heqê cı",
        "specialpages-group-highuse": "Peleyê ke vêşi karênê",
        "specialpages-group-pages": "Listeyê pelan",
        "specialpages-group-pagetools": "Haletê pelan",
        "mw-widgets-titleinput-description-redirect": "berd be $1",
        "randomrootpage": "Raştamaye perra çımey",
        "log-action-filter-newusers": "Babetê hesabvıraştışi:",
-       "changecredentials": "Malumatanê karberi bıvurnê"
+       "changecredentials": "Malumatanê karberi bıvurnê",
+       "removecredentials": "Kamiyer wedarne",
+       "removecredentials-submit": "Kamiyer wedarne"
 }
index 2685328..b6e1b18 100644 (file)
        "category-file-count-limited": "निम्न {{PLURAL:$1|फाइल|$1 फाइलहरू}} यै श्रेणीमी रया छ ।",
        "listingcontinuesabbrev": "निरन्तरता...",
        "index-category": "क्रमाङ्कित पानाहरू",
-       "noindex-category": "à¤\95à¥\8dरमाà¤\99à¥\8dà¤\95न à¤¨à¤\97रà¥\80याà¤\95ा à¤ªà¤¾à¤¨à¤¾à¤¹à¤°à¥\82",
+       "noindex-category": "à¤\85नà¥\81à¤\95à¥\8dरमित à¤¨à¤\85रियाऽ à¤ªà¤¨à¥\8dनाà¤\85न",
        "broken-file-category": "टुटेको फाइल लिङ्कहरूसितको पाना",
        "about": "बारेमी",
        "article": "सामाग्री पानो",
        "passwordreset": "पासवर्ड पूर्वनिर्धारित गर",
        "passwordreset-username": "प्रयोगकर्ता-नाम:",
        "passwordreset-domain": "डोमेन",
-       "passwordreset-capture": "निस्कने इमेलको नमुना हेर्ने ?",
        "passwordreset-email": "इमेल ठेगाना:",
        "passwordreset-emailtitle": "{{SITENAME}}मा खाता विवरण",
        "passwordreset-emailelement": "प्रयोगकर्ताको नाम: \n$1\n\nअस्थाई पासवर्ड: \n$2",
        "searchprofile-advanced-tooltip": "अनुकुल नेमस्पेसमा खोज्या",
        "search-result-size": "$1 ({{PLURAL:$2|1 आँखर|$2 आँखर}})",
        "search-result-category-size": "{{PLURAL:$1|एक सदस्य|$1 सदस्यहरू}} ({{PLURAL:$2|1 उपश्रेणी|$2  उपश्रेणीहरू}}, {{PLURAL:$3|एउटा फाइल|$3 फाइलहरू}})",
-       "search-redirect": "(जान्या $1)",
+       "search-redirect": "($1 बठेइ पुन:निर्देशित)",
        "search-section": "(खण्ड $1)",
        "search-category": "(श्रेणी $1)",
        "search-file-match": "(भेटिईया फाइल सामाग्री)",
        "userrights-changeable-col": "तमले परिवर्तन गद्द सक्दया समूहअन",
        "userrights-unchangeable-col": "तमीले परिवर्तन गद्द नसक्ने समूहहरू",
        "userrights-conflict": "प्रयोगकर्ताको अधिकार परिवर्तनमी मतभेद भयो ! कृपया तमरो परिवर्तन पुनरावलोकन तथा पुष्टि गर ।",
-       "userrights-removed-self": "तमले सफलतापूर्वक आफनो अधिकारहरूलाई मेटाया । त्यै कारण तम आब यो पानो हेद्द नाइसक्दा ।",
        "group": "समूह:",
        "group-user": "प्रयोगकर्ताहरू",
        "group-autoconfirmed": "स्वत स्थापित प्रयोगकर्ताहरू",
        "logentry-newusers-create": "प्रयोगकर्ता खाता $1 {{GENDER:$2|खोलियो}}",
        "logentry-upload-upload": "$1 ले $3 {{GENDER:$2|अपलोड अरेका छन्}}",
        "feedback-bugornote": "यदि तमी कुनै प्राविधिक समस्यालाई विस्तारले सम्झाउन तयार छौ भण्या कृपया [$1 बग राख]।\nयदि हैन, भण्या तमी तल दियाको सरल फारमको प्रयोग गद्दसक्द्याहौ । तमरो टिप्पणी, तमरो प्रयोगकर्ता नाम र तमरो ब्राउजरको नाम सहित \"[$3 $2]\" पानामी जोडिन्याछ ।",
-       "searchsuggest-search": "खोज:",
+       "searchsuggest-search": "{{SITENAME}} खोजऽ",
        "api-error-duplicate": "यै साइटमी पहिलीबठे यस्तै सामग्री {{PLURAL:$1|भयाको अर्को फाइल छ|भयाका  केहि अरु फाइलहरू छन्}} ।",
        "api-error-duplicate-archive": "यै साइटमी पहिलेबाट यस्तै सामग्री {{PLURAL:$1|भयाको अर्को फाइल थियो|भयाका केहि अरु फाइलहरू थिए}} ।\nतर {{PLURAL:$1|यो मेट्याको थियो|यी मेटायाका थिए}} ।",
        "expand_templates_preview_fail_html": "<em>किनकि {{SITENAME}} सिधै एचटिएमयल सक्षम छ र तमीले लग इन गर्या छैनौ, पूर्वावलोकन लुकाइयाको छ ताकि सम्भावित जाभास्क्रिप्ट आक्रमणलाई रोक्द सकियोस् ।</em>\n\n<strong>यदि यो मान्य पूर्ववावलोकन प्रयास हो भण्या पुन प्रयास गर ।</strong>\nयदि यसले कार्य पूर्ण भएन भण्या [[Special:UserLogout|लग आउट गरिबर]] फेरी लग इन गर्या ।",
index 9aa0f46..a49f95c 100644 (file)
        "listgrants-summary": "The following is a list of grants with their associated access to user rights. Users can authorize applications to use their account, but with limited permissions based on the grants the user gave to the application. An application acting on behalf of a user cannot actually use rights that the user does not have however.\nThere may be [[{{MediaWiki:Listgrouprights-helppage}}|additional information]] about individual rights.",
        "listgrants-grant": "Grant",
        "listgrants-rights": "Rights",
+       "listgrants-grant-display": "$1 <code>($2)</code>",
        "trackingcategories": "Tracking categories",
        "trackingcategories-summary": "This page lists tracking categories which are automatically populated by the MediaWiki software. Their names can be changed by altering the relevant system messages in the {{ns:8}} namespace.",
        "trackingcategories-msg": "Tracking category",
        "mw-widgets-dateinput-no-date": "No date selected",
        "mw-widgets-dateinput-placeholder-day": "YYYY-MM-DD",
        "mw-widgets-dateinput-placeholder-month": "YYYY-MM",
+       "mw-widgets-mediasearch-input-placeholder": "Search for media",
+       "mw-widgets-mediasearch-noresults": "No results found.",
        "mw-widgets-titleinput-description-new-page": "page does not exist yet",
        "mw-widgets-titleinput-description-redirect": "redirect to $1",
        "mw-widgets-categoryselector-add-category-placeholder": "Add a category...",
index 6699cc8..35a399d 100644 (file)
        "activeusers-intro": "See on loetelu kasutajatest, kes on viimase $1 {{PLURAL:$1|päev|päeva}} jooksul midagi teinud.",
        "activeusers-count": "$1 {{PLURAL:$1|toiming|toimingut}} viimase {{PLURAL:$3|päeva|$3 päeva}} jooksul",
        "activeusers-from": "Näita kasutajaid alates:",
+       "activeusers-groups": "Kuva kasutajad, kes kuuluvad järgmistesse rühmadesse:",
        "activeusers-noresult": "Kasutajaid ei leidunud.",
        "activeusers-submit": "Kuva aktiivsed kasutajad",
        "listgrouprights": "Kasutajarühma õigused",
        "mw-widgets-titleinput-description-redirect": "ümbersuunamine leheküljele \"$1\"",
        "randomrootpage": "Juhuslik juurlehekülg",
        "log-action-filter-block": "Blokeeringu tüüp:",
+       "log-action-filter-contentmodel": "Sisumudeli muudatuse tüüp:",
        "log-action-filter-delete": "Kustutamise tüüp:",
+       "log-action-filter-import": "Impordi tüüp:",
+       "log-action-filter-managetags": "Märgiste haldamistegevuse tüüp:",
+       "log-action-filter-move": "Teisaldamise tüüp:",
+       "log-action-filter-newusers": "Konto loomise tüüp:",
+       "log-action-filter-patrol": "Kontrolli tüüp:",
+       "log-action-filter-protect": "Kaitsmise tüüp:",
+       "log-action-filter-rights": "Õiguste muudatuse tüüp:",
+       "log-action-filter-upload": "Üleslaadimise tüüp:",
        "log-action-filter-all": "Kõik",
        "log-action-filter-block-block": "Blokeerimine",
        "log-action-filter-block-reblock": "Blokeeringu muutmine",
        "log-action-filter-block-unblock": "Blokeeringu tühistamine",
+       "log-action-filter-contentmodel-change": "Sisumudeli muudatus",
+       "log-action-filter-contentmodel-new": "Ebastandardse sisumudeliga lehekülje loomine",
        "log-action-filter-delete-delete": "Lehekülje kustutamine",
        "log-action-filter-delete-restore": "Lehekülje taastamine",
        "log-action-filter-delete-event": "Logi kustutamine",
        "log-action-filter-delete-revision": "Redaktsiooni kustutamine",
+       "log-action-filter-import-interwiki": "Vikidevaheline import",
+       "log-action-filter-import-upload": "XML-faili üleslaadimisega import",
+       "log-action-filter-managetags-create": "Märgise koostamine",
+       "log-action-filter-managetags-delete": "Märgise kustutamine",
+       "log-action-filter-managetags-activate": "Märgise lubamine",
+       "log-action-filter-managetags-deactivate": "Märgise keelamine",
+       "log-action-filter-move-move": "Teisaldamine ümbersuunamise ülekirjutamiseta",
+       "log-action-filter-move-move_redir": "Teisaldamine ümbersuunamise ülekirjutamisega",
+       "log-action-filter-newusers-create": "Loonud anonüümne kasutaja",
+       "log-action-filter-newusers-create2": "Loonud registreeritud kasutaja",
+       "log-action-filter-newusers-autocreate": "Loodud automaatselt",
+       "log-action-filter-newusers-byemail": "Loodud e-kirjatsi saadetud parooliga",
+       "log-action-filter-patrol-patrol": "Kontrollitud käsitsi",
+       "log-action-filter-patrol-autopatrol": "Kontrollitud automaatselt",
+       "log-action-filter-protect-protect": "Kaitsmine",
+       "log-action-filter-protect-modify": "Kaitse muutmine",
+       "log-action-filter-protect-unprotect": "Kaitse eemaldamine",
+       "log-action-filter-protect-move_prot": "Kaitse teisaldamine",
+       "log-action-filter-rights-rights": "Muudetud käsitsi",
+       "log-action-filter-rights-autopromote": "Muudetud automaatselt",
+       "log-action-filter-upload-upload": "Uus üleslaadimine",
+       "log-action-filter-upload-overwrite": "Uuesti üleslaadimine",
        "authmanager-provider-password": "Paroolipõhine autentimine",
        "authmanager-provider-password-domain": "Parooli- ja domeenipõhine autentimine",
        "authmanager-provider-temporarypassword": "Ajutine parool",
index 28e84bc..590caf6 100644 (file)
        "passwordreset-emaildisabled": "E-mail мүмкіндігі бұл уикиде өшірілген.",
        "passwordreset-username": "Қатысушы аты:",
        "passwordreset-domain": "Домен:",
-       "passwordreset-capture": "Келген хатты қарау керек пе?",
-       "passwordreset-capture-help": "Егер Сіз берілген белгішені қондырсаңыз, қатысушыға жіберілетін уақытша құпия сөз жазылған хат көрсетіледі.",
        "passwordreset-email": "Е-поштаның мекен-жайы:",
        "passwordreset-emailtitle": "{{SITENAME}} тіркелгісі туралы анықтама",
        "passwordreset-emailtext-ip": "Әлде кім (мүмкін сіз болуыңыз, $1 IP адресінен) {{SITENAME}} сайтында ($4) құпия сөзді өзгертуге өтініш білдірді. Мына қатысушы {{PLURAL:$3|аккаунты|аккаунттары}} осы электронды почта қатысты:\n\n$2\n\n{{PLURAL:$3|Бұл уақытша құпия сөз|Бұл уақытша құпия сөздер}} {{PLURAL:$5|бір күнде|$5 күнде}}уақыты аяқталады.\nСіз кіруіңіз және жаңа құпия сөзді таңдауыңыз керек. Егер бұл өтінішті басқа біреу жасаса, немесе сіз  бұрынғы құпия сөзіңізді еске түсірсеңіз және құпия сөзді ауыстыруды қаламасаңыз, сіз бұл хабарламаны ескермей және бұрынғы құпия сөзді қолдана беруіңізге болады.",
        "passwordreset-emailtext-user": "$1 есімді қатысушы {{SITENAME}} сайтында ($4) құпия сөзді өзгертуге өтініш білдірді. Мына қатысушы {{PLURAL:$3|аккаунт|аккаунттар}} осы електронды почта қатысты:\n\n$2\n\n{{PLURAL:$3|Бұл уақытша құпия сөз|Бұл уақытша құпия сөздер}} {{PLURAL:$5|бір күнде|$5 күнде}}уақыты аяқталады.\nСіз кіруіңіз және жаңа құпия сөзді таңдауыңыз керек. Егер бұл өтінішті басқа біреу жасаса, немесе сіз  бұрынғы құпия сөзіңізді еске түсірсеңіз, және құпия сөзді ауыстыруды қаламасаңыз, сіз бұл хабарламаны ескермей және бұрыңғы құпия сөзді қолдана беруіңізге болады.",
        "passwordreset-emailelement": "Қатысушы есімі: \n$1\n\nУақытша құпия сөз: \n$2",
        "passwordreset-emailsentemail": "Бұл email мекенжайы тіркелгіңізге байланысқан, сол себепті құпия сөзді өзгерту электронды пошта арқылы жөнелтіледі.",
-       "passwordreset-emailsent-capture2": "{{PLURAL:$1|email has|emails have}}үшін құпия сөздің қалпына келтіру хабарламасы жіберілді. {{PLURAL:$1|username and password|list of usernames and passwords}} мында көрсетілген.",
-       "passwordreset-emailerror-capture2": "{{GENDER:$2|user}}-мен электронды поштамен хабарласу нәтижесіз қалды: $1 The {{PLURAL:$3|username and password|list of usernames and passwords}} мында көрсетілген.",
        "changeemail": "Е-пошта мекенжайын өзгерту немесе аластау",
        "changeemail-header": "Е-пошта мекен-жайының өзгертілуі",
        "changeemail-no-info": "Бұл бетке тікелей ену үшін жүйеге кіруіңіз керек.",
        "userrights-reason": "Себебі:",
        "userrights-no-interwiki": "Басқа уикилердегі қатысушы құқықтарын өңдеуге рұқсатыңыз жоқ.",
        "userrights-nodatabase": "$1 дерекқоры жоқ не жергілікті емес.",
-       "userrights-nologin": "Қатысушы құқықтарын тағайындау үшін әкімші тіркелгісімен [[Special:UserLogin|кіруіңіз]] жөн.",
-       "userrights-notallowed": "Сізге қатысушы құқықтарын қосуға немесе алып тастауға рұқсат берілмеген.",
        "userrights-changeable-col": "Өзгерте алатын топтар",
        "userrights-unchangeable-col": "Өзгерте алмайтын топтар",
        "userrights-conflict": "Қатысушы құқықтарының қақтығысы! Өзгертулеріңізді қайта қарап шығыңыз және құптаңыз.",
-       "userrights-removed-self": "Өзіңіздің құқықтарыңызды алып тастадыңыз.  Осылайша бұл бетке бұдан былай қатынай алмайсыз.",
        "group": "Топ:",
        "group-user": "Қатысушылар",
        "group-autoconfirmed": "Өздіктіқұпталған қатысушылар",
        "right-siteadmin": "Дерекқорды құлыптау және құлыптауын өшіру",
        "right-override-export-depth": "Тереңдігі 5-тен жоғары сілтенген бетттерді қамти беттерді экспорттау",
        "right-sendemail": "Басқа қатысушыларға е-пошта жіберу",
-       "right-passwordreset": "Өзгерген құпия сөз арқылы хабарламаларды шолу",
        "right-managechangetags": "[[Special:Tags|Тегтерді]] дерекқордан бастау және жою",
        "right-applychangetags": "[[Special:Tags|Тегтерді]] бір өзгерісімен қолдану",
        "right-changetags": "Кез келген [[Special:Tags|тегті]] жеке нұсқалардан және журнал жазбаларынан аластау және қосу",
        "trackingcategories-msg": "Санатты қадағалау",
        "trackingcategories-name": "Хабарлама атауы",
        "trackingcategories-desc": "Санаттарды қосу шарттары",
-       "restricted-displaytitle-ignored": "Еленбеген көретілетін атауларымен беттер",
+       "restricted-displaytitle-ignored": "Еленбеген көрcетілетін атауларымен беттер",
        "noindex-category-desc": "Бұл бет роботтар арқылы индекстелмеген, себебі онда <code><nowiki>__NOINDEX__</nowiki></code> деген сиқырлы сөзі бар және бұл жалауша рұқсат етілген есім кеңістігінде орналасқан.",
        "index-category-desc": "Бұл бетте <code><nowiki>__INDEX__</nowiki></code> деген код бар (және бұл жалауша рұқсат етілген есім кеңістігінде орналасқан), демек мұнда қалыпты жағдайда роботтар арқылы индекстелмейді.",
        "post-expand-template-inclusion-category-desc": "Беттің мөлшері барлық үлгілерді кеңейткен соң мынадан <code>$wgMaxArticleSize</code> үлкенірек болады, сондықтан біраз үлгілер кеңейтілмейді.",
index ddc46f0..6ef89e6 100644 (file)
        "passwordreset-emaildisabled": "या विकिवर विपत्र पाठविणे 'अशक्य' करण्यात आलेले आहे.",
        "passwordreset-username": "सदस्यनाव:",
        "passwordreset-domain": "डोमेन",
-       "passwordreset-capture": "ईमेल कशी असेल ते बघायचेय ?",
-       "passwordreset-capture-help": "या चौकटीत खूण केली तर, ईमेल (तात्पुरत्या परवलीच्या शब्दासह) दाखविण्यात व सदस्यास पाठविण्यात येईल.",
        "passwordreset-email": "विपत्र पत्ता",
        "passwordreset-emailtitle": "{{SITENAME}} वरील खात्याची माहिती",
        "passwordreset-emailtext-ip": "कुणीतरी (कदाचित तुम्ही, अंकपत्ता $1 वरुन) {{SITENAME}}($4) करिता नविन 'परवलीचा शब्द' पुनर्स्थापनेबद्दल विनंती केली आहे.\nखालील{{PLURAL:$3|सदस्यखाते}}या विपत्रपत्त्याशी निगडीत आहे: \n\"$2\"\n{{PLURAL:$3|हा तात्पुरता परवलीचा शब्द|हे तात्पुरते परवलीचे शब्द}}{{PLURAL:$5|एक दिवस|$5 दिवसात}} मुदतबाह्य होतील.आता आपण लॉग-ईन करून  नविन परवलीचा शब्द निवडा.जर ईतर कोणी ही विनंती केली असेल,किंवा जर आपणास परवलीच शब्द आठवला असेल तर,व जर आपण तो बदलु इच्छित नसाल तर आपण हा संदेश टाळा व आपला जुना परवलीचा शब्द वापरणे सुरू ठेवा.",
        "userrights-reason": "कारण:",
        "userrights-no-interwiki": "इतर विकींवरचे सदस्य अधिकार बदलण्याची परवानगी तुम्हाला नाही.",
        "userrights-nodatabase": "विदा $1 अस्तित्वात नाही अथवा स्थानिक नाही.",
-       "userrights-nologin": "सदस्य अधिकार देण्यासाठी तुम्ही प्रबंधक म्हणून [[Special:UserLogin|सनोंद प्रवेशित]] असणे आवश्यक आहे.",
-       "userrights-notallowed": "तुमच्या सदस्य खात्यास, सदस्य अधिकारांची निश्चिती करण्याची परवानगी नाही.",
        "userrights-changeable-col": "गट जे तुम्ही बदलू शकता",
        "userrights-unchangeable-col": "गट जे तुम्ही बदलू शकत नाही",
        "userrights-conflict": "बदलाबाबत सदस्य-हक्क विसंवाद !कृपया आपले बदल पुन्हा पुनरावलोकित व नक्की करा.",
-       "userrights-removed-self": "आपण आपले हक्क यशस्वीरित्या काढलेत.म्हणुन, या पानात आपण दाखल होऊ शकणार नाही.",
        "group": "गट:",
        "group-user": "सदस्य",
        "group-autoconfirmed": "स्वयंशाबीत सदस्य",
        "right-siteadmin": "माहितीसाठ्याला कुलूप लावा अथवा काढा",
        "right-override-export-depth": "जोडलेल्या पानांचा पाचव्या पातळीपर्यंत अंतर्भाव करुन पाने निर्यात करा",
        "right-sendemail": "इतर सदस्यांना विपत्रे पाठवा",
-       "right-passwordreset": "परवलीचा शब्द पुनर्स्थापित केल्याचे विपत्र पहा.",
        "right-managechangetags": "डाटाबेस मधून [[Special:Tags|खूणपताका]] तयार करा किंवा  वगळा",
        "right-applychangetags": "कोणाच्याही बदलास [[Special:Tags|खूणपताका]] जोडा",
        "right-changetags": "वैयक्तिक आवृत्त्यांना व नोंद प्रवेष्ट्यांना, आहेतुक(arbitrary) [[Special:Tags|खूणपताका]] जोडा अथवा हटवा",
        "listgrants": "अनुदाने",
        "listgrants-grant": "अनुदान",
        "listgrants-rights": "अधिकार",
-       "trackingcategories": "वरà¥\8dà¤\97 à¤¶à¥\8bधत à¤\86हà¥\8bत",
+       "trackingcategories": "माà¤\97à¥\8bवा à¤\98à¥\87णारà¥\87 à¤µà¤°à¥\8dà¤\97",
        "trackingcategories-summary": "या पानात ते रेखापथनातील वर्ग(tracking categories) आहेत, जे, मिडियाविकि संचेतनाद्वारे स्वयंचलितरित्या वसविण्यात (तयार करण्यात) आले आहेत. त्यांची नावे, {{ns:8}} नामविश्वातील संबंधित प्रणाली संदेशात फेरफार करुन, बदलविता येतात.",
        "trackingcategories-name": "संदेश नाम",
        "trackingcategories-desc": "वर्ग अंतर्भूत करण्याचे निकष",
        "randomrootpage": "अविशिष्ट मूळ पान",
        "log-action-filter-suppress-block": "रोधामार्फत सदस्य दाबणे",
        "changecredentials": "अधिकारपत्रे (क्रेडेंटियल्स)बदला",
-       "removecredentials": "अधिकारपत्रे (क्रेडेंटियल्स) हटवा",
-       "edit-error-short": "त्रुटी: $1",
-       "edit-error-long": "त्रुटी:$1"
+       "removecredentials": "अधिकारपत्रे (क्रेडेंटियल्स) हटवा"
 }
index 7327012..84bca9a 100644 (file)
        "listgrants-summary": "Explanatory text shown at the top of the grant/rights mapping table.\n\nRefers to {{msg-mw|Listgrouprights-helppage}}.",
        "listgrants-grant": "Used as table header for the grant/rights mapping table.\n{{Identical|Grant}}",
        "listgrants-rights": "Used as table header for the grant/rights mapping table.\n{{Identical|Right}}",
+       "listgrants-grant-display": "{{optional}}\nUsed to display the code name of a grant next to the grant. Parameters:\n* $1 - the text from the \"grant-...\" messages, i.e. {{msg-mw|Grant-highvolume}}\n* $2 - the codename of this grant",
        "trackingcategories": "[[Special:TrackingCategories]] page implementing list of Tracking categories [[mw:Special:MyLanguage/Help:Tracking categories|tracking category]].\n{{Identical|Tracking category}}",
        "trackingcategories-summary": "Description for [[Special:TrackingCategories]] page [[mw:Help:Tracking categories|tracking category]]",
        "trackingcategories-msg": "Header for the message column of the table on [[Special:TrackingCategories]]. This column lists the mediawiki message that controls the tracking category in question.\n{{Identical|Tracking category}}",
        "mw-widgets-dateinput-no-date": "Label of a date input field when no date has been selected.",
        "mw-widgets-dateinput-placeholder-day": "[[File:DateInputWidget active, empty.png|frame|Screenshot]]\nPlaceholder displayed in a date input field when it's empty, representing a date format with 4 digits for year, 2 digits for month, and 2 digits for day, separated with hyphens. This should be uppercase, if possible, and must not include any additional explanations. If there is no good way to translate it, make this message blank.",
        "mw-widgets-dateinput-placeholder-month": "Placeholder displayed in a date input field when it's empty, representing a date format with 4 digits for year and 2 digits for month, separated with hyphens (without a day). This should be uppercase, if possible, and must not include any additional explanations. If there is no good way to translate it, make this message blank.",
+       "mw-widgets-mediasearch-input-placeholder": "Place holder text for media search input",
+       "mw-widgets-mediasearch-noresults": "Label notifying the user no results were found for the media search.",
        "mw-widgets-titleinput-description-new-page": "Description label for a new page in the title input widget.",
        "mw-widgets-titleinput-description-redirect": "Description label for a redirect in the title input widget.",
        "mw-widgets-categoryselector-add-category-placeholder": "Placeholder displayed in the category selector widget after the capsules of already added categories.",
index ea05650..6e45545 100644 (file)
        "uploadstash-errclear": "Билэлэри сотор табыллыбата.",
        "uploadstash-refresh": "Билэлэр тиһиктэрин саҥардан биэр",
        "uploadstash-thumbnail": "ойуучааны көрдөр",
+       "uploadstash-exception": "Суруттараргын быстах уурар сиргэ харайар сатаммата ($1): \"$2\".",
        "invalid-chunk-offset": "Бобуллубут сыҕарыйыы",
        "img-auth-accessdenied": "Киирии бобуллубут",
        "img-auth-nopathinfo": "PATH_INFO суох.\nЭн сиэрбэриҥ маннык сибидиэнньэни ыытарга туруоруллубатах эбит.\nБаҕар кини CGI олоҕурара буолуо ол иһин img_auth өйөөбөтө буолуо.\nМаны https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Image_Authorization көр.",
        "filerevert-submit": "Төннөрүү",
        "filerevert-success": "'''[[Media:$1|$1]]''' бу торумҥа төннөрүлүннэ [$4 торум Filetype-missingот $3, $2].",
        "filerevert-badversion": "Бу билэ этиллибит күҥҥэ-ыйга/кэмҥэ оҥоһуллубут урукку торума суох.",
+       "filerevert-identical": "Талбыт торумуҥ билиҥҥи торуму кытта үүт үкчүлэр.",
        "filedelete": "Сот: $1",
        "filedelete-legend": "Билэни сот",
        "filedelete-intro": "Бу билэни '''[[Media:$1|$1]]''' туох баар суруллубут историятын кытта сотон эрэҕин.",
        "apisandbox": "API песочница",
        "apisandbox-jsonly": "API-песочницаны туһанарга JavaScript ирдэнэр.",
        "apisandbox-api-disabled": "Бу сайтка API араарыллыбыт.",
+       "apisandbox-intro": "Бу сирэйи <strong>MediaWiki API</strong> тургутан көрөргө туһан.\nAPI-ни туттар туһунан сиһилии манна ааҕыахха сөп [[mw:API:Main page|API туһунан]]. Холобура, [https://www.mediawiki.org/wiki/API#A_simple_example Сүрүн сирэй иһинээҕитин хайдах ылар туһунан]. Атын холобурдары көрөргө сигэни баттаа.\nБолҕой: бу тургутар сирэй эрээри, манна суруйбутуҥ биикигэ уларытыыны оҥоруон сөп.",
        "apisandbox-fullscreen": "Паныалы арыйыы.",
        "apisandbox-fullscreen-tooltip": "Браузеры толорорго песочница паныалын арыйыы.",
        "apisandbox-unfullscreen": "Сирэйи көрдөрүү",
        "apisandbox-submit": "Ыйытык оҥоруу",
        "apisandbox-reset": "Сот",
        "apisandbox-retry": "Хатылаа",
+       "apisandbox-loading": "«$1» API-модульга аналлаах хачайдана турар…",
+       "apisandbox-load-error": "«$1» API-модулга аналлаах хачайданарыгар алҕас таҕыста: $2",
+       "apisandbox-no-parameters": "Бу API-модулга туруоруута (параметра) суох.",
        "apisandbox-helpurls": "Көмө сигэлэр",
        "apisandbox-examples": "Холобурдар",
        "apisandbox-dynamic-parameters": "Дьайыы кээмэйдэрэ.",
        "apisandbox-results": "Түмүк",
        "apisandbox-sending-request": "API-көрдөбүлү ыытыы…",
        "apisandbox-loading-results": "API-түмүгүн ылыы…",
+       "apisandbox-results-error": "Көрдөбүлгэ API-хоруйу киллэрии  кэмигэр алҕас таҕыста: $1.",
+       "apisandbox-request-url-label": "Көрдөбүл URL-аадырыһа:",
+       "apisandbox-request-time": "Көрдөбүл болдьоҕо: {{PLURAL:$1|$1 мс}}",
        "apisandbox-results-fixtoken": "Токены көннөрөн баран саҥаттан ыыт.",
+       "apisandbox-results-fixtoken-fail": "«$1» токены ыҥырар табыллыбата.",
+       "apisandbox-alert-page": "Бу сирэй хонуулара алҕастаах.",
+       "apisandbox-alert-field": "Хонуу суолтата алҕастаах.",
+       "apisandbox-continue": "Салгыы",
+       "apisandbox-continue-clear": "Сот",
        "booksources": "Кинигэлэр источниктара",
        "booksources-search-legend": "Кинигэ туһунан көрдөө",
        "booksources-search": "Бул",
index 12d7974..290a8b8 100644 (file)
        "tooltip-pt-mytalk": "{{GENDER:|Tvoja}} pogovorna stran",
        "tooltip-pt-anontalk": "Pogovor o urejanjih s tega IP-naslova",
        "tooltip-pt-preferences": "{{GENDER:|Tvoje}} nastavitve",
-       "tooltip-pt-watchlist": "Seznam strani, katerih spremembe spremljate",
+       "tooltip-pt-watchlist": "Seznam strani, katerih spremembe spremljaš",
        "tooltip-pt-mycontris": "Seznam {{GENDER:|tvojih}} prispevkov",
        "tooltip-pt-anoncontribs": "Seznam urejanj s tega IP-naslova",
        "tooltip-pt-login": "Prijava ni obvezna, vendar je zaželena",
index cbf3596..b272865 100644 (file)
        "passwordreset-emaildisabled": "Bu wiki'deki e-posta özellikleri devre dışı bırakıldı.",
        "passwordreset-username": "Kullanıcı adı:",
        "passwordreset-domain": "Domain:",
-       "passwordreset-capture": "Sonuç e-postasını görüntüle?",
-       "passwordreset-capture-help": "Bu kutuyu işaretlerseniz, e-posta (geçici şifre ile) size ve yanı sıra kullanıcıya gönderiliyor.",
        "passwordreset-email": "E-posta adresi:",
        "passwordreset-emailtitle": "{{SITENAME}} hesap detayları",
        "passwordreset-emailtext-ip": "Birisi, (muhtemelen siz, $1 IP adresinden) {{SITENAME}} ($4) için hesap bilgilerinizin \nhatırlatılmasını istedi. Aşağıdaki kullanıcı {{PLURAL:$3|hesabı|hesapları}} bu e-posta adresiyle ilişkili:\n\n$2\n\n{{PLURAL:$3|Bu geçici şifre|Bu geçici şifreler}} {{PLURAL:$5|bir gün|$5  gün}} geçerlidir.\nBu geçici parola ile giriş yapın ve yeni bir şifre seçin. Şifre değişimini siz istemediyseniz veya şifrenizi hatırladıysanız ve artık şifrenizi değiştirmek istemiyorsanız; bu iletiyi önemsemeyerek eski şifrenizi kullanmaya devam edebilirsiniz.",
        "userrights-reason": "Neden:",
        "userrights-no-interwiki": "Diğer vikilerdeki kullanıcıların izinlerini değiştirmeye yetkiniz yok.",
        "userrights-nodatabase": "$1 veritabanı mevcut veya bölgesel değil",
-       "userrights-nologin": "Kullanıcı haklarını atamak için hizmetli hesabı ile [[Special:UserLogin|giriş yapmanız gerekir]].",
-       "userrights-notallowed": "Kullanıcı hakları eklemek veya kaldırmak için izniniz yok.",
        "userrights-changeable-col": "Değiştirebildiğiniz gruplar",
        "userrights-unchangeable-col": "Değiştirebilmediğiniz gruplar",
        "userrights-conflict": "Kullanıcı hakları değişikliklerinde çakışma! Lütfen değişikliklerinizi gözden geçirin ve onaylayın.",
-       "userrights-removed-self": "Kendi haklarınız başarıyla kaldırıldı. Bu nedenle, artık bu sayfaya erişemeyeceksiniz.",
        "group": "Grup:",
        "group-user": "Kullanıcılar",
        "group-autoconfirmed": "Otomatik onaylanmış kullanıcılar",
        "right-siteadmin": "Veritabanını kilitle ve kilidi aç",
        "right-override-export-depth": "Sayfaları, derinlik 5'e kadar bağlantılı sayfalarla beraber, dışa aktar",
        "right-sendemail": "Diğer kullanıcılara e-posta gönder",
-       "right-passwordreset": "Parola sıfırlama e-postalarını görür",
        "right-managechangetags": "Veritabanında [[Special:Tags|etiket]] oluşturma veya silme",
        "right-applychangetags": "Değişiklikleriyle beraber [[Special:Tags|etiketleri]] uygula",
        "right-changetags": "Tekil sürümler ve günlük kayıtlarına rastgele [[Special:Tags|etiket]] ekleme veya çıkarma",
        "booksources-search": "Ara",
        "booksources-text": "Aşağıdaki, yeni ve kullanılmış kitap satan diğer sitelere bağlantıların listesidir, ve aradığınız kitaplar hakkında daha fazla bilgiye sahip olabilirler:",
        "booksources-invalid-isbn": "Verilen ISBN geçersiz gibi görünüyor; orijinal kaynaktan kopyalama hataları için kontrol edin.",
+       "magiclink-tracking-rfc": "RFC sihirli bağlantısını kullanan sayfalar",
+       "magiclink-tracking-pmid": "PMID sihirli bağlantısını kullanan sayfalar",
+       "magiclink-tracking-isbn": "ISBN sihirli bağlantısını kullanan sayfalar",
        "specialloguserlabel": "Kullanıcı:",
        "speciallogtitlelabel": "Hedef (başlık ya da kullanıcı):",
        "log": "Kayıtlar",
index 2269267..3a5a537 100644 (file)
        "createacct-another-username-ph": "Учётной книга нимъёс пыртэмын",
        "yourpassword": "Лушкемкыл:",
        "userlogin-yourpassword": "Лушкемкыл",
+       "createacct-yourpassword-ph": "Гожтэ паролез",
        "createacct-yourpasswordagain": "Пароль юнматэ",
+       "createacct-yourpasswordagain-ph": "Гожтэ паролез эшшо одӥг пол",
        "userlogin-remembermypassword": "Кылем сӧзнэтэз",
        "cannotcreateaccount-title": "Уг быгатиськы гожъян кылдӥз учётной",
        "yourdomainname": "Тӥ доменэн:",
        "userlogin-helplink2": "Пыронъя юрттэт",
        "createacct-emailrequired": "Электронной почталэн адресэз",
        "createacct-emailoptional": "Электронной почтаезлэн адресэз (необязательное)",
+       "createacct-email-ph": "Гожтэ асьтэлэн электрон почтадылэсь адрессэ",
        "createaccountmail": "Адрес электронной почта огдырлы кутӥ вылын возьматэм образъёсыныз но соослэн случайной сгенерировать пароль ыстыны",
        "createacct-submit": "Выль вики-авторлэн регистрациез",
        "createacct-another-submit": "Выль вики-авторлэн регистрациез",
+       "createacct-benefit-heading": "{{SITENAME}} — тӥ выллем адямиослэн валче ужамзы.",
        "loginerror": "Янгышъёс пырон",
        "createacct-error": "Янгышъёс бордын учётной книга кылдытыны",
        "createaccounterror": "Уг быгатиськы гожъян учётной кылдоз: $1",
        "blocked-notice-logextract": "Пользователь заблокирован сётӥз та учырлы.\nСправка понна радъяськылӥсь журнал блокировка лапег берпуметӥ гожтэт:",
        "continue-editing": "Тупатъянэз азьланьтоно",
        "editing": "Тупатон: $1",
+       "creating": "«$1» бамез кылдытон",
        "editingsection": "Тупатон: $1 (люкет)",
        "template-protected": "(утемын)",
        "template-semiprotected": "(полуутемын)",
        "tooltip-ca-addsection": "Выль люкет кылдытоно",
        "tooltip-ca-viewsource": "Та бам воштонъёслэсь утемын.\nТӥ быгатӥськоды инъет текстсэ учкыны но кӧчырыны",
        "tooltip-ca-history": "Бамлэн воштонъёсыныз журнал",
+       "tooltip-ca-move": "Та бамлэсь нимзэ воштыны",
        "tooltip-ca-watch": "Та бамез чаклан списокады пыртоно",
        "tooltip-search": "Утчано {{SITENAME}}",
        "tooltip-search-go": "Выжоно сыӵе ик нимын баме",
        "simpleantispam-label": "Анти-спам эскерон.\n<strong>Эн</strong> гожтэ татчы!",
        "pageinfo-header-edits": "Воштонъёслэн историзы",
        "pageinfo-toolboxlink": "Бам сярысь тодэтъёс",
+       "previousdiff": "← Вужгес тупатон",
        "file-info-size": "$1 × $2 пиксель, файллэн быдӟалаез: $3, MIME-тип: $4",
        "file-nohires": "Бадӟымгес быдӟалаен суред ӧвӧл.",
        "svg-long-desc": "SVG файл, номинально $1 × $2 пиксель, файллэн быдӟалаез: $3",
index 360adef..18ad10f 100644 (file)
        "userrights-user-editname": "Введіть ім'я користувача:",
        "editusergroup": "Завантажити групи користувачів",
        "editinguser": "Зміна прав {{GENDER:$1|користувача}} <strong>[[User:$1|$1]]</strong> $2",
-       "userrights-editusergroup": "Змінити групи користувачів",
+       "userrights-editusergroup": "Змінити групи {{GENDER:$1|користувача|користувачки}}",
        "saveusergroups": "Зберегти групи {{GENDER:$1|користувачів}}",
        "userrights-groupsmember": "Член груп:",
        "userrights-groupsmember-auto": "Неявний член:",
index 587a84d..b37febd 100644 (file)
@@ -2289,6 +2289,32 @@ return [
                ],
                'targets' => [ 'desktop', 'mobile' ],
        ],
+       'mediawiki.widgets.MediaSearch' => [
+               'scripts' => [
+                       'resources/src/mediawiki.widgets/MediaSearch/mw.widgets.APIResultsProvider.js',
+                       'resources/src/mediawiki.widgets/MediaSearch/mw.widgets.APIResultsQueue.js',
+                       'resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResourceProvider.js',
+                       'resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchProvider.js',
+                       'resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResourceQueue.js',
+                       'resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchQueue.js',
+                       'resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchWidget.js',
+                       'resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResultWidget.js',
+               ],
+               'styles' => [
+                       'resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchWidget.css',
+                       'resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResultWidget.css',
+               ],
+               'dependencies' => [
+                       'oojs-ui-widgets',
+                       'mediawiki.ForeignApi',
+                       'mediawiki.Title',
+               ],
+               'messages' => [
+                       'mw-widgets-mediasearch-noresults',
+                       'mw-widgets-mediasearch-input-placeholder',
+               ],
+               'targets' => [ 'desktop', 'mobile' ],
+       ],
        'mediawiki.widgets.UserInputWidget' => [
                'scripts' => [
                        'resources/src/mediawiki.widgets/mw.widgets.UserInputWidget.js',
index 8c78b67..ae68fc4 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * QUnit 1.22.0
+ * QUnit 1.23.1
  * https://qunitjs.com/
  *
  * Copyright jQuery Foundation and other contributors
  * Released under the MIT license
  * https://jquery.org/license
  *
- * Date: 2016-02-23T15:57Z
+ * Date: 2016-04-12T17:29Z
  */
 
 /** Font Family and Sizes */
index 84873ae..5df0822 100644 (file)
@@ -1,15 +1,15 @@
 /*!
- * QUnit 1.22.0
+ * QUnit 1.23.1
  * https://qunitjs.com/
  *
  * Copyright jQuery Foundation and other contributors
  * Released under the MIT license
  * https://jquery.org/license
  *
- * Date: 2016-02-23T15:57Z
+ * Date: 2016-04-12T17:29Z
  */
 
-(function( global ) {
+( function( global ) {
 
 var QUnit = {};
 
@@ -27,7 +27,7 @@ var window = global.window;
 var defined = {
        document: window && window.document !== undefined,
        setTimeout: setTimeout !== undefined,
-       sessionStorage: (function() {
+       sessionStorage: ( function() {
                var x = "qunit-test-string";
                try {
                        sessionStorage.setItem( x, x );
@@ -46,7 +46,7 @@ var runStarted = false;
 var toString = Object.prototype.toString,
        hasOwn = Object.prototype.hasOwnProperty;
 
-// returns a new Array with the elements that are in a but not in b
+// Returns a new Array with the elements that are in a but not in b
 function diff( a, b ) {
        var i, j,
                result = a.slice();
@@ -63,7 +63,7 @@ function diff( a, b ) {
        return result;
 }
 
-// from jquery.js
+// From jquery.js
 function inArray( elem, array ) {
        if ( array.indexOf ) {
                return array.indexOf( elem );
@@ -157,32 +157,6 @@ function is( type, obj ) {
        return QUnit.objectType( obj ) === type;
 }
 
-var getUrlParams = function() {
-       var i, param, name, value;
-       var urlParams = {};
-       var location = window.location;
-       var params = location.search.slice( 1 ).split( "&" );
-       var length = params.length;
-
-       for ( i = 0; i < length; i++ ) {
-               if ( params[ i ] ) {
-                       param = params[ i ].split( "=" );
-                       name = decodeURIComponent( param[ 0 ] );
-
-                       // allow just a key to turn on a flag, e.g., test.html?noglobals
-                       value = param.length === 1 ||
-                               decodeURIComponent( param.slice( 1 ).join( "=" ) ) ;
-                       if ( urlParams[ name ] ) {
-                               urlParams[ name ] = [].concat( urlParams[ name ], value );
-                       } else {
-                               urlParams[ name ] = value;
-                       }
-               }
-       }
-
-       return urlParams;
-};
-
 // Doesn't support IE6 to IE9, it will return undefined on these browsers
 // See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error/Stack
 function extractStacktrace( e, offset ) {
@@ -212,12 +186,12 @@ function extractStacktrace( e, offset ) {
        // Support: Safari <=6 only
        } else if ( e.sourceURL ) {
 
-               // exclude useless self-reference for generated Error objects
+               // Exclude useless self-reference for generated Error objects
                if ( /qunit.js$/.test( e.sourceURL ) ) {
                        return;
                }
 
-               // for actual exceptions, this is useful
+               // For actual exceptions, this is useful
                return e.sourceURL + ":" + e.line;
        }
 }
@@ -244,53 +218,35 @@ function sourceFromStacktrace( offset ) {
  * `config` initialized at top of scope
  */
 var config = {
+
        // The queue of tests to run
        queue: [],
 
-       // block until document ready
+       // Block until document ready
        blocking: true,
 
-       // by default, run previously failed tests first
+       // By default, run previously failed tests first
        // very useful in combination with "Hide passed tests" checked
        reorder: true,
 
-       // by default, modify document.title when suite is done
+       // By default, modify document.title when suite is done
        altertitle: true,
 
        // HTML Reporter: collapse every test except the first failing test
        // If false, all failing tests will be expanded
        collapse: true,
 
-       // by default, scroll to top of the page when suite is done
+       // By default, scroll to top of the page when suite is done
        scrolltop: true,
 
-       // depth up-to which object will be dumped
+       // Depth up-to which object will be dumped
        maxDepth: 5,
 
-       // when enabled, all tests must call expect()
+       // When enabled, all tests must call expect()
        requireExpects: false,
 
-       // add checkboxes that are persisted in the query-string
-       // when enabled, the id is set to `true` as a `QUnit.config` property
-       urlConfig: [
-               {
-                       id: "hidepassed",
-                       label: "Hide passed tests",
-                       tooltip: "Only show tests and assertions that fail. Stored as query-strings."
-               },
-               {
-                       id: "noglobals",
-                       label: "Check for Globals",
-                       tooltip: "Enabling this will test if any test introduces new properties on the " +
-                               "global object (`window` in Browsers). Stored as query-strings."
-               },
-               {
-                       id: "notrycatch",
-                       label: "No try-catch",
-                       tooltip: "Enabling this will run tests outside of a try-catch block. Makes debugging " +
-                               "exceptions in IE reasonable. Stored as query-strings."
-               }
-       ],
+       // Placeholder for user-configurable form-exposed URL parameters
+       urlConfig: [],
 
        // Set of all modules.
        modules: [],
@@ -307,27 +263,9 @@ var config = {
        callbacks: {}
 };
 
-var urlParams = defined.document ? getUrlParams() : {};
-
 // Push a loose unnamed module to the modules collection
 config.modules.push( config.currentModule );
 
-if ( urlParams.filter === true ) {
-       delete urlParams.filter;
-}
-
-// String search anywhere in moduleName+testName
-config.filter = urlParams.filter;
-
-config.testId = [];
-if ( urlParams.testId ) {
-       // Ensure that urlParams.testId is an array
-       urlParams.testId = decodeURIComponent( urlParams.testId ).split( "," );
-       for (var i = 0; i < urlParams.testId.length; i++ ) {
-               config.testId.push( urlParams.testId[ i ] );
-       }
-}
-
 var loggingCallbacks = {};
 
 // Register logging callbacks
@@ -431,7 +369,7 @@ function verifyLoggingCallbacks() {
                                }
                                QUnit.pushFailure( error, filePath + ":" + linerNr );
                        } else {
-                               QUnit.test( "global failure", extend(function() {
+                               QUnit.test( "global failure", extend( function() {
                                        QUnit.pushFailure( error, filePath + ":" + linerNr );
                                }, { validTest: true } ) );
                        }
@@ -440,25 +378,23 @@ function verifyLoggingCallbacks() {
 
                return ret;
        };
-} )();
-
-QUnit.urlParams = urlParams;
+}() );
 
 // Figure out if we're running the tests from a server or not
 QUnit.isLocal = !( defined.document && window.location.protocol !== "file:" );
 
 // Expose the current QUnit version
-QUnit.version = "1.22.0";
+QUnit.version = "1.23.1";
 
 extend( QUnit, {
 
-       // call on start of module test to prepend name to all tests
+       // Call on start of module test to prepend name to all tests
        module: function( name, testEnvironment, executeNow ) {
                var module, moduleFns;
                var currentModule = config.currentModule;
 
                if ( arguments.length === 2 ) {
-                       if ( testEnvironment instanceof Function ) {
+                       if ( objectType( testEnvironment ) === "function" ) {
                                executeNow = testEnvironment;
                                testEnvironment = undefined;
                        }
@@ -482,7 +418,7 @@ extend( QUnit, {
                        afterEach: setHook( module, "afterEach" )
                };
 
-               if ( executeNow instanceof Function ) {
+               if ( objectType( executeNow ) === "function" ) {
                        config.moduleStack.push( module );
                        setCurrentModule( module );
                        executeNow.call( module.testEnvironment, moduleFns );
@@ -500,7 +436,8 @@ extend( QUnit, {
                        var module = {
                                name: moduleName,
                                parentModule: parentModule,
-                               tests: []
+                               tests: [],
+                               moduleId: generateHash( moduleName )
                        };
 
                        var env = {};
@@ -573,7 +510,7 @@ extend( QUnit, {
                                return;
                        }
 
-                       // throw an Error if start is called more often than stop
+                       // Throw an Error if start is called more often than stop
                        if ( config.current.semaphore < 0 ) {
                                config.current.semaphore = 0;
 
@@ -634,7 +571,7 @@ extend( QUnit, {
                offset = ( offset || 0 ) + 2;
                return sourceFromStacktrace( offset );
        }
-});
+} );
 
 registerLoggingCallbacks( QUnit );
 
@@ -657,17 +594,17 @@ function begin() {
 
                // Avoid unnecessary information by not logging modules' test environments
                for ( i = 0, l = config.modules.length; i < l; i++ ) {
-                       modulesLog.push({
+                       modulesLog.push( {
                                name: config.modules[ i ].name,
                                tests: config.modules[ i ].tests
-                       });
+                       } );
                }
 
                // The test run is officially beginning now
                runLoggingCallbacks( "begin", {
                        totalTests: Test.count,
                        modules: modulesLog
-               });
+               } );
        }
 
        config.blocking = false;
@@ -706,7 +643,7 @@ function pauseProcessing() {
 
        if ( config.testTimeout && defined.setTimeout ) {
                clearTimeout( config.timeout );
-               config.timeout = setTimeout(function() {
+               config.timeout = setTimeout( function() {
                        if ( config.current ) {
                                config.current.semaphore = 0;
                                QUnit.pushFailure( "Test timed out", sourceFromStacktrace( 2 ) );
@@ -723,7 +660,7 @@ function resumeProcessing() {
 
        // A slight delay to allow this iteration of the event loop to finish (more assertions, etc.)
        if ( defined.setTimeout ) {
-               setTimeout(function() {
+               setTimeout( function() {
                        if ( config.current && config.current.semaphore > 0 ) {
                                return;
                        }
@@ -752,7 +689,7 @@ function done() {
                        passed: config.moduleStats.all - config.moduleStats.bad,
                        total: config.moduleStats.all,
                        runtime: now() - config.moduleStats.started
-               });
+               } );
        }
        delete config.previousModule;
 
@@ -764,7 +701,7 @@ function done() {
                passed: passed,
                total: config.stats.all,
                runtime: runtime
-       });
+       } );
 }
 
 function setHook( module, hookName ) {
@@ -779,6 +716,7 @@ function setHook( module, hookName ) {
 
 var focused = false;
 var priorityCount = 0;
+var unitSampler;
 
 function Test( settings ) {
        var i, l;
@@ -801,10 +739,10 @@ function Test( settings ) {
 
        this.testId = generateHash( this.module.name, this.testName );
 
-       this.module.tests.push({
+       this.module.tests.push( {
                name: this.testName,
                testId: this.testId
-       });
+       } );
 
        if ( settings.skip ) {
 
@@ -840,14 +778,14 @@ Test.prototype = {
                                        passed: config.moduleStats.all - config.moduleStats.bad,
                                        total: config.moduleStats.all,
                                        runtime: now() - config.moduleStats.started
-                               });
+                               } );
                        }
                        config.previousModule = this.module;
                        config.moduleStats = { all: 0, bad: 0, started: now() };
                        runLoggingCallbacks( "moduleStart", {
                                name: this.module.name,
                                tests: this.module.tests
-                       });
+                       } );
                }
 
                config.current = this;
@@ -863,7 +801,7 @@ Test.prototype = {
                        name: this.testName,
                        module: this.module.name,
                        testId: this.testId
-               });
+               } );
 
                if ( !config.pollution ) {
                        saveGlobal();
@@ -892,7 +830,7 @@ Test.prototype = {
                        this.pushFailure( "Died on test #" + ( this.assertions.length + 1 ) + " " +
                                this.stack + ": " + ( e.message || e ), extractStacktrace( e, 0 ) );
 
-                       // else next test will carry the responsibility
+                       // Else next test will carry the responsibility
                        saveGlobal();
 
                        // Restart the tests if they're blocking
@@ -1001,7 +939,7 @@ Test.prototype = {
 
                        // DEPRECATED: this property will be removed in 2.0.0, use runtime instead
                        duration: this.runtime
-               });
+               } );
 
                // QUnit.reset() is deprecated and will be replaced for a new
                // fixture reset function on QUnit 2.0/2.1.
@@ -1021,8 +959,8 @@ Test.prototype = {
 
                function run() {
 
-                       // each of these can by async
-                       synchronize([
+                       // Each of these can by async
+                       synchronize( [
                                function() {
                                        test.before();
                                },
@@ -1040,19 +978,19 @@ Test.prototype = {
                                function() {
                                        test.finish();
                                }
-                       ]);
+                       ] );
                }
 
                // Prioritize previously failed tests, detected from sessionStorage
                priority = QUnit.config.reorder && defined.sessionStorage &&
                                +sessionStorage.getItem( "qunit-test-" + this.module.name + "-" + this.testName );
 
-               return synchronize( run, priority );
+               return synchronize( run, priority, config.seed );
        },
 
        pushResult: function( resultInfo ) {
 
-               // resultInfo = { result, actual, expected, message, negative }
+               // Destructure of resultInfo = { result, actual, expected, message, negative }
                var source,
                        details = {
                                module: this.module.name,
@@ -1076,10 +1014,10 @@ Test.prototype = {
 
                runLoggingCallbacks( "log", details );
 
-               this.assertions.push({
+               this.assertions.push( {
                        result: !!resultInfo.result,
                        message: resultInfo.message
-               });
+               } );
        },
 
        pushFailure: function( message, source, actual ) {
@@ -1104,10 +1042,10 @@ Test.prototype = {
 
                runLoggingCallbacks( "log", details );
 
-               this.assertions.push({
+               this.assertions.push( {
                        result: false,
                        message: message
-               });
+               } );
        },
 
        resolvePromise: function( promise, phase ) {
@@ -1126,7 +1064,7 @@ Test.prototype = {
                                                        " " + test.testName + ": " + ( error.message || error );
                                                test.pushFailure( message, extractStacktrace( error, 0 ) );
 
-                                               // else next test will carry the responsibility
+                                               // Else next test will carry the responsibility
                                                saveGlobal();
 
                                                // Unblock
@@ -1140,30 +1078,43 @@ Test.prototype = {
        valid: function() {
                var filter = config.filter,
                        regexFilter = /^(!?)\/([\w\W]*)\/(i?$)/.exec( filter ),
-                       module = QUnit.urlParams.module && QUnit.urlParams.module.toLowerCase(),
+                       module = config.module && config.module.toLowerCase(),
                        fullName = ( this.module.name + ": " + this.testName );
 
-               function testInModuleChain( testModule ) {
+               function moduleChainNameMatch( testModule ) {
                        var testModuleName = testModule.name ? testModule.name.toLowerCase() : null;
                        if ( testModuleName === module ) {
                                return true;
                        } else if ( testModule.parentModule ) {
-                               return testInModuleChain( testModule.parentModule );
+                               return moduleChainNameMatch( testModule.parentModule );
                        } else {
                                return false;
                        }
                }
 
+               function moduleChainIdMatch( testModule ) {
+                       return inArray( testModule.moduleId, config.moduleId ) > -1 ||
+                               testModule.parentModule && moduleChainIdMatch( testModule.parentModule );
+               }
+
                // Internally-generated tests are always valid
                if ( this.callback && this.callback.validTest ) {
                        return true;
                }
 
-               if ( config.testId.length > 0 && inArray( this.testId, config.testId ) < 0 ) {
+               if ( config.moduleId && config.moduleId.length > 0 &&
+                       !moduleChainIdMatch( this.module ) ) {
+
+                       return false;
+               }
+
+               if ( config.testId && config.testId.length > 0 &&
+                       inArray( this.testId, config.testId ) < 0 ) {
+
                        return false;
                }
 
-               if ( module && !testInModuleChain( this.module ) ) {
+               if ( module && !moduleChainNameMatch( this.module ) ) {
                        return false;
                }
 
@@ -1172,7 +1123,7 @@ Test.prototype = {
                }
 
                return regexFilter ?
-                       this.regexFilter( !!regexFilter[1], regexFilter[2], regexFilter[3], fullName ) :
+                       this.regexFilter( !!regexFilter[ 1 ], regexFilter[ 2 ], regexFilter[ 3 ], fullName ) :
                        this.stringFilter( filter, fullName );
        },
 
@@ -1260,8 +1211,9 @@ function generateHash( module, testName ) {
        return hex.slice( -8 );
 }
 
-function synchronize( callback, priority ) {
-       var last = !priority;
+function synchronize( callback, priority, seed ) {
+       var last = !priority,
+               index;
 
        if ( QUnit.objectType( callback ) === "array" ) {
                while ( callback.length ) {
@@ -1272,6 +1224,14 @@ function synchronize( callback, priority ) {
 
        if ( priority ) {
                config.queue.splice( priorityCount++, 0, callback );
+       } else if ( seed ) {
+               if ( !unitSampler ) {
+                       unitSampler = unitSamplerGenerator( seed );
+               }
+
+               // Insert into a random position after all priority items
+               index = Math.floor( unitSampler() * ( config.queue.length - priorityCount + 1 ) );
+               config.queue.splice( priorityCount + index, 0, callback );
        } else {
                config.queue.push( callback );
        }
@@ -1281,6 +1241,25 @@ function synchronize( callback, priority ) {
        }
 }
 
+function unitSamplerGenerator( seed ) {
+
+       // 32-bit xorshift, requires only a nonzero seed
+       // http://excamera.com/sphinx/article-xorshift.html
+       var sample = parseInt( generateHash( seed ), 16 ) || -1;
+       return function() {
+               sample ^= sample << 13;
+               sample ^= sample >>> 17;
+               sample ^= sample << 5;
+
+               // ECMAScript has no unsigned number type
+               if ( sample < 0 ) {
+                       sample += 0x100000000;
+               }
+
+               return sample / 0x100000000;
+       };
+}
+
 function saveGlobal() {
        config.pollution = [];
 
@@ -1288,7 +1267,7 @@ function saveGlobal() {
                for ( var key in global ) {
                        if ( hasOwn.call( global, key ) ) {
 
-                               // in Opera sometimes DOM element ids show up here, ignore them
+                               // In Opera sometimes DOM element ids show up here, ignore them
                                if ( /^qunit-test-output/.test( key ) ) {
                                        continue;
                                }
@@ -1337,12 +1316,12 @@ function test( testName, expected, callback, async ) {
                expected = null;
        }
 
-       newTest = new Test({
+       newTest = new Test( {
                testName: testName,
                expected: expected,
                async: async,
                callback: callback
-       });
+       } );
 
        newTest.queue();
 }
@@ -1351,10 +1330,10 @@ function test( testName, expected, callback, async ) {
 function skip( testName ) {
        if ( focused )  { return; }
 
-       var test = new Test({
+       var test = new Test( {
                testName: testName,
                skip: true
-       });
+       } );
 
        test.queue();
 }
@@ -1373,12 +1352,12 @@ function only( testName, expected, callback, async ) {
                expected = null;
        }
 
-       newTest = new Test({
+       newTest = new Test( {
                testName: testName,
                expected: expected,
                async: async,
                callback: callback
-       });
+       } );
 
        newTest.queue();
 }
@@ -1448,7 +1427,7 @@ QUnit.assert = Assert.prototype = {
 
        pushResult: function( resultInfo ) {
 
-               // resultInfo = { result, actual, expected, message, negative }
+               // Destructure of resultInfo = { result, actual, expected, message, negative }
                var assert = this,
                        currentTest = ( assert instanceof Assert && assert.test ) || QUnit.config.current;
 
@@ -1594,7 +1573,7 @@ QUnit.assert = Assert.prototype = {
                currentTest.ignoreGlobalErrors = true;
                try {
                        block.call( currentTest.testEnvironment );
-               } catch (e) {
+               } catch ( e ) {
                        actual = e;
                }
                currentTest.ignoreGlobalErrors = false;
@@ -1602,30 +1581,30 @@ QUnit.assert = Assert.prototype = {
                if ( actual ) {
                        expectedType = QUnit.objectType( expected );
 
-                       // we don't want to validate thrown error
+                       // We don't want to validate thrown error
                        if ( !expected ) {
                                ok = true;
                                expectedOutput = null;
 
-                       // expected is a regexp
+                       // Expected is a regexp
                        } else if ( expectedType === "regexp" ) {
                                ok = expected.test( errorString( actual ) );
 
-                       // expected is a string
+                       // Expected is a string
                        } else if ( expectedType === "string" ) {
                                ok = expected === errorString( actual );
 
-                       // expected is a constructor, maybe an Error constructor
+                       // Expected is a constructor, maybe an Error constructor
                        } else if ( expectedType === "function" && actual instanceof expected ) {
                                ok = true;
 
-                       // expected is an Error object
+                       // Expected is an Error object
                        } else if ( expectedType === "object" ) {
                                ok = actual instanceof expected.constructor &&
                                        actual.name === expected.name &&
                                        actual.message === expected.message;
 
-                       // expected is a validation function which returns true if validation passed
+                       // Expected is a validation function which returns true if validation passed
                        } else if ( expectedType === "function" && expected.call( {}, actual ) === true ) {
                                expectedOutput = null;
                                ok = true;
@@ -1643,10 +1622,10 @@ QUnit.assert = Assert.prototype = {
 
 // Provide an alternative to assert.throws(), for environments that consider throws a reserved word
 // Known to us are: Closure Compiler, Narwhal
-(function() {
+( function() {
        /*jshint sub:true */
-       Assert.prototype.raises = Assert.prototype[ "throws" ];
-}());
+       Assert.prototype.raises = Assert.prototype [ "throws" ]; //jscs:ignore requireDotNotation
+}() );
 
 function errorString( error ) {
        var name, message,
@@ -1670,7 +1649,7 @@ function errorString( error ) {
 
 // Test for equality any JavaScript type.
 // Author: Philippe Rathé <prathe@gmail.com>
-QUnit.equiv = (function() {
+QUnit.equiv = ( function() {
 
        // Stack to decide between skip/abort functions
        var callers = [];
@@ -1766,7 +1745,8 @@ QUnit.equiv = (function() {
 
                        len = a.length;
                        if ( len !== b.length ) {
-                               // safe and faster
+
+                               // Safe and faster
                                return false;
                        }
 
@@ -1800,33 +1780,53 @@ QUnit.equiv = (function() {
                },
 
                "set": function( b, a ) {
-                       var aArray, bArray;
-
-                       aArray = [];
-                       a.forEach( function( v ) {
-                               aArray.push( v );
-                       });
-                       bArray = [];
-                       b.forEach( function( v ) {
-                               bArray.push( v );
-                       });
-
-                       return innerEquiv( bArray, aArray );
+                       var innerEq,
+                               outerEq = true;
+
+                       if ( a.size !== b.size ) {
+                               return false;
+                       }
+
+                       a.forEach( function( aVal ) {
+                               innerEq = false;
+
+                               b.forEach( function( bVal ) {
+                                       if ( innerEquiv( bVal, aVal ) ) {
+                                               innerEq = true;
+                                       }
+                               } );
+
+                               if ( !innerEq ) {
+                                       outerEq = false;
+                               }
+                       } );
+
+                       return outerEq;
                },
 
                "map": function( b, a ) {
-                       var aArray, bArray;
-
-                       aArray = [];
-                       a.forEach( function( v, k ) {
-                               aArray.push( [ k, v ] );
-                       });
-                       bArray = [];
-                       b.forEach( function( v, k ) {
-                               bArray.push( [ k, v ] );
-                       });
-
-                       return innerEquiv( bArray, aArray );
+                       var innerEq,
+                               outerEq = true;
+
+                       if ( a.size !== b.size ) {
+                               return false;
+                       }
+
+                       a.forEach( function( aVal, aKey ) {
+                               innerEq = false;
+
+                               b.forEach( function( bVal, bKey ) {
+                                       if ( innerEquiv( [ bVal, bKey ], [ aVal, aKey ] ) ) {
+                                               innerEq = true;
+                                       }
+                               } );
+
+                               if ( !innerEq ) {
+                                       outerEq = false;
+                               }
+                       } );
+
+                       return outerEq;
                },
 
                "object": function( b, a ) {
@@ -1908,11 +1908,11 @@ QUnit.equiv = (function() {
        }
 
        return innerEquiv;
-}());
+}() );
 
 // Based on jsDump by Ariel Flesler
 // http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html
-QUnit.dump = (function() {
+QUnit.dump = ( function() {
        function quote( str ) {
                return "\"" + str.toString().replace( /\\/g, "\\\\" ).replace( /"/g, "\\\"" ) + "\"";
        }
@@ -1950,7 +1950,7 @@ QUnit.dump = (function() {
        var reName = /^function (\w+)/,
                dump = {
 
-                       // objType is used mostly internally, you can fix a (custom) type in advance
+                       // The objType is used mostly internally, you can fix a (custom) type in advance
                        parse: function( obj, objType, stack ) {
                                stack = stack || [];
                                var res, parser, parserType,
@@ -1994,7 +1994,7 @@ QUnit.dump = (function() {
                                        type = "node";
                                } else if (
 
-                                       // native arrays
+                                       // Native arrays
                                        toString.call( obj ) === "[object Array]" ||
 
                                        // NodeList objects
@@ -2010,10 +2010,12 @@ QUnit.dump = (function() {
                                }
                                return type;
                        },
+
                        separator: function() {
                                return this.multiline ? this.HTML ? "<br />" : "\n" : this.HTML ? "&#160;" : " ";
                        },
-                       // extra can be a number, shortcut for increasing-calling-decreasing
+
+                       // Extra can be a number, shortcut for increasing-calling-decreasing
                        indent: function( extra ) {
                                if ( !this.multiline ) {
                                        return "";
@@ -2033,11 +2035,11 @@ QUnit.dump = (function() {
                        setParser: function( name, parser ) {
                                this.parsers[ name ] = parser;
                        },
+
                        // The next 3 are exposed so you can use them
                        quote: quote,
                        literal: literal,
                        join: join,
-                       //
                        depth: 1,
                        maxDepth: QUnit.config.maxDepth,
 
@@ -2054,13 +2056,13 @@ QUnit.dump = (function() {
                                "function": function( fn ) {
                                        var ret = "function",
 
-                                               // functions never have name in IE
+                                               // Functions never have name in IE
                                                name = "name" in fn ? fn.name : ( reName.exec( fn ) || [] )[ 1 ];
 
                                        if ( name ) {
                                                ret += " " + name;
                                        }
-                                       ret += "( ";
+                                       ret += "(";
 
                                        ret = [ ret, dump.parse( fn, "functionArgs" ), "){" ].join( "" );
                                        return join( ret, dump.parse( fn, "functionCode" ), "}" );
@@ -2131,7 +2133,7 @@ QUnit.dump = (function() {
                                        return ret + open + "/" + tag + close;
                                },
 
-                               // function calls it internally, it's the arguments part of the function
+                               // Function calls it internally, it's the arguments part of the function
                                functionArgs: function( fn ) {
                                        var args,
                                                l = fn.length;
@@ -2148,11 +2150,14 @@ QUnit.dump = (function() {
                                        }
                                        return " " + args.join( ", " ) + " ";
                                },
-                               // object calls it internally, the key part of an item in a map
+
+                               // Object calls it internally, the key part of an item in a map
                                key: quote,
-                               // function calls it internally, it's the content of the function
+
+                               // Function calls it internally, it's the content of the function
                                functionCode: "[code]",
-                               // node calls it internally, it's a html attribute value
+
+                               // Node calls it internally, it's a html attribute value
                                attribute: quote,
                                string: quote,
                                date: quote,
@@ -2160,23 +2165,26 @@ QUnit.dump = (function() {
                                number: literal,
                                "boolean": literal
                        },
-                       // if true, entities are escaped ( <, >, \t, space and \n )
+
+                       // If true, entities are escaped ( <, >, \t, space and \n )
                        HTML: false,
-                       // indentation unit
+
+                       // Indentation unit
                        indentChar: "  ",
-                       // if true, items in a collection, are separated by a \n, else just a space.
+
+                       // If true, items in a collection, are separated by a \n, else just a space.
                        multiline: true
                };
 
        return dump;
-}());
+}() );
 
-// back compat
+// Back compat
 QUnit.jsDump = QUnit.dump;
 
 // Deprecated
 // Extend assert methods to QUnit for Backwards compatibility
-(function() {
+( function() {
        var i,
                assertions = Assert.prototype;
 
@@ -2190,12 +2198,12 @@ QUnit.jsDump = QUnit.dump;
        for ( i in assertions ) {
                QUnit[ i ] = applyCurrent( assertions[ i ] );
        }
-})();
+}() );
 
 // For browser, export only select globals
 if ( defined.document ) {
 
-       (function() {
+       ( function() {
                var i, l,
                        keys = [
                                "test",
@@ -2221,7 +2229,7 @@ if ( defined.document ) {
                for ( i = 0, l = keys.length; i < l; i++ ) {
                        window[ keys[ i ] ] = QUnit[ keys[ i ] ];
                }
-       })();
+       }() );
 
        window.QUnit = QUnit;
 }
@@ -2246,1959 +2254,2081 @@ if ( typeof define === "function" && define.amd ) {
        QUnit.config.autostart = false;
 }
 
-/*
- * This file is a modified version of google-diff-match-patch's JavaScript implementation
- * (https://code.google.com/p/google-diff-match-patch/source/browse/trunk/javascript/diff_match_patch_uncompressed.js),
- * modifications are licensed as more fully set forth in LICENSE.txt.
- *
- * The original source of google-diff-match-patch is attributable and licensed as follows:
- *
- * Copyright 2006 Google Inc.
- * https://code.google.com/p/google-diff-match-patch/
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * More Info:
- *  https://code.google.com/p/google-diff-match-patch/
- *
- * Usage: QUnit.diff(expected, actual)
- *
- */
-QUnit.diff = ( function() {
-       function DiffMatchPatch() {
-       }
+// Get a reference to the global object, like window in browsers
+}( ( function() {
+       return this;
+}() ) ) );
 
-       //  DIFF FUNCTIONS
+( function() {
 
-       /**
-        * The data structure representing a diff is an array of tuples:
-        * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
-        * which means: delete 'Hello', add 'Goodbye' and keep ' world.'
-        */
-       var DIFF_DELETE = -1,
-               DIFF_INSERT = 1,
-               DIFF_EQUAL = 0;
+// Only interact with URLs via window.location
+var location = typeof window !== "undefined" && window.location;
+if ( !location ) {
+       return;
+}
 
-       /**
-        * Find the differences between two texts.  Simplifies the problem by stripping
-        * any common prefix or suffix off the texts before diffing.
-        * @param {string} text1 Old string to be diffed.
-        * @param {string} text2 New string to be diffed.
-        * @param {boolean=} optChecklines Optional speedup flag. If present and false,
-        *     then don't run a line-level diff first to identify the changed areas.
-        *     Defaults to true, which does a faster, slightly less optimal diff.
-        * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
-        */
-       DiffMatchPatch.prototype.DiffMain = function( text1, text2, optChecklines ) {
-               var deadline, checklines, commonlength,
-                       commonprefix, commonsuffix, diffs;
+var urlParams = getUrlParams();
 
-               // The diff must be complete in up to 1 second.
-               deadline = ( new Date() ).getTime() + 1000;
+QUnit.urlParams = urlParams;
 
-               // Check for null inputs.
-               if ( text1 === null || text2 === null ) {
-                       throw new Error( "Null input. (DiffMain)" );
-               }
+// Match module/test by inclusion in an array
+QUnit.config.moduleId = [].concat( urlParams.moduleId || [] );
+QUnit.config.testId = [].concat( urlParams.testId || [] );
 
-               // Check for equality (speedup).
-               if ( text1 === text2 ) {
-                       if ( text1 ) {
-                               return [
-                                       [ DIFF_EQUAL, text1 ]
-                               ];
-                       }
-                       return [];
-               }
+// Exact case-insensitive match of the module name
+QUnit.config.module = urlParams.module;
 
-               if ( typeof optChecklines === "undefined" ) {
-                       optChecklines = true;
-               }
+// Regular expression or case-insenstive substring match against "moduleName: testName"
+QUnit.config.filter = urlParams.filter;
 
-               checklines = optChecklines;
+// Test order randomization
+if ( urlParams.seed === true ) {
 
-               // Trim off common prefix (speedup).
-               commonlength = this.diffCommonPrefix( text1, text2 );
-               commonprefix = text1.substring( 0, commonlength );
-               text1 = text1.substring( commonlength );
-               text2 = text2.substring( commonlength );
+       // Generate a random seed if the option is specified without a value
+       QUnit.config.seed = Math.random().toString( 36 ).slice( 2 );
+} else if ( urlParams.seed ) {
+       QUnit.config.seed = urlParams.seed;
+}
 
-               // Trim off common suffix (speedup).
-               commonlength = this.diffCommonSuffix( text1, text2 );
-               commonsuffix = text1.substring( text1.length - commonlength );
-               text1 = text1.substring( 0, text1.length - commonlength );
-               text2 = text2.substring( 0, text2.length - commonlength );
+// Add URL-parameter-mapped config values with UI form rendering data
+QUnit.config.urlConfig.push(
+       {
+               id: "hidepassed",
+               label: "Hide passed tests",
+               tooltip: "Only show tests and assertions that fail. Stored as query-strings."
+       },
+       {
+               id: "noglobals",
+               label: "Check for Globals",
+               tooltip: "Enabling this will test if any test introduces new properties on the " +
+                       "global object (`window` in Browsers). Stored as query-strings."
+       },
+       {
+               id: "notrycatch",
+               label: "No try-catch",
+               tooltip: "Enabling this will run tests outside of a try-catch block. Makes debugging " +
+                       "exceptions in IE reasonable. Stored as query-strings."
+       }
+);
 
-               // Compute the diff on the middle block.
-               diffs = this.diffCompute( text1, text2, checklines, deadline );
+QUnit.begin( function() {
+       var i, option,
+               urlConfig = QUnit.config.urlConfig;
 
-               // Restore the prefix and suffix.
-               if ( commonprefix ) {
-                       diffs.unshift( [ DIFF_EQUAL, commonprefix ] );
-               }
-               if ( commonsuffix ) {
-                       diffs.push( [ DIFF_EQUAL, commonsuffix ] );
-               }
-               this.diffCleanupMerge( diffs );
-               return diffs;
-       };
+       for ( i = 0; i < urlConfig.length; i++ ) {
 
-       /**
-        * Reduce the number of edits by eliminating operationally trivial equalities.
-        * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
-        */
-       DiffMatchPatch.prototype.diffCleanupEfficiency = function( diffs ) {
-               var changes, equalities, equalitiesLength, lastequality,
-                       pointer, preIns, preDel, postIns, postDel;
-               changes = false;
-               equalities = []; // Stack of indices where equalities are found.
-               equalitiesLength = 0; // Keeping our own length var is faster in JS.
-               /** @type {?string} */
-               lastequality = null;
-               // Always equal to diffs[equalities[equalitiesLength - 1]][1]
-               pointer = 0; // Index of current position.
-               // Is there an insertion operation before the last equality.
-               preIns = false;
-               // Is there a deletion operation before the last equality.
-               preDel = false;
-               // Is there an insertion operation after the last equality.
-               postIns = false;
-               // Is there a deletion operation after the last equality.
-               postDel = false;
-               while ( pointer < diffs.length ) {
+               // Options can be either strings or objects with nonempty "id" properties
+               option = QUnit.config.urlConfig[ i ];
+               if ( typeof option !== "string" ) {
+                       option = option.id;
+               }
 
-                       // Equality found.
-                       if ( diffs[ pointer ][ 0 ] === DIFF_EQUAL ) {
-                               if ( diffs[ pointer ][ 1 ].length < 4 && ( postIns || postDel ) ) {
+               if ( QUnit.config[ option ] === undefined ) {
+                       QUnit.config[ option ] = urlParams[ option ];
+               }
+       }
+} );
 
-                                       // Candidate found.
-                                       equalities[ equalitiesLength++ ] = pointer;
-                                       preIns = postIns;
-                                       preDel = postDel;
-                                       lastequality = diffs[ pointer ][ 1 ];
-                               } else {
+function getUrlParams() {
+       var i, param, name, value;
+       var urlParams = {};
+       var params = location.search.slice( 1 ).split( "&" );
+       var length = params.length;
 
-                                       // Not a candidate, and can never become one.
-                                       equalitiesLength = 0;
-                                       lastequality = null;
-                               }
-                               postIns = postDel = false;
+       for ( i = 0; i < length; i++ ) {
+               if ( params[ i ] ) {
+                       param = params[ i ].split( "=" );
+                       name = decodeURIComponent( param[ 0 ] );
 
-                       // An insertion or deletion.
+                       // Allow just a key to turn on a flag, e.g., test.html?noglobals
+                       value = param.length === 1 ||
+                               decodeURIComponent( param.slice( 1 ).join( "=" ) ) ;
+                       if ( urlParams[ name ] ) {
+                               urlParams[ name ] = [].concat( urlParams[ name ], value );
                        } else {
+                               urlParams[ name ] = value;
+                       }
+               }
+       }
 
-                               if ( diffs[ pointer ][ 0 ] === DIFF_DELETE ) {
-                                       postDel = true;
-                               } else {
-                                       postIns = true;
-                               }
+       return urlParams;
+}
 
-                               /*
-                                * Five types to be split:
-                                * <ins>A</ins><del>B</del>XY<ins>C</ins><del>D</del>
-                                * <ins>A</ins>X<ins>C</ins><del>D</del>
-                                * <ins>A</ins><del>B</del>X<ins>C</ins>
-                                * <ins>A</del>X<ins>C</ins><del>D</del>
-                                * <ins>A</ins><del>B</del>X<del>C</del>
-                                */
-                               if ( lastequality && ( ( preIns && preDel && postIns && postDel ) ||
-                                               ( ( lastequality.length < 2 ) &&
-                                               ( preIns + preDel + postIns + postDel ) === 3 ) ) ) {
+// Don't load the HTML Reporter on non-browser environments
+if ( typeof window === "undefined" || !window.document ) {
+       return;
+}
 
-                                       // Duplicate record.
-                                       diffs.splice(
-                                               equalities[ equalitiesLength - 1 ],
-                                               0,
-                                               [ DIFF_DELETE, lastequality ]
-                                       );
+// Deprecated QUnit.init - Ref #530
+// Re-initialize the configuration options
+QUnit.init = function() {
+       var config = QUnit.config;
 
-                                       // Change second copy to insert.
-                                       diffs[ equalities[ equalitiesLength - 1 ] + 1 ][ 0 ] = DIFF_INSERT;
-                                       equalitiesLength--; // Throw away the equality we just deleted;
-                                       lastequality = null;
-                                       if ( preIns && preDel ) {
-                                               // No changes made which could affect previous entry, keep going.
-                                               postIns = postDel = true;
-                                               equalitiesLength = 0;
-                                       } else {
-                                               equalitiesLength--; // Throw away the previous equality.
-                                               pointer = equalitiesLength > 0 ? equalities[ equalitiesLength - 1 ] : -1;
-                                               postIns = postDel = false;
-                                       }
-                                       changes = true;
-                               }
-                       }
-                       pointer++;
-               }
+       config.stats = { all: 0, bad: 0 };
+       config.moduleStats = { all: 0, bad: 0 };
+       config.started = 0;
+       config.updateRate = 1000;
+       config.blocking = false;
+       config.autostart = true;
+       config.autorun = false;
+       config.filter = "";
+       config.queue = [];
 
-               if ( changes ) {
-                       this.diffCleanupMerge( diffs );
-               }
-       };
+       appendInterface();
+};
 
-       /**
-        * Convert a diff array into a pretty HTML report.
-        * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
-        * @param {integer} string to be beautified.
-        * @return {string} HTML representation.
-        */
-       DiffMatchPatch.prototype.diffPrettyHtml = function( diffs ) {
-               var op, data, x,
-                       html = [];
-               for ( x = 0; x < diffs.length; x++ ) {
-                       op = diffs[ x ][ 0 ]; // Operation (insert, delete, equal)
-                       data = diffs[ x ][ 1 ]; // Text of change.
-                       switch ( op ) {
-                       case DIFF_INSERT:
-                               html[ x ] = "<ins>" + data + "</ins>";
-                               break;
-                       case DIFF_DELETE:
-                               html[ x ] = "<del>" + data + "</del>";
-                               break;
-                       case DIFF_EQUAL:
-                               html[ x ] = "<span>" + data + "</span>";
-                               break;
+var config = QUnit.config,
+       document = window.document,
+       collapseNext = false,
+       hasOwn = Object.prototype.hasOwnProperty,
+       unfilteredUrl = setUrl( { filter: undefined, module: undefined,
+               moduleId: undefined, testId: undefined } ),
+       defined = {
+               sessionStorage: ( function() {
+                       var x = "qunit-test-string";
+                       try {
+                               sessionStorage.setItem( x, x );
+                               sessionStorage.removeItem( x );
+                               return true;
+                       } catch ( e ) {
+                               return false;
                        }
-               }
-               return html.join( "" );
-       };
+               }() )
+       },
+       modulesList = [];
 
-       /**
-        * Determine the common prefix of two strings.
-        * @param {string} text1 First string.
-        * @param {string} text2 Second string.
-        * @return {number} The number of characters common to the start of each
-        *     string.
-        */
-       DiffMatchPatch.prototype.diffCommonPrefix = function( text1, text2 ) {
-               var pointermid, pointermax, pointermin, pointerstart;
-               // Quick check for common null cases.
-               if ( !text1 || !text2 || text1.charAt( 0 ) !== text2.charAt( 0 ) ) {
-                       return 0;
-               }
-               // Binary search.
-               // Performance analysis: https://neil.fraser.name/news/2007/10/09/
-               pointermin = 0;
-               pointermax = Math.min( text1.length, text2.length );
-               pointermid = pointermax;
-               pointerstart = 0;
-               while ( pointermin < pointermid ) {
-                       if ( text1.substring( pointerstart, pointermid ) ===
-                                       text2.substring( pointerstart, pointermid ) ) {
-                               pointermin = pointermid;
-                               pointerstart = pointermin;
-                       } else {
-                               pointermax = pointermid;
-                       }
-                       pointermid = Math.floor( ( pointermax - pointermin ) / 2 + pointermin );
-               }
-               return pointermid;
-       };
+/**
+* Escape text for attribute or text content.
+*/
+function escapeText( s ) {
+       if ( !s ) {
+               return "";
+       }
+       s = s + "";
 
-       /**
-        * Determine the common suffix of two strings.
-        * @param {string} text1 First string.
-        * @param {string} text2 Second string.
-        * @return {number} The number of characters common to the end of each string.
-        */
-       DiffMatchPatch.prototype.diffCommonSuffix = function( text1, text2 ) {
-               var pointermid, pointermax, pointermin, pointerend;
-               // Quick check for common null cases.
-               if ( !text1 ||
-                               !text2 ||
-                               text1.charAt( text1.length - 1 ) !== text2.charAt( text2.length - 1 ) ) {
-                       return 0;
-               }
-               // Binary search.
-               // Performance analysis: https://neil.fraser.name/news/2007/10/09/
-               pointermin = 0;
-               pointermax = Math.min( text1.length, text2.length );
-               pointermid = pointermax;
-               pointerend = 0;
-               while ( pointermin < pointermid ) {
-                       if ( text1.substring( text1.length - pointermid, text1.length - pointerend ) ===
-                                       text2.substring( text2.length - pointermid, text2.length - pointerend ) ) {
-                               pointermin = pointermid;
-                               pointerend = pointermin;
-                       } else {
-                               pointermax = pointermid;
-                       }
-                       pointermid = Math.floor( ( pointermax - pointermin ) / 2 + pointermin );
+       // Both single quotes and double quotes (for attributes)
+       return s.replace( /['"<>&]/g, function( s ) {
+               switch ( s ) {
+               case "'":
+                       return "&#039;";
+               case "\"":
+                       return "&quot;";
+               case "<":
+                       return "&lt;";
+               case ">":
+                       return "&gt;";
+               case "&":
+                       return "&amp;";
                }
-               return pointermid;
-       };
-
-       /**
-        * Find the differences between two texts.  Assumes that the texts do not
-        * have any common prefix or suffix.
-        * @param {string} text1 Old string to be diffed.
-        * @param {string} text2 New string to be diffed.
-        * @param {boolean} checklines Speedup flag.  If false, then don't run a
-        *     line-level diff first to identify the changed areas.
-        *     If true, then run a faster, slightly less optimal diff.
-        * @param {number} deadline Time when the diff should be complete by.
-        * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
-        * @private
-        */
-       DiffMatchPatch.prototype.diffCompute = function( text1, text2, checklines, deadline ) {
-               var diffs, longtext, shorttext, i, hm,
-                       text1A, text2A, text1B, text2B,
-                       midCommon, diffsA, diffsB;
+       } );
+}
 
-               if ( !text1 ) {
-                       // Just add some text (speedup).
-                       return [
-                               [ DIFF_INSERT, text2 ]
-                       ];
-               }
+/**
+ * @param {HTMLElement} elem
+ * @param {string} type
+ * @param {Function} fn
+ */
+function addEvent( elem, type, fn ) {
+       if ( elem.addEventListener ) {
 
-               if ( !text2 ) {
-                       // Just delete some text (speedup).
-                       return [
-                               [ DIFF_DELETE, text1 ]
-                       ];
-               }
+               // Standards-based browsers
+               elem.addEventListener( type, fn, false );
+       } else if ( elem.attachEvent ) {
 
-               longtext = text1.length > text2.length ? text1 : text2;
-               shorttext = text1.length > text2.length ? text2 : text1;
-               i = longtext.indexOf( shorttext );
-               if ( i !== -1 ) {
-                       // Shorter text is inside the longer text (speedup).
-                       diffs = [
-                               [ DIFF_INSERT, longtext.substring( 0, i ) ],
-                               [ DIFF_EQUAL, shorttext ],
-                               [ DIFF_INSERT, longtext.substring( i + shorttext.length ) ]
-                       ];
-                       // Swap insertions for deletions if diff is reversed.
-                       if ( text1.length > text2.length ) {
-                               diffs[ 0 ][ 0 ] = diffs[ 2 ][ 0 ] = DIFF_DELETE;
+               // Support: IE <9
+               elem.attachEvent( "on" + type, function() {
+                       var event = window.event;
+                       if ( !event.target ) {
+                               event.target = event.srcElement || document;
                        }
-                       return diffs;
-               }
 
-               if ( shorttext.length === 1 ) {
-                       // Single character string.
-                       // After the previous speedup, the character can't be an equality.
-                       return [
-                               [ DIFF_DELETE, text1 ],
-                               [ DIFF_INSERT, text2 ]
-                       ];
-               }
+                       fn.call( elem, event );
+               } );
+       }
+}
 
-               // Check to see if the problem can be split in two.
-               hm = this.diffHalfMatch( text1, text2 );
-               if ( hm ) {
-                       // A half-match was found, sort out the return data.
-                       text1A = hm[ 0 ];
-                       text1B = hm[ 1 ];
-                       text2A = hm[ 2 ];
-                       text2B = hm[ 3 ];
-                       midCommon = hm[ 4 ];
-                       // Send both pairs off for separate processing.
-                       diffsA = this.DiffMain( text1A, text2A, checklines, deadline );
-                       diffsB = this.DiffMain( text1B, text2B, checklines, deadline );
-                       // Merge the results.
-                       return diffsA.concat( [
-                               [ DIFF_EQUAL, midCommon ]
-                       ], diffsB );
-               }
+/**
+ * @param {Array|NodeList} elems
+ * @param {string} type
+ * @param {Function} fn
+ */
+function addEvents( elems, type, fn ) {
+       var i = elems.length;
+       while ( i-- ) {
+               addEvent( elems[ i ], type, fn );
+       }
+}
 
-               if ( checklines && text1.length > 100 && text2.length > 100 ) {
-                       return this.diffLineMode( text1, text2, deadline );
-               }
+function hasClass( elem, name ) {
+       return ( " " + elem.className + " " ).indexOf( " " + name + " " ) >= 0;
+}
 
-               return this.diffBisect( text1, text2, deadline );
-       };
+function addClass( elem, name ) {
+       if ( !hasClass( elem, name ) ) {
+               elem.className += ( elem.className ? " " : "" ) + name;
+       }
+}
 
-       /**
-        * Do the two texts share a substring which is at least half the length of the
-        * longer text?
-        * This speedup can produce non-minimal diffs.
-        * @param {string} text1 First string.
-        * @param {string} text2 Second string.
-        * @return {Array.<string>} Five element Array, containing the prefix of
-        *     text1, the suffix of text1, the prefix of text2, the suffix of
-        *     text2 and the common middle.  Or null if there was no match.
-        * @private
-        */
-       DiffMatchPatch.prototype.diffHalfMatch = function( text1, text2 ) {
-               var longtext, shorttext, dmp,
-                       text1A, text2B, text2A, text1B, midCommon,
-                       hm1, hm2, hm;
+function toggleClass( elem, name, force ) {
+       if ( force || typeof force === "undefined" && !hasClass( elem, name ) ) {
+               addClass( elem, name );
+       } else {
+               removeClass( elem, name );
+       }
+}
 
-               longtext = text1.length > text2.length ? text1 : text2;
-               shorttext = text1.length > text2.length ? text2 : text1;
-               if ( longtext.length < 4 || shorttext.length * 2 < longtext.length ) {
-                       return null; // Pointless.
+function removeClass( elem, name ) {
+       var set = " " + elem.className + " ";
+
+       // Class name may appear multiple times
+       while ( set.indexOf( " " + name + " " ) >= 0 ) {
+               set = set.replace( " " + name + " ", " " );
+       }
+
+       // Trim for prettiness
+       elem.className = typeof set.trim === "function" ? set.trim() : set.replace( /^\s+|\s+$/g, "" );
+}
+
+function id( name ) {
+       return document.getElementById && document.getElementById( name );
+}
+
+function getUrlConfigHtml() {
+       var i, j, val,
+               escaped, escapedTooltip,
+               selection = false,
+               urlConfig = config.urlConfig,
+               urlConfigHtml = "";
+
+       for ( i = 0; i < urlConfig.length; i++ ) {
+
+               // Options can be either strings or objects with nonempty "id" properties
+               val = config.urlConfig[ i ];
+               if ( typeof val === "string" ) {
+                       val = {
+                               id: val,
+                               label: val
+                       };
                }
-               dmp = this; // 'this' becomes 'window' in a closure.
 
-               /**
-                * Does a substring of shorttext exist within longtext such that the substring
-                * is at least half the length of longtext?
-                * Closure, but does not reference any external variables.
-                * @param {string} longtext Longer string.
-                * @param {string} shorttext Shorter string.
-                * @param {number} i Start index of quarter length substring within longtext.
-                * @return {Array.<string>} Five element Array, containing the prefix of
-                *     longtext, the suffix of longtext, the prefix of shorttext, the suffix
-                *     of shorttext and the common middle.  Or null if there was no match.
-                * @private
-                */
-               function diffHalfMatchI( longtext, shorttext, i ) {
-                       var seed, j, bestCommon, prefixLength, suffixLength,
-                               bestLongtextA, bestLongtextB, bestShorttextA, bestShorttextB;
-                       // Start with a 1/4 length substring at position i as a seed.
-                       seed = longtext.substring( i, i + Math.floor( longtext.length / 4 ) );
-                       j = -1;
-                       bestCommon = "";
-                       while ( ( j = shorttext.indexOf( seed, j + 1 ) ) !== -1 ) {
-                               prefixLength = dmp.diffCommonPrefix( longtext.substring( i ),
-                                       shorttext.substring( j ) );
-                               suffixLength = dmp.diffCommonSuffix( longtext.substring( 0, i ),
-                                       shorttext.substring( 0, j ) );
-                               if ( bestCommon.length < suffixLength + prefixLength ) {
-                                       bestCommon = shorttext.substring( j - suffixLength, j ) +
-                                               shorttext.substring( j, j + prefixLength );
-                                       bestLongtextA = longtext.substring( 0, i - suffixLength );
-                                       bestLongtextB = longtext.substring( i + prefixLength );
-                                       bestShorttextA = shorttext.substring( 0, j - suffixLength );
-                                       bestShorttextB = shorttext.substring( j + prefixLength );
+               escaped = escapeText( val.id );
+               escapedTooltip = escapeText( val.tooltip );
+
+               if ( !val.value || typeof val.value === "string" ) {
+                       urlConfigHtml += "<input id='qunit-urlconfig-" + escaped +
+                               "' name='" + escaped + "' type='checkbox'" +
+                               ( val.value ? " value='" + escapeText( val.value ) + "'" : "" ) +
+                               ( config[ val.id ] ? " checked='checked'" : "" ) +
+                               " title='" + escapedTooltip + "' /><label for='qunit-urlconfig-" + escaped +
+                               "' title='" + escapedTooltip + "'>" + val.label + "</label>";
+               } else {
+                       urlConfigHtml += "<label for='qunit-urlconfig-" + escaped +
+                               "' title='" + escapedTooltip + "'>" + val.label +
+                               ": </label><select id='qunit-urlconfig-" + escaped +
+                               "' name='" + escaped + "' title='" + escapedTooltip + "'><option></option>";
+
+                       if ( QUnit.is( "array", val.value ) ) {
+                               for ( j = 0; j < val.value.length; j++ ) {
+                                       escaped = escapeText( val.value[ j ] );
+                                       urlConfigHtml += "<option value='" + escaped + "'" +
+                                               ( config[ val.id ] === val.value[ j ] ?
+                                                       ( selection = true ) && " selected='selected'" : "" ) +
+                                               ">" + escaped + "</option>";
                                }
-                       }
-                       if ( bestCommon.length * 2 >= longtext.length ) {
-                               return [ bestLongtextA, bestLongtextB,
-                                       bestShorttextA, bestShorttextB, bestCommon
-                               ];
                        } else {
-                               return null;
+                               for ( j in val.value ) {
+                                       if ( hasOwn.call( val.value, j ) ) {
+                                               urlConfigHtml += "<option value='" + escapeText( j ) + "'" +
+                                                       ( config[ val.id ] === j ?
+                                                               ( selection = true ) && " selected='selected'" : "" ) +
+                                                       ">" + escapeText( val.value[ j ] ) + "</option>";
+                                       }
+                               }
+                       }
+                       if ( config[ val.id ] && !selection ) {
+                               escaped = escapeText( config[ val.id ] );
+                               urlConfigHtml += "<option value='" + escaped +
+                                       "' selected='selected' disabled='disabled'>" + escaped + "</option>";
                        }
+                       urlConfigHtml += "</select>";
                }
+       }
 
-               // First check if the second quarter is the seed for a half-match.
-               hm1 = diffHalfMatchI( longtext, shorttext,
-                       Math.ceil( longtext.length / 4 ) );
-               // Check again based on the third quarter.
-               hm2 = diffHalfMatchI( longtext, shorttext,
-                       Math.ceil( longtext.length / 2 ) );
-               if ( !hm1 && !hm2 ) {
-                       return null;
-               } else if ( !hm2 ) {
-                       hm = hm1;
-               } else if ( !hm1 ) {
-                       hm = hm2;
-               } else {
-                       // Both matched.  Select the longest.
-                       hm = hm1[ 4 ].length > hm2[ 4 ].length ? hm1 : hm2;
-               }
+       return urlConfigHtml;
+}
 
-               // A half-match was found, sort out the return data.
-               text1A, text1B, text2A, text2B;
-               if ( text1.length > text2.length ) {
-                       text1A = hm[ 0 ];
-                       text1B = hm[ 1 ];
-                       text2A = hm[ 2 ];
-                       text2B = hm[ 3 ];
-               } else {
-                       text2A = hm[ 0 ];
-                       text2B = hm[ 1 ];
-                       text1A = hm[ 2 ];
-                       text1B = hm[ 3 ];
+// Handle "click" events on toolbar checkboxes and "change" for select menus.
+// Updates the URL with the new state of `config.urlConfig` values.
+function toolbarChanged() {
+       var updatedUrl, value, tests,
+               field = this,
+               params = {};
+
+       // Detect if field is a select menu or a checkbox
+       if ( "selectedIndex" in field ) {
+               value = field.options[ field.selectedIndex ].value || undefined;
+       } else {
+               value = field.checked ? ( field.defaultValue || true ) : undefined;
+       }
+
+       params[ field.name ] = value;
+       updatedUrl = setUrl( params );
+
+       // Check if we can apply the change without a page refresh
+       if ( "hidepassed" === field.name && "replaceState" in window.history ) {
+               QUnit.urlParams[ field.name ] = value;
+               config[ field.name ] = value || false;
+               tests = id( "qunit-tests" );
+               if ( tests ) {
+                       toggleClass( tests, "hidepass", value || false );
                }
-               midCommon = hm[ 4 ];
-               return [ text1A, text1B, text2A, text2B, midCommon ];
-       };
+               window.history.replaceState( null, "", updatedUrl );
+       } else {
+               window.location = updatedUrl;
+       }
+}
 
-       /**
-        * Do a quick line-level diff on both strings, then rediff the parts for
-        * greater accuracy.
-        * This speedup can produce non-minimal diffs.
-        * @param {string} text1 Old string to be diffed.
-        * @param {string} text2 New string to be diffed.
-        * @param {number} deadline Time when the diff should be complete by.
-        * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
-        * @private
-        */
-       DiffMatchPatch.prototype.diffLineMode = function( text1, text2, deadline ) {
-               var a, diffs, linearray, pointer, countInsert,
-                       countDelete, textInsert, textDelete, j;
-               // Scan the text on a line-by-line basis first.
-               a = this.diffLinesToChars( text1, text2 );
-               text1 = a.chars1;
-               text2 = a.chars2;
-               linearray = a.lineArray;
+function setUrl( params ) {
+       var key, arrValue, i,
+               querystring = "?",
+               location = window.location;
 
-               diffs = this.DiffMain( text1, text2, false, deadline );
+       params = QUnit.extend( QUnit.extend( {}, QUnit.urlParams ), params );
 
-               // Convert the diff back to original text.
-               this.diffCharsToLines( diffs, linearray );
-               // Eliminate freak matches (e.g. blank lines)
-               this.diffCleanupSemantic( diffs );
+       for ( key in params ) {
 
-               // Rediff any replacement blocks, this time character-by-character.
-               // Add a dummy entry at the end.
-               diffs.push( [ DIFF_EQUAL, "" ] );
-               pointer = 0;
-               countDelete = 0;
-               countInsert = 0;
-               textDelete = "";
-               textInsert = "";
-               while ( pointer < diffs.length ) {
-                       switch ( diffs[ pointer ][ 0 ] ) {
-                       case DIFF_INSERT:
-                               countInsert++;
-                               textInsert += diffs[ pointer ][ 1 ];
-                               break;
-                       case DIFF_DELETE:
-                               countDelete++;
-                               textDelete += diffs[ pointer ][ 1 ];
-                               break;
-                       case DIFF_EQUAL:
-                               // Upon reaching an equality, check for prior redundancies.
-                               if ( countDelete >= 1 && countInsert >= 1 ) {
-                                       // Delete the offending records and add the merged ones.
-                                       diffs.splice( pointer - countDelete - countInsert,
-                                               countDelete + countInsert );
-                                       pointer = pointer - countDelete - countInsert;
-                                       a = this.DiffMain( textDelete, textInsert, false, deadline );
-                                       for ( j = a.length - 1; j >= 0; j-- ) {
-                                               diffs.splice( pointer, 0, a[ j ] );
-                                       }
-                                       pointer = pointer + a.length;
+               // Skip inherited or undefined properties
+               if ( hasOwn.call( params, key ) && params[ key ] !== undefined ) {
+
+                       // Output a parameter for each value of this key (but usually just one)
+                       arrValue = [].concat( params[ key ] );
+                       for ( i = 0; i < arrValue.length; i++ ) {
+                               querystring += encodeURIComponent( key );
+                               if ( arrValue[ i ] !== true ) {
+                                       querystring += "=" + encodeURIComponent( arrValue[ i ] );
                                }
-                               countInsert = 0;
-                               countDelete = 0;
-                               textDelete = "";
-                               textInsert = "";
-                               break;
+                               querystring += "&";
                        }
-                       pointer++;
                }
-               diffs.pop(); // Remove the dummy entry at the end.
+       }
+       return location.protocol + "//" + location.host +
+               location.pathname + querystring.slice( 0, -1 );
+}
 
-               return diffs;
-       };
+function applyUrlParams() {
+       var selectedModule,
+               modulesList = id( "qunit-modulefilter" ),
+               filter = id( "qunit-filter-input" ).value;
 
-       /**
-        * Find the 'middle snake' of a diff, split the problem in two
-        * and return the recursively constructed diff.
-        * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
-        * @param {string} text1 Old string to be diffed.
-        * @param {string} text2 New string to be diffed.
-        * @param {number} deadline Time at which to bail if not yet complete.
-        * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
-        * @private
-        */
-       DiffMatchPatch.prototype.diffBisect = function( text1, text2, deadline ) {
-               var text1Length, text2Length, maxD, vOffset, vLength,
-                       v1, v2, x, delta, front, k1start, k1end, k2start,
-                       k2end, k2Offset, k1Offset, x1, x2, y1, y2, d, k1, k2;
-               // Cache the text lengths to prevent multiple calls.
-               text1Length = text1.length;
-               text2Length = text2.length;
-               maxD = Math.ceil( ( text1Length + text2Length ) / 2 );
-               vOffset = maxD;
-               vLength = 2 * maxD;
-               v1 = new Array( vLength );
-               v2 = new Array( vLength );
-               // Setting all elements to -1 is faster in Chrome & Firefox than mixing
-               // integers and undefined.
-               for ( x = 0; x < vLength; x++ ) {
-                       v1[ x ] = -1;
-                       v2[ x ] = -1;
+       selectedModule = modulesList ?
+               decodeURIComponent( modulesList.options[ modulesList.selectedIndex ].value ) :
+               undefined;
+
+       window.location = setUrl( {
+               module: ( selectedModule === "" ) ? undefined : selectedModule,
+               filter: ( filter === "" ) ? undefined : filter,
+
+               // Remove moduleId and testId filters
+               moduleId: undefined,
+               testId: undefined
+       } );
+}
+
+function toolbarUrlConfigContainer() {
+       var urlConfigContainer = document.createElement( "span" );
+
+       urlConfigContainer.innerHTML = getUrlConfigHtml();
+       addClass( urlConfigContainer, "qunit-url-config" );
+
+       // For oldIE support:
+       // * Add handlers to the individual elements instead of the container
+       // * Use "click" instead of "change" for checkboxes
+       addEvents( urlConfigContainer.getElementsByTagName( "input" ), "click", toolbarChanged );
+       addEvents( urlConfigContainer.getElementsByTagName( "select" ), "change", toolbarChanged );
+
+       return urlConfigContainer;
+}
+
+function toolbarLooseFilter() {
+       var filter = document.createElement( "form" ),
+               label = document.createElement( "label" ),
+               input = document.createElement( "input" ),
+               button = document.createElement( "button" );
+
+       addClass( filter, "qunit-filter" );
+
+       label.innerHTML = "Filter: ";
+
+       input.type = "text";
+       input.value = config.filter || "";
+       input.name = "filter";
+       input.id = "qunit-filter-input";
+
+       button.innerHTML = "Go";
+
+       label.appendChild( input );
+
+       filter.appendChild( label );
+       filter.appendChild( button );
+       addEvent( filter, "submit", function( ev ) {
+               applyUrlParams();
+
+               if ( ev && ev.preventDefault ) {
+                       ev.preventDefault();
                }
-               v1[ vOffset + 1 ] = 0;
-               v2[ vOffset + 1 ] = 0;
-               delta = text1Length - text2Length;
-               // If the total number of characters is odd, then the front path will collide
-               // with the reverse path.
-               front = ( delta % 2 !== 0 );
-               // Offsets for start and end of k loop.
-               // Prevents mapping of space beyond the grid.
-               k1start = 0;
-               k1end = 0;
-               k2start = 0;
-               k2end = 0;
-               for ( d = 0; d < maxD; d++ ) {
-                       // Bail out if deadline is reached.
-                       if ( ( new Date() ).getTime() > deadline ) {
-                               break;
-                       }
 
-                       // Walk the front path one step.
-                       for ( k1 = -d + k1start; k1 <= d - k1end; k1 += 2 ) {
-                               k1Offset = vOffset + k1;
-                               if ( k1 === -d || ( k1 !== d && v1[ k1Offset - 1 ] < v1[ k1Offset + 1 ] ) ) {
-                                       x1 = v1[ k1Offset + 1 ];
-                               } else {
-                                       x1 = v1[ k1Offset - 1 ] + 1;
-                               }
-                               y1 = x1 - k1;
-                               while ( x1 < text1Length && y1 < text2Length &&
-                                       text1.charAt( x1 ) === text2.charAt( y1 ) ) {
-                                       x1++;
-                                       y1++;
-                               }
-                               v1[ k1Offset ] = x1;
-                               if ( x1 > text1Length ) {
-                                       // Ran off the right of the graph.
-                                       k1end += 2;
-                               } else if ( y1 > text2Length ) {
-                                       // Ran off the bottom of the graph.
-                                       k1start += 2;
-                               } else if ( front ) {
-                                       k2Offset = vOffset + delta - k1;
-                                       if ( k2Offset >= 0 && k2Offset < vLength && v2[ k2Offset ] !== -1 ) {
-                                               // Mirror x2 onto top-left coordinate system.
-                                               x2 = text1Length - v2[ k2Offset ];
-                                               if ( x1 >= x2 ) {
-                                                       // Overlap detected.
-                                                       return this.diffBisectSplit( text1, text2, x1, y1, deadline );
-                                               }
-                                       }
-                               }
-                       }
+               return false;
+       } );
+
+       return filter;
+}
+
+function toolbarModuleFilterHtml() {
+       var i,
+               moduleFilterHtml = "";
+
+       if ( !modulesList.length ) {
+               return false;
+       }
+
+       moduleFilterHtml += "<label for='qunit-modulefilter'>Module: </label>" +
+               "<select id='qunit-modulefilter' name='modulefilter'><option value='' " +
+               ( QUnit.urlParams.module === undefined ? "selected='selected'" : "" ) +
+               ">< All Modules ></option>";
+
+       for ( i = 0; i < modulesList.length; i++ ) {
+               moduleFilterHtml += "<option value='" +
+                       escapeText( encodeURIComponent( modulesList[ i ] ) ) + "' " +
+                       ( QUnit.urlParams.module === modulesList[ i ] ? "selected='selected'" : "" ) +
+                       ">" + escapeText( modulesList[ i ] ) + "</option>";
+       }
+       moduleFilterHtml += "</select>";
+
+       return moduleFilterHtml;
+}
+
+function toolbarModuleFilter() {
+       var toolbar = id( "qunit-testrunner-toolbar" ),
+               moduleFilter = document.createElement( "span" ),
+               moduleFilterHtml = toolbarModuleFilterHtml();
+
+       if ( !toolbar || !moduleFilterHtml ) {
+               return false;
+       }
+
+       moduleFilter.setAttribute( "id", "qunit-modulefilter-container" );
+       moduleFilter.innerHTML = moduleFilterHtml;
+
+       addEvent( moduleFilter.lastChild, "change", applyUrlParams );
+
+       toolbar.appendChild( moduleFilter );
+}
+
+function appendToolbar() {
+       var toolbar = id( "qunit-testrunner-toolbar" );
+
+       if ( toolbar ) {
+               toolbar.appendChild( toolbarUrlConfigContainer() );
+               toolbar.appendChild( toolbarLooseFilter() );
+               toolbarModuleFilter();
+       }
+}
+
+function appendHeader() {
+       var header = id( "qunit-header" );
+
+       if ( header ) {
+               header.innerHTML = "<a href='" + escapeText( unfilteredUrl ) + "'>" + header.innerHTML +
+                       "</a> ";
+       }
+}
+
+function appendBanner() {
+       var banner = id( "qunit-banner" );
+
+       if ( banner ) {
+               banner.className = "";
+       }
+}
+
+function appendTestResults() {
+       var tests = id( "qunit-tests" ),
+               result = id( "qunit-testresult" );
+
+       if ( result ) {
+               result.parentNode.removeChild( result );
+       }
+
+       if ( tests ) {
+               tests.innerHTML = "";
+               result = document.createElement( "p" );
+               result.id = "qunit-testresult";
+               result.className = "result";
+               tests.parentNode.insertBefore( result, tests );
+               result.innerHTML = "Running...<br />&#160;";
+       }
+}
+
+function storeFixture() {
+       var fixture = id( "qunit-fixture" );
+       if ( fixture ) {
+               config.fixture = fixture.innerHTML;
+       }
+}
+
+function appendFilteredTest() {
+       var testId = QUnit.config.testId;
+       if ( !testId || testId.length <= 0 ) {
+               return "";
+       }
+       return "<div id='qunit-filteredTest'>Rerunning selected tests: " +
+               escapeText( testId.join( ", " ) ) +
+               " <a id='qunit-clearFilter' href='" +
+               escapeText( unfilteredUrl ) +
+               "'>Run all tests</a></div>";
+}
+
+function appendUserAgent() {
+       var userAgent = id( "qunit-userAgent" );
+
+       if ( userAgent ) {
+               userAgent.innerHTML = "";
+               userAgent.appendChild(
+                       document.createTextNode(
+                               "QUnit " + QUnit.version + "; " + navigator.userAgent
+                       )
+               );
+       }
+}
 
-                       // Walk the reverse path one step.
-                       for ( k2 = -d + k2start; k2 <= d - k2end; k2 += 2 ) {
-                               k2Offset = vOffset + k2;
-                               if ( k2 === -d || ( k2 !== d && v2[ k2Offset - 1 ] < v2[ k2Offset + 1 ] ) ) {
-                                       x2 = v2[ k2Offset + 1 ];
-                               } else {
-                                       x2 = v2[ k2Offset - 1 ] + 1;
-                               }
-                               y2 = x2 - k2;
-                               while ( x2 < text1Length && y2 < text2Length &&
-                                       text1.charAt( text1Length - x2 - 1 ) ===
-                                       text2.charAt( text2Length - y2 - 1 ) ) {
-                                       x2++;
-                                       y2++;
-                               }
-                               v2[ k2Offset ] = x2;
-                               if ( x2 > text1Length ) {
-                                       // Ran off the left of the graph.
-                                       k2end += 2;
-                               } else if ( y2 > text2Length ) {
-                                       // Ran off the top of the graph.
-                                       k2start += 2;
-                               } else if ( !front ) {
-                                       k1Offset = vOffset + delta - k2;
-                                       if ( k1Offset >= 0 && k1Offset < vLength && v1[ k1Offset ] !== -1 ) {
-                                               x1 = v1[ k1Offset ];
-                                               y1 = vOffset + x1 - k1Offset;
-                                               // Mirror x2 onto top-left coordinate system.
-                                               x2 = text1Length - x2;
-                                               if ( x1 >= x2 ) {
-                                                       // Overlap detected.
-                                                       return this.diffBisectSplit( text1, text2, x1, y1, deadline );
-                                               }
-                                       }
-                               }
-                       }
+function appendInterface() {
+       var qunit = id( "qunit" );
+
+       if ( qunit ) {
+               qunit.innerHTML =
+                       "<h1 id='qunit-header'>" + escapeText( document.title ) + "</h1>" +
+                       "<h2 id='qunit-banner'></h2>" +
+                       "<div id='qunit-testrunner-toolbar'></div>" +
+                       appendFilteredTest() +
+                       "<h2 id='qunit-userAgent'></h2>" +
+                       "<ol id='qunit-tests'></ol>";
+       }
+
+       appendHeader();
+       appendBanner();
+       appendTestResults();
+       appendUserAgent();
+       appendToolbar();
+}
+
+function appendTestsList( modules ) {
+       var i, l, x, z, test, moduleObj;
+
+       for ( i = 0, l = modules.length; i < l; i++ ) {
+               moduleObj = modules[ i ];
+
+               for ( x = 0, z = moduleObj.tests.length; x < z; x++ ) {
+                       test = moduleObj.tests[ x ];
+
+                       appendTest( test.name, test.testId, moduleObj.name );
                }
-               // Diff took too long and hit the deadline or
-               // number of diffs equals number of characters, no commonality at all.
-               return [
-                       [ DIFF_DELETE, text1 ],
-                       [ DIFF_INSERT, text2 ]
-               ];
-       };
+       }
+}
 
-       /**
-        * Given the location of the 'middle snake', split the diff in two parts
-        * and recurse.
-        * @param {string} text1 Old string to be diffed.
-        * @param {string} text2 New string to be diffed.
-        * @param {number} x Index of split point in text1.
-        * @param {number} y Index of split point in text2.
-        * @param {number} deadline Time at which to bail if not yet complete.
-        * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
-        * @private
-        */
-       DiffMatchPatch.prototype.diffBisectSplit = function( text1, text2, x, y, deadline ) {
-               var text1a, text1b, text2a, text2b, diffs, diffsb;
-               text1a = text1.substring( 0, x );
-               text2a = text2.substring( 0, y );
-               text1b = text1.substring( x );
-               text2b = text2.substring( y );
+function appendTest( name, testId, moduleName ) {
+       var title, rerunTrigger, testBlock, assertList,
+               tests = id( "qunit-tests" );
 
-               // Compute both diffs serially.
-               diffs = this.DiffMain( text1a, text2a, false, deadline );
-               diffsb = this.DiffMain( text1b, text2b, false, deadline );
+       if ( !tests ) {
+               return;
+       }
 
-               return diffs.concat( diffsb );
-       };
+       title = document.createElement( "strong" );
+       title.innerHTML = getNameHtml( name, moduleName );
 
-       /**
-        * Reduce the number of edits by eliminating semantically trivial equalities.
-        * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
-        */
-       DiffMatchPatch.prototype.diffCleanupSemantic = function( diffs ) {
-               var changes, equalities, equalitiesLength, lastequality,
-                       pointer, lengthInsertions2, lengthDeletions2, lengthInsertions1,
-                       lengthDeletions1, deletion, insertion, overlapLength1, overlapLength2;
-               changes = false;
-               equalities = []; // Stack of indices where equalities are found.
-               equalitiesLength = 0; // Keeping our own length var is faster in JS.
-               /** @type {?string} */
-               lastequality = null;
-               // Always equal to diffs[equalities[equalitiesLength - 1]][1]
-               pointer = 0; // Index of current position.
-               // Number of characters that changed prior to the equality.
-               lengthInsertions1 = 0;
-               lengthDeletions1 = 0;
-               // Number of characters that changed after the equality.
-               lengthInsertions2 = 0;
-               lengthDeletions2 = 0;
-               while ( pointer < diffs.length ) {
-                       if ( diffs[ pointer ][ 0 ] === DIFF_EQUAL ) { // Equality found.
-                               equalities[ equalitiesLength++ ] = pointer;
-                               lengthInsertions1 = lengthInsertions2;
-                               lengthDeletions1 = lengthDeletions2;
-                               lengthInsertions2 = 0;
-                               lengthDeletions2 = 0;
-                               lastequality = diffs[ pointer ][ 1 ];
-                       } else { // An insertion or deletion.
-                               if ( diffs[ pointer ][ 0 ] === DIFF_INSERT ) {
-                                       lengthInsertions2 += diffs[ pointer ][ 1 ].length;
-                               } else {
-                                       lengthDeletions2 += diffs[ pointer ][ 1 ].length;
-                               }
-                               // Eliminate an equality that is smaller or equal to the edits on both
-                               // sides of it.
-                               if ( lastequality && ( lastequality.length <=
-                                               Math.max( lengthInsertions1, lengthDeletions1 ) ) &&
-                                               ( lastequality.length <= Math.max( lengthInsertions2,
-                                                       lengthDeletions2 ) ) ) {
+       rerunTrigger = document.createElement( "a" );
+       rerunTrigger.innerHTML = "Rerun";
+       rerunTrigger.href = setUrl( { testId: testId } );
 
-                                       // Duplicate record.
-                                       diffs.splice(
-                                               equalities[ equalitiesLength - 1 ],
-                                               0,
-                                               [ DIFF_DELETE, lastequality ]
-                                       );
+       testBlock = document.createElement( "li" );
+       testBlock.appendChild( title );
+       testBlock.appendChild( rerunTrigger );
+       testBlock.id = "qunit-test-output-" + testId;
 
-                                       // Change second copy to insert.
-                                       diffs[ equalities[ equalitiesLength - 1 ] + 1 ][ 0 ] = DIFF_INSERT;
+       assertList = document.createElement( "ol" );
+       assertList.className = "qunit-assert-list";
 
-                                       // Throw away the equality we just deleted.
-                                       equalitiesLength--;
+       testBlock.appendChild( assertList );
 
-                                       // Throw away the previous equality (it needs to be reevaluated).
-                                       equalitiesLength--;
-                                       pointer = equalitiesLength > 0 ? equalities[ equalitiesLength - 1 ] : -1;
+       tests.appendChild( testBlock );
+}
 
-                                       // Reset the counters.
-                                       lengthInsertions1 = 0;
-                                       lengthDeletions1 = 0;
-                                       lengthInsertions2 = 0;
-                                       lengthDeletions2 = 0;
-                                       lastequality = null;
-                                       changes = true;
-                               }
-                       }
-                       pointer++;
-               }
+// HTML Reporter initialization and load
+QUnit.begin( function( details ) {
+       var i, moduleObj, tests;
 
-               // Normalize the diff.
-               if ( changes ) {
-                       this.diffCleanupMerge( diffs );
+       // Sort modules by name for the picker
+       for ( i = 0; i < details.modules.length; i++ ) {
+               moduleObj = details.modules[ i ];
+               if ( moduleObj.name ) {
+                       modulesList.push( moduleObj.name );
                }
+       }
+       modulesList.sort( function( a, b ) {
+               return a.localeCompare( b );
+       } );
 
-               // Find any overlaps between deletions and insertions.
-               // e.g: <del>abcxxx</del><ins>xxxdef</ins>
-               //   -> <del>abc</del>xxx<ins>def</ins>
-               // e.g: <del>xxxabc</del><ins>defxxx</ins>
-               //   -> <ins>def</ins>xxx<del>abc</del>
-               // Only extract an overlap if it is as big as the edit ahead or behind it.
-               pointer = 1;
-               while ( pointer < diffs.length ) {
-                       if ( diffs[ pointer - 1 ][ 0 ] === DIFF_DELETE &&
-                                       diffs[ pointer ][ 0 ] === DIFF_INSERT ) {
-                               deletion = diffs[ pointer - 1 ][ 1 ];
-                               insertion = diffs[ pointer ][ 1 ];
-                               overlapLength1 = this.diffCommonOverlap( deletion, insertion );
-                               overlapLength2 = this.diffCommonOverlap( insertion, deletion );
-                               if ( overlapLength1 >= overlapLength2 ) {
-                                       if ( overlapLength1 >= deletion.length / 2 ||
-                                                       overlapLength1 >= insertion.length / 2 ) {
-                                               // Overlap found.  Insert an equality and trim the surrounding edits.
-                                               diffs.splice(
-                                                       pointer,
-                                                       0,
-                                                       [ DIFF_EQUAL, insertion.substring( 0, overlapLength1 ) ]
-                                               );
-                                               diffs[ pointer - 1 ][ 1 ] =
-                                                       deletion.substring( 0, deletion.length - overlapLength1 );
-                                               diffs[ pointer + 1 ][ 1 ] = insertion.substring( overlapLength1 );
-                                               pointer++;
-                                       }
-                               } else {
-                                       if ( overlapLength2 >= deletion.length / 2 ||
-                                                       overlapLength2 >= insertion.length / 2 ) {
+       // Capture fixture HTML from the page
+       storeFixture();
 
-                                               // Reverse overlap found.
-                                               // Insert an equality and swap and trim the surrounding edits.
-                                               diffs.splice(
-                                                       pointer,
-                                                       0,
-                                                       [ DIFF_EQUAL, deletion.substring( 0, overlapLength2 ) ]
-                                               );
+       // Initialize QUnit elements
+       appendInterface();
+       appendTestsList( details.modules );
+       tests = id( "qunit-tests" );
+       if ( tests && config.hidepassed ) {
+               addClass( tests, "hidepass" );
+       }
+} );
+
+QUnit.done( function( details ) {
+       var i, key,
+               banner = id( "qunit-banner" ),
+               tests = id( "qunit-tests" ),
+               html = [
+                       "Tests completed in ",
+                       details.runtime,
+                       " milliseconds.<br />",
+                       "<span class='passed'>",
+                       details.passed,
+                       "</span> assertions of <span class='total'>",
+                       details.total,
+                       "</span> passed, <span class='failed'>",
+                       details.failed,
+                       "</span> failed."
+               ].join( "" );
+
+       if ( banner ) {
+               banner.className = details.failed ? "qunit-fail" : "qunit-pass";
+       }
+
+       if ( tests ) {
+               id( "qunit-testresult" ).innerHTML = html;
+       }
+
+       if ( config.altertitle && document.title ) {
 
-                                               diffs[ pointer - 1 ][ 0 ] = DIFF_INSERT;
-                                               diffs[ pointer - 1 ][ 1 ] =
-                                                       insertion.substring( 0, insertion.length - overlapLength2 );
-                                               diffs[ pointer + 1 ][ 0 ] = DIFF_DELETE;
-                                               diffs[ pointer + 1 ][ 1 ] =
-                                                       deletion.substring( overlapLength2 );
-                                               pointer++;
-                                       }
-                               }
-                               pointer++;
+               // Show ✖ for good, ✔ for bad suite result in title
+               // use escape sequences in case file gets loaded with non-utf-8-charset
+               document.title = [
+                       ( details.failed ? "\u2716" : "\u2714" ),
+                       document.title.replace( /^[\u2714\u2716] /i, "" )
+               ].join( " " );
+       }
+
+       // Clear own sessionStorage items if all tests passed
+       if ( config.reorder && defined.sessionStorage && details.failed === 0 ) {
+               for ( i = 0; i < sessionStorage.length; i++ ) {
+                       key = sessionStorage.key( i++ );
+                       if ( key.indexOf( "qunit-test-" ) === 0 ) {
+                               sessionStorage.removeItem( key );
                        }
-                       pointer++;
                }
-       };
+       }
 
-       /**
-        * Determine if the suffix of one string is the prefix of another.
-        * @param {string} text1 First string.
-        * @param {string} text2 Second string.
-        * @return {number} The number of characters common to the end of the first
-        *     string and the start of the second string.
-        * @private
-        */
-       DiffMatchPatch.prototype.diffCommonOverlap = function( text1, text2 ) {
-               var text1Length, text2Length, textLength,
-                       best, length, pattern, found;
-               // Cache the text lengths to prevent multiple calls.
-               text1Length = text1.length;
-               text2Length = text2.length;
-               // Eliminate the null case.
-               if ( text1Length === 0 || text2Length === 0 ) {
-                       return 0;
-               }
-               // Truncate the longer string.
-               if ( text1Length > text2Length ) {
-                       text1 = text1.substring( text1Length - text2Length );
-               } else if ( text1Length < text2Length ) {
-                       text2 = text2.substring( 0, text1Length );
-               }
-               textLength = Math.min( text1Length, text2Length );
-               // Quick check for the worst case.
-               if ( text1 === text2 ) {
-                       return textLength;
-               }
+       // Scroll back to top to show results
+       if ( config.scrolltop && window.scrollTo ) {
+               window.scrollTo( 0, 0 );
+       }
+} );
 
-               // Start by looking for a single character match
-               // and increase length until no match is found.
-               // Performance analysis: https://neil.fraser.name/news/2010/11/04/
-               best = 0;
-               length = 1;
-               while ( true ) {
-                       pattern = text1.substring( textLength - length );
-                       found = text2.indexOf( pattern );
-                       if ( found === -1 ) {
-                               return best;
-                       }
-                       length += found;
-                       if ( found === 0 || text1.substring( textLength - length ) ===
-                                       text2.substring( 0, length ) ) {
-                               best = length;
-                               length++;
-                       }
-               }
-       };
+function getNameHtml( name, module ) {
+       var nameHtml = "";
 
-       /**
-        * Split two texts into an array of strings.  Reduce the texts to a string of
-        * hashes where each Unicode character represents one line.
-        * @param {string} text1 First string.
-        * @param {string} text2 Second string.
-        * @return {{chars1: string, chars2: string, lineArray: !Array.<string>}}
-        *     An object containing the encoded text1, the encoded text2 and
-        *     the array of unique strings.
-        *     The zeroth element of the array of unique strings is intentionally blank.
-        * @private
-        */
-       DiffMatchPatch.prototype.diffLinesToChars = function( text1, text2 ) {
-               var lineArray, lineHash, chars1, chars2;
-               lineArray = []; // e.g. lineArray[4] === 'Hello\n'
-               lineHash = {}; // e.g. lineHash['Hello\n'] === 4
+       if ( module ) {
+               nameHtml = "<span class='module-name'>" + escapeText( module ) + "</span>: ";
+       }
 
-               // '\x00' is a valid character, but various debuggers don't like it.
-               // So we'll insert a junk entry to avoid generating a null character.
-               lineArray[ 0 ] = "";
+       nameHtml += "<span class='test-name'>" + escapeText( name ) + "</span>";
 
-               /**
-                * Split a text into an array of strings.  Reduce the texts to a string of
-                * hashes where each Unicode character represents one line.
-                * Modifies linearray and linehash through being a closure.
-                * @param {string} text String to encode.
-                * @return {string} Encoded string.
-                * @private
-                */
-               function diffLinesToCharsMunge( text ) {
-                       var chars, lineStart, lineEnd, lineArrayLength, line;
-                       chars = "";
-                       // Walk the text, pulling out a substring for each line.
-                       // text.split('\n') would would temporarily double our memory footprint.
-                       // Modifying text would create many large strings to garbage collect.
-                       lineStart = 0;
-                       lineEnd = -1;
-                       // Keeping our own length variable is faster than looking it up.
-                       lineArrayLength = lineArray.length;
-                       while ( lineEnd < text.length - 1 ) {
-                               lineEnd = text.indexOf( "\n", lineStart );
-                               if ( lineEnd === -1 ) {
-                                       lineEnd = text.length - 1;
-                               }
-                               line = text.substring( lineStart, lineEnd + 1 );
-                               lineStart = lineEnd + 1;
+       return nameHtml;
+}
 
-                               if ( lineHash.hasOwnProperty ? lineHash.hasOwnProperty( line ) :
-                                                       ( lineHash[ line ] !== undefined ) ) {
-                                       chars += String.fromCharCode( lineHash[ line ] );
-                               } else {
-                                       chars += String.fromCharCode( lineArrayLength );
-                                       lineHash[ line ] = lineArrayLength;
-                                       lineArray[ lineArrayLength++ ] = line;
-                               }
-                       }
-                       return chars;
-               }
+QUnit.testStart( function( details ) {
+       var running, testBlock, bad;
 
-               chars1 = diffLinesToCharsMunge( text1 );
-               chars2 = diffLinesToCharsMunge( text2 );
-               return {
-                       chars1: chars1,
-                       chars2: chars2,
-                       lineArray: lineArray
-               };
-       };
+       testBlock = id( "qunit-test-output-" + details.testId );
+       if ( testBlock ) {
+               testBlock.className = "running";
+       } else {
 
-       /**
-        * Rehydrate the text in a diff from a string of line hashes to real lines of
-        * text.
-        * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
-        * @param {!Array.<string>} lineArray Array of unique strings.
-        * @private
-        */
-       DiffMatchPatch.prototype.diffCharsToLines = function( diffs, lineArray ) {
-               var x, chars, text, y;
-               for ( x = 0; x < diffs.length; x++ ) {
-                       chars = diffs[ x ][ 1 ];
-                       text = [];
-                       for ( y = 0; y < chars.length; y++ ) {
-                               text[ y ] = lineArray[ chars.charCodeAt( y ) ];
-                       }
-                       diffs[ x ][ 1 ] = text.join( "" );
-               }
-       };
+               // Report later registered tests
+               appendTest( details.name, details.testId, details.module );
+       }
 
-       /**
-        * Reorder and merge like edit sections.  Merge equalities.
-        * Any edit section can move as long as it doesn't cross an equality.
-        * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
-        */
-       DiffMatchPatch.prototype.diffCleanupMerge = function( diffs ) {
-               var pointer, countDelete, countInsert, textInsert, textDelete,
-                       commonlength, changes, diffPointer, position;
-               diffs.push( [ DIFF_EQUAL, "" ] ); // Add a dummy entry at the end.
-               pointer = 0;
-               countDelete = 0;
-               countInsert = 0;
-               textDelete = "";
-               textInsert = "";
-               commonlength;
-               while ( pointer < diffs.length ) {
-                       switch ( diffs[ pointer ][ 0 ] ) {
-                       case DIFF_INSERT:
-                               countInsert++;
-                               textInsert += diffs[ pointer ][ 1 ];
-                               pointer++;
-                               break;
-                       case DIFF_DELETE:
-                               countDelete++;
-                               textDelete += diffs[ pointer ][ 1 ];
-                               pointer++;
-                               break;
-                       case DIFF_EQUAL:
-                               // Upon reaching an equality, check for prior redundancies.
-                               if ( countDelete + countInsert > 1 ) {
-                                       if ( countDelete !== 0 && countInsert !== 0 ) {
-                                               // Factor out any common prefixes.
-                                               commonlength = this.diffCommonPrefix( textInsert, textDelete );
-                                               if ( commonlength !== 0 ) {
-                                                       if ( ( pointer - countDelete - countInsert ) > 0 &&
-                                                                       diffs[ pointer - countDelete - countInsert - 1 ][ 0 ] ===
-                                                                       DIFF_EQUAL ) {
-                                                               diffs[ pointer - countDelete - countInsert - 1 ][ 1 ] +=
-                                                                       textInsert.substring( 0, commonlength );
-                                                       } else {
-                                                               diffs.splice( 0, 0, [ DIFF_EQUAL,
-                                                                       textInsert.substring( 0, commonlength )
-                                                               ] );
-                                                               pointer++;
-                                                       }
-                                                       textInsert = textInsert.substring( commonlength );
-                                                       textDelete = textDelete.substring( commonlength );
-                                               }
-                                               // Factor out any common suffixies.
-                                               commonlength = this.diffCommonSuffix( textInsert, textDelete );
-                                               if ( commonlength !== 0 ) {
-                                                       diffs[ pointer ][ 1 ] = textInsert.substring( textInsert.length -
-                                                                       commonlength ) + diffs[ pointer ][ 1 ];
-                                                       textInsert = textInsert.substring( 0, textInsert.length -
-                                                               commonlength );
-                                                       textDelete = textDelete.substring( 0, textDelete.length -
-                                                               commonlength );
-                                               }
-                                       }
-                                       // Delete the offending records and add the merged ones.
-                                       if ( countDelete === 0 ) {
-                                               diffs.splice( pointer - countInsert,
-                                                       countDelete + countInsert, [ DIFF_INSERT, textInsert ] );
-                                       } else if ( countInsert === 0 ) {
-                                               diffs.splice( pointer - countDelete,
-                                                       countDelete + countInsert, [ DIFF_DELETE, textDelete ] );
-                                       } else {
-                                               diffs.splice(
-                                                       pointer - countDelete - countInsert,
-                                                       countDelete + countInsert,
-                                                       [ DIFF_DELETE, textDelete ], [ DIFF_INSERT, textInsert ]
-                                               );
-                                       }
-                                       pointer = pointer - countDelete - countInsert +
-                                               ( countDelete ? 1 : 0 ) + ( countInsert ? 1 : 0 ) + 1;
-                               } else if ( pointer !== 0 && diffs[ pointer - 1 ][ 0 ] === DIFF_EQUAL ) {
+       running = id( "qunit-testresult" );
+       if ( running ) {
+               bad = QUnit.config.reorder && defined.sessionStorage &&
+                       +sessionStorage.getItem( "qunit-test-" + details.module + "-" + details.name );
+
+               running.innerHTML = ( bad ?
+                       "Rerunning previously failed test: <br />" :
+                       "Running: <br />" ) +
+                       getNameHtml( details.name, details.module );
+       }
 
-                                       // Merge this equality with the previous one.
-                                       diffs[ pointer - 1 ][ 1 ] += diffs[ pointer ][ 1 ];
-                                       diffs.splice( pointer, 1 );
-                               } else {
-                                       pointer++;
-                               }
-                               countInsert = 0;
-                               countDelete = 0;
-                               textDelete = "";
-                               textInsert = "";
-                               break;
-                       }
-               }
-               if ( diffs[ diffs.length - 1 ][ 1 ] === "" ) {
-                       diffs.pop(); // Remove the dummy entry at the end.
-               }
+} );
 
-               // Second pass: look for single edits surrounded on both sides by equalities
-               // which can be shifted sideways to eliminate an equality.
-               // e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
-               changes = false;
-               pointer = 1;
+function stripHtml( string ) {
 
-               // Intentionally ignore the first and last element (don't need checking).
-               while ( pointer < diffs.length - 1 ) {
-                       if ( diffs[ pointer - 1 ][ 0 ] === DIFF_EQUAL &&
-                                       diffs[ pointer + 1 ][ 0 ] === DIFF_EQUAL ) {
+       // Strip tags, html entity and whitespaces
+       return string.replace( /<\/?[^>]+(>|$)/g, "" ).replace( /\&quot;/g, "" ).replace( /\s+/g, "" );
+}
 
-                               diffPointer = diffs[ pointer ][ 1 ];
-                               position = diffPointer.substring(
-                                       diffPointer.length - diffs[ pointer - 1 ][ 1 ].length
-                               );
+QUnit.log( function( details ) {
+       var assertList, assertLi,
+               message, expected, actual, diff,
+               showDiff = false,
+               testItem = id( "qunit-test-output-" + details.testId );
 
-                               // This is a single edit surrounded by equalities.
-                               if ( position === diffs[ pointer - 1 ][ 1 ] ) {
+       if ( !testItem ) {
+               return;
+       }
 
-                                       // Shift the edit over the previous equality.
-                                       diffs[ pointer ][ 1 ] = diffs[ pointer - 1 ][ 1 ] +
-                                               diffs[ pointer ][ 1 ].substring( 0, diffs[ pointer ][ 1 ].length -
-                                                       diffs[ pointer - 1 ][ 1 ].length );
-                                       diffs[ pointer + 1 ][ 1 ] =
-                                               diffs[ pointer - 1 ][ 1 ] + diffs[ pointer + 1 ][ 1 ];
-                                       diffs.splice( pointer - 1, 1 );
-                                       changes = true;
-                               } else if ( diffPointer.substring( 0, diffs[ pointer + 1 ][ 1 ].length ) ===
-                                               diffs[ pointer + 1 ][ 1 ] ) {
+       message = escapeText( details.message ) || ( details.result ? "okay" : "failed" );
+       message = "<span class='test-message'>" + message + "</span>";
+       message += "<span class='runtime'>@ " + details.runtime + " ms</span>";
 
-                                       // Shift the edit over the next equality.
-                                       diffs[ pointer - 1 ][ 1 ] += diffs[ pointer + 1 ][ 1 ];
-                                       diffs[ pointer ][ 1 ] =
-                                               diffs[ pointer ][ 1 ].substring( diffs[ pointer + 1 ][ 1 ].length ) +
-                                               diffs[ pointer + 1 ][ 1 ];
-                                       diffs.splice( pointer + 1, 1 );
-                                       changes = true;
-                               }
-                       }
-                       pointer++;
-               }
-               // If shifts were made, the diff needs reordering and another shift sweep.
-               if ( changes ) {
-                       this.diffCleanupMerge( diffs );
+       // The pushFailure doesn't provide details.expected
+       // when it calls, it's implicit to also not show expected and diff stuff
+       // Also, we need to check details.expected existence, as it can exist and be undefined
+       if ( !details.result && hasOwn.call( details, "expected" ) ) {
+               if ( details.negative ) {
+                       expected = "NOT " + QUnit.dump.parse( details.expected );
+               } else {
+                       expected = QUnit.dump.parse( details.expected );
                }
-       };
 
-       return function( o, n ) {
-               var diff, output, text;
-               diff = new DiffMatchPatch();
-               output = diff.DiffMain( o, n );
-               diff.diffCleanupEfficiency( output );
-               text = diff.diffPrettyHtml( output );
+               actual = QUnit.dump.parse( details.actual );
+               message += "<table><tr class='test-expected'><th>Expected: </th><td><pre>" +
+                       escapeText( expected ) +
+                       "</pre></td></tr>";
 
-               return text;
-       };
-}() );
+               if ( actual !== expected ) {
 
-// Get a reference to the global object, like window in browsers
-}( (function() {
-       return this;
-})() ));
+                       message += "<tr class='test-actual'><th>Result: </th><td><pre>" +
+                               escapeText( actual ) + "</pre></td></tr>";
 
-(function() {
+                       // Don't show diff if actual or expected are booleans
+                       if ( !( /^(true|false)$/.test( actual ) ) &&
+                                       !( /^(true|false)$/.test( expected ) ) ) {
+                               diff = QUnit.diff( expected, actual );
+                               showDiff = stripHtml( diff ).length !==
+                                       stripHtml( expected ).length +
+                                       stripHtml( actual ).length;
+                       }
 
-// Don't load the HTML Reporter on non-Browser environments
-if ( typeof window === "undefined" || !window.document ) {
-       return;
-}
+                       // Don't show diff if expected and actual are totally different
+                       if ( showDiff ) {
+                               message += "<tr class='test-diff'><th>Diff: </th><td><pre>" +
+                                       diff + "</pre></td></tr>";
+                       }
+               } else if ( expected.indexOf( "[object Array]" ) !== -1 ||
+                               expected.indexOf( "[object Object]" ) !== -1 ) {
+                       message += "<tr class='test-message'><th>Message: </th><td>" +
+                               "Diff suppressed as the depth of object is more than current max depth (" +
+                               QUnit.config.maxDepth + ").<p>Hint: Use <code>QUnit.dump.maxDepth</code> to " +
+                               " run with a higher max depth or <a href='" +
+                               escapeText( setUrl( { maxDepth: -1 } ) ) + "'>" +
+                               "Rerun</a> without max depth.</p></td></tr>";
+               } else {
+                       message += "<tr class='test-message'><th>Message: </th><td>" +
+                               "Diff suppressed as the expected and actual results have an equivalent" +
+                               " serialization</td></tr>";
+               }
 
-// Deprecated QUnit.init - Ref #530
-// Re-initialize the configuration options
-QUnit.init = function() {
-       var tests, banner, result, qunit,
-               config = QUnit.config;
+               if ( details.source ) {
+                       message += "<tr class='test-source'><th>Source: </th><td><pre>" +
+                               escapeText( details.source ) + "</pre></td></tr>";
+               }
 
-       config.stats = { all: 0, bad: 0 };
-       config.moduleStats = { all: 0, bad: 0 };
-       config.started = 0;
-       config.updateRate = 1000;
-       config.blocking = false;
-       config.autostart = true;
-       config.autorun = false;
-       config.filter = "";
-       config.queue = [];
+               message += "</table>";
 
-       // Return on non-browser environments
-       // This is necessary to not break on node tests
-       if ( typeof window === "undefined" ) {
-               return;
+       // This occurs when pushFailure is set and we have an extracted stack trace
+       } else if ( !details.result && details.source ) {
+               message += "<table>" +
+                       "<tr class='test-source'><th>Source: </th><td><pre>" +
+                       escapeText( details.source ) + "</pre></td></tr>" +
+                       "</table>";
        }
 
-       qunit = id( "qunit" );
-       if ( qunit ) {
-               qunit.innerHTML =
-                       "<h1 id='qunit-header'>" + escapeText( document.title ) + "</h1>" +
-                       "<h2 id='qunit-banner'></h2>" +
-                       "<div id='qunit-testrunner-toolbar'></div>" +
-                       "<h2 id='qunit-userAgent'></h2>" +
-                       "<ol id='qunit-tests'></ol>";
-       }
+       assertList = testItem.getElementsByTagName( "ol" )[ 0 ];
 
-       tests = id( "qunit-tests" );
-       banner = id( "qunit-banner" );
-       result = id( "qunit-testresult" );
+       assertLi = document.createElement( "li" );
+       assertLi.className = details.result ? "pass" : "fail";
+       assertLi.innerHTML = message;
+       assertList.appendChild( assertLi );
+} );
 
-       if ( tests ) {
-               tests.innerHTML = "";
-       }
+QUnit.testDone( function( details ) {
+       var testTitle, time, testItem, assertList,
+               good, bad, testCounts, skipped, sourceName,
+               tests = id( "qunit-tests" );
 
-       if ( banner ) {
-               banner.className = "";
+       if ( !tests ) {
+               return;
        }
 
-       if ( result ) {
-               result.parentNode.removeChild( result );
-       }
+       testItem = id( "qunit-test-output-" + details.testId );
 
-       if ( tests ) {
-               result = document.createElement( "p" );
-               result.id = "qunit-testresult";
-               result.className = "result";
-               tests.parentNode.insertBefore( result, tests );
-               result.innerHTML = "Running...<br />&#160;";
+       assertList = testItem.getElementsByTagName( "ol" )[ 0 ];
+
+       good = details.passed;
+       bad = details.failed;
+
+       // Store result when possible
+       if ( config.reorder && defined.sessionStorage ) {
+               if ( bad ) {
+                       sessionStorage.setItem( "qunit-test-" + details.module + "-" + details.name, bad );
+               } else {
+                       sessionStorage.removeItem( "qunit-test-" + details.module + "-" + details.name );
+               }
        }
-};
 
-var config = QUnit.config,
-       collapseNext = false,
-       hasOwn = Object.prototype.hasOwnProperty,
-       defined = {
-               document: window.document !== undefined,
-               sessionStorage: (function() {
-                       var x = "qunit-test-string";
-                       try {
-                               sessionStorage.setItem( x, x );
-                               sessionStorage.removeItem( x );
-                               return true;
-                       } catch ( e ) {
-                               return false;
-                       }
-               }())
-       },
-       modulesList = [];
+       if ( bad === 0 ) {
 
-/**
-* Escape text for attribute or text content.
-*/
-function escapeText( s ) {
-       if ( !s ) {
-               return "";
+               // Collapse the passing tests
+               addClass( assertList, "qunit-collapsed" );
+       } else if ( bad && config.collapse && !collapseNext ) {
+
+               // Skip collapsing the first failing test
+               collapseNext = true;
+       } else {
+
+               // Collapse remaining tests
+               addClass( assertList, "qunit-collapsed" );
        }
-       s = s + "";
 
-       // Both single quotes and double quotes (for attributes)
-       return s.replace( /['"<>&]/g, function( s ) {
-               switch ( s ) {
-               case "'":
-                       return "&#039;";
-               case "\"":
-                       return "&quot;";
-               case "<":
-                       return "&lt;";
-               case ">":
-                       return "&gt;";
-               case "&":
-                       return "&amp;";
-               }
-       });
-}
+       // The testItem.firstChild is the test name
+       testTitle = testItem.firstChild;
 
-/**
- * @param {HTMLElement} elem
- * @param {string} type
- * @param {Function} fn
- */
-function addEvent( elem, type, fn ) {
-       if ( elem.addEventListener ) {
+       testCounts = bad ?
+               "<b class='failed'>" + bad + "</b>, " + "<b class='passed'>" + good + "</b>, " :
+               "";
 
-               // Standards-based browsers
-               elem.addEventListener( type, fn, false );
-       } else if ( elem.attachEvent ) {
+       testTitle.innerHTML += " <b class='counts'>(" + testCounts +
+               details.assertions.length + ")</b>";
+
+       if ( details.skipped ) {
+               testItem.className = "skipped";
+               skipped = document.createElement( "em" );
+               skipped.className = "qunit-skipped-label";
+               skipped.innerHTML = "skipped";
+               testItem.insertBefore( skipped, testTitle );
+       } else {
+               addEvent( testTitle, "click", function() {
+                       toggleClass( assertList, "qunit-collapsed" );
+               } );
 
-               // support: IE <9
-               elem.attachEvent( "on" + type, function() {
-                       var event = window.event;
-                       if ( !event.target ) {
-                               event.target = event.srcElement || document;
-                       }
+               testItem.className = bad ? "fail" : "pass";
 
-                       fn.call( elem, event );
-               });
+               time = document.createElement( "span" );
+               time.className = "runtime";
+               time.innerHTML = details.runtime + " ms";
+               testItem.insertBefore( time, assertList );
        }
-}
 
-/**
- * @param {Array|NodeList} elems
- * @param {string} type
- * @param {Function} fn
- */
-function addEvents( elems, type, fn ) {
-       var i = elems.length;
-       while ( i-- ) {
-               addEvent( elems[ i ], type, fn );
+       // Show the source of the test when showing assertions
+       if ( details.source ) {
+               sourceName = document.createElement( "p" );
+               sourceName.innerHTML = "<strong>Source: </strong>" + details.source;
+               addClass( sourceName, "qunit-source" );
+               if ( bad === 0 ) {
+                       addClass( sourceName, "qunit-collapsed" );
+               }
+               addEvent( testTitle, "click", function() {
+                       toggleClass( sourceName, "qunit-collapsed" );
+               } );
+               testItem.appendChild( sourceName );
        }
-}
+} );
 
-function hasClass( elem, name ) {
-       return ( " " + elem.className + " " ).indexOf( " " + name + " " ) >= 0;
-}
+// Avoid readyState issue with phantomjs
+// Ref: #818
+var notPhantom = ( function( p ) {
+       return !( p && p.version && p.version.major > 0 );
+} )( window.phantom );
 
-function addClass( elem, name ) {
-       if ( !hasClass( elem, name ) ) {
-               elem.className += ( elem.className ? " " : "" ) + name;
-       }
+if ( notPhantom && document.readyState === "complete" ) {
+       QUnit.load();
+} else {
+       addEvent( window, "load", QUnit.load );
 }
 
-function toggleClass( elem, name ) {
-       if ( hasClass( elem, name ) ) {
-               removeClass( elem, name );
-       } else {
-               addClass( elem, name );
+/*
+ * This file is a modified version of google-diff-match-patch's JavaScript implementation
+ * (https://code.google.com/p/google-diff-match-patch/source/browse/trunk/javascript/diff_match_patch_uncompressed.js),
+ * modifications are licensed as more fully set forth in LICENSE.txt.
+ *
+ * The original source of google-diff-match-patch is attributable and licensed as follows:
+ *
+ * Copyright 2006 Google Inc.
+ * https://code.google.com/p/google-diff-match-patch/
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * More Info:
+ *  https://code.google.com/p/google-diff-match-patch/
+ *
+ * Usage: QUnit.diff(expected, actual)
+ *
+ */
+QUnit.diff = ( function() {
+       function DiffMatchPatch() {
        }
-}
 
-function removeClass( elem, name ) {
-       var set = " " + elem.className + " ";
-
-       // Class name may appear multiple times
-       while ( set.indexOf( " " + name + " " ) >= 0 ) {
-               set = set.replace( " " + name + " ", " " );
-       }
+       //  DIFF FUNCTIONS
 
-       // trim for prettiness
-       elem.className = typeof set.trim === "function" ? set.trim() : set.replace( /^\s+|\s+$/g, "" );
-}
+       /**
+        * The data structure representing a diff is an array of tuples:
+        * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
+        * which means: delete 'Hello', add 'Goodbye' and keep ' world.'
+        */
+       var DIFF_DELETE = -1,
+               DIFF_INSERT = 1,
+               DIFF_EQUAL = 0;
 
-function id( name ) {
-       return defined.document && document.getElementById && document.getElementById( name );
-}
+       /**
+        * Find the differences between two texts.  Simplifies the problem by stripping
+        * any common prefix or suffix off the texts before diffing.
+        * @param {string} text1 Old string to be diffed.
+        * @param {string} text2 New string to be diffed.
+        * @param {boolean=} optChecklines Optional speedup flag. If present and false,
+        *     then don't run a line-level diff first to identify the changed areas.
+        *     Defaults to true, which does a faster, slightly less optimal diff.
+        * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
+        */
+       DiffMatchPatch.prototype.DiffMain = function( text1, text2, optChecklines ) {
+               var deadline, checklines, commonlength,
+                       commonprefix, commonsuffix, diffs;
 
-function getUrlConfigHtml() {
-       var i, j, val,
-               escaped, escapedTooltip,
-               selection = false,
-               len = config.urlConfig.length,
-               urlConfigHtml = "";
+               // The diff must be complete in up to 1 second.
+               deadline = ( new Date() ).getTime() + 1000;
 
-       for ( i = 0; i < len; i++ ) {
-               val = config.urlConfig[ i ];
-               if ( typeof val === "string" ) {
-                       val = {
-                               id: val,
-                               label: val
-                       };
+               // Check for null inputs.
+               if ( text1 === null || text2 === null ) {
+                       throw new Error( "Null input. (DiffMain)" );
                }
 
-               escaped = escapeText( val.id );
-               escapedTooltip = escapeText( val.tooltip );
-
-               if ( config[ val.id ] === undefined ) {
-                       config[ val.id ] = QUnit.urlParams[ val.id ];
+               // Check for equality (speedup).
+               if ( text1 === text2 ) {
+                       if ( text1 ) {
+                               return [
+                                       [ DIFF_EQUAL, text1 ]
+                               ];
+                       }
+                       return [];
                }
 
-               if ( !val.value || typeof val.value === "string" ) {
-                       urlConfigHtml += "<input id='qunit-urlconfig-" + escaped +
-                               "' name='" + escaped + "' type='checkbox'" +
-                               ( val.value ? " value='" + escapeText( val.value ) + "'" : "" ) +
-                               ( config[ val.id ] ? " checked='checked'" : "" ) +
-                               " title='" + escapedTooltip + "' /><label for='qunit-urlconfig-" + escaped +
-                               "' title='" + escapedTooltip + "'>" + val.label + "</label>";
-               } else {
-                       urlConfigHtml += "<label for='qunit-urlconfig-" + escaped +
-                               "' title='" + escapedTooltip + "'>" + val.label +
-                               ": </label><select id='qunit-urlconfig-" + escaped +
-                               "' name='" + escaped + "' title='" + escapedTooltip + "'><option></option>";
-
-                       if ( QUnit.is( "array", val.value ) ) {
-                               for ( j = 0; j < val.value.length; j++ ) {
-                                       escaped = escapeText( val.value[ j ] );
-                                       urlConfigHtml += "<option value='" + escaped + "'" +
-                                               ( config[ val.id ] === val.value[ j ] ?
-                                                       ( selection = true ) && " selected='selected'" : "" ) +
-                                               ">" + escaped + "</option>";
-                               }
-                       } else {
-                               for ( j in val.value ) {
-                                       if ( hasOwn.call( val.value, j ) ) {
-                                               urlConfigHtml += "<option value='" + escapeText( j ) + "'" +
-                                                       ( config[ val.id ] === j ?
-                                                               ( selection = true ) && " selected='selected'" : "" ) +
-                                                       ">" + escapeText( val.value[ j ] ) + "</option>";
-                                       }
-                               }
-                       }
-                       if ( config[ val.id ] && !selection ) {
-                               escaped = escapeText( config[ val.id ] );
-                               urlConfigHtml += "<option value='" + escaped +
-                                       "' selected='selected' disabled='disabled'>" + escaped + "</option>";
-                       }
-                       urlConfigHtml += "</select>";
+               if ( typeof optChecklines === "undefined" ) {
+                       optChecklines = true;
                }
-       }
 
-       return urlConfigHtml;
-}
+               checklines = optChecklines;
 
-// Handle "click" events on toolbar checkboxes and "change" for select menus.
-// Updates the URL with the new state of `config.urlConfig` values.
-function toolbarChanged() {
-       var updatedUrl, value,
-               field = this,
-               params = {};
+               // Trim off common prefix (speedup).
+               commonlength = this.diffCommonPrefix( text1, text2 );
+               commonprefix = text1.substring( 0, commonlength );
+               text1 = text1.substring( commonlength );
+               text2 = text2.substring( commonlength );
 
-       // Detect if field is a select menu or a checkbox
-       if ( "selectedIndex" in field ) {
-               value = field.options[ field.selectedIndex ].value || undefined;
-       } else {
-               value = field.checked ? ( field.defaultValue || true ) : undefined;
-       }
+               // Trim off common suffix (speedup).
+               commonlength = this.diffCommonSuffix( text1, text2 );
+               commonsuffix = text1.substring( text1.length - commonlength );
+               text1 = text1.substring( 0, text1.length - commonlength );
+               text2 = text2.substring( 0, text2.length - commonlength );
 
-       params[ field.name ] = value;
-       updatedUrl = setUrl( params );
+               // Compute the diff on the middle block.
+               diffs = this.diffCompute( text1, text2, checklines, deadline );
 
-       if ( "hidepassed" === field.name && "replaceState" in window.history ) {
-               config[ field.name ] = value || false;
-               if ( value ) {
-                       addClass( id( "qunit-tests" ), "hidepass" );
-               } else {
-                       removeClass( id( "qunit-tests" ), "hidepass" );
+               // Restore the prefix and suffix.
+               if ( commonprefix ) {
+                       diffs.unshift( [ DIFF_EQUAL, commonprefix ] );
                }
+               if ( commonsuffix ) {
+                       diffs.push( [ DIFF_EQUAL, commonsuffix ] );
+               }
+               this.diffCleanupMerge( diffs );
+               return diffs;
+       };
 
-               // It is not necessary to refresh the whole page
-               window.history.replaceState( null, "", updatedUrl );
-       } else {
-               window.location = updatedUrl;
-       }
-}
-
-function setUrl( params ) {
-       var key,
-               querystring = "?";
+       /**
+        * Reduce the number of edits by eliminating operationally trivial equalities.
+        * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
+        */
+       DiffMatchPatch.prototype.diffCleanupEfficiency = function( diffs ) {
+               var changes, equalities, equalitiesLength, lastequality,
+                       pointer, preIns, preDel, postIns, postDel;
+               changes = false;
+               equalities = []; // Stack of indices where equalities are found.
+               equalitiesLength = 0; // Keeping our own length var is faster in JS.
+               /** @type {?string} */
+               lastequality = null;
 
-       params = QUnit.extend( QUnit.extend( {}, QUnit.urlParams ), params );
+               // Always equal to diffs[equalities[equalitiesLength - 1]][1]
+               pointer = 0; // Index of current position.
 
-       for ( key in params ) {
-               if ( hasOwn.call( params, key ) ) {
-                       if ( params[ key ] === undefined ) {
-                               continue;
-                       }
-                       querystring += encodeURIComponent( key );
-                       if ( params[ key ] !== true ) {
-                               querystring += "=" + encodeURIComponent( params[ key ] );
-                       }
-                       querystring += "&";
-               }
-       }
-       return location.protocol + "//" + location.host +
-               location.pathname + querystring.slice( 0, -1 );
-}
+               // Is there an insertion operation before the last equality.
+               preIns = false;
 
-function applyUrlParams() {
-       var selectedModule,
-               modulesList = id( "qunit-modulefilter" ),
-               filter = id( "qunit-filter-input" ).value;
+               // Is there a deletion operation before the last equality.
+               preDel = false;
 
-       selectedModule = modulesList ?
-               decodeURIComponent( modulesList.options[ modulesList.selectedIndex ].value ) :
-               undefined;
+               // Is there an insertion operation after the last equality.
+               postIns = false;
 
-       window.location = setUrl({
-               module: ( selectedModule === "" ) ? undefined : selectedModule,
-               filter: ( filter === "" ) ? undefined : filter,
+               // Is there a deletion operation after the last equality.
+               postDel = false;
+               while ( pointer < diffs.length ) {
 
-               // Remove testId filter
-               testId: undefined
-       });
-}
+                       // Equality found.
+                       if ( diffs[ pointer ][ 0 ] === DIFF_EQUAL ) {
+                               if ( diffs[ pointer ][ 1 ].length < 4 && ( postIns || postDel ) ) {
 
-function toolbarUrlConfigContainer() {
-       var urlConfigContainer = document.createElement( "span" );
+                                       // Candidate found.
+                                       equalities[ equalitiesLength++ ] = pointer;
+                                       preIns = postIns;
+                                       preDel = postDel;
+                                       lastequality = diffs[ pointer ][ 1 ];
+                               } else {
 
-       urlConfigContainer.innerHTML = getUrlConfigHtml();
-       addClass( urlConfigContainer, "qunit-url-config" );
+                                       // Not a candidate, and can never become one.
+                                       equalitiesLength = 0;
+                                       lastequality = null;
+                               }
+                               postIns = postDel = false;
 
-       // For oldIE support:
-       // * Add handlers to the individual elements instead of the container
-       // * Use "click" instead of "change" for checkboxes
-       addEvents( urlConfigContainer.getElementsByTagName( "input" ), "click", toolbarChanged );
-       addEvents( urlConfigContainer.getElementsByTagName( "select" ), "change", toolbarChanged );
+                       // An insertion or deletion.
+                       } else {
 
-       return urlConfigContainer;
-}
+                               if ( diffs[ pointer ][ 0 ] === DIFF_DELETE ) {
+                                       postDel = true;
+                               } else {
+                                       postIns = true;
+                               }
 
-function toolbarLooseFilter() {
-       var filter = document.createElement( "form" ),
-               label = document.createElement( "label" ),
-               input = document.createElement( "input" ),
-               button = document.createElement( "button" );
+                               /*
+                                * Five types to be split:
+                                * <ins>A</ins><del>B</del>XY<ins>C</ins><del>D</del>
+                                * <ins>A</ins>X<ins>C</ins><del>D</del>
+                                * <ins>A</ins><del>B</del>X<ins>C</ins>
+                                * <ins>A</del>X<ins>C</ins><del>D</del>
+                                * <ins>A</ins><del>B</del>X<del>C</del>
+                                */
+                               if ( lastequality && ( ( preIns && preDel && postIns && postDel ) ||
+                                               ( ( lastequality.length < 2 ) &&
+                                               ( preIns + preDel + postIns + postDel ) === 3 ) ) ) {
 
-       addClass( filter, "qunit-filter" );
+                                       // Duplicate record.
+                                       diffs.splice(
+                                               equalities[ equalitiesLength - 1 ],
+                                               0,
+                                               [ DIFF_DELETE, lastequality ]
+                                       );
 
-       label.innerHTML = "Filter: ";
+                                       // Change second copy to insert.
+                                       diffs[ equalities[ equalitiesLength - 1 ] + 1 ][ 0 ] = DIFF_INSERT;
+                                       equalitiesLength--; // Throw away the equality we just deleted;
+                                       lastequality = null;
+                                       if ( preIns && preDel ) {
 
-       input.type = "text";
-       input.value = config.filter || "";
-       input.name = "filter";
-       input.id = "qunit-filter-input";
+                                               // No changes made which could affect previous entry, keep going.
+                                               postIns = postDel = true;
+                                               equalitiesLength = 0;
+                                       } else {
+                                               equalitiesLength--; // Throw away the previous equality.
+                                               pointer = equalitiesLength > 0 ? equalities[ equalitiesLength - 1 ] : -1;
+                                               postIns = postDel = false;
+                                       }
+                                       changes = true;
+                               }
+                       }
+                       pointer++;
+               }
 
-       button.innerHTML = "Go";
+               if ( changes ) {
+                       this.diffCleanupMerge( diffs );
+               }
+       };
 
-       label.appendChild( input );
+       /**
+        * Convert a diff array into a pretty HTML report.
+        * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
+        * @param {integer} string to be beautified.
+        * @return {string} HTML representation.
+        */
+       DiffMatchPatch.prototype.diffPrettyHtml = function( diffs ) {
+               var op, data, x,
+                       html = [];
+               for ( x = 0; x < diffs.length; x++ ) {
+                       op = diffs[ x ][ 0 ]; // Operation (insert, delete, equal)
+                       data = diffs[ x ][ 1 ]; // Text of change.
+                       switch ( op ) {
+                       case DIFF_INSERT:
+                               html[ x ] = "<ins>" + escapeText( data ) + "</ins>";
+                               break;
+                       case DIFF_DELETE:
+                               html[ x ] = "<del>" + escapeText( data ) + "</del>";
+                               break;
+                       case DIFF_EQUAL:
+                               html[ x ] = "<span>" + escapeText( data ) + "</span>";
+                               break;
+                       }
+               }
+               return html.join( "" );
+       };
 
-       filter.appendChild( label );
-       filter.appendChild( button );
-       addEvent( filter, "submit", function( ev ) {
-               applyUrlParams();
+       /**
+        * Determine the common prefix of two strings.
+        * @param {string} text1 First string.
+        * @param {string} text2 Second string.
+        * @return {number} The number of characters common to the start of each
+        *     string.
+        */
+       DiffMatchPatch.prototype.diffCommonPrefix = function( text1, text2 ) {
+               var pointermid, pointermax, pointermin, pointerstart;
 
-               if ( ev && ev.preventDefault ) {
-                       ev.preventDefault();
+               // Quick check for common null cases.
+               if ( !text1 || !text2 || text1.charAt( 0 ) !== text2.charAt( 0 ) ) {
+                       return 0;
                }
 
-               return false;
-       });
+               // Binary search.
+               // Performance analysis: https://neil.fraser.name/news/2007/10/09/
+               pointermin = 0;
+               pointermax = Math.min( text1.length, text2.length );
+               pointermid = pointermax;
+               pointerstart = 0;
+               while ( pointermin < pointermid ) {
+                       if ( text1.substring( pointerstart, pointermid ) ===
+                                       text2.substring( pointerstart, pointermid ) ) {
+                               pointermin = pointermid;
+                               pointerstart = pointermin;
+                       } else {
+                               pointermax = pointermid;
+                       }
+                       pointermid = Math.floor( ( pointermax - pointermin ) / 2 + pointermin );
+               }
+               return pointermid;
+       };
 
-       return filter;
-}
+       /**
+        * Determine the common suffix of two strings.
+        * @param {string} text1 First string.
+        * @param {string} text2 Second string.
+        * @return {number} The number of characters common to the end of each string.
+        */
+       DiffMatchPatch.prototype.diffCommonSuffix = function( text1, text2 ) {
+               var pointermid, pointermax, pointermin, pointerend;
 
-function toolbarModuleFilterHtml() {
-       var i,
-               moduleFilterHtml = "";
+               // Quick check for common null cases.
+               if ( !text1 ||
+                               !text2 ||
+                               text1.charAt( text1.length - 1 ) !== text2.charAt( text2.length - 1 ) ) {
+                       return 0;
+               }
 
-       if ( !modulesList.length ) {
-               return false;
-       }
+               // Binary search.
+               // Performance analysis: https://neil.fraser.name/news/2007/10/09/
+               pointermin = 0;
+               pointermax = Math.min( text1.length, text2.length );
+               pointermid = pointermax;
+               pointerend = 0;
+               while ( pointermin < pointermid ) {
+                       if ( text1.substring( text1.length - pointermid, text1.length - pointerend ) ===
+                                       text2.substring( text2.length - pointermid, text2.length - pointerend ) ) {
+                               pointermin = pointermid;
+                               pointerend = pointermin;
+                       } else {
+                               pointermax = pointermid;
+                       }
+                       pointermid = Math.floor( ( pointermax - pointermin ) / 2 + pointermin );
+               }
+               return pointermid;
+       };
 
-       modulesList.sort(function( a, b ) {
-               return a.localeCompare( b );
-       });
+       /**
+        * Find the differences between two texts.  Assumes that the texts do not
+        * have any common prefix or suffix.
+        * @param {string} text1 Old string to be diffed.
+        * @param {string} text2 New string to be diffed.
+        * @param {boolean} checklines Speedup flag.  If false, then don't run a
+        *     line-level diff first to identify the changed areas.
+        *     If true, then run a faster, slightly less optimal diff.
+        * @param {number} deadline Time when the diff should be complete by.
+        * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
+        * @private
+        */
+       DiffMatchPatch.prototype.diffCompute = function( text1, text2, checklines, deadline ) {
+               var diffs, longtext, shorttext, i, hm,
+                       text1A, text2A, text1B, text2B,
+                       midCommon, diffsA, diffsB;
 
-       moduleFilterHtml += "<label for='qunit-modulefilter'>Module: </label>" +
-               "<select id='qunit-modulefilter' name='modulefilter'><option value='' " +
-               ( QUnit.urlParams.module === undefined ? "selected='selected'" : "" ) +
-               ">< All Modules ></option>";
+               if ( !text1 ) {
 
-       for ( i = 0; i < modulesList.length; i++ ) {
-               moduleFilterHtml += "<option value='" +
-                       escapeText( encodeURIComponent( modulesList[ i ] ) ) + "' " +
-                       ( QUnit.urlParams.module === modulesList[ i ] ? "selected='selected'" : "" ) +
-                       ">" + escapeText( modulesList[ i ] ) + "</option>";
-       }
-       moduleFilterHtml += "</select>";
+                       // Just add some text (speedup).
+                       return [
+                               [ DIFF_INSERT, text2 ]
+                       ];
+               }
 
-       return moduleFilterHtml;
-}
+               if ( !text2 ) {
 
-function toolbarModuleFilter() {
-       var toolbar = id( "qunit-testrunner-toolbar" ),
-               moduleFilter = document.createElement( "span" ),
-               moduleFilterHtml = toolbarModuleFilterHtml();
+                       // Just delete some text (speedup).
+                       return [
+                               [ DIFF_DELETE, text1 ]
+                       ];
+               }
+
+               longtext = text1.length > text2.length ? text1 : text2;
+               shorttext = text1.length > text2.length ? text2 : text1;
+               i = longtext.indexOf( shorttext );
+               if ( i !== -1 ) {
+
+                       // Shorter text is inside the longer text (speedup).
+                       diffs = [
+                               [ DIFF_INSERT, longtext.substring( 0, i ) ],
+                               [ DIFF_EQUAL, shorttext ],
+                               [ DIFF_INSERT, longtext.substring( i + shorttext.length ) ]
+                       ];
 
-       if ( !toolbar || !moduleFilterHtml ) {
-               return false;
-       }
+                       // Swap insertions for deletions if diff is reversed.
+                       if ( text1.length > text2.length ) {
+                               diffs[ 0 ][ 0 ] = diffs[ 2 ][ 0 ] = DIFF_DELETE;
+                       }
+                       return diffs;
+               }
 
-       moduleFilter.setAttribute( "id", "qunit-modulefilter-container" );
-       moduleFilter.innerHTML = moduleFilterHtml;
+               if ( shorttext.length === 1 ) {
 
-       addEvent( moduleFilter.lastChild, "change", applyUrlParams );
+                       // Single character string.
+                       // After the previous speedup, the character can't be an equality.
+                       return [
+                               [ DIFF_DELETE, text1 ],
+                               [ DIFF_INSERT, text2 ]
+                       ];
+               }
 
-       toolbar.appendChild( moduleFilter );
-}
+               // Check to see if the problem can be split in two.
+               hm = this.diffHalfMatch( text1, text2 );
+               if ( hm ) {
 
-function appendToolbar() {
-       var toolbar = id( "qunit-testrunner-toolbar" );
+                       // A half-match was found, sort out the return data.
+                       text1A = hm[ 0 ];
+                       text1B = hm[ 1 ];
+                       text2A = hm[ 2 ];
+                       text2B = hm[ 3 ];
+                       midCommon = hm[ 4 ];
 
-       if ( toolbar ) {
-               toolbar.appendChild( toolbarUrlConfigContainer() );
-               toolbar.appendChild( toolbarLooseFilter() );
-       }
-}
+                       // Send both pairs off for separate processing.
+                       diffsA = this.DiffMain( text1A, text2A, checklines, deadline );
+                       diffsB = this.DiffMain( text1B, text2B, checklines, deadline );
 
-function appendHeader() {
-       var header = id( "qunit-header" );
+                       // Merge the results.
+                       return diffsA.concat( [
+                               [ DIFF_EQUAL, midCommon ]
+                       ], diffsB );
+               }
 
-       if ( header ) {
-               header.innerHTML = "<a href='" +
-                       escapeText( setUrl( { filter: undefined, module: undefined, testId: undefined } ) ) +
-                       "'>" + header.innerHTML + "</a> ";
-       }
-}
+               if ( checklines && text1.length > 100 && text2.length > 100 ) {
+                       return this.diffLineMode( text1, text2, deadline );
+               }
 
-function appendBanner() {
-       var banner = id( "qunit-banner" );
+               return this.diffBisect( text1, text2, deadline );
+       };
 
-       if ( banner ) {
-               banner.className = "";
-       }
-}
+       /**
+        * Do the two texts share a substring which is at least half the length of the
+        * longer text?
+        * This speedup can produce non-minimal diffs.
+        * @param {string} text1 First string.
+        * @param {string} text2 Second string.
+        * @return {Array.<string>} Five element Array, containing the prefix of
+        *     text1, the suffix of text1, the prefix of text2, the suffix of
+        *     text2 and the common middle.  Or null if there was no match.
+        * @private
+        */
+       DiffMatchPatch.prototype.diffHalfMatch = function( text1, text2 ) {
+               var longtext, shorttext, dmp,
+                       text1A, text2B, text2A, text1B, midCommon,
+                       hm1, hm2, hm;
 
-function appendTestResults() {
-       var tests = id( "qunit-tests" ),
-               result = id( "qunit-testresult" );
+               longtext = text1.length > text2.length ? text1 : text2;
+               shorttext = text1.length > text2.length ? text2 : text1;
+               if ( longtext.length < 4 || shorttext.length * 2 < longtext.length ) {
+                       return null; // Pointless.
+               }
+               dmp = this; // 'this' becomes 'window' in a closure.
 
-       if ( result ) {
-               result.parentNode.removeChild( result );
-       }
+               /**
+                * Does a substring of shorttext exist within longtext such that the substring
+                * is at least half the length of longtext?
+                * Closure, but does not reference any external variables.
+                * @param {string} longtext Longer string.
+                * @param {string} shorttext Shorter string.
+                * @param {number} i Start index of quarter length substring within longtext.
+                * @return {Array.<string>} Five element Array, containing the prefix of
+                *     longtext, the suffix of longtext, the prefix of shorttext, the suffix
+                *     of shorttext and the common middle.  Or null if there was no match.
+                * @private
+                */
+               function diffHalfMatchI( longtext, shorttext, i ) {
+                       var seed, j, bestCommon, prefixLength, suffixLength,
+                               bestLongtextA, bestLongtextB, bestShorttextA, bestShorttextB;
 
-       if ( tests ) {
-               tests.innerHTML = "";
-               result = document.createElement( "p" );
-               result.id = "qunit-testresult";
-               result.className = "result";
-               tests.parentNode.insertBefore( result, tests );
-               result.innerHTML = "Running...<br />&#160;";
-       }
-}
+                       // Start with a 1/4 length substring at position i as a seed.
+                       seed = longtext.substring( i, i + Math.floor( longtext.length / 4 ) );
+                       j = -1;
+                       bestCommon = "";
+                       while ( ( j = shorttext.indexOf( seed, j + 1 ) ) !== -1 ) {
+                               prefixLength = dmp.diffCommonPrefix( longtext.substring( i ),
+                                       shorttext.substring( j ) );
+                               suffixLength = dmp.diffCommonSuffix( longtext.substring( 0, i ),
+                                       shorttext.substring( 0, j ) );
+                               if ( bestCommon.length < suffixLength + prefixLength ) {
+                                       bestCommon = shorttext.substring( j - suffixLength, j ) +
+                                               shorttext.substring( j, j + prefixLength );
+                                       bestLongtextA = longtext.substring( 0, i - suffixLength );
+                                       bestLongtextB = longtext.substring( i + prefixLength );
+                                       bestShorttextA = shorttext.substring( 0, j - suffixLength );
+                                       bestShorttextB = shorttext.substring( j + prefixLength );
+                               }
+                       }
+                       if ( bestCommon.length * 2 >= longtext.length ) {
+                               return [ bestLongtextA, bestLongtextB,
+                                       bestShorttextA, bestShorttextB, bestCommon
+                               ];
+                       } else {
+                               return null;
+                       }
+               }
 
-function storeFixture() {
-       var fixture = id( "qunit-fixture" );
-       if ( fixture ) {
-               config.fixture = fixture.innerHTML;
-       }
-}
+               // First check if the second quarter is the seed for a half-match.
+               hm1 = diffHalfMatchI( longtext, shorttext,
+                       Math.ceil( longtext.length / 4 ) );
 
-function appendFilteredTest() {
-       var testId = QUnit.config.testId;
-       if ( !testId || testId.length <= 0 ) {
-               return "";
-       }
-       return "<div id='qunit-filteredTest'>Rerunning selected tests: " +
-               escapeText( testId.join(", ") ) +
-               " <a id='qunit-clearFilter' href='" +
-               escapeText( setUrl( { filter: undefined, module: undefined, testId: undefined } ) ) +
-               "'>" + "Run all tests" + "</a></div>";
-}
+               // Check again based on the third quarter.
+               hm2 = diffHalfMatchI( longtext, shorttext,
+                       Math.ceil( longtext.length / 2 ) );
+               if ( !hm1 && !hm2 ) {
+                       return null;
+               } else if ( !hm2 ) {
+                       hm = hm1;
+               } else if ( !hm1 ) {
+                       hm = hm2;
+               } else {
 
-function appendUserAgent() {
-       var userAgent = id( "qunit-userAgent" );
+                       // Both matched.  Select the longest.
+                       hm = hm1[ 4 ].length > hm2[ 4 ].length ? hm1 : hm2;
+               }
 
-       if ( userAgent ) {
-               userAgent.innerHTML = "";
-               userAgent.appendChild(
-                       document.createTextNode(
-                               "QUnit " + QUnit.version + "; " + navigator.userAgent
-                       )
-               );
-       }
-}
+               // A half-match was found, sort out the return data.
+               text1A, text1B, text2A, text2B;
+               if ( text1.length > text2.length ) {
+                       text1A = hm[ 0 ];
+                       text1B = hm[ 1 ];
+                       text2A = hm[ 2 ];
+                       text2B = hm[ 3 ];
+               } else {
+                       text2A = hm[ 0 ];
+                       text2B = hm[ 1 ];
+                       text1A = hm[ 2 ];
+                       text1B = hm[ 3 ];
+               }
+               midCommon = hm[ 4 ];
+               return [ text1A, text1B, text2A, text2B, midCommon ];
+       };
 
-function appendTestsList( modules ) {
-       var i, l, x, z, test, moduleObj;
+       /**
+        * Do a quick line-level diff on both strings, then rediff the parts for
+        * greater accuracy.
+        * This speedup can produce non-minimal diffs.
+        * @param {string} text1 Old string to be diffed.
+        * @param {string} text2 New string to be diffed.
+        * @param {number} deadline Time when the diff should be complete by.
+        * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
+        * @private
+        */
+       DiffMatchPatch.prototype.diffLineMode = function( text1, text2, deadline ) {
+               var a, diffs, linearray, pointer, countInsert,
+                       countDelete, textInsert, textDelete, j;
 
-       for ( i = 0, l = modules.length; i < l; i++ ) {
-               moduleObj = modules[ i ];
+               // Scan the text on a line-by-line basis first.
+               a = this.diffLinesToChars( text1, text2 );
+               text1 = a.chars1;
+               text2 = a.chars2;
+               linearray = a.lineArray;
 
-               if ( moduleObj.name ) {
-                       modulesList.push( moduleObj.name );
-               }
+               diffs = this.DiffMain( text1, text2, false, deadline );
 
-               for ( x = 0, z = moduleObj.tests.length; x < z; x++ ) {
-                       test = moduleObj.tests[ x ];
+               // Convert the diff back to original text.
+               this.diffCharsToLines( diffs, linearray );
 
-                       appendTest( test.name, test.testId, moduleObj.name );
-               }
-       }
-}
+               // Eliminate freak matches (e.g. blank lines)
+               this.diffCleanupSemantic( diffs );
 
-function appendTest( name, testId, moduleName ) {
-       var title, rerunTrigger, testBlock, assertList,
-               tests = id( "qunit-tests" );
+               // Rediff any replacement blocks, this time character-by-character.
+               // Add a dummy entry at the end.
+               diffs.push( [ DIFF_EQUAL, "" ] );
+               pointer = 0;
+               countDelete = 0;
+               countInsert = 0;
+               textDelete = "";
+               textInsert = "";
+               while ( pointer < diffs.length ) {
+                       switch ( diffs[ pointer ][ 0 ] ) {
+                       case DIFF_INSERT:
+                               countInsert++;
+                               textInsert += diffs[ pointer ][ 1 ];
+                               break;
+                       case DIFF_DELETE:
+                               countDelete++;
+                               textDelete += diffs[ pointer ][ 1 ];
+                               break;
+                       case DIFF_EQUAL:
+
+                               // Upon reaching an equality, check for prior redundancies.
+                               if ( countDelete >= 1 && countInsert >= 1 ) {
 
-       if ( !tests ) {
-               return;
-       }
+                                       // Delete the offending records and add the merged ones.
+                                       diffs.splice( pointer - countDelete - countInsert,
+                                               countDelete + countInsert );
+                                       pointer = pointer - countDelete - countInsert;
+                                       a = this.DiffMain( textDelete, textInsert, false, deadline );
+                                       for ( j = a.length - 1; j >= 0; j-- ) {
+                                               diffs.splice( pointer, 0, a[ j ] );
+                                       }
+                                       pointer = pointer + a.length;
+                               }
+                               countInsert = 0;
+                               countDelete = 0;
+                               textDelete = "";
+                               textInsert = "";
+                               break;
+                       }
+                       pointer++;
+               }
+               diffs.pop(); // Remove the dummy entry at the end.
 
-       title = document.createElement( "strong" );
-       title.innerHTML = getNameHtml( name, moduleName );
+               return diffs;
+       };
 
-       rerunTrigger = document.createElement( "a" );
-       rerunTrigger.innerHTML = "Rerun";
-       rerunTrigger.href = setUrl({ testId: testId });
+       /**
+        * Find the 'middle snake' of a diff, split the problem in two
+        * and return the recursively constructed diff.
+        * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
+        * @param {string} text1 Old string to be diffed.
+        * @param {string} text2 New string to be diffed.
+        * @param {number} deadline Time at which to bail if not yet complete.
+        * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
+        * @private
+        */
+       DiffMatchPatch.prototype.diffBisect = function( text1, text2, deadline ) {
+               var text1Length, text2Length, maxD, vOffset, vLength,
+                       v1, v2, x, delta, front, k1start, k1end, k2start,
+                       k2end, k2Offset, k1Offset, x1, x2, y1, y2, d, k1, k2;
 
-       testBlock = document.createElement( "li" );
-       testBlock.appendChild( title );
-       testBlock.appendChild( rerunTrigger );
-       testBlock.id = "qunit-test-output-" + testId;
+               // Cache the text lengths to prevent multiple calls.
+               text1Length = text1.length;
+               text2Length = text2.length;
+               maxD = Math.ceil( ( text1Length + text2Length ) / 2 );
+               vOffset = maxD;
+               vLength = 2 * maxD;
+               v1 = new Array( vLength );
+               v2 = new Array( vLength );
 
-       assertList = document.createElement( "ol" );
-       assertList.className = "qunit-assert-list";
+               // Setting all elements to -1 is faster in Chrome & Firefox than mixing
+               // integers and undefined.
+               for ( x = 0; x < vLength; x++ ) {
+                       v1[ x ] = -1;
+                       v2[ x ] = -1;
+               }
+               v1[ vOffset + 1 ] = 0;
+               v2[ vOffset + 1 ] = 0;
+               delta = text1Length - text2Length;
 
-       testBlock.appendChild( assertList );
+               // If the total number of characters is odd, then the front path will collide
+               // with the reverse path.
+               front = ( delta % 2 !== 0 );
 
-       tests.appendChild( testBlock );
-}
+               // Offsets for start and end of k loop.
+               // Prevents mapping of space beyond the grid.
+               k1start = 0;
+               k1end = 0;
+               k2start = 0;
+               k2end = 0;
+               for ( d = 0; d < maxD; d++ ) {
 
-// HTML Reporter initialization and load
-QUnit.begin(function( details ) {
-       var qunit = id( "qunit" );
+                       // Bail out if deadline is reached.
+                       if ( ( new Date() ).getTime() > deadline ) {
+                               break;
+                       }
 
-       // Fixture is the only one necessary to run without the #qunit element
-       storeFixture();
+                       // Walk the front path one step.
+                       for ( k1 = -d + k1start; k1 <= d - k1end; k1 += 2 ) {
+                               k1Offset = vOffset + k1;
+                               if ( k1 === -d || ( k1 !== d && v1[ k1Offset - 1 ] < v1[ k1Offset + 1 ] ) ) {
+                                       x1 = v1[ k1Offset + 1 ];
+                               } else {
+                                       x1 = v1[ k1Offset - 1 ] + 1;
+                               }
+                               y1 = x1 - k1;
+                               while ( x1 < text1Length && y1 < text2Length &&
+                                       text1.charAt( x1 ) === text2.charAt( y1 ) ) {
+                                       x1++;
+                                       y1++;
+                               }
+                               v1[ k1Offset ] = x1;
+                               if ( x1 > text1Length ) {
 
-       if ( qunit ) {
-               qunit.innerHTML =
-                       "<h1 id='qunit-header'>" + escapeText( document.title ) + "</h1>" +
-                       "<h2 id='qunit-banner'></h2>" +
-                       "<div id='qunit-testrunner-toolbar'></div>" +
-                       appendFilteredTest() +
-                       "<h2 id='qunit-userAgent'></h2>" +
-                       "<ol id='qunit-tests'></ol>";
-       }
+                                       // Ran off the right of the graph.
+                                       k1end += 2;
+                               } else if ( y1 > text2Length ) {
 
-       appendHeader();
-       appendBanner();
-       appendTestResults();
-       appendUserAgent();
-       appendToolbar();
-       appendTestsList( details.modules );
-       toolbarModuleFilter();
+                                       // Ran off the bottom of the graph.
+                                       k1start += 2;
+                               } else if ( front ) {
+                                       k2Offset = vOffset + delta - k1;
+                                       if ( k2Offset >= 0 && k2Offset < vLength && v2[ k2Offset ] !== -1 ) {
 
-       if ( qunit && config.hidepassed ) {
-               addClass( qunit.lastChild, "hidepass" );
-       }
-});
+                                               // Mirror x2 onto top-left coordinate system.
+                                               x2 = text1Length - v2[ k2Offset ];
+                                               if ( x1 >= x2 ) {
 
-QUnit.done(function( details ) {
-       var i, key,
-               banner = id( "qunit-banner" ),
-               tests = id( "qunit-tests" ),
-               html = [
-                       "Tests completed in ",
-                       details.runtime,
-                       " milliseconds.<br />",
-                       "<span class='passed'>",
-                       details.passed,
-                       "</span> assertions of <span class='total'>",
-                       details.total,
-                       "</span> passed, <span class='failed'>",
-                       details.failed,
-                       "</span> failed."
-               ].join( "" );
+                                                       // Overlap detected.
+                                                       return this.diffBisectSplit( text1, text2, x1, y1, deadline );
+                                               }
+                                       }
+                               }
+                       }
 
-       if ( banner ) {
-               banner.className = details.failed ? "qunit-fail" : "qunit-pass";
-       }
+                       // Walk the reverse path one step.
+                       for ( k2 = -d + k2start; k2 <= d - k2end; k2 += 2 ) {
+                               k2Offset = vOffset + k2;
+                               if ( k2 === -d || ( k2 !== d && v2[ k2Offset - 1 ] < v2[ k2Offset + 1 ] ) ) {
+                                       x2 = v2[ k2Offset + 1 ];
+                               } else {
+                                       x2 = v2[ k2Offset - 1 ] + 1;
+                               }
+                               y2 = x2 - k2;
+                               while ( x2 < text1Length && y2 < text2Length &&
+                                       text1.charAt( text1Length - x2 - 1 ) ===
+                                       text2.charAt( text2Length - y2 - 1 ) ) {
+                                       x2++;
+                                       y2++;
+                               }
+                               v2[ k2Offset ] = x2;
+                               if ( x2 > text1Length ) {
 
-       if ( tests ) {
-               id( "qunit-testresult" ).innerHTML = html;
-       }
+                                       // Ran off the left of the graph.
+                                       k2end += 2;
+                               } else if ( y2 > text2Length ) {
 
-       if ( config.altertitle && defined.document && document.title ) {
+                                       // Ran off the top of the graph.
+                                       k2start += 2;
+                               } else if ( !front ) {
+                                       k1Offset = vOffset + delta - k2;
+                                       if ( k1Offset >= 0 && k1Offset < vLength && v1[ k1Offset ] !== -1 ) {
+                                               x1 = v1[ k1Offset ];
+                                               y1 = vOffset + x1 - k1Offset;
 
-               // show ✖ for good, ✔ for bad suite result in title
-               // use escape sequences in case file gets loaded with non-utf-8-charset
-               document.title = [
-                       ( details.failed ? "\u2716" : "\u2714" ),
-                       document.title.replace( /^[\u2714\u2716] /i, "" )
-               ].join( " " );
-       }
+                                               // Mirror x2 onto top-left coordinate system.
+                                               x2 = text1Length - x2;
+                                               if ( x1 >= x2 ) {
 
-       // clear own sessionStorage items if all tests passed
-       if ( config.reorder && defined.sessionStorage && details.failed === 0 ) {
-               for ( i = 0; i < sessionStorage.length; i++ ) {
-                       key = sessionStorage.key( i++ );
-                       if ( key.indexOf( "qunit-test-" ) === 0 ) {
-                               sessionStorage.removeItem( key );
+                                                       // Overlap detected.
+                                                       return this.diffBisectSplit( text1, text2, x1, y1, deadline );
+                                               }
+                                       }
+                               }
                        }
                }
-       }
-
-       // scroll back to top to show results
-       if ( config.scrolltop && window.scrollTo ) {
-               window.scrollTo( 0, 0 );
-       }
-});
 
-function getNameHtml( name, module ) {
-       var nameHtml = "";
+               // Diff took too long and hit the deadline or
+               // number of diffs equals number of characters, no commonality at all.
+               return [
+                       [ DIFF_DELETE, text1 ],
+                       [ DIFF_INSERT, text2 ]
+               ];
+       };
 
-       if ( module ) {
-               nameHtml = "<span class='module-name'>" + escapeText( module ) + "</span>: ";
-       }
+       /**
+        * Given the location of the 'middle snake', split the diff in two parts
+        * and recurse.
+        * @param {string} text1 Old string to be diffed.
+        * @param {string} text2 New string to be diffed.
+        * @param {number} x Index of split point in text1.
+        * @param {number} y Index of split point in text2.
+        * @param {number} deadline Time at which to bail if not yet complete.
+        * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
+        * @private
+        */
+       DiffMatchPatch.prototype.diffBisectSplit = function( text1, text2, x, y, deadline ) {
+               var text1a, text1b, text2a, text2b, diffs, diffsb;
+               text1a = text1.substring( 0, x );
+               text2a = text2.substring( 0, y );
+               text1b = text1.substring( x );
+               text2b = text2.substring( y );
 
-       nameHtml += "<span class='test-name'>" + escapeText( name ) + "</span>";
+               // Compute both diffs serially.
+               diffs = this.DiffMain( text1a, text2a, false, deadline );
+               diffsb = this.DiffMain( text1b, text2b, false, deadline );
 
-       return nameHtml;
-}
+               return diffs.concat( diffsb );
+       };
 
-QUnit.testStart(function( details ) {
-       var running, testBlock, bad;
+       /**
+        * Reduce the number of edits by eliminating semantically trivial equalities.
+        * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
+        */
+       DiffMatchPatch.prototype.diffCleanupSemantic = function( diffs ) {
+               var changes, equalities, equalitiesLength, lastequality,
+                       pointer, lengthInsertions2, lengthDeletions2, lengthInsertions1,
+                       lengthDeletions1, deletion, insertion, overlapLength1, overlapLength2;
+               changes = false;
+               equalities = []; // Stack of indices where equalities are found.
+               equalitiesLength = 0; // Keeping our own length var is faster in JS.
+               /** @type {?string} */
+               lastequality = null;
 
-       testBlock = id( "qunit-test-output-" + details.testId );
-       if ( testBlock ) {
-               testBlock.className = "running";
-       } else {
+               // Always equal to diffs[equalities[equalitiesLength - 1]][1]
+               pointer = 0; // Index of current position.
 
-               // Report later registered tests
-               appendTest( details.name, details.testId, details.module );
-       }
+               // Number of characters that changed prior to the equality.
+               lengthInsertions1 = 0;
+               lengthDeletions1 = 0;
 
-       running = id( "qunit-testresult" );
-       if ( running ) {
-               bad = QUnit.config.reorder && defined.sessionStorage &&
-                       +sessionStorage.getItem( "qunit-test-" + details.module + "-" + details.name );
+               // Number of characters that changed after the equality.
+               lengthInsertions2 = 0;
+               lengthDeletions2 = 0;
+               while ( pointer < diffs.length ) {
+                       if ( diffs[ pointer ][ 0 ] === DIFF_EQUAL ) { // Equality found.
+                               equalities[ equalitiesLength++ ] = pointer;
+                               lengthInsertions1 = lengthInsertions2;
+                               lengthDeletions1 = lengthDeletions2;
+                               lengthInsertions2 = 0;
+                               lengthDeletions2 = 0;
+                               lastequality = diffs[ pointer ][ 1 ];
+                       } else { // An insertion or deletion.
+                               if ( diffs[ pointer ][ 0 ] === DIFF_INSERT ) {
+                                       lengthInsertions2 += diffs[ pointer ][ 1 ].length;
+                               } else {
+                                       lengthDeletions2 += diffs[ pointer ][ 1 ].length;
+                               }
 
-               running.innerHTML = ( bad ?
-                       "Rerunning previously failed test: <br />" :
-                       "Running: <br />" ) +
-                       getNameHtml( details.name, details.module );
-       }
+                               // Eliminate an equality that is smaller or equal to the edits on both
+                               // sides of it.
+                               if ( lastequality && ( lastequality.length <=
+                                               Math.max( lengthInsertions1, lengthDeletions1 ) ) &&
+                                               ( lastequality.length <= Math.max( lengthInsertions2,
+                                                       lengthDeletions2 ) ) ) {
 
-});
+                                       // Duplicate record.
+                                       diffs.splice(
+                                               equalities[ equalitiesLength - 1 ],
+                                               0,
+                                               [ DIFF_DELETE, lastequality ]
+                                       );
 
-function stripHtml( string ) {
-       // strip tags, html entity and whitespaces
-       return string.replace(/<\/?[^>]+(>|$)/g, "").replace(/\&quot;/g, "").replace(/\s+/g, "");
-}
+                                       // Change second copy to insert.
+                                       diffs[ equalities[ equalitiesLength - 1 ] + 1 ][ 0 ] = DIFF_INSERT;
 
-QUnit.log(function( details ) {
-       var assertList, assertLi,
-               message, expected, actual, diff,
-               showDiff = false,
-               testItem = id( "qunit-test-output-" + details.testId );
+                                       // Throw away the equality we just deleted.
+                                       equalitiesLength--;
 
-       if ( !testItem ) {
-               return;
-       }
+                                       // Throw away the previous equality (it needs to be reevaluated).
+                                       equalitiesLength--;
+                                       pointer = equalitiesLength > 0 ? equalities[ equalitiesLength - 1 ] : -1;
 
-       message = escapeText( details.message ) || ( details.result ? "okay" : "failed" );
-       message = "<span class='test-message'>" + message + "</span>";
-       message += "<span class='runtime'>@ " + details.runtime + " ms</span>";
+                                       // Reset the counters.
+                                       lengthInsertions1 = 0;
+                                       lengthDeletions1 = 0;
+                                       lengthInsertions2 = 0;
+                                       lengthDeletions2 = 0;
+                                       lastequality = null;
+                                       changes = true;
+                               }
+                       }
+                       pointer++;
+               }
 
-       // pushFailure doesn't provide details.expected
-       // when it calls, it's implicit to also not show expected and diff stuff
-       // Also, we need to check details.expected existence, as it can exist and be undefined
-       if ( !details.result && hasOwn.call( details, "expected" ) ) {
-               if ( details.negative ) {
-                       expected = escapeText( "NOT " + QUnit.dump.parse( details.expected ) );
-               } else {
-                       expected = escapeText( QUnit.dump.parse( details.expected ) );
+               // Normalize the diff.
+               if ( changes ) {
+                       this.diffCleanupMerge( diffs );
                }
 
-               actual = escapeText( QUnit.dump.parse( details.actual ) );
-               message += "<table><tr class='test-expected'><th>Expected: </th><td><pre>" +
-                       expected +
-                       "</pre></td></tr>";
+               // Find any overlaps between deletions and insertions.
+               // e.g: <del>abcxxx</del><ins>xxxdef</ins>
+               //   -> <del>abc</del>xxx<ins>def</ins>
+               // e.g: <del>xxxabc</del><ins>defxxx</ins>
+               //   -> <ins>def</ins>xxx<del>abc</del>
+               // Only extract an overlap if it is as big as the edit ahead or behind it.
+               pointer = 1;
+               while ( pointer < diffs.length ) {
+                       if ( diffs[ pointer - 1 ][ 0 ] === DIFF_DELETE &&
+                                       diffs[ pointer ][ 0 ] === DIFF_INSERT ) {
+                               deletion = diffs[ pointer - 1 ][ 1 ];
+                               insertion = diffs[ pointer ][ 1 ];
+                               overlapLength1 = this.diffCommonOverlap( deletion, insertion );
+                               overlapLength2 = this.diffCommonOverlap( insertion, deletion );
+                               if ( overlapLength1 >= overlapLength2 ) {
+                                       if ( overlapLength1 >= deletion.length / 2 ||
+                                                       overlapLength1 >= insertion.length / 2 ) {
 
-               if ( actual !== expected ) {
+                                               // Overlap found.  Insert an equality and trim the surrounding edits.
+                                               diffs.splice(
+                                                       pointer,
+                                                       0,
+                                                       [ DIFF_EQUAL, insertion.substring( 0, overlapLength1 ) ]
+                                               );
+                                               diffs[ pointer - 1 ][ 1 ] =
+                                                       deletion.substring( 0, deletion.length - overlapLength1 );
+                                               diffs[ pointer + 1 ][ 1 ] = insertion.substring( overlapLength1 );
+                                               pointer++;
+                                       }
+                               } else {
+                                       if ( overlapLength2 >= deletion.length / 2 ||
+                                                       overlapLength2 >= insertion.length / 2 ) {
 
-                       message += "<tr class='test-actual'><th>Result: </th><td><pre>" +
-                               actual + "</pre></td></tr>";
+                                               // Reverse overlap found.
+                                               // Insert an equality and swap and trim the surrounding edits.
+                                               diffs.splice(
+                                                       pointer,
+                                                       0,
+                                                       [ DIFF_EQUAL, deletion.substring( 0, overlapLength2 ) ]
+                                               );
 
-                       // Don't show diff if actual or expected are booleans
-                       if ( !( /^(true|false)$/.test( actual ) ) &&
-                                       !( /^(true|false)$/.test( expected ) ) ) {
-                               diff = QUnit.diff( expected, actual );
-                               showDiff = stripHtml( diff ).length !==
-                                       stripHtml( expected ).length +
-                                       stripHtml( actual ).length;
+                                               diffs[ pointer - 1 ][ 0 ] = DIFF_INSERT;
+                                               diffs[ pointer - 1 ][ 1 ] =
+                                                       insertion.substring( 0, insertion.length - overlapLength2 );
+                                               diffs[ pointer + 1 ][ 0 ] = DIFF_DELETE;
+                                               diffs[ pointer + 1 ][ 1 ] =
+                                                       deletion.substring( overlapLength2 );
+                                               pointer++;
+                                       }
+                               }
+                               pointer++;
                        }
+                       pointer++;
+               }
+       };
 
-                       // Don't show diff if expected and actual are totally different
-                       if ( showDiff ) {
-                               message += "<tr class='test-diff'><th>Diff: </th><td><pre>" +
-                                       diff + "</pre></td></tr>";
-                       }
-               } else if ( expected.indexOf( "[object Array]" ) !== -1 ||
-                               expected.indexOf( "[object Object]" ) !== -1 ) {
-                       message += "<tr class='test-message'><th>Message: </th><td>" +
-                               "Diff suppressed as the depth of object is more than current max depth (" +
-                               QUnit.config.maxDepth + ").<p>Hint: Use <code>QUnit.dump.maxDepth</code> to " +
-                               " run with a higher max depth or <a href='" +
-                               escapeText( setUrl( { maxDepth: -1 } ) ) + "'>" +
-                               "Rerun</a> without max depth.</p></td></tr>";
+       /**
+        * Determine if the suffix of one string is the prefix of another.
+        * @param {string} text1 First string.
+        * @param {string} text2 Second string.
+        * @return {number} The number of characters common to the end of the first
+        *     string and the start of the second string.
+        * @private
+        */
+       DiffMatchPatch.prototype.diffCommonOverlap = function( text1, text2 ) {
+               var text1Length, text2Length, textLength,
+                       best, length, pattern, found;
+
+               // Cache the text lengths to prevent multiple calls.
+               text1Length = text1.length;
+               text2Length = text2.length;
+
+               // Eliminate the null case.
+               if ( text1Length === 0 || text2Length === 0 ) {
+                       return 0;
                }
 
-               if ( details.source ) {
-                       message += "<tr class='test-source'><th>Source: </th><td><pre>" +
-                               escapeText( details.source ) + "</pre></td></tr>";
+               // Truncate the longer string.
+               if ( text1Length > text2Length ) {
+                       text1 = text1.substring( text1Length - text2Length );
+               } else if ( text1Length < text2Length ) {
+                       text2 = text2.substring( 0, text1Length );
                }
+               textLength = Math.min( text1Length, text2Length );
 
-               message += "</table>";
+               // Quick check for the worst case.
+               if ( text1 === text2 ) {
+                       return textLength;
+               }
 
-       // this occurs when pushFailure is set and we have an extracted stack trace
-       } else if ( !details.result && details.source ) {
-               message += "<table>" +
-                       "<tr class='test-source'><th>Source: </th><td><pre>" +
-                       escapeText( details.source ) + "</pre></td></tr>" +
-                       "</table>";
-       }
+               // Start by looking for a single character match
+               // and increase length until no match is found.
+               // Performance analysis: https://neil.fraser.name/news/2010/11/04/
+               best = 0;
+               length = 1;
+               while ( true ) {
+                       pattern = text1.substring( textLength - length );
+                       found = text2.indexOf( pattern );
+                       if ( found === -1 ) {
+                               return best;
+                       }
+                       length += found;
+                       if ( found === 0 || text1.substring( textLength - length ) ===
+                                       text2.substring( 0, length ) ) {
+                               best = length;
+                               length++;
+                       }
+               }
+       };
 
-       assertList = testItem.getElementsByTagName( "ol" )[ 0 ];
+       /**
+        * Split two texts into an array of strings.  Reduce the texts to a string of
+        * hashes where each Unicode character represents one line.
+        * @param {string} text1 First string.
+        * @param {string} text2 Second string.
+        * @return {{chars1: string, chars2: string, lineArray: !Array.<string>}}
+        *     An object containing the encoded text1, the encoded text2 and
+        *     the array of unique strings.
+        *     The zeroth element of the array of unique strings is intentionally blank.
+        * @private
+        */
+       DiffMatchPatch.prototype.diffLinesToChars = function( text1, text2 ) {
+               var lineArray, lineHash, chars1, chars2;
+               lineArray = []; // E.g. lineArray[4] === 'Hello\n'
+               lineHash = {};  // E.g. lineHash['Hello\n'] === 4
 
-       assertLi = document.createElement( "li" );
-       assertLi.className = details.result ? "pass" : "fail";
-       assertLi.innerHTML = message;
-       assertList.appendChild( assertLi );
-});
+               // '\x00' is a valid character, but various debuggers don't like it.
+               // So we'll insert a junk entry to avoid generating a null character.
+               lineArray[ 0 ] = "";
 
-QUnit.testDone(function( details ) {
-       var testTitle, time, testItem, assertList,
-               good, bad, testCounts, skipped, sourceName,
-               tests = id( "qunit-tests" );
+               /**
+                * Split a text into an array of strings.  Reduce the texts to a string of
+                * hashes where each Unicode character represents one line.
+                * Modifies linearray and linehash through being a closure.
+                * @param {string} text String to encode.
+                * @return {string} Encoded string.
+                * @private
+                */
+               function diffLinesToCharsMunge( text ) {
+                       var chars, lineStart, lineEnd, lineArrayLength, line;
+                       chars = "";
 
-       if ( !tests ) {
-               return;
-       }
+                       // Walk the text, pulling out a substring for each line.
+                       // text.split('\n') would would temporarily double our memory footprint.
+                       // Modifying text would create many large strings to garbage collect.
+                       lineStart = 0;
+                       lineEnd = -1;
 
-       testItem = id( "qunit-test-output-" + details.testId );
+                       // Keeping our own length variable is faster than looking it up.
+                       lineArrayLength = lineArray.length;
+                       while ( lineEnd < text.length - 1 ) {
+                               lineEnd = text.indexOf( "\n", lineStart );
+                               if ( lineEnd === -1 ) {
+                                       lineEnd = text.length - 1;
+                               }
+                               line = text.substring( lineStart, lineEnd + 1 );
+                               lineStart = lineEnd + 1;
 
-       assertList = testItem.getElementsByTagName( "ol" )[ 0 ];
+                               if ( lineHash.hasOwnProperty ? lineHash.hasOwnProperty( line ) :
+                                                       ( lineHash[ line ] !== undefined ) ) {
+                                       chars += String.fromCharCode( lineHash[ line ] );
+                               } else {
+                                       chars += String.fromCharCode( lineArrayLength );
+                                       lineHash[ line ] = lineArrayLength;
+                                       lineArray[ lineArrayLength++ ] = line;
+                               }
+                       }
+                       return chars;
+               }
 
-       good = details.passed;
-       bad = details.failed;
+               chars1 = diffLinesToCharsMunge( text1 );
+               chars2 = diffLinesToCharsMunge( text2 );
+               return {
+                       chars1: chars1,
+                       chars2: chars2,
+                       lineArray: lineArray
+               };
+       };
 
-       // store result when possible
-       if ( config.reorder && defined.sessionStorage ) {
-               if ( bad ) {
-                       sessionStorage.setItem( "qunit-test-" + details.module + "-" + details.name, bad );
-               } else {
-                       sessionStorage.removeItem( "qunit-test-" + details.module + "-" + details.name );
+       /**
+        * Rehydrate the text in a diff from a string of line hashes to real lines of
+        * text.
+        * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
+        * @param {!Array.<string>} lineArray Array of unique strings.
+        * @private
+        */
+       DiffMatchPatch.prototype.diffCharsToLines = function( diffs, lineArray ) {
+               var x, chars, text, y;
+               for ( x = 0; x < diffs.length; x++ ) {
+                       chars = diffs[ x ][ 1 ];
+                       text = [];
+                       for ( y = 0; y < chars.length; y++ ) {
+                               text[ y ] = lineArray[ chars.charCodeAt( y ) ];
+                       }
+                       diffs[ x ][ 1 ] = text.join( "" );
                }
-       }
+       };
 
-       if ( bad === 0 ) {
+       /**
+        * Reorder and merge like edit sections.  Merge equalities.
+        * Any edit section can move as long as it doesn't cross an equality.
+        * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
+        */
+       DiffMatchPatch.prototype.diffCleanupMerge = function( diffs ) {
+               var pointer, countDelete, countInsert, textInsert, textDelete,
+                       commonlength, changes, diffPointer, position;
+               diffs.push( [ DIFF_EQUAL, "" ] ); // Add a dummy entry at the end.
+               pointer = 0;
+               countDelete = 0;
+               countInsert = 0;
+               textDelete = "";
+               textInsert = "";
+               commonlength;
+               while ( pointer < diffs.length ) {
+                       switch ( diffs[ pointer ][ 0 ] ) {
+                       case DIFF_INSERT:
+                               countInsert++;
+                               textInsert += diffs[ pointer ][ 1 ];
+                               pointer++;
+                               break;
+                       case DIFF_DELETE:
+                               countDelete++;
+                               textDelete += diffs[ pointer ][ 1 ];
+                               pointer++;
+                               break;
+                       case DIFF_EQUAL:
 
-               // Collapse the passing tests
-               addClass( assertList, "qunit-collapsed" );
-       } else if ( bad && config.collapse && !collapseNext ) {
+                               // Upon reaching an equality, check for prior redundancies.
+                               if ( countDelete + countInsert > 1 ) {
+                                       if ( countDelete !== 0 && countInsert !== 0 ) {
 
-               // Skip collapsing the first failing test
-               collapseNext = true;
-       } else {
+                                               // Factor out any common prefixes.
+                                               commonlength = this.diffCommonPrefix( textInsert, textDelete );
+                                               if ( commonlength !== 0 ) {
+                                                       if ( ( pointer - countDelete - countInsert ) > 0 &&
+                                                                       diffs[ pointer - countDelete - countInsert - 1 ][ 0 ] ===
+                                                                       DIFF_EQUAL ) {
+                                                               diffs[ pointer - countDelete - countInsert - 1 ][ 1 ] +=
+                                                                       textInsert.substring( 0, commonlength );
+                                                       } else {
+                                                               diffs.splice( 0, 0, [ DIFF_EQUAL,
+                                                                       textInsert.substring( 0, commonlength )
+                                                               ] );
+                                                               pointer++;
+                                                       }
+                                                       textInsert = textInsert.substring( commonlength );
+                                                       textDelete = textDelete.substring( commonlength );
+                                               }
 
-               // Collapse remaining tests
-               addClass( assertList, "qunit-collapsed" );
-       }
+                                               // Factor out any common suffixies.
+                                               commonlength = this.diffCommonSuffix( textInsert, textDelete );
+                                               if ( commonlength !== 0 ) {
+                                                       diffs[ pointer ][ 1 ] = textInsert.substring( textInsert.length -
+                                                                       commonlength ) + diffs[ pointer ][ 1 ];
+                                                       textInsert = textInsert.substring( 0, textInsert.length -
+                                                               commonlength );
+                                                       textDelete = textDelete.substring( 0, textDelete.length -
+                                                               commonlength );
+                                               }
+                                       }
 
-       // testItem.firstChild is the test name
-       testTitle = testItem.firstChild;
+                                       // Delete the offending records and add the merged ones.
+                                       if ( countDelete === 0 ) {
+                                               diffs.splice( pointer - countInsert,
+                                                       countDelete + countInsert, [ DIFF_INSERT, textInsert ] );
+                                       } else if ( countInsert === 0 ) {
+                                               diffs.splice( pointer - countDelete,
+                                                       countDelete + countInsert, [ DIFF_DELETE, textDelete ] );
+                                       } else {
+                                               diffs.splice(
+                                                       pointer - countDelete - countInsert,
+                                                       countDelete + countInsert,
+                                                       [ DIFF_DELETE, textDelete ], [ DIFF_INSERT, textInsert ]
+                                               );
+                                       }
+                                       pointer = pointer - countDelete - countInsert +
+                                               ( countDelete ? 1 : 0 ) + ( countInsert ? 1 : 0 ) + 1;
+                               } else if ( pointer !== 0 && diffs[ pointer - 1 ][ 0 ] === DIFF_EQUAL ) {
 
-       testCounts = bad ?
-               "<b class='failed'>" + bad + "</b>, " + "<b class='passed'>" + good + "</b>, " :
-               "";
+                                       // Merge this equality with the previous one.
+                                       diffs[ pointer - 1 ][ 1 ] += diffs[ pointer ][ 1 ];
+                                       diffs.splice( pointer, 1 );
+                               } else {
+                                       pointer++;
+                               }
+                               countInsert = 0;
+                               countDelete = 0;
+                               textDelete = "";
+                               textInsert = "";
+                               break;
+                       }
+               }
+               if ( diffs[ diffs.length - 1 ][ 1 ] === "" ) {
+                       diffs.pop(); // Remove the dummy entry at the end.
+               }
 
-       testTitle.innerHTML += " <b class='counts'>(" + testCounts +
-               details.assertions.length + ")</b>";
+               // Second pass: look for single edits surrounded on both sides by equalities
+               // which can be shifted sideways to eliminate an equality.
+               // e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
+               changes = false;
+               pointer = 1;
 
-       if ( details.skipped ) {
-               testItem.className = "skipped";
-               skipped = document.createElement( "em" );
-               skipped.className = "qunit-skipped-label";
-               skipped.innerHTML = "skipped";
-               testItem.insertBefore( skipped, testTitle );
-       } else {
-               addEvent( testTitle, "click", function() {
-                       toggleClass( assertList, "qunit-collapsed" );
-               });
+               // Intentionally ignore the first and last element (don't need checking).
+               while ( pointer < diffs.length - 1 ) {
+                       if ( diffs[ pointer - 1 ][ 0 ] === DIFF_EQUAL &&
+                                       diffs[ pointer + 1 ][ 0 ] === DIFF_EQUAL ) {
 
-               testItem.className = bad ? "fail" : "pass";
+                               diffPointer = diffs[ pointer ][ 1 ];
+                               position = diffPointer.substring(
+                                       diffPointer.length - diffs[ pointer - 1 ][ 1 ].length
+                               );
 
-               time = document.createElement( "span" );
-               time.className = "runtime";
-               time.innerHTML = details.runtime + " ms";
-               testItem.insertBefore( time, assertList );
-       }
+                               // This is a single edit surrounded by equalities.
+                               if ( position === diffs[ pointer - 1 ][ 1 ] ) {
 
-       // Show the source of the test when showing assertions
-       if ( details.source ) {
-               sourceName = document.createElement( "p" );
-               sourceName.innerHTML = "<strong>Source: </strong>" + details.source;
-               addClass( sourceName, "qunit-source" );
-               if ( bad === 0 ) {
-                       addClass( sourceName, "qunit-collapsed" );
+                                       // Shift the edit over the previous equality.
+                                       diffs[ pointer ][ 1 ] = diffs[ pointer - 1 ][ 1 ] +
+                                               diffs[ pointer ][ 1 ].substring( 0, diffs[ pointer ][ 1 ].length -
+                                                       diffs[ pointer - 1 ][ 1 ].length );
+                                       diffs[ pointer + 1 ][ 1 ] =
+                                               diffs[ pointer - 1 ][ 1 ] + diffs[ pointer + 1 ][ 1 ];
+                                       diffs.splice( pointer - 1, 1 );
+                                       changes = true;
+                               } else if ( diffPointer.substring( 0, diffs[ pointer + 1 ][ 1 ].length ) ===
+                                               diffs[ pointer + 1 ][ 1 ] ) {
+
+                                       // Shift the edit over the next equality.
+                                       diffs[ pointer - 1 ][ 1 ] += diffs[ pointer + 1 ][ 1 ];
+                                       diffs[ pointer ][ 1 ] =
+                                               diffs[ pointer ][ 1 ].substring( diffs[ pointer + 1 ][ 1 ].length ) +
+                                               diffs[ pointer + 1 ][ 1 ];
+                                       diffs.splice( pointer + 1, 1 );
+                                       changes = true;
+                               }
+                       }
+                       pointer++;
                }
-               addEvent( testTitle, "click", function() {
-                       toggleClass( sourceName, "qunit-collapsed" );
-               });
-               testItem.appendChild( sourceName );
-       }
-});
 
-if ( defined.document ) {
+               // If shifts were made, the diff needs reordering and another shift sweep.
+               if ( changes ) {
+                       this.diffCleanupMerge( diffs );
+               }
+       };
 
-       // Avoid readyState issue with phantomjs
-       // Ref: #818
-       var notPhantom = ( function( p ) {
-               return !( p && p.version && p.version.major > 0 );
-       } )( window.phantom );
+       return function( o, n ) {
+               var diff, output, text;
+               diff = new DiffMatchPatch();
+               output = diff.DiffMain( o, n );
+               diff.diffCleanupEfficiency( output );
+               text = diff.diffPrettyHtml( output );
 
-       if ( notPhantom && document.readyState === "complete" ) {
-               QUnit.load();
-       } else {
-               addEvent( window, "load", QUnit.load );
-       }
-} else {
-       config.pageLoaded = true;
-       config.autorun = true;
-}
+               return text;
+       };
+}() );
 
-})();
+}() );
index 676ecca..9688f1f 100644 (file)
@@ -26,9 +26,9 @@
 // Orange; for contextual use of returning to a past action
 @colorRegressive: #ff5d00;
 // Red; for contextual use of a negative action of high severity
-@colorDestructive: #c33;
-@colorDestructiveHighlight: #e53939;
-@colorDestructiveActive: #873636;
+@colorDestructive: #d33;
+@colorDestructiveHighlight: #ff4242;
+@colorDestructiveActive: #b32424;
 // Orange; for contextual use of a potentially negative action of medium severity
 @colorMediumSevere: #ff5d00;
 // Yellow; for contextual use of a potentially negative action of low severity
diff --git a/resources/src/mediawiki.widgets/MediaSearch/broken-image.png b/resources/src/mediawiki.widgets/MediaSearch/broken-image.png
new file mode 100644 (file)
index 0000000..f5be958
Binary files /dev/null and b/resources/src/mediawiki.widgets/MediaSearch/broken-image.png differ
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.APIResultsProvider.js b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.APIResultsProvider.js
new file mode 100644 (file)
index 0000000..dd07b92
--- /dev/null
@@ -0,0 +1,229 @@
+/*!
+ * MediaWiki Widgets - APIResultsProvider class.
+ *
+ * @copyright 2011-2016 VisualEditor Team and others; see http://ve.mit-license.org
+ */
+( function ( $, mw ) {
+
+       /**
+        * API Results Provider object.
+        *
+        * @class
+        * @mixins OO.EventEmitter
+        *
+        * @constructor
+        * @param {string} apiurl The URL to the api
+        * @param {Object} [config] Configuration options
+        * @cfg {number} fetchLimit The default number of results to fetch
+        * @cfg {string} lang The language of the API
+        * @cfg {number} offset Initial offset, if relevant, to call results from
+        * @cfg {Object} ajaxSettings The settings for the ajax call
+        * @cfg {Object} staticParams The data parameters that are static and should
+        *  always be sent to the API request, as opposed to user parameters.
+        * @cfg {Object} userParams Initial user parameters to be sent as data to
+        *  the API request. These can change per request, like the search query term
+        *  or sizing parameters for images, etc.
+        */
+       mw.widgets.APIResultsProvider = function MwWidgetsAPIResultsProvider( apiurl, config ) {
+               config = config || {};
+
+               this.setAPIurl( apiurl );
+               this.setDefaultFetchLimit( config.fetchLimit || 30 );
+               this.setLang( config.lang );
+               this.setOffset( config.offset || 0 );
+               this.setAjaxSettings( config.ajaxSettings || {} );
+
+               this.staticParams = config.staticParams || {};
+               this.userParams = config.userParams || {};
+
+               this.toggleDepleted( false );
+
+               // Mixin constructors
+               OO.EventEmitter.call( this );
+       };
+
+       /* Setup */
+       OO.mixinClass( mw.widgets.APIResultsProvider, OO.EventEmitter );
+
+       /* Methods */
+
+       /**
+        * Get results from the source
+        *
+        * @param {number} howMany Number of results to ask for
+        * @return {jQuery.Promise} Promise that is resolved into an array
+        * of available results, or is rejected if no results are available.
+        */
+       mw.widgets.APIResultsProvider.prototype.getResults = function () {
+               var xhr,
+                       deferred = $.Deferred(),
+                       allParams = $.extend( {}, this.getStaticParams(), this.getUserParams() );
+
+               xhr = $.getJSON( this.getAPIurl(), allParams )
+                       .done( function ( data ) {
+                               if (
+                                       $.type( data ) !== 'array' ||
+                                       (
+                                               $.type( data ) === 'array' &&
+                                               data.length === 0
+                                       )
+                               ) {
+                                       deferred.resolve();
+                               } else {
+                                       deferred.resolve( data );
+                               }
+                       } );
+               return deferred.promise( { abort: xhr.abort } );
+       };
+
+       /**
+        * Set API url
+        *
+        * @param {string} apiurl API url
+        */
+       mw.widgets.APIResultsProvider.prototype.setAPIurl = function ( apiurl ) {
+               this.apiurl = apiurl;
+       };
+
+       /**
+        * Set api url
+        *
+        * @return {string} API url
+        */
+       mw.widgets.APIResultsProvider.prototype.getAPIurl = function () {
+               return this.apiurl;
+       };
+
+       /**
+        * Get the static, non-changing data parameters sent to the API
+        *
+        * @return {Object} Data parameters
+        */
+       mw.widgets.APIResultsProvider.prototype.getStaticParams = function () {
+               return this.staticParams;
+       };
+
+       /**
+        * Get the user-inputted dynamic data parameters sent to the API
+        *
+        * @return {Object} Data parameters
+        */
+       mw.widgets.APIResultsProvider.prototype.getUserParams = function () {
+               return this.userParams;
+       };
+
+       /**
+        * Set the data parameters sent to the API
+        *
+        * @param {Object} params User defined data parameters
+        */
+       mw.widgets.APIResultsProvider.prototype.setUserParams = function ( params ) {
+               // Asymmetrically compare (params is subset of this.userParams)
+               if ( !OO.compare( params, this.userParams, true ) ) {
+                       this.userParams = $.extend( {}, this.userParams, params );
+                       this.reset();
+               }
+       };
+
+       /**
+        * Reset the provider
+        */
+       mw.widgets.APIResultsProvider.prototype.reset = function () {
+               // Reset offset
+               this.setOffset( 0 );
+               // Reset depleted status
+               this.toggleDepleted( false );
+       };
+
+       /**
+        * Get fetch limit or 'page' size. This is the number
+        * of results per request.
+        *
+        * @return {number} limit
+        */
+       mw.widgets.APIResultsProvider.prototype.getDefaultFetchLimit = function () {
+               return this.limit;
+       };
+
+       /**
+        * Set limit
+        *
+        * @param {number} limit Default number of results to fetch from the API
+        */
+       mw.widgets.APIResultsProvider.prototype.setDefaultFetchLimit = function ( limit ) {
+               this.limit = limit;
+       };
+
+       /**
+        * Get provider API language
+        *
+        * @return {string} Provider API language
+        */
+       mw.widgets.APIResultsProvider.prototype.getLang = function () {
+               return this.lang;
+       };
+
+       /**
+        * Set provider API language
+        *
+        * @param {string} lang Provider API language
+        */
+       mw.widgets.APIResultsProvider.prototype.setLang = function ( lang ) {
+               this.lang = lang;
+       };
+
+       /**
+        * Get result offset
+        *
+        * @return {number} Offset Results offset for the upcoming request
+        */
+       mw.widgets.APIResultsProvider.prototype.getOffset = function () {
+               return this.offset;
+       };
+
+       /**
+        * Set result offset
+        *
+        * @param {number} offset Results offset for the upcoming request
+        */
+       mw.widgets.APIResultsProvider.prototype.setOffset = function ( offset ) {
+               this.offset = offset;
+       };
+
+       /**
+        * Check whether the provider is depleted and has no more results
+        * to hand off.
+        *
+        * @return {boolean} The provider is depleted
+        */
+       mw.widgets.APIResultsProvider.prototype.isDepleted = function () {
+               return this.depleted;
+       };
+
+       /**
+        * Toggle depleted state
+        *
+        * @param {boolean} isDepleted The provider is depleted
+        */
+       mw.widgets.APIResultsProvider.prototype.toggleDepleted = function ( isDepleted ) {
+               this.depleted = isDepleted !== undefined ? isDepleted : !this.depleted;
+       };
+
+       /**
+        * Get the default ajax settings
+        *
+        * @return {Object} Ajax settings
+        */
+       mw.widgets.APIResultsProvider.prototype.getAjaxSettings = function () {
+               return this.ajaxSettings;
+       };
+
+       /**
+        * Get the default ajax settings
+        *
+        * @param {Object} settings Ajax settings
+        */
+       mw.widgets.APIResultsProvider.prototype.setAjaxSettings = function ( settings ) {
+               this.ajaxSettings = settings;
+       };
+}( jQuery, mediaWiki ) );
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.APIResultsQueue.js b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.APIResultsQueue.js
new file mode 100644 (file)
index 0000000..3bc1d51
--- /dev/null
@@ -0,0 +1,224 @@
+/*!
+ * MediaWiki Widgets - APIResultsQueue class.
+ *
+ * @copyright 2011-2016 VisualEditor Team and others; see http://ve.mit-license.org
+ */
+( function ( $, mw ) {
+
+       /**
+        * API Results Queue object.
+        *
+        * @class
+        * @mixins OO.EventEmitter
+        *
+        * @constructor
+        * @param {Object} [config] Configuration options
+        * @cfg {number} limit The default number of results to fetch
+        * @cfg {number} threshold The default number of extra results
+        *  that the queue should always strive to have on top of the
+        *  individual requests for items.
+        */
+       mw.widgets.APIResultsQueue = function MwWidgetsAPIResultsQueue( config ) {
+               config = config || {};
+
+               this.fileRepoPromise = null;
+               this.providers = [];
+               this.providerPromises = [];
+               this.queue = [];
+
+               this.params = {};
+
+               this.limit = config.limit || 20;
+               this.setThreshold( config.threshold || 10 );
+
+               // Mixin constructors
+               OO.EventEmitter.call( this );
+       };
+
+       /* Setup */
+       OO.mixinClass( mw.widgets.APIResultsQueue, OO.EventEmitter );
+
+       /* Methods */
+
+       /**
+        * Set up the queue and its resources.
+        * This should be overridden if there are any setup steps to perform.
+        *
+        * @return {jQuery.Promise} Promise that resolves when the resources
+        *  are set up. Note: The promise must have an .abort() functionality.
+        */
+       mw.widgets.APIResultsQueue.prototype.setup = function () {
+               return $.Deferred().resolve().promise( { abort: $.noop } );
+       };
+
+       /**
+        * Get items from the queue
+        *
+        * @param {number} [howMany] How many items to retrieve. Defaults to the
+        *  default limit supplied on initialization.
+        * @return {jQuery.Promise} Promise that resolves into an array of items.
+        */
+       mw.widgets.APIResultsQueue.prototype.get = function ( howMany ) {
+               var fetchingPromise = null,
+                       me = this;
+
+               howMany = howMany || this.limit;
+
+               // Check if the queue has enough items
+               if ( this.queue.length < howMany + this.threshold ) {
+                       // Call for more results
+                       fetchingPromise = this.queryProviders( howMany + this.threshold )
+                               .then( function ( items ) {
+                                       // Add to the queue
+                                       me.queue = me.queue.concat.apply( me.queue, items );
+                               } );
+               }
+
+               return $.when( fetchingPromise )
+                       .then( function () {
+                               return me.queue.splice( 0, howMany );
+                       } );
+
+       };
+
+       /**
+        * Get results from all providers
+        *
+        * @param {number} [howMany] How many items to retrieve. Defaults to the
+        *  default limit supplied on initialization.
+        * @return {jQuery.Promise} Promise that is resolved into an array
+        *  of fetched items. Note: The promise must have an .abort() functionality.
+        */
+       mw.widgets.APIResultsQueue.prototype.queryProviders = function ( howMany ) {
+               var i, len,
+                       queue = this;
+
+               // Make sure there are resources set up
+               return this.setup()
+                       .then( function () {
+                               // Abort previous requests
+                               for ( i = 0, len = queue.providerPromises.length; i < len; i++ ) {
+                                       queue.providerPromises[ i ].abort();
+                               }
+                               queue.providerPromises = [];
+                               // Set up the query to all providers
+                               for ( i = 0, len = queue.providers.length; i < len; i++ ) {
+                                       if ( !queue.providers[ i ].isDepleted() ) {
+                                               queue.providerPromises.push(
+                                                       queue.providers[ i ].getResults( howMany )
+                                               );
+                                       }
+                               }
+
+                               return $.when.apply( $, queue.providerPromises )
+                                       .then( Array.prototype.concat.bind( [] ) );
+                       } );
+       };
+
+       /**
+        * Set the search query for all the providers.
+        *
+        * This also makes sure to abort any previous promises.
+        *
+        * @param {Object} params API search parameters
+        */
+       mw.widgets.APIResultsQueue.prototype.setParams = function ( params ) {
+               var i, len;
+               if ( !OO.compare( params, this.params, true ) ) {
+                       this.reset();
+                       this.params = $.extend( this.params, params );
+                       // Reset queue
+                       this.queue = [];
+                       // Reset promises
+                       for ( i = 0, len = this.providerPromises.length; i < len; i++ ) {
+                               this.providerPromises[ i ].abort();
+                       }
+                       // Change queries
+                       for ( i = 0, len = this.providers.length; i < len; i++ ) {
+                               this.providers[ i ].setUserParams( this.params );
+                       }
+               }
+       };
+
+       /**
+        * Reset the queue and all its providers
+        */
+       mw.widgets.APIResultsQueue.prototype.reset = function () {
+               var i, len;
+               // Reset queue
+               this.queue = [];
+               // Reset promises
+               for ( i = 0, len = this.providerPromises.length; i < len; i++ ) {
+                       this.providerPromises[ i ].abort();
+               }
+               // Change queries
+               for ( i = 0, len = this.providers.length; i < len; i++ ) {
+                       this.providers[ i ].reset();
+               }
+       };
+
+       /**
+        * Get the data parameters sent to the API
+        *
+        * @return {Object} params API search parameters
+        */
+       mw.widgets.APIResultsQueue.prototype.getParams = function () {
+               return this.params;
+       };
+
+       /**
+        * Set the providers
+        *
+        * @param {mw.widgets.APIResultsProvider[]} providers An array of providers
+        */
+       mw.widgets.APIResultsQueue.prototype.setProviders = function ( providers ) {
+               this.providers = providers;
+       };
+
+       /**
+        * Add a provider to the group
+        *
+        * @param {mw.widgets.APIResultsProvider} provider A provider object
+        */
+       mw.widgets.APIResultsQueue.prototype.addProvider = function ( provider ) {
+               this.providers.push( provider );
+       };
+
+       /**
+        * Set the providers
+        *
+        * @return {mw.widgets.APIResultsProvider[]} providers An array of providers
+        */
+       mw.widgets.APIResultsQueue.prototype.getProviders = function () {
+               return this.providers;
+       };
+
+       /**
+        * Get the queue size
+        *
+        * @return {number} Queue size
+        */
+       mw.widgets.APIResultsQueue.prototype.getQueueSize = function () {
+               return this.queue.length;
+       };
+
+       /**
+        * Set queue threshold
+        *
+        * @param {number} threshold Queue threshold, below which we will
+        *  request more items
+        */
+       mw.widgets.APIResultsQueue.prototype.setThreshold = function ( threshold ) {
+               this.threshold = threshold;
+       };
+
+       /**
+        * Get queue threshold
+        *
+        * @return {number} threshold Queue threshold, below which we will
+        *  request more items
+        */
+       mw.widgets.APIResultsQueue.prototype.getThreshold = function () {
+               return this.threshold;
+       };
+}( jQuery, mediaWiki ) );
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResourceProvider.js b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResourceProvider.js
new file mode 100644 (file)
index 0000000..d767109
--- /dev/null
@@ -0,0 +1,322 @@
+/*!
+ * MediaWiki Widgets - MediaResourceProvider class.
+ *
+ * @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+( function ( $, mw ) {
+
+       /**
+        * MediaWiki media resource provider.
+        *
+        * @class
+        * @extends mw.widgets.APIResultsProvider
+        *
+        * @constructor
+        * @param {string} apiurl The API url
+        * @param {Object} [config] Configuration options
+        * @cfg {string} [scriptDirUrl] The url of the API script
+        */
+       mw.widgets.MediaResourceProvider = function MwWidgetsMediaResourceProvider( apiurl, config ) {
+               config = config || {};
+
+               // Parent constructor
+               mw.widgets.MediaResourceProvider.super.call( this, apiurl, config );
+
+               // Fetching configuration
+               this.scriptDirUrl = config.scriptDirUrl;
+               this.isLocal = config.local !== undefined;
+
+               if ( this.isLocal ) {
+                       this.setAPIurl( mw.util.wikiScript( 'api' ) );
+               } else {
+                       // If 'apiurl' is set, use that. Otherwise, build the url
+                       // from scriptDirUrl and /api.php suffix
+                       this.setAPIurl( this.getAPIurl() || ( this.scriptDirUrl + '/api.php' ) );
+               }
+
+               this.siteInfoPromise = null;
+               this.thumbSizes = [];
+               this.imageSizes = [];
+       };
+
+       /* Inheritance */
+       OO.inheritClass( mw.widgets.MediaResourceProvider, mw.widgets.APIResultsProvider );
+
+       /* Methods */
+
+       /**
+        * @inheritdoc
+        */
+       mw.widgets.MediaResourceProvider.prototype.getStaticParams = function () {
+               return $.extend(
+                       {},
+                       // Parent method
+                       mw.widgets.MediaResourceProvider.super.prototype.getStaticParams.call( this ),
+                       {
+                               action: 'query',
+                               iiprop: 'dimensions|url|mediatype|extmetadata|timestamp|user',
+                               iiextmetadatalanguage: this.getLang(),
+                               prop: 'imageinfo'
+                       }
+               );
+       };
+
+       /**
+        * Initialize the source and get the site info.
+        *
+        * Connect to the api url and retrieve the siteinfo parameters
+        * that are required for fetching results.
+        *
+        * @return {jQuery.Promise} Promise that resolves when the class
+        * properties are set.
+        */
+       mw.widgets.MediaResourceProvider.prototype.loadSiteInfo = function () {
+               var provider = this;
+
+               if ( !this.siteInfoPromise ) {
+                       this.siteInfoPromise = new mw.Api().get( {
+                               action: 'query',
+                               meta: 'siteinfo'
+                       } )
+                               .then( function ( data ) {
+                                       provider.setImageSizes( data.query.general.imagelimits || [] );
+                                       provider.setThumbSizes( data.query.general.thumblimits || [] );
+                                       provider.setUserParams( {
+                                               // Standard width per resource
+                                               iiurlwidth: provider.getStandardWidth()
+                                       } );
+                               } );
+               }
+               return this.siteInfoPromise;
+       };
+
+       /**
+        * Override parent method and get results from the source
+        *
+        * @param {number} [howMany] The number of items to pull from the API
+        * @return {jQuery.Promise} Promise that is resolved into an array
+        * of available results, or is rejected if no results are available.
+        */
+       mw.widgets.MediaResourceProvider.prototype.getResults = function ( howMany ) {
+               var xhr,
+                       aborted = false,
+                       provider = this;
+
+               return this.loadSiteInfo()
+                       .then( function () {
+                               if ( aborted ) {
+                                       return $.Deferred().reject();
+                               }
+                               xhr = provider.fetchAPIresults( howMany );
+                               return xhr;
+                       } )
+                       .then(
+                               function ( results ) {
+                                       if ( !results || results.length === 0 ) {
+                                               provider.toggleDepleted( true );
+                                               return [];
+                                       }
+                                       return results;
+                               },
+                               // Process failed, return an empty promise
+                               function () {
+                                       provider.toggleDepleted( true );
+                                       return $.Deferred().resolve( [] );
+                               }
+                       )
+                       .promise( { abort: function () {
+                               aborted = true;
+                               if ( xhr ) {
+                                       xhr.abort();
+                               }
+                       } } );
+       };
+
+       /**
+        * Get continuation API data
+        *
+        * @param {number} howMany The number of results to retrieve
+        * @return {Object} API request data
+        */
+       mw.widgets.MediaResourceProvider.prototype.getContinueData = function () {
+               return {};
+       };
+
+       /**
+        * Set continuation data for the next page
+        *
+        * @param {Object} continueData Continuation data
+        */
+       mw.widgets.MediaResourceProvider.prototype.setContinue = function () {
+       };
+
+       /**
+        * Sort the results
+        *
+        * @param {Object[]} results API results
+        * @return {Object[]} Sorted results
+        */
+       mw.widgets.MediaResourceProvider.prototype.sort = function ( results ) {
+               return results;
+       };
+
+       /**
+        * Call the API for search results.
+        *
+        * @param {number} howMany The number of results to retrieve
+        * @return {jQuery.Promise} Promise that resolves with an array of objects that contain
+        *  the fetched data.
+        */
+       mw.widgets.MediaResourceProvider.prototype.fetchAPIresults = function ( howMany ) {
+               var xhr, api,
+                       provider = this;
+
+               if ( !this.isValid() ) {
+                       return $.Deferred().reject().promise( { abort: $.noop } );
+               }
+
+               api = this.isLocal ? new mw.Api() : new mw.ForeignApi( this.getAPIurl(), { anonymous: true } );
+               xhr = api.get( $.extend( {}, this.getStaticParams(), this.getUserParams(), this.getContinueData( howMany ) ) );
+               return xhr
+                       .then( function ( data ) {
+                               var page, newObj, raw,
+                                       results = [];
+
+                               if ( data.error ) {
+                                       provider.toggleDepleted( true );
+                                       return [];
+                               }
+
+                               if ( data.continue ) {
+                                       // Update the offset for next time
+                                       provider.setContinue( data.continue );
+                               } else {
+                                       // This is the last available set of results. Mark as depleted!
+                                       provider.toggleDepleted( true );
+                               }
+
+                               // If the source returned no results, it will not have a
+                               // query property
+                               if ( data.query ) {
+                                       raw = data.query.pages;
+                                       if ( raw ) {
+                                               // Strip away the page ids
+                                               for ( page in raw ) {
+                                                       if ( !raw[ page ].imageinfo ) {
+                                                               // The search may give us pages that belong to the File:
+                                                               // namespace but have no files in them, either because
+                                                               // they were deleted or imported wrongly, or just started
+                                                               // as pages. In that case, the response will not include
+                                                               // imageinfo. Skip those files.
+                                                               continue;
+                                                       }
+                                                       newObj = raw[ page ].imageinfo[ 0 ];
+                                                       newObj.title = raw[ page ].title;
+                                                       newObj.index = raw[ page ].index;
+                                                       results.push( newObj );
+                                               }
+                                       }
+                               }
+                               return provider.sort( results );
+                       } )
+                       .promise( { abort: xhr.abort } );
+       };
+
+       /**
+        * Set name
+        *
+        * @param {string} name
+        */
+       mw.widgets.MediaResourceProvider.prototype.setName = function ( name ) {
+               this.name = name;
+       };
+
+       /**
+        * Get name
+        *
+        * @return {string} name
+        */
+       mw.widgets.MediaResourceProvider.prototype.getName = function () {
+               return this.name;
+       };
+
+       /**
+        * Get standard width, based on the provider source's thumb sizes.
+        *
+        * @return {number|undefined} fetchWidth
+        */
+       mw.widgets.MediaResourceProvider.prototype.getStandardWidth = function () {
+               return ( this.thumbSizes && this.thumbSizes[ this.thumbSizes.length - 1 ] ) ||
+                       ( this.imageSizes && this.imageSizes[ 0 ] ) ||
+                       // Fall back on a number
+                       300;
+       };
+
+       /**
+        * Get prop
+        *
+        * @return {string} prop
+        */
+       mw.widgets.MediaResourceProvider.prototype.getFetchProp = function () {
+               return this.fetchProp;
+       };
+
+       /**
+        * Set prop
+        *
+        * @param {string} prop
+        */
+       mw.widgets.MediaResourceProvider.prototype.setFetchProp = function ( prop ) {
+               this.fetchProp = prop;
+       };
+
+       /**
+        * Set thumb sizes
+        *
+        * @param {number[]} sizes Available thumbnail sizes
+        */
+       mw.widgets.MediaResourceProvider.prototype.setThumbSizes = function ( sizes ) {
+               this.thumbSizes = sizes;
+       };
+
+       /**
+        * Set image sizes
+        *
+        * @param {number[]} sizes Available image sizes
+        */
+       mw.widgets.MediaResourceProvider.prototype.setImageSizes = function ( sizes ) {
+               this.imageSizes = sizes;
+       };
+
+       /**
+        * Get thumb sizes
+        *
+        * @return {number[]} sizes Available thumbnail sizes
+        */
+       mw.widgets.MediaResourceProvider.prototype.getThumbSizes = function () {
+               return this.thumbSizes;
+       };
+
+       /**
+        * Get image sizes
+        *
+        * @return {number[]} sizes Available image sizes
+        */
+       mw.widgets.MediaResourceProvider.prototype.getImageSizes = function () {
+               return this.imageSizes;
+       };
+
+       /**
+        * Check if this source is valid.
+        *
+        * @return {boolean} Source is valid
+        */
+       mw.widgets.MediaResourceProvider.prototype.isValid = function () {
+               return this.isLocal ||
+                       // If we don't have either 'apiurl' or 'scriptDirUrl'
+                       // the source is invalid, and we will skip it
+                       this.apiurl !== undefined ||
+                       this.scriptDirUrl !== undefined;
+       };
+}( jQuery, mediaWiki ) );
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResourceQueue.js b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResourceQueue.js
new file mode 100644 (file)
index 0000000..34fa44b
--- /dev/null
@@ -0,0 +1,68 @@
+/*!
+ * MediaWiki Widgets - MediaResourceQueue class.
+ *
+ * @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+( function ( $, mw ) {
+
+       /**
+        * MediaWiki media resource queue.
+        *
+        * @class
+        * @extends mw.widgets.APIResultsQueue
+        *
+        * @constructor
+        * @param {Object} [config] Configuration options
+        * @cfg {number} maxHeight The maximum height of the media, used in the
+        *  search call to the API.
+        */
+       mw.widgets.MediaResourceQueue = function MwWidgetsMediaResourceQueue( config ) {
+               config = config || {};
+
+               // Parent constructor
+               mw.widgets.MediaResourceQueue.super.call( this, config );
+
+               this.maxHeight = config.maxHeight || 200;
+       };
+
+       /* Inheritance */
+       OO.inheritClass( mw.widgets.MediaResourceQueue, mw.widgets.APIResultsQueue );
+
+       /**
+        * Fetch the file repos.
+        *
+        * @return {jQuery.Promise} Promise that resolves when the resources are set up
+        */
+       mw.widgets.MediaResourceQueue.prototype.getFileRepos = function () {
+               var defaultSource = [ {
+                       url: mw.util.wikiScript( 'api' ),
+                       local: ''
+               } ];
+
+               if ( !this.fileRepoPromise ) {
+                       this.fileRepoPromise = new mw.Api().get( {
+                               action: 'query',
+                               meta: 'filerepoinfo'
+                       } ).then(
+                               function ( resp ) {
+                                       return resp.query && resp.query.repos || defaultSource;
+                               },
+                               function () {
+                                       return $.Deferred().resolve( defaultSource );
+                               }
+                       );
+               }
+
+               return this.fileRepoPromise;
+       };
+
+       /**
+        * Get image maximum height
+        *
+        * @return {string} Image max height
+        */
+       mw.widgets.MediaResourceQueue.prototype.getMaxHeight = function () {
+               return this.maxHeight;
+       };
+}( jQuery, mediaWiki ) );
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResultWidget.css b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResultWidget.css
new file mode 100644 (file)
index 0000000..bc752b5
--- /dev/null
@@ -0,0 +1,89 @@
+/*!
+ * MediaWiki Widgets - MediaResultWidget styles.
+ *
+ * @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+.mw-widget-mediaResultWidget {
+       display: inline-block;
+       position: relative;
+       padding: 0;
+       margin: 2px;
+       overflow: hidden;
+       box-sizing: border-box;
+       text-align: center;
+}
+
+.mw-widget-mediaResultWidget-error {
+       background-color: #f3f3f3;
+}
+
+.mw-widget-mediaResultWidget-thumbnail {
+       opacity: 0;
+       display: inline-block;
+       /* stylelint-disable no-unsupported-browser-features */
+       -webkit-transition: opacity 400ms;
+       -moz-transition: opacity 400ms;
+       transition: opacity 400ms;
+       /* stylelint-enable no-unsupported-browser-features */
+}
+
+.mw-widget-mediaResultWidget-done .mw-widget-mediaResultWidget-thumbnail,
+.mw-widget-mediaResultWidget-error .mw-widget-mediaResultWidget-thumbnail {
+       opacity: 1;
+}
+
+.mw-widget-mediaResultWidget-crop {
+       background-size: cover; /* stylelint-disable-line no-unsupported-browser-features */
+       background-position: center center;
+}
+
+.mw-widget-mediaResultWidget-overlay {
+       position: absolute;
+       top: 0;
+       bottom: 0;
+       left: 0;
+       right: 0;
+       box-shadow: inset 0 0 0 1px #ccc;
+}
+
+.mw-widget-mediaResultWidget.oo-ui-optionWidget-highlighted,
+.mw-widget-mediaResultWidget.oo-ui-optionWidget-selected {
+       box-shadow: 0 0 0.3em #a7dcff, 0 0 0 #fff;
+}
+
+.mw-widget-mediaResultWidget-error .mw-widget-mediaResultWidget-thumbnail {
+       /* @embed */
+       background-image: url( broken-image.png );
+       background-size: auto; /* stylelint-disable-line no-unsupported-browser-features */
+       background-position: center center;
+       background-repeat: no-repeat;
+}
+
+.mw-widget-mediaResultWidget .mw-widget-mediaResultWidget-nameLabel {
+       position: absolute;
+       bottom: 0;
+       left: 0;
+       right: 0;
+       overflow: hidden;
+       padding: 0.5em;
+       color: #fff;
+       text-shadow: 1px 1px #000; /* stylelint-disable-line no-unsupported-browser-features */
+       line-height: 1.125em;
+       background-color: rgba( 0, 0, 0, 0.5 );
+       text-overflow: ellipsis;
+       text-align: left;
+}
+
+.mw-widget-mediaResultWidget.oo-ui-optionWidget-highlighted .mw-widget-mediaResultWidget-nameLabel {
+       background-color: rgba( 0, 0, 0, 0.75 );
+}
+
+.mw-widget-mediaResultWidget.oo-ui-optionWidget-selected .mw-widget-mediaResultWidget-nameLabel {
+       background-color: #000;
+}
+
+.mw-widget-mediaSearchWidget-noresults {
+       padding-top: 1em;
+}
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResultWidget.js b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResultWidget.js
new file mode 100644 (file)
index 0000000..7607e84
--- /dev/null
@@ -0,0 +1,274 @@
+/*!
+ * MediaWiki Widgets - MediaResultWidget class.
+ *
+ * @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+( function ( $, mw ) {
+
+       /**
+        * Creates an mw.widgets.MediaResultWidget object.
+        *
+        * @class
+        * @extends OO.ui.OptionWidget
+        *
+        * @constructor
+        * @param {Object} [config] Configuration options
+        * @cfg {number} [rowHeight] Height of the row this result is part of
+        * @cfg {number} [maxRowWidth] A limit for the width of the row this
+        *  result is a part of.
+        * @cfg {number} [minWidth] Minimum width for the result
+        * @cfg {number} [maxWidth] Maximum width for the result
+        */
+       mw.widgets.MediaResultWidget = function MwWidgetsMediaResultWidget( config ) {
+               // Configuration initialization
+               config = config || {};
+
+               // Parent constructor
+               mw.widgets.MediaResultWidget.super.call( this, config );
+
+               // Properties
+               this.setRowHeight( config.rowHeight || 150 );
+               this.maxRowWidth = config.maxRowWidth || 500;
+               this.minWidth = config.minWidth || this.maxRowWidth / 5;
+               this.maxWidth = config.maxWidth || this.maxRowWidth * 2 / 3;
+
+               this.imageDimensions = {};
+
+               this.isAudio = this.data.mediatype === 'AUDIO';
+
+               // Store the thumbnail url
+               this.thumbUrl = this.data.thumburl;
+               this.src = null;
+               this.row = null;
+
+               this.$thumb = $( '<img>' )
+                       .addClass( 'mw-widget-mediaResultWidget-thumbnail' )
+                       .on( {
+                               load: this.onThumbnailLoad.bind( this ),
+                               error: this.onThumbnailError.bind( this )
+                       } );
+               this.$overlay = $( '<div>' )
+                       .addClass( 'mw-widget-mediaResultWidget-overlay' );
+
+               this.calculateSizing( this.data );
+
+               // Get wiki default thumbnail size
+               this.defaultThumbSize = mw.config.get( 'wgVisualEditorConfig' )
+                       .defaultUserOptions.defaultthumbsize;
+
+               // Initialization
+               this.setLabel( new mw.Title( this.data.title ).getNameText() );
+               this.$label.addClass( 'mw-widget-mediaResultWidget-nameLabel' );
+
+               this.$element
+                       .addClass( 'mw-widget-mediaResultWidget ve-ui-texture-pending' )
+                       .prepend( this.$thumb, this.$overlay );
+       };
+
+       /* Inheritance */
+
+       OO.inheritClass( mw.widgets.MediaResultWidget, OO.ui.OptionWidget );
+
+       /* Static methods */
+
+       // Copied from ve.dm.MWImageNode
+       mw.widgets.MediaResultWidget.static.resizeToBoundingBox = function ( imageDimensions, boundingBox ) {
+               var newDimensions = OO.copy( imageDimensions ),
+                       scale = Math.min(
+                               boundingBox.height / imageDimensions.height,
+                               boundingBox.width / imageDimensions.width
+                       );
+
+               if ( scale < 1 ) {
+                       // Scale down
+                       newDimensions = {
+                               width: Math.floor( newDimensions.width * scale ),
+                               height: Math.floor( newDimensions.height * scale )
+                       };
+               }
+               return newDimensions;
+       };
+
+       /* Methods */
+       /** */
+       mw.widgets.MediaResultWidget.prototype.onThumbnailLoad = function () {
+               this.$thumb.first().addClass( 've-ui-texture-transparency' );
+               this.$element
+                       .addClass( 'mw-widget-mediaResultWidget-done' )
+                       .removeClass( 've-ui-texture-pending' );
+       };
+
+       /** */
+       mw.widgets.MediaResultWidget.prototype.onThumbnailError = function () {
+               this.$thumb.last()
+                       .css( 'background-image', '' )
+                       .addClass( 've-ui-texture-alert' );
+               this.$element
+                       .addClass( 'mw-widget-mediaResultWidget-error' )
+                       .removeClass( 've-ui-texture-pending' );
+       };
+
+       /**
+        * Resize the thumbnail and wrapper according to row height and bounding boxes, if given.
+        *
+        * @param {Object} originalDimensions Original image dimensions with width and height values
+        * @param {Object} [boundingBox] Specific bounding box, if supplied
+        */
+       mw.widgets.MediaResultWidget.prototype.calculateSizing = function ( originalDimensions, boundingBox ) {
+               var wrapperPadding,
+                       imageDimensions = {};
+
+               boundingBox = boundingBox || {};
+
+               if ( this.isAudio ) {
+                       // HACK: We are getting the wrong information from the
+                       // API about audio files. Set their thumbnail to square 120px
+                       imageDimensions = {
+                               width: 120,
+                               height: 120
+                       };
+               } else {
+                       // Get the image within the bounding box
+                       imageDimensions = this.constructor.static.resizeToBoundingBox(
+                               // Image original dimensions
+                               {
+                                       width: originalDimensions.width || originalDimensions.thumbwidth,
+                                       height: originalDimensions.height || originalDimensions.thumbwidth
+                               },
+                               // Bounding box
+                               {
+                                       width: boundingBox.width || this.getImageMaxWidth(),
+                                       height: boundingBox.height || this.getRowHeight()
+                               }
+                       );
+               }
+               this.imageDimensions = imageDimensions;
+               // Set the thumbnail size
+               this.$thumb.css( this.imageDimensions );
+
+               // Set the box size
+               wrapperPadding = this.calculateWrapperPadding( this.imageDimensions );
+               this.$element.css( wrapperPadding );
+       };
+
+       /**
+        * Replace the empty .src attribute of the image with the
+        * actual src.
+        */
+       mw.widgets.MediaResultWidget.prototype.lazyLoad = function () {
+               if ( !this.hasSrc() ) {
+                       this.src = this.thumbUrl;
+                       this.$thumb.attr( 'src', this.thumbUrl );
+               }
+       };
+
+       /**
+        * Retrieve the store dimensions object
+        *
+        * @return {Object} Thumb dimensions
+        */
+       mw.widgets.MediaResultWidget.prototype.getDimensions = function () {
+               return this.dimensions;
+       };
+
+       /**
+        * Resize thumbnail and element according to the resize factor
+        *
+        * @param {number} resizeFactor The resizing factor for the image
+        */
+       mw.widgets.MediaResultWidget.prototype.resizeThumb = function ( resizeFactor ) {
+               var boundingBox,
+                       imageOriginalWidth = this.imageDimensions.width,
+                       wrapperWidth = this.$element.width();
+               // Set the new row height
+               this.setRowHeight( Math.ceil( this.getRowHeight() * resizeFactor ) );
+
+               boundingBox = {
+                       width: Math.ceil( this.imageDimensions.width * resizeFactor ),
+                       height: this.getRowHeight()
+               };
+
+               this.calculateSizing( this.data, boundingBox );
+
+               // We need to adjust the wrapper this time to fit the "perfect"
+               // dimensions, regardless of how small the image is
+               if ( imageOriginalWidth < wrapperWidth ) {
+                       boundingBox.width = wrapperWidth * resizeFactor;
+               }
+               this.$element.css( this.calculateWrapperPadding( boundingBox ) );
+       };
+
+       /**
+        * Adjust the wrapper padding for small images
+        *
+        * @param {Object} thumbDimensions Thumbnail dimensions
+        * @return {Object} Css styling for the wrapper
+        */
+       mw.widgets.MediaResultWidget.prototype.calculateWrapperPadding = function ( thumbDimensions ) {
+               var css = {
+                       height: this.rowHeight,
+                       width: thumbDimensions.width,
+                       lineHeight: this.getRowHeight() + 'px'
+               };
+
+               // Check if the image is too thin so we can make a bit of space around it
+               if ( thumbDimensions.width < this.minWidth ) {
+                       css.width = this.minWidth;
+               }
+
+               return css;
+       };
+
+       /**
+        * Set the row height for all size calculations
+        *
+        * @return {number} rowHeight Row height
+        */
+       mw.widgets.MediaResultWidget.prototype.getRowHeight = function () {
+               return this.rowHeight;
+       };
+
+       /**
+        * Set the row height for all size calculations
+        *
+        * @param {number} rowHeight Row height
+        */
+       mw.widgets.MediaResultWidget.prototype.setRowHeight = function ( rowHeight ) {
+               this.rowHeight = rowHeight;
+       };
+
+       mw.widgets.MediaResultWidget.prototype.setImageMaxWidth = function ( width ) {
+               this.maxWidth = width;
+       };
+       mw.widgets.MediaResultWidget.prototype.getImageMaxWidth = function () {
+               return this.maxWidth;
+       };
+
+       /**
+        * Set the row this result is in.
+        *
+        * @param {number} row Row number
+        */
+       mw.widgets.MediaResultWidget.prototype.setRow = function ( row ) {
+               this.row = row;
+       };
+
+       /**
+        * Get the row this result is in.
+        *
+        * @return {number} row Row number
+        */
+       mw.widgets.MediaResultWidget.prototype.getRow = function () {
+               return this.row;
+       };
+
+       /**
+        * Check if the image has a src attribute already
+        *
+        * @return {boolean} Thumbnail has its source attribute set
+        */
+       mw.widgets.MediaResultWidget.prototype.hasSrc = function () {
+               return !!this.src;
+       };
+}( jQuery, mediaWiki ) );
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchProvider.js b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchProvider.js
new file mode 100644 (file)
index 0000000..a46d911
--- /dev/null
@@ -0,0 +1,69 @@
+/*!
+ * MediaWiki Widgets - MediaSearchProvider class.
+ *
+ * @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+( function ( $, mw ) {
+
+       /**
+        * MediaWiki media search provider.
+        *
+        * @class
+        * @extends mw.widgets.MediaResourceProvider
+        *
+        * @constructor
+        * @param {string} apiurl The API url
+        * @param {Object} [config] Configuration options
+        */
+       mw.widgets.MediaSearchProvider = function MwWidgetsMediaSearchProvider( apiurl, config ) {
+               config = config || {};
+
+               config.staticParams = $.extend( {
+                       generator: 'search',
+                       gsrnamespace: mw.config.get( 'wgNamespaceIds' ).file
+               }, config.staticParams );
+
+               // Parent constructor
+               mw.widgets.MediaSearchProvider.super.call( this, apiurl, config );
+       };
+
+       /* Inheritance */
+       OO.inheritClass( mw.widgets.MediaSearchProvider, mw.widgets.MediaResourceProvider );
+
+       /* Methods */
+
+       /**
+        * @inheritdoc
+        */
+       mw.widgets.MediaSearchProvider.prototype.getContinueData = function ( howMany ) {
+               return {
+                       gsroffset: this.getOffset(),
+                       gsrlimit: howMany || this.getDefaultFetchLimit()
+               };
+       };
+
+       /**
+        * @inheritdoc
+        */
+       mw.widgets.MediaSearchProvider.prototype.setContinue = function ( continueData ) {
+               // Update the offset for next time
+               this.setOffset( continueData.gsroffset );
+       };
+
+       /**
+        * @inheritdoc
+        */
+       mw.widgets.MediaSearchProvider.prototype.sort = function ( results ) {
+               return results.sort( function ( a, b ) {
+                       return a.index - b.index;
+               } );
+       };
+
+       /**
+        * @inheritdoc
+        */
+       mw.widgets.MediaSearchProvider.prototype.isValid = function () {
+               return this.getUserParams().gsrsearch && mw.widgets.MediaSearchProvider.super.prototype.isValid.call( this );
+       };
+}( jQuery, mediaWiki ) );
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchQueue.js b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchQueue.js
new file mode 100644 (file)
index 0000000..7ee98bb
--- /dev/null
@@ -0,0 +1,82 @@
+/*!
+ * MediaWiki Widgets - MediaSearchQueue class.
+ *
+ * @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+( function ( $, mw ) {
+
+       /**
+        * MediaWiki media resource queue.
+        *
+        * @class
+        * @extends mw.widgets.MediaResourceQueue
+        *
+        * @constructor
+        * @param {Object} [config] Configuration options
+        * @cfg {number} maxHeight The maximum height of the media, used in the
+        *  search call to the API.
+        */
+       mw.widgets.MediaSearchQueue = function MwWidgetsMediaSearchQueue( config ) {
+               config = config || {};
+
+               // Parent constructor
+               mw.widgets.MediaSearchQueue.super.call( this, config );
+
+               this.searchQuery = '';
+       };
+
+       /* Inheritance */
+       OO.inheritClass( mw.widgets.MediaSearchQueue, mw.widgets.MediaResourceQueue );
+
+       /**
+        * Override parent method to set up the providers according to
+        * the file repos
+        *
+        * @return {jQuery.Promise} Promise that resolves when the resources are set up
+        */
+       mw.widgets.MediaSearchQueue.prototype.setup = function () {
+               var i, len,
+                       queue = this;
+
+               return this.getFileRepos().then( function ( sources ) {
+                       if ( queue.providers.length === 0 ) {
+                               // Set up the providers
+                               for ( i = 0, len = sources.length; i < len; i++ ) {
+                                       queue.providers.push( new mw.widgets.MediaSearchProvider(
+                                               sources[ i ].apiurl,
+                                               {
+                                                       name: sources[ i ].name,
+                                                       local: sources[ i ].local,
+                                                       scriptDirUrl: sources[ i ].scriptDirUrl,
+                                                       userParams: {
+                                                               gsrsearch: queue.getSearchQuery()
+                                                       },
+                                                       staticParams: {
+                                                               iiurlheight: queue.getMaxHeight()
+                                                       }
+                                               } )
+                                       );
+                               }
+                       }
+               } );
+       };
+
+       /**
+        * Set the search query
+        *
+        * @param {string} searchQuery API search query
+        */
+       mw.widgets.MediaSearchQueue.prototype.setSearchQuery = function ( searchQuery ) {
+               this.setParams( { gsrsearch: searchQuery } );
+       };
+
+       /**
+        * Get the search query
+        *
+        * @return {string} API search query
+        */
+       mw.widgets.MediaSearchQueue.prototype.getSearchQuery = function () {
+               return this.getParams().gsrsearch;
+       };
+}( jQuery, mediaWiki ) );
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchWidget.css b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchWidget.css
new file mode 100644 (file)
index 0000000..3d28ef8
--- /dev/null
@@ -0,0 +1,10 @@
+/*!
+ * MediaWiki Widgets - MediaSearchWidget styles.
+ *
+ * @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+.mw-widget-mediaSearchWidget .oo-ui-searchWidget-query .oo-ui-inputWidget {
+       max-width: none;
+}
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchWidget.js b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchWidget.js
new file mode 100644 (file)
index 0000000..c6938e8
--- /dev/null
@@ -0,0 +1,462 @@
+/*!
+ * MediaWiki Widgets - MediaSearchWidget class.
+ *
+ * @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+( function ( $, mw ) {
+
+       /**
+        * Creates an mw.widgets.MediaSearchWidget object.
+        *
+        * @class
+        * @extends OO.ui.SearchWidget
+        *
+        * @constructor
+        * @param {Object} [config] Configuration options
+        * @param {number} [size] Vertical size of thumbnails
+        */
+       mw.widgets.MediaSearchWidget = function MwWidgetsMediaSearchWidget( config ) {
+               // Configuration initialization
+               config = $.extend( {
+                       placeholder: mw.msg( 'mw-widgets-mediasearch-input-placeholder' )
+               }, config );
+
+               // Parent constructor
+               mw.widgets.MediaSearchWidget.super.call( this, config );
+
+               // Properties
+               this.providers = {};
+               this.lastQueryValue = '';
+               this.searchQueue = new mw.widgets.MediaSearchQueue( {
+                       limit: this.constructor.static.limit,
+                       threshold: this.constructor.static.threshold
+               } );
+
+               this.queryTimeout = null;
+               this.itemCache = {};
+               this.promises = [];
+               this.lang = config.lang || 'en';
+               this.$panels = config.$panels;
+
+               this.externalLinkUrlProtocolsRegExp = new RegExp(
+                       '^(' + mw.config.get( 'wgUrlProtocols' ) + ')',
+                       'i'
+               );
+
+               // Masonry fit properties
+               this.rows = [];
+               this.rowHeight = config.rowHeight || 200;
+               this.layoutQueue = [];
+               this.numItems = 0;
+               this.currentItemCache = [];
+
+               this.resultsSize = {};
+
+               this.selected = null;
+
+               this.noItemsMessage = new OO.ui.LabelWidget( {
+                       label: mw.msg( 'mw-widgets-mediasearch-noresults' ),
+                       classes: [ 'mw-widget-mediaSearchWidget-noresults' ]
+               } );
+               this.noItemsMessage.toggle( false );
+
+               // Events
+               this.$results.on( 'scroll', this.onResultsScroll.bind( this ) );
+               this.$query.append( this.noItemsMessage.$element );
+               this.results.connect( this, {
+                       add: 'onResultsAdd',
+                       remove: 'onResultsRemove'
+               } );
+
+               this.resizeHandler = OO.ui.debounce( this.afterResultsResize.bind( this ), 500 );
+
+               // Initialization
+               this.$element.addClass( 'mw-widget-mediaSearchWidget' );
+       };
+
+       /* Inheritance */
+
+       OO.inheritClass( mw.widgets.MediaSearchWidget, OO.ui.SearchWidget );
+
+       /* Static properties */
+
+       mw.widgets.MediaSearchWidget.static.limit = 10;
+
+       mw.widgets.MediaSearchWidget.static.threshold = 5;
+
+       /* Methods */
+
+       /**
+        * Respond to window resize and check if the result display should
+        * be updated.
+        */
+       mw.widgets.MediaSearchWidget.prototype.afterResultsResize = function () {
+               var items = this.currentItemCache;
+
+               if (
+                       items.length > 0 &&
+                       (
+                               this.resultsSize.width !== this.$results.width() ||
+                               this.resultsSize.height !== this.$results.height()
+                       )
+               ) {
+                       this.resetRows();
+                       this.itemCache = {};
+                       this.processQueueResults( items );
+                       if ( this.results.getItems().length > 0 ) {
+                               this.lazyLoadResults();
+                       }
+
+                       // Cache the size
+                       this.resultsSize = {
+                               width: this.$results.width(),
+                               height: this.$results.height()
+                       };
+               }
+       };
+
+       /**
+        * Teardown the widget; disconnect the window resize event.
+        */
+       mw.widgets.MediaSearchWidget.prototype.teardown = function () {
+               $( window ).off( 'resize', this.resizeHandler );
+       };
+
+       /**
+        * Setup the widget; activate the resize event.
+        */
+       mw.widgets.MediaSearchWidget.prototype.setup = function () {
+               $( window ).on( 'resize', this.resizeHandler );
+       };
+
+       /**
+        * Query all sources for media.
+        *
+        * @method
+        */
+       mw.widgets.MediaSearchWidget.prototype.queryMediaQueue = function () {
+               var search = this,
+                       value = this.getQueryValue();
+
+               if ( value === '' ) {
+                       return;
+               }
+
+               this.query.pushPending();
+               search.noItemsMessage.toggle( false );
+
+               this.searchQueue.setSearchQuery( value );
+               this.searchQueue.get( this.constructor.static.limit )
+                       .then( function ( items ) {
+                               if ( items.length > 0 ) {
+                                       search.processQueueResults( items );
+                                       search.currentItemCache = search.currentItemCache.concat( items );
+                               }
+
+                               search.query.popPending();
+                               search.noItemsMessage.toggle( search.results.getItems().length === 0 );
+                               if ( search.results.getItems().length > 0 ) {
+                                       search.lazyLoadResults();
+                               }
+
+                       } );
+       };
+
+       /**
+        * Process the media queue giving more items
+        *
+        * @method
+        * @param {Object[]} items Given items by the media queue
+        */
+       mw.widgets.MediaSearchWidget.prototype.processQueueResults = function ( items ) {
+               var i, len, title,
+                       resultWidgets = [],
+                       inputSearchQuery = this.getQueryValue(),
+                       queueSearchQuery = this.searchQueue.getSearchQuery();
+
+               if ( inputSearchQuery === '' || queueSearchQuery !== inputSearchQuery ) {
+                       return;
+               }
+
+               for ( i = 0, len = items.length; i < len; i++ ) {
+                       title = new mw.Title( items[ i ].title ).getMainText();
+                       // Do not insert duplicates
+                       if ( !Object.prototype.hasOwnProperty.call( this.itemCache, title ) ) {
+                               this.itemCache[ title ] = true;
+                               resultWidgets.push(
+                                       new mw.widgets.MediaResultWidget( {
+                                               data: items[ i ],
+                                               rowHeight: this.rowHeight,
+                                               maxWidth: this.results.$element.width() / 3,
+                                               minWidth: 30,
+                                               rowWidth: this.results.$element.width()
+                                       } )
+                               );
+                       }
+               }
+               this.results.addItems( resultWidgets );
+
+       };
+
+       /**
+        * Get the sanitized query value from the input
+        *
+        * @return {string} Query value
+        */
+       mw.widgets.MediaSearchWidget.prototype.getQueryValue = function () {
+               var queryValue = this.query.getValue().trim();
+
+               if ( queryValue.match( this.externalLinkUrlProtocolsRegExp ) ) {
+                       queryValue = queryValue.match( /.+\/([^\/]+)/ )[ 1 ];
+               }
+               return queryValue;
+       };
+
+       /**
+        * Handle search value change
+        *
+        * @param {string} value New value
+        */
+       mw.widgets.MediaSearchWidget.prototype.onQueryChange = function () {
+               // Get the sanitized query value
+               var queryValue = this.getQueryValue();
+
+               if ( queryValue === this.lastQueryValue ) {
+                       return;
+               }
+
+               // Parent method
+               mw.widgets.MediaSearchWidget.super.prototype.onQueryChange.apply( this, arguments );
+
+               // Reset
+               this.itemCache = {};
+               this.currentItemCache = [];
+               this.resetRows();
+
+               // Empty the results queue
+               this.layoutQueue = [];
+
+               // Change resource queue query
+               this.searchQueue.setSearchQuery( queryValue );
+               this.lastQueryValue = queryValue;
+
+               // Queue
+               clearTimeout( this.queryTimeout );
+               this.queryTimeout = setTimeout( this.queryMediaQueue.bind( this ), 350 );
+       };
+
+       /**
+        * Handle results scroll events.
+        *
+        * @param {jQuery.Event} e Scroll event
+        */
+       mw.widgets.MediaSearchWidget.prototype.onResultsScroll = function () {
+               var position = this.$results.scrollTop() + this.$results.outerHeight(),
+                       threshold = this.results.$element.outerHeight() - this.rowHeight * 3;
+
+               // Check if we need to ask for more results
+               if ( !this.query.isPending() && position > threshold ) {
+                       this.queryMediaQueue();
+               }
+
+               this.lazyLoadResults();
+       };
+
+       /**
+        * Lazy-load the images that are visible.
+        */
+       mw.widgets.MediaSearchWidget.prototype.lazyLoadResults = function () {
+               var i, elementTop,
+                       items = this.results.getItems(),
+                       resultsScrollTop = this.$results.scrollTop(),
+                       position = resultsScrollTop + this.$results.outerHeight();
+
+               // Lazy-load results
+               for ( i = 0; i < items.length; i++ ) {
+                       elementTop = items[ i ].$element.position().top;
+                       if ( elementTop <= position && !items[ i ].hasSrc() ) {
+                               // Load the image
+                               items[ i ].lazyLoad();
+                       }
+               }
+       };
+
+       /**
+        * Reset all the rows; destroy the jQuery elements and reset
+        * the rows array.
+        */
+       mw.widgets.MediaSearchWidget.prototype.resetRows = function () {
+               var i, len;
+
+               for ( i = 0, len = this.rows.length; i < len; i++ ) {
+                       this.rows[ i ].$element.remove();
+               }
+
+               this.rows = [];
+               this.itemCache = {};
+       };
+
+       /**
+        * Find an available row at the end. Either we will need to create a new
+        * row or use the last available row if it isn't full.
+        *
+        * @return {number} Row index
+        */
+       mw.widgets.MediaSearchWidget.prototype.getAvailableRow = function () {
+               var row;
+
+               if ( this.rows.length === 0 ) {
+                       row = 0;
+               } else {
+                       row = this.rows.length - 1;
+               }
+
+               if ( !this.rows[ row ] ) {
+                       // Create new row
+                       this.rows[ row ] = {
+                               isFull: false,
+                               width: 0,
+                               items: [],
+                               $element: $( '<div>' )
+                                       .addClass( 'mw-widget-mediaResultWidget-row' )
+                                       .css( {
+                                               overflow: 'hidden'
+                                       } )
+                                       .data( 'row', row )
+                                       .attr( 'data-full', false )
+                       };
+                       // Append to results
+                       this.results.$element.append( this.rows[ row ].$element );
+               } else if ( this.rows[ row ].isFull ) {
+                       row++;
+                       // Create new row
+                       this.rows[ row ] = {
+                               isFull: false,
+                               width: 0,
+                               items: [],
+                               $element: $( '<div>' )
+                                       .addClass( 'mw-widget-mediaResultWidget-row' )
+                                       .css( {
+                                               overflow: 'hidden'
+                                       } )
+                                       .data( 'row', row )
+                                       .attr( 'data-full', false )
+                       };
+                       // Append to results
+                       this.results.$element.append( this.rows[ row ].$element );
+               }
+
+               return row;
+       };
+
+       /**
+        * Respond to add results event in the results widget.
+        * Override the way SelectWidget and GroupElement append the items
+        * into the group so we can append them in groups of rows.
+        *
+        * @param {mw.widgets.MediaResultWidget[]} items An array of item elements
+        */
+       mw.widgets.MediaSearchWidget.prototype.onResultsAdd = function ( items ) {
+               var search = this;
+
+               // Add method to a queue; this queue will only run when the widget
+               // is visible
+               this.layoutQueue.push( function () {
+                       var i, j, ilen, jlen, itemWidth, row, effectiveWidth,
+                               resizeFactor,
+                               maxRowWidth = search.results.$element.width() - 15;
+
+                       // Go over the added items
+                       row = search.getAvailableRow();
+                       for ( i = 0, ilen = items.length; i < ilen; i++ ) {
+                               itemWidth = items[ i ].$element.outerWidth( true );
+
+                               // Add items to row until it is full
+                               if ( search.rows[ row ].width + itemWidth >= maxRowWidth ) {
+                                       // Mark this row as full
+                                       search.rows[ row ].isFull = true;
+                                       search.rows[ row ].$element.attr( 'data-full', true );
+
+                                       // Find the resize factor
+                                       effectiveWidth = search.rows[ row ].width;
+                                       resizeFactor = maxRowWidth / effectiveWidth;
+
+                                       search.rows[ row ].$element.attr( 'data-effectiveWidth', effectiveWidth );
+                                       search.rows[ row ].$element.attr( 'data-resizeFactor', resizeFactor );
+                                       search.rows[ row ].$element.attr( 'data-row', row );
+
+                                       // Resize all images in the row to fit the width
+                                       for ( j = 0, jlen = search.rows[ row ].items.length; j < jlen; j++ ) {
+                                               search.rows[ row ].items[ j ].resizeThumb( resizeFactor );
+                                       }
+
+                                       // find another row
+                                       row = search.getAvailableRow();
+                               }
+
+                               // Add the cumulative
+                               search.rows[ row ].width += itemWidth;
+
+                               // Store reference to the item and to the row
+                               search.rows[ row ].items.push( items[ i ] );
+                               items[ i ].setRow( row );
+
+                               // Append the item
+                               search.rows[ row ].$element.append( items[ i ].$element );
+                       }
+
+                       // If we have less than 4 rows, call for more images
+                       if ( search.rows.length < 4 ) {
+                               search.queryMediaQueue();
+                       }
+               } );
+               this.runLayoutQueue();
+       };
+
+       /**
+        * Run layout methods from the queue only if the element is visible.
+        */
+       mw.widgets.MediaSearchWidget.prototype.runLayoutQueue = function () {
+               var i, len;
+
+               if ( this.$element.is( ':visible' ) ) {
+                       for ( i = 0, len = this.layoutQueue.length; i < len; i++ ) {
+                               this.layoutQueue.pop()();
+                       }
+               }
+       };
+
+       /**
+        * Respond to removing results event in the results widget.
+        * Clear the relevant rows.
+        *
+        * @param {OO.ui.OptionWidget[]} items Removed items
+        */
+       mw.widgets.MediaSearchWidget.prototype.onResultsRemove = function ( items ) {
+               if ( items.length > 0 ) {
+                       // In the case of the media search widget, if any items are removed
+                       // all are removed (new search)
+                       this.resetRows();
+                       this.currentItemCache = [];
+               }
+       };
+
+       /**
+        * Set language for the search results.
+        *
+        * @param {string} lang Language
+        */
+       mw.widgets.MediaSearchWidget.prototype.setLang = function ( lang ) {
+               this.lang = lang;
+       };
+
+       /**
+        * Get language for the search results.
+        *
+        * @return {string} lang Language
+        */
+       mw.widgets.MediaSearchWidget.prototype.getLang = function () {
+               return this.lang;
+       };
+}( jQuery, mediaWiki ) );
index 39bee7c..2ac75c5 100755 (executable)
@@ -78,7 +78,7 @@
         * @inheritdoc mw.widgets.TitleWidget
         */
        mw.widgets.SearchInputWidget.prototype.getSuggestionsPromise = function () {
-               var api = new mw.Api(),
+               var api = this.getApi(),
                        promise,
                        self = this;
 
index e1e50ea..0e5e0c5 100644 (file)
@@ -6,16 +6,6 @@
  */
 ( function ( $, mw ) {
 
-       var interwikiPrefixesPromise = new mw.Api().get( {
-               action: 'query',
-               meta: 'siteinfo',
-               siprop: 'interwikimap'
-       } ).then( function ( data ) {
-               return $.map( data.query.interwikimap, function ( interwiki ) {
-                       return interwiki.prefix;
-               } );
-       } );
-
        /**
         * Mixin for title widgets
         *
@@ -36,6 +26,7 @@
         * @cfg {boolean} [validateTitle=true] Whether the input must be a valid title (if set to true,
         *  the widget will marks itself red for invalid inputs, including an empty query).
         * @cfg {Object} [cache] Result cache which implements a 'set' method, taking keyed values as an argument
+        * @cfg {mw.Api} [api] API object to use, creates a default mw.Api instance if not specified
         */
        mw.widgets.TitleWidget = function MwWidgetsTitleWidget( config ) {
                // Config initialization
@@ -56,6 +47,7 @@
                this.excludeCurrentPage = !!config.excludeCurrentPage;
                this.validateTitle = config.validateTitle !== undefined ? config.validateTitle : true;
                this.cache = config.cache;
+               this.api = config.api || new mw.Api();
 
                // Initialization
                this.$element.addClass( 'mw-widget-titleWidget' );
 
        OO.initClass( mw.widgets.TitleWidget );
 
+       /* Static properties */
+
+       mw.widgets.TitleWidget.static.interwikiPrefixesPromiseCache = {};
+
        /* Methods */
 
        /**
                this.namespace = namespace;
        };
 
+       mw.widgets.TitleWidget.prototype.getInterwikiPrefixesPromise = function () {
+               var api = this.getApi(),
+                       cache = this.constructor.static.interwikiPrefixesPromiseCache,
+                       key = api.defaults.ajax.url;
+               if ( !cache.hasOwnProperty( key ) ) {
+                       cache[ key ] = api.get( {
+                               action: 'query',
+                               meta: 'siteinfo',
+                               siprop: 'interwikimap'
+                       } ).then( function ( data ) {
+                               return $.map( data.query.interwikimap, function ( interwiki ) {
+                                       return interwiki.prefix;
+                               } );
+                       } );
+               }
+               return cache[ key ];
+       };
+
        /**
         * Get a promise which resolves with an API repsonse for suggested
         * links for the current query.
         */
        mw.widgets.TitleWidget.prototype.getSuggestionsPromise = function () {
                var req,
+                       api = this.getApi(),
                        query = this.getQueryValue(),
                        widget = this,
                        promiseAbortObject = { abort: function () {
                        } };
 
                if ( mw.Title.newFromText( query ) ) {
-                       return interwikiPrefixesPromise.then( function ( interwikiPrefixes ) {
+                       return this.getInterwikiPrefixesPromise().then( function ( interwikiPrefixes ) {
                                var params,
                                        interwiki = query.substring( 0, query.indexOf( ':' ) );
                                if (
                                                params.prop.push( 'pageterms' );
                                                params.wbptterms = 'description';
                                        }
-                                       req = new mw.Api().get( params );
+                                       req = api.get( params );
                                        promiseAbortObject.abort = req.abort.bind( req ); // TODO ew
                                        return req.then( function ( ret ) {
                                                if ( ret.query === undefined ) {
-                                                       ret = new mw.Api().get( { action: 'query', titles: query } );
+                                                       ret = api.get( { action: 'query', titles: query } );
                                                        promiseAbortObject.abort = ret.abort.bind( ret );
                                                }
                                                return ret;
                }
        };
 
+       /**
+        * Get the API object for title requests
+        *
+        * @return {mw.Api} MediaWiki API
+        */
+       mw.widgets.TitleWidget.prototype.getApi = function () {
+               return this.api;
+       };
+
        /**
         * Get option widgets from the server response
         *
diff --git a/tests/phpunit/includes/debug/logger/monolog/LogstashFormatterTest.php b/tests/phpunit/includes/debug/logger/monolog/LogstashFormatterTest.php
new file mode 100644 (file)
index 0000000..8086b4b
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+
+namespace MediaWiki\Logger\Monolog;
+
+class LogstashFormatterTest extends \PHPUnit_Framework_TestCase {
+       /**
+        * @dataProvider provideV1
+        * @param array $record The input record.
+        * @param array $expected Associative array of expected keys and their values.
+        * @param array $notExpected List of keys that should not exist.
+        */
+       public function testV1( array $record, array $expected, array $notExpected ) {
+               $formatter = new LogstashFormatter( 'app', 'system', null, null, LogstashFormatter::V1 );
+               $formatted = json_decode( $formatter->format( $record ), true );
+               foreach ( $expected as $key => $value ) {
+                       $this->assertArrayHasKey( $key, $formatted );
+                       $this->assertSame( $value, $formatted[$key] );
+               }
+               foreach ( $notExpected as $key ) {
+                       $this->assertArrayNotHasKey( $key, $formatted );
+               }
+       }
+
+       public function provideV1() {
+               return [
+                       [
+                               [ 'extra' => [ 'foo' => 1 ], 'context' => [ 'bar' => 2 ] ],
+                               [ 'foo' => 1, 'bar' => 2 ],
+                               [ 'logstash_formatter_key_conflict' ],
+                       ],
+                       [
+                               [ 'extra' => [ 'url' => 1 ], 'context' => [ 'url' => 2 ] ],
+                               [ 'url' => 1, 'c_url' => 2, 'logstash_formatter_key_conflict' => [ 'url' ] ],
+                               [],
+                       ],
+                       [
+                               [ 'channel' => 'x', 'context' => [ 'channel' => 'y' ] ],
+                               [ 'channel' => 'x', 'c_channel' => 'y',
+                                       'logstash_formatter_key_conflict' => [ 'channel' ] ],
+                               [],
+                       ],
+               ];
+       }
+
+       public function testV1WithPrefix() {
+               $formatter = new LogstashFormatter( 'app', 'system', null, 'ctx_', LogstashFormatter::V1 );
+               $record = [ 'extra' => [ 'url' => 1 ], 'context' => [ 'url' => 2 ] ];
+               $formatted = json_decode( $formatter->format( $record ), true );
+               $this->assertArrayHasKey( 'url', $formatted );
+               $this->assertSame( 1, $formatted['url'] );
+               $this->assertArrayHasKey( 'ctx_url', $formatted );
+               $this->assertSame( 2, $formatted['ctx_url'] );
+               $this->assertArrayNotHasKey( 'c_url', $formatted );
+       }
+}
index fca25c5..c38b89c 100644 (file)
--- a/thumb.php
+++ b/thumb.php
@@ -341,6 +341,7 @@ function wfStreamThumb( array $params ) {
        // Check for thumbnail generation errors...
        $msg = wfMessage( 'thumbnail_error' );
        $errorCode = 500;
+
        if ( !$thumb ) {
                $errorMsg = $errorMsg ?: $msg->rawParams( 'File::transform() returned false' )->escaped();
                if ( $errorMsg instanceof MessageSpecifier &&
@@ -350,6 +351,7 @@ function wfStreamThumb( array $params ) {
                }
        } elseif ( $thumb->isError() ) {
                $errorMsg = $thumb->getHtmlMsg();
+               $errorCode = $thumb->getHttpStatusCode();
        } elseif ( !$thumb->hasFile() ) {
                $errorMsg = $msg->rawParams( 'No path supplied in thumbnail object' )->escaped();
        } elseif ( $thumb->fileIsSource() ) {