From: jenkins-bot Date: Sat, 17 Dec 2016 06:55:58 +0000 (+0000) Subject: Merge "mediawiki.api.watch: Use formatversion=2 for API requests" X-Git-Tag: 1.31.0-rc.0~4532 X-Git-Url: https://git.heureux-cyclage.org/?a=commitdiff_plain;h=b8da5c83743ea31c6f73c063508384f114748537;hp=d3a4c8c5ee57e93951fdbba0f16ac835b2e60492;p=lhc%2Fweb%2Fwiklou.git Merge "mediawiki.api.watch: Use formatversion=2 for API requests" --- diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000000..044dd7202d --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": "wikimedia", + "env": { + "browser": true, + "jquery": true, + "qunit": true + }, + "globals": { + "require": false, + "module": false, + "mediaWiki": false, + "mwPerformance": false, + "OO": false + }, + "rules": { + "dot-notation": 0 + } +} diff --git a/.gitignore b/.gitignore index 01a11bf411..b2c4d45cb1 100644 --- a/.gitignore +++ b/.gitignore @@ -71,3 +71,4 @@ Thumbs.db /tags /.htaccess /.htpasswd +/tests/phan/issues diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index 3f7e90d209..0000000000 --- a/.jscsrc +++ /dev/null @@ -1,36 +0,0 @@ -{ - "preset": "wikimedia", - "es3": true, - - "requireVarDeclFirst": null, - - "requireDotNotation": { "allExcept": [ "keywords" ] }, - "jsDoc": { - "checkAnnotations": { - "preset": "jsduck5", - "extra": { - "context": "some", - "see": "some" - } - }, - "checkParamNames": true, - "checkRedundantAccess": true, - "checkRedundantReturns": true, - "checkTypes": "strictNativeCase", - "requireNewlineAfterDescription": true, - "requireParamTypes": true, - "requireReturnTypes": true - }, - - "excludeFiles": [ - "docs/**", - "extensions/**", - "node_modules/**", - "resources/lib/**", - "resources/src/jquery.tipsy/**", - "resources/src/jquery/jquery.farbtastic.js", - "resources/src/mediawiki.libs/**", - "skins/**", - "vendor/**" - ] -} diff --git a/.jshintignore b/.jshintignore deleted file mode 100644 index fdde7d054d..0000000000 --- a/.jshintignore +++ /dev/null @@ -1,12 +0,0 @@ -# Generated documentation -docs/** - -# third-party libs -extensions/** -node_modules/** -resources/lib/** -resources/src/jquery.tipsy/** -resources/src/jquery/jquery.farbtastic.js -resources/src/mediawiki.libs/** -skins/** -vendor/** diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 441c4e310b..0000000000 --- a/.jshintrc +++ /dev/null @@ -1,33 +0,0 @@ -{ - // Enforcing - "bitwise": true, - "eqeqeq": true, - "esversion": 3, - "freeze": true, - "futurehostile": true, - "latedef": "nofunc", - "noarg": true, - "nonew": true, - "strict": false, - "undef": true, - "unused": true, - - // Relaxing - "laxbreak": true, - "multistr": true, - - // Environment - "browser": true, - - "globals": { - "require": false, - "module": false, - "mediaWiki": true, - "JSON": true, - "OO": true, - "mwPerformance": true, - "jQuery": false, - "QUnit": false, - "sinon": false - } -} diff --git a/.mailmap b/.mailmap index 5c82af8118..dd968e8d08 100644 --- a/.mailmap +++ b/.mailmap @@ -1,30 +1,62 @@ +# Map author and committer names and email addresses to canonical real names +# and email addresses. +# +# To update the CREDITS file, run maintenance/updateCredits.php +# +# Two types of entries are useful here. The first sets a canonical author +# name for a given email address: +# +# Canonical Author Name +# +# The second allows collecting alternate email addresses into a single +# canonical author name and email address: +# +# Canonical Author Name +# +# Mappings are only needed for authors who have used multiple author names +# and/or author emails for revisions over time. Author names beginning with +# "[BOT]" will be omitted from the CREDITS file. +# +# See also: https://git-scm.com/docs/git-shortlog#_mapping_authors +# +[BOT] Gerrit Code Review [BOT] Gerrit Patch Uploader +[BOT] jenkins-bot +[BOT] jenkins-bot [BOT] Translation updater bot Aaron Schulz Aaron Schulz Adam Roses Wight +Adam Roses Wight addshore +Aditya Sastry Adrian Heine -Alex Monk -Alex Monk -Alex Z -Alexander Emsenhuber -Alexander Emsenhuber -Alexander Emsenhuber +Alex Z. +Alexandre Emsenhuber +Alexandre Emsenhuber +Alexandre Emsenhuber +Alexander Monk +Alexander Monk +Alexander Monk Alexia E. Smith Amir E. Aharoni Amir E. Aharoni +Amir Sarabadani Anders Wegge Jakobsen Andre Engels +Andrew Garrett Andrew Garrett Angela Beesley Starling Antoine Musso Antoine Musso Aran Dunkley Ariel Glenn +Ariel Glenn Arlo Breault +Arthur Richards Arthur Richards Aryeh Gregor +Asher Feldman Asher Feldman aude Audrey Tang @@ -32,25 +64,30 @@ Audrey Tang ayush_garg Bahodir Mansurov Bartosz Dziewoński -Bartosz Dziewoński Bartosz Dziewoński +Bartosz Dziewoński Ben Hartshorne Bene -Benjamin Lees +Bene +Benny Situ Benny Situ Bertrand Grondin Brad Jorsch +Brad Jorsch Brandon Harris -Brian Wolff Brian Wolff +Brian Wolff +Brian Wolff Brion Vibber Brion Vibber Brion Vibber Bryan Davis +Bryan Davis +Bryan Tong Minh Bryan Tong Minh C. Scott Ananian C. Scott Ananian -cacycle@gerrit.wikimedia.org +Cacycle cenarium Chad Horohoe Chad Horohoe @@ -58,44 +95,64 @@ Charles Melbye Chiefwei Chris McMahon Chris Steipp -Christian Aistleitner Christian Aistleitner +Christian Aistleitner Christian Williams Christian Williams Christian Williams +Christopher Johnson +church of emacs +Cindy Cicalese ckoerner Conrad Irwin Dan Duvall dan-nl Daniel A. R. Werner Daniel Cannon +Daniel Friesen +Daniel Friesen Daniel Friesen +Daniel Friesen Daniel Kinzler Daniel Kinzler -Danny B +Danny B. +Danny B. +Danny B. +Danny B. +Darian Anthony Patrick +Darkdragon09 David Chan +Dereckson +Derk-Jan Hartman +Derk-Jan Hartman Derk-Jan Hartman -Derk-Jan Hartman Diederik van Liere Domas Mituzas Douglas Gardner DPStokesNZ Ebrahim Byagowi Ed Sanders -Elliott Eggleston +Elliott Eggleston +Elliott Eggleston Emmanuel Engelhart -eranroz +Emufarmers +Emufarmers +Entlinkt +Eranroz Erik Bernhardson Erik Moeller Erik Moeller Erwin Dokter Evan McIntire +Evan Prodromou Federico Leva Fenzik Joseph -Florianschmidtwelzow -Florianschmidtwelzow Florian -Fomafix +Florian Schmidt +Florian Schmidt +fomafix +Fran Rogers Fran Rogers +freakolowsky FunPika Gabriel Wicke Gabriel Wicke @@ -110,31 +167,38 @@ glaisher Greg Sabino Mullane Greg Sabino Mullane Greg Sabino Mullane +Grunny Guy Van den Broeck Happy-melon Helder Helder Hoo man +Huji Huji Ian Baker Ilmari Karonen Inez Korczyński Inez Korczyński isarra +isarra Ivan Lanin -Jack Phoenix Jack Phoenix +Jack Phoenix Jackmcbarn -Jackmcbarn +Jackmcbarn jagori -James D. Forrester +James Forrester Jan Gerber +Jan Luca Naumann Jan Luca Naumann Jan Paul Posma Jan Zerebecki +Jared Flores Jaroslav Škarvada jarrettmunton +Jason Richey Jason Richey +Jason Richey Jeff Hall Jeff Hall Jeff Janes @@ -151,40 +215,58 @@ Jon Robson Juliusz Gonera Juliusz Gonera JuneHyeon Bae +Jure Kajzer Jure Kajzer +Karun Dambiec +Katie Filbert Katie Filbert Kevin Israel -Kunal Mehta -Kunal Mehta +Kunal Grover +Kunal Mehta +Kunal Mehta +Kunal Mehta Kwan Ting Chan lekshmi Leo Koppelkamm +Leon Liesener Leon Weber Leonardo Gregianin Leons Petrazickis -Liangent +liangent Lisa Ridley Ljudusika Luis Felipe Schenone +Lupo m4tx +Madman Magnus Manske Manuel Schneider <80686@users.mediawiki.org> +Marc-André Pelletier +Marcin Cieślak Marcin Cieślak +Marco Falke +MarcoAurelio Marielle Volz Marius Hoch -Mark A. Hershberger -Mark A. Hershberger -Mark A. Hershberger Mark Clements +Mark Hershberger +Mark Hershberger +Mark Hershberger +Mark Hershberger Mark Holmquist +Mark Holmquist Marko Obrovac +Markus Glaser +Markus Glaser Matt Johnston Matthew Britton Matthew Flaschen Matthias Mullie +Matthias Mullie Matěj Grabovský Max Semenik Max Semenik +Max Semenik mgooley Michael Dale mjbmr @@ -192,23 +274,30 @@ Mohamed Magdy Moriel Schottlender Moriel Schottlender Mormegil +MrBlueSky +MrBlueSky Mukunda Modell +Mwalker MZMcBride nadeesha Namit Nathaniel Herman Neil Kandalgaonkar Nemo bis -Nephele +nephele Nick Jenkins Nik Everett Niklas Laxström Niklas Laxström Nimish Gautam Nuria Ruiz -Ori.livneh +Ori Livneh +Ori Livneh OverlordQ +Owen Davis +Owen Davis paladox +Patrick Reilly Patrick Reilly Patrick Westerhoff Paul Copperman @@ -223,9 +312,9 @@ PranavK Prateek Saxena Prateek Saxena Priyanka Dhanda -Purodha B Blissenbach -Purodha B Blissenbach -Purodha B Blissenbach +Purodha Blissenbach +Purodha Blissenbach +Purodha Blissenbach Raimond Spekking Raimond Spekking Remember the dot @@ -233,13 +322,15 @@ Reza Ricordisamoa rillke rillke -River Tarnell River Tarnell +River Tarnell Roan Kattouw Roan Kattouw Roan Kattouw Rob Church +Rob Lanphier Rob Lanphier +Rob Lanphier Rob Moen Rob Moen Rob Moen @@ -247,24 +338,30 @@ Robert Hoenig Robert Leverington Robert Rohde Robert Stojnić +Robin Pepermans Robin Pepermans robinhood701 Rohan Rotem Liss Rummana Yasmeen Russ Nelson -Ryan Kaldari Ryan Kaldari Ryan Kaldari +Ryan Kaldari +Ryan Lane Ryan Lane +Ryan Lane +Ryan Schmidt +Ryan Schmidt Ryan Schmidt S Page Sam Reed +Sam Reed +Sam Reed Sam Reed Sam Smith -Santhosh Thottingal Santhosh Thottingal -saper +Santhosh Thottingal Schnark Scimonster Sean Colombo @@ -272,11 +369,14 @@ Sean Pringle Seb35 Sergio Santoro Shahyar +Shinjiman Shinjiman Siebrand Mazeland Siebrand Mazeland Siebrand Mazeland Siebrand Mazeland +Smriti Singh +Sorawee Porncharoenwase Southparkfan SQL Stanislav Malyshev @@ -288,9 +388,10 @@ Steven Roddis Subramanya Sastry Sucheta Ghoshal Sumit Asthana +Swalling Thalia Chan -TheDJ Thiemo Mättig (WMDE) +Thiemo Mättig (WMDE) This, that and the other tholam Thomas Bleher @@ -305,29 +406,45 @@ Timo Tijhof Timo Tijhof Timo Tijhof Tina Johnson +Tisane +Tjones Tom Maaswinkel Tomasz Finc +Tomasz W. Kozlowski +Tomasz W. Kozlowski +Tomasz W. Kozlowski Tony Thomas <01tonythomas@gmail.com> +Tpt Trevor Parscal Trevor Parscal Trevor Parscal Tyler Cipriani Tyler Romeo -umherirrender +Umherirrender +Victor Vasiliev Victor Vasiliev +Victor Vasiliev Vikas S Yaligar Vivek Ghaisas wctaiwan withoutaname X! +Yaron Koren +Yaron Koren Yaroslav Melnychuk +Yongmin Hong +Yongmin Hong +Yongmin Hong Yuri Astrakhan +Yuri Astrakhan Yuri Astrakhan Yusuke Matsubara -YuviPanda +Yuvi Panda Zak Greant +Zhengzhu Feng +Zhengzhu Feng +Zppix Ævar Arnfjörð Bjarmason +Étienne Beaulé Željko Filipin Željko Filipin -Zhengzhu Feng -Zhengzhu Feng diff --git a/CREDITS b/CREDITS index 46d5c9ca0b..d9ff9709f1 100644 --- a/CREDITS +++ b/CREDITS @@ -6,252 +6,656 @@ following names for their contribution to the product. --> -== Developers == -* Aaron Schulz -* Alex Z. -* Alexander Monk -* Alexandre Emsenhuber -* Andrew Garrett -* Antoine Musso -* Arthur Richards -* Aryeh Gregor -* Bartosz Dziewoński -* Bertrand Grondin -* Brad Jorsch -* Brian Wolff -* Brion Vibber -* Bryan Davis -* Bryan Tong Minh -* Chad Horohoe -* Charles Melbye -* Chris Steipp -* church of emacs -* Daniel Friesen -* Daniel Kinzler -* Daniel Renfro -* Danny B. -* David McCabe -* Derk-Jan Hartman -* Domas Mituzas -* Ed Sanders -* Emufarmers -* Fran Rogers -* Greg Sabino Mullane -* Guy Van den Broeck -* Happy-melon -* Hojjat -* Ian Baker -* Ilmari Karonen -* Jack D. Pond -* Jack Phoenix -* Jackmcbarn -* James Forrester -* Jan Paul Posma -* Jason Richey -* Jeroen De Dauw -* John Du Hart -* Jon Harald Søby -* Juliano F. Ravasi -* JuneHyeon Bae -* Leo Koppelkamm -* Leon Weber -* Leslie Hoare -* Marco Schuster -* Marius Hoch -* Matěj Grabovský -* Matt Johnston -* Matthew Flaschen -* Max Semenik -* Meno25 -* MinuteElectron -* Mohamed Magdy -* Nathaniel Herman -* Neil Kandalgaonkar -* Nicolas Dumazet -* Niklas Laxström -* Ori Livneh -* Patrick Reilly -* Philip Tzou -* Platonides -* Purodha Blissenbach -* Raimond Spekking -* Remember the dot -* Roan Kattouw -* Robert Stojnić -* Robin Pepermans -* Rotem Liss -* Ryan Kaldari -* Ryan Lane -* Ryan Schmidt -* Sam Reed -* Shinjiman -* Siebrand Mazeland -* Soxred93 -* SQL -* Szymon Świerkosz -* This, that and the other -* Thomas Bleher -* Thomas Gries -* Tim Starling -* Timo Tijhof -* Trevor Parscal -* Tyler Anthony Romeo -* Victor Vasiliev -* Yesid Carrillo -* Yuri Astrakhan - -== Patch Contributors == +== Contributors == + + +* aalekhN * Aaron Ball * Aaron Pramana +* Aaron Schulz +* Aarti Dwivedi +* Aashaka Shah +* abhinand +* Abhishek Das +* Adam Miller +* Adam Roses Wight +* addshore +* Aditya Sastry +* Adrian Heine +* Adrian Lang +* Ævar Arnfjörð Bjarmason * Agbad * Ahmad Sherif +* Ajayrahul P +* Alangi Derick +* Albert221 * Alejandro Mery +* AlephNull +* Alex Ivanov +* Alex Shih-Han Lin +* Alex Z. +* Alexander I. Mashin +* Alexander Lehmann +* Alexander Monk +* Alexander Sigachov +* Alexandre Emsenhuber +* Alexia E. Smith * Amalthea * Amir E. Aharoni +* Amir Sarabadani +* ananay +* Anders Wegge Jakobsen +* Andre Engels +* Andrew Bogott * Andrew Dunbar +* Andrew Garrett +* Andrew Green +* Andrew H +* Andrew Harris +* Andrew Otto +* Andrius R +* andymw +* Angela Beesley Starling +* ankur +* Antoine Musso * Antonio Ospite +* apexkid +* April King +* Aran Dunkley +* Arash Boostani +* Arcane21 +* Ariel Glenn +* Arlo Breault +* Arne Heizmann +* Arthur Richards +* Aryeh Gregor +* Asher Feldman * Asier Lostalé +* ayush_garg * Azliq7 * Bagariavivek +* Bahodir Mansurov +* balloonguy +* Bartosz Dziewoński * Beau +* Ben Davis +* Ben Hartshorne +* Bene * Benny Situ * Bergi +* Bertrand Grondin +* Bill Traynor +* Billinghurst +* billm +* blotmandroid +* Bogdan Stancescu +* Boris Nagaev * Borislav Manolov +* Brad Jorsch +* Brandon Black +* Brandon Harris * Brent G +* Brent Garber +* Brian Wolff * Brianna Laugher +* Brion Vibber +* Bryan Davis +* Bryan Tong Minh +* burthsceh +* C. Scott Ananian +* Cacycle +* Calak +* Camille Constans +* Carl Fürstenberg * Carlin * Carsten Nielsen +* Cblair91 +* cenarium +* Chad Horohoe +* Charles Melbye +* Chiefwei +* Chris McMahon +* Chris Seaton +* Chris Steipp * Christian Aistleitner +* Christian List * Christian Neubauer +* Christopher Johnson +* church of emacs +* Cindy Cicalese +* ckoerner * Conrad Irwin * cryptocoryne * Dan Barrett * Dan Collins +* Dan Duvall * Dan Nessett +* Dan Poltawski +* dan-nl +* Daniel A. R. Werner * Daniel Arnold +* Daniel Cannon +* Daniel De Marco +* Daniel Evans +* Daniel Friesen +* Daniel Kinzler +* Daniel Renfro * Daniel Werner +* DanielRenfro +* Danny B. +* Darian Anthony Patrick +* Darkdragon09 +* DaSch * David Baumgarten +* David Chan +* David E. Narváez +* David Lynch +* David McCabe +* David Mudrák +* dcausse +* dennisroczek * Denny Vrandecic +* Dereckson +* Derk-Jan Hartman +* Derric Atzrott +* Derrick Coetzee * Dévai Tamás +* Devi Krishnan +* Diederik van Liere +* Domas Mituzas +* Douglas Gardner +* DPStokesNZ +* dr0ptp4kt * Ebrahim Byagowi +* Ed Sanders +* Edward Chernenko * Edward Z. Yang +* Elisabeth Bauer +* Elliott Eggleston * Elvis Stansvik +* Emil Podlaszewski +* Emmanuel Engelhart +* Emmanuel Gil Peyrot +* Emmet Hikory +* Emufarmers +* enigmaeth +* Entlinkt * Eranroz +* Eric Evans +* Eric Schneider +* Erich Lerch +* Erick Guan +* Erik Bernhardson +* Erik Moeller * Erwin Dokter * Étienne Beaulé +* Evan McIntire +* Evan Prodromou +* ExplosiveHippo +* Faidon Liambotis * Federico Leva +* Fenzik Joseph +* firebus * Florian Schmidt * fomafix +* Fran Rogers +* Fred Emmott * FunPika * Gabriel Wicke +* Gary Guo +* gbt248 * Geoffrey Mon +* georggi +* Gergő Tisza * Gero Scholz +* gicode +* Giftpflanze +* Gilles Dubuc * Gilles van den Hoven +* Giuseppe Lavagetto +* gladoscc +* glaisher +* Greg Maxwell +* Greg Sabino Mullane +* Gregory Szorc * Grunny +* Guillaume Blanchard +* Guy Van den Broeck +* Happy-melon +* haritha28 * Harry Burt +* Hazard-SJ +* Hector A Escobedo +* Helder +* Henning Snater +* Hojjat +* Huji +* Hydriz +* Ian Baker +* Ilmari Karonen +* Inez Korczyński +* IoannisKydonis * Ireas +* isarra +* Ivan Lanin +* Jack D. Pond +* Jack Phoenix +* Jackmcbarn * Jacob Block +* Jacob Clark +* jagori +* Jakub Vrana +* James Earl Douglas +* James Forrester +* Jan Berkel +* Jan Drewniak * Jan Gerber * Jan Luca Naumann +* Jan Paul Posma +* Jan Zerebecki +* Jared Flores +* Jaroslav Škarvada +* jarrettmunton +* jarry1250 * Jaska Zedlik +* Jason Richey +* jeblad +* Jeff Janes +* jeff303 +* Jens Frank +* Jens Ohlig +* Jérémie Roquet * Jeremy Baron +* Jeremy Postlethwaite +* jeremyb +* Jeroen De Dauw +* Jerome Jamnicky +* Jesús Martínez Novo +* jhobs +* Jiabao * Jidanni +* Jimmy Collins * Jimmy Xu +* joakin +* Joan Creus +* Joel Natividad +* Joerg +* Johan Dahlin +* John Du Hart * John N +* Jon Harald Søby +* Jon Robson * Jonathan Wiltshire +* Jools Wills +* jsahleen +* Julian Ostrow +* Juliano F. Ravasi +* Juliusz Gonera +* JuneHyeon Bae * Jure Kajzer +* Justin Du +* Kai_WMDE +* kaligula +* Kartik Mistry * Karun Dambiec * Katie Filbert * Kevin Israel +* Kghbln +* Kim Eik * Kim Hyun-Joon +* kipod +* kishanio +* konarak +* krishna keshav +* Krzysztof Krzyzaniak +* Krzysztof Zbudniewek +* Kunal Grover +* Kunal Mehta +* Kwan Ting Chan +* Laurence Parry +* Lee Bousfield +* Lee Daniel Crocker * Lee Worden * Lejonel +* lekshmi +* Leo Koppelkamm * Leon Liesener +* Leon Weber +* Leonardo Gregianin +* Leons Petrazickis +* Leslie Hoare +* Leszek Manicki +* lethosor +* Lewis Cawte +* Liam Edwards-Playne * liangent +* Lisa Ridley +* Ljudusika +* Lojjik Braughler * Louperivois +* Ltrlg +* Luc Van Oostenryck * Lucas Garczewski * Luigi Corsaro +* Luis Felipe Schenone * Luke Faraone +* Lupin * Lupo +* lwelling +* m4tx * Madman +* madurangasiriwardena +* Magnus Manske * Manuel Menal +* Manuel Schneider +* Marc Ordinas i Llopis * Marc-André Pelletier * Marcin Cieślak +* Marco Falke +* Marco Schuster +* MarcoAurelio * Marcus Buck +* Marius Hoch +* Mark Bergsma +* Mark Clements * Mark Hershberger * Mark Holmquist +* Marko Obrovac +* Markus Glaser +* Markus Krötzsch * Marooned +* Martin Urbanec +* Massaf +* Matěj Grabovský +* matejsuchanek * Mathias Ertl * mati +* Matt Fitzpatrick +* Matt Johnston +* Matt Russell +* Matthew Bowker * Matthew Britton +* Matthew Flaschen +* Matthias Jordan * Matthias Mullie +* MatthiasDD * Max +* Max Semenik * Max Sikström +* mayankmadan +* Meno25 * merl +* Merlijn S. van Deen +* MGChecker +* mgooley +* mhutti1 * Michael Dale * Michael De La Rue +* Michael Holloway * Michael M. * Michael Newton * Michael Walsh +* Michał Łazowik +* Michał Roszka +* Michał Zieliński * Mike Horvath +* Minh Nguyễn +* MinuteElectron +* Misza13 +* mjbmr * moejoe0000 +* Mohamed Magdy +* Molly White +* Moriel Schottlender * Mormegil +* Mr. E23 * MrBlueSky * MrPete +* Mukunda Modell +* Mwalker +* mwjames * mybugs.mail * MZMcBride +* nadeesha * Nakon +* Namit * Nathan Larson +* Nathaniel Herman +* Neil Kandalgaonkar +* Nemo bis * nephele +* Nicholas Pisarro, Jr +* Nick Jenkins +* nicoco007 +* Nicolas Dumazet +* Nicolas Weeger * Nik +* Nik Everett +* Niklas Laxström * Nikola Kovacs +* Nikola Smolenski * Nikolaos S. Karastathis +* Nimish Gautam * Nischay Nahata +* nischayn22 +* nomoa +* nullspoon +* Nuria Ruiz * Nx.devnull +* Ocean behind ears * Olaf Lenz * Olivier Finlay Beaton +* onei +* opatel99 +* Oren Held +* Ori Livneh +* oskar.jauch@gmail.com +* OverlordQ +* Owen Davis +* Paa Kwesi Imbeah +* paladox * Patricio Molina +* Patrick Reilly +* Patrick Westerhoff +* Pau Giner * Paul Copperman * Paul Oranje +* Pavel Astakhov +* Pavel Selitskas +* Pcoombe +* Perside Rosalie * Peter Gehres +* Peter Hedenskog +* Peter Potrowl +* Petr Bena +* Petr Kadlec * Petr Onderka +* Petr Pchelko +* Philip Tzou +* physikerwelt (Moritz Schubotz) * PieRRoMaN +* Pikne +* PiRSquared17 +* Platonides +* Pmlineditor +* pmolina +* prageck +* Pranav Ravichandran +* PranavK +* Prateek Saxena +* Priyanka Dhanda +* Prod +* ptarjan +* pubudu538 +* Purodha Blissenbach +* quiddity * quietust +* Quim Gil +* rahul21 +* Raimond Spekking +* Ramunas Geciauskas +* Remember the dot * René Kijewski +* Reza * rgcjonas +* Ricordisamoa +* rillke +* River Tarnell +* Roan Kattouw +* Rob Church +* Rob Lanphier * Rob Moen +* Robert Hoenig +* Robert Leverington +* Robert Rohde +* Robert Stojnić * Robert Treat +* Robert Vogel +* Robin Pepermans +* robinhood701 * RockMFR +* Rohan +* Roman Nosov +* Roman Tsukanov +* Rotem Liss +* Rowan Collins +* Russ Nelson * Russell Blau * Rusty Burchfield +* Ruud Koot +* Ryan Bies +* Ryan Finnie +* Ryan Kaldari +* Ryan Lane +* Ryan Schmidt * S Page * Salvatore Ingala +* Sam Reed +* Sam Smith * Santhosh Thottingal +* Schnark +* Scimonster +* scnd * Scott Colcord * se4598 +* Sean Colombo +* Sean Pringle +* Seb35 +* Sebastian Brückner * Sébastien Santoro +* Sergio Santoro +* Sethakill +* Shahyar +* Shane Gibbons +* Shane King +* Shinjiman +* shirayuki +* Sidhant Gupta +* Siebrand Mazeland * Simon Walker +* Smriti Singh * Solitarius +* Sorawee Porncharoenwase * Søren Løvborg * Southparkfan +* Soxred93 +* SQL * Srikanth Lakshmanan +* Stanislav Malyshev * Stefano Codari +* Steinsplitter +* Stephan Gambke +* Stephan Muggli +* Stephane Bisson +* Stephen Liang +* Steve Sanbeg +* Steven Roddis * Str4nd * Subramanya Sastry +* Sumit Asthana * svip +* Swalling +* Szymon Świerkosz +* T.D. Corell +* Tarquin +* The Discoverer * The Evil IP address +* theopolisme +* Thiemo Mättig (WMDE) +* This, that and the other +* tholam +* Thomas Arrow +* Thomas Bleher +* Thomas Dalton +* Thomas Gries +* ThomasV +* Tim Hollmann * Tim Landscheidt +* Tim Laqua +* Tim Starling +* Timo Tijhof +* Tina Johnson * Tisane +* tjlsangria +* Tjones +* TK-999 +* Tobias Gritschacher +* Tom Arrow +* Tom Gilder +* Tom Maaswinkel +* Tomasz Finc +* Tomasz W. Kozlowski +* Tomasz Wegrzanowski +* tomek +* Tony Thomas +* Tpt +* Trevor Parscal +* TyA +* Tychay +* Tyler Anthony Romeo +* Tyler Cipriani +* Tyler Romeo +* U-REDMOND\emadelw +* UltrasonicNXT * Umherirrender +* utkarsh95 * Van de Bugger +* Viačeslav +* Victor Porton +* Victor Vasiliev +* victorbarbu * Ville Stadista +* vishnu * Vitaliy Filippov * Vivek Ghaisas +* vlakoff +* Volker E * Waldir Pimenta +* wctaiwan +* Wikinaut +* Wil Mahan * William Demchick +* withoutaname +* WMDE-Fisch +* X! +* XP1 +* Yaron Koren +* Yaroslav Melnychuk +* Yesid Carrillo +* Yogesh K S +* Yongmin Hong +* yoonghm +* Yuri Astrakhan * Yusuke Matsubara * Yuvi Panda * Zachary Hauri +* Zak Greant +* Željko Filipin +* Zhaofeng Li +* Zhengzhu Feng +* Zppix +* محمد شعیب + == Translators == diff --git a/Gruntfile.js b/Gruntfile.js index a08db5c780..55b7932f00 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,33 +1,44 @@ -/*jshint node:true */ +/* eslint-env node */ + module.exports = function ( grunt ) { - grunt.loadNpmTasks( 'grunt-contrib-copy' ); - grunt.loadNpmTasks( 'grunt-contrib-jshint' ); - grunt.loadNpmTasks( 'grunt-stylelint' ); - grunt.loadNpmTasks( 'grunt-contrib-watch' ); - grunt.loadNpmTasks( 'grunt-banana-checker' ); - grunt.loadNpmTasks( 'grunt-jscs' ); - grunt.loadNpmTasks( 'grunt-jsonlint' ); - grunt.loadNpmTasks( 'grunt-karma' ); var wgServer = process.env.MW_SERVER, wgScriptPath = process.env.MW_SCRIPT_PATH, karmaProxy = {}; + grunt.loadNpmTasks( 'grunt-banana-checker' ); + grunt.loadNpmTasks( 'grunt-contrib-copy' ); + grunt.loadNpmTasks( 'grunt-contrib-watch' ); + grunt.loadNpmTasks( 'grunt-eslint' ); + grunt.loadNpmTasks( 'grunt-jsonlint' ); + grunt.loadNpmTasks( 'grunt-karma' ); + grunt.loadNpmTasks( 'grunt-stylelint' ); + karmaProxy[ wgScriptPath ] = wgServer + wgScriptPath; grunt.initConfig( { - jshint: { - options: { - jshintrc: true - }, - all: '.' - }, - jscs: { - all: '.' + eslint: { + all: [ + '**/*.js', + '!docs/**', + '!tests/**', + '!node_modules/**', + '!resources/lib/**', + '!resources/src/jquery.tipsy/**', + '!resources/src/jquery/jquery.farbtastic.js', + '!resources/src/mediawiki.libs/**', + '!vendor/**', + // Explicitly say "**/*.js" here in case of symlinks + '!extensions/**/*.js', + '!skins/**/*.js', + // Skip functions aren't even parseable + '!resources/src/dom-level2-skip.js', + '!resources/src/es5-skip.js', + '!resources/src/mediawiki.hidpi-skip.js' + ] }, jsonlint: { all: [ - '.jscsrc', '**/*.json', '!{docs/js,extensions,node_modules,skins,vendor}/**' ] @@ -48,7 +59,7 @@ module.exports = function ( grunt ) { }, watch: { files: [ - '.{stylelintrc,jscsrc,jshintignore,jshintrc}', + '.{stylelintrc,eslintrc.json}', '**/*', '!{docs,extensions,node_modules,skins,vendor}/**' ], @@ -103,7 +114,7 @@ module.exports = function ( grunt ) { return !!( process.env.MW_SERVER && process.env.MW_SCRIPT_PATH ); } ); - grunt.registerTask( 'lint', [ 'jshint', 'jscs', 'jsonlint', 'banana', 'stylelint' ] ); + grunt.registerTask( 'lint', [ 'eslint', 'banana', 'stylelint' ] ); grunt.registerTask( 'qunit', [ 'assert-mw-env', 'karma:main' ] ); grunt.registerTask( 'test', [ 'lint' ] ); diff --git a/HISTORY b/HISTORY index 6de7de4adc..28a9b869df 100644 --- a/HISTORY +++ b/HISTORY @@ -1,4 +1,328 @@ -Change notes from older releases. For current info see RELEASE-NOTES-1.28. +Change notes from older releases. For current info see RELEASE-NOTES-1.29. + +== MediaWiki 1.28 == + +=== Changes since 1.28.0-rc1 === +* (T148957) Replace wgShowExceptionDetails with wgShowDBErrorBacktrace on db + errors. +* (T148956) Only apply wgDBschema to postgres/mssql. +* (T145991) Introduce separate log action for deleting pages on move. +* (T141474) (T110464) Bypass login page if no user input is required. + +=== Changes since 1.28.0-rc0 === +* (T142210) The changes to move the parser "NewPP limit report" from a HTML + comment to a machine-readable JavaScript config option 'wgPageParseReport' + have been undone. They caused the human-readable limit report to be shown + incompletely or not at all. ParserOutput::setLimitReportData() and + getLimitReportData() behave as they did in MediaWiki 1.27 again. +* (T149510) Value of {{DISPLAYTITLE:}} parser function will not be used for + the text of subheadings on a category page when creating it. This wasn't + working correctly. +* (T106793) MediaWiki will no longer try to perform a HTTP redirect to the + canonical pretty URL when a non-pretty URL is used. It resulted in redirect + loops in some clients and in some server configurations. This undoes a change + made in MediaWiki 1.26. +* (T149759) manifest_version: 2 was removed. + +=== Configuration changes in 1.28 === +* $wgSend404Code now affects status code of action=history if the page is not there. +* BREAKING CHANGE: $wgHTTPProxy is now *required* for all external requests + made by MediaWiki via a proxy. Relying on the http_proxy environment + variable is no longer supported. +* The load.php entry point now enforces the existing policy of not allowing + access to session data, which includes the session user and the session + user's language. If such access is attempted, an exception will be thrown. +* The number of internal PBKDF2 iterations used to derive the session secret + is configurable via $wgSessionPbkdf2Iterations. +* Upload dialog's file upload log comment can now be configured separately for + local and foreign uploads. +* $wgForeignUploadTargets now defaults to `[ 'local' ]`, where `'local'` + signifies local uploads. A value of `[]` (empty array) now means that + no upload targets are allowed, effectively disabling the upload dialog. +* The deprecated $wgEditEncoding variable has been removed; it was only used + for Esperanto language character conversion. You are now recommended to use + input methods provided by the UniversalLanguageSelector extension. +* When $wgPingback is true, MediaWiki will periodically ping + https://www.mediawiki.org/beacon with basic information about the local + MediaWiki installation. This data includes, for example, the type of system, + PHP version, and chosen database backend. This behavior is off by default. +* When $wgEditSubmitButtonLabelPublish is true, MediaWiki will label the button + to store-to-database-and-show-to-others as "Publish page"/"Publish changes"; + if false, the default, they will be "Save page"/"Save changes". +* The 'editcontentmodel' permission is now granted to all logged-in users ('user'). + instead of just administrators ('sysop'). Documentation for this feature is + available at . +* $wgRevisionCacheExpiry is now set to one week by default instead of being disabled. +* Magic links are now disabled by default, and can be re-enabled by modifying the value + of $wgEnableMagicLinks. Their usage is discouraged, but if they are manually enabled, + a tracking category will be added to help identify usage and make it easier to migrate + away from. If you depend upon magic link functionality, it is requested that you comment + on and + explain your use case(s). +* New config variable $wgCSPFalsePositiveUrls to control what URLs to ignore + in upcoming Content-Security-Policy feature's reporting. + +=== New features in 1.28 === +* User::isBot() method for checking if an account is a bot role account. +* Added a new 'slideshow' mode for galleries. +* Added a new hook, 'UserIsBot', to aid in determining if a user is a bot. +* Added a new hook, 'ApiMakeParserOptions', to allow extensions to better + interact with API parsing. +* Added a new hook, 'UploadVerifyUpload', which can be used to reject a file + upload. Unlike 'UploadVerifyFile' it provides information about upload comment + and the file description page, but does not run for uploads to stash. +* (T141604) Extensions can now provide a better error message when their + maintenance scripts are run without the extension being installed. +* (T8948) Numeric sorting in categories is now supported by setting $wgCategoryCollation + to 'uca-default-u-kn' or 'uca--u-kn'. If you can't use UCA collations, + a 'numeric' collation is also available. If migrating from another + collation, you will need to run the updateCollation.php maintenance script. +* Two new codes have been added to #time parser function: "xit" for days in current + month, and "xiz" for days passed in the year, both in Iranian calendar. +* mw.Api has a new option, useUS, to use U+001F (Unit Separator) when + appropriate for sending multi-valued parameters. This defaults to true when + the mw.Api instance seems to be for the local wiki. +* After a client performs an action which alters a database that has replica databases, + MediaWiki will wait for the replica databases to synchronize with the master database + while it renders the HTML output. However, if the output is a redirect to another wiki + on the wiki farm with a different domain, MediaWiki will instead alter the redirect + URL to include a ?cpPosTime parameter that triggers the database synchronization when + the URL is followed by the client. The same-domain case uses a new cpPosTime cookie. +* Added new hooks, 'ApiQueryBaseBeforeQuery', 'ApiQueryBaseAfterQuery', and + 'ApiQueryBaseProcessRow', to make it easier for extensions to add 'prop' and + 'show' parameters to existing API query modules. + +=== External library changes in 1.28 === + +==== Upgraded external libraries ==== +* Updated es5-shim from v4.1.5 to v4.5.8 +* Updated composer/semver from v1.4.1 to v1.4.2 +* Updated wikimedia/php-session-serializer from v1.0.3 to v1.0.4 + +==== New external libraries ==== +* Added wikimedia/scoped-callback v1.0.0 +* Added wikimedia/wait-condition-loop v1.0.1 + +=== Bug fixes in 1.28 === +* (T146496) action=history pages should return 404 HTTP error code if the page does not exist +* (T137264) SECURITY: XSS in unclosed internal links +* (T133147) SECURITY: Escape '<' and ']]>' in inline - - - - + + + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-ltr-progressive.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-ltr-progressive.png index 183aaeb7aa..af290b9654 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-ltr-progressive.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-ltr-progressive.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-ltr-progressive.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-ltr-progressive.svg index fedf7877a2..e1f33d8f84 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-ltr-progressive.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-ltr-progressive.svg @@ -1,7 +1,6 @@ - - - - + + + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-ltr.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-ltr.png index 82fbd14db4..e8b2911d8f 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-ltr.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-ltr.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-ltr.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-ltr.svg index 6d95fc6693..fffbcdd3de 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-ltr.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-ltr.svg @@ -1,7 +1,6 @@ - - - - + + + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl-invert.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl-invert.png index 628de3db59..f40c30327d 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl-invert.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl-invert.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl-invert.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl-invert.svg index aeb562c74e..8ed760bd6c 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl-invert.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl-invert.svg @@ -1,7 +1,6 @@ - - - - + + + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl-progressive.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl-progressive.png index 47af038789..a5095a1ab3 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl-progressive.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl-progressive.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl-progressive.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl-progressive.svg index 6c7b5fc591..34ec7c004b 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl-progressive.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl-progressive.svg @@ -1,7 +1,6 @@ - - - - + + + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl.png index 64d1cf1d38..2f5e05dfad 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl.svg index 807cdd9143..7b903c4b3d 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/bigger-rtl.svg @@ -1,7 +1,6 @@ - - - - + + + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/block-destructive.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/block-destructive.png index 53460bea18..54b9f62ffa 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/block-destructive.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/block-destructive.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/block-destructive.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/block-destructive.svg index abf656f313..f01a7790d4 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/block-destructive.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/block-destructive.svg @@ -1,4 +1,4 @@ - + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/cancel-destructive.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/cancel-destructive.png index 000e529e3c..f574a39231 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/cancel-destructive.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/cancel-destructive.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/cancel-destructive.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/cancel-destructive.svg index b2b01790ca..3391d4e8eb 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/cancel-destructive.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/cancel-destructive.svg @@ -1,5 +1,5 @@ - + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/check-destructive.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/check-destructive.png index 0cc9169ee5..305f41d5e6 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/check-destructive.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/check-destructive.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/check-destructive.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/check-destructive.svg index 7e3dc53dc9..059f0bd146 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/check-destructive.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/check-destructive.svg @@ -1,4 +1,4 @@ - + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/lock-ltr-destructive.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/lock-ltr-destructive.png index 42311de116..e16f04292f 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/lock-ltr-destructive.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/lock-ltr-destructive.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/lock-ltr-destructive.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/lock-ltr-destructive.svg index a9900c18e2..2cfa62e84f 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/lock-ltr-destructive.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/lock-ltr-destructive.svg @@ -1,4 +1,4 @@ - + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/lock-rtl-destructive.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/lock-rtl-destructive.png index 72d6a7b6b4..29cd2b57a2 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/lock-rtl-destructive.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/lock-rtl-destructive.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/lock-rtl-destructive.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/lock-rtl-destructive.svg index 2811b252d6..2daea47b1a 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/lock-rtl-destructive.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/lock-rtl-destructive.svg @@ -1,4 +1,4 @@ - + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin-invert.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin-invert.png index 55a68db7c6..441fe2df18 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin-invert.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin-invert.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin-invert.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin-invert.svg index 663913a5c7..548e136734 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin-invert.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin-invert.svg @@ -1,4 +1,4 @@ - + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin-progressive.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin-progressive.png index c1676e6383..2e7107d3ee 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin-progressive.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin-progressive.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin-progressive.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin-progressive.svg index a9631cc999..daf032a04c 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin-progressive.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin-progressive.svg @@ -1,4 +1,4 @@ - + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin.png index 536e77c8a3..ddb1c5cda7 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin.svg index f1fa246a69..26fb6b7286 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPin.svg @@ -1,4 +1,4 @@ - + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr-invert.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr-invert.png index 607354cf2b..ee5de90d28 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr-invert.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr-invert.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr-invert.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr-invert.svg index 43074afe5a..cfa98d8416 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr-invert.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr-invert.svg @@ -1,5 +1,6 @@ - - + + + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr-progressive.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr-progressive.png index 2fcf2e1769..036a31dc59 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr-progressive.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr-progressive.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr-progressive.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr-progressive.svg index 7dc09d4b54..7cf1509e00 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr-progressive.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr-progressive.svg @@ -1,5 +1,6 @@ - - + + + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr.png index 88160bcc4a..d8c1691e5a 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr.svg index d84970fd15..9d71335aaf 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-ltr.svg @@ -1,5 +1,6 @@ - - + + + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl-invert.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl-invert.png index 6ea82260f3..934d5ccc6b 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl-invert.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl-invert.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl-invert.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl-invert.svg index 6a4af93986..8b02ddbb71 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl-invert.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl-invert.svg @@ -1,5 +1,5 @@ - - + + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl-progressive.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl-progressive.png index 56b79248be..be7c51e961 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl-progressive.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl-progressive.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl-progressive.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl-progressive.svg index 8108685751..c920c8d5be 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl-progressive.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl-progressive.svg @@ -1,5 +1,5 @@ - - + + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl.png index 20aba25570..7cc1f74c6d 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl.svg index 8f35458ace..03c484abb1 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/mapPinAdd-rtl.svg @@ -1,5 +1,5 @@ - - + + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr-invert.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr-invert.png index 84b1bcd153..1b597da510 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr-invert.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr-invert.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr-invert.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr-invert.svg index 0eb2bfa0e4..b29f71839c 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr-invert.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr-invert.svg @@ -1,7 +1,6 @@ - - - - + + + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr-progressive.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr-progressive.png index ba4fcefd76..2878f2358f 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr-progressive.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr-progressive.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr-progressive.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr-progressive.svg index b3c6452f85..9b7962ef1c 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr-progressive.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr-progressive.svg @@ -1,7 +1,6 @@ - - - - + + + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr.png index f5e89ba8e9..a9b29d887d 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr.svg index 82d16af934..943125224f 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-ltr.svg @@ -1,7 +1,6 @@ - - - - + + + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl-invert.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl-invert.png index c9cdd7741c..f94184a449 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl-invert.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl-invert.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl-invert.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl-invert.svg index a87f7ba50b..171b31dac3 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl-invert.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl-invert.svg @@ -1,7 +1,6 @@ - - - - + + + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl-progressive.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl-progressive.png index 03a4bccd56..99abfdbe5b 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl-progressive.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl-progressive.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl-progressive.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl-progressive.svg index 64d103c539..23c0b09a98 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl-progressive.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl-progressive.svg @@ -1,7 +1,6 @@ - - - - + + + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl.png index e07c7b0d10..006bd2bd1c 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl.svg index 7466f48b06..d2d28587a4 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/smaller-rtl.svg @@ -1,7 +1,6 @@ - - - - + + + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/tag-destructive.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/tag-destructive.png index 55ab6c435e..cf85c4d052 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/tag-destructive.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/tag-destructive.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/tag-destructive.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/tag-destructive.svg index 7048a402b2..0732f2ebe6 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/tag-destructive.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/tag-destructive.svg @@ -1,4 +1,4 @@ - + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/trash-destructive.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/trash-destructive.png index c1d2a66790..c367e77b0f 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/trash-destructive.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/trash-destructive.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/trash-destructive.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/trash-destructive.svg index 3ebc63b862..59ad3f280b 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/trash-destructive.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/trash-destructive.svg @@ -1,4 +1,4 @@ - + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/unLock-ltr-destructive.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/unLock-ltr-destructive.png index 8fb039ca5c..2cb27f157c 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/unLock-ltr-destructive.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/unLock-ltr-destructive.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/unLock-ltr-destructive.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/unLock-ltr-destructive.svg index 7ee7522a4f..d45ebac277 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/unLock-ltr-destructive.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/unLock-ltr-destructive.svg @@ -1,4 +1,4 @@ - + diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/unLock-rtl-destructive.png b/resources/lib/oojs-ui/themes/mediawiki/images/icons/unLock-rtl-destructive.png index 7c2786d4c4..fac51b9fdd 100644 Binary files a/resources/lib/oojs-ui/themes/mediawiki/images/icons/unLock-rtl-destructive.png and b/resources/lib/oojs-ui/themes/mediawiki/images/icons/unLock-rtl-destructive.png differ diff --git a/resources/lib/oojs-ui/themes/mediawiki/images/icons/unLock-rtl-destructive.svg b/resources/lib/oojs-ui/themes/mediawiki/images/icons/unLock-rtl-destructive.svg index a5f2721672..5e6d2055a2 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/images/icons/unLock-rtl-destructive.svg +++ b/resources/lib/oojs-ui/themes/mediawiki/images/icons/unLock-rtl-destructive.svg @@ -1,4 +1,4 @@ - + diff --git a/resources/lib/oojs-ui/themes/mediawiki/indicators.json b/resources/lib/oojs-ui/themes/mediawiki/indicators.json index 349227a4f5..91d0358d19 100644 --- a/resources/lib/oojs-ui/themes/mediawiki/indicators.json +++ b/resources/lib/oojs-ui/themes/mediawiki/indicators.json @@ -15,7 +15,7 @@ "color": "#36c" }, "destructive": { - "color": "#c33" + "color": "#d33" }, "warning": { "color": "#ff5d00" diff --git a/resources/lib/qunitjs/qunit.css b/resources/lib/qunitjs/qunit.css index 8c78b67e6d..ae68fc412e 100644 --- a/resources/lib/qunitjs/qunit.css +++ b/resources/lib/qunitjs/qunit.css @@ -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 */ diff --git a/resources/lib/qunitjs/qunit.js b/resources/lib/qunitjs/qunit.js index 84873ae576..5df0822ea4 100644 --- a/resources/lib/qunitjs/qunit.js +++ b/resources/lib/qunitjs/qunit.js @@ -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é -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 ? "
" : "\n" : this.HTML ? " " : " "; }, - // 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.} 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.} 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: - * ABXYCD - * AXCD - * ABXC - * AXCD - * ABXC - */ - 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.} 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 ] = "" + data + ""; - break; - case DIFF_DELETE: - html[ x ] = "" + data + ""; - break; - case DIFF_EQUAL: - html[ x ] = "" + data + ""; - 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 "'"; + case "\"": + return """; + case "<": + return "<"; + case ">": + return ">"; + case "&": + return "&"; } - 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.} 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.} 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.} 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 += ""; + } else { + urlConfigHtml += ""; } + } - // 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.} 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.} 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 += "" + + ""; + + 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 = "" + header.innerHTML + + " "; + } +} + +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...
 "; + } +} + +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 "
Rerunning selected tests: " + + escapeText( testId.join( ", " ) ) + + " Run all tests
"; +} + +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 = + "

" + escapeText( document.title ) + "

" + + "

" + + "
" + + appendFilteredTest() + + "

" + + "
    "; + } + + 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.} 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.} 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: abcxxxxxxdef - // -> abcxxxdef - // e.g: xxxabcdefxxx - // -> defxxxabc - // 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.
    ", + "", + details.passed, + " assertions of ", + details.total, + " passed, ", + details.failed, + " 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.}} - * 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 = "" + escapeText( module ) + ": "; + } - // '\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 += "" + escapeText( name ) + ""; - /** - * 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.} diffs Array of diff tuples. - * @param {!Array.} 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.} 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:
    " : + "Running:
    " ) + + 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: ABAC -> ABAC - 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( /\"/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 = "" + message + ""; + message += "@ " + details.runtime + " ms"; - // 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 += ""; - return text; - }; -}() ); + if ( actual !== expected ) { -// Get a reference to the global object, like window in browsers -}( (function() { - return this; -})() )); + message += ""; -(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 += ""; + } + } else if ( expected.indexOf( "[object Array]" ) !== -1 || + expected.indexOf( "[object Object]" ) !== -1 ) { + message += ""; + } else { + message += ""; + } -// 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 += ""; + } - 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 += "
    Expected:
    " +
    +			escapeText( expected ) +
    +			"
    Result:
    " +
    +				escapeText( actual ) + "
    Diff:
    " +
    +					diff + "
    Message: " + + "Diff suppressed as the depth of object is more than current max depth (" + + QUnit.config.maxDepth + ").

    Hint: Use QUnit.dump.maxDepth to " + + " run with a higher max depth or " + + "Rerun without max depth.

    Message: " + + "Diff suppressed as the expected and actual results have an equivalent" + + " serialization
    Source:
    " +
    +				escapeText( details.source ) + "
    "; - // 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 += "" + + "" + + "
    Source:
    " +
    +			escapeText( details.source ) + "
    "; } - qunit = id( "qunit" ); - if ( qunit ) { - qunit.innerHTML = - "

    " + escapeText( document.title ) + "

    " + - "

    " + - "
    " + - "

    " + - "
      "; - } + 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...
       "; + 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 "'"; - case "\"": - return """; - case "<": - return "<"; - case ">": - return ">"; - case "&": - return "&"; - } - }); -} + // 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 ? + "" + bad + ", " + "" + good + ", " : + ""; - // Standards-based browsers - elem.addEventListener( type, fn, false ); - } else if ( elem.attachEvent ) { + testTitle.innerHTML += " (" + testCounts + + details.assertions.length + ")"; + + 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 = "Source: " + 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.} 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 += ""; - } else { - urlConfigHtml += ""; + 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.} 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: + * ABXYCD + * AXCD + * ABXC + * AXCD + * ABXC + */ + 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.} 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 ] = "" + escapeText( data ) + ""; + break; + case DIFF_DELETE: + html[ x ] = "" + escapeText( data ) + ""; + break; + case DIFF_EQUAL: + html[ x ] = "" + escapeText( data ) + ""; + 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.} 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 += "" + - ""; + // 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 = "" + header.innerHTML + " "; - } -} + 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.} 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.} 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...
       "; - } -} + // 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 "
      Rerunning selected tests: " + - escapeText( testId.join(", ") ) + - " " + "Run all tests" + "
      "; -} + // 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.} 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.} 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 = - "

      " + escapeText( document.title ) + "

      " + - "

      " + - "
      " + - appendFilteredTest() + - "

      " + - "
        "; - } + // 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.
        ", - "", - details.passed, - " assertions of ", - details.total, - " passed, ", - details.failed, - " 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 = "" + escapeText( module ) + ": "; - } + /** + * 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.} 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 += "" + escapeText( name ) + ""; + // 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.} 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:
        " : - "Running:
        " ) + - 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(/\"/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 = "" + message + ""; - message += "@ " + details.runtime + " ms"; + // 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 += ""; + // Find any overlaps between deletions and insertions. + // e.g: abcxxxxxxdef + // -> abcxxxdef + // e.g: xxxabcdefxxx + // -> defxxxabc + // 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 += ""; + // 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 += ""; - } - } else if ( expected.indexOf( "[object Array]" ) !== -1 || - expected.indexOf( "[object Object]" ) !== -1 ) { - message += ""; + /** + * 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 += ""; + // 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 += "
        Expected:
        " +
        -			expected +
        -			"
        Result:
        " +
        -				actual + "
        Diff:
        " +
        -					diff + "
        Message: " + - "Diff suppressed as the depth of object is more than current max depth (" + - QUnit.config.maxDepth + ").

        Hint: Use QUnit.dump.maxDepth to " + - " run with a higher max depth or " + - "Rerun without max depth.

        Source:
        " +
        -				escapeText( details.source ) + "
        "; + // 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 += "" + - "" + - "
        Source:
        " +
        -			escapeText( details.source ) + "
        "; - } + // 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.}} + * 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.} diffs Array of diff tuples. + * @param {!Array.} 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.} 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 ? - "" + bad + ", " + "" + good + ", " : - ""; + // 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 += " (" + testCounts + - details.assertions.length + ")"; + // Second pass: look for single edits surrounded on both sides by equalities + // which can be shifted sideways to eliminate an equality. + // e.g: ABAC -> ABAC + 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 = "Source: " + 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; + }; +}() ); -})(); +}() ); diff --git a/resources/src/jquery.tipsy/jquery.tipsy.js b/resources/src/jquery.tipsy/jquery.tipsy.js index 2c6a5887e0..ddda432f32 100644 --- a/resources/src/jquery.tipsy/jquery.tipsy.js +++ b/resources/src/jquery.tipsy/jquery.tipsy.js @@ -197,24 +197,18 @@ } }; - if (!options.live) this.each(function() { get(this); }); + this.each(function() { get(this); }); if ( options.trigger != 'manual' ) { var eventIn = options.trigger == 'hover' ? 'mouseenter focus' : 'focus', eventOut = options.trigger == 'hover' ? 'mouseleave blur' : 'blur'; if ( options.live ) { mw.track( 'mw.deprecate', 'tipsy-live' ); - mw.log.warn( 'Use of the "live" option of jquery.tipsy is deprecated.' ); - // XXX: The official status of 'context' is deprecated, and the official status of - // 'selector' is removed, so this really needs to go. - $( this.context ) - .on( eventIn, this.selector, enter ) - .on( eventOut, this.selector, leave ); - } else { - this - .on( eventIn, enter ) - .on( eventOut, leave ); + mw.log.warn( 'Use of the "live" option of jquery.tipsy is no longer supported.' ); } + this + .on( eventIn, enter ) + .on( eventOut, leave ); } return this; diff --git a/resources/src/jquery/jquery.accessKeyLabel.js b/resources/src/jquery/jquery.accessKeyLabel.js index e52d6a7c86..f25944c94e 100644 --- a/resources/src/jquery/jquery.accessKeyLabel.js +++ b/resources/src/jquery/jquery.accessKeyLabel.js @@ -5,217 +5,225 @@ */ ( function ( $, mw ) { -// Cached access key modifiers for used browser -var cachedAccessKeyModifiers, - - // Whether to use 'test-' instead of correct prefix (used for testing) - useTestPrefix = false, - - // tag names which can have a label tag - // https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Form-associated_content - labelable = 'button, input, textarea, keygen, meter, output, progress, select'; - -/** - * Find the modifier keys that need to be pressed together with the accesskey to trigger the input. - * - * The result is dependant on the ua paramater or the current platform. - * For browsers that support accessKeyLabel, #getAccessKeyLabel never calls here. - * Valid key values that are returned can be: ctrl, alt, option, shift, esc - * - * @private - * @param {Object} [ua] An object with a 'userAgent' and 'platform' property. - * @return {Array} Array with 0 or more of the string values: ctrl, option, alt, shift, esc - */ -function getAccessKeyModifiers( ua ) { - // use cached prefix if possible - if ( !ua && cachedAccessKeyModifiers ) { - return cachedAccessKeyModifiers; - } + // Cached access key modifiers for used browser + var cachedAccessKeyModifiers, + + // Whether to use 'test-' instead of correct prefix (used for testing) + useTestPrefix = false, + + // tag names which can have a label tag + // https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Form-associated_content + labelable = 'button, input, textarea, keygen, meter, output, progress, select'; + + /** + * Find the modifier keys that need to be pressed together with the accesskey to trigger the input. + * + * The result is dependant on the ua paramater or the current platform. + * For browsers that support accessKeyLabel, #getAccessKeyLabel never calls here. + * Valid key values that are returned can be: ctrl, alt, option, shift, esc + * + * @private + * @param {Object} [ua] An object with a 'userAgent' and 'platform' property. + * @return {Array} Array with 0 or more of the string values: ctrl, option, alt, shift, esc + */ + function getAccessKeyModifiers( ua ) { + var profile, accessKeyModifiers; + + // use cached prefix if possible + if ( !ua && cachedAccessKeyModifiers ) { + return cachedAccessKeyModifiers; + } - var profile = $.client.profile( ua ), + profile = $.client.profile( ua ); accessKeyModifiers = [ 'alt' ]; - // Classic Opera on any platform - if ( profile.name === 'opera' && profile.versionNumber < 15 ) { - accessKeyModifiers = [ 'shift', 'esc' ]; - - // Chrome and modern Opera on any platform - } else if ( profile.name === 'chrome' || profile.name === 'opera' ) { - accessKeyModifiers = ( - profile.platform === 'mac' - // Chrome on Mac - ? [ 'ctrl', 'option' ] - // Chrome on Windows or Linux - // (both alt- and alt-shift work, but alt with E, D, F etc does not - // work since they are browser shortcuts) - : [ 'alt', 'shift' ] - ); - - // Non-Windows Safari with webkit_version > 526 - } else if ( profile.platform !== 'win' - && profile.name === 'safari' - && profile.layoutVersion > 526 - ) { - accessKeyModifiers = [ 'ctrl', 'alt' ]; - - // Safari/Konqueror on any platform, or any browser on Mac - // (but not Safari on Windows) - } else if ( !( profile.platform === 'win' && profile.name === 'safari' ) - && ( profile.name === 'safari' - || profile.platform === 'mac' - || profile.name === 'konqueror' ) - ) { - accessKeyModifiers = [ 'ctrl' ]; - - // Firefox/Iceweasel 2.x and later - } else if ( ( profile.name === 'firefox' || profile.name === 'iceweasel' ) - && profile.versionBase > '1' - ) { - accessKeyModifiers = [ 'alt', 'shift' ]; - } + // Classic Opera on any platform + if ( profile.name === 'opera' && profile.versionNumber < 15 ) { + accessKeyModifiers = [ 'shift', 'esc' ]; + + // Chrome and modern Opera on any platform + } else if ( profile.name === 'chrome' || profile.name === 'opera' ) { + accessKeyModifiers = ( + profile.platform === 'mac' ? + // Chrome on Mac + [ 'ctrl', 'option' ] : + // Chrome on Windows or Linux + // (both alt- and alt-shift work, but alt with E, D, F etc does not + // work since they are browser shortcuts) + [ 'alt', 'shift' ] + ); + + // Non-Windows Safari with webkit_version > 526 + } else if ( profile.platform !== 'win' && + profile.name === 'safari' && + profile.layoutVersion > 526 + ) { + accessKeyModifiers = [ 'ctrl', 'alt' ]; + + // Safari/Konqueror on any platform, or any browser on Mac + // (but not Safari on Windows) + } else if ( + !( profile.platform === 'win' && profile.name === 'safari' ) && + ( + profile.name === 'safari' || + profile.platform === 'mac' || + profile.name === 'konqueror' + ) + ) { + accessKeyModifiers = [ 'ctrl' ]; + + // Firefox/Iceweasel 2.x and later + } else if ( + ( profile.name === 'firefox' || profile.name === 'iceweasel' ) && + profile.versionBase > '1' + ) { + accessKeyModifiers = [ 'alt', 'shift' ]; + } - // cache modifiers - if ( !ua ) { - cachedAccessKeyModifiers = accessKeyModifiers; + // cache modifiers + if ( !ua ) { + cachedAccessKeyModifiers = accessKeyModifiers; + } + return accessKeyModifiers; } - return accessKeyModifiers; -} -/** - * Get the access key label for an element. - * - * Will use native accessKeyLabel if available (currently only in Firefox 8+), - * falls back to #getAccessKeyModifiers. - * - * @private - * @param {HTMLElement} element Element to get the label for - * @return {string} Access key label - */ -function getAccessKeyLabel( element ) { - // abort early if no access key - if ( !element.accessKey ) { - return ''; - } - // use accessKeyLabel if possible - // http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#dom-accesskeylabel - if ( !useTestPrefix && element.accessKeyLabel ) { - return element.accessKeyLabel; + /** + * Get the access key label for an element. + * + * Will use native accessKeyLabel if available (currently only in Firefox 8+), + * falls back to #getAccessKeyModifiers. + * + * @private + * @param {HTMLElement} element Element to get the label for + * @return {string} Access key label + */ + function getAccessKeyLabel( element ) { + // abort early if no access key + if ( !element.accessKey ) { + return ''; + } + // use accessKeyLabel if possible + // https://html.spec.whatwg.org/multipage/interaction.html#dom-accesskeylabel + if ( !useTestPrefix && element.accessKeyLabel ) { + return element.accessKeyLabel; + } + return ( useTestPrefix ? 'test' : getAccessKeyModifiers().join( '-' ) ) + '-' + element.accessKey; } - return ( useTestPrefix ? 'test' : getAccessKeyModifiers().join( '-' ) ) + '-' + element.accessKey; -} - -/** - * Update the title for an element (on the element with the access key or it's label) to show - * the correct access key label. - * - * @private - * @param {HTMLElement} element Element with the accesskey - * @param {HTMLElement} titleElement Element with the title to update (may be the same as `element`) - */ -function updateTooltipOnElement( element, titleElement ) { - var oldTitle, parts, regexp, newTitle, accessKeyLabel; - oldTitle = titleElement.title; - if ( !oldTitle ) { - // don't add a title if the element didn't have one before - return; - } + /** + * Update the title for an element (on the element with the access key or it's label) to show + * the correct access key label. + * + * @private + * @param {HTMLElement} element Element with the accesskey + * @param {HTMLElement} titleElement Element with the title to update (may be the same as `element`) + */ + function updateTooltipOnElement( element, titleElement ) { + var oldTitle, parts, regexp, newTitle, accessKeyLabel; + + oldTitle = titleElement.title; + if ( !oldTitle ) { + // don't add a title if the element didn't have one before + return; + } - parts = ( mw.msg( 'word-separator' ) + mw.msg( 'brackets' ) ).split( '$1' ); - regexp = new RegExp( $.map( parts, mw.RegExp.escape ).join( '.*?' ) + '$' ); - newTitle = oldTitle.replace( regexp, '' ); - accessKeyLabel = getAccessKeyLabel( element ); + parts = ( mw.msg( 'word-separator' ) + mw.msg( 'brackets' ) ).split( '$1' ); + regexp = new RegExp( $.map( parts, mw.RegExp.escape ).join( '.*?' ) + '$' ); + newTitle = oldTitle.replace( regexp, '' ); + accessKeyLabel = getAccessKeyLabel( element ); - if ( accessKeyLabel ) { - // Should be build the same as in Linker::titleAttrib - newTitle += mw.msg( 'word-separator' ) + mw.msg( 'brackets', accessKeyLabel ); - } - if ( oldTitle !== newTitle ) { - titleElement.title = newTitle; + if ( accessKeyLabel ) { + // Should be build the same as in Linker::titleAttrib + newTitle += mw.msg( 'word-separator' ) + mw.msg( 'brackets', accessKeyLabel ); + } + if ( oldTitle !== newTitle ) { + titleElement.title = newTitle; + } } -} -/** - * Update the title for an element to show the correct access key label. - * - * @private - * @param {HTMLElement} element Element with the accesskey - */ -function updateTooltip( element ) { - var id, $element, $label, $labelParent; - updateTooltipOnElement( element, element ); - - // update associated label if there is one - $element = $( element ); - if ( $element.is( labelable ) ) { - // Search it using 'for' attribute - id = element.id.replace( /"/g, '\\"' ); - if ( id ) { - $label = $( 'label[for="' + id + '"]' ); - if ( $label.length === 1 ) { - updateTooltipOnElement( element, $label[ 0 ] ); + /** + * Update the title for an element to show the correct access key label. + * + * @private + * @param {HTMLElement} element Element with the accesskey + */ + function updateTooltip( element ) { + var id, $element, $label, $labelParent; + updateTooltipOnElement( element, element ); + + // update associated label if there is one + $element = $( element ); + if ( $element.is( labelable ) ) { + // Search it using 'for' attribute + id = element.id.replace( /"/g, '\\"' ); + if ( id ) { + $label = $( 'label[for="' + id + '"]' ); + if ( $label.length === 1 ) { + updateTooltipOnElement( element, $label[ 0 ] ); + } } - } - // Search it as parent, because the form control can also be inside the label element itself - $labelParent = $element.parents( 'label' ); - if ( $labelParent.length === 1 ) { - updateTooltipOnElement( element, $labelParent[ 0 ] ); + // Search it as parent, because the form control can also be inside the label element itself + $labelParent = $element.parents( 'label' ); + if ( $labelParent.length === 1 ) { + updateTooltipOnElement( element, $labelParent[ 0 ] ); + } } } -} - -/** - * Update the titles for all elements in a jQuery selection. - * - * @return {jQuery} - * @chainable - */ -$.fn.updateTooltipAccessKeys = function () { - return this.each( function () { - updateTooltip( this ); - } ); -}; -/** - * getAccessKeyModifiers - * - * @method updateTooltipAccessKeys_getAccessKeyModifiers - * @inheritdoc #getAccessKeyModifiers - */ -$.fn.updateTooltipAccessKeys.getAccessKeyModifiers = getAccessKeyModifiers; - -/** - * getAccessKeyLabel - * - * @method updateTooltipAccessKeys_getAccessKeyLabel - * @inheritdoc #getAccessKeyLabel - */ -$.fn.updateTooltipAccessKeys.getAccessKeyLabel = getAccessKeyLabel; - -/** - * getAccessKeyPrefix - * - * @method updateTooltipAccessKeys_getAccessKeyPrefix - * @deprecated since 1.27 Use #getAccessKeyModifiers - */ -$.fn.updateTooltipAccessKeys.getAccessKeyPrefix = function ( ua ) { - return getAccessKeyModifiers( ua ).join( '-' ) + '-'; -}; - -/** - * Switch test mode on and off. - * - * @method updateTooltipAccessKeys_setTestMode - * @param {boolean} mode New mode - */ -$.fn.updateTooltipAccessKeys.setTestMode = function ( mode ) { - useTestPrefix = mode; -}; - -/** - * @class jQuery - * @mixins jQuery.plugin.accessKeyLabel - */ + /** + * Update the titles for all elements in a jQuery selection. + * + * @return {jQuery} + * @chainable + */ + $.fn.updateTooltipAccessKeys = function () { + return this.each( function () { + updateTooltip( this ); + } ); + }; + + /** + * getAccessKeyModifiers + * + * @method updateTooltipAccessKeys_getAccessKeyModifiers + * @inheritdoc #getAccessKeyModifiers + */ + $.fn.updateTooltipAccessKeys.getAccessKeyModifiers = getAccessKeyModifiers; + + /** + * getAccessKeyLabel + * + * @method updateTooltipAccessKeys_getAccessKeyLabel + * @inheritdoc #getAccessKeyLabel + */ + $.fn.updateTooltipAccessKeys.getAccessKeyLabel = getAccessKeyLabel; + + /** + * getAccessKeyPrefix + * + * @method updateTooltipAccessKeys_getAccessKeyPrefix + * @deprecated since 1.27 Use #getAccessKeyModifiers + * @param {Object} [ua] An object with a 'userAgent' and 'platform' property. + * @return {string} + */ + $.fn.updateTooltipAccessKeys.getAccessKeyPrefix = function ( ua ) { + return getAccessKeyModifiers( ua ).join( '-' ) + '-'; + }; + + /** + * Switch test mode on and off. + * + * @method updateTooltipAccessKeys_setTestMode + * @param {boolean} mode New mode + */ + $.fn.updateTooltipAccessKeys.setTestMode = function ( mode ) { + useTestPrefix = mode; + }; + + /** + * @class jQuery + * @mixins jQuery.plugin.accessKeyLabel + */ }( jQuery, mediaWiki ) ); diff --git a/resources/src/jquery/jquery.autoEllipsis.js b/resources/src/jquery/jquery.autoEllipsis.js index fd7e8d1e39..8716b69405 100644 --- a/resources/src/jquery/jquery.autoEllipsis.js +++ b/resources/src/jquery/jquery.autoEllipsis.js @@ -3,169 +3,169 @@ */ ( function ( $ ) { -var - // Cache ellipsed substrings for every string-width-position combination - cache = {}, + var + // Cache ellipsed substrings for every string-width-position combination + cache = {}, - // Use a separate cache when match highlighting is enabled - matchTextCache = {}; + // Use a separate cache when match highlighting is enabled + matchTextCache = {}; -// Due to -// jscs:disable jsDoc -/** - * Automatically truncate the plain text contents of an element and add an ellipsis - * - * @param {Object} options - * @param {'left'|'center'|'right'} [options.position='center'] Where to remove text. - * @param {boolean} [options.tooltip=false] Whether to show a tooltip with the remainder - * of the text. - * @param {boolean} [options.restoreText=false] Whether to save the text for restoring - * later. - * @param {boolean} [options.hasSpan=false] Whether the element is already a container, - * or if the library should create a new container for it. - * @param {string|null} [options.matchText=null] Text to highlight, e.g. search terms. - * @return {jQuery} - * @chainable - */ -$.fn.autoEllipsis = function ( options ) { - options = $.extend( { - position: 'center', - tooltip: false, - restoreText: false, - hasSpan: false, - matchText: null - }, options ); + // Due to + // jscs:disable jsDoc + /** + * Automatically truncate the plain text contents of an element and add an ellipsis + * + * @param {Object} options + * @param {'left'|'center'|'right'} [options.position='center'] Where to remove text. + * @param {boolean} [options.tooltip=false] Whether to show a tooltip with the remainder + * of the text. + * @param {boolean} [options.restoreText=false] Whether to save the text for restoring + * later. + * @param {boolean} [options.hasSpan=false] Whether the element is already a container, + * or if the library should create a new container for it. + * @param {string|null} [options.matchText=null] Text to highlight, e.g. search terms. + * @return {jQuery} + * @chainable + */ + $.fn.autoEllipsis = function ( options ) { + options = $.extend( { + position: 'center', + tooltip: false, + restoreText: false, + hasSpan: false, + matchText: null + }, options ); - return this.each( function () { - var $trimmableText, - text, trimmableText, w, pw, - l, r, i, side, m, - // container element - used for measuring against - $container = $( this ); + return this.each( function () { + var $trimmableText, + text, trimmableText, w, pw, + l, r, i, side, m, + // container element - used for measuring against + $container = $( this ); - if ( options.restoreText ) { - if ( !$container.data( 'autoEllipsis.originalText' ) ) { - $container.data( 'autoEllipsis.originalText', $container.text() ); - } else { - $container.text( $container.data( 'autoEllipsis.originalText' ) ); + if ( options.restoreText ) { + if ( !$container.data( 'autoEllipsis.originalText' ) ) { + $container.data( 'autoEllipsis.originalText', $container.text() ); + } else { + $container.text( $container.data( 'autoEllipsis.originalText' ) ); + } } - } - // trimmable text element - only the text within this element will be trimmed - if ( options.hasSpan ) { - $trimmableText = $container.children( options.selector ); - } else { - $trimmableText = $( '' ) - .css( 'whiteSpace', 'nowrap' ) - .text( $container.text() ); - $container - .empty() - .append( $trimmableText ); - } + // trimmable text element - only the text within this element will be trimmed + if ( options.hasSpan ) { + $trimmableText = $container.children( options.selector ); + } else { + $trimmableText = $( '' ) + .css( 'whiteSpace', 'nowrap' ) + .text( $container.text() ); + $container + .empty() + .append( $trimmableText ); + } - text = $container.text(); - trimmableText = $trimmableText.text(); - w = $container.width(); - pw = 0; + text = $container.text(); + trimmableText = $trimmableText.text(); + w = $container.width(); + pw = 0; - // Try cache - if ( options.matchText ) { - if ( !( text in matchTextCache ) ) { - matchTextCache[ text ] = {}; - } - if ( !( options.matchText in matchTextCache[ text ] ) ) { - matchTextCache[ text ][ options.matchText ] = {}; - } - if ( !( w in matchTextCache[ text ][ options.matchText ] ) ) { - matchTextCache[ text ][ options.matchText ][ w ] = {}; - } - if ( options.position in matchTextCache[ text ][ options.matchText ][ w ] ) { - $container.html( matchTextCache[ text ][ options.matchText ][ w ][ options.position ] ); - if ( options.tooltip ) { - $container.attr( 'title', text ); + // Try cache + if ( options.matchText ) { + if ( !( text in matchTextCache ) ) { + matchTextCache[ text ] = {}; } - return; - } - } else { - if ( !( text in cache ) ) { - cache[ text ] = {}; - } - if ( !( w in cache[ text ] ) ) { - cache[ text ][ w ] = {}; - } - if ( options.position in cache[ text ][ w ] ) { - $container.html( cache[ text ][ w ][ options.position ] ); - if ( options.tooltip ) { - $container.attr( 'title', text ); + if ( !( options.matchText in matchTextCache[ text ] ) ) { + matchTextCache[ text ][ options.matchText ] = {}; + } + if ( !( w in matchTextCache[ text ][ options.matchText ] ) ) { + matchTextCache[ text ][ options.matchText ][ w ] = {}; + } + if ( options.position in matchTextCache[ text ][ options.matchText ][ w ] ) { + $container.html( matchTextCache[ text ][ options.matchText ][ w ][ options.position ] ); + if ( options.tooltip ) { + $container.attr( 'title', text ); + } + return; + } + } else { + if ( !( text in cache ) ) { + cache[ text ] = {}; + } + if ( !( w in cache[ text ] ) ) { + cache[ text ][ w ] = {}; + } + if ( options.position in cache[ text ][ w ] ) { + $container.html( cache[ text ][ w ][ options.position ] ); + if ( options.tooltip ) { + $container.attr( 'title', text ); + } + return; } - return; } - } - if ( $trimmableText.width() + pw > w ) { - switch ( options.position ) { - case 'right': - // Use binary search-like technique for efficiency - l = 0; - r = trimmableText.length; - do { - m = Math.ceil( ( l + r ) / 2 ); - $trimmableText.text( trimmableText.slice( 0, m ) + '...' ); - if ( $trimmableText.width() + pw > w ) { - // Text is too long - r = m - 1; - } else { - l = m; + if ( $trimmableText.width() + pw > w ) { + switch ( options.position ) { + case 'right': + // Use binary search-like technique for efficiency + l = 0; + r = trimmableText.length; + do { + m = Math.ceil( ( l + r ) / 2 ); + $trimmableText.text( trimmableText.slice( 0, m ) + '...' ); + if ( $trimmableText.width() + pw > w ) { + // Text is too long + r = m - 1; + } else { + l = m; + } + } while ( l < r ); + $trimmableText.text( trimmableText.slice( 0, l ) + '...' ); + break; + case 'center': + // TODO: Use binary search like for 'right' + i = [ Math.round( trimmableText.length / 2 ), Math.round( trimmableText.length / 2 ) ]; + // Begin with making the end shorter + side = 1; + while ( $trimmableText.outerWidth() + pw > w && i[ 0 ] > 0 ) { + $trimmableText.text( trimmableText.slice( 0, i[ 0 ] ) + '...' + trimmableText.slice( i[ 1 ] ) ); + // Alternate between trimming the end and begining + if ( side === 0 ) { + // Make the begining shorter + i[ 0 ]--; + side = 1; + } else { + // Make the end shorter + i[ 1 ]++; + side = 0; + } } - } while ( l < r ); - $trimmableText.text( trimmableText.slice( 0, l ) + '...' ); - break; - case 'center': - // TODO: Use binary search like for 'right' - i = [ Math.round( trimmableText.length / 2 ), Math.round( trimmableText.length / 2 ) ]; - // Begin with making the end shorter - side = 1; - while ( $trimmableText.outerWidth() + pw > w && i[ 0 ] > 0 ) { - $trimmableText.text( trimmableText.slice( 0, i[ 0 ] ) + '...' + trimmableText.slice( i[ 1 ] ) ); - // Alternate between trimming the end and begining - if ( side === 0 ) { - // Make the begining shorter - i[ 0 ]--; - side = 1; - } else { - // Make the end shorter - i[ 1 ]++; - side = 0; + break; + case 'left': + // TODO: Use binary search like for 'right' + r = 0; + while ( $trimmableText.outerWidth() + pw > w && r < trimmableText.length ) { + $trimmableText.text( '...' + trimmableText.slice( r ) ); + r++; } - } - break; - case 'left': - // TODO: Use binary search like for 'right' - r = 0; - while ( $trimmableText.outerWidth() + pw > w && r < trimmableText.length ) { - $trimmableText.text( '...' + trimmableText.slice( r ) ); - r++; - } - break; + break; + } + } + if ( options.tooltip ) { + $container.attr( 'title', text ); + } + if ( options.matchText ) { + $container.highlightText( options.matchText ); + matchTextCache[ text ][ options.matchText ][ w ][ options.position ] = $container.html(); + } else { + cache[ text ][ w ][ options.position ] = $container.html(); } - } - if ( options.tooltip ) { - $container.attr( 'title', text ); - } - if ( options.matchText ) { - $container.highlightText( options.matchText ); - matchTextCache[ text ][ options.matchText ][ w ][ options.position ] = $container.html(); - } else { - cache[ text ][ w ][ options.position ] = $container.html(); - } - } ); -}; -// jscs:enable jsDoc + } ); + }; + // jscs:enable jsDoc -/** - * @class jQuery - * @mixins jQuery.plugin.autoEllipsis - */ + /** + * @class jQuery + * @mixins jQuery.plugin.autoEllipsis + */ }( jQuery ) ); diff --git a/resources/src/jquery/jquery.byteLimit.js b/resources/src/jquery/jquery.byteLimit.js index dd71a2bc4d..567bec8ad6 100644 --- a/resources/src/jquery/jquery.byteLimit.js +++ b/resources/src/jquery/jquery.byteLimit.js @@ -3,6 +3,17 @@ */ ( function ( $ ) { + var eventKeys = [ + 'keyup.byteLimit', + 'keydown.byteLimit', + 'change.byteLimit', + 'mouseup.byteLimit', + 'cut.byteLimit', + 'paste.byteLimit', + 'focus.byteLimit', + 'blur.byteLimit' + ].join( ' ' ); + /** * Utility function to trim down a string, based on byteLimit * and given a safe start position. It supports insertion anywhere @@ -94,17 +105,6 @@ }; }; - var eventKeys = [ - 'keyup.byteLimit', - 'keydown.byteLimit', - 'change.byteLimit', - 'mouseup.byteLimit', - 'cut.byteLimit', - 'paste.byteLimit', - 'focus.byteLimit', - 'blur.byteLimit' - ].join( ' ' ); - /** * Enforces a byte limit on an input field, so that UTF-8 entries are counted as well, * when, for example, a database field has a byte limit rather than a character limit. @@ -176,7 +176,7 @@ // maxLength is a strange property. Removing or setting the property to // undefined directly doesn't work. Instead, it can only be unset internally // by the browser when removing the associated attribute (Firefox/Chrome). - // http://code.google.com/p/chromium/issues/detail?id=136004 + // https://bugs.chromium.org/p/chromium/issues/detail?id=136004 $el.removeAttr( 'maxlength' ); } else { @@ -203,7 +203,7 @@ // changed while text is being entered and keyup/change will not be fired yet // (such as holding down a single key, fires keydown, and after each keydown, // we can trim the previous one). - // See http://www.w3.org/TR/DOM-Level-3-Events/#events-keyboard-event-order for + // See https://www.w3.org/TR/DOM-Level-3-Events/#events-keyboard-event-order for // the order and characteristics of the key events. $el.on( eventKeys, function () { var res = $.trimByteLength( diff --git a/resources/src/jquery/jquery.color.js b/resources/src/jquery/jquery.color.js index a3cc8fc3af..70dc1057a6 100644 --- a/resources/src/jquery/jquery.color.js +++ b/resources/src/jquery/jquery.color.js @@ -10,7 +10,6 @@ ( function ( $ ) { function getColor( elem, attr ) { - /*jshint boss:true */ var color; do { @@ -22,6 +21,7 @@ } attr = 'backgroundColor'; + // eslint-disable-next-line no-cond-assign } while ( elem = elem.parentNode ); return $.colorUtil.getRGB( color ); diff --git a/resources/src/jquery/jquery.colorUtil.js b/resources/src/jquery/jquery.colorUtil.js index c14f2c861c..c53ec3b147 100644 --- a/resources/src/jquery/jquery.colorUtil.js +++ b/resources/src/jquery/jquery.colorUtil.js @@ -23,7 +23,6 @@ * @return {Array} */ getRGB: function ( color ) { - /*jshint boss:true */ var result; // Check if we're already dealing with an array of colors @@ -32,6 +31,7 @@ } // Look for rgb(num,num,num) + // eslint-disable-next-line no-cond-assign if ( result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec( color ) ) { return [ parseInt( result[ 1 ], 10 ), @@ -41,6 +41,7 @@ } // Look for rgb(num%,num%,num%) + // eslint-disable-next-line no-cond-assign if ( result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec( color ) ) { return [ parseFloat( result[ 1 ] ) * 2.55, @@ -50,6 +51,7 @@ } // Look for #a0b1c2 + // eslint-disable-next-line no-cond-assign if ( result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec( color ) ) { return [ parseInt( result[ 1 ], 16 ), @@ -59,6 +61,7 @@ } // Look for #fff + // eslint-disable-next-line no-cond-assign if ( result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec( color ) ) { return [ parseInt( result[ 1 ] + result[ 1 ], 16 ), @@ -68,6 +71,7 @@ } // Look for rgba(0, 0, 0, 0) == transparent in Safari 3 + // eslint-disable-next-line no-cond-assign if ( result = /rgba\(0, 0, 0, 0\)/.exec( color ) ) { return $.colorUtil.colors.transparent; } @@ -148,16 +152,15 @@ * @return {number[]} The HSL representation */ rgbToHsl: function ( r, g, b ) { + var d, h, s, l, min, max; + r = r / 255; g = g / 255; b = b / 255; - var d, - max = Math.max( r, g, b ), - min = Math.min( r, g, b ), - h, - s, - l = ( max + min ) / 2; + max = Math.max( r, g, b ); + min = Math.min( r, g, b ); + l = ( max + min ) / 2; if ( max === min ) { // achromatic diff --git a/resources/src/jquery/jquery.confirmable.js b/resources/src/jquery/jquery.confirmable.js index 1ecce6cad7..7931c8147f 100644 --- a/resources/src/jquery/jquery.confirmable.js +++ b/resources/src/jquery/jquery.confirmable.js @@ -12,6 +12,7 @@ return data; }; + // eslint-disable-next-line valid-jsdoc /** * Enable inline confirmation for given clickable element (like `` or `