qunit-2.13.0.js 229 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303
  1. /*!
  2. * QUnit 2.13.0
  3. * https://qunitjs.com/
  4. *
  5. * Copyright OpenJS Foundation and other contributors
  6. * Released under the MIT license
  7. * https://jquery.org/license
  8. *
  9. * Date: 2020-11-29T20:34Z
  10. */
  11. (function (global$1) {
  12. 'use strict';
  13. // Support IE 9-10, PhantomJS: Fallback for fuzzysort.js used by /reporter/html.js
  14. // eslint-disable-next-line no-unused-vars
  15. var Map = typeof Map === "function" ? Map : function StringMap() {
  16. var store = Object.create( null );
  17. this.get = function( strKey ) {
  18. return store[ strKey ];
  19. };
  20. this.set = function( strKey, val ) {
  21. store[ strKey ] = val;
  22. return this;
  23. };
  24. this.clear = function() {
  25. store = Object.create( null );
  26. };
  27. };
  28. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  29. var global__default = /*#__PURE__*/_interopDefaultLegacy(global$1);
  30. var window$1 = global__default['default'].window;
  31. var self$1 = global__default['default'].self;
  32. var console = global__default['default'].console;
  33. var setTimeout$1 = global__default['default'].setTimeout;
  34. var clearTimeout = global__default['default'].clearTimeout;
  35. var document$1 = window$1 && window$1.document;
  36. var navigator = window$1 && window$1.navigator;
  37. var localSessionStorage = function () {
  38. var x = "qunit-test-string";
  39. try {
  40. global__default['default'].sessionStorage.setItem(x, x);
  41. global__default['default'].sessionStorage.removeItem(x);
  42. return global__default['default'].sessionStorage;
  43. } catch (e) {
  44. return undefined;
  45. }
  46. }();
  47. function _typeof(obj) {
  48. "@babel/helpers - typeof";
  49. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  50. _typeof = function (obj) {
  51. return typeof obj;
  52. };
  53. } else {
  54. _typeof = function (obj) {
  55. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  56. };
  57. }
  58. return _typeof(obj);
  59. }
  60. function _classCallCheck(instance, Constructor) {
  61. if (!(instance instanceof Constructor)) {
  62. throw new TypeError("Cannot call a class as a function");
  63. }
  64. }
  65. function _defineProperties(target, props) {
  66. for (var i = 0; i < props.length; i++) {
  67. var descriptor = props[i];
  68. descriptor.enumerable = descriptor.enumerable || false;
  69. descriptor.configurable = true;
  70. if ("value" in descriptor) descriptor.writable = true;
  71. Object.defineProperty(target, descriptor.key, descriptor);
  72. }
  73. }
  74. function _createClass(Constructor, protoProps, staticProps) {
  75. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  76. if (staticProps) _defineProperties(Constructor, staticProps);
  77. return Constructor;
  78. }
  79. function _toConsumableArray(arr) {
  80. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  81. }
  82. function _arrayWithoutHoles(arr) {
  83. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  84. }
  85. function _iterableToArray(iter) {
  86. if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
  87. }
  88. function _unsupportedIterableToArray(o, minLen) {
  89. if (!o) return;
  90. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  91. var n = Object.prototype.toString.call(o).slice(8, -1);
  92. if (n === "Object" && o.constructor) n = o.constructor.name;
  93. if (n === "Map" || n === "Set") return Array.from(o);
  94. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  95. }
  96. function _arrayLikeToArray(arr, len) {
  97. if (len == null || len > arr.length) len = arr.length;
  98. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  99. return arr2;
  100. }
  101. function _nonIterableSpread() {
  102. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  103. }
  104. function _createForOfIteratorHelper(o, allowArrayLike) {
  105. var it;
  106. if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
  107. if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
  108. if (it) o = it;
  109. var i = 0;
  110. var F = function () {};
  111. return {
  112. s: F,
  113. n: function () {
  114. if (i >= o.length) return {
  115. done: true
  116. };
  117. return {
  118. done: false,
  119. value: o[i++]
  120. };
  121. },
  122. e: function (e) {
  123. throw e;
  124. },
  125. f: F
  126. };
  127. }
  128. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  129. }
  130. var normalCompletion = true,
  131. didErr = false,
  132. err;
  133. return {
  134. s: function () {
  135. it = o[Symbol.iterator]();
  136. },
  137. n: function () {
  138. var step = it.next();
  139. normalCompletion = step.done;
  140. return step;
  141. },
  142. e: function (e) {
  143. didErr = true;
  144. err = e;
  145. },
  146. f: function () {
  147. try {
  148. if (!normalCompletion && it.return != null) it.return();
  149. } finally {
  150. if (didErr) throw err;
  151. }
  152. }
  153. };
  154. }
  155. // This allows support for IE 9, which doesn't have a console
  156. // object if the developer tools are not open.
  157. var Logger = {
  158. warn: console ? console.warn.bind(console) : function () {}
  159. };
  160. var toString = Object.prototype.toString;
  161. var hasOwn = Object.prototype.hasOwnProperty;
  162. var now = Date.now || function () {
  163. return new Date().getTime();
  164. };
  165. var nativePerf = getNativePerf();
  166. function getNativePerf() {
  167. if (window$1 && typeof window$1.performance !== "undefined" && typeof window$1.performance.mark === "function" && typeof window$1.performance.measure === "function") {
  168. return window$1.performance;
  169. } else {
  170. return undefined;
  171. }
  172. }
  173. var performance = {
  174. now: nativePerf ? nativePerf.now.bind(nativePerf) : now,
  175. measure: nativePerf ? function (comment, startMark, endMark) {
  176. // `performance.measure` may fail if the mark could not be found.
  177. // reasons a specific mark could not be found include: outside code invoking `performance.clearMarks()`
  178. try {
  179. nativePerf.measure(comment, startMark, endMark);
  180. } catch (ex) {
  181. Logger.warn("performance.measure could not be executed because of ", ex.message);
  182. }
  183. } : function () {},
  184. mark: nativePerf ? nativePerf.mark.bind(nativePerf) : function () {}
  185. }; // Returns a new Array with the elements that are in a but not in b
  186. function diff(a, b) {
  187. var i,
  188. j,
  189. result = a.slice();
  190. for (i = 0; i < result.length; i++) {
  191. for (j = 0; j < b.length; j++) {
  192. if (result[i] === b[j]) {
  193. result.splice(i, 1);
  194. i--;
  195. break;
  196. }
  197. }
  198. }
  199. return result;
  200. }
  201. /**
  202. * Determines whether an element exists in a given array or not.
  203. *
  204. * @method inArray
  205. * @param {Any} elem
  206. * @param {Array} array
  207. * @return {Boolean}
  208. */
  209. function inArray(elem, array) {
  210. return array.indexOf(elem) !== -1;
  211. }
  212. /**
  213. * Makes a clone of an object using only Array or Object as base,
  214. * and copies over the own enumerable properties.
  215. *
  216. * @param {Object} obj
  217. * @return {Object} New object with only the own properties (recursively).
  218. */
  219. function objectValues(obj) {
  220. var key,
  221. val,
  222. vals = is("array", obj) ? [] : {};
  223. for (key in obj) {
  224. if (hasOwn.call(obj, key)) {
  225. val = obj[key];
  226. vals[key] = val === Object(val) ? objectValues(val) : val;
  227. }
  228. }
  229. return vals;
  230. }
  231. function extend(a, b, undefOnly) {
  232. for (var prop in b) {
  233. if (hasOwn.call(b, prop)) {
  234. if (b[prop] === undefined) {
  235. delete a[prop];
  236. } else if (!(undefOnly && typeof a[prop] !== "undefined")) {
  237. a[prop] = b[prop];
  238. }
  239. }
  240. }
  241. return a;
  242. }
  243. function objectType(obj) {
  244. if (typeof obj === "undefined") {
  245. return "undefined";
  246. } // Consider: typeof null === object
  247. if (obj === null) {
  248. return "null";
  249. }
  250. var match = toString.call(obj).match(/^\[object\s(.*)\]$/),
  251. type = match && match[1];
  252. switch (type) {
  253. case "Number":
  254. if (isNaN(obj)) {
  255. return "nan";
  256. }
  257. return "number";
  258. case "String":
  259. case "Boolean":
  260. case "Array":
  261. case "Set":
  262. case "Map":
  263. case "Date":
  264. case "RegExp":
  265. case "Function":
  266. case "Symbol":
  267. return type.toLowerCase();
  268. default:
  269. return _typeof(obj);
  270. }
  271. } // Safe object type checking
  272. function is(type, obj) {
  273. return objectType(obj) === type;
  274. } // Based on Java's String.hashCode, a simple but not
  275. // rigorously collision resistant hashing function
  276. function generateHash(module, testName) {
  277. var str = module + "\x1C" + testName;
  278. var hash = 0;
  279. for (var i = 0; i < str.length; i++) {
  280. hash = (hash << 5) - hash + str.charCodeAt(i);
  281. hash |= 0;
  282. } // Convert the possibly negative integer hash code into an 8 character hex string, which isn't
  283. // strictly necessary but increases user understanding that the id is a SHA-like hash
  284. var hex = (0x100000000 + hash).toString(16);
  285. if (hex.length < 8) {
  286. hex = "0000000" + hex;
  287. }
  288. return hex.slice(-8);
  289. }
  290. // Authors: Philippe Rathé <prathe@gmail.com>, David Chan <david@troi.org>
  291. var equiv = (function () {
  292. // Value pairs queued for comparison. Used for breadth-first processing order, recursion
  293. // detection and avoiding repeated comparison (see below for details).
  294. // Elements are { a: val, b: val }.
  295. var pairs = [];
  296. var getProto = Object.getPrototypeOf || function (obj) {
  297. return obj.__proto__;
  298. };
  299. function useStrictEquality(a, b) {
  300. // This only gets called if a and b are not strict equal, and is used to compare on
  301. // the primitive values inside object wrappers. For example:
  302. // `var i = 1;`
  303. // `var j = new Number(1);`
  304. // Neither a nor b can be null, as a !== b and they have the same type.
  305. if (_typeof(a) === "object") {
  306. a = a.valueOf();
  307. }
  308. if (_typeof(b) === "object") {
  309. b = b.valueOf();
  310. }
  311. return a === b;
  312. }
  313. function compareConstructors(a, b) {
  314. var protoA = getProto(a);
  315. var protoB = getProto(b); // Comparing constructors is more strict than using `instanceof`
  316. if (a.constructor === b.constructor) {
  317. return true;
  318. } // Ref #851
  319. // If the obj prototype descends from a null constructor, treat it
  320. // as a null prototype.
  321. if (protoA && protoA.constructor === null) {
  322. protoA = null;
  323. }
  324. if (protoB && protoB.constructor === null) {
  325. protoB = null;
  326. } // Allow objects with no prototype to be equivalent to
  327. // objects with Object as their constructor.
  328. if (protoA === null && protoB === Object.prototype || protoB === null && protoA === Object.prototype) {
  329. return true;
  330. }
  331. return false;
  332. }
  333. function getRegExpFlags(regexp) {
  334. return "flags" in regexp ? regexp.flags : regexp.toString().match(/[gimuy]*$/)[0];
  335. }
  336. function isContainer(val) {
  337. return ["object", "array", "map", "set"].indexOf(objectType(val)) !== -1;
  338. }
  339. function breadthFirstCompareChild(a, b) {
  340. // If a is a container not reference-equal to b, postpone the comparison to the
  341. // end of the pairs queue -- unless (a, b) has been seen before, in which case skip
  342. // over the pair.
  343. if (a === b) {
  344. return true;
  345. }
  346. if (!isContainer(a)) {
  347. return typeEquiv(a, b);
  348. }
  349. if (pairs.every(function (pair) {
  350. return pair.a !== a || pair.b !== b;
  351. })) {
  352. // Not yet started comparing this pair
  353. pairs.push({
  354. a: a,
  355. b: b
  356. });
  357. }
  358. return true;
  359. }
  360. var callbacks = {
  361. "string": useStrictEquality,
  362. "boolean": useStrictEquality,
  363. "number": useStrictEquality,
  364. "null": useStrictEquality,
  365. "undefined": useStrictEquality,
  366. "symbol": useStrictEquality,
  367. "date": useStrictEquality,
  368. "nan": function nan() {
  369. return true;
  370. },
  371. "regexp": function regexp(a, b) {
  372. return a.source === b.source && // Include flags in the comparison
  373. getRegExpFlags(a) === getRegExpFlags(b);
  374. },
  375. // abort (identical references / instance methods were skipped earlier)
  376. "function": function _function() {
  377. return false;
  378. },
  379. "array": function array(a, b) {
  380. var i, len;
  381. len = a.length;
  382. if (len !== b.length) {
  383. // Safe and faster
  384. return false;
  385. }
  386. for (i = 0; i < len; i++) {
  387. // Compare non-containers; queue non-reference-equal containers
  388. if (!breadthFirstCompareChild(a[i], b[i])) {
  389. return false;
  390. }
  391. }
  392. return true;
  393. },
  394. // Define sets a and b to be equivalent if for each element aVal in a, there
  395. // is some element bVal in b such that aVal and bVal are equivalent. Element
  396. // repetitions are not counted, so these are equivalent:
  397. // a = new Set( [ {}, [], [] ] );
  398. // b = new Set( [ {}, {}, [] ] );
  399. "set": function set(a, b) {
  400. var innerEq,
  401. outerEq = true;
  402. if (a.size !== b.size) {
  403. // This optimization has certain quirks because of the lack of
  404. // repetition counting. For instance, adding the same
  405. // (reference-identical) element to two equivalent sets can
  406. // make them non-equivalent.
  407. return false;
  408. }
  409. a.forEach(function (aVal) {
  410. // Short-circuit if the result is already known. (Using for...of
  411. // with a break clause would be cleaner here, but it would cause
  412. // a syntax error on older Javascript implementations even if
  413. // Set is unused)
  414. if (!outerEq) {
  415. return;
  416. }
  417. innerEq = false;
  418. b.forEach(function (bVal) {
  419. var parentPairs; // Likewise, short-circuit if the result is already known
  420. if (innerEq) {
  421. return;
  422. } // Swap out the global pairs list, as the nested call to
  423. // innerEquiv will clobber its contents
  424. parentPairs = pairs;
  425. if (innerEquiv(bVal, aVal)) {
  426. innerEq = true;
  427. } // Replace the global pairs list
  428. pairs = parentPairs;
  429. });
  430. if (!innerEq) {
  431. outerEq = false;
  432. }
  433. });
  434. return outerEq;
  435. },
  436. // Define maps a and b to be equivalent if for each key-value pair (aKey, aVal)
  437. // in a, there is some key-value pair (bKey, bVal) in b such that
  438. // [ aKey, aVal ] and [ bKey, bVal ] are equivalent. Key repetitions are not
  439. // counted, so these are equivalent:
  440. // a = new Map( [ [ {}, 1 ], [ {}, 1 ], [ [], 1 ] ] );
  441. // b = new Map( [ [ {}, 1 ], [ [], 1 ], [ [], 1 ] ] );
  442. "map": function map(a, b) {
  443. var innerEq,
  444. outerEq = true;
  445. if (a.size !== b.size) {
  446. // This optimization has certain quirks because of the lack of
  447. // repetition counting. For instance, adding the same
  448. // (reference-identical) key-value pair to two equivalent maps
  449. // can make them non-equivalent.
  450. return false;
  451. }
  452. a.forEach(function (aVal, aKey) {
  453. // Short-circuit if the result is already known. (Using for...of
  454. // with a break clause would be cleaner here, but it would cause
  455. // a syntax error on older Javascript implementations even if
  456. // Map is unused)
  457. if (!outerEq) {
  458. return;
  459. }
  460. innerEq = false;
  461. b.forEach(function (bVal, bKey) {
  462. var parentPairs; // Likewise, short-circuit if the result is already known
  463. if (innerEq) {
  464. return;
  465. } // Swap out the global pairs list, as the nested call to
  466. // innerEquiv will clobber its contents
  467. parentPairs = pairs;
  468. if (innerEquiv([bVal, bKey], [aVal, aKey])) {
  469. innerEq = true;
  470. } // Replace the global pairs list
  471. pairs = parentPairs;
  472. });
  473. if (!innerEq) {
  474. outerEq = false;
  475. }
  476. });
  477. return outerEq;
  478. },
  479. "object": function object(a, b) {
  480. var i,
  481. aProperties = [],
  482. bProperties = [];
  483. if (compareConstructors(a, b) === false) {
  484. return false;
  485. } // Be strict: don't ensure hasOwnProperty and go deep
  486. for (i in a) {
  487. // Collect a's properties
  488. aProperties.push(i); // Skip OOP methods that look the same
  489. if (a.constructor !== Object && typeof a.constructor !== "undefined" && typeof a[i] === "function" && typeof b[i] === "function" && a[i].toString() === b[i].toString()) {
  490. continue;
  491. } // Compare non-containers; queue non-reference-equal containers
  492. if (!breadthFirstCompareChild(a[i], b[i])) {
  493. return false;
  494. }
  495. }
  496. for (i in b) {
  497. // Collect b's properties
  498. bProperties.push(i);
  499. } // Ensures identical properties name
  500. return typeEquiv(aProperties.sort(), bProperties.sort());
  501. }
  502. };
  503. function typeEquiv(a, b) {
  504. var type = objectType(a); // Callbacks for containers will append to the pairs queue to achieve breadth-first
  505. // search order. The pairs queue is also used to avoid reprocessing any pair of
  506. // containers that are reference-equal to a previously visited pair (a special case
  507. // this being recursion detection).
  508. //
  509. // Because of this approach, once typeEquiv returns a false value, it should not be
  510. // called again without clearing the pair queue else it may wrongly report a visited
  511. // pair as being equivalent.
  512. return objectType(b) === type && callbacks[type](a, b);
  513. }
  514. function innerEquiv(a, b) {
  515. var i, pair; // We're done when there's nothing more to compare
  516. if (arguments.length < 2) {
  517. return true;
  518. } // Clear the global pair queue and add the top-level values being compared
  519. pairs = [{
  520. a: a,
  521. b: b
  522. }];
  523. for (i = 0; i < pairs.length; i++) {
  524. pair = pairs[i]; // Perform type-specific comparison on any pairs that are not strictly
  525. // equal. For container types, that comparison will postpone comparison
  526. // of any sub-container pair to the end of the pair queue. This gives
  527. // breadth-first search order. It also avoids the reprocessing of
  528. // reference-equal siblings, cousins etc, which can have a significant speed
  529. // impact when comparing a container of small objects each of which has a
  530. // reference to the same (singleton) large object.
  531. if (pair.a !== pair.b && !typeEquiv(pair.a, pair.b)) {
  532. return false;
  533. }
  534. } // ...across all consecutive argument pairs
  535. return arguments.length === 2 || innerEquiv.apply(this, [].slice.call(arguments, 1));
  536. }
  537. return function () {
  538. var result = innerEquiv.apply(void 0, arguments); // Release any retained objects
  539. pairs.length = 0;
  540. return result;
  541. };
  542. })();
  543. /**
  544. * Config object: Maintain internal state
  545. * Later exposed as QUnit.config
  546. * `config` initialized at top of scope
  547. */
  548. var config = {
  549. // The queue of tests to run
  550. queue: [],
  551. // Block until document ready
  552. blocking: true,
  553. // By default, run previously failed tests first
  554. // very useful in combination with "Hide passed tests" checked
  555. reorder: true,
  556. // By default, modify document.title when suite is done
  557. altertitle: true,
  558. // HTML Reporter: collapse every test except the first failing test
  559. // If false, all failing tests will be expanded
  560. collapse: true,
  561. // By default, scroll to top of the page when suite is done
  562. scrolltop: true,
  563. // Depth up-to which object will be dumped
  564. maxDepth: 5,
  565. // When enabled, all tests must call expect()
  566. requireExpects: false,
  567. // Placeholder for user-configurable form-exposed URL parameters
  568. urlConfig: [],
  569. // Set of all modules.
  570. modules: [],
  571. // The first unnamed module
  572. currentModule: {
  573. name: "",
  574. tests: [],
  575. childModules: [],
  576. testsRun: 0,
  577. testsIgnored: 0,
  578. hooks: {
  579. before: [],
  580. beforeEach: [],
  581. afterEach: [],
  582. after: []
  583. }
  584. },
  585. callbacks: {},
  586. // The storage module to use for reordering tests
  587. storage: localSessionStorage
  588. }; // take a predefined QUnit.config and extend the defaults
  589. var globalConfig = window$1 && window$1.QUnit && window$1.QUnit.config; // only extend the global config if there is no QUnit overload
  590. if (window$1 && window$1.QUnit && !window$1.QUnit.version) {
  591. extend(config, globalConfig);
  592. } // Push a loose unnamed module to the modules collection
  593. config.modules.push(config.currentModule);
  594. var dump = (function () {
  595. function quote(str) {
  596. return "\"" + str.toString().replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\"";
  597. }
  598. function literal(o) {
  599. return o + "";
  600. }
  601. function join(pre, arr, post) {
  602. var s = dump.separator(),
  603. base = dump.indent(),
  604. inner = dump.indent(1);
  605. if (arr.join) {
  606. arr = arr.join("," + s + inner);
  607. }
  608. if (!arr) {
  609. return pre + post;
  610. }
  611. return [pre, inner + arr, base + post].join(s);
  612. }
  613. function array(arr, stack) {
  614. var i = arr.length,
  615. ret = new Array(i);
  616. if (dump.maxDepth && dump.depth > dump.maxDepth) {
  617. return "[object Array]";
  618. }
  619. this.up();
  620. while (i--) {
  621. ret[i] = this.parse(arr[i], undefined, stack);
  622. }
  623. this.down();
  624. return join("[", ret, "]");
  625. }
  626. function isArray(obj) {
  627. return (//Native Arrays
  628. toString.call(obj) === "[object Array]" || // NodeList objects
  629. typeof obj.length === "number" && obj.item !== undefined && (obj.length ? obj.item(0) === obj[0] : obj.item(0) === null && obj[0] === undefined)
  630. );
  631. }
  632. var reName = /^function (\w+)/,
  633. dump = {
  634. // The objType is used mostly internally, you can fix a (custom) type in advance
  635. parse: function parse(obj, objType, stack) {
  636. stack = stack || [];
  637. var res,
  638. parser,
  639. parserType,
  640. objIndex = stack.indexOf(obj);
  641. if (objIndex !== -1) {
  642. return "recursion(".concat(objIndex - stack.length, ")");
  643. }
  644. objType = objType || this.typeOf(obj);
  645. parser = this.parsers[objType];
  646. parserType = _typeof(parser);
  647. if (parserType === "function") {
  648. stack.push(obj);
  649. res = parser.call(this, obj, stack);
  650. stack.pop();
  651. return res;
  652. }
  653. return parserType === "string" ? parser : this.parsers.error;
  654. },
  655. typeOf: function typeOf(obj) {
  656. var type;
  657. if (obj === null) {
  658. type = "null";
  659. } else if (typeof obj === "undefined") {
  660. type = "undefined";
  661. } else if (is("regexp", obj)) {
  662. type = "regexp";
  663. } else if (is("date", obj)) {
  664. type = "date";
  665. } else if (is("function", obj)) {
  666. type = "function";
  667. } else if (obj.setInterval !== undefined && obj.document !== undefined && obj.nodeType === undefined) {
  668. type = "window";
  669. } else if (obj.nodeType === 9) {
  670. type = "document";
  671. } else if (obj.nodeType) {
  672. type = "node";
  673. } else if (isArray(obj)) {
  674. type = "array";
  675. } else if (obj.constructor === Error.prototype.constructor) {
  676. type = "error";
  677. } else {
  678. type = _typeof(obj);
  679. }
  680. return type;
  681. },
  682. separator: function separator() {
  683. if (this.multiline) {
  684. return this.HTML ? "<br />" : "\n";
  685. } else {
  686. return this.HTML ? "&#160;" : " ";
  687. }
  688. },
  689. // Extra can be a number, shortcut for increasing-calling-decreasing
  690. indent: function indent(extra) {
  691. if (!this.multiline) {
  692. return "";
  693. }
  694. var chr = this.indentChar;
  695. if (this.HTML) {
  696. chr = chr.replace(/\t/g, " ").replace(/ /g, "&#160;");
  697. }
  698. return new Array(this.depth + (extra || 0)).join(chr);
  699. },
  700. up: function up(a) {
  701. this.depth += a || 1;
  702. },
  703. down: function down(a) {
  704. this.depth -= a || 1;
  705. },
  706. setParser: function setParser(name, parser) {
  707. this.parsers[name] = parser;
  708. },
  709. // The next 3 are exposed so you can use them
  710. quote: quote,
  711. literal: literal,
  712. join: join,
  713. depth: 1,
  714. maxDepth: config.maxDepth,
  715. // This is the list of parsers, to modify them, use dump.setParser
  716. parsers: {
  717. window: "[Window]",
  718. document: "[Document]",
  719. error: function error(_error) {
  720. return "Error(\"" + _error.message + "\")";
  721. },
  722. unknown: "[Unknown]",
  723. "null": "null",
  724. "undefined": "undefined",
  725. "function": function _function(fn) {
  726. var ret = "function",
  727. // Functions never have name in IE
  728. name = "name" in fn ? fn.name : (reName.exec(fn) || [])[1];
  729. if (name) {
  730. ret += " " + name;
  731. }
  732. ret += "(";
  733. ret = [ret, dump.parse(fn, "functionArgs"), "){"].join("");
  734. return join(ret, dump.parse(fn, "functionCode"), "}");
  735. },
  736. array: array,
  737. nodelist: array,
  738. "arguments": array,
  739. object: function object(map, stack) {
  740. var keys,
  741. key,
  742. val,
  743. i,
  744. nonEnumerableProperties,
  745. ret = [];
  746. if (dump.maxDepth && dump.depth > dump.maxDepth) {
  747. return "[object Object]";
  748. }
  749. dump.up();
  750. keys = [];
  751. for (key in map) {
  752. keys.push(key);
  753. } // Some properties are not always enumerable on Error objects.
  754. nonEnumerableProperties = ["message", "name"];
  755. for (i in nonEnumerableProperties) {
  756. key = nonEnumerableProperties[i];
  757. if (key in map && !inArray(key, keys)) {
  758. keys.push(key);
  759. }
  760. }
  761. keys.sort();
  762. for (i = 0; i < keys.length; i++) {
  763. key = keys[i];
  764. val = map[key];
  765. ret.push(dump.parse(key, "key") + ": " + dump.parse(val, undefined, stack));
  766. }
  767. dump.down();
  768. return join("{", ret, "}");
  769. },
  770. node: function node(_node) {
  771. var len,
  772. i,
  773. val,
  774. open = dump.HTML ? "&lt;" : "<",
  775. close = dump.HTML ? "&gt;" : ">",
  776. tag = _node.nodeName.toLowerCase(),
  777. ret = open + tag,
  778. attrs = _node.attributes;
  779. if (attrs) {
  780. for (i = 0, len = attrs.length; i < len; i++) {
  781. val = attrs[i].nodeValue; // IE6 includes all attributes in .attributes, even ones not explicitly
  782. // set. Those have values like undefined, null, 0, false, "" or
  783. // "inherit".
  784. if (val && val !== "inherit") {
  785. ret += " " + attrs[i].nodeName + "=" + dump.parse(val, "attribute");
  786. }
  787. }
  788. }
  789. ret += close; // Show content of TextNode or CDATASection
  790. if (_node.nodeType === 3 || _node.nodeType === 4) {
  791. ret += _node.nodeValue;
  792. }
  793. return ret + open + "/" + tag + close;
  794. },
  795. // Function calls it internally, it's the arguments part of the function
  796. functionArgs: function functionArgs(fn) {
  797. var args,
  798. l = fn.length;
  799. if (!l) {
  800. return "";
  801. }
  802. args = new Array(l);
  803. while (l--) {
  804. // 97 is 'a'
  805. args[l] = String.fromCharCode(97 + l);
  806. }
  807. return " " + args.join(", ") + " ";
  808. },
  809. // Object calls it internally, the key part of an item in a map
  810. key: quote,
  811. // Function calls it internally, it's the content of the function
  812. functionCode: "[code]",
  813. // Node calls it internally, it's a html attribute value
  814. attribute: quote,
  815. string: quote,
  816. date: quote,
  817. regexp: literal,
  818. number: literal,
  819. "boolean": literal,
  820. symbol: function symbol(sym) {
  821. return sym.toString();
  822. }
  823. },
  824. // If true, entities are escaped ( <, >, \t, space and \n )
  825. HTML: false,
  826. // Indentation unit
  827. indentChar: " ",
  828. // If true, items in a collection, are separated by a \n, else just a space.
  829. multiline: true
  830. };
  831. return dump;
  832. })();
  833. var SuiteReport = /*#__PURE__*/function () {
  834. function SuiteReport(name, parentSuite) {
  835. _classCallCheck(this, SuiteReport);
  836. this.name = name;
  837. this.fullName = parentSuite ? parentSuite.fullName.concat(name) : [];
  838. this.tests = [];
  839. this.childSuites = [];
  840. if (parentSuite) {
  841. parentSuite.pushChildSuite(this);
  842. }
  843. }
  844. _createClass(SuiteReport, [{
  845. key: "start",
  846. value: function start(recordTime) {
  847. if (recordTime) {
  848. this._startTime = performance.now();
  849. var suiteLevel = this.fullName.length;
  850. performance.mark("qunit_suite_".concat(suiteLevel, "_start"));
  851. }
  852. return {
  853. name: this.name,
  854. fullName: this.fullName.slice(),
  855. tests: this.tests.map(function (test) {
  856. return test.start();
  857. }),
  858. childSuites: this.childSuites.map(function (suite) {
  859. return suite.start();
  860. }),
  861. testCounts: {
  862. total: this.getTestCounts().total
  863. }
  864. };
  865. }
  866. }, {
  867. key: "end",
  868. value: function end(recordTime) {
  869. if (recordTime) {
  870. this._endTime = performance.now();
  871. var suiteLevel = this.fullName.length;
  872. var suiteName = this.fullName.join(" – ");
  873. performance.mark("qunit_suite_".concat(suiteLevel, "_end"));
  874. performance.measure(suiteLevel === 0 ? "QUnit Test Run" : "QUnit Test Suite: ".concat(suiteName), "qunit_suite_".concat(suiteLevel, "_start"), "qunit_suite_".concat(suiteLevel, "_end"));
  875. }
  876. return {
  877. name: this.name,
  878. fullName: this.fullName.slice(),
  879. tests: this.tests.map(function (test) {
  880. return test.end();
  881. }),
  882. childSuites: this.childSuites.map(function (suite) {
  883. return suite.end();
  884. }),
  885. testCounts: this.getTestCounts(),
  886. runtime: this.getRuntime(),
  887. status: this.getStatus()
  888. };
  889. }
  890. }, {
  891. key: "pushChildSuite",
  892. value: function pushChildSuite(suite) {
  893. this.childSuites.push(suite);
  894. }
  895. }, {
  896. key: "pushTest",
  897. value: function pushTest(test) {
  898. this.tests.push(test);
  899. }
  900. }, {
  901. key: "getRuntime",
  902. value: function getRuntime() {
  903. return this._endTime - this._startTime;
  904. }
  905. }, {
  906. key: "getTestCounts",
  907. value: function getTestCounts() {
  908. var counts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  909. passed: 0,
  910. failed: 0,
  911. skipped: 0,
  912. todo: 0,
  913. total: 0
  914. };
  915. counts = this.tests.reduce(function (counts, test) {
  916. if (test.valid) {
  917. counts[test.getStatus()]++;
  918. counts.total++;
  919. }
  920. return counts;
  921. }, counts);
  922. return this.childSuites.reduce(function (counts, suite) {
  923. return suite.getTestCounts(counts);
  924. }, counts);
  925. }
  926. }, {
  927. key: "getStatus",
  928. value: function getStatus() {
  929. var _this$getTestCounts = this.getTestCounts(),
  930. total = _this$getTestCounts.total,
  931. failed = _this$getTestCounts.failed,
  932. skipped = _this$getTestCounts.skipped,
  933. todo = _this$getTestCounts.todo;
  934. if (failed) {
  935. return "failed";
  936. } else {
  937. if (skipped === total) {
  938. return "skipped";
  939. } else if (todo === total) {
  940. return "todo";
  941. } else {
  942. return "passed";
  943. }
  944. }
  945. }
  946. }]);
  947. return SuiteReport;
  948. }();
  949. var focused = false;
  950. var moduleStack = [];
  951. function isParentModuleInQueue() {
  952. var modulesInQueue = config.modules.map(function (module) {
  953. return module.moduleId;
  954. });
  955. return moduleStack.some(function (module) {
  956. return modulesInQueue.includes(module.moduleId);
  957. });
  958. }
  959. function createModule(name, testEnvironment, modifiers) {
  960. var parentModule = moduleStack.length ? moduleStack.slice(-1)[0] : null;
  961. var moduleName = parentModule !== null ? [parentModule.name, name].join(" > ") : name;
  962. var parentSuite = parentModule ? parentModule.suiteReport : globalSuite;
  963. var skip = parentModule !== null && parentModule.skip || modifiers.skip;
  964. var todo = parentModule !== null && parentModule.todo || modifiers.todo;
  965. var module = {
  966. name: moduleName,
  967. parentModule: parentModule,
  968. tests: [],
  969. moduleId: generateHash(moduleName),
  970. testsRun: 0,
  971. testsIgnored: 0,
  972. childModules: [],
  973. suiteReport: new SuiteReport(name, parentSuite),
  974. // Pass along `skip` and `todo` properties from parent module, in case
  975. // there is one, to childs. And use own otherwise.
  976. // This property will be used to mark own tests and tests of child suites
  977. // as either `skipped` or `todo`.
  978. skip: skip,
  979. todo: skip ? false : todo
  980. };
  981. var env = {};
  982. if (parentModule) {
  983. parentModule.childModules.push(module);
  984. extend(env, parentModule.testEnvironment);
  985. }
  986. extend(env, testEnvironment);
  987. module.testEnvironment = env;
  988. config.modules.push(module);
  989. return module;
  990. }
  991. function processModule(name, options, executeNow) {
  992. var modifiers = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  993. if (objectType(options) === "function") {
  994. executeNow = options;
  995. options = undefined;
  996. }
  997. var module = createModule(name, options, modifiers); // Move any hooks to a 'hooks' object
  998. var testEnvironment = module.testEnvironment;
  999. var hooks = module.hooks = {};
  1000. setHookFromEnvironment(hooks, testEnvironment, "before");
  1001. setHookFromEnvironment(hooks, testEnvironment, "beforeEach");
  1002. setHookFromEnvironment(hooks, testEnvironment, "afterEach");
  1003. setHookFromEnvironment(hooks, testEnvironment, "after");
  1004. var moduleFns = {
  1005. before: setHookFunction(module, "before"),
  1006. beforeEach: setHookFunction(module, "beforeEach"),
  1007. afterEach: setHookFunction(module, "afterEach"),
  1008. after: setHookFunction(module, "after")
  1009. };
  1010. var currentModule = config.currentModule;
  1011. if (objectType(executeNow) === "function") {
  1012. moduleStack.push(module);
  1013. config.currentModule = module;
  1014. executeNow.call(module.testEnvironment, moduleFns);
  1015. moduleStack.pop();
  1016. module = module.parentModule || currentModule;
  1017. }
  1018. config.currentModule = module;
  1019. function setHookFromEnvironment(hooks, environment, name) {
  1020. var potentialHook = environment[name];
  1021. hooks[name] = typeof potentialHook === "function" ? [potentialHook] : [];
  1022. delete environment[name];
  1023. }
  1024. function setHookFunction(module, hookName) {
  1025. return function setHook(callback) {
  1026. module.hooks[hookName].push(callback);
  1027. };
  1028. }
  1029. }
  1030. function module$1(name, options, executeNow) {
  1031. if (focused && !isParentModuleInQueue()) {
  1032. return;
  1033. }
  1034. processModule(name, options, executeNow);
  1035. }
  1036. module$1.only = function () {
  1037. if (!focused) {
  1038. config.modules.length = 0;
  1039. config.queue.length = 0;
  1040. }
  1041. processModule.apply(void 0, arguments);
  1042. focused = true;
  1043. };
  1044. module$1.skip = function (name, options, executeNow) {
  1045. if (focused) {
  1046. return;
  1047. }
  1048. processModule(name, options, executeNow, {
  1049. skip: true
  1050. });
  1051. };
  1052. module$1.todo = function (name, options, executeNow) {
  1053. if (focused) {
  1054. return;
  1055. }
  1056. processModule(name, options, executeNow, {
  1057. todo: true
  1058. });
  1059. };
  1060. var LISTENERS = Object.create(null);
  1061. var SUPPORTED_EVENTS = ["runStart", "suiteStart", "testStart", "assertion", "testEnd", "suiteEnd", "runEnd"];
  1062. /**
  1063. * Emits an event with the specified data to all currently registered listeners.
  1064. * Callbacks will fire in the order in which they are registered (FIFO). This
  1065. * function is not exposed publicly; it is used by QUnit internals to emit
  1066. * logging events.
  1067. *
  1068. * @private
  1069. * @method emit
  1070. * @param {String} eventName
  1071. * @param {Object} data
  1072. * @return {Void}
  1073. */
  1074. function emit(eventName, data) {
  1075. if (objectType(eventName) !== "string") {
  1076. throw new TypeError("eventName must be a string when emitting an event");
  1077. } // Clone the callbacks in case one of them registers a new callback
  1078. var originalCallbacks = LISTENERS[eventName];
  1079. var callbacks = originalCallbacks ? _toConsumableArray(originalCallbacks) : [];
  1080. for (var i = 0; i < callbacks.length; i++) {
  1081. callbacks[i](data);
  1082. }
  1083. }
  1084. /**
  1085. * Registers a callback as a listener to the specified event.
  1086. *
  1087. * @public
  1088. * @method on
  1089. * @param {String} eventName
  1090. * @param {Function} callback
  1091. * @return {Void}
  1092. */
  1093. function on(eventName, callback) {
  1094. if (objectType(eventName) !== "string") {
  1095. throw new TypeError("eventName must be a string when registering a listener");
  1096. } else if (!inArray(eventName, SUPPORTED_EVENTS)) {
  1097. var events = SUPPORTED_EVENTS.join(", ");
  1098. throw new Error("\"".concat(eventName, "\" is not a valid event; must be one of: ").concat(events, "."));
  1099. } else if (objectType(callback) !== "function") {
  1100. throw new TypeError("callback must be a function when registering a listener");
  1101. }
  1102. if (!LISTENERS[eventName]) {
  1103. LISTENERS[eventName] = [];
  1104. } // Don't register the same callback more than once
  1105. if (!inArray(callback, LISTENERS[eventName])) {
  1106. LISTENERS[eventName].push(callback);
  1107. }
  1108. }
  1109. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  1110. function createCommonjsModule(fn, basedir, module) {
  1111. return module = {
  1112. path: basedir,
  1113. exports: {},
  1114. require: function (path, base) {
  1115. return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
  1116. }
  1117. }, fn(module, module.exports), module.exports;
  1118. }
  1119. function commonjsRequire () {
  1120. throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
  1121. }
  1122. var es6Promise = createCommonjsModule(function (module, exports) {
  1123. /*!
  1124. * @overview es6-promise - a tiny implementation of Promises/A+.
  1125. * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
  1126. * @license Licensed under MIT license
  1127. * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
  1128. * @version v4.2.8+1e68dce6
  1129. */
  1130. (function (global, factory) {
  1131. module.exports = factory() ;
  1132. })(commonjsGlobal, function () {
  1133. function objectOrFunction(x) {
  1134. var type = typeof x;
  1135. return x !== null && (type === 'object' || type === 'function');
  1136. }
  1137. function isFunction(x) {
  1138. return typeof x === 'function';
  1139. }
  1140. var _isArray = void 0;
  1141. if (Array.isArray) {
  1142. _isArray = Array.isArray;
  1143. } else {
  1144. _isArray = function (x) {
  1145. return Object.prototype.toString.call(x) === '[object Array]';
  1146. };
  1147. }
  1148. var isArray = _isArray;
  1149. var len = 0;
  1150. var vertxNext = void 0;
  1151. var customSchedulerFn = void 0;
  1152. var asap = function asap(callback, arg) {
  1153. queue[len] = callback;
  1154. queue[len + 1] = arg;
  1155. len += 2;
  1156. if (len === 2) {
  1157. // If len is 2, that means that we need to schedule an async flush.
  1158. // If additional callbacks are queued before the queue is flushed, they
  1159. // will be processed by this flush that we are scheduling.
  1160. if (customSchedulerFn) {
  1161. customSchedulerFn(flush);
  1162. } else {
  1163. scheduleFlush();
  1164. }
  1165. }
  1166. };
  1167. function setScheduler(scheduleFn) {
  1168. customSchedulerFn = scheduleFn;
  1169. }
  1170. function setAsap(asapFn) {
  1171. asap = asapFn;
  1172. }
  1173. var browserWindow = typeof window !== 'undefined' ? window : undefined;
  1174. var browserGlobal = browserWindow || {};
  1175. var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
  1176. var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'; // test for web worker but not in IE10
  1177. var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; // node
  1178. function useNextTick() {
  1179. // node version 0.10.x displays a deprecation warning when nextTick is used recursively
  1180. // see https://github.com/cujojs/when/issues/410 for details
  1181. return function () {
  1182. return process.nextTick(flush);
  1183. };
  1184. } // vertx
  1185. function useVertxTimer() {
  1186. if (typeof vertxNext !== 'undefined') {
  1187. return function () {
  1188. vertxNext(flush);
  1189. };
  1190. }
  1191. return useSetTimeout();
  1192. }
  1193. function useMutationObserver() {
  1194. var iterations = 0;
  1195. var observer = new BrowserMutationObserver(flush);
  1196. var node = document.createTextNode('');
  1197. observer.observe(node, {
  1198. characterData: true
  1199. });
  1200. return function () {
  1201. node.data = iterations = ++iterations % 2;
  1202. };
  1203. } // web worker
  1204. function useMessageChannel() {
  1205. var channel = new MessageChannel();
  1206. channel.port1.onmessage = flush;
  1207. return function () {
  1208. return channel.port2.postMessage(0);
  1209. };
  1210. }
  1211. function useSetTimeout() {
  1212. // Store setTimeout reference so es6-promise will be unaffected by
  1213. // other code modifying setTimeout (like sinon.useFakeTimers())
  1214. var globalSetTimeout = setTimeout;
  1215. return function () {
  1216. return globalSetTimeout(flush, 1);
  1217. };
  1218. }
  1219. var queue = new Array(1000);
  1220. function flush() {
  1221. for (var i = 0; i < len; i += 2) {
  1222. var callback = queue[i];
  1223. var arg = queue[i + 1];
  1224. callback(arg);
  1225. queue[i] = undefined;
  1226. queue[i + 1] = undefined;
  1227. }
  1228. len = 0;
  1229. }
  1230. function attemptVertx() {
  1231. try {
  1232. var vertx = Function('return this')().require('vertx');
  1233. vertxNext = vertx.runOnLoop || vertx.runOnContext;
  1234. return useVertxTimer();
  1235. } catch (e) {
  1236. return useSetTimeout();
  1237. }
  1238. }
  1239. var scheduleFlush = void 0; // Decide what async method to use to triggering processing of queued callbacks:
  1240. if (isNode) {
  1241. scheduleFlush = useNextTick();
  1242. } else if (BrowserMutationObserver) {
  1243. scheduleFlush = useMutationObserver();
  1244. } else if (isWorker) {
  1245. scheduleFlush = useMessageChannel();
  1246. } else if (browserWindow === undefined && typeof commonjsRequire === 'function') {
  1247. scheduleFlush = attemptVertx();
  1248. } else {
  1249. scheduleFlush = useSetTimeout();
  1250. }
  1251. function then(onFulfillment, onRejection) {
  1252. var parent = this;
  1253. var child = new this.constructor(noop);
  1254. if (child[PROMISE_ID] === undefined) {
  1255. makePromise(child);
  1256. }
  1257. var _state = parent._state;
  1258. if (_state) {
  1259. var callback = arguments[_state - 1];
  1260. asap(function () {
  1261. return invokeCallback(_state, child, callback, parent._result);
  1262. });
  1263. } else {
  1264. subscribe(parent, child, onFulfillment, onRejection);
  1265. }
  1266. return child;
  1267. }
  1268. /**
  1269. `Promise.resolve` returns a promise that will become resolved with the
  1270. passed `value`. It is shorthand for the following:
  1271. ```javascript
  1272. let promise = new Promise(function(resolve, reject){
  1273. resolve(1);
  1274. });
  1275. promise.then(function(value){
  1276. // value === 1
  1277. });
  1278. ```
  1279. Instead of writing the above, your code now simply becomes the following:
  1280. ```javascript
  1281. let promise = Promise.resolve(1);
  1282. promise.then(function(value){
  1283. // value === 1
  1284. });
  1285. ```
  1286. @method resolve
  1287. @static
  1288. @param {Any} value value that the returned promise will be resolved with
  1289. Useful for tooling.
  1290. @return {Promise} a promise that will become fulfilled with the given
  1291. `value`
  1292. */
  1293. function resolve$1(object) {
  1294. /*jshint validthis:true */
  1295. var Constructor = this;
  1296. if (object && typeof object === 'object' && object.constructor === Constructor) {
  1297. return object;
  1298. }
  1299. var promise = new Constructor(noop);
  1300. resolve(promise, object);
  1301. return promise;
  1302. }
  1303. var PROMISE_ID = Math.random().toString(36).substring(2);
  1304. function noop() {}
  1305. var PENDING = void 0;
  1306. var FULFILLED = 1;
  1307. var REJECTED = 2;
  1308. function selfFulfillment() {
  1309. return new TypeError("You cannot resolve a promise with itself");
  1310. }
  1311. function cannotReturnOwn() {
  1312. return new TypeError('A promises callback cannot return that same promise.');
  1313. }
  1314. function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) {
  1315. try {
  1316. then$$1.call(value, fulfillmentHandler, rejectionHandler);
  1317. } catch (e) {
  1318. return e;
  1319. }
  1320. }
  1321. function handleForeignThenable(promise, thenable, then$$1) {
  1322. asap(function (promise) {
  1323. var sealed = false;
  1324. var error = tryThen(then$$1, thenable, function (value) {
  1325. if (sealed) {
  1326. return;
  1327. }
  1328. sealed = true;
  1329. if (thenable !== value) {
  1330. resolve(promise, value);
  1331. } else {
  1332. fulfill(promise, value);
  1333. }
  1334. }, function (reason) {
  1335. if (sealed) {
  1336. return;
  1337. }
  1338. sealed = true;
  1339. reject(promise, reason);
  1340. }, 'Settle: ' + (promise._label || ' unknown promise'));
  1341. if (!sealed && error) {
  1342. sealed = true;
  1343. reject(promise, error);
  1344. }
  1345. }, promise);
  1346. }
  1347. function handleOwnThenable(promise, thenable) {
  1348. if (thenable._state === FULFILLED) {
  1349. fulfill(promise, thenable._result);
  1350. } else if (thenable._state === REJECTED) {
  1351. reject(promise, thenable._result);
  1352. } else {
  1353. subscribe(thenable, undefined, function (value) {
  1354. return resolve(promise, value);
  1355. }, function (reason) {
  1356. return reject(promise, reason);
  1357. });
  1358. }
  1359. }
  1360. function handleMaybeThenable(promise, maybeThenable, then$$1) {
  1361. if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) {
  1362. handleOwnThenable(promise, maybeThenable);
  1363. } else {
  1364. if (then$$1 === undefined) {
  1365. fulfill(promise, maybeThenable);
  1366. } else if (isFunction(then$$1)) {
  1367. handleForeignThenable(promise, maybeThenable, then$$1);
  1368. } else {
  1369. fulfill(promise, maybeThenable);
  1370. }
  1371. }
  1372. }
  1373. function resolve(promise, value) {
  1374. if (promise === value) {
  1375. reject(promise, selfFulfillment());
  1376. } else if (objectOrFunction(value)) {
  1377. var then$$1 = void 0;
  1378. try {
  1379. then$$1 = value.then;
  1380. } catch (error) {
  1381. reject(promise, error);
  1382. return;
  1383. }
  1384. handleMaybeThenable(promise, value, then$$1);
  1385. } else {
  1386. fulfill(promise, value);
  1387. }
  1388. }
  1389. function publishRejection(promise) {
  1390. if (promise._onerror) {
  1391. promise._onerror(promise._result);
  1392. }
  1393. publish(promise);
  1394. }
  1395. function fulfill(promise, value) {
  1396. if (promise._state !== PENDING) {
  1397. return;
  1398. }
  1399. promise._result = value;
  1400. promise._state = FULFILLED;
  1401. if (promise._subscribers.length !== 0) {
  1402. asap(publish, promise);
  1403. }
  1404. }
  1405. function reject(promise, reason) {
  1406. if (promise._state !== PENDING) {
  1407. return;
  1408. }
  1409. promise._state = REJECTED;
  1410. promise._result = reason;
  1411. asap(publishRejection, promise);
  1412. }
  1413. function subscribe(parent, child, onFulfillment, onRejection) {
  1414. var _subscribers = parent._subscribers;
  1415. var length = _subscribers.length;
  1416. parent._onerror = null;
  1417. _subscribers[length] = child;
  1418. _subscribers[length + FULFILLED] = onFulfillment;
  1419. _subscribers[length + REJECTED] = onRejection;
  1420. if (length === 0 && parent._state) {
  1421. asap(publish, parent);
  1422. }
  1423. }
  1424. function publish(promise) {
  1425. var subscribers = promise._subscribers;
  1426. var settled = promise._state;
  1427. if (subscribers.length === 0) {
  1428. return;
  1429. }
  1430. var child = void 0,
  1431. callback = void 0,
  1432. detail = promise._result;
  1433. for (var i = 0; i < subscribers.length; i += 3) {
  1434. child = subscribers[i];
  1435. callback = subscribers[i + settled];
  1436. if (child) {
  1437. invokeCallback(settled, child, callback, detail);
  1438. } else {
  1439. callback(detail);
  1440. }
  1441. }
  1442. promise._subscribers.length = 0;
  1443. }
  1444. function invokeCallback(settled, promise, callback, detail) {
  1445. var hasCallback = isFunction(callback),
  1446. value = void 0,
  1447. error = void 0,
  1448. succeeded = true;
  1449. if (hasCallback) {
  1450. try {
  1451. value = callback(detail);
  1452. } catch (e) {
  1453. succeeded = false;
  1454. error = e;
  1455. }
  1456. if (promise === value) {
  1457. reject(promise, cannotReturnOwn());
  1458. return;
  1459. }
  1460. } else {
  1461. value = detail;
  1462. }
  1463. if (promise._state !== PENDING) ; else if (hasCallback && succeeded) {
  1464. resolve(promise, value);
  1465. } else if (succeeded === false) {
  1466. reject(promise, error);
  1467. } else if (settled === FULFILLED) {
  1468. fulfill(promise, value);
  1469. } else if (settled === REJECTED) {
  1470. reject(promise, value);
  1471. }
  1472. }
  1473. function initializePromise(promise, resolver) {
  1474. try {
  1475. resolver(function resolvePromise(value) {
  1476. resolve(promise, value);
  1477. }, function rejectPromise(reason) {
  1478. reject(promise, reason);
  1479. });
  1480. } catch (e) {
  1481. reject(promise, e);
  1482. }
  1483. }
  1484. var id = 0;
  1485. function nextId() {
  1486. return id++;
  1487. }
  1488. function makePromise(promise) {
  1489. promise[PROMISE_ID] = id++;
  1490. promise._state = undefined;
  1491. promise._result = undefined;
  1492. promise._subscribers = [];
  1493. }
  1494. function validationError() {
  1495. return new Error('Array Methods must be provided an Array');
  1496. }
  1497. var Enumerator = function () {
  1498. function Enumerator(Constructor, input) {
  1499. this._instanceConstructor = Constructor;
  1500. this.promise = new Constructor(noop);
  1501. if (!this.promise[PROMISE_ID]) {
  1502. makePromise(this.promise);
  1503. }
  1504. if (isArray(input)) {
  1505. this.length = input.length;
  1506. this._remaining = input.length;
  1507. this._result = new Array(this.length);
  1508. if (this.length === 0) {
  1509. fulfill(this.promise, this._result);
  1510. } else {
  1511. this.length = this.length || 0;
  1512. this._enumerate(input);
  1513. if (this._remaining === 0) {
  1514. fulfill(this.promise, this._result);
  1515. }
  1516. }
  1517. } else {
  1518. reject(this.promise, validationError());
  1519. }
  1520. }
  1521. Enumerator.prototype._enumerate = function _enumerate(input) {
  1522. for (var i = 0; this._state === PENDING && i < input.length; i++) {
  1523. this._eachEntry(input[i], i);
  1524. }
  1525. };
  1526. Enumerator.prototype._eachEntry = function _eachEntry(entry, i) {
  1527. var c = this._instanceConstructor;
  1528. var resolve$$1 = c.resolve;
  1529. if (resolve$$1 === resolve$1) {
  1530. var _then = void 0;
  1531. var error = void 0;
  1532. var didError = false;
  1533. try {
  1534. _then = entry.then;
  1535. } catch (e) {
  1536. didError = true;
  1537. error = e;
  1538. }
  1539. if (_then === then && entry._state !== PENDING) {
  1540. this._settledAt(entry._state, i, entry._result);
  1541. } else if (typeof _then !== 'function') {
  1542. this._remaining--;
  1543. this._result[i] = entry;
  1544. } else if (c === Promise$1) {
  1545. var promise = new c(noop);
  1546. if (didError) {
  1547. reject(promise, error);
  1548. } else {
  1549. handleMaybeThenable(promise, entry, _then);
  1550. }
  1551. this._willSettleAt(promise, i);
  1552. } else {
  1553. this._willSettleAt(new c(function (resolve$$1) {
  1554. return resolve$$1(entry);
  1555. }), i);
  1556. }
  1557. } else {
  1558. this._willSettleAt(resolve$$1(entry), i);
  1559. }
  1560. };
  1561. Enumerator.prototype._settledAt = function _settledAt(state, i, value) {
  1562. var promise = this.promise;
  1563. if (promise._state === PENDING) {
  1564. this._remaining--;
  1565. if (state === REJECTED) {
  1566. reject(promise, value);
  1567. } else {
  1568. this._result[i] = value;
  1569. }
  1570. }
  1571. if (this._remaining === 0) {
  1572. fulfill(promise, this._result);
  1573. }
  1574. };
  1575. Enumerator.prototype._willSettleAt = function _willSettleAt(promise, i) {
  1576. var enumerator = this;
  1577. subscribe(promise, undefined, function (value) {
  1578. return enumerator._settledAt(FULFILLED, i, value);
  1579. }, function (reason) {
  1580. return enumerator._settledAt(REJECTED, i, reason);
  1581. });
  1582. };
  1583. return Enumerator;
  1584. }();
  1585. /**
  1586. `Promise.all` accepts an array of promises, and returns a new promise which
  1587. is fulfilled with an array of fulfillment values for the passed promises, or
  1588. rejected with the reason of the first passed promise to be rejected. It casts all
  1589. elements of the passed iterable to promises as it runs this algorithm.
  1590. Example:
  1591. ```javascript
  1592. let promise1 = resolve(1);
  1593. let promise2 = resolve(2);
  1594. let promise3 = resolve(3);
  1595. let promises = [ promise1, promise2, promise3 ];
  1596. Promise.all(promises).then(function(array){
  1597. // The array here would be [ 1, 2, 3 ];
  1598. });
  1599. ```
  1600. If any of the `promises` given to `all` are rejected, the first promise
  1601. that is rejected will be given as an argument to the returned promises's
  1602. rejection handler. For example:
  1603. Example:
  1604. ```javascript
  1605. let promise1 = resolve(1);
  1606. let promise2 = reject(new Error("2"));
  1607. let promise3 = reject(new Error("3"));
  1608. let promises = [ promise1, promise2, promise3 ];
  1609. Promise.all(promises).then(function(array){
  1610. // Code here never runs because there are rejected promises!
  1611. }, function(error) {
  1612. // error.message === "2"
  1613. });
  1614. ```
  1615. @method all
  1616. @static
  1617. @param {Array} entries array of promises
  1618. @param {String} label optional string for labeling the promise.
  1619. Useful for tooling.
  1620. @return {Promise} promise that is fulfilled when all `promises` have been
  1621. fulfilled, or rejected if any of them become rejected.
  1622. @static
  1623. */
  1624. function all(entries) {
  1625. return new Enumerator(this, entries).promise;
  1626. }
  1627. /**
  1628. `Promise.race` returns a new promise which is settled in the same way as the
  1629. first passed promise to settle.
  1630. Example:
  1631. ```javascript
  1632. let promise1 = new Promise(function(resolve, reject){
  1633. setTimeout(function(){
  1634. resolve('promise 1');
  1635. }, 200);
  1636. });
  1637. let promise2 = new Promise(function(resolve, reject){
  1638. setTimeout(function(){
  1639. resolve('promise 2');
  1640. }, 100);
  1641. });
  1642. Promise.race([promise1, promise2]).then(function(result){
  1643. // result === 'promise 2' because it was resolved before promise1
  1644. // was resolved.
  1645. });
  1646. ```
  1647. `Promise.race` is deterministic in that only the state of the first
  1648. settled promise matters. For example, even if other promises given to the
  1649. `promises` array argument are resolved, but the first settled promise has
  1650. become rejected before the other promises became fulfilled, the returned
  1651. promise will become rejected:
  1652. ```javascript
  1653. let promise1 = new Promise(function(resolve, reject){
  1654. setTimeout(function(){
  1655. resolve('promise 1');
  1656. }, 200);
  1657. });
  1658. let promise2 = new Promise(function(resolve, reject){
  1659. setTimeout(function(){
  1660. reject(new Error('promise 2'));
  1661. }, 100);
  1662. });
  1663. Promise.race([promise1, promise2]).then(function(result){
  1664. // Code here never runs
  1665. }, function(reason){
  1666. // reason.message === 'promise 2' because promise 2 became rejected before
  1667. // promise 1 became fulfilled
  1668. });
  1669. ```
  1670. An example real-world use case is implementing timeouts:
  1671. ```javascript
  1672. Promise.race([ajax('foo.json'), timeout(5000)])
  1673. ```
  1674. @method race
  1675. @static
  1676. @param {Array} promises array of promises to observe
  1677. Useful for tooling.
  1678. @return {Promise} a promise which settles in the same way as the first passed
  1679. promise to settle.
  1680. */
  1681. function race(entries) {
  1682. /*jshint validthis:true */
  1683. var Constructor = this;
  1684. if (!isArray(entries)) {
  1685. return new Constructor(function (_, reject) {
  1686. return reject(new TypeError('You must pass an array to race.'));
  1687. });
  1688. } else {
  1689. return new Constructor(function (resolve, reject) {
  1690. var length = entries.length;
  1691. for (var i = 0; i < length; i++) {
  1692. Constructor.resolve(entries[i]).then(resolve, reject);
  1693. }
  1694. });
  1695. }
  1696. }
  1697. /**
  1698. `Promise.reject` returns a promise rejected with the passed `reason`.
  1699. It is shorthand for the following:
  1700. ```javascript
  1701. let promise = new Promise(function(resolve, reject){
  1702. reject(new Error('WHOOPS'));
  1703. });
  1704. promise.then(function(value){
  1705. // Code here doesn't run because the promise is rejected!
  1706. }, function(reason){
  1707. // reason.message === 'WHOOPS'
  1708. });
  1709. ```
  1710. Instead of writing the above, your code now simply becomes the following:
  1711. ```javascript
  1712. let promise = Promise.reject(new Error('WHOOPS'));
  1713. promise.then(function(value){
  1714. // Code here doesn't run because the promise is rejected!
  1715. }, function(reason){
  1716. // reason.message === 'WHOOPS'
  1717. });
  1718. ```
  1719. @method reject
  1720. @static
  1721. @param {Any} reason value that the returned promise will be rejected with.
  1722. Useful for tooling.
  1723. @return {Promise} a promise rejected with the given `reason`.
  1724. */
  1725. function reject$1(reason) {
  1726. /*jshint validthis:true */
  1727. var Constructor = this;
  1728. var promise = new Constructor(noop);
  1729. reject(promise, reason);
  1730. return promise;
  1731. }
  1732. function needsResolver() {
  1733. throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
  1734. }
  1735. function needsNew() {
  1736. throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
  1737. }
  1738. /**
  1739. Promise objects represent the eventual result of an asynchronous operation. The
  1740. primary way of interacting with a promise is through its `then` method, which
  1741. registers callbacks to receive either a promise's eventual value or the reason
  1742. why the promise cannot be fulfilled.
  1743. Terminology
  1744. -----------
  1745. - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
  1746. - `thenable` is an object or function that defines a `then` method.
  1747. - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
  1748. - `exception` is a value that is thrown using the throw statement.
  1749. - `reason` is a value that indicates why a promise was rejected.
  1750. - `settled` the final resting state of a promise, fulfilled or rejected.
  1751. A promise can be in one of three states: pending, fulfilled, or rejected.
  1752. Promises that are fulfilled have a fulfillment value and are in the fulfilled
  1753. state. Promises that are rejected have a rejection reason and are in the
  1754. rejected state. A fulfillment value is never a thenable.
  1755. Promises can also be said to *resolve* a value. If this value is also a
  1756. promise, then the original promise's settled state will match the value's
  1757. settled state. So a promise that *resolves* a promise that rejects will
  1758. itself reject, and a promise that *resolves* a promise that fulfills will
  1759. itself fulfill.
  1760. Basic Usage:
  1761. ------------
  1762. ```js
  1763. let promise = new Promise(function(resolve, reject) {
  1764. // on success
  1765. resolve(value);
  1766. // on failure
  1767. reject(reason);
  1768. });
  1769. promise.then(function(value) {
  1770. // on fulfillment
  1771. }, function(reason) {
  1772. // on rejection
  1773. });
  1774. ```
  1775. Advanced Usage:
  1776. ---------------
  1777. Promises shine when abstracting away asynchronous interactions such as
  1778. `XMLHttpRequest`s.
  1779. ```js
  1780. function getJSON(url) {
  1781. return new Promise(function(resolve, reject){
  1782. let xhr = new XMLHttpRequest();
  1783. xhr.open('GET', url);
  1784. xhr.onreadystatechange = handler;
  1785. xhr.responseType = 'json';
  1786. xhr.setRequestHeader('Accept', 'application/json');
  1787. xhr.send();
  1788. function handler() {
  1789. if (this.readyState === this.DONE) {
  1790. if (this.status === 200) {
  1791. resolve(this.response);
  1792. } else {
  1793. reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
  1794. }
  1795. }
  1796. };
  1797. });
  1798. }
  1799. getJSON('/posts.json').then(function(json) {
  1800. // on fulfillment
  1801. }, function(reason) {
  1802. // on rejection
  1803. });
  1804. ```
  1805. Unlike callbacks, promises are great composable primitives.
  1806. ```js
  1807. Promise.all([
  1808. getJSON('/posts'),
  1809. getJSON('/comments')
  1810. ]).then(function(values){
  1811. values[0] // => postsJSON
  1812. values[1] // => commentsJSON
  1813. return values;
  1814. });
  1815. ```
  1816. @class Promise
  1817. @param {Function} resolver
  1818. Useful for tooling.
  1819. @constructor
  1820. */
  1821. var Promise$1 = function () {
  1822. function Promise(resolver) {
  1823. this[PROMISE_ID] = nextId();
  1824. this._result = this._state = undefined;
  1825. this._subscribers = [];
  1826. if (noop !== resolver) {
  1827. typeof resolver !== 'function' && needsResolver();
  1828. this instanceof Promise ? initializePromise(this, resolver) : needsNew();
  1829. }
  1830. }
  1831. /**
  1832. The primary way of interacting with a promise is through its `then` method,
  1833. which registers callbacks to receive either a promise's eventual value or the
  1834. reason why the promise cannot be fulfilled.
  1835. ```js
  1836. findUser().then(function(user){
  1837. // user is available
  1838. }, function(reason){
  1839. // user is unavailable, and you are given the reason why
  1840. });
  1841. ```
  1842. Chaining
  1843. --------
  1844. The return value of `then` is itself a promise. This second, 'downstream'
  1845. promise is resolved with the return value of the first promise's fulfillment
  1846. or rejection handler, or rejected if the handler throws an exception.
  1847. ```js
  1848. findUser().then(function (user) {
  1849. return user.name;
  1850. }, function (reason) {
  1851. return 'default name';
  1852. }).then(function (userName) {
  1853. // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
  1854. // will be `'default name'`
  1855. });
  1856. findUser().then(function (user) {
  1857. throw new Error('Found user, but still unhappy');
  1858. }, function (reason) {
  1859. throw new Error('`findUser` rejected and we're unhappy');
  1860. }).then(function (value) {
  1861. // never reached
  1862. }, function (reason) {
  1863. // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
  1864. // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
  1865. });
  1866. ```
  1867. If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
  1868. ```js
  1869. findUser().then(function (user) {
  1870. throw new PedagogicalException('Upstream error');
  1871. }).then(function (value) {
  1872. // never reached
  1873. }).then(function (value) {
  1874. // never reached
  1875. }, function (reason) {
  1876. // The `PedgagocialException` is propagated all the way down to here
  1877. });
  1878. ```
  1879. Assimilation
  1880. ------------
  1881. Sometimes the value you want to propagate to a downstream promise can only be
  1882. retrieved asynchronously. This can be achieved by returning a promise in the
  1883. fulfillment or rejection handler. The downstream promise will then be pending
  1884. until the returned promise is settled. This is called *assimilation*.
  1885. ```js
  1886. findUser().then(function (user) {
  1887. return findCommentsByAuthor(user);
  1888. }).then(function (comments) {
  1889. // The user's comments are now available
  1890. });
  1891. ```
  1892. If the assimliated promise rejects, then the downstream promise will also reject.
  1893. ```js
  1894. findUser().then(function (user) {
  1895. return findCommentsByAuthor(user);
  1896. }).then(function (comments) {
  1897. // If `findCommentsByAuthor` fulfills, we'll have the value here
  1898. }, function (reason) {
  1899. // If `findCommentsByAuthor` rejects, we'll have the reason here
  1900. });
  1901. ```
  1902. Simple Example
  1903. --------------
  1904. Synchronous Example
  1905. ```javascript
  1906. let result;
  1907. try {
  1908. result = findResult();
  1909. // success
  1910. } catch(reason) {
  1911. // failure
  1912. }
  1913. ```
  1914. Errback Example
  1915. ```js
  1916. findResult(function(result, err){
  1917. if (err) {
  1918. // failure
  1919. } else {
  1920. // success
  1921. }
  1922. });
  1923. ```
  1924. Promise Example;
  1925. ```javascript
  1926. findResult().then(function(result){
  1927. // success
  1928. }, function(reason){
  1929. // failure
  1930. });
  1931. ```
  1932. Advanced Example
  1933. --------------
  1934. Synchronous Example
  1935. ```javascript
  1936. let author, books;
  1937. try {
  1938. author = findAuthor();
  1939. books = findBooksByAuthor(author);
  1940. // success
  1941. } catch(reason) {
  1942. // failure
  1943. }
  1944. ```
  1945. Errback Example
  1946. ```js
  1947. function foundBooks(books) {
  1948. }
  1949. function failure(reason) {
  1950. }
  1951. findAuthor(function(author, err){
  1952. if (err) {
  1953. failure(err);
  1954. // failure
  1955. } else {
  1956. try {
  1957. findBoooksByAuthor(author, function(books, err) {
  1958. if (err) {
  1959. failure(err);
  1960. } else {
  1961. try {
  1962. foundBooks(books);
  1963. } catch(reason) {
  1964. failure(reason);
  1965. }
  1966. }
  1967. });
  1968. } catch(error) {
  1969. failure(err);
  1970. }
  1971. // success
  1972. }
  1973. });
  1974. ```
  1975. Promise Example;
  1976. ```javascript
  1977. findAuthor().
  1978. then(findBooksByAuthor).
  1979. then(function(books){
  1980. // found books
  1981. }).catch(function(reason){
  1982. // something went wrong
  1983. });
  1984. ```
  1985. @method then
  1986. @param {Function} onFulfilled
  1987. @param {Function} onRejected
  1988. Useful for tooling.
  1989. @return {Promise}
  1990. */
  1991. /**
  1992. `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
  1993. as the catch block of a try/catch statement.
  1994. ```js
  1995. function findAuthor(){
  1996. throw new Error('couldn't find that author');
  1997. }
  1998. // synchronous
  1999. try {
  2000. findAuthor();
  2001. } catch(reason) {
  2002. // something went wrong
  2003. }
  2004. // async with promises
  2005. findAuthor().catch(function(reason){
  2006. // something went wrong
  2007. });
  2008. ```
  2009. @method catch
  2010. @param {Function} onRejection
  2011. Useful for tooling.
  2012. @return {Promise}
  2013. */
  2014. Promise.prototype.catch = function _catch(onRejection) {
  2015. return this.then(null, onRejection);
  2016. };
  2017. /**
  2018. `finally` will be invoked regardless of the promise's fate just as native
  2019. try/catch/finally behaves
  2020. Synchronous example:
  2021. ```js
  2022. findAuthor() {
  2023. if (Math.random() > 0.5) {
  2024. throw new Error();
  2025. }
  2026. return new Author();
  2027. }
  2028. try {
  2029. return findAuthor(); // succeed or fail
  2030. } catch(error) {
  2031. return findOtherAuther();
  2032. } finally {
  2033. // always runs
  2034. // doesn't affect the return value
  2035. }
  2036. ```
  2037. Asynchronous example:
  2038. ```js
  2039. findAuthor().catch(function(reason){
  2040. return findOtherAuther();
  2041. }).finally(function(){
  2042. // author was either found, or not
  2043. });
  2044. ```
  2045. @method finally
  2046. @param {Function} callback
  2047. @return {Promise}
  2048. */
  2049. Promise.prototype.finally = function _finally(callback) {
  2050. var promise = this;
  2051. var constructor = promise.constructor;
  2052. if (isFunction(callback)) {
  2053. return promise.then(function (value) {
  2054. return constructor.resolve(callback()).then(function () {
  2055. return value;
  2056. });
  2057. }, function (reason) {
  2058. return constructor.resolve(callback()).then(function () {
  2059. throw reason;
  2060. });
  2061. });
  2062. }
  2063. return promise.then(callback, callback);
  2064. };
  2065. return Promise;
  2066. }();
  2067. Promise$1.prototype.then = then;
  2068. Promise$1.all = all;
  2069. Promise$1.race = race;
  2070. Promise$1.resolve = resolve$1;
  2071. Promise$1.reject = reject$1;
  2072. Promise$1._setScheduler = setScheduler;
  2073. Promise$1._setAsap = setAsap;
  2074. Promise$1._asap = asap;
  2075. /*global self*/
  2076. function polyfill() {
  2077. var local = void 0;
  2078. if (typeof commonjsGlobal !== 'undefined') {
  2079. local = commonjsGlobal;
  2080. } else if (typeof self !== 'undefined') {
  2081. local = self;
  2082. } else {
  2083. try {
  2084. local = Function('return this')();
  2085. } catch (e) {
  2086. throw new Error('polyfill failed because global object is unavailable in this environment');
  2087. }
  2088. }
  2089. var P = local.Promise;
  2090. if (P) {
  2091. var promiseToString = null;
  2092. try {
  2093. promiseToString = Object.prototype.toString.call(P.resolve());
  2094. } catch (e) {// silently ignored
  2095. }
  2096. if (promiseToString === '[object Promise]' && !P.cast) {
  2097. return;
  2098. }
  2099. }
  2100. local.Promise = Promise$1;
  2101. } // Strange compat..
  2102. Promise$1.polyfill = polyfill;
  2103. Promise$1.Promise = Promise$1;
  2104. return Promise$1;
  2105. });
  2106. });
  2107. var Promise$1 = typeof Promise !== "undefined" ? Promise : es6Promise;
  2108. function registerLoggingCallbacks(obj) {
  2109. var i,
  2110. l,
  2111. key,
  2112. callbackNames = ["begin", "done", "log", "testStart", "testDone", "moduleStart", "moduleDone"];
  2113. function registerLoggingCallback(key) {
  2114. var loggingCallback = function loggingCallback(callback) {
  2115. if (objectType(callback) !== "function") {
  2116. throw new Error("QUnit logging methods require a callback function as their first parameters.");
  2117. }
  2118. config.callbacks[key].push(callback);
  2119. };
  2120. return loggingCallback;
  2121. }
  2122. for (i = 0, l = callbackNames.length; i < l; i++) {
  2123. key = callbackNames[i]; // Initialize key collection of logging callback
  2124. if (objectType(config.callbacks[key]) === "undefined") {
  2125. config.callbacks[key] = [];
  2126. }
  2127. obj[key] = registerLoggingCallback(key);
  2128. }
  2129. }
  2130. function runLoggingCallbacks(key, args) {
  2131. var callbacks = config.callbacks[key]; // Handling 'log' callbacks separately. Unlike the other callbacks,
  2132. // the log callback is not controlled by the processing queue,
  2133. // but rather used by asserts. Hence to promisfy the 'log' callback
  2134. // would mean promisfying each step of a test
  2135. if (key === "log") {
  2136. callbacks.map(function (callback) {
  2137. return callback(args);
  2138. });
  2139. return;
  2140. } // ensure that each callback is executed serially
  2141. return callbacks.reduce(function (promiseChain, callback) {
  2142. return promiseChain.then(function () {
  2143. return Promise$1.resolve(callback(args));
  2144. });
  2145. }, Promise$1.resolve([]));
  2146. }
  2147. // Doesn't support IE9, it will return undefined on these browsers
  2148. // See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error/Stack
  2149. var fileName = (sourceFromStacktrace(0) || "").replace(/(:\d+)+\)?/, "").replace(/.+\//, "");
  2150. function extractStacktrace(e, offset) {
  2151. offset = offset === undefined ? 4 : offset;
  2152. var stack, include, i;
  2153. if (e && e.stack) {
  2154. stack = e.stack.split("\n");
  2155. if (/^error$/i.test(stack[0])) {
  2156. stack.shift();
  2157. }
  2158. if (fileName) {
  2159. include = [];
  2160. for (i = offset; i < stack.length; i++) {
  2161. if (stack[i].indexOf(fileName) !== -1) {
  2162. break;
  2163. }
  2164. include.push(stack[i]);
  2165. }
  2166. if (include.length) {
  2167. return include.join("\n");
  2168. }
  2169. }
  2170. return stack[offset];
  2171. }
  2172. }
  2173. function sourceFromStacktrace(offset) {
  2174. var error = new Error(); // Support: Safari <=7 only, IE <=10 - 11 only
  2175. // Not all browsers generate the `stack` property for `new Error()`, see also #636
  2176. if (!error.stack) {
  2177. try {
  2178. throw error;
  2179. } catch (err) {
  2180. error = err;
  2181. }
  2182. }
  2183. return extractStacktrace(error, offset);
  2184. }
  2185. var priorityCount = 0;
  2186. var unitSampler; // This is a queue of functions that are tasks within a single test.
  2187. // After tests are dequeued from config.queue they are expanded into
  2188. // a set of tasks in this queue.
  2189. var taskQueue = [];
  2190. /**
  2191. * Advances the taskQueue to the next task. If the taskQueue is empty,
  2192. * process the testQueue
  2193. */
  2194. function advance() {
  2195. advanceTaskQueue();
  2196. if (!taskQueue.length && !config.blocking && !config.current) {
  2197. advanceTestQueue();
  2198. }
  2199. }
  2200. /**
  2201. * Advances the taskQueue with an increased depth
  2202. */
  2203. function advanceTaskQueue() {
  2204. var start = now();
  2205. config.depth = (config.depth || 0) + 1;
  2206. processTaskQueue(start);
  2207. config.depth--;
  2208. }
  2209. /**
  2210. * Process the first task on the taskQueue as a promise.
  2211. * Each task is a function returned by https://github.com/qunitjs/qunit/blob/master/src/test.js#L381
  2212. */
  2213. function processTaskQueue(start) {
  2214. if (taskQueue.length && !config.blocking) {
  2215. var elapsedTime = now() - start;
  2216. if (!setTimeout$1 || config.updateRate <= 0 || elapsedTime < config.updateRate) {
  2217. var task = taskQueue.shift();
  2218. Promise$1.resolve(task()).then(function () {
  2219. if (!taskQueue.length) {
  2220. advance();
  2221. } else {
  2222. processTaskQueue(start);
  2223. }
  2224. });
  2225. } else {
  2226. setTimeout$1(advance);
  2227. }
  2228. }
  2229. }
  2230. /**
  2231. * Advance the testQueue to the next test to process. Call done() if testQueue completes.
  2232. */
  2233. function advanceTestQueue() {
  2234. if (!config.blocking && !config.queue.length && config.depth === 0) {
  2235. done();
  2236. return;
  2237. }
  2238. var testTasks = config.queue.shift();
  2239. addToTaskQueue(testTasks());
  2240. if (priorityCount > 0) {
  2241. priorityCount--;
  2242. }
  2243. advance();
  2244. }
  2245. /**
  2246. * Enqueue the tasks for a test into the task queue.
  2247. * @param {Array} tasksArray
  2248. */
  2249. function addToTaskQueue(tasksArray) {
  2250. taskQueue.push.apply(taskQueue, _toConsumableArray(tasksArray));
  2251. }
  2252. /**
  2253. * Return the number of tasks remaining in the task queue to be processed.
  2254. * @return {Number}
  2255. */
  2256. function taskQueueLength() {
  2257. return taskQueue.length;
  2258. }
  2259. /**
  2260. * Adds a test to the TestQueue for execution.
  2261. * @param {Function} testTasksFunc
  2262. * @param {Boolean} prioritize
  2263. * @param {String} seed
  2264. */
  2265. function addToTestQueue(testTasksFunc, prioritize, seed) {
  2266. if (prioritize) {
  2267. config.queue.splice(priorityCount++, 0, testTasksFunc);
  2268. } else if (seed) {
  2269. if (!unitSampler) {
  2270. unitSampler = unitSamplerGenerator(seed);
  2271. } // Insert into a random position after all prioritized items
  2272. var index = Math.floor(unitSampler() * (config.queue.length - priorityCount + 1));
  2273. config.queue.splice(priorityCount + index, 0, testTasksFunc);
  2274. } else {
  2275. config.queue.push(testTasksFunc);
  2276. }
  2277. }
  2278. /**
  2279. * Creates a seeded "sample" generator which is used for randomizing tests.
  2280. */
  2281. function unitSamplerGenerator(seed) {
  2282. // 32-bit xorshift, requires only a nonzero seed
  2283. // https://excamera.com/sphinx/article-xorshift.html
  2284. var sample = parseInt(generateHash(seed), 16) || -1;
  2285. return function () {
  2286. sample ^= sample << 13;
  2287. sample ^= sample >>> 17;
  2288. sample ^= sample << 5; // ECMAScript has no unsigned number type
  2289. if (sample < 0) {
  2290. sample += 0x100000000;
  2291. }
  2292. return sample / 0x100000000;
  2293. };
  2294. }
  2295. /**
  2296. * This function is called when the ProcessingQueue is done processing all
  2297. * items. It handles emitting the final run events.
  2298. */
  2299. function done() {
  2300. var storage = config.storage;
  2301. ProcessingQueue.finished = true;
  2302. var runtime = now() - config.started;
  2303. var passed = config.stats.all - config.stats.bad;
  2304. if (config.stats.testCount === 0) {
  2305. if (config.filter && config.filter.length) {
  2306. throw new Error("No tests matched the filter \"".concat(config.filter, "\"."));
  2307. }
  2308. if (config.module && config.module.length) {
  2309. throw new Error("No tests matched the module \"".concat(config.module, "\"."));
  2310. }
  2311. if (config.moduleId && config.moduleId.length) {
  2312. throw new Error("No tests matched the moduleId \"".concat(config.moduleId, "\"."));
  2313. }
  2314. if (config.testId && config.testId.length) {
  2315. throw new Error("No tests matched the testId \"".concat(config.testId, "\"."));
  2316. }
  2317. throw new Error("No tests were run.");
  2318. }
  2319. emit("runEnd", globalSuite.end(true));
  2320. runLoggingCallbacks("done", {
  2321. passed: passed,
  2322. failed: config.stats.bad,
  2323. total: config.stats.all,
  2324. runtime: runtime
  2325. }).then(function () {
  2326. // Clear own storage items if all tests passed
  2327. if (storage && config.stats.bad === 0) {
  2328. for (var i = storage.length - 1; i >= 0; i--) {
  2329. var key = storage.key(i);
  2330. if (key.indexOf("qunit-test-") === 0) {
  2331. storage.removeItem(key);
  2332. }
  2333. }
  2334. }
  2335. });
  2336. }
  2337. var ProcessingQueue = {
  2338. finished: false,
  2339. add: addToTestQueue,
  2340. advance: advance,
  2341. taskCount: taskQueueLength
  2342. };
  2343. var TestReport = /*#__PURE__*/function () {
  2344. function TestReport(name, suite, options) {
  2345. _classCallCheck(this, TestReport);
  2346. this.name = name;
  2347. this.suiteName = suite.name;
  2348. this.fullName = suite.fullName.concat(name);
  2349. this.runtime = 0;
  2350. this.assertions = [];
  2351. this.skipped = !!options.skip;
  2352. this.todo = !!options.todo;
  2353. this.valid = options.valid;
  2354. this._startTime = 0;
  2355. this._endTime = 0;
  2356. suite.pushTest(this);
  2357. }
  2358. _createClass(TestReport, [{
  2359. key: "start",
  2360. value: function start(recordTime) {
  2361. if (recordTime) {
  2362. this._startTime = performance.now();
  2363. performance.mark("qunit_test_start");
  2364. }
  2365. return {
  2366. name: this.name,
  2367. suiteName: this.suiteName,
  2368. fullName: this.fullName.slice()
  2369. };
  2370. }
  2371. }, {
  2372. key: "end",
  2373. value: function end(recordTime) {
  2374. if (recordTime) {
  2375. this._endTime = performance.now();
  2376. if (performance) {
  2377. performance.mark("qunit_test_end");
  2378. var testName = this.fullName.join(" – ");
  2379. performance.measure("QUnit Test: ".concat(testName), "qunit_test_start", "qunit_test_end");
  2380. }
  2381. }
  2382. return extend(this.start(), {
  2383. runtime: this.getRuntime(),
  2384. status: this.getStatus(),
  2385. errors: this.getFailedAssertions(),
  2386. assertions: this.getAssertions()
  2387. });
  2388. }
  2389. }, {
  2390. key: "pushAssertion",
  2391. value: function pushAssertion(assertion) {
  2392. this.assertions.push(assertion);
  2393. }
  2394. }, {
  2395. key: "getRuntime",
  2396. value: function getRuntime() {
  2397. return this._endTime - this._startTime;
  2398. }
  2399. }, {
  2400. key: "getStatus",
  2401. value: function getStatus() {
  2402. if (this.skipped) {
  2403. return "skipped";
  2404. }
  2405. var testPassed = this.getFailedAssertions().length > 0 ? this.todo : !this.todo;
  2406. if (!testPassed) {
  2407. return "failed";
  2408. } else if (this.todo) {
  2409. return "todo";
  2410. } else {
  2411. return "passed";
  2412. }
  2413. }
  2414. }, {
  2415. key: "getFailedAssertions",
  2416. value: function getFailedAssertions() {
  2417. return this.assertions.filter(function (assertion) {
  2418. return !assertion.passed;
  2419. });
  2420. }
  2421. }, {
  2422. key: "getAssertions",
  2423. value: function getAssertions() {
  2424. return this.assertions.slice();
  2425. } // Remove actual and expected values from assertions. This is to prevent
  2426. // leaking memory throughout a test suite.
  2427. }, {
  2428. key: "slimAssertions",
  2429. value: function slimAssertions() {
  2430. this.assertions = this.assertions.map(function (assertion) {
  2431. delete assertion.actual;
  2432. delete assertion.expected;
  2433. return assertion;
  2434. });
  2435. }
  2436. }]);
  2437. return TestReport;
  2438. }();
  2439. var focused$1 = false;
  2440. function Test(settings) {
  2441. this.expected = null;
  2442. this.assertions = [];
  2443. this.semaphore = 0;
  2444. this.module = config.currentModule;
  2445. this.steps = [];
  2446. this.timeout = undefined;
  2447. extend(this, settings); // If a module is skipped, all its tests and the tests of the child suites
  2448. // should be treated as skipped even if they are defined as `only` or `todo`.
  2449. // As for `todo` module, all its tests will be treated as `todo` except for
  2450. // tests defined as `skip` which will be left intact.
  2451. //
  2452. // So, if a test is defined as `todo` and is inside a skipped module, we should
  2453. // then treat that test as if was defined as `skip`.
  2454. if (this.module.skip) {
  2455. this.skip = true;
  2456. this.todo = false; // Skipped tests should be left intact
  2457. } else if (this.module.todo && !this.skip) {
  2458. this.todo = true;
  2459. }
  2460. if (!this.skip && typeof this.callback !== "function") {
  2461. var method = this.todo ? "QUnit.todo" : "QUnit.test";
  2462. throw new TypeError("You must provide a callback to ".concat(method, "(\"").concat(this.testName, "\")"));
  2463. } // No validation after this. Beyond this point, failures must be recorded as
  2464. // a completed test with errors, instead of early bail out.
  2465. // Otherwise, internals may be left in an inconsistent state.
  2466. // Ref https://github.com/qunitjs/qunit/issues/1514
  2467. ++Test.count;
  2468. this.errorForStack = new Error();
  2469. this.testReport = new TestReport(this.testName, this.module.suiteReport, {
  2470. todo: this.todo,
  2471. skip: this.skip,
  2472. valid: this.valid()
  2473. }); // Register unique strings
  2474. for (var i = 0, l = this.module.tests; i < l.length; i++) {
  2475. if (this.module.tests[i].name === this.testName) {
  2476. this.testName += " ";
  2477. }
  2478. }
  2479. this.testId = generateHash(this.module.name, this.testName);
  2480. this.module.tests.push({
  2481. name: this.testName,
  2482. testId: this.testId,
  2483. skip: !!this.skip
  2484. });
  2485. if (this.skip) {
  2486. // Skipped tests will fully ignore any sent callback
  2487. this.callback = function () {};
  2488. this.async = false;
  2489. this.expected = 0;
  2490. } else {
  2491. this.assert = new Assert(this);
  2492. }
  2493. }
  2494. Test.count = 0;
  2495. function getNotStartedModules(startModule) {
  2496. var module = startModule,
  2497. modules = [];
  2498. while (module && module.testsRun === 0) {
  2499. modules.push(module);
  2500. module = module.parentModule;
  2501. } // The above push modules from the child to the parent
  2502. // return a reversed order with the top being the top most parent module
  2503. return modules.reverse();
  2504. }
  2505. Test.prototype = {
  2506. // generating a stack trace can be expensive, so using a getter defers this until we need it
  2507. get stack() {
  2508. return extractStacktrace(this.errorForStack, 2);
  2509. },
  2510. before: function before() {
  2511. var _this = this;
  2512. var module = this.module,
  2513. notStartedModules = getNotStartedModules(module); // ensure the callbacks are executed serially for each module
  2514. var callbackPromises = notStartedModules.reduce(function (promiseChain, startModule) {
  2515. return promiseChain.then(function () {
  2516. startModule.stats = {
  2517. all: 0,
  2518. bad: 0,
  2519. started: now()
  2520. };
  2521. emit("suiteStart", startModule.suiteReport.start(true));
  2522. return runLoggingCallbacks("moduleStart", {
  2523. name: startModule.name,
  2524. tests: startModule.tests
  2525. });
  2526. });
  2527. }, Promise$1.resolve([]));
  2528. return callbackPromises.then(function () {
  2529. config.current = _this;
  2530. _this.testEnvironment = extend({}, module.testEnvironment);
  2531. _this.started = now();
  2532. emit("testStart", _this.testReport.start(true));
  2533. return runLoggingCallbacks("testStart", {
  2534. name: _this.testName,
  2535. module: module.name,
  2536. testId: _this.testId,
  2537. previousFailure: _this.previousFailure
  2538. }).then(function () {
  2539. if (!config.pollution) {
  2540. saveGlobal();
  2541. }
  2542. });
  2543. });
  2544. },
  2545. run: function run() {
  2546. var promise;
  2547. config.current = this;
  2548. this.callbackStarted = now();
  2549. if (config.notrycatch) {
  2550. runTest(this);
  2551. return;
  2552. }
  2553. try {
  2554. runTest(this);
  2555. } catch (e) {
  2556. this.pushFailure("Died on test #" + (this.assertions.length + 1) + " " + this.stack + ": " + (e.message || e), extractStacktrace(e, 0)); // Else next test will carry the responsibility
  2557. saveGlobal(); // Restart the tests if they're blocking
  2558. if (config.blocking) {
  2559. internalRecover(this);
  2560. }
  2561. }
  2562. function runTest(test) {
  2563. promise = test.callback.call(test.testEnvironment, test.assert);
  2564. test.resolvePromise(promise); // If the test has a "lock" on it, but the timeout is 0, then we push a
  2565. // failure as the test should be synchronous.
  2566. if (test.timeout === 0 && test.semaphore !== 0) {
  2567. pushFailure("Test did not finish synchronously even though assert.timeout( 0 ) was used.", sourceFromStacktrace(2));
  2568. }
  2569. }
  2570. },
  2571. after: function after() {
  2572. checkPollution();
  2573. },
  2574. queueHook: function queueHook(hook, hookName, hookOwner) {
  2575. var _this2 = this;
  2576. var callHook = function callHook() {
  2577. var promise = hook.call(_this2.testEnvironment, _this2.assert);
  2578. _this2.resolvePromise(promise, hookName);
  2579. };
  2580. var runHook = function runHook() {
  2581. if (hookName === "before") {
  2582. if (hookOwner.testsRun !== 0) {
  2583. return;
  2584. }
  2585. _this2.preserveEnvironment = true;
  2586. } // The 'after' hook should only execute when there are not tests left and
  2587. // when the 'after' and 'finish' tasks are the only tasks left to process
  2588. if (hookName === "after" && !lastTestWithinModuleExecuted(hookOwner) && (config.queue.length > 0 || ProcessingQueue.taskCount() > 2)) {
  2589. return;
  2590. }
  2591. config.current = _this2;
  2592. if (config.notrycatch) {
  2593. callHook();
  2594. return;
  2595. }
  2596. try {
  2597. callHook();
  2598. } catch (error) {
  2599. _this2.pushFailure(hookName + " failed on " + _this2.testName + ": " + (error.message || error), extractStacktrace(error, 0));
  2600. }
  2601. };
  2602. return runHook;
  2603. },
  2604. // Currently only used for module level hooks, can be used to add global level ones
  2605. hooks: function hooks(handler) {
  2606. var hooks = [];
  2607. function processHooks(test, module) {
  2608. if (module.parentModule) {
  2609. processHooks(test, module.parentModule);
  2610. }
  2611. if (module.hooks[handler].length) {
  2612. for (var i = 0; i < module.hooks[handler].length; i++) {
  2613. hooks.push(test.queueHook(module.hooks[handler][i], handler, module));
  2614. }
  2615. }
  2616. } // Hooks are ignored on skipped tests
  2617. if (!this.skip) {
  2618. processHooks(this, this.module);
  2619. }
  2620. return hooks;
  2621. },
  2622. finish: function finish() {
  2623. config.current = this; // Release the test callback to ensure that anything referenced has been
  2624. // released to be garbage collected.
  2625. this.callback = undefined;
  2626. if (this.steps.length) {
  2627. var stepsList = this.steps.join(", ");
  2628. this.pushFailure("Expected assert.verifySteps() to be called before end of test " + "after using assert.step(). Unverified steps: ".concat(stepsList), this.stack);
  2629. }
  2630. if (config.requireExpects && this.expected === null) {
  2631. this.pushFailure("Expected number of assertions to be defined, but expect() was " + "not called.", this.stack);
  2632. } else if (this.expected !== null && this.expected !== this.assertions.length) {
  2633. this.pushFailure("Expected " + this.expected + " assertions, but " + this.assertions.length + " were run", this.stack);
  2634. } else if (this.expected === null && !this.assertions.length) {
  2635. this.pushFailure("Expected at least one assertion, but none were run - call " + "expect(0) to accept zero assertions.", this.stack);
  2636. }
  2637. var i,
  2638. module = this.module,
  2639. moduleName = module.name,
  2640. testName = this.testName,
  2641. skipped = !!this.skip,
  2642. todo = !!this.todo,
  2643. bad = 0,
  2644. storage = config.storage;
  2645. this.runtime = now() - this.started;
  2646. config.stats.all += this.assertions.length;
  2647. config.stats.testCount += 1;
  2648. module.stats.all += this.assertions.length;
  2649. for (i = 0; i < this.assertions.length; i++) {
  2650. if (!this.assertions[i].result) {
  2651. bad++;
  2652. config.stats.bad++;
  2653. module.stats.bad++;
  2654. }
  2655. }
  2656. if (skipped) {
  2657. incrementTestsIgnored(module);
  2658. } else {
  2659. incrementTestsRun(module);
  2660. } // Store result when possible
  2661. if (storage) {
  2662. if (bad) {
  2663. storage.setItem("qunit-test-" + moduleName + "-" + testName, bad);
  2664. } else {
  2665. storage.removeItem("qunit-test-" + moduleName + "-" + testName);
  2666. }
  2667. } // After emitting the js-reporters event we cleanup the assertion data to
  2668. // avoid leaking it. It is not used by the legacy testDone callbacks.
  2669. emit("testEnd", this.testReport.end(true));
  2670. this.testReport.slimAssertions();
  2671. var test = this;
  2672. return runLoggingCallbacks("testDone", {
  2673. name: testName,
  2674. module: moduleName,
  2675. skipped: skipped,
  2676. todo: todo,
  2677. failed: bad,
  2678. passed: this.assertions.length - bad,
  2679. total: this.assertions.length,
  2680. runtime: skipped ? 0 : this.runtime,
  2681. // HTML Reporter use
  2682. assertions: this.assertions,
  2683. testId: this.testId,
  2684. // Source of Test
  2685. // generating stack trace is expensive, so using a getter will help defer this until we need it
  2686. get source() {
  2687. return test.stack;
  2688. }
  2689. }).then(function () {
  2690. if (allTestsExecuted(module)) {
  2691. var completedModules = [module]; // Check if the parent modules, iteratively, are done. If that the case,
  2692. // we emit the `suiteEnd` event and trigger `moduleDone` callback.
  2693. var parent = module.parentModule;
  2694. while (parent && allTestsExecuted(parent)) {
  2695. completedModules.push(parent);
  2696. parent = parent.parentModule;
  2697. }
  2698. return completedModules.reduce(function (promiseChain, completedModule) {
  2699. return promiseChain.then(function () {
  2700. return logSuiteEnd(completedModule);
  2701. });
  2702. }, Promise$1.resolve([]));
  2703. }
  2704. }).then(function () {
  2705. config.current = undefined;
  2706. });
  2707. function logSuiteEnd(module) {
  2708. // Reset `module.hooks` to ensure that anything referenced in these hooks
  2709. // has been released to be garbage collected.
  2710. module.hooks = {};
  2711. emit("suiteEnd", module.suiteReport.end(true));
  2712. return runLoggingCallbacks("moduleDone", {
  2713. name: module.name,
  2714. tests: module.tests,
  2715. failed: module.stats.bad,
  2716. passed: module.stats.all - module.stats.bad,
  2717. total: module.stats.all,
  2718. runtime: now() - module.stats.started
  2719. });
  2720. }
  2721. },
  2722. preserveTestEnvironment: function preserveTestEnvironment() {
  2723. if (this.preserveEnvironment) {
  2724. this.module.testEnvironment = this.testEnvironment;
  2725. this.testEnvironment = extend({}, this.module.testEnvironment);
  2726. }
  2727. },
  2728. queue: function queue() {
  2729. var test = this;
  2730. if (!this.valid()) {
  2731. incrementTestsIgnored(this.module);
  2732. return;
  2733. }
  2734. function runTest() {
  2735. return [function () {
  2736. return test.before();
  2737. }].concat(_toConsumableArray(test.hooks("before")), [function () {
  2738. test.preserveTestEnvironment();
  2739. }], _toConsumableArray(test.hooks("beforeEach")), [function () {
  2740. test.run();
  2741. }], _toConsumableArray(test.hooks("afterEach").reverse()), _toConsumableArray(test.hooks("after").reverse()), [function () {
  2742. test.after();
  2743. }, function () {
  2744. return test.finish();
  2745. }]);
  2746. }
  2747. var previousFailCount = config.storage && +config.storage.getItem("qunit-test-" + this.module.name + "-" + this.testName); // Prioritize previously failed tests, detected from storage
  2748. var prioritize = config.reorder && !!previousFailCount;
  2749. this.previousFailure = !!previousFailCount;
  2750. ProcessingQueue.add(runTest, prioritize, config.seed); // If the queue has already finished, we manually process the new test
  2751. if (ProcessingQueue.finished) {
  2752. ProcessingQueue.advance();
  2753. }
  2754. },
  2755. pushResult: function pushResult(resultInfo) {
  2756. if (this !== config.current) {
  2757. var message = resultInfo && resultInfo.message || "";
  2758. var testName = this && this.testName || "";
  2759. var error = "Assertion occurred after test finished.\n" + "> Test: " + testName + "\n" + "> Message: " + message + "\n";
  2760. throw new Error(error);
  2761. } // Destructure of resultInfo = { result, actual, expected, message, negative }
  2762. var source,
  2763. details = {
  2764. module: this.module.name,
  2765. name: this.testName,
  2766. result: resultInfo.result,
  2767. message: resultInfo.message,
  2768. actual: resultInfo.actual,
  2769. testId: this.testId,
  2770. negative: resultInfo.negative || false,
  2771. runtime: now() - this.started,
  2772. todo: !!this.todo
  2773. };
  2774. if (hasOwn.call(resultInfo, "expected")) {
  2775. details.expected = resultInfo.expected;
  2776. }
  2777. if (!resultInfo.result) {
  2778. source = resultInfo.source || sourceFromStacktrace();
  2779. if (source) {
  2780. details.source = source;
  2781. }
  2782. }
  2783. this.logAssertion(details);
  2784. this.assertions.push({
  2785. result: !!resultInfo.result,
  2786. message: resultInfo.message
  2787. });
  2788. },
  2789. pushFailure: function pushFailure(message, source, actual) {
  2790. if (!(this instanceof Test)) {
  2791. throw new Error("pushFailure() assertion outside test context, was " + sourceFromStacktrace(2));
  2792. }
  2793. this.pushResult({
  2794. result: false,
  2795. message: message || "error",
  2796. actual: actual || null,
  2797. source: source
  2798. });
  2799. },
  2800. /**
  2801. * Log assertion details using both the old QUnit.log interface and
  2802. * QUnit.on( "assertion" ) interface.
  2803. *
  2804. * @private
  2805. */
  2806. logAssertion: function logAssertion(details) {
  2807. runLoggingCallbacks("log", details);
  2808. var assertion = {
  2809. passed: details.result,
  2810. actual: details.actual,
  2811. expected: details.expected,
  2812. message: details.message,
  2813. stack: details.source,
  2814. todo: details.todo
  2815. };
  2816. this.testReport.pushAssertion(assertion);
  2817. emit("assertion", assertion);
  2818. },
  2819. resolvePromise: function resolvePromise(promise, phase) {
  2820. var then,
  2821. resume,
  2822. message,
  2823. test = this;
  2824. if (promise != null) {
  2825. then = promise.then;
  2826. if (objectType(then) === "function") {
  2827. resume = internalStop(test);
  2828. if (config.notrycatch) {
  2829. then.call(promise, function () {
  2830. resume();
  2831. });
  2832. } else {
  2833. then.call(promise, function () {
  2834. resume();
  2835. }, function (error) {
  2836. message = "Promise rejected " + (!phase ? "during" : phase.replace(/Each$/, "")) + " \"" + test.testName + "\": " + (error && error.message || error);
  2837. test.pushFailure(message, extractStacktrace(error, 0)); // Else next test will carry the responsibility
  2838. saveGlobal(); // Unblock
  2839. internalRecover(test);
  2840. });
  2841. }
  2842. }
  2843. }
  2844. },
  2845. valid: function valid() {
  2846. var filter = config.filter,
  2847. regexFilter = /^(!?)\/([\w\W]*)\/(i?$)/.exec(filter),
  2848. module = config.module && config.module.toLowerCase(),
  2849. fullName = this.module.name + ": " + this.testName;
  2850. function moduleChainNameMatch(testModule) {
  2851. var testModuleName = testModule.name ? testModule.name.toLowerCase() : null;
  2852. if (testModuleName === module) {
  2853. return true;
  2854. } else if (testModule.parentModule) {
  2855. return moduleChainNameMatch(testModule.parentModule);
  2856. } else {
  2857. return false;
  2858. }
  2859. }
  2860. function moduleChainIdMatch(testModule) {
  2861. return inArray(testModule.moduleId, config.moduleId) || testModule.parentModule && moduleChainIdMatch(testModule.parentModule);
  2862. } // Internally-generated tests are always valid
  2863. if (this.callback && this.callback.validTest) {
  2864. return true;
  2865. }
  2866. if (config.moduleId && config.moduleId.length > 0 && !moduleChainIdMatch(this.module)) {
  2867. return false;
  2868. }
  2869. if (config.testId && config.testId.length > 0 && !inArray(this.testId, config.testId)) {
  2870. return false;
  2871. }
  2872. if (module && !moduleChainNameMatch(this.module)) {
  2873. return false;
  2874. }
  2875. if (!filter) {
  2876. return true;
  2877. }
  2878. return regexFilter ? this.regexFilter(!!regexFilter[1], regexFilter[2], regexFilter[3], fullName) : this.stringFilter(filter, fullName);
  2879. },
  2880. regexFilter: function regexFilter(exclude, pattern, flags, fullName) {
  2881. var regex = new RegExp(pattern, flags);
  2882. var match = regex.test(fullName);
  2883. return match !== exclude;
  2884. },
  2885. stringFilter: function stringFilter(filter, fullName) {
  2886. filter = filter.toLowerCase();
  2887. fullName = fullName.toLowerCase();
  2888. var include = filter.charAt(0) !== "!";
  2889. if (!include) {
  2890. filter = filter.slice(1);
  2891. } // If the filter matches, we need to honour include
  2892. if (fullName.indexOf(filter) !== -1) {
  2893. return include;
  2894. } // Otherwise, do the opposite
  2895. return !include;
  2896. }
  2897. };
  2898. function pushFailure() {
  2899. if (!config.current) {
  2900. throw new Error("pushFailure() assertion outside test context, in " + sourceFromStacktrace(2));
  2901. } // Gets current test obj
  2902. var currentTest = config.current;
  2903. return currentTest.pushFailure.apply(currentTest, arguments);
  2904. }
  2905. function saveGlobal() {
  2906. config.pollution = [];
  2907. if (config.noglobals) {
  2908. for (var key in global__default['default']) {
  2909. if (hasOwn.call(global__default['default'], key)) {
  2910. // In Opera sometimes DOM element ids show up here, ignore them
  2911. if (/^qunit-test-output/.test(key)) {
  2912. continue;
  2913. }
  2914. config.pollution.push(key);
  2915. }
  2916. }
  2917. }
  2918. }
  2919. function checkPollution() {
  2920. var newGlobals,
  2921. deletedGlobals,
  2922. old = config.pollution;
  2923. saveGlobal();
  2924. newGlobals = diff(config.pollution, old);
  2925. if (newGlobals.length > 0) {
  2926. pushFailure("Introduced global variable(s): " + newGlobals.join(", "));
  2927. }
  2928. deletedGlobals = diff(old, config.pollution);
  2929. if (deletedGlobals.length > 0) {
  2930. pushFailure("Deleted global variable(s): " + deletedGlobals.join(", "));
  2931. }
  2932. } // Will be exposed as QUnit.test
  2933. function test(testName, callback) {
  2934. if (focused$1) {
  2935. return;
  2936. }
  2937. var newTest = new Test({
  2938. testName: testName,
  2939. callback: callback
  2940. });
  2941. newTest.queue();
  2942. }
  2943. extend(test, {
  2944. todo: function todo(testName, callback) {
  2945. if (focused$1) {
  2946. return;
  2947. }
  2948. var newTest = new Test({
  2949. testName: testName,
  2950. callback: callback,
  2951. todo: true
  2952. });
  2953. newTest.queue();
  2954. },
  2955. skip: function skip(testName) {
  2956. if (focused$1) {
  2957. return;
  2958. }
  2959. var test = new Test({
  2960. testName: testName,
  2961. skip: true
  2962. });
  2963. test.queue();
  2964. },
  2965. only: function only(testName, callback) {
  2966. if (!focused$1) {
  2967. config.queue.length = 0;
  2968. focused$1 = true;
  2969. }
  2970. var newTest = new Test({
  2971. testName: testName,
  2972. callback: callback
  2973. });
  2974. newTest.queue();
  2975. }
  2976. }); // Resets config.timeout with a new timeout duration.
  2977. function resetTestTimeout(timeoutDuration) {
  2978. clearTimeout(config.timeout);
  2979. config.timeout = setTimeout$1(config.timeoutHandler(timeoutDuration), timeoutDuration);
  2980. } // Put a hold on processing and return a function that will release it.
  2981. function internalStop(test) {
  2982. var released = false;
  2983. test.semaphore += 1;
  2984. config.blocking = true; // Set a recovery timeout, if so configured.
  2985. if (setTimeout$1) {
  2986. var timeoutDuration;
  2987. if (typeof test.timeout === "number") {
  2988. timeoutDuration = test.timeout;
  2989. } else if (typeof config.testTimeout === "number") {
  2990. timeoutDuration = config.testTimeout;
  2991. }
  2992. if (typeof timeoutDuration === "number" && timeoutDuration > 0) {
  2993. clearTimeout(config.timeout);
  2994. config.timeoutHandler = function (timeout) {
  2995. return function () {
  2996. pushFailure("Test took longer than ".concat(timeout, "ms; test timed out."), sourceFromStacktrace(2));
  2997. released = true;
  2998. internalRecover(test);
  2999. };
  3000. };
  3001. config.timeout = setTimeout$1(config.timeoutHandler(timeoutDuration), timeoutDuration);
  3002. }
  3003. }
  3004. return function resume() {
  3005. if (released) {
  3006. return;
  3007. }
  3008. released = true;
  3009. test.semaphore -= 1;
  3010. internalStart(test);
  3011. };
  3012. } // Forcefully release all processing holds.
  3013. function internalRecover(test) {
  3014. test.semaphore = 0;
  3015. internalStart(test);
  3016. } // Release a processing hold, scheduling a resumption attempt if no holds remain.
  3017. function internalStart(test) {
  3018. // If semaphore is non-numeric, throw error
  3019. if (isNaN(test.semaphore)) {
  3020. test.semaphore = 0;
  3021. pushFailure("Invalid value on test.semaphore", sourceFromStacktrace(2));
  3022. return;
  3023. } // Don't start until equal number of stop-calls
  3024. if (test.semaphore > 0) {
  3025. return;
  3026. } // Throw an Error if start is called more often than stop
  3027. if (test.semaphore < 0) {
  3028. test.semaphore = 0;
  3029. pushFailure("Tried to restart test while already started (test's semaphore was 0 already)", sourceFromStacktrace(2));
  3030. return;
  3031. } // Add a slight delay to allow more assertions etc.
  3032. if (setTimeout$1) {
  3033. if (config.timeout) {
  3034. clearTimeout(config.timeout);
  3035. }
  3036. config.timeout = setTimeout$1(function () {
  3037. if (test.semaphore > 0) {
  3038. return;
  3039. }
  3040. if (config.timeout) {
  3041. clearTimeout(config.timeout);
  3042. }
  3043. begin();
  3044. });
  3045. } else {
  3046. begin();
  3047. }
  3048. }
  3049. function collectTests(module) {
  3050. var tests = [].concat(module.tests);
  3051. var modules = _toConsumableArray(module.childModules); // Do a breadth-first traversal of the child modules
  3052. while (modules.length) {
  3053. var nextModule = modules.shift();
  3054. tests.push.apply(tests, nextModule.tests);
  3055. modules.push.apply(modules, _toConsumableArray(nextModule.childModules));
  3056. }
  3057. return tests;
  3058. } // This returns true after all executable and skippable tests
  3059. // in a module have been proccessed, and informs 'suiteEnd'
  3060. // and moduleDone().
  3061. function allTestsExecuted(module) {
  3062. return module.testsRun + module.testsIgnored === collectTests(module).length;
  3063. } // This returns true during the last executable non-skipped test
  3064. // within a module, and informs the running of the 'after' hook
  3065. // for a given module. This runs only once for a given module,
  3066. // but must run during the last non-skipped test. When it runs,
  3067. // there may be non-zero skipped tests left.
  3068. function lastTestWithinModuleExecuted(module) {
  3069. return module.testsRun === collectTests(module).filter(function (test) {
  3070. return !test.skip;
  3071. }).length - 1;
  3072. }
  3073. function incrementTestsRun(module) {
  3074. module.testsRun++;
  3075. while (module = module.parentModule) {
  3076. module.testsRun++;
  3077. }
  3078. }
  3079. function incrementTestsIgnored(module) {
  3080. module.testsIgnored++;
  3081. while (module = module.parentModule) {
  3082. module.testsIgnored++;
  3083. }
  3084. }
  3085. var Assert = /*#__PURE__*/function () {
  3086. function Assert(testContext) {
  3087. _classCallCheck(this, Assert);
  3088. this.test = testContext;
  3089. } // Assert helpers
  3090. _createClass(Assert, [{
  3091. key: "timeout",
  3092. value: function timeout(duration) {
  3093. if (typeof duration !== "number") {
  3094. throw new Error("You must pass a number as the duration to assert.timeout");
  3095. }
  3096. this.test.timeout = duration; // If a timeout has been set, clear it and reset with the new duration
  3097. if (config.timeout) {
  3098. clearTimeout(config.timeout);
  3099. if (config.timeoutHandler && this.test.timeout > 0) {
  3100. resetTestTimeout(this.test.timeout);
  3101. }
  3102. }
  3103. } // Documents a "step", which is a string value, in a test as a passing assertion
  3104. }, {
  3105. key: "step",
  3106. value: function step(message) {
  3107. var assertionMessage = message;
  3108. var result = !!message;
  3109. this.test.steps.push(message);
  3110. if (objectType(message) === "undefined" || message === "") {
  3111. assertionMessage = "You must provide a message to assert.step";
  3112. } else if (objectType(message) !== "string") {
  3113. assertionMessage = "You must provide a string value to assert.step";
  3114. result = false;
  3115. }
  3116. this.pushResult({
  3117. result: result,
  3118. message: assertionMessage
  3119. });
  3120. } // Verifies the steps in a test match a given array of string values
  3121. }, {
  3122. key: "verifySteps",
  3123. value: function verifySteps(steps, message) {
  3124. // Since the steps array is just string values, we can clone with slice
  3125. var actualStepsClone = this.test.steps.slice();
  3126. this.deepEqual(actualStepsClone, steps, message);
  3127. this.test.steps.length = 0;
  3128. } // Specify the number of expected assertions to guarantee that failed test
  3129. // (no assertions are run at all) don't slip through.
  3130. }, {
  3131. key: "expect",
  3132. value: function expect(asserts) {
  3133. if (arguments.length === 1) {
  3134. this.test.expected = asserts;
  3135. } else {
  3136. return this.test.expected;
  3137. }
  3138. } // Put a hold on processing and return a function that will release it a maximum of once.
  3139. }, {
  3140. key: "async",
  3141. value: function async(count) {
  3142. var test = this.test;
  3143. var popped = false,
  3144. acceptCallCount = count;
  3145. if (typeof acceptCallCount === "undefined") {
  3146. acceptCallCount = 1;
  3147. }
  3148. var resume = internalStop(test);
  3149. return function done() {
  3150. if (config.current !== test) {
  3151. throw Error("assert.async callback called after test finished.");
  3152. }
  3153. if (popped) {
  3154. test.pushFailure("Too many calls to the `assert.async` callback", sourceFromStacktrace(2));
  3155. return;
  3156. }
  3157. acceptCallCount -= 1;
  3158. if (acceptCallCount > 0) {
  3159. return;
  3160. }
  3161. popped = true;
  3162. resume();
  3163. };
  3164. } // Exports test.push() to the user API
  3165. // Alias of pushResult.
  3166. }, {
  3167. key: "push",
  3168. value: function push(result, actual, expected, message, negative) {
  3169. Logger.warn("assert.push is deprecated and will be removed in QUnit 3.0." + " Please use assert.pushResult instead (https://api.qunitjs.com/assert/pushResult).");
  3170. var currentAssert = this instanceof Assert ? this : config.current.assert;
  3171. return currentAssert.pushResult({
  3172. result: result,
  3173. actual: actual,
  3174. expected: expected,
  3175. message: message,
  3176. negative: negative
  3177. });
  3178. }
  3179. }, {
  3180. key: "pushResult",
  3181. value: function pushResult(resultInfo) {
  3182. // Destructure of resultInfo = { result, actual, expected, message, negative }
  3183. var assert = this;
  3184. var currentTest = assert instanceof Assert && assert.test || config.current; // Backwards compatibility fix.
  3185. // Allows the direct use of global exported assertions and QUnit.assert.*
  3186. // Although, it's use is not recommended as it can leak assertions
  3187. // to other tests from async tests, because we only get a reference to the current test,
  3188. // not exactly the test where assertion were intended to be called.
  3189. if (!currentTest) {
  3190. throw new Error("assertion outside test context, in " + sourceFromStacktrace(2));
  3191. }
  3192. if (!(assert instanceof Assert)) {
  3193. assert = currentTest.assert;
  3194. }
  3195. return assert.test.pushResult(resultInfo);
  3196. }
  3197. }, {
  3198. key: "ok",
  3199. value: function ok(result, message) {
  3200. if (!message) {
  3201. message = result ? "okay" : "failed, expected argument to be truthy, was: ".concat(dump.parse(result));
  3202. }
  3203. this.pushResult({
  3204. result: !!result,
  3205. actual: result,
  3206. expected: true,
  3207. message: message
  3208. });
  3209. }
  3210. }, {
  3211. key: "notOk",
  3212. value: function notOk(result, message) {
  3213. if (!message) {
  3214. message = !result ? "okay" : "failed, expected argument to be falsy, was: ".concat(dump.parse(result));
  3215. }
  3216. this.pushResult({
  3217. result: !result,
  3218. actual: result,
  3219. expected: false,
  3220. message: message
  3221. });
  3222. }
  3223. }, {
  3224. key: "true",
  3225. value: function _true(result, message) {
  3226. this.pushResult({
  3227. result: result === true,
  3228. actual: result,
  3229. expected: true,
  3230. message: message
  3231. });
  3232. }
  3233. }, {
  3234. key: "false",
  3235. value: function _false(result, message) {
  3236. this.pushResult({
  3237. result: result === false,
  3238. actual: result,
  3239. expected: false,
  3240. message: message
  3241. });
  3242. }
  3243. }, {
  3244. key: "equal",
  3245. value: function equal(actual, expected, message) {
  3246. // eslint-disable-next-line eqeqeq
  3247. var result = expected == actual;
  3248. this.pushResult({
  3249. result: result,
  3250. actual: actual,
  3251. expected: expected,
  3252. message: message
  3253. });
  3254. }
  3255. }, {
  3256. key: "notEqual",
  3257. value: function notEqual(actual, expected, message) {
  3258. // eslint-disable-next-line eqeqeq
  3259. var result = expected != actual;
  3260. this.pushResult({
  3261. result: result,
  3262. actual: actual,
  3263. expected: expected,
  3264. message: message,
  3265. negative: true
  3266. });
  3267. }
  3268. }, {
  3269. key: "propEqual",
  3270. value: function propEqual(actual, expected, message) {
  3271. actual = objectValues(actual);
  3272. expected = objectValues(expected);
  3273. this.pushResult({
  3274. result: equiv(actual, expected),
  3275. actual: actual,
  3276. expected: expected,
  3277. message: message
  3278. });
  3279. }
  3280. }, {
  3281. key: "notPropEqual",
  3282. value: function notPropEqual(actual, expected, message) {
  3283. actual = objectValues(actual);
  3284. expected = objectValues(expected);
  3285. this.pushResult({
  3286. result: !equiv(actual, expected),
  3287. actual: actual,
  3288. expected: expected,
  3289. message: message,
  3290. negative: true
  3291. });
  3292. }
  3293. }, {
  3294. key: "deepEqual",
  3295. value: function deepEqual(actual, expected, message) {
  3296. this.pushResult({
  3297. result: equiv(actual, expected),
  3298. actual: actual,
  3299. expected: expected,
  3300. message: message
  3301. });
  3302. }
  3303. }, {
  3304. key: "notDeepEqual",
  3305. value: function notDeepEqual(actual, expected, message) {
  3306. this.pushResult({
  3307. result: !equiv(actual, expected),
  3308. actual: actual,
  3309. expected: expected,
  3310. message: message,
  3311. negative: true
  3312. });
  3313. }
  3314. }, {
  3315. key: "strictEqual",
  3316. value: function strictEqual(actual, expected, message) {
  3317. this.pushResult({
  3318. result: expected === actual,
  3319. actual: actual,
  3320. expected: expected,
  3321. message: message
  3322. });
  3323. }
  3324. }, {
  3325. key: "notStrictEqual",
  3326. value: function notStrictEqual(actual, expected, message) {
  3327. this.pushResult({
  3328. result: expected !== actual,
  3329. actual: actual,
  3330. expected: expected,
  3331. message: message,
  3332. negative: true
  3333. });
  3334. }
  3335. }, {
  3336. key: "throws",
  3337. value: function throws(block, expected, message) {
  3338. var actual,
  3339. result = false;
  3340. var currentTest = this instanceof Assert && this.test || config.current; // 'expected' is optional unless doing string comparison
  3341. if (objectType(expected) === "string") {
  3342. if (message == null) {
  3343. message = expected;
  3344. expected = null;
  3345. } else {
  3346. throw new Error("throws/raises does not accept a string value for the expected argument.\n" + "Use a non-string object value (e.g. regExp) instead if it's necessary.");
  3347. }
  3348. }
  3349. currentTest.ignoreGlobalErrors = true;
  3350. try {
  3351. block.call(currentTest.testEnvironment);
  3352. } catch (e) {
  3353. actual = e;
  3354. }
  3355. currentTest.ignoreGlobalErrors = false;
  3356. if (actual) {
  3357. var expectedType = objectType(expected); // We don't want to validate thrown error
  3358. if (!expected) {
  3359. result = true; // Expected is a regexp
  3360. } else if (expectedType === "regexp") {
  3361. result = expected.test(errorString(actual)); // Log the string form of the regexp
  3362. expected = String(expected); // Expected is a constructor, maybe an Error constructor.
  3363. // Note the extra check on its prototype - this is an implicit
  3364. // requirement of "instanceof", else it will throw a TypeError.
  3365. } else if (expectedType === "function" && expected.prototype !== undefined && actual instanceof expected) {
  3366. result = true; // Expected is an Error object
  3367. } else if (expectedType === "object") {
  3368. result = actual instanceof expected.constructor && actual.name === expected.name && actual.message === expected.message; // Log the string form of the Error object
  3369. expected = errorString(expected); // Expected is a validation function which returns true if validation passed
  3370. } else if (expectedType === "function" && expected.call({}, actual) === true) {
  3371. expected = null;
  3372. result = true;
  3373. }
  3374. }
  3375. currentTest.assert.pushResult({
  3376. result: result,
  3377. // undefined if it didn't throw
  3378. actual: actual && errorString(actual),
  3379. expected: expected,
  3380. message: message
  3381. });
  3382. }
  3383. }, {
  3384. key: "rejects",
  3385. value: function rejects(promise, expected, message) {
  3386. var result = false;
  3387. var currentTest = this instanceof Assert && this.test || config.current; // 'expected' is optional unless doing string comparison
  3388. if (objectType(expected) === "string") {
  3389. if (message === undefined) {
  3390. message = expected;
  3391. expected = undefined;
  3392. } else {
  3393. message = "assert.rejects does not accept a string value for the expected " + "argument.\nUse a non-string object value (e.g. validator function) instead " + "if necessary.";
  3394. currentTest.assert.pushResult({
  3395. result: false,
  3396. message: message
  3397. });
  3398. return;
  3399. }
  3400. }
  3401. var then = promise && promise.then;
  3402. if (objectType(then) !== "function") {
  3403. var _message = "The value provided to `assert.rejects` in " + "\"" + currentTest.testName + "\" was not a promise.";
  3404. currentTest.assert.pushResult({
  3405. result: false,
  3406. message: _message,
  3407. actual: promise
  3408. });
  3409. return;
  3410. }
  3411. var done = this.async();
  3412. return then.call(promise, function handleFulfillment() {
  3413. var message = "The promise returned by the `assert.rejects` callback in " + "\"" + currentTest.testName + "\" did not reject.";
  3414. currentTest.assert.pushResult({
  3415. result: false,
  3416. message: message,
  3417. actual: promise
  3418. });
  3419. done();
  3420. }, function handleRejection(actual) {
  3421. var expectedType = objectType(expected); // We don't want to validate
  3422. if (expected === undefined) {
  3423. result = true; // Expected is a regexp
  3424. } else if (expectedType === "regexp") {
  3425. result = expected.test(errorString(actual)); // Log the string form of the regexp
  3426. expected = String(expected); // Expected is a constructor, maybe an Error constructor
  3427. } else if (expectedType === "function" && actual instanceof expected) {
  3428. result = true; // Expected is an Error object
  3429. } else if (expectedType === "object") {
  3430. result = actual instanceof expected.constructor && actual.name === expected.name && actual.message === expected.message; // Log the string form of the Error object
  3431. expected = errorString(expected); // Expected is a validation function which returns true if validation passed
  3432. } else {
  3433. if (expectedType === "function") {
  3434. result = expected.call({}, actual) === true;
  3435. expected = null; // Expected is some other invalid type
  3436. } else {
  3437. result = false;
  3438. message = "invalid expected value provided to `assert.rejects` " + "callback in \"" + currentTest.testName + "\": " + expectedType + ".";
  3439. }
  3440. }
  3441. currentTest.assert.pushResult({
  3442. result: result,
  3443. // leave rejection value of undefined as-is
  3444. actual: actual && errorString(actual),
  3445. expected: expected,
  3446. message: message
  3447. });
  3448. done();
  3449. });
  3450. }
  3451. }]);
  3452. return Assert;
  3453. }(); // Provide an alternative to assert.throws(), for environments that consider throws a reserved word
  3454. // Known to us are: Closure Compiler, Narwhal
  3455. // eslint-disable-next-line dot-notation
  3456. Assert.prototype.raises = Assert.prototype["throws"];
  3457. /**
  3458. * Converts an error into a simple string for comparisons.
  3459. *
  3460. * @param {Error|Object} error
  3461. * @return {String}
  3462. */
  3463. function errorString(error) {
  3464. var resultErrorString = error.toString(); // If the error wasn't a subclass of Error but something like
  3465. // an object literal with name and message properties...
  3466. if (resultErrorString.slice(0, 7) === "[object") {
  3467. // Based on https://es5.github.com/#x15.11.4.4
  3468. var name = error.name ? String(error.name) : "Error";
  3469. return error.message ? "".concat(name, ": ").concat(error.message) : name;
  3470. } else {
  3471. return resultErrorString;
  3472. }
  3473. }
  3474. /* global module, exports, define */
  3475. function exportQUnit(QUnit) {
  3476. if (window$1 && document$1) {
  3477. // QUnit may be defined when it is preconfigured but then only QUnit and QUnit.config may be defined.
  3478. if (window$1.QUnit && window$1.QUnit.version) {
  3479. throw new Error("QUnit has already been defined.");
  3480. }
  3481. window$1.QUnit = QUnit;
  3482. } // For nodejs
  3483. if (typeof module !== "undefined" && module && module.exports) {
  3484. module.exports = QUnit; // For consistency with CommonJS environments' exports
  3485. module.exports.QUnit = QUnit;
  3486. } // For CommonJS with exports, but without module.exports, like Rhino
  3487. if (typeof exports !== "undefined" && exports) {
  3488. exports.QUnit = QUnit;
  3489. }
  3490. if (typeof define === "function" && define.amd) {
  3491. define(function () {
  3492. return QUnit;
  3493. });
  3494. QUnit.config.autostart = false;
  3495. } // For Web/Service Workers
  3496. if (self$1 && self$1.WorkerGlobalScope && self$1 instanceof self$1.WorkerGlobalScope) {
  3497. self$1.QUnit = QUnit;
  3498. }
  3499. }
  3500. // error handling should be suppressed and false otherwise.
  3501. // In this case, we will only suppress further error handling if the
  3502. // "ignoreGlobalErrors" configuration option is enabled.
  3503. function onError(error) {
  3504. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  3505. args[_key - 1] = arguments[_key];
  3506. }
  3507. if (config.current) {
  3508. if (config.current.ignoreGlobalErrors) {
  3509. return true;
  3510. }
  3511. pushFailure.apply(void 0, [error.message, error.stacktrace || error.fileName + ":" + error.lineNumber].concat(args));
  3512. } else {
  3513. test("global failure", extend(function () {
  3514. pushFailure.apply(void 0, [error.message, error.stacktrace || error.fileName + ":" + error.lineNumber].concat(args));
  3515. }, {
  3516. validTest: true
  3517. }));
  3518. }
  3519. return false;
  3520. }
  3521. function onUnhandledRejection(reason) {
  3522. var resultInfo = {
  3523. result: false,
  3524. message: reason.message || "error",
  3525. actual: reason,
  3526. source: reason.stack || sourceFromStacktrace(3)
  3527. };
  3528. var currentTest = config.current;
  3529. if (currentTest) {
  3530. currentTest.assert.pushResult(resultInfo);
  3531. } else {
  3532. test("global failure", extend(function (assert) {
  3533. assert.pushResult(resultInfo);
  3534. }, {
  3535. validTest: true
  3536. }));
  3537. }
  3538. }
  3539. var QUnit = {};
  3540. var globalSuite = new SuiteReport(); // The initial "currentModule" represents the global (or top-level) module that
  3541. // is not explicitly defined by the user, therefore we add the "globalSuite" to
  3542. // it since each module has a suiteReport associated with it.
  3543. config.currentModule.suiteReport = globalSuite;
  3544. var globalStartCalled = false;
  3545. var runStarted = false; // Figure out if we're running the tests from a server or not
  3546. QUnit.isLocal = window$1 && window$1.location && window$1.location.protocol === "file:"; // Expose the current QUnit version
  3547. QUnit.version = "2.13.0";
  3548. extend(QUnit, {
  3549. on: on,
  3550. module: module$1,
  3551. test: test,
  3552. // alias other test flavors for easy access
  3553. todo: test.todo,
  3554. skip: test.skip,
  3555. only: test.only,
  3556. start: function start(count) {
  3557. var globalStartAlreadyCalled = globalStartCalled;
  3558. if (!config.current) {
  3559. globalStartCalled = true;
  3560. if (runStarted) {
  3561. throw new Error("Called start() while test already started running");
  3562. } else if (globalStartAlreadyCalled || count > 1) {
  3563. throw new Error("Called start() outside of a test context too many times");
  3564. } else if (config.autostart) {
  3565. throw new Error("Called start() outside of a test context when " + "QUnit.config.autostart was true");
  3566. } else if (!config.pageLoaded) {
  3567. // The page isn't completely loaded yet, so we set autostart and then
  3568. // load if we're in Node or wait for the browser's load event.
  3569. config.autostart = true; // Starts from Node even if .load was not previously called. We still return
  3570. // early otherwise we'll wind up "beginning" twice.
  3571. if (!document$1) {
  3572. QUnit.load();
  3573. }
  3574. return;
  3575. }
  3576. } else {
  3577. throw new Error("QUnit.start cannot be called inside a test context.");
  3578. }
  3579. scheduleBegin();
  3580. },
  3581. config: config,
  3582. is: is,
  3583. objectType: objectType,
  3584. extend: function extend$1() {
  3585. Logger.warn("QUnit.extend is deprecated and will be removed in QUnit 3.0." + " Please use Object.assign instead."); // delegate to utility implementation, which does not warn and can be used elsewhere internally
  3586. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  3587. args[_key] = arguments[_key];
  3588. }
  3589. return extend.apply(this, args);
  3590. },
  3591. load: function load() {
  3592. config.pageLoaded = true; // Initialize the configuration options
  3593. extend(config, {
  3594. stats: {
  3595. all: 0,
  3596. bad: 0,
  3597. testCount: 0
  3598. },
  3599. started: 0,
  3600. updateRate: 1000,
  3601. autostart: true,
  3602. filter: ""
  3603. }, true);
  3604. if (!runStarted) {
  3605. config.blocking = false;
  3606. if (config.autostart) {
  3607. scheduleBegin();
  3608. }
  3609. }
  3610. },
  3611. stack: function stack(offset) {
  3612. offset = (offset || 0) + 2;
  3613. return sourceFromStacktrace(offset);
  3614. },
  3615. onError: onError,
  3616. onUnhandledRejection: onUnhandledRejection
  3617. });
  3618. QUnit.pushFailure = pushFailure;
  3619. QUnit.assert = Assert.prototype;
  3620. QUnit.equiv = equiv;
  3621. QUnit.dump = dump;
  3622. registerLoggingCallbacks(QUnit);
  3623. function scheduleBegin() {
  3624. runStarted = true; // Add a slight delay to allow definition of more modules and tests.
  3625. if (setTimeout$1) {
  3626. setTimeout$1(function () {
  3627. begin();
  3628. });
  3629. } else {
  3630. begin();
  3631. }
  3632. }
  3633. function unblockAndAdvanceQueue() {
  3634. config.blocking = false;
  3635. ProcessingQueue.advance();
  3636. }
  3637. function begin() {
  3638. var i,
  3639. l,
  3640. modulesLog = []; // If the test run hasn't officially begun yet
  3641. if (!config.started) {
  3642. // Record the time of the test run's beginning
  3643. config.started = now(); // Delete the loose unnamed module if unused.
  3644. if (config.modules[0].name === "" && config.modules[0].tests.length === 0) {
  3645. config.modules.shift();
  3646. } // Avoid unnecessary information by not logging modules' test environments
  3647. for (i = 0, l = config.modules.length; i < l; i++) {
  3648. modulesLog.push({
  3649. name: config.modules[i].name,
  3650. tests: config.modules[i].tests
  3651. });
  3652. } // The test run is officially beginning now
  3653. emit("runStart", globalSuite.start(true));
  3654. runLoggingCallbacks("begin", {
  3655. totalTests: Test.count,
  3656. modules: modulesLog
  3657. }).then(unblockAndAdvanceQueue);
  3658. } else {
  3659. unblockAndAdvanceQueue();
  3660. }
  3661. }
  3662. exportQUnit(QUnit);
  3663. (function () {
  3664. if (!window$1 || !document$1) {
  3665. return;
  3666. }
  3667. var config = QUnit.config,
  3668. hasOwn = Object.prototype.hasOwnProperty; // Stores fixture HTML for resetting later
  3669. function storeFixture() {
  3670. // Avoid overwriting user-defined values
  3671. if (hasOwn.call(config, "fixture")) {
  3672. return;
  3673. }
  3674. var fixture = document$1.getElementById("qunit-fixture");
  3675. if (fixture) {
  3676. config.fixture = fixture.cloneNode(true);
  3677. }
  3678. }
  3679. QUnit.begin(storeFixture); // Resets the fixture DOM element if available.
  3680. function resetFixture() {
  3681. if (config.fixture == null) {
  3682. return;
  3683. }
  3684. var fixture = document$1.getElementById("qunit-fixture");
  3685. var resetFixtureType = _typeof(config.fixture);
  3686. if (resetFixtureType === "string") {
  3687. // support user defined values for `config.fixture`
  3688. var newFixture = document$1.createElement("div");
  3689. newFixture.setAttribute("id", "qunit-fixture");
  3690. newFixture.innerHTML = config.fixture;
  3691. fixture.parentNode.replaceChild(newFixture, fixture);
  3692. } else {
  3693. var clonedFixture = config.fixture.cloneNode(true);
  3694. fixture.parentNode.replaceChild(clonedFixture, fixture);
  3695. }
  3696. }
  3697. QUnit.testStart(resetFixture);
  3698. })();
  3699. (function () {
  3700. // Only interact with URLs via window.location
  3701. var location = typeof window$1 !== "undefined" && window$1.location;
  3702. if (!location) {
  3703. return;
  3704. }
  3705. var urlParams = getUrlParams();
  3706. QUnit.urlParams = urlParams; // Match module/test by inclusion in an array
  3707. QUnit.config.moduleId = [].concat(urlParams.moduleId || []);
  3708. QUnit.config.testId = [].concat(urlParams.testId || []); // Exact case-insensitive match of the module name
  3709. QUnit.config.module = urlParams.module; // Regular expression or case-insenstive substring match against "moduleName: testName"
  3710. QUnit.config.filter = urlParams.filter; // Test order randomization
  3711. if (urlParams.seed === true) {
  3712. // Generate a random seed if the option is specified without a value
  3713. QUnit.config.seed = Math.random().toString(36).slice(2);
  3714. } else if (urlParams.seed) {
  3715. QUnit.config.seed = urlParams.seed;
  3716. } // Add URL-parameter-mapped config values with UI form rendering data
  3717. QUnit.config.urlConfig.push({
  3718. id: "hidepassed",
  3719. label: "Hide passed tests",
  3720. tooltip: "Only show tests and assertions that fail. Stored as query-strings."
  3721. }, {
  3722. id: "noglobals",
  3723. label: "Check for Globals",
  3724. tooltip: "Enabling this will test if any test introduces new properties on the " + "global object (`window` in Browsers). Stored as query-strings."
  3725. }, {
  3726. id: "notrycatch",
  3727. label: "No try-catch",
  3728. tooltip: "Enabling this will run tests outside of a try-catch block. Makes debugging " + "exceptions in IE reasonable. Stored as query-strings."
  3729. });
  3730. QUnit.begin(function () {
  3731. var i,
  3732. option,
  3733. urlConfig = QUnit.config.urlConfig;
  3734. for (i = 0; i < urlConfig.length; i++) {
  3735. // Options can be either strings or objects with nonempty "id" properties
  3736. option = QUnit.config.urlConfig[i];
  3737. if (typeof option !== "string") {
  3738. option = option.id;
  3739. }
  3740. if (QUnit.config[option] === undefined) {
  3741. QUnit.config[option] = urlParams[option];
  3742. }
  3743. }
  3744. });
  3745. function getUrlParams() {
  3746. var i, param, name, value;
  3747. var urlParams = Object.create(null);
  3748. var params = location.search.slice(1).split("&");
  3749. var length = params.length;
  3750. for (i = 0; i < length; i++) {
  3751. if (params[i]) {
  3752. param = params[i].split("=");
  3753. name = decodeQueryParam(param[0]); // Allow just a key to turn on a flag, e.g., test.html?noglobals
  3754. value = param.length === 1 || decodeQueryParam(param.slice(1).join("="));
  3755. if (name in urlParams) {
  3756. urlParams[name] = [].concat(urlParams[name], value);
  3757. } else {
  3758. urlParams[name] = value;
  3759. }
  3760. }
  3761. }
  3762. return urlParams;
  3763. }
  3764. function decodeQueryParam(param) {
  3765. return decodeURIComponent(param.replace(/\+/g, "%20"));
  3766. }
  3767. })();
  3768. var fuzzysort = createCommonjsModule(function (module) {
  3769. (function (root, UMD) {
  3770. if ( module.exports) module.exports = UMD();else root.fuzzysort = UMD();
  3771. })(commonjsGlobal, function UMD() {
  3772. function fuzzysortNew(instanceOptions) {
  3773. var fuzzysort = {
  3774. single: function (search, target, options) {
  3775. if (!search) return null;
  3776. if (!isObj(search)) search = fuzzysort.getPreparedSearch(search);
  3777. if (!target) return null;
  3778. if (!isObj(target)) target = fuzzysort.getPrepared(target);
  3779. var allowTypo = options && options.allowTypo !== undefined ? options.allowTypo : instanceOptions && instanceOptions.allowTypo !== undefined ? instanceOptions.allowTypo : true;
  3780. var algorithm = allowTypo ? fuzzysort.algorithm : fuzzysort.algorithmNoTypo;
  3781. return algorithm(search, target, search[0]); // var threshold = options && options.threshold || instanceOptions && instanceOptions.threshold || -9007199254740991
  3782. // var result = algorithm(search, target, search[0])
  3783. // if(result === null) return null
  3784. // if(result.score < threshold) return null
  3785. // return result
  3786. },
  3787. go: function (search, targets, options) {
  3788. if (!search) return noResults;
  3789. search = fuzzysort.prepareSearch(search);
  3790. var searchLowerCode = search[0];
  3791. var threshold = options && options.threshold || instanceOptions && instanceOptions.threshold || -9007199254740991;
  3792. var limit = options && options.limit || instanceOptions && instanceOptions.limit || 9007199254740991;
  3793. var allowTypo = options && options.allowTypo !== undefined ? options.allowTypo : instanceOptions && instanceOptions.allowTypo !== undefined ? instanceOptions.allowTypo : true;
  3794. var algorithm = allowTypo ? fuzzysort.algorithm : fuzzysort.algorithmNoTypo;
  3795. var resultsLen = 0;
  3796. var limitedCount = 0;
  3797. var targetsLen = targets.length; // This code is copy/pasted 3 times for performance reasons [options.keys, options.key, no keys]
  3798. // options.keys
  3799. if (options && options.keys) {
  3800. var scoreFn = options.scoreFn || defaultScoreFn;
  3801. var keys = options.keys;
  3802. var keysLen = keys.length;
  3803. for (var i = targetsLen - 1; i >= 0; --i) {
  3804. var obj = targets[i];
  3805. var objResults = new Array(keysLen);
  3806. for (var keyI = keysLen - 1; keyI >= 0; --keyI) {
  3807. var key = keys[keyI];
  3808. var target = getValue(obj, key);
  3809. if (!target) {
  3810. objResults[keyI] = null;
  3811. continue;
  3812. }
  3813. if (!isObj(target)) target = fuzzysort.getPrepared(target);
  3814. objResults[keyI] = algorithm(search, target, searchLowerCode);
  3815. }
  3816. objResults.obj = obj; // before scoreFn so scoreFn can use it
  3817. var score = scoreFn(objResults);
  3818. if (score === null) continue;
  3819. if (score < threshold) continue;
  3820. objResults.score = score;
  3821. if (resultsLen < limit) {
  3822. q.add(objResults);
  3823. ++resultsLen;
  3824. } else {
  3825. ++limitedCount;
  3826. if (score > q.peek().score) q.replaceTop(objResults);
  3827. }
  3828. } // options.key
  3829. } else if (options && options.key) {
  3830. var key = options.key;
  3831. for (var i = targetsLen - 1; i >= 0; --i) {
  3832. var obj = targets[i];
  3833. var target = getValue(obj, key);
  3834. if (!target) continue;
  3835. if (!isObj(target)) target = fuzzysort.getPrepared(target);
  3836. var result = algorithm(search, target, searchLowerCode);
  3837. if (result === null) continue;
  3838. if (result.score < threshold) continue; // have to clone result so duplicate targets from different obj can each reference the correct obj
  3839. result = {
  3840. target: result.target,
  3841. _targetLowerCodes: null,
  3842. _nextBeginningIndexes: null,
  3843. score: result.score,
  3844. indexes: result.indexes,
  3845. obj: obj
  3846. }; // hidden
  3847. if (resultsLen < limit) {
  3848. q.add(result);
  3849. ++resultsLen;
  3850. } else {
  3851. ++limitedCount;
  3852. if (result.score > q.peek().score) q.replaceTop(result);
  3853. }
  3854. } // no keys
  3855. } else {
  3856. for (var i = targetsLen - 1; i >= 0; --i) {
  3857. var target = targets[i];
  3858. if (!target) continue;
  3859. if (!isObj(target)) target = fuzzysort.getPrepared(target);
  3860. var result = algorithm(search, target, searchLowerCode);
  3861. if (result === null) continue;
  3862. if (result.score < threshold) continue;
  3863. if (resultsLen < limit) {
  3864. q.add(result);
  3865. ++resultsLen;
  3866. } else {
  3867. ++limitedCount;
  3868. if (result.score > q.peek().score) q.replaceTop(result);
  3869. }
  3870. }
  3871. }
  3872. if (resultsLen === 0) return noResults;
  3873. var results = new Array(resultsLen);
  3874. for (var i = resultsLen - 1; i >= 0; --i) results[i] = q.poll();
  3875. results.total = resultsLen + limitedCount;
  3876. return results;
  3877. },
  3878. goAsync: function (search, targets, options) {
  3879. var canceled = false;
  3880. var p = new Promise(function (resolve, reject) {
  3881. if (!search) return resolve(noResults);
  3882. search = fuzzysort.prepareSearch(search);
  3883. var searchLowerCode = search[0];
  3884. var q = fastpriorityqueue();
  3885. var iCurrent = targets.length - 1;
  3886. var threshold = options && options.threshold || instanceOptions && instanceOptions.threshold || -9007199254740991;
  3887. var limit = options && options.limit || instanceOptions && instanceOptions.limit || 9007199254740991;
  3888. var allowTypo = options && options.allowTypo !== undefined ? options.allowTypo : instanceOptions && instanceOptions.allowTypo !== undefined ? instanceOptions.allowTypo : true;
  3889. var algorithm = allowTypo ? fuzzysort.algorithm : fuzzysort.algorithmNoTypo;
  3890. var resultsLen = 0;
  3891. var limitedCount = 0;
  3892. function step() {
  3893. if (canceled) return reject('canceled');
  3894. var startMs = Date.now(); // This code is copy/pasted 3 times for performance reasons [options.keys, options.key, no keys]
  3895. // options.keys
  3896. if (options && options.keys) {
  3897. var scoreFn = options.scoreFn || defaultScoreFn;
  3898. var keys = options.keys;
  3899. var keysLen = keys.length;
  3900. for (; iCurrent >= 0; --iCurrent) {
  3901. var obj = targets[iCurrent];
  3902. var objResults = new Array(keysLen);
  3903. for (var keyI = keysLen - 1; keyI >= 0; --keyI) {
  3904. var key = keys[keyI];
  3905. var target = getValue(obj, key);
  3906. if (!target) {
  3907. objResults[keyI] = null;
  3908. continue;
  3909. }
  3910. if (!isObj(target)) target = fuzzysort.getPrepared(target);
  3911. objResults[keyI] = algorithm(search, target, searchLowerCode);
  3912. }
  3913. objResults.obj = obj; // before scoreFn so scoreFn can use it
  3914. var score = scoreFn(objResults);
  3915. if (score === null) continue;
  3916. if (score < threshold) continue;
  3917. objResults.score = score;
  3918. if (resultsLen < limit) {
  3919. q.add(objResults);
  3920. ++resultsLen;
  3921. } else {
  3922. ++limitedCount;
  3923. if (score > q.peek().score) q.replaceTop(objResults);
  3924. }
  3925. if (iCurrent % 1000
  3926. /*itemsPerCheck*/
  3927. === 0) {
  3928. if (Date.now() - startMs >= 10
  3929. /*asyncInterval*/
  3930. ) {
  3931. isNode ? setImmediate(step) : setTimeout(step);
  3932. return;
  3933. }
  3934. }
  3935. } // options.key
  3936. } else if (options && options.key) {
  3937. var key = options.key;
  3938. for (; iCurrent >= 0; --iCurrent) {
  3939. var obj = targets[iCurrent];
  3940. var target = getValue(obj, key);
  3941. if (!target) continue;
  3942. if (!isObj(target)) target = fuzzysort.getPrepared(target);
  3943. var result = algorithm(search, target, searchLowerCode);
  3944. if (result === null) continue;
  3945. if (result.score < threshold) continue; // have to clone result so duplicate targets from different obj can each reference the correct obj
  3946. result = {
  3947. target: result.target,
  3948. _targetLowerCodes: null,
  3949. _nextBeginningIndexes: null,
  3950. score: result.score,
  3951. indexes: result.indexes,
  3952. obj: obj
  3953. }; // hidden
  3954. if (resultsLen < limit) {
  3955. q.add(result);
  3956. ++resultsLen;
  3957. } else {
  3958. ++limitedCount;
  3959. if (result.score > q.peek().score) q.replaceTop(result);
  3960. }
  3961. if (iCurrent % 1000
  3962. /*itemsPerCheck*/
  3963. === 0) {
  3964. if (Date.now() - startMs >= 10
  3965. /*asyncInterval*/
  3966. ) {
  3967. isNode ? setImmediate(step) : setTimeout(step);
  3968. return;
  3969. }
  3970. }
  3971. } // no keys
  3972. } else {
  3973. for (; iCurrent >= 0; --iCurrent) {
  3974. var target = targets[iCurrent];
  3975. if (!target) continue;
  3976. if (!isObj(target)) target = fuzzysort.getPrepared(target);
  3977. var result = algorithm(search, target, searchLowerCode);
  3978. if (result === null) continue;
  3979. if (result.score < threshold) continue;
  3980. if (resultsLen < limit) {
  3981. q.add(result);
  3982. ++resultsLen;
  3983. } else {
  3984. ++limitedCount;
  3985. if (result.score > q.peek().score) q.replaceTop(result);
  3986. }
  3987. if (iCurrent % 1000
  3988. /*itemsPerCheck*/
  3989. === 0) {
  3990. if (Date.now() - startMs >= 10
  3991. /*asyncInterval*/
  3992. ) {
  3993. isNode ? setImmediate(step) : setTimeout(step);
  3994. return;
  3995. }
  3996. }
  3997. }
  3998. }
  3999. if (resultsLen === 0) return resolve(noResults);
  4000. var results = new Array(resultsLen);
  4001. for (var i = resultsLen - 1; i >= 0; --i) results[i] = q.poll();
  4002. results.total = resultsLen + limitedCount;
  4003. resolve(results);
  4004. }
  4005. isNode ? setImmediate(step) : step();
  4006. });
  4007. p.cancel = function () {
  4008. canceled = true;
  4009. };
  4010. return p;
  4011. },
  4012. highlight: function (result, hOpen, hClose) {
  4013. if (result === null) return null;
  4014. if (hOpen === undefined) hOpen = '<b>';
  4015. if (hClose === undefined) hClose = '</b>';
  4016. var highlighted = '';
  4017. var matchesIndex = 0;
  4018. var opened = false;
  4019. var target = result.target;
  4020. var targetLen = target.length;
  4021. var matchesBest = result.indexes;
  4022. for (var i = 0; i < targetLen; ++i) {
  4023. var char = target[i];
  4024. if (matchesBest[matchesIndex] === i) {
  4025. ++matchesIndex;
  4026. if (!opened) {
  4027. opened = true;
  4028. highlighted += hOpen;
  4029. }
  4030. if (matchesIndex === matchesBest.length) {
  4031. highlighted += char + hClose + target.substr(i + 1);
  4032. break;
  4033. }
  4034. } else {
  4035. if (opened) {
  4036. opened = false;
  4037. highlighted += hClose;
  4038. }
  4039. }
  4040. highlighted += char;
  4041. }
  4042. return highlighted;
  4043. },
  4044. prepare: function (target) {
  4045. if (!target) return;
  4046. return {
  4047. target: target,
  4048. _targetLowerCodes: fuzzysort.prepareLowerCodes(target),
  4049. _nextBeginningIndexes: null,
  4050. score: null,
  4051. indexes: null,
  4052. obj: null
  4053. }; // hidden
  4054. },
  4055. prepareSlow: function (target) {
  4056. if (!target) return;
  4057. return {
  4058. target: target,
  4059. _targetLowerCodes: fuzzysort.prepareLowerCodes(target),
  4060. _nextBeginningIndexes: fuzzysort.prepareNextBeginningIndexes(target),
  4061. score: null,
  4062. indexes: null,
  4063. obj: null
  4064. }; // hidden
  4065. },
  4066. prepareSearch: function (search) {
  4067. if (!search) return;
  4068. return fuzzysort.prepareLowerCodes(search);
  4069. },
  4070. // Below this point is only internal code
  4071. // Below this point is only internal code
  4072. // Below this point is only internal code
  4073. // Below this point is only internal code
  4074. getPrepared: function (target) {
  4075. if (target.length > 999) return fuzzysort.prepare(target); // don't cache huge targets
  4076. var targetPrepared = preparedCache.get(target);
  4077. if (targetPrepared !== undefined) return targetPrepared;
  4078. targetPrepared = fuzzysort.prepare(target);
  4079. preparedCache.set(target, targetPrepared);
  4080. return targetPrepared;
  4081. },
  4082. getPreparedSearch: function (search) {
  4083. if (search.length > 999) return fuzzysort.prepareSearch(search); // don't cache huge searches
  4084. var searchPrepared = preparedSearchCache.get(search);
  4085. if (searchPrepared !== undefined) return searchPrepared;
  4086. searchPrepared = fuzzysort.prepareSearch(search);
  4087. preparedSearchCache.set(search, searchPrepared);
  4088. return searchPrepared;
  4089. },
  4090. algorithm: function (searchLowerCodes, prepared, searchLowerCode) {
  4091. var targetLowerCodes = prepared._targetLowerCodes;
  4092. var searchLen = searchLowerCodes.length;
  4093. var targetLen = targetLowerCodes.length;
  4094. var searchI = 0; // where we at
  4095. var targetI = 0; // where you at
  4096. var typoSimpleI = 0;
  4097. var matchesSimpleLen = 0; // very basic fuzzy match; to remove non-matching targets ASAP!
  4098. // walk through target. find sequential matches.
  4099. // if all chars aren't found then exit
  4100. for (;;) {
  4101. var isMatch = searchLowerCode === targetLowerCodes[targetI];
  4102. if (isMatch) {
  4103. matchesSimple[matchesSimpleLen++] = targetI;
  4104. ++searchI;
  4105. if (searchI === searchLen) break;
  4106. searchLowerCode = searchLowerCodes[typoSimpleI === 0 ? searchI : typoSimpleI === searchI ? searchI + 1 : typoSimpleI === searchI - 1 ? searchI - 1 : searchI];
  4107. }
  4108. ++targetI;
  4109. if (targetI >= targetLen) {
  4110. // Failed to find searchI
  4111. // Check for typo or exit
  4112. // we go as far as possible before trying to transpose
  4113. // then we transpose backwards until we reach the beginning
  4114. for (;;) {
  4115. if (searchI <= 1) return null; // not allowed to transpose first char
  4116. if (typoSimpleI === 0) {
  4117. // we haven't tried to transpose yet
  4118. --searchI;
  4119. var searchLowerCodeNew = searchLowerCodes[searchI];
  4120. if (searchLowerCode === searchLowerCodeNew) continue; // doesn't make sense to transpose a repeat char
  4121. typoSimpleI = searchI;
  4122. } else {
  4123. if (typoSimpleI === 1) return null; // reached the end of the line for transposing
  4124. --typoSimpleI;
  4125. searchI = typoSimpleI;
  4126. searchLowerCode = searchLowerCodes[searchI + 1];
  4127. var searchLowerCodeNew = searchLowerCodes[searchI];
  4128. if (searchLowerCode === searchLowerCodeNew) continue; // doesn't make sense to transpose a repeat char
  4129. }
  4130. matchesSimpleLen = searchI;
  4131. targetI = matchesSimple[matchesSimpleLen - 1] + 1;
  4132. break;
  4133. }
  4134. }
  4135. }
  4136. var searchI = 0;
  4137. var typoStrictI = 0;
  4138. var successStrict = false;
  4139. var matchesStrictLen = 0;
  4140. var nextBeginningIndexes = prepared._nextBeginningIndexes;
  4141. if (nextBeginningIndexes === null) nextBeginningIndexes = prepared._nextBeginningIndexes = fuzzysort.prepareNextBeginningIndexes(prepared.target);
  4142. var firstPossibleI = targetI = matchesSimple[0] === 0 ? 0 : nextBeginningIndexes[matchesSimple[0] - 1]; // Our target string successfully matched all characters in sequence!
  4143. // Let's try a more advanced and strict test to improve the score
  4144. // only count it as a match if it's consecutive or a beginning character!
  4145. if (targetI !== targetLen) for (;;) {
  4146. if (targetI >= targetLen) {
  4147. // We failed to find a good spot for this search char, go back to the previous search char and force it forward
  4148. if (searchI <= 0) {
  4149. // We failed to push chars forward for a better match
  4150. // transpose, starting from the beginning
  4151. ++typoStrictI;
  4152. if (typoStrictI > searchLen - 2) break;
  4153. if (searchLowerCodes[typoStrictI] === searchLowerCodes[typoStrictI + 1]) continue; // doesn't make sense to transpose a repeat char
  4154. targetI = firstPossibleI;
  4155. continue;
  4156. }
  4157. --searchI;
  4158. var lastMatch = matchesStrict[--matchesStrictLen];
  4159. targetI = nextBeginningIndexes[lastMatch];
  4160. } else {
  4161. var isMatch = searchLowerCodes[typoStrictI === 0 ? searchI : typoStrictI === searchI ? searchI + 1 : typoStrictI === searchI - 1 ? searchI - 1 : searchI] === targetLowerCodes[targetI];
  4162. if (isMatch) {
  4163. matchesStrict[matchesStrictLen++] = targetI;
  4164. ++searchI;
  4165. if (searchI === searchLen) {
  4166. successStrict = true;
  4167. break;
  4168. }
  4169. ++targetI;
  4170. } else {
  4171. targetI = nextBeginningIndexes[targetI];
  4172. }
  4173. }
  4174. }
  4175. {
  4176. // tally up the score & keep track of matches for highlighting later
  4177. if (successStrict) {
  4178. var matchesBest = matchesStrict;
  4179. var matchesBestLen = matchesStrictLen;
  4180. } else {
  4181. var matchesBest = matchesSimple;
  4182. var matchesBestLen = matchesSimpleLen;
  4183. }
  4184. var score = 0;
  4185. var lastTargetI = -1;
  4186. for (var i = 0; i < searchLen; ++i) {
  4187. var targetI = matchesBest[i]; // score only goes down if they're not consecutive
  4188. if (lastTargetI !== targetI - 1) score -= targetI;
  4189. lastTargetI = targetI;
  4190. }
  4191. if (!successStrict) {
  4192. score *= 1000;
  4193. if (typoSimpleI !== 0) score += -20;
  4194. /*typoPenalty*/
  4195. } else {
  4196. if (typoStrictI !== 0) score += -20;
  4197. /*typoPenalty*/
  4198. }
  4199. score -= targetLen - searchLen;
  4200. prepared.score = score;
  4201. prepared.indexes = new Array(matchesBestLen);
  4202. for (var i = matchesBestLen - 1; i >= 0; --i) prepared.indexes[i] = matchesBest[i];
  4203. return prepared;
  4204. }
  4205. },
  4206. algorithmNoTypo: function (searchLowerCodes, prepared, searchLowerCode) {
  4207. var targetLowerCodes = prepared._targetLowerCodes;
  4208. var searchLen = searchLowerCodes.length;
  4209. var targetLen = targetLowerCodes.length;
  4210. var searchI = 0; // where we at
  4211. var targetI = 0; // where you at
  4212. var matchesSimpleLen = 0; // very basic fuzzy match; to remove non-matching targets ASAP!
  4213. // walk through target. find sequential matches.
  4214. // if all chars aren't found then exit
  4215. for (;;) {
  4216. var isMatch = searchLowerCode === targetLowerCodes[targetI];
  4217. if (isMatch) {
  4218. matchesSimple[matchesSimpleLen++] = targetI;
  4219. ++searchI;
  4220. if (searchI === searchLen) break;
  4221. searchLowerCode = searchLowerCodes[searchI];
  4222. }
  4223. ++targetI;
  4224. if (targetI >= targetLen) return null; // Failed to find searchI
  4225. }
  4226. var searchI = 0;
  4227. var successStrict = false;
  4228. var matchesStrictLen = 0;
  4229. var nextBeginningIndexes = prepared._nextBeginningIndexes;
  4230. if (nextBeginningIndexes === null) nextBeginningIndexes = prepared._nextBeginningIndexes = fuzzysort.prepareNextBeginningIndexes(prepared.target);
  4231. var firstPossibleI = targetI = matchesSimple[0] === 0 ? 0 : nextBeginningIndexes[matchesSimple[0] - 1]; // Our target string successfully matched all characters in sequence!
  4232. // Let's try a more advanced and strict test to improve the score
  4233. // only count it as a match if it's consecutive or a beginning character!
  4234. if (targetI !== targetLen) for (;;) {
  4235. if (targetI >= targetLen) {
  4236. // We failed to find a good spot for this search char, go back to the previous search char and force it forward
  4237. if (searchI <= 0) break; // We failed to push chars forward for a better match
  4238. --searchI;
  4239. var lastMatch = matchesStrict[--matchesStrictLen];
  4240. targetI = nextBeginningIndexes[lastMatch];
  4241. } else {
  4242. var isMatch = searchLowerCodes[searchI] === targetLowerCodes[targetI];
  4243. if (isMatch) {
  4244. matchesStrict[matchesStrictLen++] = targetI;
  4245. ++searchI;
  4246. if (searchI === searchLen) {
  4247. successStrict = true;
  4248. break;
  4249. }
  4250. ++targetI;
  4251. } else {
  4252. targetI = nextBeginningIndexes[targetI];
  4253. }
  4254. }
  4255. }
  4256. {
  4257. // tally up the score & keep track of matches for highlighting later
  4258. if (successStrict) {
  4259. var matchesBest = matchesStrict;
  4260. var matchesBestLen = matchesStrictLen;
  4261. } else {
  4262. var matchesBest = matchesSimple;
  4263. var matchesBestLen = matchesSimpleLen;
  4264. }
  4265. var score = 0;
  4266. var lastTargetI = -1;
  4267. for (var i = 0; i < searchLen; ++i) {
  4268. var targetI = matchesBest[i]; // score only goes down if they're not consecutive
  4269. if (lastTargetI !== targetI - 1) score -= targetI;
  4270. lastTargetI = targetI;
  4271. }
  4272. if (!successStrict) score *= 1000;
  4273. score -= targetLen - searchLen;
  4274. prepared.score = score;
  4275. prepared.indexes = new Array(matchesBestLen);
  4276. for (var i = matchesBestLen - 1; i >= 0; --i) prepared.indexes[i] = matchesBest[i];
  4277. return prepared;
  4278. }
  4279. },
  4280. prepareLowerCodes: function (str) {
  4281. var strLen = str.length;
  4282. var lowerCodes = []; // new Array(strLen) sparse array is too slow
  4283. var lower = str.toLowerCase();
  4284. for (var i = 0; i < strLen; ++i) lowerCodes[i] = lower.charCodeAt(i);
  4285. return lowerCodes;
  4286. },
  4287. prepareBeginningIndexes: function (target) {
  4288. var targetLen = target.length;
  4289. var beginningIndexes = [];
  4290. var beginningIndexesLen = 0;
  4291. var wasUpper = false;
  4292. var wasAlphanum = false;
  4293. for (var i = 0; i < targetLen; ++i) {
  4294. var targetCode = target.charCodeAt(i);
  4295. var isUpper = targetCode >= 65 && targetCode <= 90;
  4296. var isAlphanum = isUpper || targetCode >= 97 && targetCode <= 122 || targetCode >= 48 && targetCode <= 57;
  4297. var isBeginning = isUpper && !wasUpper || !wasAlphanum || !isAlphanum;
  4298. wasUpper = isUpper;
  4299. wasAlphanum = isAlphanum;
  4300. if (isBeginning) beginningIndexes[beginningIndexesLen++] = i;
  4301. }
  4302. return beginningIndexes;
  4303. },
  4304. prepareNextBeginningIndexes: function (target) {
  4305. var targetLen = target.length;
  4306. var beginningIndexes = fuzzysort.prepareBeginningIndexes(target);
  4307. var nextBeginningIndexes = []; // new Array(targetLen) sparse array is too slow
  4308. var lastIsBeginning = beginningIndexes[0];
  4309. var lastIsBeginningI = 0;
  4310. for (var i = 0; i < targetLen; ++i) {
  4311. if (lastIsBeginning > i) {
  4312. nextBeginningIndexes[i] = lastIsBeginning;
  4313. } else {
  4314. lastIsBeginning = beginningIndexes[++lastIsBeginningI];
  4315. nextBeginningIndexes[i] = lastIsBeginning === undefined ? targetLen : lastIsBeginning;
  4316. }
  4317. }
  4318. return nextBeginningIndexes;
  4319. },
  4320. cleanup: cleanup,
  4321. new: fuzzysortNew
  4322. };
  4323. return fuzzysort;
  4324. } // fuzzysortNew
  4325. // This stuff is outside fuzzysortNew, because it's shared with instances of fuzzysort.new()
  4326. var isNode = typeof commonjsRequire !== 'undefined' && typeof window === 'undefined'; // var MAX_INT = Number.MAX_SAFE_INTEGER
  4327. // var MIN_INT = Number.MIN_VALUE
  4328. var preparedCache = new Map();
  4329. var preparedSearchCache = new Map();
  4330. var noResults = [];
  4331. noResults.total = 0;
  4332. var matchesSimple = [];
  4333. var matchesStrict = [];
  4334. function cleanup() {
  4335. preparedCache.clear();
  4336. preparedSearchCache.clear();
  4337. matchesSimple = [];
  4338. matchesStrict = [];
  4339. }
  4340. function defaultScoreFn(a) {
  4341. var max = -9007199254740991;
  4342. for (var i = a.length - 1; i >= 0; --i) {
  4343. var result = a[i];
  4344. if (result === null) continue;
  4345. var score = result.score;
  4346. if (score > max) max = score;
  4347. }
  4348. if (max === -9007199254740991) return null;
  4349. return max;
  4350. } // prop = 'key' 2.5ms optimized for this case, seems to be about as fast as direct obj[prop]
  4351. // prop = 'key1.key2' 10ms
  4352. // prop = ['key1', 'key2'] 27ms
  4353. function getValue(obj, prop) {
  4354. var tmp = obj[prop];
  4355. if (tmp !== undefined) return tmp;
  4356. var segs = prop;
  4357. if (!Array.isArray(prop)) segs = prop.split('.');
  4358. var len = segs.length;
  4359. var i = -1;
  4360. while (obj && ++i < len) obj = obj[segs[i]];
  4361. return obj;
  4362. }
  4363. function isObj(x) {
  4364. return typeof x === 'object';
  4365. } // faster as a function
  4366. // Hacked version of https://github.com/lemire/FastPriorityQueue.js
  4367. var fastpriorityqueue = function () {
  4368. var r = [],
  4369. o = 0,
  4370. e = {};
  4371. function n() {
  4372. for (var e = 0, n = r[e], c = 1; c < o;) {
  4373. var f = c + 1;
  4374. e = c, f < o && r[f].score < r[c].score && (e = f), r[e - 1 >> 1] = r[e], c = 1 + (e << 1);
  4375. }
  4376. for (var a = e - 1 >> 1; e > 0 && n.score < r[a].score; a = (e = a) - 1 >> 1) r[e] = r[a];
  4377. r[e] = n;
  4378. }
  4379. return e.add = function (e) {
  4380. var n = o;
  4381. r[o++] = e;
  4382. for (var c = n - 1 >> 1; n > 0 && e.score < r[c].score; c = (n = c) - 1 >> 1) r[n] = r[c];
  4383. r[n] = e;
  4384. }, e.poll = function () {
  4385. if (0 !== o) {
  4386. var e = r[0];
  4387. return r[0] = r[--o], n(), e;
  4388. }
  4389. }, e.peek = function (e) {
  4390. if (0 !== o) return r[0];
  4391. }, e.replaceTop = function (o) {
  4392. r[0] = o, n();
  4393. }, e;
  4394. };
  4395. var q = fastpriorityqueue(); // reuse this, except for async, it needs to make its own
  4396. return fuzzysortNew();
  4397. }); // UMD
  4398. // TODO: (performance) wasm version!?
  4399. // TODO: (performance) layout memory in an optimal way to go fast by avoiding cache misses
  4400. // TODO: (performance) preparedCache is a memory leak
  4401. // TODO: (like sublime) backslash === forwardslash
  4402. // TODO: (performance) i have no idea how well optizmied the allowing typos algorithm is
  4403. });
  4404. var stats = {
  4405. passedTests: 0,
  4406. failedTests: 0,
  4407. skippedTests: 0,
  4408. todoTests: 0
  4409. }; // Escape text for attribute or text content.
  4410. function escapeText(s) {
  4411. if (!s) {
  4412. return "";
  4413. }
  4414. s = s + ""; // Both single quotes and double quotes (for attributes)
  4415. return s.replace(/['"<>&]/g, function (s) {
  4416. switch (s) {
  4417. case "'":
  4418. return "&#039;";
  4419. case "\"":
  4420. return "&quot;";
  4421. case "<":
  4422. return "&lt;";
  4423. case ">":
  4424. return "&gt;";
  4425. case "&":
  4426. return "&amp;";
  4427. }
  4428. });
  4429. }
  4430. (function () {
  4431. // Don't load the HTML Reporter on non-browser environments
  4432. if (!window$1 || !document$1) {
  4433. return;
  4434. }
  4435. var config = QUnit.config,
  4436. hiddenTests = [],
  4437. collapseNext = false,
  4438. hasOwn = Object.prototype.hasOwnProperty,
  4439. unfilteredUrl = setUrl({
  4440. filter: undefined,
  4441. module: undefined,
  4442. moduleId: undefined,
  4443. testId: undefined
  4444. });
  4445. function addEvent(elem, type, fn) {
  4446. elem.addEventListener(type, fn, false);
  4447. }
  4448. function removeEvent(elem, type, fn) {
  4449. elem.removeEventListener(type, fn, false);
  4450. }
  4451. function addEvents(elems, type, fn) {
  4452. var i = elems.length;
  4453. while (i--) {
  4454. addEvent(elems[i], type, fn);
  4455. }
  4456. }
  4457. function hasClass(elem, name) {
  4458. return (" " + elem.className + " ").indexOf(" " + name + " ") >= 0;
  4459. }
  4460. function addClass(elem, name) {
  4461. if (!hasClass(elem, name)) {
  4462. elem.className += (elem.className ? " " : "") + name;
  4463. }
  4464. }
  4465. function toggleClass(elem, name, force) {
  4466. if (force || typeof force === "undefined" && !hasClass(elem, name)) {
  4467. addClass(elem, name);
  4468. } else {
  4469. removeClass(elem, name);
  4470. }
  4471. }
  4472. function removeClass(elem, name) {
  4473. var set = " " + elem.className + " "; // Class name may appear multiple times
  4474. while (set.indexOf(" " + name + " ") >= 0) {
  4475. set = set.replace(" " + name + " ", " ");
  4476. } // Trim for prettiness
  4477. elem.className = typeof set.trim === "function" ? set.trim() : set.replace(/^\s+|\s+$/g, "");
  4478. }
  4479. function id(name) {
  4480. return document$1.getElementById && document$1.getElementById(name);
  4481. }
  4482. function abortTests() {
  4483. var abortButton = id("qunit-abort-tests-button");
  4484. if (abortButton) {
  4485. abortButton.disabled = true;
  4486. abortButton.innerHTML = "Aborting...";
  4487. }
  4488. QUnit.config.queue.length = 0;
  4489. return false;
  4490. }
  4491. function interceptNavigation(ev) {
  4492. applyUrlParams();
  4493. if (ev && ev.preventDefault) {
  4494. ev.preventDefault();
  4495. }
  4496. return false;
  4497. }
  4498. function getUrlConfigHtml() {
  4499. var i,
  4500. j,
  4501. val,
  4502. escaped,
  4503. escapedTooltip,
  4504. selection = false,
  4505. urlConfig = config.urlConfig,
  4506. urlConfigHtml = "";
  4507. for (i = 0; i < urlConfig.length; i++) {
  4508. // Options can be either strings or objects with nonempty "id" properties
  4509. val = config.urlConfig[i];
  4510. if (typeof val === "string") {
  4511. val = {
  4512. id: val,
  4513. label: val
  4514. };
  4515. }
  4516. escaped = escapeText(val.id);
  4517. escapedTooltip = escapeText(val.tooltip);
  4518. if (!val.value || typeof val.value === "string") {
  4519. urlConfigHtml += "<label for='qunit-urlconfig-" + escaped + "' title='" + escapedTooltip + "'><input id='qunit-urlconfig-" + escaped + "' name='" + escaped + "' type='checkbox'" + (val.value ? " value='" + escapeText(val.value) + "'" : "") + (config[val.id] ? " checked='checked'" : "") + " title='" + escapedTooltip + "' />" + escapeText(val.label) + "</label>";
  4520. } else {
  4521. urlConfigHtml += "<label for='qunit-urlconfig-" + escaped + "' title='" + escapedTooltip + "'>" + val.label + ": </label><select id='qunit-urlconfig-" + escaped + "' name='" + escaped + "' title='" + escapedTooltip + "'><option></option>";
  4522. if (QUnit.is("array", val.value)) {
  4523. for (j = 0; j < val.value.length; j++) {
  4524. escaped = escapeText(val.value[j]);
  4525. urlConfigHtml += "<option value='" + escaped + "'" + (config[val.id] === val.value[j] ? (selection = true) && " selected='selected'" : "") + ">" + escaped + "</option>";
  4526. }
  4527. } else {
  4528. for (j in val.value) {
  4529. if (hasOwn.call(val.value, j)) {
  4530. urlConfigHtml += "<option value='" + escapeText(j) + "'" + (config[val.id] === j ? (selection = true) && " selected='selected'" : "") + ">" + escapeText(val.value[j]) + "</option>";
  4531. }
  4532. }
  4533. }
  4534. if (config[val.id] && !selection) {
  4535. escaped = escapeText(config[val.id]);
  4536. urlConfigHtml += "<option value='" + escaped + "' selected='selected' disabled='disabled'>" + escaped + "</option>";
  4537. }
  4538. urlConfigHtml += "</select>";
  4539. }
  4540. }
  4541. return urlConfigHtml;
  4542. } // Handle "click" events on toolbar checkboxes and "change" for select menus.
  4543. // Updates the URL with the new state of `config.urlConfig` values.
  4544. function toolbarChanged() {
  4545. var updatedUrl,
  4546. value,
  4547. tests,
  4548. field = this,
  4549. params = {}; // Detect if field is a select menu or a checkbox
  4550. if ("selectedIndex" in field) {
  4551. value = field.options[field.selectedIndex].value || undefined;
  4552. } else {
  4553. value = field.checked ? field.defaultValue || true : undefined;
  4554. }
  4555. params[field.name] = value;
  4556. updatedUrl = setUrl(params); // Check if we can apply the change without a page refresh
  4557. if ("hidepassed" === field.name && "replaceState" in window$1.history) {
  4558. QUnit.urlParams[field.name] = value;
  4559. config[field.name] = value || false;
  4560. tests = id("qunit-tests");
  4561. if (tests) {
  4562. var length = tests.children.length;
  4563. var children = tests.children;
  4564. if (field.checked) {
  4565. for (var i = 0; i < length; i++) {
  4566. var test = children[i];
  4567. var className = test ? test.className : "";
  4568. var classNameHasPass = className.indexOf("pass") > -1;
  4569. var classNameHasSkipped = className.indexOf("skipped") > -1;
  4570. if (classNameHasPass || classNameHasSkipped) {
  4571. hiddenTests.push(test);
  4572. }
  4573. }
  4574. var _iterator = _createForOfIteratorHelper(hiddenTests),
  4575. _step;
  4576. try {
  4577. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  4578. var hiddenTest = _step.value;
  4579. tests.removeChild(hiddenTest);
  4580. }
  4581. } catch (err) {
  4582. _iterator.e(err);
  4583. } finally {
  4584. _iterator.f();
  4585. }
  4586. } else {
  4587. while ((test = hiddenTests.pop()) != null) {
  4588. tests.appendChild(test);
  4589. }
  4590. }
  4591. }
  4592. window$1.history.replaceState(null, "", updatedUrl);
  4593. } else {
  4594. window$1.location = updatedUrl;
  4595. }
  4596. }
  4597. function setUrl(params) {
  4598. var key,
  4599. arrValue,
  4600. i,
  4601. querystring = "?",
  4602. location = window$1.location;
  4603. params = extend(extend({}, QUnit.urlParams), params);
  4604. for (key in params) {
  4605. // Skip inherited or undefined properties
  4606. if (hasOwn.call(params, key) && params[key] !== undefined) {
  4607. // Output a parameter for each value of this key
  4608. // (but usually just one)
  4609. arrValue = [].concat(params[key]);
  4610. for (i = 0; i < arrValue.length; i++) {
  4611. querystring += encodeURIComponent(key);
  4612. if (arrValue[i] !== true) {
  4613. querystring += "=" + encodeURIComponent(arrValue[i]);
  4614. }
  4615. querystring += "&";
  4616. }
  4617. }
  4618. }
  4619. return location.protocol + "//" + location.host + location.pathname + querystring.slice(0, -1);
  4620. }
  4621. function applyUrlParams() {
  4622. var i,
  4623. selectedModules = [],
  4624. modulesList = id("qunit-modulefilter-dropdown-list").getElementsByTagName("input"),
  4625. filter = id("qunit-filter-input").value;
  4626. for (i = 0; i < modulesList.length; i++) {
  4627. if (modulesList[i].checked) {
  4628. selectedModules.push(modulesList[i].value);
  4629. }
  4630. }
  4631. window$1.location = setUrl({
  4632. filter: filter === "" ? undefined : filter,
  4633. moduleId: selectedModules.length === 0 ? undefined : selectedModules,
  4634. // Remove module and testId filter
  4635. module: undefined,
  4636. testId: undefined
  4637. });
  4638. }
  4639. function toolbarUrlConfigContainer() {
  4640. var urlConfigContainer = document$1.createElement("span");
  4641. urlConfigContainer.innerHTML = getUrlConfigHtml();
  4642. addClass(urlConfigContainer, "qunit-url-config");
  4643. addEvents(urlConfigContainer.getElementsByTagName("input"), "change", toolbarChanged);
  4644. addEvents(urlConfigContainer.getElementsByTagName("select"), "change", toolbarChanged);
  4645. return urlConfigContainer;
  4646. }
  4647. function abortTestsButton() {
  4648. var button = document$1.createElement("button");
  4649. button.id = "qunit-abort-tests-button";
  4650. button.innerHTML = "Abort";
  4651. addEvent(button, "click", abortTests);
  4652. return button;
  4653. }
  4654. function toolbarLooseFilter() {
  4655. var filter = document$1.createElement("form"),
  4656. label = document$1.createElement("label"),
  4657. input = document$1.createElement("input"),
  4658. button = document$1.createElement("button");
  4659. addClass(filter, "qunit-filter");
  4660. label.innerHTML = "Filter: ";
  4661. input.type = "text";
  4662. input.value = config.filter || "";
  4663. input.name = "filter";
  4664. input.id = "qunit-filter-input";
  4665. button.innerHTML = "Go";
  4666. label.appendChild(input);
  4667. filter.appendChild(label);
  4668. filter.appendChild(document$1.createTextNode(" "));
  4669. filter.appendChild(button);
  4670. addEvent(filter, "submit", interceptNavigation);
  4671. return filter;
  4672. }
  4673. function moduleListHtml(modules) {
  4674. var i,
  4675. checked,
  4676. html = "";
  4677. for (i = 0; i < modules.length; i++) {
  4678. if (modules[i].name !== "") {
  4679. checked = config.moduleId.indexOf(modules[i].moduleId) > -1;
  4680. html += "<li><label class='clickable" + (checked ? " checked" : "") + "'><input type='checkbox' " + "value='" + modules[i].moduleId + "'" + (checked ? " checked='checked'" : "") + " />" + escapeText(modules[i].name) + "</label></li>";
  4681. }
  4682. }
  4683. return html;
  4684. }
  4685. function toolbarModuleFilter() {
  4686. var commit,
  4687. reset,
  4688. moduleFilter = document$1.createElement("form"),
  4689. label = document$1.createElement("label"),
  4690. moduleSearch = document$1.createElement("input"),
  4691. dropDown = document$1.createElement("div"),
  4692. actions = document$1.createElement("span"),
  4693. applyButton = document$1.createElement("button"),
  4694. resetButton = document$1.createElement("button"),
  4695. allModulesLabel = document$1.createElement("label"),
  4696. allCheckbox = document$1.createElement("input"),
  4697. dropDownList = document$1.createElement("ul"),
  4698. dirty = false;
  4699. moduleSearch.id = "qunit-modulefilter-search";
  4700. moduleSearch.autocomplete = "off";
  4701. addEvent(moduleSearch, "input", searchInput);
  4702. addEvent(moduleSearch, "input", searchFocus);
  4703. addEvent(moduleSearch, "focus", searchFocus);
  4704. addEvent(moduleSearch, "click", searchFocus);
  4705. config.modules.forEach(function (module) {
  4706. return module.namePrepared = fuzzysort.prepare(module.name);
  4707. });
  4708. label.id = "qunit-modulefilter-search-container";
  4709. label.innerHTML = "Module: ";
  4710. label.appendChild(moduleSearch);
  4711. applyButton.textContent = "Apply";
  4712. applyButton.style.display = "none";
  4713. resetButton.textContent = "Reset";
  4714. resetButton.type = "reset";
  4715. resetButton.style.display = "none";
  4716. allCheckbox.type = "checkbox";
  4717. allCheckbox.checked = config.moduleId.length === 0;
  4718. allModulesLabel.className = "clickable";
  4719. if (config.moduleId.length) {
  4720. allModulesLabel.className = "checked";
  4721. }
  4722. allModulesLabel.appendChild(allCheckbox);
  4723. allModulesLabel.appendChild(document$1.createTextNode("All modules"));
  4724. actions.id = "qunit-modulefilter-actions";
  4725. actions.appendChild(applyButton);
  4726. actions.appendChild(resetButton);
  4727. actions.appendChild(allModulesLabel);
  4728. commit = actions.firstChild;
  4729. reset = commit.nextSibling;
  4730. addEvent(commit, "click", applyUrlParams);
  4731. dropDownList.id = "qunit-modulefilter-dropdown-list";
  4732. dropDownList.innerHTML = moduleListHtml(config.modules);
  4733. dropDown.id = "qunit-modulefilter-dropdown";
  4734. dropDown.style.display = "none";
  4735. dropDown.appendChild(actions);
  4736. dropDown.appendChild(dropDownList);
  4737. addEvent(dropDown, "change", selectionChange);
  4738. selectionChange();
  4739. moduleFilter.id = "qunit-modulefilter";
  4740. moduleFilter.appendChild(label);
  4741. moduleFilter.appendChild(dropDown);
  4742. addEvent(moduleFilter, "submit", interceptNavigation);
  4743. addEvent(moduleFilter, "reset", function () {
  4744. // Let the reset happen, then update styles
  4745. window$1.setTimeout(selectionChange);
  4746. }); // Enables show/hide for the dropdown
  4747. function searchFocus() {
  4748. if (dropDown.style.display !== "none") {
  4749. return;
  4750. }
  4751. dropDown.style.display = "block";
  4752. addEvent(document$1, "click", hideHandler);
  4753. addEvent(document$1, "keydown", hideHandler); // Hide on Escape keydown or outside-container click
  4754. function hideHandler(e) {
  4755. var inContainer = moduleFilter.contains(e.target);
  4756. if (e.keyCode === 27 || !inContainer) {
  4757. if (e.keyCode === 27 && inContainer) {
  4758. moduleSearch.focus();
  4759. }
  4760. dropDown.style.display = "none";
  4761. removeEvent(document$1, "click", hideHandler);
  4762. removeEvent(document$1, "keydown", hideHandler);
  4763. moduleSearch.value = "";
  4764. searchInput();
  4765. }
  4766. }
  4767. }
  4768. function filterModules(searchText) {
  4769. if (searchText === "") {
  4770. return config.modules;
  4771. }
  4772. return fuzzysort.go(searchText, config.modules, {
  4773. key: "namePrepared",
  4774. threshold: -10000
  4775. }).map(function (module) {
  4776. return module.obj;
  4777. });
  4778. } // Processes module search box input
  4779. var searchInputTimeout;
  4780. function searchInput() {
  4781. window$1.clearTimeout(searchInputTimeout);
  4782. searchInputTimeout = window$1.setTimeout(function () {
  4783. var searchText = moduleSearch.value.toLowerCase(),
  4784. filteredModules = filterModules(searchText);
  4785. dropDownList.innerHTML = moduleListHtml(filteredModules);
  4786. }, 200);
  4787. } // Processes selection changes
  4788. function selectionChange(evt) {
  4789. var i,
  4790. item,
  4791. checkbox = evt && evt.target || allCheckbox,
  4792. modulesList = dropDownList.getElementsByTagName("input"),
  4793. selectedNames = [];
  4794. toggleClass(checkbox.parentNode, "checked", checkbox.checked);
  4795. dirty = false;
  4796. if (checkbox.checked && checkbox !== allCheckbox) {
  4797. allCheckbox.checked = false;
  4798. removeClass(allCheckbox.parentNode, "checked");
  4799. }
  4800. for (i = 0; i < modulesList.length; i++) {
  4801. item = modulesList[i];
  4802. if (!evt) {
  4803. toggleClass(item.parentNode, "checked", item.checked);
  4804. } else if (checkbox === allCheckbox && checkbox.checked) {
  4805. item.checked = false;
  4806. removeClass(item.parentNode, "checked");
  4807. }
  4808. dirty = dirty || item.checked !== item.defaultChecked;
  4809. if (item.checked) {
  4810. selectedNames.push(item.parentNode.textContent);
  4811. }
  4812. }
  4813. commit.style.display = reset.style.display = dirty ? "" : "none";
  4814. moduleSearch.placeholder = selectedNames.join(", ") || allCheckbox.parentNode.textContent;
  4815. moduleSearch.title = "Type to filter list. Current selection:\n" + (selectedNames.join("\n") || allCheckbox.parentNode.textContent);
  4816. }
  4817. return moduleFilter;
  4818. }
  4819. function toolbarFilters() {
  4820. var toolbarFilters = document$1.createElement("span");
  4821. toolbarFilters.id = "qunit-toolbar-filters";
  4822. toolbarFilters.appendChild(toolbarLooseFilter());
  4823. toolbarFilters.appendChild(toolbarModuleFilter());
  4824. return toolbarFilters;
  4825. }
  4826. function appendToolbar() {
  4827. var toolbar = id("qunit-testrunner-toolbar");
  4828. if (toolbar) {
  4829. toolbar.appendChild(toolbarUrlConfigContainer());
  4830. toolbar.appendChild(toolbarFilters());
  4831. toolbar.appendChild(document$1.createElement("div")).className = "clearfix";
  4832. }
  4833. }
  4834. function appendHeader() {
  4835. var header = id("qunit-header");
  4836. if (header) {
  4837. header.innerHTML = "<a href='" + escapeText(unfilteredUrl) + "'>" + header.innerHTML + "</a> ";
  4838. }
  4839. }
  4840. function appendBanner() {
  4841. var banner = id("qunit-banner");
  4842. if (banner) {
  4843. banner.className = "";
  4844. }
  4845. }
  4846. function appendTestResults() {
  4847. var tests = id("qunit-tests"),
  4848. result = id("qunit-testresult"),
  4849. controls;
  4850. if (result) {
  4851. result.parentNode.removeChild(result);
  4852. }
  4853. if (tests) {
  4854. tests.innerHTML = "";
  4855. result = document$1.createElement("p");
  4856. result.id = "qunit-testresult";
  4857. result.className = "result";
  4858. tests.parentNode.insertBefore(result, tests);
  4859. result.innerHTML = "<div id=\"qunit-testresult-display\">Running...<br />&#160;</div>" + "<div id=\"qunit-testresult-controls\"></div>" + "<div class=\"clearfix\"></div>";
  4860. controls = id("qunit-testresult-controls");
  4861. }
  4862. if (controls) {
  4863. controls.appendChild(abortTestsButton());
  4864. }
  4865. }
  4866. function appendFilteredTest() {
  4867. var testId = QUnit.config.testId;
  4868. if (!testId || testId.length <= 0) {
  4869. return "";
  4870. }
  4871. return "<div id='qunit-filteredTest'>Rerunning selected tests: " + escapeText(testId.join(", ")) + " <a id='qunit-clearFilter' href='" + escapeText(unfilteredUrl) + "'>Run all tests</a></div>";
  4872. }
  4873. function appendUserAgent() {
  4874. var userAgent = id("qunit-userAgent");
  4875. if (userAgent) {
  4876. userAgent.innerHTML = "";
  4877. userAgent.appendChild(document$1.createTextNode("QUnit " + QUnit.version + "; " + navigator.userAgent));
  4878. }
  4879. }
  4880. function appendInterface() {
  4881. var qunit = id("qunit"); // For compat with QUnit 1.2, and to support fully custom theme HTML,
  4882. // we will use any existing elements if no id="qunit" element exists.
  4883. //
  4884. // Note that we don't fail or fallback to creating it ourselves,
  4885. // because not having id="qunit" (and not having the below elements)
  4886. // simply means QUnit acts headless, allowing users to use their own
  4887. // reporters, or for a test runner to listen for events directly without
  4888. // having the HTML reporter actively render anything.
  4889. if (qunit) {
  4890. // Since QUnit 1.3, these are created automatically if the page
  4891. // contains id="qunit".
  4892. qunit.innerHTML = "<h1 id='qunit-header'>" + escapeText(document$1.title) + "</h1>" + "<h2 id='qunit-banner'></h2>" + "<div id='qunit-testrunner-toolbar'></div>" + appendFilteredTest() + "<h2 id='qunit-userAgent'></h2>" + "<ol id='qunit-tests'></ol>";
  4893. }
  4894. appendHeader();
  4895. appendBanner();
  4896. appendTestResults();
  4897. appendUserAgent();
  4898. appendToolbar();
  4899. }
  4900. function appendTest(name, testId, moduleName) {
  4901. var title,
  4902. rerunTrigger,
  4903. testBlock,
  4904. assertList,
  4905. tests = id("qunit-tests");
  4906. if (!tests) {
  4907. return;
  4908. }
  4909. title = document$1.createElement("strong");
  4910. title.innerHTML = getNameHtml(name, moduleName);
  4911. rerunTrigger = document$1.createElement("a");
  4912. rerunTrigger.innerHTML = "Rerun";
  4913. rerunTrigger.href = setUrl({
  4914. testId: testId
  4915. });
  4916. testBlock = document$1.createElement("li");
  4917. testBlock.appendChild(title);
  4918. testBlock.appendChild(rerunTrigger);
  4919. testBlock.id = "qunit-test-output-" + testId;
  4920. assertList = document$1.createElement("ol");
  4921. assertList.className = "qunit-assert-list";
  4922. testBlock.appendChild(assertList);
  4923. tests.appendChild(testBlock);
  4924. } // HTML Reporter initialization and load
  4925. QUnit.begin(function () {
  4926. // Initialize QUnit elements
  4927. appendInterface();
  4928. });
  4929. QUnit.done(function (details) {
  4930. var banner = id("qunit-banner"),
  4931. tests = id("qunit-tests"),
  4932. abortButton = id("qunit-abort-tests-button"),
  4933. totalTests = stats.passedTests + stats.skippedTests + stats.todoTests + stats.failedTests,
  4934. html = [totalTests, " tests completed in ", details.runtime, " milliseconds, with ", stats.failedTests, " failed, ", stats.skippedTests, " skipped, and ", stats.todoTests, " todo.<br />", "<span class='passed'>", details.passed, "</span> assertions of <span class='total'>", details.total, "</span> passed, <span class='failed'>", details.failed, "</span> failed."].join(""),
  4935. test,
  4936. assertLi,
  4937. assertList; // Update remaining tests to aborted
  4938. if (abortButton && abortButton.disabled) {
  4939. html = "Tests aborted after " + details.runtime + " milliseconds.";
  4940. for (var i = 0; i < tests.children.length; i++) {
  4941. test = tests.children[i];
  4942. if (test.className === "" || test.className === "running") {
  4943. test.className = "aborted";
  4944. assertList = test.getElementsByTagName("ol")[0];
  4945. assertLi = document$1.createElement("li");
  4946. assertLi.className = "fail";
  4947. assertLi.innerHTML = "Test aborted.";
  4948. assertList.appendChild(assertLi);
  4949. }
  4950. }
  4951. }
  4952. if (banner && (!abortButton || abortButton.disabled === false)) {
  4953. banner.className = stats.failedTests ? "qunit-fail" : "qunit-pass";
  4954. }
  4955. if (abortButton) {
  4956. abortButton.parentNode.removeChild(abortButton);
  4957. }
  4958. if (tests) {
  4959. id("qunit-testresult-display").innerHTML = html;
  4960. }
  4961. if (config.altertitle && document$1.title) {
  4962. // Show ✖ for good, ✔ for bad suite result in title
  4963. // use escape sequences in case file gets loaded with non-utf-8
  4964. // charset
  4965. document$1.title = [stats.failedTests ? "\u2716" : "\u2714", document$1.title.replace(/^[\u2714\u2716] /i, "")].join(" ");
  4966. } // Scroll back to top to show results
  4967. if (config.scrolltop && window$1.scrollTo) {
  4968. window$1.scrollTo(0, 0);
  4969. }
  4970. });
  4971. function getNameHtml(name, module) {
  4972. var nameHtml = "";
  4973. if (module) {
  4974. nameHtml = "<span class='module-name'>" + escapeText(module) + "</span>: ";
  4975. }
  4976. nameHtml += "<span class='test-name'>" + escapeText(name) + "</span>";
  4977. return nameHtml;
  4978. }
  4979. function getProgressHtml(runtime, stats, total) {
  4980. var completed = stats.passedTests + stats.skippedTests + stats.todoTests + stats.failedTests;
  4981. return ["<br />", completed, " / ", total, " tests completed in ", runtime, " milliseconds, with ", stats.failedTests, " failed, ", stats.skippedTests, " skipped, and ", stats.todoTests, " todo."].join("");
  4982. }
  4983. QUnit.testStart(function (details) {
  4984. var running, bad;
  4985. appendTest(details.name, details.testId, details.module);
  4986. running = id("qunit-testresult-display");
  4987. if (running) {
  4988. addClass(running, "running");
  4989. bad = QUnit.config.reorder && details.previousFailure;
  4990. running.innerHTML = [bad ? "Rerunning previously failed test: <br />" : "Running: <br />", getNameHtml(details.name, details.module), getProgressHtml(now() - config.started, stats, Test.count)].join("");
  4991. }
  4992. });
  4993. function stripHtml(string) {
  4994. // Strip tags, html entity and whitespaces
  4995. return string.replace(/<\/?[^>]+(>|$)/g, "").replace(/&quot;/g, "").replace(/\s+/g, "");
  4996. }
  4997. QUnit.log(function (details) {
  4998. var assertList,
  4999. assertLi,
  5000. message,
  5001. expected,
  5002. actual,
  5003. diff,
  5004. showDiff = false,
  5005. testItem = id("qunit-test-output-" + details.testId);
  5006. if (!testItem) {
  5007. return;
  5008. }
  5009. message = escapeText(details.message) || (details.result ? "okay" : "failed");
  5010. message = "<span class='test-message'>" + message + "</span>";
  5011. message += "<span class='runtime'>@ " + details.runtime + " ms</span>"; // The pushFailure doesn't provide details.expected
  5012. // when it calls, it's implicit to also not show expected and diff stuff
  5013. // Also, we need to check details.expected existence, as it can exist and be undefined
  5014. if (!details.result && hasOwn.call(details, "expected")) {
  5015. if (details.negative) {
  5016. expected = "NOT " + QUnit.dump.parse(details.expected);
  5017. } else {
  5018. expected = QUnit.dump.parse(details.expected);
  5019. }
  5020. actual = QUnit.dump.parse(details.actual);
  5021. message += "<table><tr class='test-expected'><th>Expected: </th><td><pre>" + escapeText(expected) + "</pre></td></tr>";
  5022. if (actual !== expected) {
  5023. message += "<tr class='test-actual'><th>Result: </th><td><pre>" + escapeText(actual) + "</pre></td></tr>";
  5024. if (typeof details.actual === "number" && typeof details.expected === "number") {
  5025. if (!isNaN(details.actual) && !isNaN(details.expected)) {
  5026. showDiff = true;
  5027. diff = details.actual - details.expected;
  5028. diff = (diff > 0 ? "+" : "") + diff;
  5029. }
  5030. } else if (typeof details.actual !== "boolean" && typeof details.expected !== "boolean") {
  5031. diff = QUnit.diff(expected, actual); // don't show diff if there is zero overlap
  5032. showDiff = stripHtml(diff).length !== stripHtml(expected).length + stripHtml(actual).length;
  5033. }
  5034. if (showDiff) {
  5035. message += "<tr class='test-diff'><th>Diff: </th><td><pre>" + diff + "</pre></td></tr>";
  5036. }
  5037. } else if (expected.indexOf("[object Array]") !== -1 || expected.indexOf("[object Object]") !== -1) {
  5038. message += "<tr class='test-message'><th>Message: </th><td>" + "Diff suppressed as the depth of object is more than current max depth (" + QUnit.config.maxDepth + ").<p>Hint: Use <code>QUnit.dump.maxDepth</code> to " + " run with a higher max depth or <a href='" + escapeText(setUrl({
  5039. maxDepth: -1
  5040. })) + "'>" + "Rerun</a> without max depth.</p></td></tr>";
  5041. } else {
  5042. message += "<tr class='test-message'><th>Message: </th><td>" + "Diff suppressed as the expected and actual results have an equivalent" + " serialization</td></tr>";
  5043. }
  5044. if (details.source) {
  5045. message += "<tr class='test-source'><th>Source: </th><td><pre>" + escapeText(details.source) + "</pre></td></tr>";
  5046. }
  5047. message += "</table>"; // This occurs when pushFailure is set and we have an extracted stack trace
  5048. } else if (!details.result && details.source) {
  5049. message += "<table>" + "<tr class='test-source'><th>Source: </th><td><pre>" + escapeText(details.source) + "</pre></td></tr>" + "</table>";
  5050. }
  5051. assertList = testItem.getElementsByTagName("ol")[0];
  5052. assertLi = document$1.createElement("li");
  5053. assertLi.className = details.result ? "pass" : "fail";
  5054. assertLi.innerHTML = message;
  5055. assertList.appendChild(assertLi);
  5056. });
  5057. QUnit.testDone(function (details) {
  5058. var testTitle,
  5059. time,
  5060. testItem,
  5061. assertList,
  5062. status,
  5063. good,
  5064. bad,
  5065. testCounts,
  5066. skipped,
  5067. sourceName,
  5068. tests = id("qunit-tests");
  5069. if (!tests) {
  5070. return;
  5071. }
  5072. testItem = id("qunit-test-output-" + details.testId);
  5073. removeClass(testItem, "running");
  5074. if (details.failed > 0) {
  5075. status = "failed";
  5076. } else if (details.todo) {
  5077. status = "todo";
  5078. } else {
  5079. status = details.skipped ? "skipped" : "passed";
  5080. }
  5081. assertList = testItem.getElementsByTagName("ol")[0];
  5082. good = details.passed;
  5083. bad = details.failed; // This test passed if it has no unexpected failed assertions
  5084. var testPassed = details.failed > 0 ? details.todo : !details.todo;
  5085. if (testPassed) {
  5086. // Collapse the passing tests
  5087. addClass(assertList, "qunit-collapsed");
  5088. } else if (config.collapse) {
  5089. if (!collapseNext) {
  5090. // Skip collapsing the first failing test
  5091. collapseNext = true;
  5092. } else {
  5093. // Collapse remaining tests
  5094. addClass(assertList, "qunit-collapsed");
  5095. }
  5096. } // The testItem.firstChild is the test name
  5097. testTitle = testItem.firstChild;
  5098. testCounts = bad ? "<b class='failed'>" + bad + "</b>, " + "<b class='passed'>" + good + "</b>, " : "";
  5099. testTitle.innerHTML += " <b class='counts'>(" + testCounts + details.assertions.length + ")</b>";
  5100. if (details.skipped) {
  5101. stats.skippedTests++;
  5102. testItem.className = "skipped";
  5103. skipped = document$1.createElement("em");
  5104. skipped.className = "qunit-skipped-label";
  5105. skipped.innerHTML = "skipped";
  5106. testItem.insertBefore(skipped, testTitle);
  5107. } else {
  5108. addEvent(testTitle, "click", function () {
  5109. toggleClass(assertList, "qunit-collapsed");
  5110. });
  5111. testItem.className = testPassed ? "pass" : "fail";
  5112. if (details.todo) {
  5113. var todoLabel = document$1.createElement("em");
  5114. todoLabel.className = "qunit-todo-label";
  5115. todoLabel.innerHTML = "todo";
  5116. testItem.className += " todo";
  5117. testItem.insertBefore(todoLabel, testTitle);
  5118. }
  5119. time = document$1.createElement("span");
  5120. time.className = "runtime";
  5121. time.innerHTML = details.runtime + " ms";
  5122. testItem.insertBefore(time, assertList);
  5123. if (!testPassed) {
  5124. stats.failedTests++;
  5125. } else if (details.todo) {
  5126. stats.todoTests++;
  5127. } else {
  5128. stats.passedTests++;
  5129. }
  5130. } // Show the source of the test when showing assertions
  5131. if (details.source) {
  5132. sourceName = document$1.createElement("p");
  5133. sourceName.innerHTML = "<strong>Source: </strong>" + escapeText(details.source);
  5134. addClass(sourceName, "qunit-source");
  5135. if (testPassed) {
  5136. addClass(sourceName, "qunit-collapsed");
  5137. }
  5138. addEvent(testTitle, "click", function () {
  5139. toggleClass(sourceName, "qunit-collapsed");
  5140. });
  5141. testItem.appendChild(sourceName);
  5142. }
  5143. if (config.hidepassed && (status === "passed" || details.skipped)) {
  5144. // use removeChild instead of remove because of support
  5145. hiddenTests.push(testItem);
  5146. tests.removeChild(testItem);
  5147. }
  5148. }); // Avoid readyState issue with phantomjs
  5149. // Ref: #818
  5150. var usingPhantom = function (p) {
  5151. return p && p.version && p.version.major > 0;
  5152. }(window$1.phantom);
  5153. if (usingPhantom) {
  5154. console.warn("Support for PhantomJS is deprecated and will be removed in QUnit 3.0.");
  5155. }
  5156. if (!usingPhantom && document$1.readyState === "complete") {
  5157. QUnit.load();
  5158. } else {
  5159. addEvent(window$1, "load", QUnit.load);
  5160. } // Wrap window.onerror. We will call the original window.onerror to see if
  5161. // the existing handler fully handles the error; if not, we will call the
  5162. // QUnit.onError function.
  5163. var originalWindowOnError = window$1.onerror; // Cover uncaught exceptions
  5164. // Returning true will suppress the default browser handler,
  5165. // returning false will let it run.
  5166. window$1.onerror = function (message, fileName, lineNumber, columnNumber, errorObj) {
  5167. var ret = false;
  5168. if (originalWindowOnError) {
  5169. for (var _len = arguments.length, args = new Array(_len > 5 ? _len - 5 : 0), _key = 5; _key < _len; _key++) {
  5170. args[_key - 5] = arguments[_key];
  5171. }
  5172. ret = originalWindowOnError.call.apply(originalWindowOnError, [this, message, fileName, lineNumber, columnNumber, errorObj].concat(args));
  5173. } // Treat return value as window.onerror itself does,
  5174. // Only do our handling if not suppressed.
  5175. if (ret !== true) {
  5176. var error = {
  5177. message: message,
  5178. fileName: fileName,
  5179. lineNumber: lineNumber
  5180. }; // According to
  5181. // https://blog.sentry.io/2016/01/04/client-javascript-reporting-window-onerror,
  5182. // most modern browsers support an errorObj argument; use that to
  5183. // get a full stack trace if it's available.
  5184. if (errorObj && errorObj.stack) {
  5185. error.stacktrace = extractStacktrace(errorObj, 0);
  5186. }
  5187. ret = QUnit.onError(error);
  5188. }
  5189. return ret;
  5190. }; // Listen for unhandled rejections, and call QUnit.onUnhandledRejection
  5191. window$1.addEventListener("unhandledrejection", function (event) {
  5192. QUnit.onUnhandledRejection(event.reason);
  5193. });
  5194. })();
  5195. /*
  5196. * This file is a modified version of google-diff-match-patch's JavaScript implementation
  5197. * (https://code.google.com/p/google-diff-match-patch/source/browse/trunk/javascript/diff_match_patch_uncompressed.js),
  5198. * modifications are licensed as more fully set forth in LICENSE.txt.
  5199. *
  5200. * The original source of google-diff-match-patch is attributable and licensed as follows:
  5201. *
  5202. * Copyright 2006 Google Inc.
  5203. * https://code.google.com/p/google-diff-match-patch/
  5204. *
  5205. * Licensed under the Apache License, Version 2.0 (the "License");
  5206. * you may not use this file except in compliance with the License.
  5207. * You may obtain a copy of the License at
  5208. *
  5209. * https://www.apache.org/licenses/LICENSE-2.0
  5210. *
  5211. * Unless required by applicable law or agreed to in writing, software
  5212. * distributed under the License is distributed on an "AS IS" BASIS,
  5213. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  5214. * See the License for the specific language governing permissions and
  5215. * limitations under the License.
  5216. *
  5217. * More Info:
  5218. * https://code.google.com/p/google-diff-match-patch/
  5219. *
  5220. * Usage: QUnit.diff(expected, actual)
  5221. *
  5222. */
  5223. QUnit.diff = function () {
  5224. function DiffMatchPatch() {} // DIFF FUNCTIONS
  5225. /**
  5226. * The data structure representing a diff is an array of tuples:
  5227. * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
  5228. * which means: delete 'Hello', add 'Goodbye' and keep ' world.'
  5229. */
  5230. var DIFF_DELETE = -1,
  5231. DIFF_INSERT = 1,
  5232. DIFF_EQUAL = 0,
  5233. hasOwn = Object.prototype.hasOwnProperty;
  5234. /**
  5235. * Find the differences between two texts. Simplifies the problem by stripping
  5236. * any common prefix or suffix off the texts before diffing.
  5237. * @param {string} text1 Old string to be diffed.
  5238. * @param {string} text2 New string to be diffed.
  5239. * @param {boolean=} optChecklines Optional speedup flag. If present and false,
  5240. * then don't run a line-level diff first to identify the changed areas.
  5241. * Defaults to true, which does a faster, slightly less optimal diff.
  5242. * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
  5243. */
  5244. DiffMatchPatch.prototype.DiffMain = function (text1, text2, optChecklines) {
  5245. var deadline, checklines, commonlength, commonprefix, commonsuffix, diffs; // The diff must be complete in up to 1 second.
  5246. deadline = new Date().getTime() + 1000; // Check for null inputs.
  5247. if (text1 === null || text2 === null) {
  5248. throw new Error("Null input. (DiffMain)");
  5249. } // Check for equality (speedup).
  5250. if (text1 === text2) {
  5251. if (text1) {
  5252. return [[DIFF_EQUAL, text1]];
  5253. }
  5254. return [];
  5255. }
  5256. if (typeof optChecklines === "undefined") {
  5257. optChecklines = true;
  5258. }
  5259. checklines = optChecklines; // Trim off common prefix (speedup).
  5260. commonlength = this.diffCommonPrefix(text1, text2);
  5261. commonprefix = text1.substring(0, commonlength);
  5262. text1 = text1.substring(commonlength);
  5263. text2 = text2.substring(commonlength); // Trim off common suffix (speedup).
  5264. commonlength = this.diffCommonSuffix(text1, text2);
  5265. commonsuffix = text1.substring(text1.length - commonlength);
  5266. text1 = text1.substring(0, text1.length - commonlength);
  5267. text2 = text2.substring(0, text2.length - commonlength); // Compute the diff on the middle block.
  5268. diffs = this.diffCompute(text1, text2, checklines, deadline); // Restore the prefix and suffix.
  5269. if (commonprefix) {
  5270. diffs.unshift([DIFF_EQUAL, commonprefix]);
  5271. }
  5272. if (commonsuffix) {
  5273. diffs.push([DIFF_EQUAL, commonsuffix]);
  5274. }
  5275. this.diffCleanupMerge(diffs);
  5276. return diffs;
  5277. };
  5278. /**
  5279. * Reduce the number of edits by eliminating operationally trivial equalities.
  5280. * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
  5281. */
  5282. DiffMatchPatch.prototype.diffCleanupEfficiency = function (diffs) {
  5283. var changes, equalities, equalitiesLength, lastequality, pointer, preIns, preDel, postIns, postDel;
  5284. changes = false;
  5285. equalities = []; // Stack of indices where equalities are found.
  5286. equalitiesLength = 0; // Keeping our own length var is faster in JS.
  5287. /** @type {?string} */
  5288. lastequality = null; // Always equal to diffs[equalities[equalitiesLength - 1]][1]
  5289. pointer = 0; // Index of current position.
  5290. // Is there an insertion operation before the last equality.
  5291. preIns = false; // Is there a deletion operation before the last equality.
  5292. preDel = false; // Is there an insertion operation after the last equality.
  5293. postIns = false; // Is there a deletion operation after the last equality.
  5294. postDel = false;
  5295. while (pointer < diffs.length) {
  5296. // Equality found.
  5297. if (diffs[pointer][0] === DIFF_EQUAL) {
  5298. if (diffs[pointer][1].length < 4 && (postIns || postDel)) {
  5299. // Candidate found.
  5300. equalities[equalitiesLength++] = pointer;
  5301. preIns = postIns;
  5302. preDel = postDel;
  5303. lastequality = diffs[pointer][1];
  5304. } else {
  5305. // Not a candidate, and can never become one.
  5306. equalitiesLength = 0;
  5307. lastequality = null;
  5308. }
  5309. postIns = postDel = false; // An insertion or deletion.
  5310. } else {
  5311. if (diffs[pointer][0] === DIFF_DELETE) {
  5312. postDel = true;
  5313. } else {
  5314. postIns = true;
  5315. }
  5316. /*
  5317. * Five types to be split:
  5318. * <ins>A</ins><del>B</del>XY<ins>C</ins><del>D</del>
  5319. * <ins>A</ins>X<ins>C</ins><del>D</del>
  5320. * <ins>A</ins><del>B</del>X<ins>C</ins>
  5321. * <ins>A</del>X<ins>C</ins><del>D</del>
  5322. * <ins>A</ins><del>B</del>X<del>C</del>
  5323. */
  5324. if (lastequality && (preIns && preDel && postIns && postDel || lastequality.length < 2 && preIns + preDel + postIns + postDel === 3)) {
  5325. // Duplicate record.
  5326. diffs.splice(equalities[equalitiesLength - 1], 0, [DIFF_DELETE, lastequality]); // Change second copy to insert.
  5327. diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT;
  5328. equalitiesLength--; // Throw away the equality we just deleted;
  5329. lastequality = null;
  5330. if (preIns && preDel) {
  5331. // No changes made which could affect previous entry, keep going.
  5332. postIns = postDel = true;
  5333. equalitiesLength = 0;
  5334. } else {
  5335. equalitiesLength--; // Throw away the previous equality.
  5336. pointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1;
  5337. postIns = postDel = false;
  5338. }
  5339. changes = true;
  5340. }
  5341. }
  5342. pointer++;
  5343. }
  5344. if (changes) {
  5345. this.diffCleanupMerge(diffs);
  5346. }
  5347. };
  5348. /**
  5349. * Convert a diff array into a pretty HTML report.
  5350. * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
  5351. * @param {integer} string to be beautified.
  5352. * @return {string} HTML representation.
  5353. */
  5354. DiffMatchPatch.prototype.diffPrettyHtml = function (diffs) {
  5355. var op,
  5356. data,
  5357. x,
  5358. html = [];
  5359. for (x = 0; x < diffs.length; x++) {
  5360. op = diffs[x][0]; // Operation (insert, delete, equal)
  5361. data = diffs[x][1]; // Text of change.
  5362. switch (op) {
  5363. case DIFF_INSERT:
  5364. html[x] = "<ins>" + escapeText(data) + "</ins>";
  5365. break;
  5366. case DIFF_DELETE:
  5367. html[x] = "<del>" + escapeText(data) + "</del>";
  5368. break;
  5369. case DIFF_EQUAL:
  5370. html[x] = "<span>" + escapeText(data) + "</span>";
  5371. break;
  5372. }
  5373. }
  5374. return html.join("");
  5375. };
  5376. /**
  5377. * Determine the common prefix of two strings.
  5378. * @param {string} text1 First string.
  5379. * @param {string} text2 Second string.
  5380. * @return {number} The number of characters common to the start of each
  5381. * string.
  5382. */
  5383. DiffMatchPatch.prototype.diffCommonPrefix = function (text1, text2) {
  5384. var pointermid, pointermax, pointermin, pointerstart; // Quick check for common null cases.
  5385. if (!text1 || !text2 || text1.charAt(0) !== text2.charAt(0)) {
  5386. return 0;
  5387. } // Binary search.
  5388. // Performance analysis: https://neil.fraser.name/news/2007/10/09/
  5389. pointermin = 0;
  5390. pointermax = Math.min(text1.length, text2.length);
  5391. pointermid = pointermax;
  5392. pointerstart = 0;
  5393. while (pointermin < pointermid) {
  5394. if (text1.substring(pointerstart, pointermid) === text2.substring(pointerstart, pointermid)) {
  5395. pointermin = pointermid;
  5396. pointerstart = pointermin;
  5397. } else {
  5398. pointermax = pointermid;
  5399. }
  5400. pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
  5401. }
  5402. return pointermid;
  5403. };
  5404. /**
  5405. * Determine the common suffix of two strings.
  5406. * @param {string} text1 First string.
  5407. * @param {string} text2 Second string.
  5408. * @return {number} The number of characters common to the end of each string.
  5409. */
  5410. DiffMatchPatch.prototype.diffCommonSuffix = function (text1, text2) {
  5411. var pointermid, pointermax, pointermin, pointerend; // Quick check for common null cases.
  5412. if (!text1 || !text2 || text1.charAt(text1.length - 1) !== text2.charAt(text2.length - 1)) {
  5413. return 0;
  5414. } // Binary search.
  5415. // Performance analysis: https://neil.fraser.name/news/2007/10/09/
  5416. pointermin = 0;
  5417. pointermax = Math.min(text1.length, text2.length);
  5418. pointermid = pointermax;
  5419. pointerend = 0;
  5420. while (pointermin < pointermid) {
  5421. if (text1.substring(text1.length - pointermid, text1.length - pointerend) === text2.substring(text2.length - pointermid, text2.length - pointerend)) {
  5422. pointermin = pointermid;
  5423. pointerend = pointermin;
  5424. } else {
  5425. pointermax = pointermid;
  5426. }
  5427. pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
  5428. }
  5429. return pointermid;
  5430. };
  5431. /**
  5432. * Find the differences between two texts. Assumes that the texts do not
  5433. * have any common prefix or suffix.
  5434. * @param {string} text1 Old string to be diffed.
  5435. * @param {string} text2 New string to be diffed.
  5436. * @param {boolean} checklines Speedup flag. If false, then don't run a
  5437. * line-level diff first to identify the changed areas.
  5438. * If true, then run a faster, slightly less optimal diff.
  5439. * @param {number} deadline Time when the diff should be complete by.
  5440. * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
  5441. * @private
  5442. */
  5443. DiffMatchPatch.prototype.diffCompute = function (text1, text2, checklines, deadline) {
  5444. var diffs, longtext, shorttext, i, hm, text1A, text2A, text1B, text2B, midCommon, diffsA, diffsB;
  5445. if (!text1) {
  5446. // Just add some text (speedup).
  5447. return [[DIFF_INSERT, text2]];
  5448. }
  5449. if (!text2) {
  5450. // Just delete some text (speedup).
  5451. return [[DIFF_DELETE, text1]];
  5452. }
  5453. longtext = text1.length > text2.length ? text1 : text2;
  5454. shorttext = text1.length > text2.length ? text2 : text1;
  5455. i = longtext.indexOf(shorttext);
  5456. if (i !== -1) {
  5457. // Shorter text is inside the longer text (speedup).
  5458. 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.
  5459. if (text1.length > text2.length) {
  5460. diffs[0][0] = diffs[2][0] = DIFF_DELETE;
  5461. }
  5462. return diffs;
  5463. }
  5464. if (shorttext.length === 1) {
  5465. // Single character string.
  5466. // After the previous speedup, the character can't be an equality.
  5467. return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
  5468. } // Check to see if the problem can be split in two.
  5469. hm = this.diffHalfMatch(text1, text2);
  5470. if (hm) {
  5471. // A half-match was found, sort out the return data.
  5472. text1A = hm[0];
  5473. text1B = hm[1];
  5474. text2A = hm[2];
  5475. text2B = hm[3];
  5476. midCommon = hm[4]; // Send both pairs off for separate processing.
  5477. diffsA = this.DiffMain(text1A, text2A, checklines, deadline);
  5478. diffsB = this.DiffMain(text1B, text2B, checklines, deadline); // Merge the results.
  5479. return diffsA.concat([[DIFF_EQUAL, midCommon]], diffsB);
  5480. }
  5481. if (checklines && text1.length > 100 && text2.length > 100) {
  5482. return this.diffLineMode(text1, text2, deadline);
  5483. }
  5484. return this.diffBisect(text1, text2, deadline);
  5485. };
  5486. /**
  5487. * Do the two texts share a substring which is at least half the length of the
  5488. * longer text?
  5489. * This speedup can produce non-minimal diffs.
  5490. * @param {string} text1 First string.
  5491. * @param {string} text2 Second string.
  5492. * @return {Array.<string>} Five element Array, containing the prefix of
  5493. * text1, the suffix of text1, the prefix of text2, the suffix of
  5494. * text2 and the common middle. Or null if there was no match.
  5495. * @private
  5496. */
  5497. DiffMatchPatch.prototype.diffHalfMatch = function (text1, text2) {
  5498. var longtext, shorttext, dmp, text1A, text2B, text2A, text1B, midCommon, hm1, hm2, hm;
  5499. longtext = text1.length > text2.length ? text1 : text2;
  5500. shorttext = text1.length > text2.length ? text2 : text1;
  5501. if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
  5502. return null; // Pointless.
  5503. }
  5504. dmp = this; // 'this' becomes 'window' in a closure.
  5505. /**
  5506. * Does a substring of shorttext exist within longtext such that the substring
  5507. * is at least half the length of longtext?
  5508. * Closure, but does not reference any external variables.
  5509. * @param {string} longtext Longer string.
  5510. * @param {string} shorttext Shorter string.
  5511. * @param {number} i Start index of quarter length substring within longtext.
  5512. * @return {Array.<string>} Five element Array, containing the prefix of
  5513. * longtext, the suffix of longtext, the prefix of shorttext, the suffix
  5514. * of shorttext and the common middle. Or null if there was no match.
  5515. * @private
  5516. */
  5517. function diffHalfMatchI(longtext, shorttext, i) {
  5518. var seed, j, bestCommon, prefixLength, suffixLength, bestLongtextA, bestLongtextB, bestShorttextA, bestShorttextB; // Start with a 1/4 length substring at position i as a seed.
  5519. seed = longtext.substring(i, i + Math.floor(longtext.length / 4));
  5520. j = -1;
  5521. bestCommon = "";
  5522. while ((j = shorttext.indexOf(seed, j + 1)) !== -1) {
  5523. prefixLength = dmp.diffCommonPrefix(longtext.substring(i), shorttext.substring(j));
  5524. suffixLength = dmp.diffCommonSuffix(longtext.substring(0, i), shorttext.substring(0, j));
  5525. if (bestCommon.length < suffixLength + prefixLength) {
  5526. bestCommon = shorttext.substring(j - suffixLength, j) + shorttext.substring(j, j + prefixLength);
  5527. bestLongtextA = longtext.substring(0, i - suffixLength);
  5528. bestLongtextB = longtext.substring(i + prefixLength);
  5529. bestShorttextA = shorttext.substring(0, j - suffixLength);
  5530. bestShorttextB = shorttext.substring(j + prefixLength);
  5531. }
  5532. }
  5533. if (bestCommon.length * 2 >= longtext.length) {
  5534. return [bestLongtextA, bestLongtextB, bestShorttextA, bestShorttextB, bestCommon];
  5535. } else {
  5536. return null;
  5537. }
  5538. } // First check if the second quarter is the seed for a half-match.
  5539. hm1 = diffHalfMatchI(longtext, shorttext, Math.ceil(longtext.length / 4)); // Check again based on the third quarter.
  5540. hm2 = diffHalfMatchI(longtext, shorttext, Math.ceil(longtext.length / 2));
  5541. if (!hm1 && !hm2) {
  5542. return null;
  5543. } else if (!hm2) {
  5544. hm = hm1;
  5545. } else if (!hm1) {
  5546. hm = hm2;
  5547. } else {
  5548. // Both matched. Select the longest.
  5549. hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
  5550. } // A half-match was found, sort out the return data.
  5551. if (text1.length > text2.length) {
  5552. text1A = hm[0];
  5553. text1B = hm[1];
  5554. text2A = hm[2];
  5555. text2B = hm[3];
  5556. } else {
  5557. text2A = hm[0];
  5558. text2B = hm[1];
  5559. text1A = hm[2];
  5560. text1B = hm[3];
  5561. }
  5562. midCommon = hm[4];
  5563. return [text1A, text1B, text2A, text2B, midCommon];
  5564. };
  5565. /**
  5566. * Do a quick line-level diff on both strings, then rediff the parts for
  5567. * greater accuracy.
  5568. * This speedup can produce non-minimal diffs.
  5569. * @param {string} text1 Old string to be diffed.
  5570. * @param {string} text2 New string to be diffed.
  5571. * @param {number} deadline Time when the diff should be complete by.
  5572. * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
  5573. * @private
  5574. */
  5575. DiffMatchPatch.prototype.diffLineMode = function (text1, text2, deadline) {
  5576. var a, diffs, linearray, pointer, countInsert, countDelete, textInsert, textDelete, j; // Scan the text on a line-by-line basis first.
  5577. a = this.diffLinesToChars(text1, text2);
  5578. text1 = a.chars1;
  5579. text2 = a.chars2;
  5580. linearray = a.lineArray;
  5581. diffs = this.DiffMain(text1, text2, false, deadline); // Convert the diff back to original text.
  5582. this.diffCharsToLines(diffs, linearray); // Eliminate freak matches (e.g. blank lines)
  5583. this.diffCleanupSemantic(diffs); // Rediff any replacement blocks, this time character-by-character.
  5584. // Add a dummy entry at the end.
  5585. diffs.push([DIFF_EQUAL, ""]);
  5586. pointer = 0;
  5587. countDelete = 0;
  5588. countInsert = 0;
  5589. textDelete = "";
  5590. textInsert = "";
  5591. while (pointer < diffs.length) {
  5592. switch (diffs[pointer][0]) {
  5593. case DIFF_INSERT:
  5594. countInsert++;
  5595. textInsert += diffs[pointer][1];
  5596. break;
  5597. case DIFF_DELETE:
  5598. countDelete++;
  5599. textDelete += diffs[pointer][1];
  5600. break;
  5601. case DIFF_EQUAL:
  5602. // Upon reaching an equality, check for prior redundancies.
  5603. if (countDelete >= 1 && countInsert >= 1) {
  5604. // Delete the offending records and add the merged ones.
  5605. diffs.splice(pointer - countDelete - countInsert, countDelete + countInsert);
  5606. pointer = pointer - countDelete - countInsert;
  5607. a = this.DiffMain(textDelete, textInsert, false, deadline);
  5608. for (j = a.length - 1; j >= 0; j--) {
  5609. diffs.splice(pointer, 0, a[j]);
  5610. }
  5611. pointer = pointer + a.length;
  5612. }
  5613. countInsert = 0;
  5614. countDelete = 0;
  5615. textDelete = "";
  5616. textInsert = "";
  5617. break;
  5618. }
  5619. pointer++;
  5620. }
  5621. diffs.pop(); // Remove the dummy entry at the end.
  5622. return diffs;
  5623. };
  5624. /**
  5625. * Find the 'middle snake' of a diff, split the problem in two
  5626. * and return the recursively constructed diff.
  5627. * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
  5628. * @param {string} text1 Old string to be diffed.
  5629. * @param {string} text2 New string to be diffed.
  5630. * @param {number} deadline Time at which to bail if not yet complete.
  5631. * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
  5632. * @private
  5633. */
  5634. DiffMatchPatch.prototype.diffBisect = function (text1, text2, deadline) {
  5635. 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.
  5636. text1Length = text1.length;
  5637. text2Length = text2.length;
  5638. maxD = Math.ceil((text1Length + text2Length) / 2);
  5639. vOffset = maxD;
  5640. vLength = 2 * maxD;
  5641. v1 = new Array(vLength);
  5642. v2 = new Array(vLength); // Setting all elements to -1 is faster in Chrome & Firefox than mixing
  5643. // integers and undefined.
  5644. for (x = 0; x < vLength; x++) {
  5645. v1[x] = -1;
  5646. v2[x] = -1;
  5647. }
  5648. v1[vOffset + 1] = 0;
  5649. v2[vOffset + 1] = 0;
  5650. delta = text1Length - text2Length; // If the total number of characters is odd, then the front path will collide
  5651. // with the reverse path.
  5652. front = delta % 2 !== 0; // Offsets for start and end of k loop.
  5653. // Prevents mapping of space beyond the grid.
  5654. k1start = 0;
  5655. k1end = 0;
  5656. k2start = 0;
  5657. k2end = 0;
  5658. for (d = 0; d < maxD; d++) {
  5659. // Bail out if deadline is reached.
  5660. if (new Date().getTime() > deadline) {
  5661. break;
  5662. } // Walk the front path one step.
  5663. for (k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
  5664. k1Offset = vOffset + k1;
  5665. if (k1 === -d || k1 !== d && v1[k1Offset - 1] < v1[k1Offset + 1]) {
  5666. x1 = v1[k1Offset + 1];
  5667. } else {
  5668. x1 = v1[k1Offset - 1] + 1;
  5669. }
  5670. y1 = x1 - k1;
  5671. while (x1 < text1Length && y1 < text2Length && text1.charAt(x1) === text2.charAt(y1)) {
  5672. x1++;
  5673. y1++;
  5674. }
  5675. v1[k1Offset] = x1;
  5676. if (x1 > text1Length) {
  5677. // Ran off the right of the graph.
  5678. k1end += 2;
  5679. } else if (y1 > text2Length) {
  5680. // Ran off the bottom of the graph.
  5681. k1start += 2;
  5682. } else if (front) {
  5683. k2Offset = vOffset + delta - k1;
  5684. if (k2Offset >= 0 && k2Offset < vLength && v2[k2Offset] !== -1) {
  5685. // Mirror x2 onto top-left coordinate system.
  5686. x2 = text1Length - v2[k2Offset];
  5687. if (x1 >= x2) {
  5688. // Overlap detected.
  5689. return this.diffBisectSplit(text1, text2, x1, y1, deadline);
  5690. }
  5691. }
  5692. }
  5693. } // Walk the reverse path one step.
  5694. for (k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
  5695. k2Offset = vOffset + k2;
  5696. if (k2 === -d || k2 !== d && v2[k2Offset - 1] < v2[k2Offset + 1]) {
  5697. x2 = v2[k2Offset + 1];
  5698. } else {
  5699. x2 = v2[k2Offset - 1] + 1;
  5700. }
  5701. y2 = x2 - k2;
  5702. while (x2 < text1Length && y2 < text2Length && text1.charAt(text1Length - x2 - 1) === text2.charAt(text2Length - y2 - 1)) {
  5703. x2++;
  5704. y2++;
  5705. }
  5706. v2[k2Offset] = x2;
  5707. if (x2 > text1Length) {
  5708. // Ran off the left of the graph.
  5709. k2end += 2;
  5710. } else if (y2 > text2Length) {
  5711. // Ran off the top of the graph.
  5712. k2start += 2;
  5713. } else if (!front) {
  5714. k1Offset = vOffset + delta - k2;
  5715. if (k1Offset >= 0 && k1Offset < vLength && v1[k1Offset] !== -1) {
  5716. x1 = v1[k1Offset];
  5717. y1 = vOffset + x1 - k1Offset; // Mirror x2 onto top-left coordinate system.
  5718. x2 = text1Length - x2;
  5719. if (x1 >= x2) {
  5720. // Overlap detected.
  5721. return this.diffBisectSplit(text1, text2, x1, y1, deadline);
  5722. }
  5723. }
  5724. }
  5725. }
  5726. } // Diff took too long and hit the deadline or
  5727. // number of diffs equals number of characters, no commonality at all.
  5728. return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]];
  5729. };
  5730. /**
  5731. * Given the location of the 'middle snake', split the diff in two parts
  5732. * and recurse.
  5733. * @param {string} text1 Old string to be diffed.
  5734. * @param {string} text2 New string to be diffed.
  5735. * @param {number} x Index of split point in text1.
  5736. * @param {number} y Index of split point in text2.
  5737. * @param {number} deadline Time at which to bail if not yet complete.
  5738. * @return {!Array.<!DiffMatchPatch.Diff>} Array of diff tuples.
  5739. * @private
  5740. */
  5741. DiffMatchPatch.prototype.diffBisectSplit = function (text1, text2, x, y, deadline) {
  5742. var text1a, text1b, text2a, text2b, diffs, diffsb;
  5743. text1a = text1.substring(0, x);
  5744. text2a = text2.substring(0, y);
  5745. text1b = text1.substring(x);
  5746. text2b = text2.substring(y); // Compute both diffs serially.
  5747. diffs = this.DiffMain(text1a, text2a, false, deadline);
  5748. diffsb = this.DiffMain(text1b, text2b, false, deadline);
  5749. return diffs.concat(diffsb);
  5750. };
  5751. /**
  5752. * Reduce the number of edits by eliminating semantically trivial equalities.
  5753. * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
  5754. */
  5755. DiffMatchPatch.prototype.diffCleanupSemantic = function (diffs) {
  5756. var changes, equalities, equalitiesLength, lastequality, pointer, lengthInsertions2, lengthDeletions2, lengthInsertions1, lengthDeletions1, deletion, insertion, overlapLength1, overlapLength2;
  5757. changes = false;
  5758. equalities = []; // Stack of indices where equalities are found.
  5759. equalitiesLength = 0; // Keeping our own length var is faster in JS.
  5760. /** @type {?string} */
  5761. lastequality = null; // Always equal to diffs[equalities[equalitiesLength - 1]][1]
  5762. pointer = 0; // Index of current position.
  5763. // Number of characters that changed prior to the equality.
  5764. lengthInsertions1 = 0;
  5765. lengthDeletions1 = 0; // Number of characters that changed after the equality.
  5766. lengthInsertions2 = 0;
  5767. lengthDeletions2 = 0;
  5768. while (pointer < diffs.length) {
  5769. if (diffs[pointer][0] === DIFF_EQUAL) {
  5770. // Equality found.
  5771. equalities[equalitiesLength++] = pointer;
  5772. lengthInsertions1 = lengthInsertions2;
  5773. lengthDeletions1 = lengthDeletions2;
  5774. lengthInsertions2 = 0;
  5775. lengthDeletions2 = 0;
  5776. lastequality = diffs[pointer][1];
  5777. } else {
  5778. // An insertion or deletion.
  5779. if (diffs[pointer][0] === DIFF_INSERT) {
  5780. lengthInsertions2 += diffs[pointer][1].length;
  5781. } else {
  5782. lengthDeletions2 += diffs[pointer][1].length;
  5783. } // Eliminate an equality that is smaller or equal to the edits on both
  5784. // sides of it.
  5785. if (lastequality && lastequality.length <= Math.max(lengthInsertions1, lengthDeletions1) && lastequality.length <= Math.max(lengthInsertions2, lengthDeletions2)) {
  5786. // Duplicate record.
  5787. diffs.splice(equalities[equalitiesLength - 1], 0, [DIFF_DELETE, lastequality]); // Change second copy to insert.
  5788. diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT; // Throw away the equality we just deleted.
  5789. equalitiesLength--; // Throw away the previous equality (it needs to be reevaluated).
  5790. equalitiesLength--;
  5791. pointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1; // Reset the counters.
  5792. lengthInsertions1 = 0;
  5793. lengthDeletions1 = 0;
  5794. lengthInsertions2 = 0;
  5795. lengthDeletions2 = 0;
  5796. lastequality = null;
  5797. changes = true;
  5798. }
  5799. }
  5800. pointer++;
  5801. } // Normalize the diff.
  5802. if (changes) {
  5803. this.diffCleanupMerge(diffs);
  5804. } // Find any overlaps between deletions and insertions.
  5805. // e.g: <del>abcxxx</del><ins>xxxdef</ins>
  5806. // -> <del>abc</del>xxx<ins>def</ins>
  5807. // e.g: <del>xxxabc</del><ins>defxxx</ins>
  5808. // -> <ins>def</ins>xxx<del>abc</del>
  5809. // Only extract an overlap if it is as big as the edit ahead or behind it.
  5810. pointer = 1;
  5811. while (pointer < diffs.length) {
  5812. if (diffs[pointer - 1][0] === DIFF_DELETE && diffs[pointer][0] === DIFF_INSERT) {
  5813. deletion = diffs[pointer - 1][1];
  5814. insertion = diffs[pointer][1];
  5815. overlapLength1 = this.diffCommonOverlap(deletion, insertion);
  5816. overlapLength2 = this.diffCommonOverlap(insertion, deletion);
  5817. if (overlapLength1 >= overlapLength2) {
  5818. if (overlapLength1 >= deletion.length / 2 || overlapLength1 >= insertion.length / 2) {
  5819. // Overlap found. Insert an equality and trim the surrounding edits.
  5820. diffs.splice(pointer, 0, [DIFF_EQUAL, insertion.substring(0, overlapLength1)]);
  5821. diffs[pointer - 1][1] = deletion.substring(0, deletion.length - overlapLength1);
  5822. diffs[pointer + 1][1] = insertion.substring(overlapLength1);
  5823. pointer++;
  5824. }
  5825. } else {
  5826. if (overlapLength2 >= deletion.length / 2 || overlapLength2 >= insertion.length / 2) {
  5827. // Reverse overlap found.
  5828. // Insert an equality and swap and trim the surrounding edits.
  5829. diffs.splice(pointer, 0, [DIFF_EQUAL, deletion.substring(0, overlapLength2)]);
  5830. diffs[pointer - 1][0] = DIFF_INSERT;
  5831. diffs[pointer - 1][1] = insertion.substring(0, insertion.length - overlapLength2);
  5832. diffs[pointer + 1][0] = DIFF_DELETE;
  5833. diffs[pointer + 1][1] = deletion.substring(overlapLength2);
  5834. pointer++;
  5835. }
  5836. }
  5837. pointer++;
  5838. }
  5839. pointer++;
  5840. }
  5841. };
  5842. /**
  5843. * Determine if the suffix of one string is the prefix of another.
  5844. * @param {string} text1 First string.
  5845. * @param {string} text2 Second string.
  5846. * @return {number} The number of characters common to the end of the first
  5847. * string and the start of the second string.
  5848. * @private
  5849. */
  5850. DiffMatchPatch.prototype.diffCommonOverlap = function (text1, text2) {
  5851. var text1Length, text2Length, textLength, best, length, pattern, found; // Cache the text lengths to prevent multiple calls.
  5852. text1Length = text1.length;
  5853. text2Length = text2.length; // Eliminate the null case.
  5854. if (text1Length === 0 || text2Length === 0) {
  5855. return 0;
  5856. } // Truncate the longer string.
  5857. if (text1Length > text2Length) {
  5858. text1 = text1.substring(text1Length - text2Length);
  5859. } else if (text1Length < text2Length) {
  5860. text2 = text2.substring(0, text1Length);
  5861. }
  5862. textLength = Math.min(text1Length, text2Length); // Quick check for the worst case.
  5863. if (text1 === text2) {
  5864. return textLength;
  5865. } // Start by looking for a single character match
  5866. // and increase length until no match is found.
  5867. // Performance analysis: https://neil.fraser.name/news/2010/11/04/
  5868. best = 0;
  5869. length = 1;
  5870. while (true) {
  5871. pattern = text1.substring(textLength - length);
  5872. found = text2.indexOf(pattern);
  5873. if (found === -1) {
  5874. return best;
  5875. }
  5876. length += found;
  5877. if (found === 0 || text1.substring(textLength - length) === text2.substring(0, length)) {
  5878. best = length;
  5879. length++;
  5880. }
  5881. }
  5882. };
  5883. /**
  5884. * Split two texts into an array of strings. Reduce the texts to a string of
  5885. * hashes where each Unicode character represents one line.
  5886. * @param {string} text1 First string.
  5887. * @param {string} text2 Second string.
  5888. * @return {{chars1: string, chars2: string, lineArray: !Array.<string>}}
  5889. * An object containing the encoded text1, the encoded text2 and
  5890. * the array of unique strings.
  5891. * The zeroth element of the array of unique strings is intentionally blank.
  5892. * @private
  5893. */
  5894. DiffMatchPatch.prototype.diffLinesToChars = function (text1, text2) {
  5895. var lineArray, lineHash, chars1, chars2;
  5896. lineArray = []; // E.g. lineArray[4] === 'Hello\n'
  5897. lineHash = {}; // E.g. lineHash['Hello\n'] === 4
  5898. // '\x00' is a valid character, but various debuggers don't like it.
  5899. // So we'll insert a junk entry to avoid generating a null character.
  5900. lineArray[0] = "";
  5901. /**
  5902. * Split a text into an array of strings. Reduce the texts to a string of
  5903. * hashes where each Unicode character represents one line.
  5904. * Modifies linearray and linehash through being a closure.
  5905. * @param {string} text String to encode.
  5906. * @return {string} Encoded string.
  5907. * @private
  5908. */
  5909. function diffLinesToCharsMunge(text) {
  5910. var chars, lineStart, lineEnd, lineArrayLength, line;
  5911. chars = ""; // Walk the text, pulling out a substring for each line.
  5912. // text.split('\n') would would temporarily double our memory footprint.
  5913. // Modifying text would create many large strings to garbage collect.
  5914. lineStart = 0;
  5915. lineEnd = -1; // Keeping our own length variable is faster than looking it up.
  5916. lineArrayLength = lineArray.length;
  5917. while (lineEnd < text.length - 1) {
  5918. lineEnd = text.indexOf("\n", lineStart);
  5919. if (lineEnd === -1) {
  5920. lineEnd = text.length - 1;
  5921. }
  5922. line = text.substring(lineStart, lineEnd + 1);
  5923. lineStart = lineEnd + 1;
  5924. if (hasOwn.call(lineHash, line)) {
  5925. chars += String.fromCharCode(lineHash[line]);
  5926. } else {
  5927. chars += String.fromCharCode(lineArrayLength);
  5928. lineHash[line] = lineArrayLength;
  5929. lineArray[lineArrayLength++] = line;
  5930. }
  5931. }
  5932. return chars;
  5933. }
  5934. chars1 = diffLinesToCharsMunge(text1);
  5935. chars2 = diffLinesToCharsMunge(text2);
  5936. return {
  5937. chars1: chars1,
  5938. chars2: chars2,
  5939. lineArray: lineArray
  5940. };
  5941. };
  5942. /**
  5943. * Rehydrate the text in a diff from a string of line hashes to real lines of
  5944. * text.
  5945. * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
  5946. * @param {!Array.<string>} lineArray Array of unique strings.
  5947. * @private
  5948. */
  5949. DiffMatchPatch.prototype.diffCharsToLines = function (diffs, lineArray) {
  5950. var x, chars, text, y;
  5951. for (x = 0; x < diffs.length; x++) {
  5952. chars = diffs[x][1];
  5953. text = [];
  5954. for (y = 0; y < chars.length; y++) {
  5955. text[y] = lineArray[chars.charCodeAt(y)];
  5956. }
  5957. diffs[x][1] = text.join("");
  5958. }
  5959. };
  5960. /**
  5961. * Reorder and merge like edit sections. Merge equalities.
  5962. * Any edit section can move as long as it doesn't cross an equality.
  5963. * @param {!Array.<!DiffMatchPatch.Diff>} diffs Array of diff tuples.
  5964. */
  5965. DiffMatchPatch.prototype.diffCleanupMerge = function (diffs) {
  5966. var pointer, countDelete, countInsert, textInsert, textDelete, commonlength, changes, diffPointer, position;
  5967. diffs.push([DIFF_EQUAL, ""]); // Add a dummy entry at the end.
  5968. pointer = 0;
  5969. countDelete = 0;
  5970. countInsert = 0;
  5971. textDelete = "";
  5972. textInsert = "";
  5973. while (pointer < diffs.length) {
  5974. switch (diffs[pointer][0]) {
  5975. case DIFF_INSERT:
  5976. countInsert++;
  5977. textInsert += diffs[pointer][1];
  5978. pointer++;
  5979. break;
  5980. case DIFF_DELETE:
  5981. countDelete++;
  5982. textDelete += diffs[pointer][1];
  5983. pointer++;
  5984. break;
  5985. case DIFF_EQUAL:
  5986. // Upon reaching an equality, check for prior redundancies.
  5987. if (countDelete + countInsert > 1) {
  5988. if (countDelete !== 0 && countInsert !== 0) {
  5989. // Factor out any common prefixes.
  5990. commonlength = this.diffCommonPrefix(textInsert, textDelete);
  5991. if (commonlength !== 0) {
  5992. if (pointer - countDelete - countInsert > 0 && diffs[pointer - countDelete - countInsert - 1][0] === DIFF_EQUAL) {
  5993. diffs[pointer - countDelete - countInsert - 1][1] += textInsert.substring(0, commonlength);
  5994. } else {
  5995. diffs.splice(0, 0, [DIFF_EQUAL, textInsert.substring(0, commonlength)]);
  5996. pointer++;
  5997. }
  5998. textInsert = textInsert.substring(commonlength);
  5999. textDelete = textDelete.substring(commonlength);
  6000. } // Factor out any common suffixies.
  6001. commonlength = this.diffCommonSuffix(textInsert, textDelete);
  6002. if (commonlength !== 0) {
  6003. diffs[pointer][1] = textInsert.substring(textInsert.length - commonlength) + diffs[pointer][1];
  6004. textInsert = textInsert.substring(0, textInsert.length - commonlength);
  6005. textDelete = textDelete.substring(0, textDelete.length - commonlength);
  6006. }
  6007. } // Delete the offending records and add the merged ones.
  6008. if (countDelete === 0) {
  6009. diffs.splice(pointer - countInsert, countDelete + countInsert, [DIFF_INSERT, textInsert]);
  6010. } else if (countInsert === 0) {
  6011. diffs.splice(pointer - countDelete, countDelete + countInsert, [DIFF_DELETE, textDelete]);
  6012. } else {
  6013. diffs.splice(pointer - countDelete - countInsert, countDelete + countInsert, [DIFF_DELETE, textDelete], [DIFF_INSERT, textInsert]);
  6014. }
  6015. pointer = pointer - countDelete - countInsert + (countDelete ? 1 : 0) + (countInsert ? 1 : 0) + 1;
  6016. } else if (pointer !== 0 && diffs[pointer - 1][0] === DIFF_EQUAL) {
  6017. // Merge this equality with the previous one.
  6018. diffs[pointer - 1][1] += diffs[pointer][1];
  6019. diffs.splice(pointer, 1);
  6020. } else {
  6021. pointer++;
  6022. }
  6023. countInsert = 0;
  6024. countDelete = 0;
  6025. textDelete = "";
  6026. textInsert = "";
  6027. break;
  6028. }
  6029. }
  6030. if (diffs[diffs.length - 1][1] === "") {
  6031. diffs.pop(); // Remove the dummy entry at the end.
  6032. } // Second pass: look for single edits surrounded on both sides by equalities
  6033. // which can be shifted sideways to eliminate an equality.
  6034. // e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
  6035. changes = false;
  6036. pointer = 1; // Intentionally ignore the first and last element (don't need checking).
  6037. while (pointer < diffs.length - 1) {
  6038. if (diffs[pointer - 1][0] === DIFF_EQUAL && diffs[pointer + 1][0] === DIFF_EQUAL) {
  6039. diffPointer = diffs[pointer][1];
  6040. position = diffPointer.substring(diffPointer.length - diffs[pointer - 1][1].length); // This is a single edit surrounded by equalities.
  6041. if (position === diffs[pointer - 1][1]) {
  6042. // Shift the edit over the previous equality.
  6043. diffs[pointer][1] = diffs[pointer - 1][1] + diffs[pointer][1].substring(0, diffs[pointer][1].length - diffs[pointer - 1][1].length);
  6044. diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
  6045. diffs.splice(pointer - 1, 1);
  6046. changes = true;
  6047. } else if (diffPointer.substring(0, diffs[pointer + 1][1].length) === diffs[pointer + 1][1]) {
  6048. // Shift the edit over the next equality.
  6049. diffs[pointer - 1][1] += diffs[pointer + 1][1];
  6050. diffs[pointer][1] = diffs[pointer][1].substring(diffs[pointer + 1][1].length) + diffs[pointer + 1][1];
  6051. diffs.splice(pointer + 1, 1);
  6052. changes = true;
  6053. }
  6054. }
  6055. pointer++;
  6056. } // If shifts were made, the diff needs reordering and another shift sweep.
  6057. if (changes) {
  6058. this.diffCleanupMerge(diffs);
  6059. }
  6060. };
  6061. return function (o, n) {
  6062. var diff, output, text;
  6063. diff = new DiffMatchPatch();
  6064. output = diff.DiffMain(o, n);
  6065. diff.diffCleanupEfficiency(output);
  6066. text = diff.diffPrettyHtml(output);
  6067. return text;
  6068. };
  6069. }();
  6070. }((function() { return this; }())));