ls.js 243 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755
  1. var level3 = require("../../lib/jsdom/level3").dom.level3;
  2. var getImplementation = function() {
  3. var doc = new level3.core.Document();
  4. return doc.implementation;
  5. };
  6. function DOMErrorMonitor() {
  7. this.allErrors = new Array();
  8. }
  9. DOMErrorMonitor.prototype.handleError = function(err) {
  10. errorMonitor.allErrors[errorMonitor.allErrors.length] = new DOMErrorImpl(err);
  11. }
  12. DOMErrorMonitor.prototype.assertLowerSeverity = function(test, id, severity) {
  13. var i;
  14. for (i = 0; i < this.allErrors.length; i++) {
  15. if (this.allErrors[i].severity >= severity) {
  16. test.strictEqual(severity - 1, this.allErrors[i].severity, id);
  17. }
  18. }
  19. }
  20. // XXX: this is horrible!
  21. function getResourceURI() {
  22. return "";
  23. }
  24. function load() {
  25. return new level3.core.Document();
  26. }
  27. exports.tests = {
  28. /**
  29. * Changes certifiedText on LSInput.
  30. * @author Curt Arnold
  31. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-DOMImplementationLS-createLSInput
  32. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSInput-certifiedText
  33. */
  34. CertifiedText1 : function (test) {
  35. var domImpl = getImplementation();
  36. var input = domImpl.createLSInput();
  37. var certifiedText = input.certifiedText;
  38. test.ok(certifiedText === false, "initiallyFalse");
  39. input.certifiedText = true;
  40. certifiedText = input.certifiedText;
  41. test.ok(certifiedText, "setTrue");
  42. input.certifiedText = false;
  43. certifiedText = input.certifiedText;
  44. test.ok(certifiedText === false, "setFalse");
  45. test.done();
  46. },
  47. /**
  48. * Writes a document to a character stream and rereads the document.
  49. * @author Curt Arnold
  50. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-DOMImplementationLS-createLSInput
  51. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSInput-characterStream
  52. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSOutput-characterStream
  53. */
  54. CharacterStream1 : function (test) {
  55. var success, testDoc, domImpl, output, serializer, writer, checkWriter, reader, checkReader, status, input, parser, checkDoc, docElem, docElemName, NULL_SCHEMA_TYPE = null, testDocRef = null;
  56. if (typeof(this.testDoc) != 'undefined') {
  57. testDocRef = this.testDoc;
  58. }
  59. testDoc = load(testDocRef, "testDoc", "test0");
  60. domImpl = getImplementation();
  61. output = domImpl.createLSOutput();
  62. checkWriter = output.characterStream;
  63. test.ok(checkWriter === null, "writerInitiallyNull");
  64. output.characterStream = writer;
  65. checkWriter = output.characterStream;
  66. test.ok(checkWriter !== null, "writerNotNull");
  67. serializer = domImpl.createLSSerializer();
  68. status = serializer.write(testDoc,output);
  69. test.ok(status, "writeStatus");
  70. reader = writer;
  71. input = domImpl.createLSInput();
  72. checkReader = input.characterStream;
  73. test.ok(checkReader === null, "readerInitiallyNull");
  74. input.characterStream = reader;
  75. checkReader = input.characterStream;
  76. test.ok(checkReader !== null, "readerNotNull");
  77. parser = domImpl.createLSParser(1,NULL_SCHEMA_TYPE);
  78. checkDoc = parser.parse(input);
  79. test.ok(checkDoc !== null, "checkNotNull");
  80. docElem = checkDoc.documentElement;
  81. docElemName = docElem.nodeName;
  82. test.strictEqual("elt0", docElemName, "checkDocElemName");
  83. test.done();
  84. },
  85. /**
  86. * Parses a document twice, once using a filter to reject all elt1 elements.
  87. * @author Jeroen van Rotterdam
  88. * @author X-Hive Corporation
  89. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-filter
  90. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParserFilter-startElement
  91. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParserFilter-whatToShow
  92. */
  93. DOMBuilderFilterTest0 : function (test) {
  94. // TODO: finish the implementation of this filter
  95. function LSParserFilterN10027() {}
  96. var
  97. success, myfilter = new LSParserFilterN10027(), list, count, resourceURI,
  98. implementation, lsImplementation, inputSource, document, writer, builder,
  99. MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2,
  100. DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml",
  101. SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema",
  102. NULL_SCHEMATYPE = null, ACTION_REPLACE_CHILDREN = 2,
  103. ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  104. implementation = getImplementation();
  105. lsImplementation = implementation;
  106. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  107. writer = lsImplementation.createLSSerializer();
  108. inputSource = lsImplementation.createLSInput();
  109. resourceURI = getResourceURI(TEST1);
  110. document = builder.parseURI(resourceURI);
  111. list = document.getElementsByTagName("elt1");
  112. count = list.length;
  113. test.strictEqual(1, count, "filter_count_1");
  114. builder.filter = myfilter;
  115. document = builder.parseURI(resourceURI);
  116. test.ok(document !== null, "secondParseDocumentNotNull");
  117. list = document.getElementsByTagName("elt1");
  118. count = list.length;
  119. test.strictEqual(0, count, "filter_count_2");
  120. test.done();
  121. },
  122. /**
  123. * DOM Builder Filter test, test whether incorrect node types are never passed to the filter.
  124. * @author Jeroen van Rotterdam
  125. * @author X-Hive Corporation
  126. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-Interfaces-LSParserFilter
  127. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-filter
  128. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParserFilter-acceptNode
  129. */
  130. DOMBuilderFilterTest1 : function (test) {
  131. function LSParserFilterN1002B() {}
  132. var success, resourceURI, myfilter = new LSParserFilterN1002B(), implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null, ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  133. implementation = getImplementation();
  134. lsImplementation = implementation;
  135. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  136. writer = lsImplementation.createLSSerializer();
  137. inputSource = lsImplementation.createLSInput();
  138. builder.filter = myfilter;
  139. resourceURI = getResourceURI(TEST7);
  140. document = builder.parseURI(resourceURI);
  141. test.ok(document !== null, "documentNotNull");
  142. test.done();
  143. },
  144. /**
  145. * Checks that attributes are visible when elements are passed to LSParserFilter.startElement.
  146. * @author Jeroen van Rotterdam
  147. * @author X-Hive Corporation
  148. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-Interfaces-LSParserFilter
  149. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParserFilter-startElement
  150. */
  151. DOMBuilderFilterTest2 : function (test) {
  152. function LSParserFilterN10028() {}
  153. var success, resourceURI;
  154. myfilter = new LSParserFilterN10028();
  155. var implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  156. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  157. implementation = getImplementation();
  158. lsImplementation = implementation;
  159. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  160. writer = lsImplementation.createLSSerializer();
  161. inputSource = lsImplementation.createLSInput();
  162. builder.filter = myfilter;
  163. resourceURI = getResourceURI(TEST3);
  164. document = builder.parseURI(resourceURI);
  165. test.done();
  166. },
  167. /**
  168. * Parses a document, writes it to string, parses the string and checks that the number of elt1 elements is as expected.
  169. * @author Jeroen van Rotterdam
  170. * @author X-Hive Corporation
  171. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parse
  172. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  173. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  174. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSInput-stringData
  175. */
  176. DOMBuilderTest0 : function (test) {
  177. var success, elementList, stringDoc, resourceURI, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  178. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  179. implementation = getImplementation();
  180. lsImplementation = implementation;
  181. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  182. writer = lsImplementation.createLSSerializer();
  183. inputSource = lsImplementation.createLSInput();
  184. resourceURI = getResourceURI(TEST0);
  185. document = builder.parseURI(resourceURI);
  186. elementList = document.getElementsByTagName("elt1");
  187. test.ok(2 === elementList.length, "count_elt1_1");
  188. stringDoc = writer.writeToString(document);
  189. inputSource.stringData = stringDoc;
  190. document = builder.parse(inputSource);
  191. elementList = document.getElementsByTagName("elt1");
  192. test.ok(2 === elementList.length, "count_elt1_2");
  193. test.done();
  194. },
  195. /**
  196. * Uses LSParser.parseWithContext to replace a node in an existing document.
  197. * @author Jeroen van Rotterdam
  198. * @author X-Hive Corporation
  199. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseWithContext
  200. */
  201. DOMBuilderTest1 : function (test) {
  202. var success, elementList, stringDoc, firstElt2, returnNode, resourceURI, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  203. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  204. implementation = getImplementation();
  205. lsImplementation = implementation;
  206. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  207. writer = lsImplementation.createLSSerializer();
  208. inputSource = lsImplementation.createLSInput();
  209. resourceURI = getResourceURI(TEST0);
  210. document = builder.parseURI(resourceURI);
  211. elementList = document.getElementsByTagName("elt2");
  212. test.ok(1 === elementList.length, "elt2Count_1");
  213. firstElt2 = elementList.item(0);
  214. resourceURI = getResourceURI(TEST2);
  215. inputSource.systemId = resourceURI;
  216. try {
  217. returnNode = builder.parseWithContext(inputSource,firstElt2,ACTION_REPLACE);
  218. } catch (ex) {
  219. if (typeof(ex.code) != 'undefined') {
  220. switch(ex.code) {
  221. case /* NOT_SUPPORTED_ERR */ 9 :
  222. return ;
  223. default:
  224. throw ex;
  225. }
  226. } else {
  227. throw ex;
  228. }
  229. }
  230. elementList = document.getElementsByTagName("elt2");
  231. test.ok(1 === elementList.length, "elt2Count_2");
  232. elementList = document.getElementsByTagName("elt3");
  233. test.ok(1 === elementList.length, "elt3Count");
  234. test.done();
  235. },
  236. /**
  237. * Uses LSParser.parseWithContext to append a document as a child of an existing node.
  238. * @author Jeroen van Rotterdam
  239. * @author X-Hive Corporation
  240. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseWithContext
  241. */
  242. DOMBuilderTest2 : function (test) {
  243. var success, elementList, stringDoc, firstElt0, returnNode, resourceURI, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  244. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  245. implementation = getImplementation();
  246. lsImplementation = implementation;
  247. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  248. writer = lsImplementation.createLSSerializer();
  249. inputSource = lsImplementation.createLSInput();
  250. resourceURI = getResourceURI(TEST0);
  251. document = builder.parseURI(resourceURI);
  252. elementList = document.getElementsByTagName("elt0");
  253. test.ok(1 === elementList.length, "count_elt0");
  254. firstElt0 = elementList.item(0);
  255. resourceURI = getResourceURI(TEST2);
  256. inputSource.systemId = resourceURI;
  257. try {
  258. returnNode = builder.parseWithContext(inputSource,firstElt0,ACTION_APPEND_AS_CHILDREN);
  259. } catch (ex) {
  260. if (typeof(ex.code) != 'undefined') {
  261. switch(ex.code) {
  262. case /* NOT_SUPPORTED_ERR */ 9 :
  263. return ;
  264. default:
  265. throw ex;
  266. }
  267. } else {
  268. throw ex;
  269. }
  270. }
  271. elementList = document.getElementsByTagName("elt2");
  272. test.ok(2 === elementList.length, "count_elt2");
  273. elementList = document.getElementsByTagName("elt3");
  274. test.ok(1 === elementList.length, "count_elt3");
  275. test.done();
  276. },
  277. /**
  278. * Uses LSParser.parseWithContext to insert a document after a node.
  279. * @author Jeroen van Rotterdam
  280. * @author X-Hive Corporation
  281. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseWithContext
  282. */
  283. DOMBuilderTest3 : function (test) {
  284. var success, elementList, stringDoc, firstElt1, secondElt1, thirdElt, nodeName, returnNode, resourceURI, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  285. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  286. implementation = getImplementation();
  287. lsImplementation = implementation;
  288. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  289. writer = lsImplementation.createLSSerializer();
  290. inputSource = lsImplementation.createLSInput();
  291. resourceURI = getResourceURI(TEST0);
  292. document = builder.parseURI(resourceURI);
  293. elementList = document.getElementsByTagName("elt1");
  294. test.ok(2 === elementList.length, "count_elt1");
  295. firstElt1 = elementList.item(0);
  296. secondElt1 = firstElt1.nextSibling;
  297. nodeName = secondElt1.nodeName;
  298. test.strictEqual("elt1", nodeName, "nextSibling_before_add");
  299. resourceURI = getResourceURI(TEST2);
  300. inputSource.systemId = resourceURI;
  301. try {
  302. returnNode = builder.parseWithContext(inputSource,firstElt1,ACTION_INSERT_AFTER);
  303. } catch (ex) {
  304. if (typeof(ex.code) != 'undefined') {
  305. switch(ex.code) {
  306. case /* NOT_SUPPORTED_ERR */ 9 :
  307. return ;
  308. default:
  309. throw ex;
  310. }
  311. } else {
  312. throw ex;
  313. }
  314. }
  315. secondElt1 = firstElt1.nextSibling;
  316. nodeName = secondElt1.nodeName;
  317. test.strictEqual("elt2", nodeName, "nextSibling_after_add");
  318. thirdElt = secondElt1.nextSibling;
  319. nodeName = thirdElt.nodeName;
  320. test.strictEqual("elt1", nodeName, "nextSiblings_sibling_after_add");
  321. test.done();
  322. },
  323. /**
  324. * Uses LSParser.parseWithContext to insert a document before a node.
  325. * @author Jeroen van Rotterdam
  326. * @author X-Hive Corporation
  327. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseWithContext
  328. */
  329. DOMBuilderTest4 : function (test) {
  330. var success, elementList, stringDoc, firstElt1, secondElt1, thirdElt, nodeName, returnNode, resourceURI, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  331. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  332. implementation = getImplementation();
  333. lsImplementation = implementation;
  334. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  335. writer = lsImplementation.createLSSerializer();
  336. inputSource = lsImplementation.createLSInput();
  337. resourceURI = getResourceURI(TEST0);
  338. document = builder.parseURI(resourceURI);
  339. elementList = document.getElementsByTagName("elt1");
  340. test.ok(2 === elementList.length, "count_elt1");
  341. secondElt1 = elementList.item(1);
  342. firstElt1 = secondElt1.previousSibling;
  343. nodeName = firstElt1.nodeName;
  344. test.strictEqual("elt1", nodeName, "previousSibling_before_insert_before");
  345. resourceURI = getResourceURI(TEST2);
  346. inputSource.systemId = resourceURI;
  347. try {
  348. returnNode = builder.parseWithContext(inputSource,secondElt1,ACTION_INSERT_BEFORE);
  349. } catch (ex) {
  350. if (typeof(ex.code) != 'undefined') {
  351. switch(ex.code) {
  352. case /* NOT_SUPPORTED_ERR */ 9 :
  353. return ;
  354. default:
  355. throw ex;
  356. }
  357. } else {
  358. throw ex;
  359. }
  360. }
  361. firstElt1 = secondElt1.previousSibling;
  362. nodeName = firstElt1.nodeName;
  363. test.strictEqual("elt2", nodeName, "previousSibling_after_insert_before");
  364. test.done();
  365. }, /**
  366. * supported-media-types-only is set to true if supported and
  367. an XML file with an unsupported media type from an HTTP server
  368. on the local machine is retrieved.
  369. * @author Jeroen van Rotterdam
  370. * @author X-Hive Corporation
  371. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  372. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-supported-media-types-only
  373. */
  374. DOMBuilderTest5 : function (test) {
  375. var success, elementList, stringDoc, configuration, ERROR_HANDLER = "error-handler", SUPPORTED_MEDIATYPES_ONLY = "supported-media-types-only", mediaTypesSupported, resourceURI;
  376. function DOMErrorHandlerN10042() {};
  377. var errorHandler = new DOMErrorHandlerN10042();
  378. var implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  379. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  380. implementation = getImplementation();
  381. lsImplementation = implementation;
  382. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  383. writer = lsImplementation.createLSSerializer();
  384. inputSource = lsImplementation.createLSInput();
  385. configuration = builder.domConfig;
  386. resourceURI = getResourceURI(TESTPDF);
  387. document = builder.parseURI(resourceURI);
  388. test.ok(document !== null, "testpdf_parsed");
  389. mediaTypesSupported = configuration.canSetParameter(SUPPORTED_MEDIATYPES_ONLY,true);
  390. if(
  391. mediaTypesSupported
  392. ) {
  393. configuration.setParameter(SUPPORTED_MEDIATYPES_ONLY, true);
  394. configuration.setParameter(ERROR_HANDLER, errorHandler.handleError);
  395. {
  396. success = false;
  397. try {
  398. document = builder.parseURI(resourceURI);
  399. }
  400. catch(ex) {
  401. success = (typeof(ex.code) != 'undefined' && ex.code == 81);
  402. }
  403. test.ok(success, "throw_PARSE_ERR");
  404. }
  405. }
  406. test.done();
  407. },
  408. /**
  409. * Parses from an uninitialized LSInput.
  410. * @author Curt Arnold
  411. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parse
  412. */
  413. DOMBuilderTest6 : function (test) {
  414. var success, domImpl, parser, NULL_SCHEMA_TYPE = null;
  415. var input, document;
  416. domImpl = getImplementation();
  417. parser = domImpl.createLSParser(1,NULL_SCHEMA_TYPE);
  418. input = domImpl.createLSInput();
  419. {
  420. success = false;
  421. try {
  422. document = parser.parse(input);
  423. }
  424. catch(ex) {
  425. success = (typeof(ex.code) != 'undefined' && ex.code == 81);
  426. }
  427. test.ok(success, "throw_PARSE_ERR");
  428. }
  429. test.done();
  430. },
  431. /**
  432. * Parses an unresolvable System ID.
  433. * @author Curt Arnold
  434. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parse
  435. */
  436. DOMBuilderTest8 : function (test) {
  437. var success, domImpl, parser, NULL_SCHEMA_TYPE = null;
  438. var input, document, resourceURI;
  439. domImpl = getImplementation();
  440. parser = domImpl.createLSParser(1,NULL_SCHEMA_TYPE);
  441. input = domImpl.createLSInput();
  442. resourceURI = getResourceURI("test0");
  443. resourceURI = resourceURI + "_missing";
  444. input.systemId = resourceURI;
  445. {
  446. success = false;
  447. try {
  448. document = parser.parse(input);
  449. }
  450. catch(ex) {
  451. success = (typeof(ex.code) != 'undefined' && ex.code == 81);
  452. }
  453. test.ok(success, "throw_PARSE_ERR");
  454. }
  455. test.done();
  456. },
  457. /**
  458. * Checks parameters on call to resolve resource are
  459. as expected and redirects to parse a different resource.
  460. * @author Jeroen van Rotterdam
  461. * @author X-Hive Corporation
  462. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSResourceResolver-resolveResource
  463. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-resource-resolver
  464. */
  465. DOMEntityResolverTest0 : function (test) {
  466. var success, resourceURI, elt2List, elt2Count;
  467. function LSResourceResolverN10030() {}
  468. myentityresolver = new LSResourceResolverN10030();
  469. var configuration, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  470. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  471. implementation = getImplementation();
  472. lsImplementation = implementation;
  473. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  474. writer = lsImplementation.createLSSerializer();
  475. inputSource = lsImplementation.createLSInput();
  476. configuration = builder.domConfig;
  477. configuration.setParameter("resource-resolver", myentityresolver);
  478. resourceURI = getResourceURI(TEST4);
  479. document = builder.parseURI(resourceURI);
  480. elt2List = document.getElementsByTagName("elt2");
  481. elt2Count = elt2List.length;
  482. test.strictEqual(1, elt2Count, "elt2Count");
  483. test.done();
  484. },
  485. /**
  486. * Tests a custom entity resolver. The entity resolver creates an input source that supplies 2 elt1 elements. The original entity reference referes to 1 elt1
  487. * @author Jeroen van Rotterdam
  488. * @author X-Hive Corporation
  489. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSResourceResolver-resolveResource
  490. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-resource-resolver
  491. */
  492. DOMEntityResolverTest1 : function (test) {
  493. var success;
  494. function LSResourceResolverN10028() {};
  495. myentityresolver = new LSResourceResolverN10028();
  496. var elementList, configuration, resourceURI, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  497. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  498. implementation = getImplementation();
  499. lsImplementation = implementation;
  500. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  501. writer = lsImplementation.createLSSerializer();
  502. inputSource = lsImplementation.createLSInput();
  503. configuration = builder.domConfig;
  504. resourceURI = getResourceURI(TEST4);
  505. document = builder.parseURI(resourceURI);
  506. elementList = document.getElementsByTagName("elt1");
  507. test.ok(2 === elementList.length, "count_elt1_before_applying_entity_resolver");
  508. configuration.setParameter("resource-resolver", myentityresolver);
  509. document = builder.parseURI(resourceURI);
  510. elementList = document.getElementsByTagName("elt1");
  511. test.ok(3 === elementList.length, "count_elt1_after_applying_entity_resolver");
  512. test.done();
  513. },
  514. /**
  515. * Resource resolvers do not participate in resolving the top-level document entity.
  516. This test attempts to redirect any resource and then checks that the
  517. requested document was not affected.
  518. * @author Jeroen van Rotterdam
  519. * @author X-Hive Corporation
  520. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSResourceResolver-resolveResource
  521. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-resource-resolver
  522. */
  523. DOMEntityResolverTest2 : function (test) {
  524. function LSResourceResolverN10030(){}
  525. LSResourceResolverN10030.prototype={};
  526. var success, resourceURI, docElem, docElemName;
  527. myentityresolver = new LSResourceResolverN10030();
  528. var configuration, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  529. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  530. implementation = getImplementation();
  531. lsImplementation = implementation;
  532. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  533. writer = lsImplementation.createLSSerializer();
  534. inputSource = lsImplementation.createLSInput();
  535. configuration = builder.domConfig;
  536. configuration.setParameter("resource-resolver", myentityresolver);
  537. resourceURI = getResourceURI(TEST0);
  538. document = builder.parseURI(resourceURI);
  539. test.ok(document !== null, "documentNotNull");
  540. docElem = document.documentElement;
  541. docElemName = docElem.nodeName;
  542. test.strictEqual("elt0", docElemName, "docElemName");
  543. test.done();
  544. },
  545. /**
  546. * Uses DOMImplementationLS.createLSParser to create a synchronous parser with an unspecified schema type.
  547. * @author Jeroen van Rotterdam
  548. * @author X-Hive Corporation
  549. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-DOMImplementationLS-createLSParser
  550. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-async
  551. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-busy
  552. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-filter
  553. */
  554. DOMImplementationLSTest0 : function (test) {
  555. var success, isAsync, isBusy, filter, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  556. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  557. implementation = getImplementation();
  558. lsImplementation = implementation;
  559. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  560. test.ok(builder !== null, "builderNotNull");
  561. isAsync = builder.async;
  562. test.ok(isAsync === false, "notAsync");
  563. isBusy = builder.busy;
  564. test.ok(isBusy === false, "notBusy");
  565. filter = builder.filter;
  566. test.ok(filter === null, "nullFilter");
  567. test.done();
  568. },
  569. /**
  570. * Calls DOMImplementationLS.createLSParser(MODE_ASYNCHRONOUS, null) and
  571. checks the return value is not null. Only applicable if DOMImplementation.hasFeature("LS-ASync", null) is true.
  572. * @author Jeroen van Rotterdam
  573. * @author X-Hive Corporation
  574. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-DOMImplementationLS-createLSParser
  575. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-async
  576. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-busy
  577. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-filter
  578. */
  579. DOMImplementationLSTest1 : function (test) {
  580. var success, isAsync, isBusy, filter, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  581. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  582. implementation = getImplementation();
  583. lsImplementation = implementation;
  584. builder = lsImplementation.createLSParser(MODE_ASYNCHRONOUS,NULL_SCHEMATYPE);
  585. test.ok(builder !== null, "builderNotNull");
  586. isAsync = builder.async;
  587. test.ok(isAsync, "notAsync");
  588. isBusy = builder.busy;
  589. test.ok(isBusy === false, "notBusy");
  590. filter = builder.filter;
  591. test.ok(filter === null, "nullFilter");
  592. test.done();
  593. },
  594. /**
  595. * Calls DOMImplementationLS.createLSParser(MODE_SYNCHRONOUS, "http://www.w3.org/TR/REC-xml") and checks the return value is not null.
  596. * @author Jeroen van Rotterdam
  597. * @author X-Hive Corporation
  598. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-DOMImplementationLS-createLSParser
  599. */
  600. DOMImplementationLSTest2 : function (test) {
  601. var success, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  602. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  603. implementation = getImplementation();
  604. lsImplementation = implementation;
  605. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,DTD_SCHEMATYPE);
  606. test.ok(builder !== null, "builderNotNull");
  607. test.done();
  608. },
  609. /**
  610. * Calls DOMImplementationLS.createLSParser(MODE_SYNCHRONOUS, "http://www.w3.org/2001/XMLSchema").
  611. Should either throw a NOT_SUPPORTED_ERR or return a non-null builder.
  612. * @author Jeroen van Rotterdam
  613. * @author X-Hive Corporation
  614. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-DOMImplementationLS-createLSParser
  615. */
  616. DOMImplementationLSTest3 : function (test) {
  617. var success, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  618. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  619. implementation = getImplementation();
  620. lsImplementation = implementation;
  621. try {
  622. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,SCHEMA_SCHEMATYPE);
  623. test.ok(builder !== null, "builderNotNull");
  624. } catch (ex) {
  625. test.ok(ex.code === /* NOT_SUPPORTED_ERR */ 9);
  626. }
  627. test.done();
  628. },
  629. /**
  630. * Calls DOMImplementationLS.createLSParser(MODE_SYNCHRONOUS, "http://nobody...err") expecting that a
  631. NOT_SUPPORTED_ERR would be raised.
  632. * @author Jeroen van Rotterdam
  633. * @author X-Hive Corporation
  634. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-DOMImplementationLS-createLSParser
  635. */
  636. DOMImplementationLSTest4 : function (test) {
  637. var success, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  638. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  639. implementation = getImplementation();
  640. lsImplementation = implementation;
  641. {
  642. success = false;
  643. try {
  644. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,"http://nobody_should_support_this_schematype_this_should_throw_a_not_supported_err");
  645. }
  646. catch(ex) {
  647. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  648. }
  649. test.ok(success, "NOT_SUPPORTED_ERR");
  650. }
  651. test.done();
  652. },
  653. /**
  654. * Calls DOMImplementationLS.createLSParser(MODE_SYNCHRONOUS, "http://nobody...err") expecting that a
  655. NOT_SUPPORTED_ERR would be raised.
  656. * @author Jeroen van Rotterdam
  657. * @author X-Hive Corporation
  658. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-DOMImplementationLS-createLSParser
  659. */
  660. DOMImplementationLSTest5 : function (test) {
  661. var success, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  662. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  663. implementation = getImplementation();
  664. lsImplementation = implementation;
  665. {
  666. success = false;
  667. try {
  668. builder = lsImplementation.createLSParser(17,NULL_SCHEMATYPE);
  669. }
  670. catch(ex) {
  671. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  672. }
  673. test.ok(success, "NOT_SUPPORTED_ERR");
  674. }
  675. test.done();
  676. },
  677. /**
  678. * Parses a document from a byte stream.
  679. * @author Jeroen van Rotterdam
  680. * @author X-Hive Corporation
  681. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSInput-byteStream
  682. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parse
  683. */
  684. DOMInputSourceTest0 : function (test) {
  685. var success, myByteStream = "3C656C74302F3E", elementList, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  686. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  687. implementation = getImplementation();
  688. lsImplementation = implementation;
  689. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  690. writer = lsImplementation.createLSSerializer();
  691. inputSource = lsImplementation.createLSInput();
  692. inputSource.byteStream = myByteStream;
  693. document = builder.parse(inputSource);
  694. elementList = document.getElementsByTagName("elt0");
  695. test.ok(1 === elementList.length, "count_elt0");
  696. test.done();
  697. },
  698. /**
  699. * Parses a document from a character stream.
  700. * @author Jeroen van Rotterdam
  701. * @author X-Hive Corporation
  702. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSInput-characterStream
  703. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parse
  704. */
  705. DOMInputSourceTest1 : function (test) {
  706. var success, myReader = "&lt;elt0/>", elementList, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  707. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  708. implementation = getImplementation();
  709. lsImplementation = implementation;
  710. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  711. writer = lsImplementation.createLSSerializer();
  712. inputSource = lsImplementation.createLSInput();
  713. inputSource.characterStream = myReader;
  714. document = builder.parse(inputSource);
  715. elementList = document.getElementsByTagName("elt0");
  716. test.ok(1 === elementList.length, "count_elt0");
  717. test.done();
  718. },
  719. /**
  720. * test the builder by using a string inputsource
  721. * @author Jeroen van Rotterdam
  722. * @author X-Hive Corporation
  723. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSInput-stringData
  724. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parse
  725. */
  726. DOMInputSourceTest2 : function (test) {
  727. var success, elementList, myString = "&lt;elt0>elt0&lt;/elt0>", implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  728. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  729. implementation = getImplementation();
  730. lsImplementation = implementation;
  731. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  732. writer = lsImplementation.createLSSerializer();
  733. inputSource = lsImplementation.createLSInput();
  734. inputSource.stringData = myString;
  735. document = builder.parse(inputSource);
  736. elementList = document.getElementsByTagName("elt0");
  737. test.ok(1 === elementList.length, "count_elt0");
  738. test.done();
  739. },
  740. /**
  741. * Specify encodings for LSInput with string data. The
  742. setting should have no effect and the inputEncoding of the resulting document should be UTF-16.
  743. * @author Jeroen van Rotterdam
  744. * @author X-Hive Corporation
  745. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSInput-encoding
  746. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parse
  747. */
  748. DOMInputSourceTest3 : function (test) {
  749. var success, myString = "<?xml version='1.0' encoding='UTF-8'?>&lt;elt0>elt0&lt;/elt0>", encodingString, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  750. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  751. implementation = getImplementation();
  752. lsImplementation = implementation;
  753. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  754. writer = lsImplementation.createLSSerializer();
  755. inputSource = lsImplementation.createLSInput();
  756. inputSource.stringData = myString;
  757. inputSource.encoding = "UTF-8";
  758. document = builder.parse(inputSource);
  759. encodingString = document.inputEncoding;
  760. test.strictEqual("UTF-16".toLowerCase(), encodingString.toLowerCase(), "encodingstringcheck0");
  761. test.done();
  762. },
  763. /**
  764. * tests whether DOMInput whether abort can be called even if loading is finished already
  765. * @author Jeroen van Rotterdam
  766. * @author X-Hive Corporation
  767. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-abort
  768. */
  769. DOMInputSourceTest4 : function (test) {
  770. var success, elementList, myString = "<?xml version='1.0' encoding='UTF-8'?>&lt;elt0>elt0&lt;/elt0>", implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  771. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  772. implementation = getImplementation();
  773. lsImplementation = implementation;
  774. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  775. writer = lsImplementation.createLSSerializer();
  776. inputSource = lsImplementation.createLSInput();
  777. inputSource.stringData = myString;
  778. document = builder.parse(inputSource);
  779. builder.abort();
  780. test.done();
  781. },
  782. /**
  783. * Parses a document containing an external entity and checks
  784. that resource resolver is passed the baseURI value specified on LSInput.
  785. * @author Jeroen van Rotterdam
  786. * @author X-Hive Corporation
  787. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSInput-systemId
  788. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSInput-publicId
  789. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSInput-baseURI
  790. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSResourceResolver-resolveResource
  791. */
  792. DOMInputSourceTest5 : function (test) {
  793. function LSResourceResolverN1002A() {}
  794. /**
  795. *
  796. * Allow the application to resolve external resources.
  797. * TheLSParserwill call this method before opening any external resource,
  798. * including the external DTD subset, external entities referenced within the DTD,
  799. * and external entities referenced within the document element (however, the
  800. * top-level document entity is not passed to this method). The application may then
  801. * request that theLSParserresolve the external resource itself, that it use an
  802. * alternative URI, or that it use an entirely different input source.
  803. *
  804. * Application writers can use this method to redirect external system identifiers to
  805. * secure and/or local URI, to look up public identifiers in a catalogue, or to read
  806. * an entity from a database or other input source (including, for example, a dialog box).
  807. *
  808. * @param type
  809. * The type of the resource being resolved. For XMLresources (i.e. entities), applications must
  810. * use the value"http://www.w3.org/TR/REC-xml". For XML Schema, applications must use the
  811. * value"http://www.w3.org/2001/XMLSchema". Other types of resources are outside the scope of
  812. * this specification and therefore should recommend an absolute URI in order to use this method.
  813. * @param namespaceURI
  814. * The namespace of the resource being resolved, e.g. the target namespace of the XML Schemawhen
  815. * resolving XML Schema resources.
  816. * @param publicId
  817. * The public identifier of the external entity being referenced, ornullif no public identifier
  818. * was supplied or if the resource is not an entity.
  819. * @param systemId
  820. * The system identifier, a URI reference, of the external resource being referenced, ornullif no
  821. * system identifier was supplied.
  822. * @param baseURI
  823. * The absolute base URI of the resource being parsed, ornullif there is no base URI.
  824. */
  825. LSResourceResolverN1002A.prototype.resolveResource = function(type, namespaceURI, publicId, systemId, baseURI) {
  826. //
  827. // bring class variables into function scope
  828. //
  829. var domImplLS;
  830. var input;
  831. test.strictEqual("http://www.example.com/new_base",baseURI);
  832. test.strictEqual("-//X-Hive//native xml storage//EN",publicId);
  833. // TODO: implement this in a helper somewhere
  834. //assertURIEquals(test,null,null,null,null,"test5",null,null,true,systemId);
  835. domImplLS = getImplementation();
  836. input = domImplLS.createLSInput();
  837. input.stringData = "";
  838. return input;
  839. }
  840. var success;
  841. myentityresolver = new LSResourceResolverN1002A();
  842. var configuration, resourceURI, nodeList, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  843. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  844. implementation = getImplementation();
  845. lsImplementation = implementation;
  846. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  847. writer = lsImplementation.createLSSerializer();
  848. inputSource = lsImplementation.createLSInput();
  849. configuration = builder.domConfig;
  850. configuration.setParameter("resource-resolver", myentityresolver);
  851. configuration.setParameter("entities", false);
  852. // TODO: WTF IS THIS?
  853. //resourceURI = getResourceURI(TEST4);
  854. inputSource.systemId = resourceURI;
  855. inputSource.publicId = "-//X-Hive//native xml storage//DE";
  856. inputSource.baseURI = "http://www.example.com/new_base";
  857. document = builder.parse(inputSource);
  858. test.ok(document !== null, "documentNotNull");
  859. nodeList = document.getElementsByTagName("elt2");
  860. test.ok(0 === nodeList.length, "noElt2");
  861. nodeList = document.getElementsByTagName("elt1");
  862. test.ok(1 === nodeList.length, "hasElt1");
  863. test.done();
  864. },
  865. /**
  866. * Specify encodings for LSInput with a character stream. The
  867. setting should have no effect and the inputEncoding of the resulting document should be UTF-16.
  868. * @author Jeroen van Rotterdam
  869. * @author X-Hive Corporation
  870. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSInput-encoding
  871. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parse
  872. */
  873. DOMInputSourceTest6 : function (test) {
  874. var success, encodingString, myReader = "<?xml version='1.0' encoding='UTF-8'?>&lt;elt0>elt0&lt;/elt0>", implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  875. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  876. implementation = getImplementation();
  877. lsImplementation = implementation;
  878. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  879. writer = lsImplementation.createLSSerializer();
  880. inputSource = lsImplementation.createLSInput();
  881. inputSource.encoding = "UTF-8";
  882. inputSource.characterStream = myReader;
  883. document = builder.parse(inputSource);
  884. test.ok(document !== null, "documentNotNull");
  885. encodingString = document.inputEncoding;
  886. test.strictEqual("UTF-16".toLowerCase(), encodingString.toLowerCase(), "encodingstringcheck0");
  887. test.done();
  888. }, /**
  889. * DOMSerializerFilter test, a simple test eliminating a subtree
  890. * @author Jeroen van Rotterdam
  891. * @author X-Hive Corporation
  892. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-Interfaces-LSSerializerFilter
  893. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-LSSerializerFilter
  894. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializerFilter-acceptNode
  895. */
  896. DOMWriterFilterTest0 : function (test) {
  897. function LSSerializerFilterN10027(){};
  898. var success;
  899. myfilter = new LSSerializerFilterN10027();
  900. var configuration, stringDoc = "&lt;elt1>first elt1&lt;elt2>elt2&lt;/elt2>&lt;/elt1>", writeResult, length, elementList, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  901. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  902. implementation = getImplementation();
  903. lsImplementation = implementation;
  904. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  905. writer = lsImplementation.createLSSerializer();
  906. inputSource = lsImplementation.createLSInput();
  907. inputSource.stringData = stringDoc;
  908. document = builder.parse(inputSource);
  909. writer.filter = myfilter;
  910. writeResult = writer.writeToString(document);
  911. inputSource.stringData = writeResult;
  912. document = builder.parse(inputSource);
  913. elementList = document.getElementsByTagName("elt2");
  914. test.ok(0 === elementList.length, "count_elt2");
  915. elementList = document.getElementsByTagName("elt1");
  916. test.ok(1 === elementList.length, "count_elt1");
  917. test.done();
  918. }, /**
  919. * Uses a serializer filter to eliminate attributes, parses the output and checks if the attribute is not there.
  920. * @author Jeroen van Rotterdam
  921. * @author X-Hive Corporation
  922. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-Interfaces-LSSerializerFilter
  923. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-LSSerializerFilter
  924. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializerFilter-acceptNode
  925. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializerFilter-whatToShow
  926. */
  927. DOMWriterFilterTest1 : function (test) {
  928. function LSSerializerFilterN1002A(){}
  929. var success;
  930. myfilter = new LSSerializerFilterN1002A();
  931. var configuration, stringDoc = "&lt;elt1 attr1='attr1'>first elt1&lt;/elt1>", writeResult, length, elementList, elt1, attrNode, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  932. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  933. implementation = getImplementation();
  934. lsImplementation = implementation;
  935. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  936. writer = lsImplementation.createLSSerializer();
  937. inputSource = lsImplementation.createLSInput();
  938. inputSource.stringData = stringDoc;
  939. document = builder.parse(inputSource);
  940. writer.filter = myfilter;
  941. writeResult = writer.writeToString(document);
  942. inputSource.stringData = writeResult;
  943. document = builder.parse(inputSource);
  944. elementList = document.getElementsByTagName("elt1");
  945. test.ok(1 === elementList.length, "count_elt2");
  946. elt1 = elementList.item(0);
  947. attrNode = elt1.getAttributeNode("attr1");
  948. test.ok(attrNode === null, "attrib1");
  949. test.done();
  950. }, /**
  951. * Uses a filter to strip text during serialization
  952. parsers to check expections.
  953. * @author Jeroen van Rotterdam
  954. * @author X-Hive Corporation
  955. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-LSSerializerFilter
  956. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializerFilter-acceptNode
  957. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializerFilter-whatToShow
  958. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=643
  959. */
  960. DOMWriterFilterTest2 : function (test) {
  961. var success;
  962. function LSSerialiserFilterN1002A() {}
  963. myfilter = new LSSerializerFilterN1002A();
  964. var stringDoc = "&lt;elt1 attr1='attr1'>first elt1&lt;/elt1>", writeResult, length, elementList, elt1, childs, attrNode, attr1, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  965. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  966. implementation = getImplementation();
  967. lsImplementation = implementation;
  968. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  969. writer = lsImplementation.createLSSerializer();
  970. inputSource = lsImplementation.createLSInput();
  971. inputSource.stringData = stringDoc;
  972. document = builder.parse(inputSource);
  973. writer.filter = myfilter;
  974. writeResult = writer.writeToString(document);
  975. inputSource.stringData = writeResult;
  976. document = builder.parse(inputSource);
  977. elementList = document.getElementsByTagName("elt1");
  978. elt1 = elementList.item(0);
  979. attrNode = elt1.getAttributeNode("attr1");
  980. test.ok(attrNode !== null, "attrExists");
  981. attr1 = attrNode.nodeValue;
  982. test.strictEqual("attr1", attr1, "attrUnchanged");
  983. childs = elt1.hasChildNodes();
  984. test.ok(childs === false, "nodeHasChilds_elt1");
  985. test.done();
  986. }, /**
  987. * Eliminates comments on serialization, parses results and checks for comments.
  988. * @author Jeroen van Rotterdam
  989. * @author X-Hive Corporation
  990. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-LSSerializerFilter
  991. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializerFilter-acceptNode
  992. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializerFilter-whatToShow
  993. */
  994. DOMWriterFilterTest3 : function (test) {
  995. var success;
  996. function LSSerializerFilterN10027() {}
  997. myfilter = new LSSerializerFilterN10027();
  998. var configuration, stringDoc = "&lt;elt1>&lt;elt2>elt2&lt;/elt2><!--comment1-->&lt;/elt1>", writeResult, length, elementList, children, elt1, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  999. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  1000. implementation = getImplementation();
  1001. lsImplementation = implementation;
  1002. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  1003. writer = lsImplementation.createLSSerializer();
  1004. inputSource = lsImplementation.createLSInput();
  1005. inputSource.stringData = stringDoc;
  1006. document = builder.parse(inputSource);
  1007. writer.filter = myfilter;
  1008. writeResult = writer.writeToString(document);
  1009. inputSource.stringData = writeResult;
  1010. document = builder.parse(inputSource);
  1011. elementList = document.getElementsByTagName("elt1");
  1012. test.ok(1 === elementList.length, "count_elt1");
  1013. elt1 = elementList.item(0);
  1014. children = elt1.childNodes;
  1015. test.ok(1 === children.length, "count_children");
  1016. test.done();
  1017. },
  1018. /**
  1019. * Calls LSSerializer.writeToString and checks result.
  1020. * @author Jeroen van Rotterdam
  1021. * @author X-Hive Corporation
  1022. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  1023. */
  1024. DOMWriterTest0 : function (test) {
  1025. var success, stringDoc, writeResult, elementList, resourceURI, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  1026. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  1027. implementation = getImplementation();
  1028. lsImplementation = implementation;
  1029. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  1030. writer = lsImplementation.createLSSerializer();
  1031. inputSource = lsImplementation.createLSInput();
  1032. resourceURI = getResourceURI(TEST0);
  1033. document = builder.parseURI(resourceURI);
  1034. writeResult = writer.writeToString(document);
  1035. inputSource.stringData = writeResult;
  1036. document = builder.parse(inputSource);
  1037. elementList = document.getElementsByTagName("elt2");
  1038. test.ok(1 === elementList.length, "elt2Count_1");
  1039. test.done();
  1040. },
  1041. /**
  1042. * Writes an element node to a byte stream.
  1043. * @author Jeroen van Rotterdam
  1044. * @author X-Hive Corporation
  1045. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSOutput-byteStream
  1046. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-write
  1047. */
  1048. DOMWriterTest1 : function (test) {
  1049. var success, stringDoc, writeResult, elementList, firstElt3, output, outputStream, inputStream = null;
  1050. var resourceURI, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  1051. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  1052. implementation = getImplementation();
  1053. lsImplementation = implementation;
  1054. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  1055. writer = lsImplementation.createLSSerializer();
  1056. inputSource = lsImplementation.createLSInput();
  1057. resourceURI = getResourceURI(TEST2);
  1058. document = builder.parseURI(resourceURI);
  1059. elementList = document.getElementsByTagName("elt3");
  1060. firstElt3 = elementList.item(0);
  1061. output = lsImplementation.createLSOutput();
  1062. output.byteStream = outputStream;
  1063. writeResult = writer.write(firstElt3,output);
  1064. inputStream = outputStream;
  1065. inputSource.byteStream = inputStream;
  1066. document = builder.parse(inputSource);
  1067. elementList = document.getElementsByTagName("elt2");
  1068. test.ok(0 === elementList.length, "elt2Count_1");
  1069. test.done();
  1070. },
  1071. /**
  1072. * Serializes a document without a XML declaration for both for 'xml-declaration' configuration values.
  1073. * @author Jeroen van Rotterdam
  1074. * @author X-Hive Corporation
  1075. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#DOMConfiguration-canSetParameter
  1076. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-config
  1077. */
  1078. DOMWriterTest2 : function (test) {
  1079. var success, configuration, XML_DECLARATION = "xml-declaration", stringDoc = "&lt;hello>me again&lt;/hello>", writeResult, xmlDecl, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  1080. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  1081. implementation = getImplementation();
  1082. lsImplementation = implementation;
  1083. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  1084. writer = lsImplementation.createLSSerializer();
  1085. inputSource = lsImplementation.createLSInput();
  1086. inputSource.stringData = stringDoc;
  1087. document = builder.parse(inputSource);
  1088. configuration = writer.domConfig;
  1089. configuration.setParameter(XML_DECLARATION, false);
  1090. writeResult = writer.writeToString(document);
  1091. test.strictEqual(stringDoc, writeResult, "without_xml_declaration");
  1092. configuration.setParameter(XML_DECLARATION, true);
  1093. writeResult = writer.writeToString(document);
  1094. // TODO: umm.. what? are these tests complete?
  1095. // fail("Unrecognized method or attribute substring");
  1096. test.strictEqual("<?xml ", xmlDecl, "with_xml_declaration");
  1097. test.done();
  1098. },
  1099. /**
  1100. * Serializes a document with a XML declaration for both for 'xml-declaration' configuration values.
  1101. * @author Jeroen van Rotterdam
  1102. * @author X-Hive Corporation
  1103. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#DOMConfiguration-canSetParameter
  1104. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-config
  1105. */
  1106. DOMWriterTest3 : function (test) {
  1107. var success, configuration, XML_DECLARATION = "xml-declaration", stringDoc = "<?xml version='1.0'?>&lt;hello>me again&lt;/hello>", writeResult, xmlDecl, implementation, lsImplementation, inputSource, document, writer, builder, MODE_SYNCHRONOUS = 1, MODE_ASYNCHRONOUS = 2, DTD_SCHEMATYPE = "http://www.w3.org/TR/REC-xml", SCHEMA_SCHEMATYPE = "http://www.w3.org/2001/XMLSchema", NULL_SCHEMATYPE = null;
  1108. var ACTION_REPLACE_CHILDREN = 2, ACTION_APPEND_AS_CHILDREN = 1, ACTION_INSERT_AFTER = 4, ACTION_INSERT_BEFORE = 3, ACTION_REPLACE = 5, TEST0 = "test0", TEST1 = "test1", TEST2 = "test2", TEST3 = "test3", TEST4 = "test4", TEST5 = "test5", TEST6 = "test6", TEST7 = "test7", TESTPDF = "testpdf";
  1109. implementation = getImplementation();
  1110. lsImplementation = implementation;
  1111. builder = lsImplementation.createLSParser(MODE_SYNCHRONOUS,NULL_SCHEMATYPE);
  1112. writer = lsImplementation.createLSSerializer();
  1113. inputSource = lsImplementation.createLSInput();
  1114. inputSource.stringData = stringDoc;
  1115. document = builder.parse(inputSource);
  1116. configuration = writer.domConfig;
  1117. configuration.setParameter(XML_DECLARATION, false);
  1118. writeResult = writer.writeToString(document);
  1119. test.strictEqual("&lt;hello>me again&lt;/hello>", writeResult, "without_xml_declaration");
  1120. configuration.setParameter(XML_DECLARATION, true);
  1121. writeResult = writer.writeToString(document);
  1122. // TODO: umm.. what? are these tests complete?
  1123. // fail("Unrecognized method or attribute substring");
  1124. test.strictEqual("<?xml ", xmlDecl, "with_xml_declaration");
  1125. test.done();
  1126. },
  1127. /**
  1128. * Writes a document to an uninitialized LSOutput.
  1129. * @author Curt Arnold
  1130. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-write
  1131. */
  1132. DOMWriterTest4 : function (test) {
  1133. var success, testDoc, domImpl, output, serializer, status;
  1134. var testDocRef = null;
  1135. if (typeof(this.testDoc) != 'undefined') {
  1136. testDocRef = this.testDoc;
  1137. }
  1138. testDoc = load(testDocRef, "testDoc", "test0");
  1139. domImpl = getImplementation();
  1140. output = domImpl.createLSOutput();
  1141. serializer = domImpl.createLSSerializer();
  1142. {
  1143. success = false;
  1144. try {
  1145. status = serializer.write(testDoc,output);
  1146. }
  1147. catch(ex) {
  1148. success = (typeof(ex.code) != 'undefined' && ex.code == 82);
  1149. }
  1150. test.ok(success, "throw_SERIALIZE_ERR");
  1151. }
  1152. test.done();
  1153. },
  1154. /**
  1155. * Creates an document containing a namespaced attribute node without
  1156. user-specified prefix and checks that it is serialized properly.
  1157. * @author Curt Arnold
  1158. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-write
  1159. * @see http://lists.w3.org/Archives/Public/www-dom/2003OctDec/0062.html
  1160. */
  1161. DOMWriterTest5 : function (test) {
  1162. var success, domImpl, origDoc, nullDocType = null;
  1163. var namespaceURI = "http://www.example.com/DOMWriterTest5", docElem, outputString, input, serializer, parser, NULL_SCHEMA_TYPE = null;
  1164. var attrValue, parsedDoc, docElemLocalName, docElemNS;
  1165. domImpl = getImplementation();
  1166. origDoc = domImpl.createDocument(namespaceURI,"test",nullDocType);
  1167. docElem = origDoc.documentElement;
  1168. docElem.setAttributeNS(namespaceURI,"attr","test value");
  1169. serializer = domImpl.createLSSerializer();
  1170. outputString = serializer.writeToString(origDoc);
  1171. input = domImpl.createLSInput();
  1172. input.stringData = outputString;
  1173. parser = domImpl.createLSParser(1,NULL_SCHEMA_TYPE);
  1174. parsedDoc = parser.parse(input);
  1175. docElem = parsedDoc.documentElement;
  1176. docElemLocalName = docElem.localName;
  1177. test.strictEqual("test", docElemLocalName, "docElemLocalName");
  1178. docElemNS = docElem.namespaceURI;
  1179. test.strictEqual(namespaceURI, docElemNS, "docElemNS");
  1180. attrValue = docElem.getAttributeNS(namespaceURI,"attr");
  1181. test.strictEqual("test value", attrValue, "properNSAttrValue");
  1182. test.done();
  1183. },
  1184. /**
  1185. * Creates an document containing a namespaced attribute node with
  1186. user-specified prefix and checks that it is serialized properly.
  1187. * @author Curt Arnold
  1188. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-write
  1189. * @see http://lists.w3.org/Archives/Public/www-dom/2003OctDec/0062.html
  1190. */
  1191. DOMWriterTest6 : function (test) {
  1192. var success, domImpl, origDoc, nullDocType = null;
  1193. var namespaceURI = "http://www.example.com/DOMWriterTest5", docElem, outputString, input, serializer, parser, NULL_SCHEMA_TYPE = null;
  1194. var attrValue, parsedDoc, docElemLocalName, docElemNS;
  1195. domImpl = getImplementation();
  1196. origDoc = domImpl.createDocument(namespaceURI,"test",nullDocType);
  1197. docElem = origDoc.documentElement;
  1198. docElem.setAttributeNS(namespaceURI,"test:attr","test value");
  1199. serializer = domImpl.createLSSerializer();
  1200. outputString = serializer.writeToString(origDoc);
  1201. input = domImpl.createLSInput();
  1202. input.stringData = outputString;
  1203. parser = domImpl.createLSParser(1,NULL_SCHEMA_TYPE);
  1204. parsedDoc = parser.parse(input);
  1205. docElem = parsedDoc.documentElement;
  1206. docElemLocalName = docElem.localName;
  1207. test.strictEqual("test", docElemLocalName, "docElemLocalName");
  1208. docElemNS = docElem.namespaceURI;
  1209. test.strictEqual(namespaceURI, docElemNS, "docElemNS");
  1210. attrValue = docElem.getAttributeNS(namespaceURI,"attr");
  1211. test.strictEqual("test value", attrValue, "properNSAttrValue");
  1212. test.done();
  1213. },
  1214. /**
  1215. * DOMImplementationLS can be obtained by DOMImplementation.getFeature("LS", "3.0").
  1216. * @author Curt Arnold
  1217. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#DOMImplementation3-getFeature
  1218. */
  1219. GetFeature1 : function (test) {
  1220. var success, domImpl, domImplLS, output;
  1221. domImpl = getImplementation();
  1222. domImplLS = domImpl.getFeature("LS","3.0");
  1223. test.ok(domImplLS !== null, "domImplLSNotNull");
  1224. output = domImplLS.createLSOutput();
  1225. test.ok(output !== null, "outputNotNull");
  1226. test.done();
  1227. },
  1228. /**
  1229. * DOMImplementationLS can be obtained by DOMImplementation.getFeature("+lS", "3.0").
  1230. * @author Curt Arnold
  1231. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#DOMImplementation3-getFeature
  1232. */
  1233. GetFeature2 : function (test) {
  1234. var success, domImpl, domImplLS, output;
  1235. domImpl = getImplementation();
  1236. domImplLS = domImpl.getFeature("+lS","3.0");
  1237. test.ok(domImplLS !== null, "domImplLSNotNull");
  1238. output = domImplLS.createLSOutput();
  1239. test.ok(output !== null, "outputNotNull");
  1240. test.done();
  1241. },
  1242. /**
  1243. * Implementations should return true for hasFeature("LS", "3.0").
  1244. * @author Curt Arnold
  1245. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#ID-5CED94D7
  1246. */
  1247. HasFeature01 : function (test) {
  1248. var success, domImpl, hasLS;
  1249. domImpl = getImplementation();
  1250. hasLS = domImpl.hasFeature("LS","3.0");
  1251. test.ok(hasLS, "hasFeature_LS3");
  1252. test.done();
  1253. },
  1254. /**
  1255. * Implementations should return true for hasFeature("LS", null).
  1256. * @author Curt Arnold
  1257. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#ID-5CED94D7
  1258. */
  1259. HasFeature02 : function (test) {
  1260. var success, domImpl, hasLS, version = null;
  1261. domImpl = getImplementation();
  1262. hasLS = domImpl.hasFeature("LS",version);
  1263. test.ok(hasLS, "hasFeature_LS");
  1264. test.done();
  1265. },
  1266. /**
  1267. * Implementations should return true for hasFeature("Core", "2.0") and hasFeature("Core", null).
  1268. * @author Curt Arnold
  1269. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#ID-5CED94D7
  1270. */
  1271. HasFeature03 : function (test) {
  1272. var success, domImpl, hasLS, NULL_VERSION = null;
  1273. domImpl = getImplementation();
  1274. hasLS = domImpl.hasFeature("cOrE","2.0");
  1275. test.ok(hasLS, "hasFeature_Core2");
  1276. hasLS = domImpl.hasFeature("cOrE",NULL_VERSION);
  1277. test.ok(hasLS, "hasFeature_Core");
  1278. test.done();
  1279. },
  1280. /**
  1281. * Implementations should return true for hasFeature("+lS", "3.0").
  1282. * @author Curt Arnold
  1283. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#ID-5CED94D7
  1284. */
  1285. HasFeature04 : function (test) {
  1286. var success, domImpl, hasLS;
  1287. domImpl = getImplementation();
  1288. hasLS = domImpl.hasFeature("+lS","3.0");
  1289. test.ok(hasLS, "hasFeature_LS3");
  1290. test.done();
  1291. },
  1292. /**
  1293. * The return values of hasFeature("lS-aSynC", "3.0") and hasFeature("+Ls-AsYNc", "3.0") should be equal.
  1294. * @author Curt Arnold
  1295. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#ID-5CED94D7
  1296. */
  1297. HasFeature05 : function (test) {
  1298. var success, domImpl, hasLS1, hasLS2;
  1299. domImpl = getImplementation();
  1300. hasLS1 = domImpl.hasFeature("lS-aSynC","3.0");
  1301. hasLS2 = domImpl.hasFeature("+Ls-AsYNc","3.0");
  1302. test.strictEqual(hasLS1, hasLS2, "featuresEqual");
  1303. test.done();
  1304. },
  1305. /**
  1306. * Checks initial state of parser configuration.
  1307. * @author Curt Arnold
  1308. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-config
  1309. */
  1310. LSParserConfig1 : function (test) {
  1311. var success, domImpl, parser, config, state, resolver, NULL_SCHEMA_TYPE = null;
  1312. domImpl = getImplementation();
  1313. parser = domImpl.createLSParser(1,NULL_SCHEMA_TYPE);
  1314. config = parser.domConfig;
  1315. test.ok(config !== null, "configNotNull");
  1316. state = config.getParameter("cHarset-overrides-xml-encoding");
  1317. test.ok(state, "charset-overrides-xml-encoding-is-true");
  1318. state = config.getParameter("dIsallow-doctype");
  1319. test.ok(state === false, "disallow-doctype-is-false");
  1320. state = config.getParameter("iGnore-unknown-character-denormalizations");
  1321. test.ok(state, "ignore-unknown-character-denormalizations-is-true");
  1322. state = config.getParameter("iNfoset");
  1323. test.ok(state, "infoset-is-true");
  1324. state = config.getParameter("nAmespaces");
  1325. test.ok(state, "namespaces-is-true");
  1326. resolver = config.getParameter("rEsource-resolver");
  1327. test.ok(resolver === null, "resource-resolver-is-null");
  1328. state = config.getParameter("sUpported-media-types-only");
  1329. test.ok(state === false, "supported-media-types-only-is-false");
  1330. state = config.getParameter("wEll-formed");
  1331. test.ok(state, "well-formed-is-true");
  1332. test.done();
  1333. },
  1334. /**
  1335. * Checks getParameterNames and canSetParameter.
  1336. * @author Curt Arnold
  1337. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-config
  1338. */
  1339. LSParserConfig2 : function (test) {
  1340. var success, domImpl, parser, config, state, resolver, NULL_SCHEMA_TYPE = null;
  1341. var parameterNames, parameterName, matchCount = 0, paramValue, canSet;
  1342. domImpl = getImplementation();
  1343. parser = domImpl.createLSParser(1,NULL_SCHEMA_TYPE);
  1344. config = parser.domConfig;
  1345. test.ok(config !== null, "configNotNull");
  1346. parameterNames = config.parameterNames;
  1347. test.ok(parameterNames !== null, "parameterNamesNotNull");
  1348. for(var indexN10066 = 0;indexN10066 < parameterNames.length; indexN10066++) {
  1349. parameterName = parameterNames.item(indexN10066);
  1350. paramValue = config.getParameter(parameterName);
  1351. canSet = config.canSetParameter(parameterName,paramValue);
  1352. test.ok(canSet, "canSetToDefaultValue");
  1353. config.setParameter(parameterName, paramValue);
  1354. if(
  1355. (("canonical-form".toUpperCase() == parameterName.toUpperCase()) || ("cdata-sections".toUpperCase() == parameterName.toUpperCase()) || ("check-character-normalization".toUpperCase() == parameterName.toUpperCase()) || ("comments".toUpperCase() == parameterName.toUpperCase()) || ("datatype-normalization".toUpperCase() == parameterName.toUpperCase()) || ("entities".toUpperCase() == parameterName.toUpperCase()) || ("error-handler".toUpperCase() == parameterName.toUpperCase()) || ("infoset".toUpperCase() == parameterName.toUpperCase()) || ("namespaces".toUpperCase() == parameterName.toUpperCase()) || ("namespace-declarations".toUpperCase() == parameterName.toUpperCase()) || ("normalize-characters".toUpperCase() == parameterName.toUpperCase()) || ("schema-location".toUpperCase() == parameterName.toUpperCase()) || ("schema-type".toUpperCase() == parameterName.toUpperCase()) || ("split-cdata-sections".toUpperCase() == parameterName.toUpperCase()) || ("validate".toUpperCase() == parameterName.toUpperCase()) || ("validate-if-schema".toUpperCase() == parameterName.toUpperCase()) || ("well-formed".toUpperCase() == parameterName.toUpperCase()) || ("element-content-whitespace".toUpperCase() == parameterName.toUpperCase()) || ("charset-overrides-xml-encoding".toUpperCase() == parameterName.toUpperCase()) || ("disallow-doctype".toUpperCase() == parameterName.toUpperCase()) || ("ignore-unknown-character-denormalizations".toUpperCase() == parameterName.toUpperCase()) || ("resource-resolver".toUpperCase() == parameterName.toUpperCase()) || ("supported-media-types-only".toUpperCase() == parameterName.toUpperCase()))
  1356. ) {
  1357. matchCount += 1;
  1358. }
  1359. }
  1360. test.strictEqual(23, matchCount, "definedParameterCount");
  1361. test.done();
  1362. },
  1363. /**
  1364. * Checks support of charset-overrides-xml-encoding.
  1365. * @author Curt Arnold
  1366. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-config
  1367. */
  1368. LSParserConfig3 : function (test) {
  1369. var success, domImpl, parser, config, state, canSet, NULL_SCHEMA_TYPE = null;
  1370. var propertyName = "cHarset-overrides-xml-encoding";
  1371. domImpl = getImplementation();
  1372. parser = domImpl.createLSParser(1,NULL_SCHEMA_TYPE);
  1373. config = parser.domConfig;
  1374. test.ok(config !== null, "configNotNull");
  1375. state = config.getParameter(propertyName);
  1376. test.ok(state, "defaultValue");
  1377. canSet = config.canSetParameter(propertyName,true);
  1378. test.ok(canSet, "canSetTrue");
  1379. canSet = config.canSetParameter(propertyName,false);
  1380. test.ok(canSet, "canSetFalse");
  1381. config.setParameter(propertyName, false);
  1382. state = config.getParameter(propertyName);
  1383. test.ok(state === false, "setFalse");
  1384. config.setParameter(propertyName, true);
  1385. state = config.getParameter(propertyName);
  1386. test.ok(state, "setTrue");
  1387. test.done();
  1388. },
  1389. /**
  1390. * Checks support of disallow-doctype.
  1391. * @author Curt Arnold
  1392. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-config
  1393. */
  1394. LSParserConfig4 : function (test) {
  1395. var success, domImpl, parser, config, state, canSet, propertyName = "dIsAllow-doctype", NULL_SCHEMA_TYPE = null;
  1396. domImpl = getImplementation();
  1397. parser = domImpl.createLSParser(1,NULL_SCHEMA_TYPE);
  1398. config = parser.domConfig;
  1399. test.ok(config !== null, "configNotNull");
  1400. state = config.getParameter(propertyName);
  1401. test.ok(state === false, "defaultValue");
  1402. canSet = config.canSetParameter(propertyName,true);
  1403. if(canSet) {
  1404. config.setParameter(propertyName, true);
  1405. state = config.getParameter(propertyName);
  1406. test.ok(state, "setTrueIsEffective");
  1407. config.setParameter(propertyName, false);
  1408. state = config.getParameter(propertyName);
  1409. test.ok(state === false, "setFalseIsEffective");
  1410. } else {
  1411. config.setParameter(propertyName, false);
  1412. success = false;
  1413. try {
  1414. config.setParameter(propertyName, true);
  1415. } catch(ex) {
  1416. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  1417. }
  1418. test.ok(success, "throw_NOT_SUPPORTED_ERR_if_canSetParameter_false");
  1419. }
  1420. test.done();
  1421. },
  1422. /**
  1423. * Checks support of ignore-unknown-character-denormalizations.
  1424. * @author Curt Arnold
  1425. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-config
  1426. */
  1427. LSParserConfig5 : function (test) {
  1428. var success, domImpl, parser, config, state, canSet, propertyName = "iGnOre-unknown-character-denormalizations", NULL_SCHEMA_TYPE = null;
  1429. domImpl = getImplementation();
  1430. parser = domImpl.createLSParser(1,NULL_SCHEMA_TYPE);
  1431. config = parser.domConfig;
  1432. test.ok(config !== null, "configNotNull");
  1433. state = config.getParameter(propertyName);
  1434. test.ok(state, "defaultValue");
  1435. canSet = config.canSetParameter(propertyName,false);
  1436. if(canSet) {
  1437. config.setParameter(propertyName, false);
  1438. state = config.getParameter(propertyName);
  1439. test.ok(state === false, "setFalseIsEffective");
  1440. config.setParameter(propertyName, true);
  1441. state = config.getParameter(propertyName);
  1442. test.ok(state === false, "setTrueIsEffective");
  1443. } else {
  1444. config.setParameter(propertyName, true);
  1445. success = false;
  1446. try {
  1447. config.setParameter(propertyName, false);
  1448. } catch(ex) {
  1449. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  1450. }
  1451. test.ok(success, "throw_NOT_SUPPORTED_ERR_if_not_canSetParameter");
  1452. }
  1453. test.done();
  1454. },
  1455. /**
  1456. * Checks support of infoset.
  1457. * @author Curt Arnold
  1458. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-config
  1459. */
  1460. LSParserConfig6 : function (test) {
  1461. var success, domImpl, parser, config, state, canSet, NULL_SCHEMA_TYPE = null;
  1462. var propertyName = "iNfoset";
  1463. domImpl = getImplementation();
  1464. parser = domImpl.createLSParser(1,NULL_SCHEMA_TYPE);
  1465. config = parser.domConfig;
  1466. test.ok(config !== null, "configNotNull");
  1467. state = config.getParameter(propertyName);
  1468. test.ok(state, "defaultValue");
  1469. canSet = config.canSetParameter(propertyName,true);
  1470. test.ok(canSet, "canSetTrue");
  1471. canSet = config.canSetParameter(propertyName,false);
  1472. test.ok(canSet, "canSetFalse");
  1473. config.setParameter(propertyName, false);
  1474. state = config.getParameter(propertyName);
  1475. test.ok(state, "setFalse");
  1476. config.setParameter("comments", false);
  1477. state = config.getParameter(propertyName);
  1478. test.ok(state === false, "falseWhenCommentsFalse");
  1479. config.setParameter(propertyName, true);
  1480. state = config.getParameter(propertyName);
  1481. test.ok(state, "resetTrue");
  1482. state = config.getParameter("comments");
  1483. test.ok(state, "resetTrueComments");
  1484. test.done();
  1485. },
  1486. /**
  1487. * Checks support of namespaces.
  1488. * @author Curt Arnold
  1489. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-config
  1490. */
  1491. LSParserConfig7 : function (test) {
  1492. var success, domImpl, parser, config, state, canSet, propertyName = "nAmespaces", NULL_SCHEMA_TYPE = null;
  1493. domImpl = getImplementation();
  1494. parser = domImpl.createLSParser(1,NULL_SCHEMA_TYPE);
  1495. config = parser.domConfig;
  1496. test.ok(config !== null, "configNotNull");
  1497. state = config.getParameter(propertyName);
  1498. test.ok(state, "defaultValue");
  1499. canSet = config.canSetParameter(propertyName,false);
  1500. if(canSet) {
  1501. config.setParameter(propertyName, false);
  1502. state = config.getParameter(propertyName);
  1503. test.ok(state === false, "setFalseIsEffective");
  1504. config.setParameter(propertyName, true);
  1505. state = config.getParameter(propertyName);
  1506. test.ok(state, "setTrueIsEffective");
  1507. } else {
  1508. config.setParameter(propertyName, true);
  1509. success = false;
  1510. try {
  1511. config.setParameter(propertyName, false);
  1512. } catch(ex) {
  1513. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  1514. }
  1515. test.ok(success, "throw_NOT_SUPPORTED_ERR_if_not_canSetParameter");
  1516. }
  1517. test.done();
  1518. },
  1519. /**
  1520. * Checks support of well-formed.
  1521. * @author Curt Arnold
  1522. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-config
  1523. */
  1524. LSParserConfig8 : function (test) {
  1525. var success, domImpl, parser, config, state, canSet, NULL_SCHEMA_TYPE = null;
  1526. var propertyName = "wEll-formed";
  1527. domImpl = getImplementation();
  1528. parser = domImpl.createLSParser(1,NULL_SCHEMA_TYPE);
  1529. config = parser.domConfig;
  1530. test.ok(config !== null, "configNotNull");
  1531. state = config.getParameter(propertyName);
  1532. test.ok(state, "defaultValue");
  1533. canSet = config.canSetParameter(propertyName,true);
  1534. test.ok(canSet, "canSetTrue");
  1535. canSet = config.canSetParameter(propertyName,false);
  1536. test.ok(canSet === false, "canSetFalse");
  1537. success = false;
  1538. try {
  1539. config.setParameter(propertyName, false);
  1540. } catch(ex) {
  1541. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  1542. }
  1543. test.ok(success, "throw_NOT_SUPPORTED_EXCEPTION");
  1544. test.done();
  1545. },
  1546. /**
  1547. * Checks support of supported-media-types-only.
  1548. * @author Curt Arnold
  1549. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-config
  1550. */
  1551. LSParserConfig9 : function (test) {
  1552. var success, domImpl, parser, config, state, canSet, propertyName = "sUpported-media-types-only", NULL_SCHEMA_TYPE = null;
  1553. domImpl = getImplementation();
  1554. parser = domImpl.createLSParser(1,NULL_SCHEMA_TYPE);
  1555. config = parser.domConfig;
  1556. test.ok(config !== null, "configNotNull");
  1557. state = config.getParameter(propertyName);
  1558. test.ok(state === false, "defaultValue");
  1559. canSet = config.canSetParameter(propertyName,true);
  1560. if(canSet) {
  1561. config.setParameter(propertyName, true);
  1562. state = config.getParameter(propertyName);
  1563. test.ok(state, "setTrueIsEffective");
  1564. config.setParameter(propertyName, false);
  1565. state = config.getParameter(propertyName);
  1566. test.ok(state === false, "setFalseIsEffective");
  1567. } else {
  1568. config.setParameter(propertyName, false);
  1569. success = false;
  1570. try {
  1571. config.setParameter(propertyName, true);
  1572. } catch(ex) {
  1573. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  1574. }
  1575. test.ok(success, "throw_NOT_SUPPORTED_ERR_if_canSetParameter_false");
  1576. }
  1577. test.done();
  1578. },
  1579. /**
  1580. * Checks initial state of serializer configuration.
  1581. * @author Curt Arnold
  1582. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-config
  1583. */
  1584. LSSerializerConfig1 : function (test) {
  1585. var success, domImpl, serializer, config, state, canSet;
  1586. domImpl = getImplementation();
  1587. serializer = domImpl.createLSSerializer();
  1588. config = serializer.domConfig;
  1589. test.ok(config !== null, "configNotNull");
  1590. state = config.getParameter("cAnonical-form");
  1591. test.ok(state === false, "canonical-form-is-false");
  1592. state = config.getParameter("dIscard-default-content");
  1593. test.ok(state, "discard-default-content-is-true");
  1594. state = config.getParameter("fOrmat-pretty-print");
  1595. test.ok(state === false, "format-pretty-print-is-false");
  1596. state = config.getParameter("iGnore-unknown-character-denormalizations");
  1597. test.ok(state, "ignore-unknown-character-denormalizations-is-true");
  1598. state = config.getParameter("nOrmalize-characters");
  1599. canSet = config.canSetParameter("normalize-characters",true);
  1600. assertTrue("normalize-characters-default", (state ||
  1601. !canSet));
  1602. state = config.getParameter("xMl-declaration");
  1603. test.ok(state, "xml-declaration-is-true");
  1604. state = config.getParameter("wEll-formed");
  1605. test.ok(state, "well-formed-is-true");
  1606. state = config.getParameter("nAmespaces");
  1607. test.ok(state, "namespaces-is-true");
  1608. state = config.getParameter("nAmespace-declarations");
  1609. test.ok(state, "namespace-declarations-is-true");
  1610. test.done();
  1611. },
  1612. /**
  1613. * Checks support of namespace-declarations.
  1614. * @author Curt Arnold
  1615. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-config
  1616. */
  1617. LSSerializerConfig10 : function (test) {
  1618. var success, domImpl, serializer, config, state, canSet, propertyName = "nAmespace-declarations";
  1619. domImpl = getImplementation();
  1620. serializer = domImpl.createLSSerializer();
  1621. config = serializer.domConfig;
  1622. test.ok(config !== null, "configNotNull");
  1623. state = config.getParameter(propertyName);
  1624. test.ok(state, "defaultValue");
  1625. canSet = config.canSetParameter(propertyName,true);
  1626. test.ok(canSet, "canSetTrue");
  1627. canSet = config.canSetParameter(propertyName,false);
  1628. test.ok(canSet, "canSetFalse");
  1629. config.setParameter(propertyName, false);
  1630. state = config.getParameter(propertyName);
  1631. test.ok(state === false, "setFalseIsEffective");
  1632. config.setParameter(propertyName, true);
  1633. state = config.getParameter(propertyName);
  1634. test.ok(state, "setTrueIsEffective");
  1635. test.done();
  1636. },
  1637. /**
  1638. * Checks getParameterNames and canSetParameter.
  1639. * @author Curt Arnold
  1640. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-config
  1641. */
  1642. LSSerializerConfig2 : function (test) {
  1643. var success, domImpl, serializer, config, state, parameterNames, parameterName, matchCount = 0, paramValue, canSet;
  1644. domImpl = getImplementation();
  1645. serializer = domImpl.createLSSerializer();
  1646. config = serializer.domConfig;
  1647. test.ok(config !== null, "configNotNull");
  1648. parameterNames = config.parameterNames;
  1649. test.ok(parameterNames !== null, "parameterNamesNotNull");
  1650. for(var indexN1005B = 0;indexN1005B < parameterNames.length; indexN1005B++) {
  1651. parameterName = parameterNames.item(indexN1005B);
  1652. paramValue = config.getParameter(parameterName);
  1653. canSet = config.canSetParameter(parameterName,paramValue);
  1654. test.ok(canSet, "canSetToDefaultValue");
  1655. config.setParameter(parameterName, paramValue);
  1656. if(
  1657. (("canonical-form".toUpperCase() == parameterName.toUpperCase()) || ("cdata-sections".toUpperCase() == parameterName.toUpperCase()) || ("check-character-normalization".toUpperCase() == parameterName.toUpperCase()) || ("comments".toUpperCase() == parameterName.toUpperCase()) || ("datatype-normalization".toUpperCase() == parameterName.toUpperCase()) || ("entities".toUpperCase() == parameterName.toUpperCase()) || ("error-handler".toUpperCase() == parameterName.toUpperCase()) || ("infoset".toUpperCase() == parameterName.toUpperCase()) || ("namespaces".toUpperCase() == parameterName.toUpperCase()) || ("namespace-declarations".toUpperCase() == parameterName.toUpperCase()) || ("normalize-characters".toUpperCase() == parameterName.toUpperCase()) || ("split-cdata-sections".toUpperCase() == parameterName.toUpperCase()) || ("validate".toUpperCase() == parameterName.toUpperCase()) || ("validate-if-schema".toUpperCase() == parameterName.toUpperCase()) || ("well-formed".toUpperCase() == parameterName.toUpperCase()) || ("element-content-whitespace".toUpperCase() == parameterName.toUpperCase()) || ("discard-default-content".toUpperCase() == parameterName.toUpperCase()) || ("format-pretty-print".toUpperCase() == parameterName.toUpperCase()) || ("ignore-unknown-character-denormalizations".toUpperCase() == parameterName.toUpperCase()) || ("xml-declaration".toUpperCase() == parameterName.toUpperCase()))
  1658. ) {
  1659. matchCount += 1;
  1660. }
  1661. }
  1662. test.strictEqual(20, matchCount, "definedParameterCount");
  1663. test.done();
  1664. },
  1665. /**
  1666. * Checks support of canonical-form.
  1667. * @author Curt Arnold
  1668. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-config
  1669. */
  1670. LSSerializerConfig3 : function (test) {
  1671. var success, domImpl, serializer, config, state, canSet, propertyName = "cAnonical-form";
  1672. domImpl = getImplementation();
  1673. serializer = domImpl.createLSSerializer();
  1674. config = serializer.domConfig;
  1675. test.ok(config !== null, "configNotNull");
  1676. state = config.getParameter(propertyName);
  1677. test.ok(state === false, "defaultValue");
  1678. canSet = config.canSetParameter(propertyName,true);
  1679. if(
  1680. canSet
  1681. ) {
  1682. config.setParameter(propertyName, true);
  1683. state = config.getParameter(propertyName);
  1684. test.ok(state, "setTrueIsEffective");
  1685. config.setParameter(propertyName, false);
  1686. state = config.getParameter(propertyName);
  1687. test.ok(state === false, "setFalseIsEffective");
  1688. }
  1689. else {
  1690. config.setParameter(propertyName, false);
  1691. {
  1692. success = false;
  1693. try {
  1694. config.setParameter(propertyName, true);
  1695. }
  1696. catch(ex) {
  1697. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  1698. }
  1699. test.ok(success, "throw_NOT_SUPPORTED_ERR_if_canSetParameter_false");
  1700. }
  1701. }
  1702. test.done();
  1703. },
  1704. /**
  1705. * Checks support of discard-default-content.
  1706. * @author Curt Arnold
  1707. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-config
  1708. */
  1709. LSSerializerConfig4 : function (test) {
  1710. var success, domImpl, serializer, config, state, canSet, propertyName = "dIscard-default-content";
  1711. domImpl = getImplementation();
  1712. serializer = domImpl.createLSSerializer();
  1713. config = serializer.domConfig;
  1714. test.ok(config !== null, "configNotNull");
  1715. state = config.getParameter(propertyName);
  1716. test.ok(state, "defaultValue");
  1717. canSet = config.canSetParameter(propertyName,true);
  1718. test.ok(canSet, "canSetTrue");
  1719. canSet = config.canSetParameter(propertyName,false);
  1720. test.ok(canSet, "canSetFalse");
  1721. config.setParameter(propertyName, false);
  1722. state = config.getParameter(propertyName);
  1723. test.ok(state === false, "setFalse");
  1724. config.setParameter(propertyName, true);
  1725. state = config.getParameter(propertyName);
  1726. test.ok(state, "setTrue");
  1727. test.done();
  1728. },
  1729. /**
  1730. * Checks support of format-pretty-print.
  1731. * @author Curt Arnold
  1732. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-config
  1733. */
  1734. LSSerializerConfig5 : function (test) {
  1735. var success, domImpl, serializer, config, state, canSet, propertyName = "fOrmat-pretty-print";
  1736. domImpl = getImplementation();
  1737. serializer = domImpl.createLSSerializer();
  1738. config = serializer.domConfig;
  1739. test.ok(config !== null, "configNotNull");
  1740. state = config.getParameter(propertyName);
  1741. test.ok(state === false, "defaultValue");
  1742. canSet = config.canSetParameter(propertyName,true);
  1743. if(
  1744. canSet
  1745. ) {
  1746. config.setParameter(propertyName, true);
  1747. state = config.getParameter(propertyName);
  1748. test.ok(state, "setTrueIsEffective");
  1749. config.setParameter(propertyName, false);
  1750. state = config.getParameter(propertyName);
  1751. test.ok(state === false, "setFalseIsEffective");
  1752. }
  1753. else {
  1754. config.setParameter(propertyName, false);
  1755. {
  1756. success = false;
  1757. try {
  1758. config.setParameter(propertyName, true);
  1759. }
  1760. catch(ex) {
  1761. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  1762. }
  1763. test.ok(success, "throw_NOT_SUPPORTED_ERR_if_canSetParameter_false");
  1764. }
  1765. }
  1766. test.done();
  1767. },
  1768. /**
  1769. * Checks support of ignore-unknown-character-denormalizations.
  1770. * @author Curt Arnold
  1771. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-config
  1772. */
  1773. LSSerializerConfig6 : function (test) {
  1774. var success, domImpl, serializer, config, state, canSet, propertyName = "iGnore-unknown-character-denormalizations";
  1775. domImpl = getImplementation();
  1776. serializer = domImpl.createLSSerializer();
  1777. config = serializer.domConfig;
  1778. test.ok(config !== null, "configNotNull");
  1779. state = config.getParameter(propertyName);
  1780. test.ok(state, "defaultValue");
  1781. canSet = config.canSetParameter(propertyName,false);
  1782. if(
  1783. canSet
  1784. ) {
  1785. config.setParameter(propertyName, false);
  1786. state = config.getParameter(propertyName);
  1787. test.ok(state === false, "setFalseIsEffective");
  1788. config.setParameter(propertyName, true);
  1789. state = config.getParameter(propertyName);
  1790. test.ok(state, "setTrueIsEffective");
  1791. }
  1792. else {
  1793. config.setParameter(propertyName, true);
  1794. {
  1795. success = false;
  1796. try {
  1797. config.setParameter(propertyName, false);
  1798. }
  1799. catch(ex) {
  1800. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  1801. }
  1802. test.ok(success, "throw_NOT_SUPPORTED_ERR_if_canSetParameter_false");
  1803. }
  1804. }
  1805. test.done();
  1806. },
  1807. /**
  1808. * Checks support of xml-declaration.
  1809. * @author Curt Arnold
  1810. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-config
  1811. */
  1812. LSSerializerConfig7 : function (test) {
  1813. var success, domImpl, serializer, config, state, canSet, propertyName = "xMl-declaration";
  1814. domImpl = getImplementation();
  1815. serializer = domImpl.createLSSerializer();
  1816. config = serializer.domConfig;
  1817. test.ok(config !== null, "configNotNull");
  1818. state = config.getParameter(propertyName);
  1819. test.ok(state, "defaultValue");
  1820. canSet = config.canSetParameter(propertyName,true);
  1821. test.ok(canSet, "canSetTrue");
  1822. canSet = config.canSetParameter(propertyName,false);
  1823. test.ok(canSet, "canSetFalse");
  1824. config.setParameter(propertyName, false);
  1825. state = config.getParameter(propertyName);
  1826. test.ok(state === false, "setFalse");
  1827. config.setParameter(propertyName, true);
  1828. state = config.getParameter(propertyName);
  1829. test.ok(state, "setTrue");
  1830. test.done();
  1831. },
  1832. /**
  1833. * Checks support of well-formed.
  1834. * @author Curt Arnold
  1835. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-config
  1836. */
  1837. LSSerializerConfig8 : function (test) {
  1838. var success, domImpl, serializer, config, state, canSet, propertyName = "wEll-formed";
  1839. domImpl = getImplementation();
  1840. serializer = domImpl.createLSSerializer();
  1841. config = serializer.domConfig;
  1842. test.ok(config !== null, "configNotNull");
  1843. state = config.getParameter(propertyName);
  1844. test.ok(state, "defaultValue");
  1845. canSet = config.canSetParameter(propertyName,true);
  1846. test.ok(canSet, "canSetTrue");
  1847. canSet = config.canSetParameter(propertyName,false);
  1848. if(
  1849. canSet
  1850. ) {
  1851. config.setParameter(propertyName, false);
  1852. state = config.getParameter(propertyName);
  1853. test.ok(state === false, "setFalseIsEffective");
  1854. config.setParameter(propertyName, true);
  1855. state = config.getParameter(propertyName);
  1856. test.ok(state, "setTrueIsEffective");
  1857. }
  1858. else {
  1859. {
  1860. success = false;
  1861. try {
  1862. config.setParameter(propertyName, false);
  1863. }
  1864. catch(ex) {
  1865. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  1866. }
  1867. test.ok(success, "throw_NOT_SUPPORTED_EXCEPTION");
  1868. }
  1869. }
  1870. test.done();
  1871. },
  1872. /**
  1873. * Checks support of namespaces.
  1874. * @author Curt Arnold
  1875. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-config
  1876. */
  1877. LSSerializerConfig9 : function (test) {
  1878. var success, domImpl, serializer, config, state, canSet, propertyName = "nAmespaces";
  1879. domImpl = getImplementation();
  1880. serializer = domImpl.createLSSerializer();
  1881. config = serializer.domConfig;
  1882. test.ok(config !== null, "configNotNull");
  1883. state = config.getParameter(propertyName);
  1884. test.ok(state, "defaultValue");
  1885. canSet = config.canSetParameter(propertyName,true);
  1886. test.ok(canSet, "canSetTrue");
  1887. canSet = config.canSetParameter(propertyName,false);
  1888. if(
  1889. canSet
  1890. ) {
  1891. config.setParameter(propertyName, false);
  1892. state = config.getParameter(propertyName);
  1893. test.ok(state === false, "setFalseIsEffective");
  1894. config.setParameter(propertyName, true);
  1895. state = config.getParameter(propertyName);
  1896. test.ok(state, "setTrueIsEffective");
  1897. }
  1898. else {
  1899. {
  1900. success = false;
  1901. try {
  1902. config.setParameter(propertyName, false);
  1903. }
  1904. catch(ex) {
  1905. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  1906. }
  1907. test.ok(success, "settingFalseWhenNotSupported");
  1908. }
  1909. }
  1910. test.done();
  1911. },
  1912. /**
  1913. * Writes a document to a URL for a temporary file and rereads the document.
  1914. * @author Curt Arnold
  1915. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSInput-systemId
  1916. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSOutput-systemId
  1917. */
  1918. SystemId1 : function (test) {
  1919. var success, testDoc, domImpl, output, serializer, systemId, checkSystemId, status, input, parser, checkDoc, docElem, docElemName, NULL_SCHEMA_TYPE = null;
  1920. var testDocRef = null;
  1921. if (typeof(this.testDoc) != 'undefined') {
  1922. testDocRef = this.testDoc;
  1923. }
  1924. testDoc = load(testDocRef, "testDoc", "test0");
  1925. domImpl = getImplementation();
  1926. output = domImpl.createLSOutput();
  1927. checkSystemId = output.systemId;
  1928. test.ok(checkSystemId === null, "LSOutputSystemIdInitiallyNull");
  1929. // TODO: umm.. what? are these tests complete?
  1930. // fail("Unrecognized method or attribute createTempURI");
  1931. output.systemId = systemId;
  1932. checkSystemId = output.systemId;
  1933. test.strictEqual(systemId, checkSystemId, "LSOutputSystemIdMatch");
  1934. serializer = domImpl.createLSSerializer();
  1935. status = serializer.write(testDoc,output);
  1936. test.ok(status, "writeStatus");
  1937. input = domImpl.createLSInput();
  1938. checkSystemId = input.systemId;
  1939. test.ok(checkSystemId === null, "LSInputSystemIdInitiallyNull");
  1940. input.systemId = systemId;
  1941. checkSystemId = input.systemId;
  1942. test.strictEqual(systemId, checkSystemId, "LSInputSystemIdMatch");
  1943. parser = domImpl.createLSParser(1,NULL_SCHEMA_TYPE);
  1944. checkDoc = parser.parse(input);
  1945. test.ok(checkDoc !== null, "checkNotNull");
  1946. docElem = checkDoc.documentElement;
  1947. docElemName = docElem.nodeName;
  1948. test.strictEqual("elt0", docElemName, "checkDocElemName");
  1949. test.done();
  1950. },
  1951. /**
  1952. * Writes a document to a URL for a temporary http document and rereads the document.
  1953. * @author Curt Arnold
  1954. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSInput-systemId
  1955. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSOutput-systemId
  1956. */
  1957. SystemId2 : function (test) {
  1958. var success, testDoc, domImpl, output, serializer, systemId, checkSystemId, status, input, parser, checkDoc, docElem, docElemName, NULL_SCHEMA_TYPE = null;
  1959. var testDocRef = null;
  1960. if (typeof(this.testDoc) != 'undefined') {
  1961. testDocRef = this.testDoc;
  1962. }
  1963. testDoc = load(testDocRef, "testDoc", "test0");
  1964. domImpl = getImplementation();
  1965. output = domImpl.createLSOutput();
  1966. checkSystemId = output.systemId;
  1967. test.ok(checkSystemId === null, "LSOutputSystemIdInitiallyNull");
  1968. // TODO: umm.. what? are these tests complete?
  1969. // fail("Unrecognized method or attribute createTempURI");
  1970. output.systemId = systemId;
  1971. checkSystemId = output.systemId;
  1972. test.strictEqual(systemId, checkSystemId, "LSOutputSystemIdMatch");
  1973. serializer = domImpl.createLSSerializer();
  1974. status = serializer.write(testDoc,output);
  1975. test.ok(status, "writeStatus");
  1976. input = domImpl.createLSInput();
  1977. checkSystemId = input.systemId;
  1978. test.ok(checkSystemId === null, "LSInputSystemIdInitiallyNull");
  1979. input.systemId = systemId;
  1980. checkSystemId = input.systemId;
  1981. test.strictEqual(systemId, checkSystemId, "LSInputSystemIdMatch");
  1982. parser = domImpl.createLSParser(1,NULL_SCHEMA_TYPE);
  1983. checkDoc = parser.parse(input);
  1984. test.ok(checkDoc !== null, "checkNotNull");
  1985. docElem = checkDoc.documentElement;
  1986. docElemName = docElem.nodeName;
  1987. test.strictEqual("elt0", docElemName, "checkDocElemName");
  1988. test.done();
  1989. },
  1990. /**
  1991. *
  1992. Load a document with canonical-form = true and see that entity references are not present in
  1993. the element content.
  1994. * @author Curt Arnold
  1995. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  1996. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-canonical-form
  1997. */
  1998. canonicalform01 : function (test) {
  1999. var success, doc, docElem, elemList, elem, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  2000. var resourceURI, canSet;
  2001. domImplLS = getImplementation();
  2002. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  2003. domConfig = lsParser.domConfig;
  2004. canSet = domConfig.canSetParameter("canonical-form",true);
  2005. if(
  2006. canSet
  2007. ) {
  2008. domConfig.setParameter("canonical-form", true);
  2009. resourceURI = getResourceURI("hc_staff");
  2010. doc = lsParser.parseURI(resourceURI);
  2011. elemList = doc.getElementsByTagName("acronym");
  2012. elem = elemList.item(1);
  2013. node = elem.firstChild;
  2014. nodeType = node.nodeType;
  2015. test.strictEqual(3, nodeType, "acrContentIsText");
  2016. }
  2017. test.done();
  2018. },
  2019. /**
  2020. *
  2021. Load a document with canonical-form = true and see that CDATASection are not present in
  2022. the parsed document.
  2023. * @author Curt Arnold
  2024. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2025. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-canonical-form
  2026. */
  2027. canonicalform03 : function (test) {
  2028. var success, doc, elem, node, nodeType, domConfig, pList, domImplLS, lsParser, nullSchemaType = null;
  2029. var resourceURI, canSet;
  2030. domImplLS = getImplementation();
  2031. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  2032. domConfig = lsParser.domConfig;
  2033. canSet = domConfig.canSetParameter("canonical-form",true);
  2034. if(
  2035. canSet
  2036. ) {
  2037. domConfig.setParameter("canonical-form", true);
  2038. resourceURI = getResourceURI("hc_staff");
  2039. doc = lsParser.parseURI(resourceURI);
  2040. pList = doc.getElementsByTagName("strong");
  2041. elem = pList.item(1);
  2042. node = elem.lastChild;
  2043. nodeType = node.nodeType;
  2044. test.strictEqual(3, nodeType, "childIsText");
  2045. }
  2046. test.done();
  2047. },
  2048. /**
  2049. *
  2050. Attempt to load a namespace invalid document with canonical-form = true.
  2051. * @author Curt Arnold
  2052. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2053. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-canonical-form
  2054. */
  2055. canonicalform04 : function (test) {
  2056. var success, doc, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  2057. var resourceURI, canSet;
  2058. domImplLS = getImplementation();
  2059. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  2060. domConfig = lsParser.domConfig;
  2061. canSet = domConfig.canSetParameter("canonical-form",true);
  2062. if(
  2063. canSet
  2064. ) {
  2065. domConfig.setParameter("canonical-form", true);
  2066. resourceURI = getResourceURI("namespaces1");
  2067. {
  2068. success = false;
  2069. try {
  2070. doc = lsParser.parseURI(resourceURI);
  2071. }
  2072. catch(ex) {
  2073. success = (typeof(ex.code) != 'undefined' && ex.code == 81);
  2074. }
  2075. test.ok(success, "throw_PARSE_ERR");
  2076. }
  2077. }
  2078. test.done();
  2079. },
  2080. /**
  2081. *
  2082. Load a document with canonical-form = true and see that attributes for namespace declarations are present.
  2083. * @author Curt Arnold
  2084. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2085. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-namespace-declarations
  2086. */
  2087. canonicalform05 : function (test) {
  2088. var success, doc, docElem, elemList, elem, node, nodeType, domConfig, domImplLS, lsParser, canSet, nullSchemaType = null;
  2089. var resourceURI;
  2090. domImplLS = getImplementation();
  2091. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  2092. domConfig = lsParser.domConfig;
  2093. canSet = domConfig.canSetParameter("canonical-form",true);
  2094. if(
  2095. canSet
  2096. ) {
  2097. domConfig.setParameter("canonical-form", true);
  2098. resourceURI = getResourceURI("hc_staff");
  2099. doc = lsParser.parseURI(resourceURI);
  2100. elemList = doc.getElementsByTagName("p");
  2101. elem = elemList.item(0);
  2102. node = elem.getAttributeNode("xmlns:dmstc");
  2103. test.ok(node !== null, "nsAttrNotNull");
  2104. }
  2105. test.done();
  2106. },
  2107. /**
  2108. *
  2109. Load a document with canonical-form and validate = true and check that
  2110. element content whitespace is not eliminated.
  2111. * @author Curt Arnold
  2112. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2113. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-canonical-form
  2114. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate
  2115. */
  2116. canonicalform06 : function (test) {
  2117. var success, doc, elem, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  2118. var resourceURI, canSetValidate, canSetCanonicalForm, elemList;
  2119. domImplLS = getImplementation();
  2120. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  2121. domConfig = lsParser.domConfig;
  2122. canSetValidate = domConfig.canSetParameter("validate",true);
  2123. canSetCanonicalForm = domConfig.canSetParameter("canonical-form",true);
  2124. if(
  2125. (canSetValidate && canSetCanonicalForm)
  2126. ) {
  2127. domConfig.setParameter("validate", true);
  2128. domConfig.setParameter("canonical-form", true);
  2129. resourceURI = getResourceURI("hc_staff");
  2130. doc = lsParser.parseURI(resourceURI);
  2131. elemList = doc.getElementsByTagName("p");
  2132. elem = elemList.item(0);
  2133. node = elem.firstChild;
  2134. nodeType = node.nodeType;
  2135. test.strictEqual(3, nodeType, "nodeIsText");
  2136. }
  2137. test.done();
  2138. },
  2139. /**
  2140. *
  2141. Normalize document based on section 3.1 with canonical-form set to true and check normalized document.
  2142. * @author Curt Arnold
  2143. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2144. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-canonical-form
  2145. */
  2146. canonicalform08 : function (test) {
  2147. var success, doc, bodyList, body, domConfig, canSet, canSetValidate, node, nodeName, nodeValue, nodeType, length, text, domImplLS, lsParser, nullSchemaType = null;
  2148. var resourceURI, canSetCanonicalForm;
  2149. domImplLS = getImplementation();
  2150. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  2151. domConfig = lsParser.domConfig;
  2152. canSetCanonicalForm = domConfig.canSetParameter("canonical-form",true);
  2153. if(
  2154. canSetCanonicalForm
  2155. ) {
  2156. domConfig.setParameter("canonical-form", true);
  2157. resourceURI = getResourceURI("canonicalform01");
  2158. doc = lsParser.parseURI(resourceURI);
  2159. node = doc.firstChild;
  2160. nodeType = node.nodeType;
  2161. test.strictEqual(7, nodeType, "PIisFirstChild");
  2162. nodeValue = node.data;
  2163. length = nodeValue.length;
  2164. test.strictEqual(36, length, "piDataLength");
  2165. node = node.nextSibling;
  2166. nodeType = node.nodeType;
  2167. test.strictEqual(3, nodeType, "TextisSecondChild");
  2168. nodeValue = node.nodeValue;
  2169. length = nodeValue.length;
  2170. test.strictEqual(1, length, "secondChildLength");
  2171. node = node.nextSibling;
  2172. nodeType = node.nodeType;
  2173. test.strictEqual(1, nodeType, "ElementisThirdChild");
  2174. node = node.nextSibling;
  2175. nodeType = node.nodeType;
  2176. test.strictEqual(3, nodeType, "TextisFourthChild");
  2177. nodeValue = node.nodeValue;
  2178. length = nodeValue.length;
  2179. test.strictEqual(1, length, "fourthChildLength");
  2180. node = node.nextSibling;
  2181. nodeType = node.nodeType;
  2182. test.strictEqual(7, nodeType, "PIisFifthChild");
  2183. nodeValue = node.data;
  2184. test.strictEqual("", nodeValue, "trailingPIData");
  2185. node = node.nextSibling;
  2186. nodeType = node.nodeType;
  2187. test.strictEqual(3, nodeType, "TextisSixthChild");
  2188. nodeValue = node.nodeValue;
  2189. length = nodeValue.length;
  2190. test.strictEqual(1, length, "sixthChildLength");
  2191. node = node.nextSibling;
  2192. nodeType = node.nodeType;
  2193. test.strictEqual(8, nodeType, "CommentisSeventhChild");
  2194. node = node.nextSibling;
  2195. nodeType = node.nodeType;
  2196. test.strictEqual(3, nodeType, "TextisEighthChild");
  2197. nodeValue = node.nodeValue;
  2198. length = nodeValue.length;
  2199. test.strictEqual(1, length, "eighthChildLength");
  2200. node = node.nextSibling;
  2201. nodeType = node.nodeType;
  2202. test.strictEqual(8, nodeType, "CommentisNinthChild");
  2203. node = node.nextSibling;
  2204. test.ok(node === null, "TenthIsNull");
  2205. }
  2206. test.done();
  2207. },
  2208. /**
  2209. *
  2210. Normalize document based on section 3.1 with canonical-form set to true
  2211. and comments to false and check normalized document.
  2212. * @author Curt Arnold
  2213. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2214. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-canonical-form
  2215. */
  2216. canonicalform09 : function (test) {
  2217. var success, doc, bodyList, body, domConfig, canSet, canSetValidate, node, nodeName, nodeValue, nodeType, length, text, domImplLS, lsParser, nullSchemaType = null;
  2218. var resourceURI, canSetCanonicalForm;
  2219. domImplLS = getImplementation();
  2220. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  2221. domConfig = lsParser.domConfig;
  2222. canSetCanonicalForm = domConfig.canSetParameter("canonical-form",true);
  2223. if(
  2224. canSetCanonicalForm
  2225. ) {
  2226. domConfig.setParameter("canonical-form", true);
  2227. domConfig.setParameter("comments", false);
  2228. resourceURI = getResourceURI("canonicalform01");
  2229. doc = lsParser.parseURI(resourceURI);
  2230. node = doc.firstChild;
  2231. nodeType = node.nodeType;
  2232. test.strictEqual(7, nodeType, "PIisFirstChild");
  2233. nodeValue = node.data;
  2234. length = nodeValue.length;
  2235. test.strictEqual(36, length, "piDataLength");
  2236. node = node.nextSibling;
  2237. nodeType = node.nodeType;
  2238. test.strictEqual(3, nodeType, "TextisSecondChild");
  2239. nodeValue = node.nodeValue;
  2240. length = nodeValue.length;
  2241. test.strictEqual(1, length, "secondChildLength");
  2242. node = node.nextSibling;
  2243. nodeType = node.nodeType;
  2244. test.strictEqual(1, nodeType, "ElementisThirdChild");
  2245. node = node.nextSibling;
  2246. nodeType = node.nodeType;
  2247. test.strictEqual(3, nodeType, "TextisFourthChild");
  2248. nodeValue = node.nodeValue;
  2249. length = nodeValue.length;
  2250. test.strictEqual(1, length, "fourthChildLength");
  2251. node = node.nextSibling;
  2252. nodeType = node.nodeType;
  2253. test.strictEqual(7, nodeType, "PIisFifthChild");
  2254. nodeValue = node.data;
  2255. test.strictEqual("", nodeValue, "trailingPIData");
  2256. node = node.nextSibling;
  2257. test.ok(node === null, "SixthIsNull");
  2258. }
  2259. test.done();
  2260. },
  2261. /**
  2262. *
  2263. Check elimination of unnecessary namespace prefixes when
  2264. normalized with canonical-form = true.
  2265. * @author Curt Arnold
  2266. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2267. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-canonical-form
  2268. */
  2269. canonicalform10 : function (test) {
  2270. var success, doc, divList, div, domConfig, node, domImplLS, lsParser, nullSchemaType = null;
  2271. var resourceURI, canSetCanonicalForm;
  2272. domImplLS = getImplementation();
  2273. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  2274. domConfig = lsParser.domConfig;
  2275. canSetCanonicalForm = domConfig.canSetParameter("canonical-form",true);
  2276. if(
  2277. canSetCanonicalForm
  2278. ) {
  2279. domConfig.setParameter("canonical-form", true);
  2280. resourceURI = getResourceURI("canonicalform03");
  2281. doc = lsParser.parseURI(resourceURI);
  2282. divList = doc.getElementsByTagName("div");
  2283. div = divList.item(5);
  2284. node = div.getAttributeNode("xmlns");
  2285. test.ok(node !== null, "xmlnsPresent");
  2286. node = div.getAttributeNode("xmlns:a");
  2287. test.ok(node === null, "xmlnsANotPresent");
  2288. }
  2289. test.done();
  2290. },
  2291. /**
  2292. *
  2293. Check that default attributes are made explicitly specified.
  2294. * @author Curt Arnold
  2295. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2296. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-canonical-form
  2297. */
  2298. canonicalform11 : function (test) {
  2299. var success, doc, elemList, elem, domConfig, attr, attrValue, attrSpecified, domImplLS, lsParser, nullSchemaType = null;
  2300. var resourceURI, canSetCanonicalForm;
  2301. domImplLS = getImplementation();
  2302. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  2303. domConfig = lsParser.domConfig;
  2304. canSetCanonicalForm = domConfig.canSetParameter("canonical-form",true);
  2305. if(
  2306. canSetCanonicalForm
  2307. ) {
  2308. domConfig.setParameter("canonical-form", true);
  2309. resourceURI = getResourceURI("canonicalform03");
  2310. doc = lsParser.parseURI(resourceURI);
  2311. elemList = doc.getElementsByTagName("acronym");
  2312. elem = elemList.item(0);
  2313. attr = elem.getAttributeNode("title");
  2314. test.ok(attr !== null, "titlePresent");
  2315. attrSpecified = attr.specified;
  2316. test.ok(attrSpecified, "titleSpecified");
  2317. attrValue = attr.nodeValue;
  2318. test.strictEqual("default", attrValue, "titleValue");
  2319. }
  2320. test.done();
  2321. },
  2322. /**
  2323. *
  2324. Load a document with canonical-form = true and see that the DocumentType node is eliminated.
  2325. * @author Curt Arnold
  2326. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2327. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-canonical-form
  2328. */
  2329. canonicalform12 : function (test) {
  2330. var success, doc, doctype, domConfig, domImplLS, lsParser, nullSchemaType = null;
  2331. var resourceURI, canSet;
  2332. domImplLS = getImplementation();
  2333. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  2334. domConfig = lsParser.domConfig;
  2335. canSet = domConfig.canSetParameter("canonical-form",true);
  2336. if(
  2337. canSet
  2338. ) {
  2339. domConfig.setParameter("canonical-form", true);
  2340. resourceURI = getResourceURI("hc_staff");
  2341. doc = lsParser.parseURI(resourceURI);
  2342. doctype = doc.doctype;
  2343. test.ok(doctype === null, "doctypeIsNull");
  2344. }
  2345. test.done();
  2346. },
  2347. /**
  2348. *
  2349. Serializing an XML 1.1 document when canonical-form raises a SERIALIZE_ERR.
  2350. * @author Curt Arnold
  2351. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  2352. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-canonical-form
  2353. */
  2354. canonicalform13 : function (test) {
  2355. var success, doc, domConfig, domImplLS, lsSerializer, docType = null;
  2356. var output, canSet;
  2357. domImplLS = getImplementation();
  2358. lsSerializer = domImplLS.createLSSerializer();
  2359. domConfig = lsSerializer.domConfig;
  2360. canSet = domConfig.canSetParameter("canonical-form",true);
  2361. if(
  2362. canSet
  2363. ) {
  2364. domConfig.setParameter("", true);
  2365. doc = domImplLS.createDocument("http://www.example.org","test",docType);
  2366. try {
  2367. doc.xmlVersion = "1.1";
  2368. } catch (ex) {
  2369. if (typeof(ex.code) != 'undefined') {
  2370. switch(ex.code) {
  2371. case /* NOT_SUPPORTED_ERR */ 9 :
  2372. return ;
  2373. default:
  2374. throw ex;
  2375. }
  2376. } else {
  2377. throw ex;
  2378. }
  2379. }
  2380. {
  2381. success = false;
  2382. try {
  2383. output = lsSerializer.writeToString(doc);
  2384. }
  2385. catch(ex) {
  2386. success = (typeof(ex.code) != 'undefined' && ex.code == 82);
  2387. }
  2388. test.ok(success, "throw_SERIALIZE_ERR");
  2389. }
  2390. }
  2391. test.done();
  2392. },
  2393. /**
  2394. *
  2395. Load a document with cdata-sections = false and see that CDATASection are not present in
  2396. the parsed document.
  2397. * @author Curt Arnold
  2398. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2399. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-cdata-sections
  2400. */
  2401. cdatasections01 : function (test) {
  2402. var success, doc, elem, node, nodeType, domConfig, pList, domImplLS, lsParser, nullSchemaType = null;
  2403. var resourceURI;
  2404. domImplLS = getImplementation();
  2405. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  2406. domConfig = lsParser.domConfig;
  2407. domConfig.setParameter("cdata-sections", false);
  2408. resourceURI = getResourceURI("hc_staff");
  2409. doc = lsParser.parseURI(resourceURI);
  2410. pList = doc.getElementsByTagName("strong");
  2411. elem = pList.item(1);
  2412. node = elem.lastChild;
  2413. nodeType = node.nodeType;
  2414. test.strictEqual(3, nodeType, "childIsText");
  2415. test.done();
  2416. },
  2417. /**
  2418. *
  2419. Load a document with cdata-sections = true and see that CDATASection are present in
  2420. the parsed document.
  2421. * @author Curt Arnold
  2422. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2423. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-cdata-sections
  2424. */
  2425. cdatasections02 : function (test) {
  2426. var success, doc, elem, node, nodeType, domConfig, pList, domImplLS, lsParser, nullSchemaType = null;
  2427. var resourceURI;
  2428. domImplLS = getImplementation();
  2429. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  2430. domConfig = lsParser.domConfig;
  2431. domConfig.setParameter("cdata-sections", true);
  2432. resourceURI = getResourceURI("hc_staff");
  2433. doc = lsParser.parseURI(resourceURI);
  2434. pList = doc.getElementsByTagName("strong");
  2435. elem = pList.item(1);
  2436. node = elem.lastChild;
  2437. nodeType = node.nodeType;
  2438. test.strictEqual(4, nodeType, "childIsCDATA");
  2439. test.done();
  2440. },
  2441. /**
  2442. *
  2443. CDATASections should be preserved when cdata-sections is true.
  2444. * @author Curt Arnold
  2445. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  2446. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-cdata-sections
  2447. */
  2448. cdatasections03 : function (test) {
  2449. var success, doc, domConfig, domImplLS, lsSerializer, docType = null;
  2450. var docElem, newNode, output, retNode;
  2451. domImplLS = getImplementation();
  2452. lsSerializer = domImplLS.createLSSerializer();
  2453. doc = domImplLS.createDocument("http://www.example.org","test",docType);
  2454. docElem = doc.documentElement;
  2455. newNode = doc.createCDATASection("foo");
  2456. retNode = docElem.appendChild(newNode);
  2457. domConfig = lsSerializer.domConfig;
  2458. domConfig.setParameter("cdata-sections", true);
  2459. output = lsSerializer.writeToString(doc);
  2460. test.ok(output.indexOf("![CDATA[foo]]") >= 0, "containsCDATA");
  2461. test.done();
  2462. },
  2463. /**
  2464. *
  2465. CDATASections should be eliminated when cdata-sections is false.
  2466. * @author Curt Arnold
  2467. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  2468. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-cdata-sections
  2469. */
  2470. cdatasections04 : function (test) {
  2471. var success, doc, domConfig, domImplLS, lsSerializer, docType = null;
  2472. var docElem, newNode, output, retNode;
  2473. domImplLS = getImplementation();
  2474. lsSerializer = domImplLS.createLSSerializer();
  2475. doc = domImplLS.createDocument("http://www.example.org","test",docType);
  2476. docElem = doc.documentElement;
  2477. newNode = doc.createCDATASection("foo");
  2478. retNode = docElem.appendChild(newNode);
  2479. domConfig = lsSerializer.domConfig;
  2480. domConfig.setParameter("cdata-sections", false);
  2481. output = lsSerializer.writeToString(doc);
  2482. test.ok(output.indexOf("&gt;foo&lt;/") >= 0, "containsCDATA");
  2483. test.done();
  2484. },
  2485. /**
  2486. *
  2487. Parsing a non-Unicode normalized document should not raise an exception if check-character-normalization
  2488. is false.
  2489. * @author Curt Arnold
  2490. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2491. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-check-character-normalization
  2492. */
  2493. checkcharacternormalization01 : function (test) {
  2494. var success, doc, domConfig, domImplLS, lsParser, resourceURI, nullSchemaLanguage = null;
  2495. domImplLS = getImplementation();
  2496. lsParser = domImplLS.createLSParser(1,nullSchemaLanguage);
  2497. domConfig = lsParser.domConfig;
  2498. domConfig.setParameter("check-character-normalization", false);
  2499. resourceURI = getResourceURI("characternormalization1");
  2500. doc = lsParser.parseURI(resourceURI);
  2501. test.ok(doc !== null, "docNotNull");
  2502. test.done();
  2503. },
  2504. /**
  2505. *
  2506. Parsing a non-Unicode normalized document should raise PARSE_ERR if check-character-normalization
  2507. is false.
  2508. * @author Curt Arnold
  2509. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2510. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-check-character-normalization
  2511. */
  2512. checkcharacternormalization02 : function (test) {
  2513. var success, doc, domConfig, domImplLS, lsParser, resourceURI, canSet, nullSchemaLanguage = null;
  2514. errorMonitor = new DOMErrorMonitor();
  2515. var errors = new Array();
  2516. var error, severity, type, errorCount = 0;
  2517. domImplLS = getImplementation();
  2518. lsParser = domImplLS.createLSParser(1,nullSchemaLanguage);
  2519. domConfig = lsParser.domConfig;
  2520. canSet = domConfig.canSetParameter("check-character-normalization",true);
  2521. if(
  2522. canSet
  2523. ) {
  2524. domConfig.setParameter("check-character-normalization", true);
  2525. domConfig.setParameter("error-handler", errorMonitor.handleError);
  2526. resourceURI = getResourceURI("characternormalization1");
  2527. {
  2528. success = false;
  2529. try {
  2530. doc = lsParser.parseURI(resourceURI);
  2531. }
  2532. catch(ex) {
  2533. success = (typeof(ex.code) != 'undefined' && ex.code == 81);
  2534. }
  2535. test.ok(success, "throw_PARSE_ERR");
  2536. }
  2537. errors = errorMonitor.allErrors;
  2538. for(var indexN1008E = 0;indexN1008E < errors.length; indexN1008E++) {
  2539. error = errors[indexN1008E];
  2540. severity = error.severity;
  2541. type = error.type;
  2542. if(
  2543. (severity > 1)
  2544. ) {
  2545. test.strictEqual(2, severity, "isError");
  2546. test.strictEqual("check-character-normalization-failure", type, "isCheck_Failure");
  2547. errorCount += 1;
  2548. }
  2549. }
  2550. test.strictEqual(1, errorCount, "oneError");
  2551. }
  2552. test.done();
  2553. },
  2554. /**
  2555. *
  2556. Characters should not be checked for normalization on serialization if check-character-normalization = false.
  2557. * @author Curt Arnold
  2558. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  2559. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-check-character-normalization
  2560. */
  2561. checkcharacternormalization03 : function (test) {
  2562. var success, doc, domConfig, domImplLS, lsSerializer, docType = null;
  2563. var docElem, newNode, output, retNode;
  2564. domImplLS = getImplementation();
  2565. lsSerializer = domImplLS.createLSSerializer();
  2566. doc = domImplLS.createDocument("http://www.example.org","suçon",docType);
  2567. docElem = doc.documentElement;
  2568. domConfig = lsSerializer.domConfig;
  2569. domConfig.setParameter("check-character-normalization", false);
  2570. domConfig.setParameter("normalize-characters", false);
  2571. output = lsSerializer.writeToString(doc);
  2572. test.done();
  2573. },
  2574. /**
  2575. *
  2576. Characters should be checked for normalization on serialization if check-character-normalization = true.
  2577. * @author Curt Arnold
  2578. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  2579. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-check-character-normalization
  2580. */
  2581. checkcharacternormalization04 : function (test) {
  2582. var success, doc, domConfig, domImplLS, lsSerializer, docType = null;
  2583. var docElem, newNode, output, retNode;
  2584. errorMonitor = new DOMErrorMonitor();
  2585. var errors = new Array();
  2586. var error, severity, type, canSet, errorCount = 0;
  2587. domImplLS = getImplementation();
  2588. lsSerializer = domImplLS.createLSSerializer();
  2589. doc = domImplLS.createDocument("http://www.example.org","suçon",docType);
  2590. docElem = doc.documentElement;
  2591. domConfig = lsSerializer.domConfig;
  2592. canSet = domConfig.canSetParameter("check-character-normalization",true);
  2593. if(
  2594. canSet
  2595. ) {
  2596. domConfig.setParameter("check-character-normalization", true);
  2597. domConfig.setParameter("normalize-characters", false);
  2598. domConfig.setParameter("error-handler", errorMonitor.handleError);
  2599. {
  2600. success = false;
  2601. try {
  2602. output = lsSerializer.writeToString(doc);
  2603. }
  2604. catch(ex) {
  2605. success = (typeof(ex.code) != 'undefined' && ex.code == 82);
  2606. }
  2607. test.ok(success, "throw_SERIALIZE_ERR");
  2608. }
  2609. errors = errorMonitor.allErrors;
  2610. for(var indexN100A3 = 0;indexN100A3 < errors.length; indexN100A3++) {
  2611. error = errors[indexN100A3];
  2612. severity = error.severity;
  2613. type = error.type;
  2614. if(("check-character-normalization-failure" == type)) {
  2615. test.strictEqual(2, severity, "severityError");
  2616. errorCount += 1;
  2617. }
  2618. }
  2619. assertTrue("hasErrors", (errorCount > 0));
  2620. }
  2621. test.done();
  2622. },
  2623. /**
  2624. *
  2625. Load a document with comments = false and see that comments are not present in
  2626. the parsed document.
  2627. * @author Curt Arnold
  2628. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2629. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-comments
  2630. */
  2631. comments01 : function (test) {
  2632. var success, doc, docElem, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  2633. var resourceURI;
  2634. domImplLS = getImplementation();
  2635. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  2636. domConfig = lsParser.domConfig;
  2637. domConfig.setParameter("comments", false);
  2638. resourceURI = getResourceURI("hc_staff");
  2639. doc = lsParser.parseURI(resourceURI);
  2640. docElem = doc.documentElement;
  2641. node = docElem.previousSibling;
  2642. nodeType = node.nodeType;
  2643. test.strictEqual(10, nodeType, "nodeIsDocType");
  2644. test.done();
  2645. },
  2646. /**
  2647. *
  2648. Load a document with comments = true and see that comments are present in
  2649. the parsed document.
  2650. * @author Curt Arnold
  2651. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2652. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-comments
  2653. */
  2654. comments02 : function (test) {
  2655. var success, doc, docElem, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  2656. var resourceURI;
  2657. domImplLS = getImplementation();
  2658. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  2659. domConfig = lsParser.domConfig;
  2660. domConfig.setParameter("comments", true);
  2661. resourceURI = getResourceURI("hc_staff");
  2662. doc = lsParser.parseURI(resourceURI);
  2663. docElem = doc.documentElement;
  2664. node = docElem.previousSibling;
  2665. nodeType = node.nodeType;
  2666. test.strictEqual(8, nodeType, "nodeIsDocType");
  2667. test.done();
  2668. },
  2669. /**
  2670. *
  2671. Comments should be preserved when comments is true.
  2672. * @author Curt Arnold
  2673. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  2674. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-comments
  2675. */
  2676. comments03 : function (test) {
  2677. var success, doc, domConfig, domImplLS, lsSerializer, docType = null;
  2678. var docElem, newNode, output, retNode;
  2679. domImplLS = getImplementation();
  2680. lsSerializer = domImplLS.createLSSerializer();
  2681. doc = domImplLS.createDocument("http://www.example.org","test",docType);
  2682. docElem = doc.documentElement;
  2683. newNode = doc.createComment("foo");
  2684. retNode = docElem.appendChild(newNode);
  2685. domConfig = lsSerializer.domConfig;
  2686. domConfig.setParameter("comments", true);
  2687. output = lsSerializer.writeToString(doc);
  2688. test.ok(output.indexOf("&gt;&lt;!--foo--&gt;&lt;/") >= 0, "hasComment");
  2689. test.done();
  2690. },
  2691. /**
  2692. *
  2693. Comments should be discarded when comments is false.
  2694. * @author Curt Arnold
  2695. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  2696. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-comments
  2697. */
  2698. comments04 : function (test) {
  2699. var success, doc, domConfig, domImplLS, lsSerializer, docType = null;
  2700. var docElem, newNode, output, retNode;
  2701. domImplLS = getImplementation();
  2702. lsSerializer = domImplLS.createLSSerializer();
  2703. doc = domImplLS.createDocument("http://www.example.org","test",docType);
  2704. docElem = doc.documentElement;
  2705. newNode = doc.createComment("foo");
  2706. retNode = docElem.appendChild(newNode);
  2707. domConfig = lsSerializer.domConfig;
  2708. domConfig.setParameter("comments", false);
  2709. output = lsSerializer.writeToString(doc);
  2710. {
  2711. test.ok((output.indexOf("<!--") >= 0) === false, "noComment");
  2712. }
  2713. test.done();
  2714. },
  2715. /**
  2716. *
  2717. Normalize document with datatype-normalization set to true.
  2718. Check if double values were normalized.
  2719. * @author Curt Arnold
  2720. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2721. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-datatype-normalization
  2722. */
  2723. datatypenormalization01 : function (test) {
  2724. var success, doc, elemList, element, domConfig, str, canSetNormalization, canSetValidate, canSetXMLSchema, xsdNS = "http://www.w3.org/2001/XMLSchema", domImplLS, lsParser, resourceURI;
  2725. domImplLS = getImplementation();
  2726. lsParser = domImplLS.createLSParser(1,xsdNS);
  2727. if(
  2728. (lsParser == null)
  2729. ) {
  2730. return ;
  2731. }
  2732. domConfig = lsParser.domConfig;
  2733. canSetNormalization = domConfig.canSetParameter("datatype-normalization",true);
  2734. canSetValidate = domConfig.canSetParameter("validate",true);
  2735. canSetXMLSchema = domConfig.canSetParameter("schema-type",xsdNS);
  2736. if(
  2737. (canSetNormalization && canSetValidate && canSetXMLSchema)
  2738. ) {
  2739. domConfig.setParameter("datatype-normalization", true);
  2740. domConfig.setParameter("validate", true);
  2741. domConfig.setParameter("schema-type", xsdNS);
  2742. resourceURI = getResourceURI("datatype_normalization");
  2743. doc = lsParser.parseURI(resourceURI);
  2744. elemList = doc.getElementsByTagNameNS("http://www.w3.org/2001/DOM-Test-Suite/Level-3/datatype_normalization","double");
  2745. element = elemList.item(0);
  2746. str = element.getAttribute("value");
  2747. test.strictEqual("+0003.141592600E+0000", str, "firstValue");
  2748. str = element.getAttribute("union");
  2749. test.strictEqual("+0003.141592600E+0000", str, "firstUnion");
  2750. str = element.textContent;
  2751. test.strictEqual("-31415926.00E-7 2.718", str, "firstList");
  2752. element = elemList.item(1);
  2753. str = element.getAttribute("value");
  2754. test.strictEqual("NaN", str, "secondValue");
  2755. str = element.getAttribute("union");
  2756. test.strictEqual("NaN", str, "secondUnion");
  2757. str = element.textContent;
  2758. test.strictEqual("INF -INF", str, "secondList");
  2759. element = elemList.item(2);
  2760. str = element.getAttribute("value");
  2761. test.strictEqual("1", str, "thirdValue");
  2762. str = element.getAttribute("union");
  2763. test.strictEqual("1", str, "thirdUnion");
  2764. str = element.textContent;
  2765. test.strictEqual("-0", str, "thirdList");
  2766. }
  2767. test.done();
  2768. },
  2769. /**
  2770. *
  2771. Normalize document with datatype-normalization set to true.
  2772. Check if decimal values were normalized.
  2773. * @author Curt Arnold
  2774. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2775. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-datatype-normalization
  2776. */
  2777. datatypenormalization02 : function (test) {
  2778. var success, doc, elemList, element, domConfig, str, canSetNormalization, canSetValidate, canSetXMLSchema, xsdNS = "http://www.w3.org/2001/XMLSchema", domImplLS, lsParser, resourceURI;
  2779. domImplLS = getImplementation();
  2780. lsParser = domImplLS.createLSParser(1,xsdNS);
  2781. if(
  2782. (lsParser == null)
  2783. ) {
  2784. return ;
  2785. }
  2786. domConfig = lsParser.domConfig;
  2787. canSetNormalization = domConfig.canSetParameter("datatype-normalization",true);
  2788. canSetValidate = domConfig.canSetParameter("validate",true);
  2789. canSetXMLSchema = domConfig.canSetParameter("schema-type",xsdNS);
  2790. if(
  2791. (canSetNormalization && canSetValidate && canSetXMLSchema)
  2792. ) {
  2793. domConfig.setParameter("datatype-normalization", true);
  2794. domConfig.setParameter("validate", true);
  2795. domConfig.setParameter("schema-type", xsdNS);
  2796. resourceURI = getResourceURI("datatype_normalization");
  2797. doc = lsParser.parseURI(resourceURI);
  2798. elemList = doc.getElementsByTagNameNS("http://www.w3.org/2001/DOM-Test-Suite/Level-3/datatype_normalization","decimal");
  2799. element = elemList.item(0);
  2800. str = element.getAttribute("value");
  2801. test.strictEqual("+0003.141592600", str, "firstValue");
  2802. str = element.getAttribute("union");
  2803. test.strictEqual("+0003.141592600", str, "firstUnion");
  2804. str = element.textContent;
  2805. test.strictEqual("+10 .1", str, "firstList");
  2806. element = elemList.item(1);
  2807. str = element.getAttribute("value");
  2808. test.strictEqual("01", str, "secondValue");
  2809. str = element.getAttribute("union");
  2810. test.strictEqual("01", str, "secondUnion");
  2811. str = element.textContent;
  2812. test.strictEqual("-.001", str, "secondList");
  2813. }
  2814. test.done();
  2815. },
  2816. /**
  2817. *
  2818. Normalize document with datatype-normalization set to true.
  2819. Check if boolean values were whitespace normalized.
  2820. * @author Curt Arnold
  2821. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2822. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-datatype-normalization
  2823. */
  2824. datatypenormalization03 : function (test) {
  2825. var success, doc, elemList, element, domConfig, str, canSetNormalization, canSetValidate, canSetXMLSchema, xsdNS = "http://www.w3.org/2001/XMLSchema", domImplLS, lsParser, resourceURI;
  2826. domImplLS = getImplementation();
  2827. lsParser = domImplLS.createLSParser(1,xsdNS);
  2828. if(
  2829. (lsParser == null)
  2830. ) {
  2831. return ;
  2832. }
  2833. domConfig = lsParser.domConfig;
  2834. canSetNormalization = domConfig.canSetParameter("datatype-normalization",true);
  2835. canSetValidate = domConfig.canSetParameter("validate",true);
  2836. canSetXMLSchema = domConfig.canSetParameter("schema-type",xsdNS);
  2837. if(
  2838. (canSetNormalization && canSetValidate && canSetXMLSchema)
  2839. ) {
  2840. domConfig.setParameter("datatype-normalization", true);
  2841. domConfig.setParameter("validate", true);
  2842. domConfig.setParameter("schema-type", xsdNS);
  2843. resourceURI = getResourceURI("datatype_normalization");
  2844. doc = lsParser.parseURI(resourceURI);
  2845. elemList = doc.getElementsByTagNameNS("http://www.w3.org/2001/DOM-Test-Suite/Level-3/datatype_normalization","boolean");
  2846. element = elemList.item(0);
  2847. str = element.getAttribute("value");
  2848. test.strictEqual("true", str, "firstValue");
  2849. str = element.getAttribute("union");
  2850. test.strictEqual("false", str, "firstUnion");
  2851. str = element.textContent;
  2852. test.strictEqual("false true false", str, "firstList");
  2853. element = elemList.item(1);
  2854. str = element.getAttribute("value");
  2855. test.strictEqual("1", str, "secondValue");
  2856. str = element.getAttribute("union");
  2857. test.strictEqual("0", str, "secondUnion");
  2858. str = element.textContent;
  2859. test.strictEqual("0 1 0", str, "secondList");
  2860. }
  2861. test.done();
  2862. },
  2863. /**
  2864. *
  2865. Normalize document with datatype-normalization set to true.
  2866. Check if float values were normalized.
  2867. * @author Curt Arnold
  2868. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2869. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-datatype-normalization
  2870. */
  2871. datatypenormalization04 : function (test) {
  2872. var success, doc, elemList, element, domConfig, str, canSetNormalization, canSetValidate, canSetXMLSchema, xsdNS = "http://www.w3.org/2001/XMLSchema", domImplLS, lsParser, resourceURI;
  2873. domImplLS = getImplementation();
  2874. lsParser = domImplLS.createLSParser(1,xsdNS);
  2875. if(
  2876. (lsParser == null)
  2877. ) {
  2878. return ;
  2879. }
  2880. domConfig = lsParser.domConfig;
  2881. canSetNormalization = domConfig.canSetParameter("datatype-normalization",true);
  2882. canSetValidate = domConfig.canSetParameter("validate",true);
  2883. canSetXMLSchema = domConfig.canSetParameter("schema-type",xsdNS);
  2884. if(
  2885. (canSetNormalization && canSetValidate && canSetXMLSchema)
  2886. ) {
  2887. domConfig.setParameter("datatype-normalization", true);
  2888. domConfig.setParameter("validate", true);
  2889. domConfig.setParameter("schema-type", xsdNS);
  2890. resourceURI = getResourceURI("datatype_normalization");
  2891. doc = lsParser.parseURI(resourceURI);
  2892. elemList = doc.getElementsByTagNameNS("http://www.w3.org/2001/DOM-Test-Suite/Level-3/datatype_normalization","float");
  2893. element = elemList.item(0);
  2894. str = element.getAttribute("value");
  2895. test.strictEqual("+0003.141592600E+0000", str, "firstValue");
  2896. str = element.getAttribute("union");
  2897. test.strictEqual("+0003.141592600E+0000", str, "firstUnion");
  2898. str = element.textContent;
  2899. test.strictEqual("-31415926.00E-7 2.718", str, "firstList");
  2900. element = elemList.item(1);
  2901. str = element.getAttribute("value");
  2902. test.strictEqual("NaN", str, "secondValue");
  2903. str = element.getAttribute("union");
  2904. test.strictEqual("NaN", str, "secondUnion");
  2905. str = element.textContent;
  2906. test.strictEqual("INF -INF", str, "secondList");
  2907. element = elemList.item(2);
  2908. str = element.getAttribute("value");
  2909. test.strictEqual("1", str, "thirdValue");
  2910. str = element.getAttribute("union");
  2911. test.strictEqual("1", str, "thirdUnion");
  2912. str = element.textContent;
  2913. test.strictEqual("-0", str, "thirdList");
  2914. }
  2915. test.done();
  2916. },
  2917. /**
  2918. *
  2919. Normalize document with datatype-normalization set to true.
  2920. Check if dateTime values were correctly normalized.
  2921. * @author Curt Arnold
  2922. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2923. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-datatype-normalization
  2924. */
  2925. datatypenormalization05 : function (test) {
  2926. var success, doc, elemList, element, domConfig, str, canSetNormalization, canSetValidate, canSetXMLSchema, xsdNS = "http://www.w3.org/2001/XMLSchema", domImplLS, lsParser, resourceURI;
  2927. domImplLS = getImplementation();
  2928. lsParser = domImplLS.createLSParser(1,xsdNS);
  2929. if(
  2930. (lsParser == null)
  2931. ) {
  2932. return ;
  2933. }
  2934. domConfig = lsParser.domConfig;
  2935. canSetNormalization = domConfig.canSetParameter("datatype-normalization",true);
  2936. canSetValidate = domConfig.canSetParameter("validate",true);
  2937. canSetXMLSchema = domConfig.canSetParameter("schema-type",xsdNS);
  2938. if(
  2939. (canSetNormalization && canSetValidate && canSetXMLSchema)
  2940. ) {
  2941. domConfig.setParameter("datatype-normalization", true);
  2942. domConfig.setParameter("validate", true);
  2943. domConfig.setParameter("schema-type", xsdNS);
  2944. resourceURI = getResourceURI("datatype_normalization");
  2945. doc = lsParser.parseURI(resourceURI);
  2946. elemList = doc.getElementsByTagNameNS("http://www.w3.org/2001/DOM-Test-Suite/Level-3/datatype_normalization","dateTime");
  2947. element = elemList.item(0);
  2948. str = element.getAttribute("value");
  2949. test.strictEqual("2004-01-21T15:30:00-05:00", str, "firstValue");
  2950. str = element.getAttribute("union");
  2951. test.strictEqual("2004-01-21T20:30:00-05:00", str, "firstUnion");
  2952. str = element.textContent;
  2953. test.strictEqual("2004-01-21T15:30:00 2004-01-21T15:30:00Z", str, "firstList");
  2954. element = elemList.item(1);
  2955. str = element.getAttribute("value");
  2956. test.strictEqual("2004-01-21T15:30:00.0000-05:00", str, "secondValue");
  2957. str = element.getAttribute("union");
  2958. test.strictEqual("2004-01-21T15:30:00.0000-05:00", str, "secondUnion");
  2959. str = element.textContent;
  2960. test.strictEqual("2004-01-21T15:30:00.0000", str, "secondList");
  2961. element = elemList.item(2);
  2962. str = element.getAttribute("value");
  2963. test.strictEqual("2004-01-21T15:30:00.0001-05:00", str, "thirdValue");
  2964. str = element.getAttribute("union");
  2965. test.strictEqual("2004-01-21T15:30:00.0001-05:00", str, "thirdUnion");
  2966. str = element.textContent;
  2967. test.strictEqual("2004-01-21T15:30:00.0001", str, "thirdList");
  2968. }
  2969. test.done();
  2970. },
  2971. /**
  2972. *
  2973. Normalize document with datatype-normalization set to true.
  2974. Check if time values were normalized.
  2975. * @author Curt Arnold
  2976. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  2977. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-datatype-normalization
  2978. */
  2979. datatypenormalization06 : function (test) {
  2980. var success, doc, elemList, element, domConfig, str, canSetNormalization, canSetValidate, canSetXMLSchema, xsdNS = "http://www.w3.org/2001/XMLSchema", domImplLS, lsParser, nullSchemaType = null;
  2981. var resourceURI;
  2982. domImplLS = getImplementation();
  2983. lsParser = domImplLS.createLSParser(1,xsdNS);
  2984. if(
  2985. (lsParser == null)
  2986. ) {
  2987. return ;
  2988. }
  2989. domConfig = lsParser.domConfig;
  2990. canSetNormalization = domConfig.canSetParameter("datatype-normalization",true);
  2991. canSetValidate = domConfig.canSetParameter("validate",true);
  2992. canSetXMLSchema = domConfig.canSetParameter("schema-type",xsdNS);
  2993. if(
  2994. (canSetNormalization && canSetValidate && canSetXMLSchema)
  2995. ) {
  2996. domConfig.setParameter("datatype-normalization", true);
  2997. domConfig.setParameter("validate", true);
  2998. domConfig.setParameter("schema-type", xsdNS);
  2999. resourceURI = getResourceURI("datatype_normalization");
  3000. doc = lsParser.parseURI(resourceURI);
  3001. elemList = doc.getElementsByTagNameNS("http://www.w3.org/2001/DOM-Test-Suite/Level-3/datatype_normalization","time");
  3002. element = elemList.item(0);
  3003. str = element.getAttribute("value");
  3004. test.strictEqual("15:30:00-05:00", str, "firstValue");
  3005. str = element.getAttribute("union");
  3006. test.strictEqual("15:30:00-05:00", str, "firstUnion");
  3007. str = element.textContent;
  3008. test.strictEqual("15:30:00", str, "firstList");
  3009. element = elemList.item(1);
  3010. str = element.getAttribute("value");
  3011. test.strictEqual("15:30:00.0000-05:00", str, "secondValue");
  3012. str = element.getAttribute("union");
  3013. test.strictEqual("15:30:00.0000-05:00", str, "secondUnion");
  3014. str = element.textContent;
  3015. test.strictEqual("15:30:00.0000", str, "secondList");
  3016. element = elemList.item(2);
  3017. str = element.getAttribute("value");
  3018. test.strictEqual("15:30:00.0001-05:00", str, "thirdValue");
  3019. str = element.getAttribute("union");
  3020. test.strictEqual("15:30:00.0001-05:00", str, "thirdUnion");
  3021. str = element.textContent;
  3022. test.strictEqual("15:30:00.0001", str, "thirdList");
  3023. }
  3024. test.done();
  3025. },
  3026. /**
  3027. *
  3028. The default value for the double element must be provided in canonical lexical form.
  3029. * @author Curt Arnold
  3030. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3031. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-datatype-normalization
  3032. */
  3033. datatypenormalization07 : function (test) {
  3034. var success, doc, elemList, element, domConfig, str, canSetNormalization, canSetValidate, canSetXMLSchema, xsdNS = "http://www.w3.org/2001/XMLSchema", domImplLS, lsParser, resourceURI;
  3035. domImplLS = getImplementation();
  3036. lsParser = domImplLS.createLSParser(1,xsdNS);
  3037. if(
  3038. (lsParser == null)
  3039. ) {
  3040. return ;
  3041. }
  3042. domConfig = lsParser.domConfig;
  3043. canSetNormalization = domConfig.canSetParameter("datatype-normalization",true);
  3044. canSetValidate = domConfig.canSetParameter("validate",true);
  3045. canSetXMLSchema = domConfig.canSetParameter("schema-type",xsdNS);
  3046. if(
  3047. (canSetNormalization && canSetValidate && canSetXMLSchema)
  3048. ) {
  3049. domConfig.setParameter("datatype-normalization", true);
  3050. domConfig.setParameter("validate", true);
  3051. domConfig.setParameter("schema-type", xsdNS);
  3052. resourceURI = getResourceURI("datatype_normalization");
  3053. doc = lsParser.parseURI(resourceURI);
  3054. elemList = doc.getElementsByTagNameNS("http://www.w3.org/2001/DOM-Test-Suite/Level-3/datatype_normalization","double");
  3055. element = elemList.item(0);
  3056. str = element.getAttribute("default");
  3057. test.strictEqual("3.1415926E0", str, "firstValue");
  3058. }
  3059. test.done();
  3060. },
  3061. /**
  3062. *
  3063. The default value for the decimal element must be provided in canonical lexical form.
  3064. * @author Curt Arnold
  3065. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3066. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-datatype-normalization
  3067. */
  3068. datatypenormalization08 : function (test) {
  3069. var success, doc, elemList, element, domConfig, str, canSetNormalization, canSetValidate, canSetXMLSchema, xsdNS = "http://www.w3.org/2001/XMLSchema", domImplLS, lsParser, resourceURI;
  3070. domImplLS = getImplementation();
  3071. lsParser = domImplLS.createLSParser(1,xsdNS);
  3072. if(
  3073. (lsParser == null)
  3074. ) {
  3075. return ;
  3076. }
  3077. domConfig = lsParser.domConfig;
  3078. canSetNormalization = domConfig.canSetParameter("datatype-normalization",true);
  3079. canSetValidate = domConfig.canSetParameter("validate",true);
  3080. canSetXMLSchema = domConfig.canSetParameter("schema-type",xsdNS);
  3081. if(
  3082. (canSetNormalization && canSetValidate && canSetXMLSchema)
  3083. ) {
  3084. domConfig.setParameter("datatype-normalization", true);
  3085. domConfig.setParameter("validate", true);
  3086. domConfig.setParameter("schema-type", xsdNS);
  3087. resourceURI = getResourceURI("datatype_normalization");
  3088. doc = lsParser.parseURI(resourceURI);
  3089. elemList = doc.getElementsByTagNameNS("http://www.w3.org/2001/DOM-Test-Suite/Level-3/datatype_normalization","decimal");
  3090. element = elemList.item(0);
  3091. str = element.getAttribute("default");
  3092. test.strictEqual("3.1415926", str, "firstValue");
  3093. }
  3094. test.done();
  3095. },
  3096. /**
  3097. *
  3098. The default value for the boolean element must be provided in canonical lexical form.
  3099. * @author Curt Arnold
  3100. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3101. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-datatype-normalization
  3102. */
  3103. datatypenormalization09 : function (test) {
  3104. var success, doc, elemList, element, domConfig, str, canSetNormalization, canSetValidate, canSetXMLSchema, xsdNS = "http://www.w3.org/2001/XMLSchema", domImplLS, lsParser, nullSchemaType = null;
  3105. var resourceURI;
  3106. domImplLS = getImplementation();
  3107. lsParser = domImplLS.createLSParser(1,xsdNS);
  3108. if(
  3109. (lsParser == null)
  3110. ) {
  3111. return ;
  3112. }
  3113. domConfig = lsParser.domConfig;
  3114. canSetNormalization = domConfig.canSetParameter("datatype-normalization",true);
  3115. canSetValidate = domConfig.canSetParameter("validate",true);
  3116. canSetXMLSchema = domConfig.canSetParameter("schema-type",xsdNS);
  3117. if(
  3118. (canSetNormalization && canSetValidate && canSetXMLSchema)
  3119. ) {
  3120. domConfig.setParameter("datatype-normalization", true);
  3121. domConfig.setParameter("validate", true);
  3122. domConfig.setParameter("schema-type", xsdNS);
  3123. resourceURI = getResourceURI("datatype_normalization");
  3124. doc = lsParser.parseURI(resourceURI);
  3125. elemList = doc.getElementsByTagNameNS("http://www.w3.org/2001/DOM-Test-Suite/Level-3/datatype_normalization","boolean");
  3126. element = elemList.item(0);
  3127. str = element.getAttribute("default");
  3128. test.strictEqual("true", str, "firstValue");
  3129. }
  3130. test.done();
  3131. },
  3132. /**
  3133. *
  3134. The default value for the float element must be provided in canonical lexical form.
  3135. * @author Curt Arnold
  3136. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3137. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-datatype-normalization
  3138. */
  3139. datatypenormalization10 : function (test) {
  3140. var success, doc, elemList, element, domConfig, str, canSetNormalization, canSetValidate, canSetXMLSchema, xsdNS = "http://www.w3.org/2001/XMLSchema", domImplLS, lsParser, resourceURI;
  3141. domImplLS = getImplementation();
  3142. lsParser = domImplLS.createLSParser(1,xsdNS);
  3143. if(
  3144. (lsParser == null)
  3145. ) {
  3146. return ;
  3147. }
  3148. domConfig = lsParser.domConfig;
  3149. canSetNormalization = domConfig.canSetParameter("datatype-normalization",true);
  3150. canSetValidate = domConfig.canSetParameter("validate",true);
  3151. canSetXMLSchema = domConfig.canSetParameter("schema-type",xsdNS);
  3152. if(
  3153. (canSetNormalization && canSetValidate && canSetXMLSchema)
  3154. ) {
  3155. domConfig.setParameter("datatype-normalization", true);
  3156. domConfig.setParameter("validate", true);
  3157. domConfig.setParameter("schema-type", xsdNS);
  3158. resourceURI = getResourceURI("datatype_normalization");
  3159. doc = lsParser.parseURI(resourceURI);
  3160. elemList = doc.getElementsByTagNameNS("http://www.w3.org/2001/DOM-Test-Suite/Level-3/datatype_normalization","float");
  3161. element = elemList.item(0);
  3162. str = element.getAttribute("default");
  3163. test.strictEqual("3.1415926E0", str, "firstValue");
  3164. }
  3165. test.done();
  3166. },
  3167. /**
  3168. *
  3169. The default value for the dateTime element must be provided in canonical lexical form.
  3170. * @author Curt Arnold
  3171. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3172. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-datatype-normalization
  3173. */
  3174. datatypenormalization11 : function (test) {
  3175. var success, doc, elemList, element, domConfig, str, canSetNormalization, canSetValidate, canSetXMLSchema, xsdNS = "http://www.w3.org/2001/XMLSchema", domImplLS, lsParser, resourceURI;
  3176. domImplLS = getImplementation();
  3177. lsParser = domImplLS.createLSParser(1,xsdNS);
  3178. if(
  3179. (lsParser == null)
  3180. ) {
  3181. return ;
  3182. }
  3183. domConfig = lsParser.domConfig;
  3184. canSetNormalization = domConfig.canSetParameter("datatype-normalization",true);
  3185. canSetValidate = domConfig.canSetParameter("validate",true);
  3186. canSetXMLSchema = domConfig.canSetParameter("schema-type",xsdNS);
  3187. if(
  3188. (canSetNormalization && canSetValidate && canSetXMLSchema)
  3189. ) {
  3190. domConfig.setParameter("datatype-normalization", true);
  3191. domConfig.setParameter("validate", true);
  3192. domConfig.setParameter("schema-type", xsdNS);
  3193. resourceURI = getResourceURI("datatype_normalization");
  3194. doc = lsParser.parseURI(resourceURI);
  3195. elemList = doc.getElementsByTagNameNS("http://www.w3.org/2001/DOM-Test-Suite/Level-3/datatype_normalization","dateTime");
  3196. element = elemList.item(0);
  3197. str = element.getAttribute("default");
  3198. test.strictEqual("2004-01-21T20:30:00Z", str, "firstValue");
  3199. }
  3200. test.done();
  3201. },
  3202. /**
  3203. *
  3204. Default values must be provided in canonical lexical form.
  3205. * @author Curt Arnold
  3206. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3207. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-datatype-normalization
  3208. */
  3209. datatypenormalization12 : function (test) {
  3210. var success, doc, elemList, element, domConfig, str, canSetNormalization, canSetValidate, canSetXMLSchema, xsdNS = "http://www.w3.org/2001/XMLSchema", domImplLS, lsParser, resourceURI;
  3211. domImplLS = getImplementation();
  3212. lsParser = domImplLS.createLSParser(1,xsdNS);
  3213. if(
  3214. (lsParser == null)
  3215. ) {
  3216. return ;
  3217. }
  3218. domConfig = lsParser.domConfig;
  3219. canSetNormalization = domConfig.canSetParameter("datatype-normalization",true);
  3220. canSetValidate = domConfig.canSetParameter("validate",true);
  3221. canSetXMLSchema = domConfig.canSetParameter("schema-type",xsdNS);
  3222. if(
  3223. (canSetNormalization && canSetValidate && canSetXMLSchema)
  3224. ) {
  3225. domConfig.setParameter("datatype-normalization", true);
  3226. domConfig.setParameter("validate", true);
  3227. domConfig.setParameter("schema-type", xsdNS);
  3228. resourceURI = getResourceURI("datatype_normalization");
  3229. doc = lsParser.parseURI(resourceURI);
  3230. elemList = doc.getElementsByTagNameNS("http://www.w3.org/2001/DOM-Test-Suite/Level-3/datatype_normalization","time");
  3231. element = elemList.item(0);
  3232. str = element.getAttribute("default");
  3233. test.strictEqual("20:30:00Z", str, "firstValue");
  3234. }
  3235. test.done();
  3236. },
  3237. /**
  3238. *
  3239. Parse document with datatype-normalization set to true.
  3240. Check if string values were normalized per default whitespace
  3241. facet of xsd:string.
  3242. * @author Curt Arnold
  3243. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3244. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-datatype-normalization
  3245. */
  3246. datatypenormalization13 : function (test) {
  3247. var success, doc, elemList, element, domConfig, str, canSetNormalization, canSetValidate, canSetXMLSchema, xsdNS = "http://www.w3.org/2001/XMLSchema", childNode, childValue, domImplLS, lsParser, resourceURI;
  3248. domImplLS = getImplementation();
  3249. lsParser = domImplLS.createLSParser(1,xsdNS);
  3250. if(
  3251. (lsParser == null)
  3252. ) {
  3253. return ;
  3254. }
  3255. domConfig = lsParser.domConfig;
  3256. canSetNormalization = domConfig.canSetParameter("datatype-normalization2",true);
  3257. canSetValidate = domConfig.canSetParameter("validate",true);
  3258. canSetXMLSchema = domConfig.canSetParameter("schema-type",xsdNS);
  3259. if(
  3260. (canSetNormalization && canSetValidate && canSetXMLSchema)
  3261. ) {
  3262. domConfig.setParameter("datatype-normalization", true);
  3263. domConfig.setParameter("validate", true);
  3264. domConfig.setParameter("schema-type", xsdNS);
  3265. resourceURI = getResourceURI("datatype_normalization2");
  3266. doc = lsParser.parseURI(resourceURI);
  3267. elemList = doc.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","em");
  3268. element = elemList.item(0);
  3269. childNode = element.firstChild;
  3270. test.ok(childNode !== null, "childNodeNotNull");
  3271. childValue = childNode.nodeValue;
  3272. test.strictEqual(" EMP 0001 ", childValue, "content");
  3273. }
  3274. test.done();
  3275. },
  3276. /**
  3277. *
  3278. Parse document with datatype-normalization set to true.
  3279. Check if string values were normalized per explicit whitespace=preserve.
  3280. * @author Curt Arnold
  3281. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3282. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-datatype-normalization
  3283. */
  3284. datatypenormalization14 : function (test) {
  3285. var success, doc, elemList, element, domConfig, str, canSetNormalization, canSetValidate, canSetXMLSchema, xsdNS = "http://www.w3.org/2001/XMLSchema", childNode, childValue, domImplLS, lsParser, nullSchemaType = null;
  3286. var resourceURI;
  3287. domImplLS = getImplementation();
  3288. lsParser = domImplLS.createLSParser(1,xsdNS);
  3289. if(
  3290. (lsParser == null)
  3291. ) {
  3292. return ;
  3293. }
  3294. domConfig = lsParser.domConfig;
  3295. canSetNormalization = domConfig.canSetParameter("datatype-normalization2",true);
  3296. canSetValidate = domConfig.canSetParameter("validate",true);
  3297. canSetXMLSchema = domConfig.canSetParameter("schema-type",xsdNS);
  3298. if(
  3299. (canSetNormalization && canSetValidate && canSetXMLSchema)
  3300. ) {
  3301. domConfig.setParameter("datatype-normalization", true);
  3302. domConfig.setParameter("validate", true);
  3303. domConfig.setParameter("schema-type", xsdNS);
  3304. resourceURI = getResourceURI("datatype_normalization2");
  3305. doc = lsParser.parseURI(resourceURI);
  3306. elemList = doc.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","acronym");
  3307. element = elemList.item(0);
  3308. childNode = element.firstChild;
  3309. test.ok(childNode !== null, "childNodeNotNull");
  3310. childValue = childNode.nodeValue;
  3311. test.strictEqual(" EMP 0001 ", childValue, "content");
  3312. }
  3313. test.done();
  3314. },
  3315. /**
  3316. *
  3317. Parse document with datatype-normalization set to true.
  3318. Check if string values were normalized per an explicit whitespace=collapse.
  3319. * @author Curt Arnold
  3320. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3321. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-datatype-normalization
  3322. */
  3323. datatypenormalization15 : function (test) {
  3324. var success, doc, elemList, element, domConfig, str, canSetNormalization, canSetValidate, canSetXMLSchema, xsdNS = "http://www.w3.org/2001/XMLSchema", childNode, childValue, domImplLS, lsParser, resourceURI;
  3325. domImplLS = getImplementation();
  3326. lsParser = domImplLS.createLSParser(1,xsdNS);
  3327. if(
  3328. (lsParser == null)
  3329. ) {
  3330. return ;
  3331. }
  3332. domConfig = lsParser.domConfig;
  3333. canSetNormalization = domConfig.canSetParameter("datatype-normalization2",true);
  3334. canSetValidate = domConfig.canSetParameter("validate",true);
  3335. canSetXMLSchema = domConfig.canSetParameter("schema-type",xsdNS);
  3336. if(
  3337. (canSetNormalization && canSetValidate && canSetXMLSchema)
  3338. ) {
  3339. domConfig.setParameter("datatype-normalization", true);
  3340. domConfig.setParameter("validate", true);
  3341. domConfig.setParameter("schema-type", xsdNS);
  3342. resourceURI = getResourceURI("datatype_normalization2");
  3343. doc = lsParser.parseURI(resourceURI);
  3344. elemList = doc.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","code");
  3345. element = elemList.item(0);
  3346. childNode = element.firstChild;
  3347. childValue = childNode.nodeValue;
  3348. test.strictEqual("EMP 0001", childValue, "content1");
  3349. element = elemList.item(1);
  3350. childNode = element.firstChild;
  3351. childValue = childNode.nodeValue;
  3352. test.strictEqual("EMP 0001", childValue, "content2");
  3353. element = elemList.item(2);
  3354. childNode = element.firstChild;
  3355. childValue = childNode.nodeValue;
  3356. test.strictEqual("EMP 0001", childValue, "content3");
  3357. }
  3358. test.done();
  3359. },
  3360. /**
  3361. *
  3362. Parse document with datatype-normalization set to true.
  3363. Check if string values were normalized per explicit whitespace=replace.
  3364. * @author Curt Arnold
  3365. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3366. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-datatype-normalization
  3367. */
  3368. datatypenormalization16 : function (test) {
  3369. var success, doc, elemList, element, domConfig, str, canSetNormalization, canSetValidate, canSetXMLSchema, xsdNS = "http://www.w3.org/2001/XMLSchema", childNode, childValue, domImplLS, lsParser, resourceURI;
  3370. domImplLS = getImplementation();
  3371. lsParser = domImplLS.createLSParser(1,xsdNS);
  3372. if(
  3373. (lsParser == null)
  3374. ) {
  3375. return ;
  3376. }
  3377. domConfig = lsParser.domConfig;
  3378. canSetNormalization = domConfig.canSetParameter("datatype-normalization2",true);
  3379. canSetValidate = domConfig.canSetParameter("validate",true);
  3380. canSetXMLSchema = domConfig.canSetParameter("schema-type",xsdNS);
  3381. if(
  3382. (canSetNormalization && canSetValidate && canSetXMLSchema)
  3383. ) {
  3384. domConfig.setParameter("datatype-normalization", true);
  3385. domConfig.setParameter("validate", true);
  3386. domConfig.setParameter("schema-type", xsdNS);
  3387. resourceURI = getResourceURI("datatype_normalization2");
  3388. doc = lsParser.parseURI(resourceURI);
  3389. elemList = doc.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","sup");
  3390. element = elemList.item(0);
  3391. childNode = element.firstChild;
  3392. childValue = childNode.nodeValue;
  3393. test.strictEqual(" EMP 0001 ", childValue, "content1");
  3394. element = elemList.item(1);
  3395. childNode = element.firstChild;
  3396. childValue = childNode.nodeValue;
  3397. test.strictEqual("EMP 0001", childValue, "content2");
  3398. element = elemList.item(2);
  3399. childNode = element.firstChild;
  3400. childValue = childNode.nodeValue;
  3401. test.strictEqual("EMP 0001", childValue, "content3");
  3402. element = elemList.item(3);
  3403. childNode = element.firstChild;
  3404. childValue = childNode.nodeValue;
  3405. test.strictEqual("EMP 0001", childValue, "content4");
  3406. }
  3407. test.done();
  3408. },
  3409. /**
  3410. *
  3411. Parse document with datatype-normalization set to false.
  3412. Check if string values were not normalized per an explicit whitespace=collapse.
  3413. * @author Curt Arnold
  3414. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3415. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-datatype-normalization
  3416. */
  3417. datatypenormalization17 : function (test) {
  3418. var success, doc, elemList, element, domConfig, str, canSetValidate, canSetXMLSchema, xsdNS = "http://www.w3.org/2001/XMLSchema", childNode, childValue, domImplLS, lsParser, resourceURI, nullSchemaType = null;
  3419. domImplLS = getImplementation();
  3420. lsParser = domImplLS.createLSParser(1,xsdNS);
  3421. if(
  3422. (lsParser == null)
  3423. ) {
  3424. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  3425. }
  3426. domConfig = lsParser.domConfig;
  3427. canSetValidate = domConfig.canSetParameter("validate",true);
  3428. if(
  3429. canSetValidate
  3430. ) {
  3431. domConfig.setParameter("validate", true);
  3432. }
  3433. canSetXMLSchema = domConfig.canSetParameter("schema-type",xsdNS);
  3434. if(
  3435. canSetXMLSchema
  3436. ) {
  3437. domConfig.setParameter("schema-type", xsdNS);
  3438. }
  3439. domConfig.setParameter("datatype-normalization", false);
  3440. resourceURI = getResourceURI("datatype_normalization2");
  3441. doc = lsParser.parseURI(resourceURI);
  3442. elemList = doc.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","code");
  3443. element = elemList.item(1);
  3444. childNode = element.firstChild;
  3445. childValue = childNode.nodeValue;
  3446. test.strictEqual("EMP 0001", childValue, "content2");
  3447. test.done();
  3448. },
  3449. /**
  3450. *
  3451. Parsing a document with a doctype should throw a PARSE_ERR if disallow-doctype is true.
  3452. is false.
  3453. * @author Curt Arnold
  3454. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3455. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-disallow-doctype
  3456. */
  3457. disallowdoctype01 : function (test) {
  3458. var success, doc, domConfig, domImplLS, lsParser, resourceURI, canSet, nullSchemaLanguage = null;
  3459. errorMonitor = new DOMErrorMonitor();
  3460. var errors = new Array();
  3461. var error, severity, type, errorCount = 0;
  3462. domImplLS = getImplementation();
  3463. lsParser = domImplLS.createLSParser(1,nullSchemaLanguage);
  3464. domConfig = lsParser.domConfig;
  3465. canSet = domConfig.canSetParameter("disallow-doctype",true);
  3466. if(
  3467. canSet
  3468. ) {
  3469. domConfig.setParameter("disallow-doctype", true);
  3470. domConfig.setParameter("error-handler", errorMonitor.handleError);
  3471. resourceURI = getResourceURI("barfoo");
  3472. {
  3473. success = false;
  3474. try {
  3475. doc = lsParser.parseURI(resourceURI);
  3476. }
  3477. catch(ex) {
  3478. success = (typeof(ex.code) != 'undefined' && ex.code == 81);
  3479. }
  3480. test.ok(success, "throw_PARSE_ERR");
  3481. }
  3482. errors = errorMonitor.allErrors;
  3483. for(var indexN1008E = 0;indexN1008E < errors.length; indexN1008E++) {
  3484. error = errors[indexN1008E];
  3485. severity = error.severity;
  3486. type = error.type;
  3487. if(
  3488. (severity > 1)
  3489. ) {
  3490. test.strictEqual(3, severity, "isFatalError");
  3491. test.strictEqual("doctype-not-allowed", type, "isDoctypeNotAllowed");
  3492. errorCount += 1;
  3493. }
  3494. }
  3495. test.strictEqual(1, errorCount, "oneError");
  3496. }
  3497. test.done();
  3498. },
  3499. /**
  3500. *
  3501. Default attributes should be not be serialized if discard-default-content is true.
  3502. * @author Curt Arnold
  3503. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  3504. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-discard-default-content
  3505. */
  3506. discarddefaultcontent01 : function (test) {
  3507. var success, doc, domConfig, domImplLS, lsSerializer, docType = null;
  3508. var docElem, newNode, output, retNode, canSet;
  3509. domImplLS = getImplementation();
  3510. lsSerializer = domImplLS.createLSSerializer();
  3511. var docRef = null;
  3512. if (typeof(this.doc) != 'undefined') {
  3513. docRef = this.doc;
  3514. }
  3515. doc = load(docRef, "doc", "hc_staff");
  3516. domConfig = lsSerializer.domConfig;
  3517. domConfig.setParameter("discard-default-content", true);
  3518. output = lsSerializer.writeToString(doc);
  3519. {
  3520. test.ok((output.indexOf("dir=") >= 0) === false, "noDirAttr");
  3521. }
  3522. test.done();
  3523. },
  3524. /**
  3525. *
  3526. Default attributes should be explicitly serialized if discard-default-content is false.
  3527. * @author Curt Arnold
  3528. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  3529. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-discard-default-content
  3530. */
  3531. discarddefaultcontent02 : function (test) {
  3532. var success, doc, domConfig, domImplLS, lsSerializer, docType = null;
  3533. var docElem, newNode, output, retNode, canSet;
  3534. domImplLS = getImplementation();
  3535. lsSerializer = domImplLS.createLSSerializer();
  3536. var docRef = null;
  3537. if (typeof(this.doc) != 'undefined') {
  3538. docRef = this.doc;
  3539. }
  3540. doc = load(docRef, "doc", "hc_staff");
  3541. domConfig = lsSerializer.domConfig;
  3542. domConfig.setParameter("discard-default-content", false);
  3543. output = lsSerializer.writeToString(doc);
  3544. test.ok(output.indexOf("dir=") >= 0, "hasDirAttr");
  3545. test.done();
  3546. },
  3547. /**
  3548. *
  3549. Load a document with element-content-whitespace = false and validation = true and check that
  3550. element content whitespace is eliminated.
  3551. * @author Curt Arnold
  3552. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3553. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-element-content-whitespace
  3554. */
  3555. elementcontentwhitespace01 : function (test) {
  3556. var success, doc, elem, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  3557. var resourceURI, canSetValidate, canSetWhitespace, elemList;
  3558. domImplLS = getImplementation();
  3559. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  3560. domConfig = lsParser.domConfig;
  3561. canSetValidate = domConfig.canSetParameter("validate",true);
  3562. canSetWhitespace = domConfig.canSetParameter("element-content-whitespace",false);
  3563. if(
  3564. (canSetValidate && canSetWhitespace)
  3565. ) {
  3566. domConfig.setParameter("validate", true);
  3567. domConfig.setParameter("element-content-whitespace", false);
  3568. resourceURI = getResourceURI("hc_staff");
  3569. doc = lsParser.parseURI(resourceURI);
  3570. elemList = doc.getElementsByTagName("p");
  3571. elem = elemList.item(0);
  3572. node = elem.firstChild;
  3573. nodeType = node.nodeType;
  3574. test.strictEqual(1, nodeType, "nodeIsElem");
  3575. }
  3576. test.done();
  3577. },
  3578. /**
  3579. *
  3580. Load a document with element-content-whitespace and validate = true and check that
  3581. element content whitespace is not eliminated.
  3582. * @author Curt Arnold
  3583. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3584. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-element-content-whitespace
  3585. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate
  3586. */
  3587. elementcontentwhitespace02 : function (test) {
  3588. var success, doc, elem, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  3589. var resourceURI, canSet, elemList;
  3590. domImplLS = getImplementation();
  3591. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  3592. domConfig = lsParser.domConfig;
  3593. canSet = domConfig.canSetParameter("validate",true);
  3594. if(
  3595. canSet
  3596. ) {
  3597. domConfig.setParameter("validate", true);
  3598. }
  3599. domConfig.setParameter("element-content-whitespace", true);
  3600. resourceURI = getResourceURI("hc_staff");
  3601. doc = lsParser.parseURI(resourceURI);
  3602. elemList = doc.getElementsByTagName("p");
  3603. elem = elemList.item(0);
  3604. node = elem.firstChild;
  3605. nodeType = node.nodeType;
  3606. test.strictEqual(3, nodeType, "nodeIsText");
  3607. test.done();
  3608. },
  3609. /**
  3610. *
  3611. Serialize a document when element-content-whitespace is false, element content whitespace should be eliminated.
  3612. * @author Curt Arnold
  3613. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  3614. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-element-content-whitespace
  3615. */
  3616. elementcontentwhitespace03 : function (test) {
  3617. var success, doc, domConfig, serializerDomConfig, domImplLS, lsParser, nullSchemaType = null;
  3618. var resourceURI, lsSerializer, output, canSetValidate, canSetWhitespace;
  3619. domImplLS = getImplementation();
  3620. lsSerializer = domImplLS.createLSSerializer();
  3621. domConfig = lsSerializer.domConfig;
  3622. canSetValidate = domConfig.canSetParameter("validate",true);
  3623. lsSerializer = domImplLS.createLSSerializer();
  3624. serializerDomConfig = lsSerializer.domConfig;
  3625. canSetWhitespace = serializerDomConfig.canSetParameter("element-content-whitespace",false);
  3626. if(
  3627. (canSetValidate && canSetWhitespace)
  3628. ) {
  3629. domConfig.setParameter("validate", true);
  3630. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  3631. domConfig = lsParser.domConfig;
  3632. domConfig.setParameter("validate", false);
  3633. resourceURI = getResourceURI("test3");
  3634. doc = lsParser.parseURI(resourceURI);
  3635. serializerDomConfig.setParameter("element-content-whitespace", false);
  3636. output = lsSerializer.writeToString(doc);
  3637. test.ok(output.indexOf("&lt;elt0>&lt;elt1>") >= 0, "noWhitespace");
  3638. }
  3639. test.done();
  3640. },
  3641. /**
  3642. *
  3643. createLSOutput should create an LSOutput, encoding should be mutable.
  3644. * @author Curt Arnold
  3645. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-DOMImplementationLS-createLSOutput
  3646. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSOutput-encoding
  3647. */
  3648. encoding01 : function (test) {
  3649. var success, domImplLS, lsOutput, encoding;
  3650. domImplLS = getImplementation();
  3651. lsOutput = domImplLS.createLSOutput();
  3652. encoding = lsOutput.encoding;
  3653. lsOutput.encoding = "ISO-8859-1";
  3654. encoding = lsOutput.encoding;
  3655. test.strictEqual("ISO-8859-1".toLowerCase(), encoding.toLowerCase(), "isLatin1");
  3656. test.done();
  3657. },
  3658. /**
  3659. *
  3660. Load a document with entities = false and see that entity references are not present in
  3661. the element content.
  3662. * @author Curt Arnold
  3663. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3664. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-entities
  3665. */
  3666. entities01 : function (test) {
  3667. var success, doc, docElem, elemList, elem, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  3668. var resourceURI;
  3669. domImplLS = getImplementation();
  3670. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  3671. domConfig = lsParser.domConfig;
  3672. domConfig.setParameter("entities", false);
  3673. resourceURI = getResourceURI("hc_staff");
  3674. doc = lsParser.parseURI(resourceURI);
  3675. elemList = doc.getElementsByTagName("acronym");
  3676. elem = elemList.item(1);
  3677. node = elem.firstChild;
  3678. nodeType = node.nodeType;
  3679. test.strictEqual(3, nodeType, "acrContentIsText");
  3680. test.done();
  3681. },
  3682. /**
  3683. *
  3684. Load a document with entities = false and see that entity references are not present in
  3685. attribute content.
  3686. * @author Curt Arnold
  3687. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3688. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-entities
  3689. */
  3690. entities02 : function (test) {
  3691. var success, doc, docElem, elemList, elem, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  3692. var resourceURI, attributes, docType, entities, entity, classAttr;
  3693. domImplLS = getImplementation();
  3694. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  3695. domConfig = lsParser.domConfig;
  3696. domConfig.setParameter("entities", false);
  3697. resourceURI = getResourceURI("hc_staff");
  3698. doc = lsParser.parseURI(resourceURI);
  3699. elemList = doc.getElementsByTagName("acronym");
  3700. elem = elemList.item(3);
  3701. attributes = elem.attributes;
  3702. classAttr = attributes.getNamedItem("class");
  3703. node = classAttr.lastChild;
  3704. test.ok(classAttr !== null, "classAttrChildNotNull");
  3705. nodeType = node.nodeType;
  3706. test.strictEqual(3, nodeType, "classAttrChildIsText");
  3707. test.done();
  3708. },
  3709. /**
  3710. *
  3711. Load a document with entities = false and see that entity definitions are preserved.
  3712. * @author Curt Arnold
  3713. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3714. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-entities
  3715. */
  3716. entities03 : function (test) {
  3717. var success, doc, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  3718. var resourceURI, docType, entities, entity;
  3719. domImplLS = getImplementation();
  3720. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  3721. domConfig = lsParser.domConfig;
  3722. domConfig.setParameter("entities", false);
  3723. resourceURI = getResourceURI("hc_staff");
  3724. doc = lsParser.parseURI(resourceURI);
  3725. docType = doc.doctype;
  3726. test.ok(docType !== null, "docTypeNotNull");
  3727. entities = docType.entities;
  3728. entity = entities.getNamedItem("alpha");
  3729. test.ok(entity !== null, "entityNotNull");
  3730. test.done();
  3731. },
  3732. /**
  3733. *
  3734. Load a document with entities = true and see that entity references are present in
  3735. the element content.
  3736. * @author Curt Arnold
  3737. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3738. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-entities
  3739. */
  3740. entities04 : function (test) {
  3741. var success, doc, docElem, elemList, elem, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  3742. var resourceURI;
  3743. domImplLS = getImplementation();
  3744. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  3745. domConfig = lsParser.domConfig;
  3746. domConfig.setParameter("entities", true);
  3747. resourceURI = getResourceURI("hc_staff");
  3748. doc = lsParser.parseURI(resourceURI);
  3749. elemList = doc.getElementsByTagName("acronym");
  3750. elem = elemList.item(1);
  3751. node = elem.firstChild;
  3752. nodeType = node.nodeType;
  3753. test.strictEqual(5, nodeType, "acrContentIsEntRef");
  3754. test.done();
  3755. },
  3756. /**
  3757. *
  3758. Load a document with entities = true and see that entity references are present in
  3759. attribute content.
  3760. * @author Curt Arnold
  3761. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3762. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-entities
  3763. */
  3764. entities05 : function (test) {
  3765. var success, doc, docElem, elemList, elem, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  3766. var resourceURI, attributes, docType, entities, entity, classAttr;
  3767. domImplLS = getImplementation();
  3768. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  3769. domConfig = lsParser.domConfig;
  3770. domConfig.setParameter("entities", true);
  3771. resourceURI = getResourceURI("hc_staff");
  3772. doc = lsParser.parseURI(resourceURI);
  3773. elemList = doc.getElementsByTagName("acronym");
  3774. elem = elemList.item(3);
  3775. attributes = elem.attributes;
  3776. classAttr = attributes.getNamedItem("class");
  3777. node = classAttr.lastChild;
  3778. test.ok(classAttr !== null, "classAttrChildNotNull");
  3779. nodeType = node.nodeType;
  3780. test.strictEqual(5, nodeType, "classAttrChildIsEntRef");
  3781. test.done();
  3782. },
  3783. /**
  3784. *
  3785. Load a document with entities = true and see that entity definitions are preserved.
  3786. * @author Curt Arnold
  3787. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3788. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-entities
  3789. */
  3790. entities06 : function (test) {
  3791. var success, doc, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  3792. var resourceURI, docType, entities, entity;
  3793. domImplLS = getImplementation();
  3794. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  3795. domConfig = lsParser.domConfig;
  3796. domConfig.setParameter("entities", true);
  3797. resourceURI = getResourceURI("hc_staff");
  3798. doc = lsParser.parseURI(resourceURI);
  3799. docType = doc.doctype;
  3800. test.ok(docType !== null, "docTypeNotNull");
  3801. entities = docType.entities;
  3802. entity = entities.getNamedItem("alpha");
  3803. test.ok(entity !== null, "entityNotNull");
  3804. test.done();
  3805. },
  3806. /**
  3807. *
  3808. A warning should be dispatched if the base URI of a processing instruction can not be preserved.
  3809. * @author Curt Arnold
  3810. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3811. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-entities
  3812. */
  3813. entities07 : function (test) {
  3814. var success, doc, domConfig, domImplLS, lsParser, resourceURI, canSet, nullSchemaLanguage = null;
  3815. errorMonitor = new DOMErrorMonitor();
  3816. var errors = new Array();
  3817. var error, severity, type, warningCount = 0;
  3818. domImplLS = getImplementation();
  3819. lsParser = domImplLS.createLSParser(1,nullSchemaLanguage);
  3820. domConfig = lsParser.domConfig;
  3821. domConfig.setParameter("entities", false);
  3822. domConfig.setParameter("error-handler", errorMonitor.handleError);
  3823. resourceURI = getResourceURI("pibase");
  3824. doc = lsParser.parseURI(resourceURI);
  3825. test.ok(doc !== null, "docNotNull");
  3826. errors = errorMonitor.allErrors;
  3827. for(var indexN10081 = 0;indexN10081 < errors.length; indexN10081++) {
  3828. error = errors[indexN10081];
  3829. severity = error.severity;
  3830. type = error.type;
  3831. if(("pi-base-uri-not-preserved" == type)) {
  3832. test.strictEqual(1, severity, "isError");
  3833. warningCount += 1;
  3834. }
  3835. }
  3836. test.strictEqual(1, warningCount, "hadWarning");
  3837. test.done();
  3838. },
  3839. /**
  3840. *
  3841. Entity references should be preserved when entities is true.
  3842. * @author Curt Arnold
  3843. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  3844. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-entities
  3845. */
  3846. entities08 : function (test) {
  3847. var success, doc, domConfig, domImplLS, lsSerializer, output;
  3848. domImplLS = getImplementation();
  3849. var docRef = null;
  3850. if (typeof(this.doc) != 'undefined') {
  3851. docRef = this.doc;
  3852. }
  3853. doc = load(docRef, "doc", "hc_staff");
  3854. lsSerializer = domImplLS.createLSSerializer();
  3855. domConfig = lsSerializer.domConfig;
  3856. domConfig.setParameter("entities", true);
  3857. output = lsSerializer.writeToString(doc);
  3858. test.ok(output.indexOf("ent4;") >= 0, "hasEntRef");
  3859. test.done();
  3860. },
  3861. /**
  3862. *
  3863. Entity references should be expanded when entities is false.
  3864. * @author Curt Arnold
  3865. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  3866. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-entities
  3867. */
  3868. entities09 : function (test) {
  3869. var success, doc, domConfig, domImplLS, lsSerializer, output;
  3870. domImplLS = getImplementation();
  3871. var docRef = null;
  3872. if (typeof(this.doc) != 'undefined') {
  3873. docRef = this.doc;
  3874. }
  3875. doc = load(docRef, "doc", "hc_staff");
  3876. lsSerializer = domImplLS.createLSSerializer();
  3877. domConfig = lsSerializer.domConfig;
  3878. domConfig.setParameter("entities", false);
  3879. output = lsSerializer.writeToString(doc);
  3880. {
  3881. test.ok((output.indexOf("ent4;") >= 0) === false, "noEntRef");
  3882. test.ok(output.indexOf("!ENTITY") >= 0, "entDef");
  3883. }
  3884. test.done();
  3885. },
  3886. /**
  3887. *
  3888. Load a document with a DTD that doesn't match content with infoset=true, should load without complaint.
  3889. * @author Curt Arnold
  3890. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3891. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-infoset
  3892. */
  3893. infoset01 : function (test) {
  3894. var success, doc, elem, node, nodeName, domConfig, domImplLS, lsParser, nullSchemaType = null;
  3895. var resourceURI;
  3896. domImplLS = getImplementation();
  3897. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  3898. domConfig = lsParser.domConfig;
  3899. domConfig.setParameter("infoset", true);
  3900. resourceURI = getResourceURI("validate1");
  3901. doc = lsParser.parseURI(resourceURI);
  3902. test.ok(doc !== null, "docNotNull");
  3903. elem = doc.documentElement;
  3904. test.ok(elem !== null, "docElemNotNull");
  3905. nodeName = elem.nodeName;
  3906. test.strictEqual("elt0", nodeName, "docElemName");
  3907. test.done();
  3908. },
  3909. /**
  3910. *
  3911. Load a document with entities = false and see that entity references are not present in
  3912. the element content.
  3913. * @author Curt Arnold
  3914. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3915. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-infoset
  3916. */
  3917. infoset02 : function (test) {
  3918. var success, doc, docElem, elemList, elem, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  3919. var resourceURI;
  3920. domImplLS = getImplementation();
  3921. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  3922. domConfig = lsParser.domConfig;
  3923. domConfig.setParameter("infoset", true);
  3924. resourceURI = getResourceURI("hc_staff");
  3925. doc = lsParser.parseURI(resourceURI);
  3926. elemList = doc.getElementsByTagName("acronym");
  3927. elem = elemList.item(1);
  3928. node = elem.firstChild;
  3929. nodeType = node.nodeType;
  3930. test.strictEqual(3, nodeType, "acrContentIsText");
  3931. test.done();
  3932. },
  3933. /**
  3934. *
  3935. Parse document with infoset set to true.
  3936. Check if string values were not normalized per an explicit whitespace=collapse.
  3937. * @author Curt Arnold
  3938. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3939. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-datatype-normalization
  3940. */
  3941. infoset03 : function (test) {
  3942. var success, doc, elemList, element, domConfig, str, canSetValidate, canSetXMLSchema, xsdNS = "http://www.w3.org/2001/XMLSchema", childNode, childValue, domImplLS, lsParser, resourceURI, nullSchemaType = null;
  3943. domImplLS = getImplementation();
  3944. lsParser = domImplLS.createLSParser(1,xsdNS);
  3945. if(
  3946. (lsParser == null)
  3947. ) {
  3948. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  3949. }
  3950. domConfig = lsParser.domConfig;
  3951. canSetValidate = domConfig.canSetParameter("validate",true);
  3952. if(
  3953. canSetValidate
  3954. ) {
  3955. domConfig.setParameter("validate", true);
  3956. }
  3957. canSetXMLSchema = domConfig.canSetParameter("schema-type",xsdNS);
  3958. if(
  3959. canSetXMLSchema
  3960. ) {
  3961. domConfig.setParameter("schema-type", xsdNS);
  3962. }
  3963. domConfig.setParameter("infoset", true);
  3964. resourceURI = getResourceURI("datatype_normalization2");
  3965. doc = lsParser.parseURI(resourceURI);
  3966. elemList = doc.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","code");
  3967. element = elemList.item(1);
  3968. childNode = element.firstChild;
  3969. childValue = childNode.nodeValue;
  3970. test.strictEqual("EMP 0001", childValue, "content2");
  3971. test.done();
  3972. },
  3973. /**
  3974. *
  3975. Load a document with infoset = true and see that CDATASection are not present in
  3976. the parsed document.
  3977. * @author Curt Arnold
  3978. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  3979. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-infoset
  3980. */
  3981. infoset04 : function (test) {
  3982. var success, doc, elem, node, nodeType, domConfig, pList, domImplLS, lsParser, nullSchemaType = null;
  3983. var resourceURI;
  3984. domImplLS = getImplementation();
  3985. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  3986. domConfig = lsParser.domConfig;
  3987. domConfig.setParameter("infoset", true);
  3988. resourceURI = getResourceURI("hc_staff");
  3989. doc = lsParser.parseURI(resourceURI);
  3990. pList = doc.getElementsByTagName("strong");
  3991. elem = pList.item(1);
  3992. node = elem.lastChild;
  3993. nodeType = node.nodeType;
  3994. test.strictEqual(3, nodeType, "childIsText");
  3995. test.done();
  3996. },
  3997. /**
  3998. *
  3999. Load a document with infoset = true and see that attributes for namespace declarations are present.
  4000. * @author Curt Arnold
  4001. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4002. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-infoset
  4003. */
  4004. infoset05 : function (test) {
  4005. var success, doc, docElem, elemList, elem, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  4006. var resourceURI;
  4007. domImplLS = getImplementation();
  4008. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  4009. domConfig = lsParser.domConfig;
  4010. domConfig.setParameter("infoset", true);
  4011. resourceURI = getResourceURI("hc_staff");
  4012. doc = lsParser.parseURI(resourceURI);
  4013. elemList = doc.getElementsByTagName("p");
  4014. elem = elemList.item(0);
  4015. node = elem.getAttributeNode("xmlns:dmstc");
  4016. test.ok(node !== null, "nsAttrNotNull");
  4017. test.done();
  4018. },
  4019. /**
  4020. *
  4021. Load a document with infoset and validate = true and check that
  4022. element content whitespace is not eliminated.
  4023. * @author Curt Arnold
  4024. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4025. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-infoset
  4026. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-validate
  4027. */
  4028. infoset06 : function (test) {
  4029. var success, doc, elem, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  4030. var resourceURI, canSet, elemList;
  4031. domImplLS = getImplementation();
  4032. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  4033. domConfig = lsParser.domConfig;
  4034. canSet = domConfig.canSetParameter("validate",true);
  4035. if(
  4036. canSet
  4037. ) {
  4038. domConfig.setParameter("validate", true);
  4039. }
  4040. domConfig.setParameter("infoset", true);
  4041. resourceURI = getResourceURI("hc_staff");
  4042. doc = lsParser.parseURI(resourceURI);
  4043. elemList = doc.getElementsByTagName("p");
  4044. elem = elemList.item(0);
  4045. node = elem.firstChild;
  4046. nodeType = node.nodeType;
  4047. test.strictEqual(3, nodeType, "nodeIsText");
  4048. test.done();
  4049. },
  4050. /**
  4051. *
  4052. Load a document with infoset = true and see that comments are present in
  4053. the parsed document.
  4054. * @author Curt Arnold
  4055. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4056. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-infoset
  4057. */
  4058. infoset07 : function (test) {
  4059. var success, doc, docElem, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  4060. var resourceURI;
  4061. domImplLS = getImplementation();
  4062. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  4063. domConfig = lsParser.domConfig;
  4064. domConfig.setParameter("infoset", true);
  4065. resourceURI = getResourceURI("hc_staff");
  4066. doc = lsParser.parseURI(resourceURI);
  4067. docElem = doc.documentElement;
  4068. node = docElem.previousSibling;
  4069. nodeType = node.nodeType;
  4070. test.strictEqual(8, nodeType, "nodeIsDocType");
  4071. test.done();
  4072. },
  4073. /**
  4074. *
  4075. Attempt to load a namespace invalid document with infoset = true.
  4076. * @author Curt Arnold
  4077. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4078. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-infoset
  4079. */
  4080. infoset08 : function (test) {
  4081. var success, doc, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  4082. var resourceURI;
  4083. domImplLS = getImplementation();
  4084. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  4085. domConfig = lsParser.domConfig;
  4086. domConfig.setParameter("infoset", true);
  4087. resourceURI = getResourceURI("namespaces1");
  4088. {
  4089. success = false;
  4090. try {
  4091. doc = lsParser.parseURI(resourceURI);
  4092. }
  4093. catch(ex) {
  4094. success = (typeof(ex.code) != 'undefined' && ex.code == 81);
  4095. }
  4096. test.ok(success, "throw_PARSE_ERR");
  4097. }
  4098. test.done();
  4099. },
  4100. /**
  4101. *
  4102. Load a document with namespace-declarations = false and see that attributes
  4103. for namespace declarations are not present.
  4104. * @author Curt Arnold
  4105. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4106. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-namespace-declarations
  4107. */
  4108. namespacedeclarations01 : function (test) {
  4109. var success, doc, docElem, elemList, elem, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  4110. var resourceURI;
  4111. domImplLS = getImplementation();
  4112. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  4113. domConfig = lsParser.domConfig;
  4114. domConfig.setParameter("namespace-declarations", false);
  4115. resourceURI = getResourceURI("hc_staff");
  4116. doc = lsParser.parseURI(resourceURI);
  4117. elemList = doc.getElementsByTagName("p");
  4118. elem = elemList.item(0);
  4119. node = elem.getAttributeNode("xmlns:dmstc");
  4120. test.ok(node === null, "nsAttrNull");
  4121. test.done();
  4122. },
  4123. /**
  4124. *
  4125. Load a document with namespace-declarations = true and see that attributes for namespace declarations are present.
  4126. * @author Curt Arnold
  4127. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4128. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-namespace-declarations
  4129. */
  4130. namespacedeclarations02 : function (test) {
  4131. var success, doc, docElem, elemList, elem, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  4132. var resourceURI;
  4133. domImplLS = getImplementation();
  4134. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  4135. domConfig = lsParser.domConfig;
  4136. domConfig.setParameter("namespace-declarations", true);
  4137. resourceURI = getResourceURI("hc_staff");
  4138. doc = lsParser.parseURI(resourceURI);
  4139. elemList = doc.getElementsByTagName("p");
  4140. elem = elemList.item(0);
  4141. node = elem.getAttributeNode("xmlns:dmstc");
  4142. test.ok(node !== null, "nsAttrNotNull");
  4143. test.done();
  4144. },
  4145. /**
  4146. *
  4147. Attempt to load a namespace invalid document with namespaces = true.
  4148. * @author Curt Arnold
  4149. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4150. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-namespaces
  4151. */
  4152. namespaces01 : function (test) {
  4153. var success, doc, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  4154. var resourceURI;
  4155. domImplLS = getImplementation();
  4156. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  4157. domConfig = lsParser.domConfig;
  4158. domConfig.setParameter("namespaces", true);
  4159. resourceURI = getResourceURI("namespaces1");
  4160. {
  4161. success = false;
  4162. try {
  4163. doc = lsParser.parseURI(resourceURI);
  4164. }
  4165. catch(ex) {
  4166. success = (typeof(ex.code) != 'undefined' && ex.code == 81);
  4167. }
  4168. test.ok(success, "throw_PARSE_ERR");
  4169. }
  4170. test.done();
  4171. },
  4172. /**
  4173. *
  4174. Attempt to load a namespace invalid document with namespaces = false.
  4175. * @author Curt Arnold
  4176. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4177. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-namespaces
  4178. */
  4179. namespaces02 : function (test) {
  4180. var success, doc, node, nodeType, domConfig, domImplLS, lsParser, nullSchemaType = null;
  4181. var resourceURI, canSet, docElem, tagName;
  4182. domImplLS = getImplementation();
  4183. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  4184. domConfig = lsParser.domConfig;
  4185. canSet = domConfig.canSetParameter("namespaces",false);
  4186. if(
  4187. canSet
  4188. ) {
  4189. domConfig.setParameter("namespaces", false);
  4190. resourceURI = getResourceURI("namespaces1");
  4191. doc = lsParser.parseURI(resourceURI);
  4192. docElem = doc.documentElement;
  4193. tagName = docElem.tagName;
  4194. test.strictEqual("bad:ns:tag", tagName, "tagName");
  4195. }
  4196. test.done();
  4197. },
  4198. /**
  4199. *
  4200. LSSerializer.newLine should contain the platform default new line.
  4201. * @author Curt Arnold
  4202. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-DOMImplementationLS-createLSSerializer
  4203. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-newLine
  4204. */
  4205. newline01 : function (test) {
  4206. var success, domImplLS, lsSerializer, newLine;
  4207. domImplLS = getImplementation();
  4208. lsSerializer = domImplLS.createLSSerializer();
  4209. newLine = lsSerializer.newLine;
  4210. test.ok(newLine !== null, "newLineNotNull");
  4211. test.done();
  4212. },
  4213. /**
  4214. *
  4215. Setting LSSerializer.newLine should change the value retrieved subsequent calls.
  4216. * @author Curt Arnold
  4217. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-DOMImplementationLS-createLSSerializer
  4218. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-newLine
  4219. */
  4220. newline02 : function (test) {
  4221. var success, domImplLS, lsSerializer, newLine;
  4222. domImplLS = getImplementation();
  4223. lsSerializer = domImplLS.createLSSerializer();
  4224. lsSerializer.newLine = "crlf";
  4225. newLine = lsSerializer.newLine;
  4226. test.strictEqual("crlf", newLine, "newLine");
  4227. test.done();
  4228. },
  4229. /**
  4230. *
  4231. Setting LSSerializer.newLine to null should reset the default value.
  4232. * @author Curt Arnold
  4233. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-DOMImplementationLS-createLSSerializer
  4234. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-newLine
  4235. */
  4236. newline03 : function (test) {
  4237. var success, domImplLS, lsSerializer, newLine, origNewLine, nullString = null;
  4238. domImplLS = getImplementation();
  4239. lsSerializer = domImplLS.createLSSerializer();
  4240. origNewLine = lsSerializer.newLine;
  4241. lsSerializer.newLine = nullString;
  4242. newLine = lsSerializer.newLine;
  4243. test.strictEqual(origNewLine, newLine, "newLine");
  4244. test.done();
  4245. },
  4246. /**
  4247. *
  4248. Parsing using an uninitialized LSInput should result in a PARSE_ERR.
  4249. is false.
  4250. * @author Curt Arnold
  4251. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parse
  4252. */
  4253. noinputspecified01 : function (test) {
  4254. var success, doc, domConfig, domImplLS, lsParser, lsInput, nullSchemaLanguage = null;
  4255. errorMonitor = new DOMErrorMonitor();
  4256. var errors = new Array();
  4257. var error, severity, type, errorCount = 0;
  4258. domImplLS = getImplementation();
  4259. lsParser = domImplLS.createLSParser(1,nullSchemaLanguage);
  4260. lsInput = domImplLS.createLSInput();
  4261. domConfig = lsParser.domConfig;
  4262. domConfig.setParameter("error-handler", errorMonitor.handleError);
  4263. {
  4264. success = false;
  4265. try {
  4266. doc = lsParser.parse(lsInput);
  4267. }
  4268. catch(ex) {
  4269. success = (typeof(ex.code) != 'undefined' && ex.code == 81);
  4270. }
  4271. test.ok(success, "throw_PARSE_ERR");
  4272. }
  4273. errors = errorMonitor.allErrors;
  4274. for(var indexN10077 = 0;indexN10077 < errors.length; indexN10077++) {
  4275. error = errors[indexN10077];
  4276. severity = error.severity;
  4277. type = error.type;
  4278. if(
  4279. (severity > 1)
  4280. ) {
  4281. test.strictEqual(3, severity, "isFatalError");
  4282. test.strictEqual("no-input-specified", type, "noInputSpecified");
  4283. errorCount += 1;
  4284. }
  4285. }
  4286. test.strictEqual(1, errorCount, "oneError");
  4287. test.done();
  4288. },
  4289. /**
  4290. *
  4291. Writing to an uninitialized LSOutput should result in a SERIALIZATION_ERR.
  4292. * @author Curt Arnold
  4293. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-write
  4294. */
  4295. nooutputspecified01 : function (test) {
  4296. var success, doc, domConfig, domImplLS, lsSerializer, lsOutput;
  4297. errorMonitor = new DOMErrorMonitor();
  4298. var errors = new Array();
  4299. var error, severity, type, errorCount = 0, docType = null;
  4300. var retval;
  4301. domImplLS = getImplementation();
  4302. lsSerializer = domImplLS.createLSSerializer();
  4303. lsOutput = domImplLS.createLSOutput();
  4304. doc = domImplLS.createDocument("http://www.w3.org/1999/xhtml","html",docType);
  4305. domConfig = lsSerializer.domConfig;
  4306. domConfig.setParameter("error-handler", errorMonitor.handleError);
  4307. {
  4308. success = false;
  4309. try {
  4310. retval = lsSerializer.write(doc,lsOutput);
  4311. }
  4312. catch(ex) {
  4313. success = (typeof(ex.code) != 'undefined' && ex.code == 82);
  4314. }
  4315. test.ok(success, "throw_SERIALIZE_ERR");
  4316. }
  4317. errors = errorMonitor.allErrors;
  4318. for(var indexN10081 = 0;indexN10081 < errors.length; indexN10081++) {
  4319. error = errors[indexN10081];
  4320. severity = error.severity;
  4321. type = error.type;
  4322. if(
  4323. (severity > 1)
  4324. ) {
  4325. test.strictEqual(3, severity, "isFatalError");
  4326. test.strictEqual("no-output-specified", type, "noOutputSpecified");
  4327. errorCount += 1;
  4328. }
  4329. }
  4330. test.strictEqual(1, errorCount, "oneError");
  4331. test.done();
  4332. },
  4333. /**
  4334. *
  4335. Parsing a non-Unicode normalized document not have characters normalized if normalize-characters is false.
  4336. * @author Curt Arnold
  4337. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4338. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-normalize-characters
  4339. */
  4340. normalizecharacters01 : function (test) {
  4341. var success, doc, domConfig, domImplLS, lsParser, resourceURI, nullSchemaLanguage = null;
  4342. var docElem, tagName;
  4343. domImplLS = getImplementation();
  4344. lsParser = domImplLS.createLSParser(1,nullSchemaLanguage);
  4345. domConfig = lsParser.domConfig;
  4346. domConfig.setParameter("normalize-characters", false);
  4347. resourceURI = getResourceURI("characternormalization1");
  4348. doc = lsParser.parseURI(resourceURI);
  4349. test.ok(doc !== null, "docNotNull");
  4350. docElem = doc.documentElement;
  4351. tagName = docElem.tagName;
  4352. test.strictEqual("suçon", tagName, "notNormalized");
  4353. test.done();
  4354. },
  4355. /**
  4356. *
  4357. Parsing a non-Unicode normalized document should result in Unicode-normalized content if normalize-characters is true..
  4358. * @author Curt Arnold
  4359. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4360. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-normalize-characters
  4361. */
  4362. normalizecharacters02 : function (test) {
  4363. var success, doc, domConfig, domImplLS, lsParser, resourceURI, canSet, nullSchemaLanguage = null;
  4364. var docElem, tagName;
  4365. domImplLS = getImplementation();
  4366. lsParser = domImplLS.createLSParser(1,nullSchemaLanguage);
  4367. domConfig = lsParser.domConfig;
  4368. canSet = domConfig.canSetParameter("normalize-characters",true);
  4369. if(
  4370. canSet
  4371. ) {
  4372. domConfig.setParameter("normalize-characters", true);
  4373. resourceURI = getResourceURI("characternormalization1");
  4374. doc = lsParser.parseURI(resourceURI);
  4375. test.ok(doc !== null, "docNotNull");
  4376. docElem = doc.documentElement;
  4377. tagName = docElem.tagName;
  4378. test.strictEqual("suçon", tagName, "charNormalized");
  4379. }
  4380. test.done();
  4381. },
  4382. /**
  4383. *
  4384. Characters should be normalized on serialization if normalize-characters is true.
  4385. * @author Curt Arnold
  4386. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  4387. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-normalize-characters
  4388. */
  4389. normalizecharacters03 : function (test) {
  4390. var success, doc, domConfig, domImplLS, lsSerializer, docType = null;
  4391. var docElem, newNode, output, retNode, canSet;
  4392. domImplLS = getImplementation();
  4393. lsSerializer = domImplLS.createLSSerializer();
  4394. domConfig = lsSerializer.domConfig;
  4395. canSet = domConfig.canSetParameter("normalize-characters",true);
  4396. if(
  4397. canSet
  4398. ) {
  4399. doc = domImplLS.createDocument("http://www.example.org","suçon",docType);
  4400. docElem = doc.documentElement;
  4401. domConfig.setParameter("normalize-characters", true);
  4402. output = lsSerializer.writeToString(doc);
  4403. test.ok(output.indexOf("suçon") >= 0, "notNormalized");
  4404. }
  4405. test.done();
  4406. },
  4407. /**
  4408. *
  4409. Characters should be not normalized on serialization if normalize-characters is false.
  4410. * @author Curt Arnold
  4411. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  4412. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-normalize-characters
  4413. */
  4414. normalizecharacters04 : function (test) {
  4415. var success, doc, domConfig, domImplLS, lsSerializer, docType = null;
  4416. var docElem, newNode, output, retNode, canSet;
  4417. domImplLS = getImplementation();
  4418. lsSerializer = domImplLS.createLSSerializer();
  4419. domConfig = lsSerializer.domConfig;
  4420. canSet = domConfig.canSetParameter("normalize-characters",false);
  4421. doc = domImplLS.createDocument("http://www.example.org","suçon",docType);
  4422. docElem = doc.documentElement;
  4423. domConfig.setParameter("normalize-characters", true);
  4424. output = lsSerializer.writeToString(doc);
  4425. test.ok(output.indexOf("suçon") >= 0, "notNormalized");
  4426. test.done();
  4427. },
  4428. /**
  4429. *
  4430. Validate a document with no DTD against an externally specified schema that matches its content.
  4431. * @author Curt Arnold
  4432. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4433. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-schema-location
  4434. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-schema-type
  4435. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate
  4436. */
  4437. schemalocation01 : function (test) {
  4438. var success, doc, elem, node, nodeName, domConfig, domImplLS, lsParser, nullSchemaType = null;
  4439. var resourceURI, canSetValidate, canSetSchemaType, canSetSchemaLocation, xsdNS = "http://www.w3.org/2001/XMLSchema";
  4440. domImplLS = getImplementation();
  4441. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  4442. domConfig = lsParser.domConfig;
  4443. canSetValidate = domConfig.canSetParameter("validate",true);
  4444. canSetSchemaType = domConfig.canSetParameter("schema-type",xsdNS);
  4445. resourceURI = getResourceURI("validateschema1");
  4446. canSetSchemaLocation = domConfig.canSetParameter("schema-location",resourceURI);
  4447. if(
  4448. (canSetValidate && canSetSchemaType && canSetSchemaLocation)
  4449. ) {
  4450. domConfig.setParameter("validate", true);
  4451. domConfig.setParameter("schema-type", xsdNS);
  4452. domConfig.setParameter("schema-location", resourceURI);
  4453. resourceURI = getResourceURI("validate1");
  4454. doc = lsParser.parseURI(resourceURI);
  4455. test.ok(doc !== null, "docNotNull");
  4456. elem = doc.documentElement;
  4457. test.ok(elem !== null, "docElemNotNull");
  4458. nodeName = elem.nodeName;
  4459. test.strictEqual("elt0", nodeName, "docElemName");
  4460. }
  4461. test.done();
  4462. },
  4463. /**
  4464. *
  4465. Validate a document with no DTD against an externally specified schema that does not match its content.
  4466. * @author Curt Arnold
  4467. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4468. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-schema-location
  4469. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-schema-type
  4470. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate
  4471. */
  4472. schemalocation02 : function (test) {
  4473. var success, doc, elem, node, nodeName, domConfig, domImplLS, lsParser, nullSchemaType = null;
  4474. var resourceURI, canSetValidate, canSetSchemaType, canSetSchemaLocation;
  4475. errorMonitor = new DOMErrorMonitor();
  4476. var errors = new Array();
  4477. var error, severity, errorCount = 0, xsdNS = "http://www.w3.org/2001/XMLSchema";
  4478. domImplLS = getImplementation();
  4479. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  4480. domConfig = lsParser.domConfig;
  4481. canSetValidate = domConfig.canSetParameter("validate",true);
  4482. canSetSchemaType = domConfig.canSetParameter("schema-type",xsdNS);
  4483. resourceURI = getResourceURI("validateschema1");
  4484. canSetSchemaLocation = domConfig.canSetParameter("schema-location",resourceURI);
  4485. if(
  4486. (canSetValidate && canSetSchemaType && canSetSchemaLocation)
  4487. ) {
  4488. domConfig.setParameter("validate", true);
  4489. domConfig.setParameter("schema-type", xsdNS);
  4490. domConfig.setParameter("schema-location", resourceURI);
  4491. domConfig.setParameter("error-handler", errorMonitor.handleError);
  4492. resourceURI = getResourceURI("test3");
  4493. {
  4494. success = false;
  4495. try {
  4496. doc = lsParser.parseURI(resourceURI);
  4497. }
  4498. catch(ex) {
  4499. success = (typeof(ex.code) != 'undefined' && ex.code == 81);
  4500. }
  4501. test.ok(success, "throw_PARSE_ERR");
  4502. }
  4503. errors = errorMonitor.allErrors;
  4504. for(var indexN100CE = 0;indexN100CE < errors.length; indexN100CE++) {
  4505. error = errors[indexN100CE];
  4506. severity = error.severity;
  4507. if((2 == severity)) {
  4508. errorCount += 1;
  4509. }
  4510. }
  4511. assertTrue("atLeastOneError", (errorCount > 0));
  4512. }
  4513. test.done();
  4514. },
  4515. /**
  4516. *
  4517. Serialize a document with no DTD against an externally specified schema that matches its content.
  4518. * @author Curt Arnold
  4519. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  4520. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-schema-location
  4521. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-schema-type
  4522. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate
  4523. */
  4524. schemalocation03 : function (test) {
  4525. var success, doc, elem, node, nodeName, domConfig, domImplLS, resourceURI, canSetValidate, canSetSchemaType, canSetSchemaLocation, xsdNS = "http://www.w3.org/2001/XMLSchema", lsSerializer, nullNS = null;
  4526. var doctype = null;
  4527. var output;
  4528. domImplLS = getImplementation();
  4529. lsSerializer = domImplLS.createLSSerializer();
  4530. domConfig = lsSerializer.domConfig;
  4531. canSetValidate = domConfig.canSetParameter("validate",true);
  4532. canSetSchemaType = domConfig.canSetParameter("schema-type",xsdNS);
  4533. resourceURI = getResourceURI("validateschema1");
  4534. canSetSchemaLocation = domConfig.canSetParameter("schema-location",resourceURI);
  4535. if(
  4536. (canSetValidate && canSetSchemaType && canSetSchemaLocation)
  4537. ) {
  4538. domConfig.setParameter("validate", true);
  4539. domConfig.setParameter("schema-type", xsdNS);
  4540. domConfig.setParameter("schema-location", resourceURI);
  4541. doc = domImplLS.createDocument(nullNS,"elt0",doctype);
  4542. output = lsSerializer.writeToString(doc);
  4543. }
  4544. test.done();
  4545. },
  4546. /**
  4547. *
  4548. Serialize a document with no DTD against an externally specified schema that matches its content.
  4549. * @author Curt Arnold
  4550. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  4551. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-schema-location
  4552. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-schema-type
  4553. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate
  4554. */
  4555. schemalocation04 : function (test) {
  4556. var success, doc, elem, node, nodeName, domConfig, domImplLS, resourceURI, canSetValidate, canSetSchemaType, canSetSchemaLocation, xsdNS = "http://www.w3.org/2001/XMLSchema", lsSerializer, nullNS = null;
  4557. var doctype = null;
  4558. var output;
  4559. domImplLS = getImplementation();
  4560. lsSerializer = domImplLS.createLSSerializer();
  4561. domConfig = lsSerializer.domConfig;
  4562. canSetValidate = domConfig.canSetParameter("validate",true);
  4563. canSetSchemaType = domConfig.canSetParameter("schema-type",xsdNS);
  4564. resourceURI = getResourceURI("validateschema1");
  4565. canSetSchemaLocation = domConfig.canSetParameter("schema-location",resourceURI);
  4566. if(
  4567. (canSetValidate && canSetSchemaType && canSetSchemaLocation)
  4568. ) {
  4569. domConfig.setParameter("validate", true);
  4570. domConfig.setParameter("schema-type", xsdNS);
  4571. domConfig.setParameter("schema-location", resourceURI);
  4572. doc = domImplLS.createDocument(nullNS,"elt2",doctype);
  4573. {
  4574. success = false;
  4575. try {
  4576. output = lsSerializer.writeToString(doc);
  4577. }
  4578. catch(ex) {
  4579. success = (typeof(ex.code) != 'undefined' && ex.code == 82);
  4580. }
  4581. test.ok(success, "throw_SERIALIZE_ERR");
  4582. }
  4583. }
  4584. test.done();
  4585. },
  4586. /**
  4587. *
  4588. Specify schema validation for a document with a DTD but no specified schema.
  4589. * @author Curt Arnold
  4590. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4591. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-schema-type
  4592. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate
  4593. */
  4594. schematype01 : function (test) {
  4595. var success, doc, domConfig, domImplLS, lsParser, nullSchemaType = null;
  4596. var resourceURI, canSetValidate, canSetSchemaType;
  4597. errorMonitor = new DOMErrorMonitor();
  4598. var errors = new Array();
  4599. var error, severity, errorCount = 0, xsdNS = "http://www.w3.org/2001/XMLSchema";
  4600. domImplLS = getImplementation();
  4601. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  4602. domConfig = lsParser.domConfig;
  4603. canSetValidate = domConfig.canSetParameter("validate",true);
  4604. canSetSchemaType = domConfig.canSetParameter("schema-type",xsdNS);
  4605. if(
  4606. (canSetValidate && canSetSchemaType)
  4607. ) {
  4608. domConfig.setParameter("validate", true);
  4609. domConfig.setParameter("schema-type", xsdNS);
  4610. domConfig.setParameter("error-handler", errorMonitor.handleError);
  4611. resourceURI = getResourceURI("test3");
  4612. {
  4613. success = false;
  4614. try {
  4615. doc = lsParser.parseURI(resourceURI);
  4616. }
  4617. catch(ex) {
  4618. success = (typeof(ex.code) != 'undefined' && ex.code == 81);
  4619. }
  4620. test.ok(success, "throw_PARSE_ERR");
  4621. }
  4622. errors = errorMonitor.allErrors;
  4623. for(var indexN100A8 = 0;indexN100A8 < errors.length; indexN100A8++) {
  4624. error = errors[indexN100A8];
  4625. severity = error.severity;
  4626. if((2 == severity)) {
  4627. errorCount += 1;
  4628. }
  4629. }
  4630. assertTrue("atLeastOneError", (errorCount > 0));
  4631. }
  4632. test.done();
  4633. },
  4634. /**
  4635. *
  4636. Specify DTD validation for a document with a matching DTD.
  4637. * @author Curt Arnold
  4638. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4639. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-schema-type
  4640. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate
  4641. */
  4642. schematype02 : function (test) {
  4643. var success, doc, elem, node, nodeName, domConfig, domImplLS, lsParser, nullSchemaType = null;
  4644. var resourceURI, canSetValidate, canSetSchemaType, dtdNS = "http://www.w3.org/TR/REC-xml";
  4645. domImplLS = getImplementation();
  4646. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  4647. domConfig = lsParser.domConfig;
  4648. canSetValidate = domConfig.canSetParameter("validate",true);
  4649. canSetSchemaType = domConfig.canSetParameter("schema-type",dtdNS);
  4650. if(
  4651. (canSetValidate && canSetSchemaType)
  4652. ) {
  4653. domConfig.setParameter("validate", true);
  4654. domConfig.setParameter("schema-type", dtdNS);
  4655. resourceURI = getResourceURI("test3");
  4656. doc = lsParser.parseURI(resourceURI);
  4657. test.ok(doc !== null, "docNotNull");
  4658. elem = doc.documentElement;
  4659. test.ok(elem !== null, "docElemNotNull");
  4660. nodeName = elem.nodeName;
  4661. test.strictEqual("elt0", nodeName, "docElemName");
  4662. }
  4663. test.done();
  4664. },
  4665. /**
  4666. *
  4667. Specify schema validation for a document with no DTD but schema location hints.
  4668. * @author Curt Arnold
  4669. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4670. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-schema-type
  4671. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate
  4672. */
  4673. schematype03 : function (test) {
  4674. var success, doc, elem, node, nodeName, domConfig, domImplLS, lsParser, nullSchemaType = null;
  4675. var resourceURI, canSetValidate, canSetSchemaType, xsdNS = "http://www.w3.org/2001/XMLSchema";
  4676. domImplLS = getImplementation();
  4677. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  4678. domConfig = lsParser.domConfig;
  4679. canSetValidate = domConfig.canSetParameter("validate",true);
  4680. canSetSchemaType = domConfig.canSetParameter("schema-type",xsdNS);
  4681. if(
  4682. (canSetValidate && canSetSchemaType)
  4683. ) {
  4684. domConfig.setParameter("validate", true);
  4685. domConfig.setParameter("schema-type", xsdNS);
  4686. resourceURI = getResourceURI("schematype1");
  4687. doc = lsParser.parseURI(resourceURI);
  4688. test.ok(doc !== null, "docNotNull");
  4689. elem = doc.documentElement;
  4690. test.ok(elem !== null, "docElemNotNull");
  4691. nodeName = elem.nodeName;
  4692. test.strictEqual("elt0", nodeName, "docElemName");
  4693. }
  4694. test.done();
  4695. },
  4696. /**
  4697. *
  4698. Serialize a document with schema validation but no available schema.
  4699. * @author Curt Arnold
  4700. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  4701. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-schema-type
  4702. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate
  4703. */
  4704. schematype04 : function (test) {
  4705. var success, doc, elem, node, nodeName, domConfig, domImplLS, resourceURI, canSetValidate, canSetSchemaType, xsdNS = "http://www.w3.org/2001/XMLSchema", lsSerializer, nullNS = null;
  4706. var doctype = null;
  4707. var output;
  4708. domImplLS = getImplementation();
  4709. lsSerializer = domImplLS.createLSSerializer();
  4710. domConfig = lsSerializer.domConfig;
  4711. canSetValidate = domConfig.canSetParameter("validate",true);
  4712. canSetSchemaType = domConfig.canSetParameter("schema-type",xsdNS);
  4713. if(
  4714. (canSetValidate && canSetSchemaType)
  4715. ) {
  4716. domConfig.setParameter("validate", true);
  4717. domConfig.setParameter("schema-type", xsdNS);
  4718. doc = domImplLS.createDocument(nullNS,"elt0",doctype);
  4719. {
  4720. success = false;
  4721. try {
  4722. output = lsSerializer.writeToString(doc);
  4723. }
  4724. catch(ex) {
  4725. success = (typeof(ex.code) != 'undefined' && ex.code == 82);
  4726. }
  4727. test.ok(success, "throw_SERIALIZE_ERR");
  4728. }
  4729. }
  4730. test.done();
  4731. },
  4732. /**
  4733. *
  4734. CDATASections containing unrepresentable characters should be split when split-cdata-sections is true.
  4735. * @author Curt Arnold
  4736. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  4737. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-split-cdata-sections
  4738. */
  4739. splitcdatasections01 : function (test) {
  4740. var success, doc, domConfig, domImplLS, lsSerializer, docType = null;
  4741. var docElem, newNode, output, retNode;
  4742. domImplLS = getImplementation();
  4743. lsSerializer = domImplLS.createLSSerializer();
  4744. doc = domImplLS.createDocument("http://www.example.org","test",docType);
  4745. docElem = doc.documentElement;
  4746. newNode = doc.createCDATASection("this is not ]]> good");
  4747. retNode = docElem.appendChild(newNode);
  4748. domConfig = lsSerializer.domConfig;
  4749. domConfig.setParameter("split-cdata-sections", true);
  4750. domConfig.setParameter("cdata-sections", true);
  4751. output = lsSerializer.writeToString(doc);
  4752. {
  4753. test.ok((output.indexOf("this is not ]]> good") >= 0) === false, "notNaive");
  4754. }
  4755. test.done();
  4756. },
  4757. /**
  4758. *
  4759. CDATASections containing unrepresentable characters raise a SERIALIZE_ERR when
  4760. split-cdata-sections is false and well-formed is true.
  4761. * @author Curt Arnold
  4762. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  4763. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-split-cdata-sections
  4764. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-well-formed
  4765. */
  4766. splitcdatasections02 : function (test) {
  4767. var success, doc, domConfig, domImplLS, lsSerializer, docType = null;
  4768. var docElem, newNode, output, retNode;
  4769. errorMonitor = new DOMErrorMonitor();
  4770. var errors = new Array();
  4771. var error, severity, type, errorCount = 0;
  4772. domImplLS = getImplementation();
  4773. lsSerializer = domImplLS.createLSSerializer();
  4774. doc = domImplLS.createDocument("http://www.example.org","test",docType);
  4775. docElem = doc.documentElement;
  4776. newNode = doc.createCDATASection("this is not ]]> good");
  4777. retNode = docElem.appendChild(newNode);
  4778. domConfig = lsSerializer.domConfig;
  4779. domConfig.setParameter("split-cdata-sections", false);
  4780. domConfig.setParameter("cdata-sections", true);
  4781. domConfig.setParameter("well-formed", true);
  4782. domConfig.setParameter("error-handler", errorMonitor.handleError);
  4783. {
  4784. success = false;
  4785. try {
  4786. output = lsSerializer.writeToString(doc);
  4787. }
  4788. catch(ex) {
  4789. success = (typeof(ex.code) != 'undefined' && ex.code == 82);
  4790. }
  4791. test.ok(success, "throw_SERIALIZE_ERR");
  4792. }
  4793. errors = errorMonitor.allErrors;
  4794. for(var indexN100A7 = 0;indexN100A7 < errors.length; indexN100A7++) {
  4795. error = errors[indexN100A7];
  4796. severity = error.severity;
  4797. type = error.type;
  4798. if(("wf-invalid-character" == type)) {
  4799. test.strictEqual(2, severity, "severityError");
  4800. errorCount += 1;
  4801. }
  4802. }
  4803. assertTrue("hasWfErrors", (errorCount > 0));
  4804. test.done();
  4805. },
  4806. /**
  4807. *
  4808. Parsing a document with a unsupported encoding should raise a PARSE_ERR and dispatch a "unsupported-encoding"
  4809. DOM error.
  4810. * @author Curt Arnold
  4811. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4812. */
  4813. unsupportedencoding01 : function (test) {
  4814. var success, doc, domConfig, domImplLS, lsParser, resourceURI, nullSchemaLanguage = null;
  4815. errorMonitor = new DOMErrorMonitor();
  4816. var errors = new Array();
  4817. var error, severity, type, errorCount = 0;
  4818. domImplLS = getImplementation();
  4819. lsParser = domImplLS.createLSParser(1,nullSchemaLanguage);
  4820. domConfig = lsParser.domConfig;
  4821. domConfig.setParameter("error-handler", errorMonitor.handleError);
  4822. resourceURI = getResourceURI("unsupportedencoding1");
  4823. {
  4824. success = false;
  4825. try {
  4826. doc = lsParser.parseURI(resourceURI);
  4827. }
  4828. catch(ex) {
  4829. success = (typeof(ex.code) != 'undefined' && ex.code == 81);
  4830. }
  4831. test.ok(success, "throw_PARSE_ERR");
  4832. }
  4833. errors = errorMonitor.allErrors;
  4834. for(var indexN10078 = 0;indexN10078 < errors.length; indexN10078++) {
  4835. error = errors[indexN10078];
  4836. severity = error.severity;
  4837. type = error.type;
  4838. if(("unsupported-encoding".toUpperCase() == type.toUpperCase())) {
  4839. test.strictEqual(3, severity, "isError");
  4840. errorCount += 1;
  4841. }
  4842. }
  4843. test.strictEqual(1, errorCount, "oneError");
  4844. test.done();
  4845. },
  4846. /**
  4847. *
  4848. Load a document without a DTD with validate=false, should load without complaint.
  4849. * @author Curt Arnold
  4850. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4851. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate
  4852. */
  4853. validate01 : function (test) {
  4854. var success, doc, elem, node, nodeName, domConfig, domImplLS, lsParser, nullSchemaType = null;
  4855. var resourceURI;
  4856. domImplLS = getImplementation();
  4857. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  4858. domConfig = lsParser.domConfig;
  4859. domConfig.setParameter("validate", false);
  4860. resourceURI = getResourceURI("test0");
  4861. doc = lsParser.parseURI(resourceURI);
  4862. test.ok(doc !== null, "docNotNull");
  4863. elem = doc.documentElement;
  4864. test.ok(elem !== null, "docElemNotNull");
  4865. nodeName = elem.nodeName;
  4866. test.strictEqual("elt0", nodeName, "docElemName");
  4867. test.done();
  4868. },
  4869. /**
  4870. *
  4871. Load a document without a DTD with validate=true, should throw PARSE_ERR.
  4872. * @author Curt Arnold
  4873. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4874. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate
  4875. */
  4876. validate02 : function (test) {
  4877. var success, doc, elem, node, nodeName, domConfig, domImplLS, lsParser, nullSchemaType = null;
  4878. var resourceURI;
  4879. errorMonitor = new DOMErrorMonitor();
  4880. var canSet, errors = new Array();
  4881. var error, errorCount = 0, severity;
  4882. domImplLS = getImplementation();
  4883. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  4884. domConfig = lsParser.domConfig;
  4885. canSet = domConfig.canSetParameter("validate",true);
  4886. if(
  4887. canSet
  4888. ) {
  4889. domConfig.setParameter("validate", true);
  4890. domConfig.setParameter("error-handler", errorMonitor.handleError);
  4891. resourceURI = getResourceURI("test0");
  4892. {
  4893. success = false;
  4894. try {
  4895. doc = lsParser.parseURI(resourceURI);
  4896. }
  4897. catch(ex) {
  4898. success = (typeof(ex.code) != 'undefined' && ex.code == 81);
  4899. }
  4900. test.ok(success, "throw_PARSE_ERR");
  4901. }
  4902. errors = errorMonitor.allErrors;
  4903. for(var indexN10096 = 0;indexN10096 < errors.length; indexN10096++) {
  4904. error = errors[indexN10096];
  4905. severity = error.severity;
  4906. if((2 == severity)) {
  4907. errorCount += 1;
  4908. }
  4909. }
  4910. assertTrue("atLeastOneError", (errorCount > 0));
  4911. }
  4912. test.done();
  4913. },
  4914. /**
  4915. *
  4916. Load a document with a DTD that doesn't match content with validate=false, should load without complaint.
  4917. * @author Curt Arnold
  4918. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4919. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate
  4920. */
  4921. validate03 : function (test) {
  4922. var success, doc, elem, node, nodeName, domConfig, domImplLS, lsParser, nullSchemaType = null;
  4923. var resourceURI;
  4924. domImplLS = getImplementation();
  4925. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  4926. domConfig = lsParser.domConfig;
  4927. domConfig.setParameter("validate", false);
  4928. resourceURI = getResourceURI("validate1");
  4929. doc = lsParser.parseURI(resourceURI);
  4930. test.ok(doc !== null, "docNotNull");
  4931. elem = doc.documentElement;
  4932. test.ok(elem !== null, "docElemNotNull");
  4933. nodeName = elem.nodeName;
  4934. test.strictEqual("elt0", nodeName, "docElemName");
  4935. test.done();
  4936. },
  4937. /**
  4938. *
  4939. Load a document with mismatched DTD with validate=true, should throw PARSE_ERR.
  4940. * @author Curt Arnold
  4941. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  4942. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate
  4943. */
  4944. validate04 : function (test) {
  4945. var success, doc, elem, node, nodeName, domConfig, domImplLS, lsParser, nullSchemaType = null;
  4946. var resourceURI;
  4947. errorMonitor = new DOMErrorMonitor();
  4948. var canSet, errors = new Array();
  4949. var error, errorCount = 0, severity;
  4950. domImplLS = getImplementation();
  4951. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  4952. domConfig = lsParser.domConfig;
  4953. canSet = domConfig.canSetParameter("validate",true);
  4954. if(
  4955. canSet
  4956. ) {
  4957. domConfig.setParameter("validate", true);
  4958. domConfig.setParameter("error-handler", errorMonitor.handleError);
  4959. resourceURI = getResourceURI("validate1");
  4960. {
  4961. success = false;
  4962. try {
  4963. doc = lsParser.parseURI(resourceURI);
  4964. }
  4965. catch(ex) {
  4966. success = (typeof(ex.code) != 'undefined' && ex.code == 81);
  4967. }
  4968. test.ok(success, "throw_PARSE_ERR");
  4969. }
  4970. errors = errorMonitor.allErrors;
  4971. for(var indexN10096 = 0;indexN10096 < errors.length; indexN10096++) {
  4972. error = errors[indexN10096];
  4973. severity = error.severity;
  4974. if((2 == severity)) {
  4975. errorCount += 1;
  4976. }
  4977. }
  4978. assertTrue("atLeastOneError", (errorCount > 0));
  4979. }
  4980. test.done();
  4981. },
  4982. /**
  4983. *
  4984. A document without a DTD should serialize without complaint if validate is false.
  4985. * @author Curt Arnold
  4986. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  4987. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate
  4988. */
  4989. validate05 : function (test) {
  4990. var success, doc, domConfig, domImplLS, lsSerializer, docType = null;
  4991. var output;
  4992. domImplLS = getImplementation();
  4993. lsSerializer = domImplLS.createLSSerializer();
  4994. doc = domImplLS.createDocument("http://www.example.org","test",docType);
  4995. domConfig = lsSerializer.domConfig;
  4996. domConfig.setParameter("validate", false);
  4997. output = lsSerializer.writeToString(doc);
  4998. test.done();
  4999. },
  5000. /**
  5001. *
  5002. A document without a DTD should throw a SERIALIZE_ERR if validate is true.
  5003. * @author Curt Arnold
  5004. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  5005. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate
  5006. */
  5007. validate06 : function (test) {
  5008. var success, doc, domConfig, domImplLS, lsSerializer, docType = null;
  5009. var output, canSet;
  5010. domImplLS = getImplementation();
  5011. lsSerializer = domImplLS.createLSSerializer();
  5012. doc = domImplLS.createDocument("http://www.example.org","test",docType);
  5013. domConfig = lsSerializer.domConfig;
  5014. canSet = domConfig.canSetParameter("validate",true);
  5015. if(
  5016. canSet
  5017. ) {
  5018. domConfig.setParameter("validate", true);
  5019. {
  5020. success = false;
  5021. try {
  5022. output = lsSerializer.writeToString(doc);
  5023. }
  5024. catch(ex) {
  5025. success = (typeof(ex.code) != 'undefined' && ex.code == 82);
  5026. }
  5027. test.ok(success, "throw_SERIALIZE_ERR");
  5028. }
  5029. }
  5030. test.done();
  5031. },
  5032. /**
  5033. *
  5034. Load and serialize a document with a DTD that doesn't match content with validate=false, should load and serialize without complaint.
  5035. * @author Curt Arnold
  5036. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  5037. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  5038. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate
  5039. */
  5040. validate07 : function (test) {
  5041. var success, doc, elem, node, nodeName, domConfig, domImplLS, lsParser, nullSchemaType = null;
  5042. var resourceURI, lsSerializer, output;
  5043. domImplLS = getImplementation();
  5044. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  5045. domConfig = lsParser.domConfig;
  5046. domConfig.setParameter("validate", false);
  5047. resourceURI = getResourceURI("validate1");
  5048. doc = lsParser.parseURI(resourceURI);
  5049. test.ok(doc !== null, "docNotNull");
  5050. elem = doc.documentElement;
  5051. test.ok(elem !== null, "docElemNotNull");
  5052. nodeName = elem.nodeName;
  5053. test.strictEqual("elt0", nodeName, "docElemName");
  5054. lsSerializer = domImplLS.createLSSerializer();
  5055. domConfig = lsSerializer.domConfig;
  5056. domConfig.setParameter("validate", false);
  5057. output = lsSerializer.writeToString(doc);
  5058. test.done();
  5059. },
  5060. /**
  5061. *
  5062. Load a document with a DTD that doesn't match content, then attempt to serialize when validate is true which
  5063. should result in a SERIALIZE_ERR.
  5064. * @author Curt Arnold
  5065. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  5066. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  5067. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate
  5068. */
  5069. validate08 : function (test) {
  5070. var success, doc, domConfig, domImplLS, lsParser, nullSchemaType = null;
  5071. var resourceURI, lsSerializer, output, canSet;
  5072. domImplLS = getImplementation();
  5073. lsSerializer = domImplLS.createLSSerializer();
  5074. domConfig = lsSerializer.domConfig;
  5075. canSet = domConfig.canSetParameter("validate",true);
  5076. if(
  5077. canSet
  5078. ) {
  5079. domConfig.setParameter("validate", true);
  5080. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  5081. domConfig = lsParser.domConfig;
  5082. domConfig.setParameter("validate", false);
  5083. resourceURI = getResourceURI("validate1");
  5084. doc = lsParser.parseURI(resourceURI);
  5085. {
  5086. success = false;
  5087. try {
  5088. output = lsSerializer.writeToString(doc);
  5089. }
  5090. catch(ex) {
  5091. success = (typeof(ex.code) != 'undefined' && ex.code == 82);
  5092. }
  5093. test.ok(success, "throw_SERIALIZE_ERR");
  5094. }
  5095. }
  5096. test.done();
  5097. },
  5098. /**
  5099. *
  5100. Load a document without a DTD with validate-if-schema=false, should load without complaint.
  5101. * @author Curt Arnold
  5102. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  5103. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate-if-schema
  5104. */
  5105. validateifschema01 : function (test) {
  5106. var success, doc, elem, node, nodeName, domConfig, domImplLS, lsParser, nullSchemaType = null;
  5107. var resourceURI;
  5108. domImplLS = getImplementation();
  5109. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  5110. domConfig = lsParser.domConfig;
  5111. domConfig.setParameter("validate-if-schema", false);
  5112. resourceURI = getResourceURI("test0");
  5113. doc = lsParser.parseURI(resourceURI);
  5114. test.ok(doc !== null, "docNotNull");
  5115. elem = doc.documentElement;
  5116. test.ok(elem !== null, "docElemNotNull");
  5117. nodeName = elem.nodeName;
  5118. test.strictEqual("elt0", nodeName, "docElemName");
  5119. test.done();
  5120. },
  5121. /**
  5122. *
  5123. Load a document without a DTD with validate-if-schema=true should successfully complete.
  5124. * @author Curt Arnold
  5125. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  5126. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate-if-schema
  5127. */
  5128. validateifschema02 : function (test) {
  5129. var success, doc, elem, node, nodeName, domConfig, domImplLS, lsParser, nullSchemaType = null;
  5130. var resourceURI;
  5131. errorMonitor = new DOMErrorMonitor();
  5132. var canSet;
  5133. domImplLS = getImplementation();
  5134. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  5135. domConfig = lsParser.domConfig;
  5136. canSet = domConfig.canSetParameter("validate-if-schema",true);
  5137. if(
  5138. canSet
  5139. ) {
  5140. domConfig.setParameter("validate-if-schema", true);
  5141. domConfig.setParameter("error-handler", errorMonitor.handleError);
  5142. resourceURI = getResourceURI("test0");
  5143. doc = lsParser.parseURI(resourceURI);
  5144. test.ok(doc !== null, "docNotNull");
  5145. errorMonitor.assertLowerSeverity(test, "noErrors", 2);
  5146. elem = doc.documentElement;
  5147. test.ok(elem !== null, "docElemNotNull");
  5148. nodeName = elem.nodeName;
  5149. test.strictEqual("elt0", nodeName, "docElemName");
  5150. }
  5151. test.done();
  5152. },
  5153. /**
  5154. *
  5155. Load a document with a DTD that doesn't match content with validate-if-schema=false, should load without complaint.
  5156. * @author Curt Arnold
  5157. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  5158. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate-if-schema
  5159. */
  5160. validateifschema03 : function (test) {
  5161. var success, doc, elem, node, nodeName, domConfig, domImplLS, lsParser, nullSchemaType = null;
  5162. var resourceURI;
  5163. domImplLS = getImplementation();
  5164. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  5165. domConfig = lsParser.domConfig;
  5166. domConfig.setParameter("validate-if-schema", false);
  5167. resourceURI = getResourceURI("validate1");
  5168. doc = lsParser.parseURI(resourceURI);
  5169. test.ok(doc !== null, "docNotNull");
  5170. elem = doc.documentElement;
  5171. test.ok(elem !== null, "docElemNotNull");
  5172. nodeName = elem.nodeName;
  5173. test.strictEqual("elt0", nodeName, "docElemName");
  5174. test.done();
  5175. },
  5176. /**
  5177. *
  5178. Load a document with mismatched DTD with validate-if-schema=true, should throw PARSE_ERR.
  5179. * @author Curt Arnold
  5180. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  5181. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-validate-if-schema
  5182. */
  5183. validateifschema04 : function (test) {
  5184. var success, doc, elem, node, nodeName, domConfig, domImplLS, lsParser, nullSchemaType = null;
  5185. var resourceURI;
  5186. errorMonitor = new DOMErrorMonitor();
  5187. var canSet, errors = new Array();
  5188. var error, errorCount = 0, severity;
  5189. domImplLS = getImplementation();
  5190. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  5191. domConfig = lsParser.domConfig;
  5192. canSet = domConfig.canSetParameter("validate-if-schema",true);
  5193. if(
  5194. canSet
  5195. ) {
  5196. domConfig.setParameter("validate-if-schema", true);
  5197. domConfig.setParameter("error-handler", errorMonitor.handleError);
  5198. resourceURI = getResourceURI("validate1");
  5199. {
  5200. success = false;
  5201. try {
  5202. doc = lsParser.parseURI(resourceURI);
  5203. }
  5204. catch(ex) {
  5205. success = (typeof(ex.code) != 'undefined' && ex.code == 81);
  5206. }
  5207. test.ok(success, "throw_PARSE_ERR");
  5208. }
  5209. errors = errorMonitor.allErrors;
  5210. for(var indexN10096 = 0;indexN10096 < errors.length; indexN10096++) {
  5211. error = errors[indexN10096];
  5212. severity = error.severity;
  5213. if((2 == severity)) {
  5214. errorCount += 1;
  5215. }
  5216. }
  5217. assertTrue("atLeastOneError", (errorCount > 0));
  5218. }
  5219. test.done();
  5220. },
  5221. /**
  5222. *
  5223. Load a document with an invalid character in a tagname.
  5224. * @author Curt Arnold
  5225. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  5226. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-well-formed
  5227. */
  5228. wellformed01 : function (test) {
  5229. var success, doc, elem, node, nodeName, domConfig, domImplLS, lsParser, nullSchemaType = null;
  5230. var resourceURI;
  5231. errorMonitor = new DOMErrorMonitor();
  5232. var errors = new Array();
  5233. var error, errorCount = 0, severity, type;
  5234. domImplLS = getImplementation();
  5235. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  5236. domConfig = lsParser.domConfig;
  5237. domConfig.setParameter("well-formed", true);
  5238. domConfig.setParameter("error-handler", errorMonitor.handleError);
  5239. resourceURI = getResourceURI("wellformed1");
  5240. {
  5241. success = false;
  5242. try {
  5243. doc = lsParser.parseURI(resourceURI);
  5244. }
  5245. catch(ex) {
  5246. success = (typeof(ex.code) != 'undefined' && ex.code == 81);
  5247. }
  5248. test.ok(success, "throw_PARSE_ERR");
  5249. }
  5250. errors = errorMonitor.allErrors;
  5251. for(var indexN1008C = 0;indexN1008C < errors.length; indexN1008C++) {
  5252. error = errors[indexN1008C];
  5253. type = error.type;
  5254. severity = error.severity;
  5255. if(
  5256. (severity > 1)
  5257. ) {
  5258. test.strictEqual("wf-invalid-character-in-node-name", type, "type");
  5259. test.strictEqual(2, severity, "severityError");
  5260. errorCount += 1;
  5261. }
  5262. }
  5263. test.strictEqual(1, errorCount, "oneWFError");
  5264. test.done();
  5265. },
  5266. /**
  5267. *
  5268. Load a document with an invalid character in an attribute name.
  5269. * @author Curt Arnold
  5270. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  5271. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-well-formed
  5272. */
  5273. wellformed02 : function (test) {
  5274. var success, doc, elem, node, nodeName, domConfig, domImplLS, lsParser, nullSchemaType = null;
  5275. var resourceURI;
  5276. errorMonitor = new DOMErrorMonitor();
  5277. var errors = new Array();
  5278. var error, errorCount = 0, severity, type;
  5279. domImplLS = getImplementation();
  5280. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  5281. domConfig = lsParser.domConfig;
  5282. domConfig.setParameter("well-formed", true);
  5283. domConfig.setParameter("error-handler", errorMonitor.handleError);
  5284. resourceURI = getResourceURI("wellformed2");
  5285. {
  5286. success = false;
  5287. try {
  5288. doc = lsParser.parseURI(resourceURI);
  5289. }
  5290. catch(ex) {
  5291. success = (typeof(ex.code) != 'undefined' && ex.code == 81);
  5292. }
  5293. test.ok(success, "throw_PARSE_ERR");
  5294. }
  5295. errors = errorMonitor.allErrors;
  5296. for(var indexN1008C = 0;indexN1008C < errors.length; indexN1008C++) {
  5297. error = errors[indexN1008C];
  5298. type = error.type;
  5299. severity = error.severity;
  5300. if(
  5301. (severity > 1)
  5302. ) {
  5303. test.strictEqual("wf-invalid-character-in-node-name", type, "type");
  5304. test.strictEqual(2, severity, "severityError");
  5305. errorCount += 1;
  5306. }
  5307. }
  5308. test.strictEqual(1, errorCount, "oneWFError");
  5309. test.done();
  5310. },
  5311. /**
  5312. *
  5313. Load a document with an invalid character in an attribute value, should throw a PARSE_ERR and
  5314. dispatch a DOMError with type 'wf-invalid-character'.
  5315. * @author Curt Arnold
  5316. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSParser-parseURI
  5317. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107/core#parameter-well-formed
  5318. */
  5319. wellformed03 : function (test) {
  5320. var success, doc, elem, node, nodeName, domConfig, domImplLS, lsParser, nullSchemaType = null;
  5321. var resourceURI;
  5322. errorMonitor = new DOMErrorMonitor();
  5323. var errors = new Array();
  5324. var error, errorCount = 0, severity, type;
  5325. domImplLS = getImplementation();
  5326. lsParser = domImplLS.createLSParser(1,nullSchemaType);
  5327. domConfig = lsParser.domConfig;
  5328. domConfig.setParameter("well-formed", true);
  5329. domConfig.setParameter("error-handler", errorMonitor.handleError);
  5330. resourceURI = getResourceURI("wellformed3");
  5331. {
  5332. success = false;
  5333. try {
  5334. doc = lsParser.parseURI(resourceURI);
  5335. }
  5336. catch(ex) {
  5337. success = (typeof(ex.code) != 'undefined' && ex.code == 81);
  5338. }
  5339. test.ok(success, "throw_PARSE_ERR");
  5340. }
  5341. errors = errorMonitor.allErrors;
  5342. for(var indexN1008C = 0;indexN1008C < errors.length; indexN1008C++) {
  5343. error = errors[indexN1008C];
  5344. type = error.type;
  5345. severity = error.severity;
  5346. if(("wf-invalid-character" == type)) {
  5347. test.strictEqual(2, severity, "severityError");
  5348. errorCount += 1;
  5349. }
  5350. }
  5351. test.strictEqual(1, errorCount, "oneWFError");
  5352. test.done();
  5353. },
  5354. /**
  5355. * Writes a document to a URL for a temporary file
  5356. using LSSerializer.writeToURI and rereads the document.
  5357. * @author Curt Arnold
  5358. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToURI
  5359. */
  5360. writeToURI1 : function (test) {
  5361. var success, testDoc, domImpl, output, serializer, systemId, checkSystemId, status, input, parser, checkDoc, docElem, docElemName, NULL_SCHEMA_TYPE = null;
  5362. var testDocRef = null;
  5363. if (typeof(this.testDoc) != 'undefined') {
  5364. testDocRef = this.testDoc;
  5365. }
  5366. testDoc = load(testDocRef, "testDoc", "test0");
  5367. domImpl = getImplementation();
  5368. // TODO: umm.. what? are these tests complete?
  5369. // fail("Unrecognized method or attribute createTempURI");
  5370. serializer = domImpl.createLSSerializer();
  5371. status = serializer.writeToURI(testDoc,systemId);
  5372. test.ok(status, "writeStatus");
  5373. input = domImpl.createLSInput();
  5374. input.systemId = systemId;
  5375. parser = domImpl.createLSParser(1,NULL_SCHEMA_TYPE);
  5376. checkDoc = parser.parse(input);
  5377. test.ok(checkDoc !== null, "checkNotNull");
  5378. docElem = checkDoc.documentElement;
  5379. docElemName = docElem.nodeName;
  5380. test.strictEqual("elt0", docElemName, "checkDocElemName");
  5381. test.done();
  5382. },
  5383. /**
  5384. * Writes a document to a URL for a http server
  5385. using LSSerializer.writeToURI and rereads the document.
  5386. * @author Curt Arnold
  5387. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToURI
  5388. */
  5389. writeToURI2 : function (test) {
  5390. var success, testDoc, domImpl, output, serializer, systemId, checkSystemId, status, input, parser, checkDoc, docElem, docElemName, NULL_SCHEMA_TYPE = null;
  5391. var testDocRef = null;
  5392. if (typeof(this.testDoc) != 'undefined') {
  5393. testDocRef = this.testDoc;
  5394. }
  5395. testDoc = load(testDocRef, "testDoc", "test0");
  5396. domImpl = getImplementation();
  5397. // TODO: umm.. what? are these tests complete?
  5398. // fail("Unrecognized method or attribute createTempURI");
  5399. serializer = domImpl.createLSSerializer();
  5400. status = serializer.writeToURI(testDoc,systemId);
  5401. test.ok(status, "writeStatus");
  5402. input = domImpl.createLSInput();
  5403. input.systemId = systemId;
  5404. parser = domImpl.createLSParser(1,NULL_SCHEMA_TYPE);
  5405. checkDoc = parser.parse(input);
  5406. test.ok(checkDoc !== null, "checkNotNull");
  5407. docElem = checkDoc.documentElement;
  5408. docElemName = docElem.nodeName;
  5409. test.strictEqual("elt0", docElemName, "checkDocElemName");
  5410. test.done();
  5411. },
  5412. /**
  5413. *
  5414. XML declarations should be serialized if xml-declaration is true.
  5415. * @author Curt Arnold
  5416. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  5417. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-xml-declaration
  5418. */
  5419. xmldeclaration01 : function (test) {
  5420. var success, doc, domConfig, domImplLS, lsSerializer, docType = null;
  5421. var output;
  5422. domImplLS = getImplementation();
  5423. lsSerializer = domImplLS.createLSSerializer();
  5424. doc = domImplLS.createDocument("http://www.example.org","test",docType);
  5425. domConfig = lsSerializer.domConfig;
  5426. domConfig.setParameter("xml-declaration", true);
  5427. output = lsSerializer.writeToString(doc);
  5428. test.ok(output.indexOf("<?xml") >= 0, "containsXMLDecl");
  5429. test.ok(output.indexOf("UTF-16") >= 0, "containsUTF16");
  5430. test.ok(output.indexOf("1.0") >= 0, "contains1_0");
  5431. test.done();
  5432. },
  5433. /**
  5434. *
  5435. XML declarations should not be serialized if xml-declaration is false.
  5436. * @author Curt Arnold
  5437. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#LS-LSSerializer-writeToString
  5438. * @see http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107/load-save#parameter-xml-declaration
  5439. */
  5440. xmldeclaration02 : function (test) {
  5441. var success, doc, domConfig, domImplLS, lsSerializer, docType = null;
  5442. var output;
  5443. domImplLS = getImplementation();
  5444. lsSerializer = domImplLS.createLSSerializer();
  5445. doc = domImplLS.createDocument("http://www.example.org","test",docType);
  5446. domConfig = lsSerializer.domConfig;
  5447. domConfig.setParameter("xml-declaration", false);
  5448. output = lsSerializer.writeToString(doc);
  5449. test.ok((output.indexOf("<?xml") >= 0) === false, "containsXMLDecl");
  5450. test.ok((output.indexOf("UTF-16") >= 0) === false, "containsUTF16");
  5451. test.ok((output.indexOf("1.0") >= 0) === false, "contains1_0");
  5452. test.done();
  5453. }
  5454. }