html.js 243 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778
  1. var hc_staff = require('./html/files/hc_staff.html');
  2. exports.tests = {
  3. /**
  4. *
  5. The "getDoctype()" method returns null for XML documents
  6. without a document type declaration.
  7. Retrieve the XML document without a DTD and invoke the
  8. "getDoctype()" method. It should return null.
  9. * @author NIST
  10. * @author Mary Brady
  11. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31
  12. */
  13. documentgetdoctypenodtd: function(test) {
  14. var doc = require('./html/files/hc_nodtdstaff.html').hc_nodtdstaff();
  15. test.equal(doc.doctype, null, 'documentGetDocTypeNoDTDAssert');
  16. test.done();
  17. },
  18. /**
  19. *
  20. The "createEntityReference(tagName)" method raises an
  21. INVALID_CHARACTER_ERR DOMException if the specified
  22. tagName contains an invalid character.
  23. * @author NIST
  24. * @author Mary Brady
  25. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  26. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-392B75AE
  27. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-392B75AE')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR'])
  28. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  29. */
  30. documentinvalidcharacterexceptioncreateentref: function(test) {
  31. var badEntityRef;
  32. var doc = hc_staff.hc_staff();
  33. var success = false;
  34. try {
  35. badEntityRef = doc.createEntityReference("foo");
  36. } catch(ex) {
  37. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  38. }
  39. test.ok(success, 'throw_NOT_SUPPORTED_ERR');
  40. test.done();
  41. },
  42. /**
  43. *
  44. Creating an entity reference with an empty name should cause an INVALID_CHARACTER_ERR.
  45. * @author Curt Arnold
  46. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  47. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-392B75AE
  48. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-392B75AE')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR'])
  49. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525
  50. */
  51. documentinvalidcharacterexceptioncreateentref1: function(test) {
  52. var badEntityRef;
  53. var doc = hc_staff.hc_staff();
  54. var success = false;
  55. try {
  56. badEntityRef = doc.createEntityReference("foo");
  57. } catch(ex) {
  58. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  59. }
  60. test.ok(success, 'throw_NOT_SUPPORTED_ERR');
  61. test.done();
  62. },
  63. /**
  64. *
  65. The "createProcessingInstruction(target,data) method
  66. raises an INVALID_CHARACTER_ERR DOMException if the
  67. specified tagName contains an invalid character.
  68. * @author NIST
  69. * @author Mary Brady
  70. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  71. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-135944439
  72. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-135944439')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR'])
  73. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  74. */
  75. documentinvalidcharacterexceptioncreatepi: function(test) {
  76. var success;
  77. var badPI;
  78. var doc = hc_staff.hc_staff();
  79. success = false;
  80. try {
  81. badPI = doc.createProcessingInstruction("foo","data");
  82. } catch(ex) {
  83. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  84. }
  85. test.ok(success, 'throw_NOT_SUPPORTED_ERR');
  86. test.done();
  87. },
  88. /**
  89. *
  90. Creating a processing instruction with an empty target should cause an INVALID_CHARACTER_ERR.
  91. * @author Curt Arnold
  92. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  93. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-135944439
  94. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-135944439')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR'])
  95. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525
  96. */
  97. documentinvalidcharacterexceptioncreatepi1: function(test) {
  98. var success;
  99. var badPI;
  100. var doc = hc_staff.hc_staff();
  101. success = false;
  102. try {
  103. badPI = doc.createProcessingInstruction("foo","data");
  104. } catch(ex) {
  105. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  106. }
  107. test.ok(success, 'throw_NOT_SUPPORTED_ERR');
  108. test.done();
  109. },
  110. /**
  111. *
  112. Appends a text node to an attribute and checks if the value of
  113. the attribute is changed.
  114. * @author Curt Arnold
  115. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  116. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  117. */
  118. hc_attrappendchild1: function(test) {
  119. var success;
  120. var doc;
  121. var acronymList;
  122. var testNode;
  123. var attributes;
  124. var titleAttr;
  125. var value;
  126. var textNode;
  127. var retval;
  128. var lastChild;
  129. doc = hc_staff.hc_staff();
  130. acronymList = doc.getElementsByTagName("acronym");
  131. testNode = acronymList.item(3);
  132. attributes = testNode.attributes;
  133. titleAttr = attributes.getNamedItem("title");
  134. textNode = doc.createTextNode("terday");
  135. retval = titleAttr.appendChild(textNode);
  136. value = titleAttr.value;
  137. test.equal(value, "Yesterday", 'attrValue');
  138. value = titleAttr.nodeValue;
  139. test.equal(value, "Yesterday", 'attrNodeValue');
  140. value = retval.nodeValue;
  141. test.equal(value, "terday", 'retvalValue');
  142. lastChild = titleAttr.lastChild;
  143. value = lastChild.nodeValue;
  144. test.equal(value, "terday", 'lastChildValue');
  145. test.done();
  146. },
  147. /**
  148. *
  149. Attempts to append an element to the child nodes of an attribute.
  150. * @author Curt Arnold
  151. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  152. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  153. */
  154. hc_attrappendchild2: function(test) {
  155. var doc = hc_staff.hc_staff();
  156. var titleAttr = doc.getElementsByTagName("acronym").item(3).attributes.getNamedItem("title");
  157. var newChild = doc.createElement("terday");
  158. var success = false;
  159. try {
  160. titleAttr.appendChild(newChild);
  161. } catch(ex) {
  162. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  163. }
  164. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  165. test.done();
  166. },
  167. /**
  168. *
  169. Appends a document fragment to an attribute and checks if the value of
  170. the attribute is changed.
  171. * @author Curt Arnold
  172. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  173. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  174. */
  175. hc_attrappendchild3: function(test) {
  176. var success;
  177. var doc;
  178. var acronymList;
  179. var testNode;
  180. var attributes;
  181. var titleAttr;
  182. var value;
  183. var terNode;
  184. var dayNode;
  185. var retval;
  186. var lastChild;
  187. var docFrag;
  188. doc = hc_staff.hc_staff();
  189. acronymList = doc.getElementsByTagName("acronym");
  190. testNode = acronymList.item(3);
  191. attributes = testNode.attributes;
  192. titleAttr = attributes.getNamedItem("title");
  193. terNode = doc.createTextNode("ter");
  194. dayNode = doc.createTextNode("day");
  195. docFrag = doc.createDocumentFragment();
  196. retval = docFrag.appendChild(terNode);
  197. retval = docFrag.appendChild(dayNode);
  198. retval = titleAttr.appendChild(docFrag);
  199. value = titleAttr.value;
  200. test.equal(value, "Yesterday", 'attrValue');
  201. value = titleAttr.nodeValue;
  202. test.equal(value, "Yesterday", 'attrNodeValue');
  203. value = retval.nodeValue;
  204. test.equal(value, null, 'retvalValue');
  205. lastChild = titleAttr.lastChild;
  206. value = lastChild.nodeValue;
  207. test.equal(value, "day", 'lastChildValue');
  208. test.done();
  209. },
  210. /**
  211. *
  212. Attempt to append a CDATASection to an attribute which should result
  213. in a HIERARCHY_REQUEST_ERR.
  214. * @author Curt Arnold
  215. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  216. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  217. */
  218. hc_attrappendchild4: function(test) {
  219. var doc = hc_staff.hc_staff();
  220. var success = false;
  221. try {
  222. doc.createCDATASection("terday");
  223. } catch(ex) {
  224. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  225. }
  226. test.ok(success, 'throw_NOT_SUPPORTED_ERR');
  227. test.done();
  228. },
  229. /**
  230. *
  231. Attempt to append a node from another document to an attribute which should result
  232. in a WRONG_DOCUMENT_ERR.
  233. * @author Curt Arnold
  234. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  235. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  236. */
  237. hc_attrappendchild5: function(test) {
  238. var doc = hc_staff.hc_staff();
  239. var otherDoc = hc_staff.hc_staff();
  240. var titleAttr = doc.getElementsByTagName("acronym").item(3).attributes.getNamedItem("title");
  241. var textNode = otherDoc.createTextNode("terday");
  242. var success = false;
  243. try {
  244. titleAttr.appendChild(textNode);
  245. } catch(ex) {
  246. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  247. }
  248. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  249. test.done();
  250. },
  251. /**
  252. *
  253. Creates an new attribute node and appends a text node.
  254. * @author Curt Arnold
  255. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  256. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  257. */
  258. hc_attrappendchild6: function(test) {
  259. var success;
  260. var doc;
  261. var acronymList;
  262. var testNode;
  263. var attributes;
  264. var titleAttr;
  265. var value;
  266. var textNode;
  267. var retval;
  268. var lastChild;
  269. doc = hc_staff.hc_staff();
  270. titleAttr = doc.createAttribute("title");
  271. textNode = doc.createTextNode("Yesterday");
  272. retval = titleAttr.appendChild(textNode);
  273. value = titleAttr.value;
  274. test.equal(value, "Yesterday", 'attrValue');
  275. value = titleAttr.nodeValue;
  276. test.equal(value, "Yesterday", 'attrNodeValue');
  277. value = retval.nodeValue;
  278. test.equal(value, "Yesterday", 'retvalValue');
  279. lastChild = titleAttr.lastChild;
  280. value = lastChild.nodeValue;
  281. test.equal(value, "Yesterday", 'lastChildValue');
  282. test.done();
  283. },
  284. /**
  285. *
  286. Checks that Node.childNodes for an attribute node contains
  287. the expected text node.
  288. * @author Curt Arnold
  289. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  290. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  291. */
  292. hc_attrchildnodes1: function(test) {
  293. var success;
  294. var doc;
  295. var acronymList;
  296. var testNode;
  297. var attributes;
  298. var titleAttr;
  299. var value;
  300. var textNode;
  301. var childNodes;
  302. doc = hc_staff.hc_staff();
  303. acronymList = doc.getElementsByTagName("acronym");
  304. testNode = acronymList.item(3);
  305. attributes = testNode.attributes;
  306. titleAttr = attributes.getNamedItem("title");
  307. childNodes = titleAttr.childNodes;
  308. test.equal(childNodes.length, 1, 'childNodesSize');
  309. textNode = childNodes.item(0);
  310. value = textNode.nodeValue;
  311. test.equal(value, "Yes", 'child1IsYes');
  312. textNode = childNodes.item(1);
  313. test.equal(textNode, null, 'secondItemIsNull');
  314. test.done();
  315. },
  316. /**
  317. *
  318. Checks Node.childNodes for an attribute with multiple child nodes.
  319. * @author Curt Arnold
  320. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  321. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  322. */
  323. hc_attrchildnodes2: function(test) {
  324. var success;
  325. var doc;
  326. var acronymList;
  327. var testNode;
  328. var attributes;
  329. var titleAttr;
  330. var value;
  331. var textNode;
  332. var childNodes;
  333. var retval;
  334. doc = hc_staff.hc_staff();
  335. acronymList = doc.getElementsByTagName("acronym");
  336. testNode = acronymList.item(3);
  337. attributes = testNode.attributes;
  338. titleAttr = attributes.getNamedItem("title");
  339. childNodes = titleAttr.childNodes;
  340. textNode = doc.createTextNode("terday");
  341. retval = titleAttr.appendChild(textNode);
  342. test.equal(childNodes.length, 2, 'childNodesSize');
  343. textNode = childNodes.item(0);
  344. value = textNode.nodeValue;
  345. test.equal(value, "Yes", 'child1IsYes');
  346. textNode = childNodes.item(1);
  347. value = textNode.nodeValue;
  348. test.equal(value, "terday", 'child2IsTerday');
  349. textNode = childNodes.item(2);
  350. test.equal(textNode, null, 'thirdItemIsNull');
  351. test.done();
  352. },
  353. /**
  354. *
  355. Appends a text node to an attribute and clones the node.
  356. * @author Curt Arnold
  357. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  358. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
  359. */
  360. hc_attrclonenode1: function(test) {
  361. var success;
  362. var doc;
  363. var acronymList;
  364. var testNode;
  365. var attributes;
  366. var titleAttr;
  367. var value;
  368. var textNode;
  369. var retval;
  370. var lastChild;
  371. var clonedTitle;
  372. doc = hc_staff.hc_staff();
  373. acronymList = doc.getElementsByTagName("acronym");
  374. testNode = acronymList.item(3);
  375. attributes = testNode.attributes;
  376. titleAttr = attributes.getNamedItem("title");
  377. textNode = doc.createTextNode("terday");
  378. retval = titleAttr.appendChild(textNode);
  379. clonedTitle = titleAttr.cloneNode(false);
  380. textNode.nodeValue = "text_node_not_cloned";
  381. value = clonedTitle.value;
  382. test.equal(value, "Yesterday", 'attrValue');
  383. value = clonedTitle.nodeValue;
  384. test.equal(value, "Yesterday", 'attrNodeValue');
  385. lastChild = clonedTitle.lastChild;
  386. value = lastChild.nodeValue;
  387. test.equal(value, "terday", 'lastChildValue');
  388. test.done();
  389. },
  390. /**
  391. *
  392. Create a new DocumentFragment and add a newly created Element node(with one attribute).
  393. Once the element is added, its attribute should be available as an attribute associated
  394. with an Element within a DocumentFragment.
  395. * @author Curt Arnold
  396. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-35CB04B5
  397. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
  398. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
  399. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  400. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
  401. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
  402. */
  403. hc_attrcreatedocumentfragment: function(test) {
  404. var langAttrCount = 0;
  405. var doc = hc_staff.hc_staff();
  406. var docFragment = doc.createDocumentFragment();
  407. var newOne = doc.createElement("html");
  408. newOne.setAttribute("lang","EN");
  409. docFragment.appendChild(newOne);
  410. var attributes = docFragment.firstChild.attributes;
  411. for(var i=0;i<attributes.length;i++) {
  412. attribute = attributes.item(i);
  413. attrName = attribute.nodeName;
  414. if(attrName == "lang") {
  415. langAttrCount += 1;
  416. }
  417. }
  418. test.equal(langAttrCount, 1, 'hasLangAttr');
  419. test.done();
  420. },
  421. /**
  422. *
  423. The "setValue()" method for an attribute creates a
  424. Text node with the unparsed content of the string.
  425. Retrieve the attribute named "class" from the last
  426. child of of the fourth employee and assign the "Y&ent1;"
  427. string to its value attribute. This value is not yet
  428. parsed and therefore should still be the same upon
  429. retrieval. This test uses the "getNamedItem(name)" method
  430. from the NamedNodeMap interface.
  431. * @author Curt Arnold
  432. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
  433. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Apr/0057.html
  434. */
  435. hc_attrcreatetextnode: function(test) {
  436. var success;
  437. var doc;
  438. var addressList;
  439. var testNode;
  440. var attributes;
  441. var streetAttr;
  442. var value;
  443. doc = hc_staff.hc_staff();
  444. addressList = doc.getElementsByTagName("acronym");
  445. testNode = addressList.item(3);
  446. attributes = testNode.attributes;
  447. streetAttr = attributes.getNamedItem("class");
  448. streetAttr.value = "Y&ent1;";
  449. value = streetAttr.value;
  450. test.equal(value, "Y&ent1;", 'value');
  451. value = streetAttr.nodeValue;
  452. test.equal(value, "Y&ent1;", 'nodeValue');
  453. test.done();
  454. },
  455. /**
  456. *
  457. The "setNodeValue()" method for an attribute creates a
  458. Text node with the unparsed content of the string.
  459. Retrieve the attribute named "class" from the last
  460. child of of the fourth employee and assign the "Y&ent1;"
  461. string to its value attribute. This value is not yet
  462. parsed and therefore should still be the same upon
  463. retrieval. This test uses the "getNamedItem(name)" method
  464. from the NamedNodeMap interface.
  465. * @author Curt Arnold
  466. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  467. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Apr/0057.html
  468. */
  469. hc_attrcreatetextnode2: function(test) {
  470. var success;
  471. var doc;
  472. var addressList;
  473. var testNode;
  474. var attributes;
  475. var streetAttr;
  476. var value;
  477. doc = hc_staff.hc_staff();
  478. addressList = doc.getElementsByTagName("acronym");
  479. testNode = addressList.item(3);
  480. attributes = testNode.attributes;
  481. streetAttr = attributes.getNamedItem("class");
  482. streetAttr.nodeValue = "Y&ent1;";
  483. value = streetAttr.value;
  484. test.equal(value, "Y&ent1;", 'value');
  485. value = streetAttr.nodeValue;
  486. test.equal(value, "Y&ent1;", 'nodeValue');
  487. test.done();
  488. },
  489. /**
  490. *
  491. If an Attr is explicitly assigned any value, then that value is the attributes effective value.
  492. Retrieve the attribute named "domestic" from the last child of of the first employee
  493. and examine its nodeValue attribute. This test uses the "getNamedItem(name)" method
  494. from the NamedNodeMap interface.
  495. * @author Curt Arnold
  496. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  497. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
  498. */
  499. hc_attreffectivevalue: function(test) {
  500. var success;
  501. var doc;
  502. var addressList;
  503. var testNode;
  504. var attributes;
  505. var domesticAttr;
  506. var value;
  507. doc = hc_staff.hc_staff();
  508. addressList = doc.getElementsByTagName("acronym");
  509. testNode = addressList.item(0);
  510. attributes = testNode.attributes;
  511. domesticAttr = attributes.getNamedItem("title");
  512. value = domesticAttr.nodeValue;
  513. test.equal(value, "Yes", 'attrEffectiveValueAssert');
  514. test.done();
  515. },
  516. /**
  517. *
  518. Checks that Node.firstChild for an attribute node contains
  519. the expected text node.
  520. * @author Curt Arnold
  521. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  522. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-169727388
  523. */
  524. hc_attrfirstchild: function(test) {
  525. var success;
  526. var doc;
  527. var acronymList;
  528. var testNode;
  529. var attributes;
  530. var titleAttr;
  531. var value;
  532. var textNode;
  533. var otherChild;
  534. doc = hc_staff.hc_staff();
  535. acronymList = doc.getElementsByTagName("acronym");
  536. testNode = acronymList.item(3);
  537. attributes = testNode.attributes;
  538. titleAttr = attributes.getNamedItem("title");
  539. textNode = titleAttr.firstChild;
  540. test.notEqual(textNode, null, 'textNodeNotNull');
  541. value = textNode.nodeValue;
  542. test.equal(value, "Yes", 'child1IsYes');
  543. otherChild = textNode.nextSibling;
  544. test.equal(otherChild, null, 'nextSiblingIsNull');
  545. otherChild = textNode.previousSibling;
  546. test.equal(otherChild, null, 'previousSiblingIsNull');
  547. test.done();
  548. },
  549. /**
  550. *
  551. Checks the value of an attribute that contains entity references.
  552. * @author Curt Arnold
  553. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
  554. */
  555. hc_attrgetvalue1: function(test) {
  556. var success;
  557. var doc;
  558. var acronymList;
  559. var testNode;
  560. var attributes;
  561. var titleAttr;
  562. var value;
  563. var textNode;
  564. var retval;
  565. var lastChild;
  566. doc = hc_staff.hc_staff();
  567. acronymList = doc.getElementsByTagName("acronym");
  568. testNode = acronymList.item(3);
  569. attributes = testNode.attributes;
  570. titleAttr = attributes.getNamedItem("class");
  571. value = titleAttr.value;
  572. test.equal(value, "Yα", 'attrValue1');
  573. test.done();
  574. },
  575. /**
  576. *
  577. Checks the value of an attribute that contains entity references.
  578. * @author Curt Arnold
  579. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
  580. */
  581. hc_attrgetvalue2: function(test) {
  582. var doc = hc_staff.hc_staff();
  583. var success = false;
  584. try {
  585. doc.createEntityReference("alpha");
  586. } catch(ex) {
  587. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  588. }
  589. test.ok(success, 'throw_NOT_SUPPORTED_ERR');
  590. test.done();
  591. },
  592. /**
  593. *
  594. Checks that Node.hasChildNodes() is true for an attribute with content.
  595. * @author Curt Arnold
  596. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  597. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-810594187
  598. */
  599. hc_attrhaschildnodes: function(test) {
  600. var success;
  601. var doc;
  602. var acronymList;
  603. var testNode;
  604. var attributes;
  605. var titleAttr;
  606. var hasChildNodes;
  607. doc = hc_staff.hc_staff();
  608. acronymList = doc.getElementsByTagName("acronym");
  609. testNode = acronymList.item(3);
  610. attributes = testNode.attributes;
  611. titleAttr = attributes.getNamedItem("title");
  612. hasChildNodes = titleAttr.hasChildNodes();
  613. test.ok(hasChildNodes, 'hasChildrenIsTrue');
  614. test.done();
  615. },
  616. /**
  617. *
  618. Appends a text node to an attribute and checks if the value of
  619. the attribute is changed.
  620. * @author Curt Arnold
  621. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  622. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  623. */
  624. hc_attrinsertbefore1: function(test) {
  625. var success;
  626. var doc;
  627. var acronymList;
  628. var testNode;
  629. var attributes;
  630. var titleAttr;
  631. var value;
  632. var textNode;
  633. var retval;
  634. var firstChild;
  635. var lastChild;
  636. var refChild = null;
  637. doc = hc_staff.hc_staff();
  638. acronymList = doc.getElementsByTagName("acronym");
  639. testNode = acronymList.item(3);
  640. attributes = testNode.attributes;
  641. titleAttr = attributes.getNamedItem("title");
  642. textNode = doc.createTextNode("terday");
  643. retval = titleAttr.insertBefore(textNode,refChild);
  644. value = titleAttr.value;
  645. test.equal(value, "Yesterday", 'attrValue');
  646. value = titleAttr.nodeValue;
  647. test.equal(value, "Yesterday", 'attrNodeValue');
  648. value = retval.nodeValue;
  649. test.equal(value, "terday", 'retvalValue');
  650. firstChild = titleAttr.firstChild;
  651. value = firstChild.nodeValue;
  652. test.equal(value, "Yes", 'firstChildValue');
  653. lastChild = titleAttr.lastChild;
  654. value = lastChild.nodeValue;
  655. test.equal(value, "terday", 'lastChildValue');
  656. test.done();
  657. },
  658. /**
  659. *
  660. Prepends a text node to an attribute and checks if the value of
  661. the attribute is changed.
  662. * @author Curt Arnold
  663. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  664. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  665. */
  666. hc_attrinsertbefore2: function(test) {
  667. var success;
  668. var doc;
  669. var acronymList;
  670. var testNode;
  671. var attributes;
  672. var titleAttr;
  673. var value;
  674. var textNode;
  675. var retval;
  676. var lastChild;
  677. var firstChild;
  678. var refChild;
  679. doc = hc_staff.hc_staff();
  680. acronymList = doc.getElementsByTagName("acronym");
  681. testNode = acronymList.item(3);
  682. attributes = testNode.attributes;
  683. titleAttr = attributes.getNamedItem("title");
  684. textNode = doc.createTextNode("terday");
  685. refChild = titleAttr.firstChild;
  686. retval = titleAttr.insertBefore(textNode,refChild);
  687. value = titleAttr.value;
  688. test.equal(value, "terdayYes", 'attrValue');
  689. value = titleAttr.nodeValue;
  690. test.equal(value, "terdayYes", 'attrNodeValue');
  691. value = retval.nodeValue;
  692. test.equal(value, "terday", 'retvalValue');
  693. firstChild = titleAttr.firstChild;
  694. value = firstChild.nodeValue;
  695. test.equal(value, "terday", 'firstChildValue');
  696. lastChild = titleAttr.lastChild;
  697. value = lastChild.nodeValue;
  698. test.equal(value, "Yes", 'lastChildValue');
  699. test.done();
  700. },
  701. /**
  702. *
  703. Appends a document fragment to an attribute and checks if the value of
  704. the attribute is changed.
  705. * @author Curt Arnold
  706. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  707. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  708. */
  709. hc_attrinsertbefore3: function(test) {
  710. var success;
  711. var doc;
  712. var acronymList;
  713. var testNode;
  714. var attributes;
  715. var titleAttr;
  716. var value;
  717. var terNode;
  718. var dayNode;
  719. var docFrag;
  720. var retval;
  721. var firstChild;
  722. var lastChild;
  723. var refChild = null;
  724. doc = hc_staff.hc_staff();
  725. acronymList = doc.getElementsByTagName("acronym");
  726. testNode = acronymList.item(3);
  727. attributes = testNode.attributes;
  728. titleAttr = attributes.getNamedItem("title");
  729. terNode = doc.createTextNode("ter");
  730. dayNode = doc.createTextNode("day");
  731. docFrag = doc.createDocumentFragment();
  732. retval = docFrag.appendChild(terNode);
  733. retval = docFrag.appendChild(dayNode);
  734. retval = titleAttr.insertBefore(docFrag,refChild);
  735. value = titleAttr.value;
  736. test.equal(value, "Yesterday", 'attrValue');
  737. value = titleAttr.nodeValue;
  738. test.equal(value, "Yesterday", 'attrNodeValue');
  739. value = retval.nodeValue;
  740. test.equal(value, null, 'retvalValue');
  741. firstChild = titleAttr.firstChild;
  742. value = firstChild.nodeValue;
  743. test.equal(value, "Yes", 'firstChildValue');
  744. lastChild = titleAttr.lastChild;
  745. value = lastChild.nodeValue;
  746. test.equal(value, "day", 'lastChildValue');
  747. test.done();
  748. },
  749. /**
  750. *
  751. Prepends a document fragment to an attribute and checks if the value of
  752. the attribute is changed.
  753. * @author Curt Arnold
  754. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  755. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  756. */
  757. hc_attrinsertbefore4: function(test) {
  758. var success;
  759. var doc;
  760. var acronymList;
  761. var testNode;
  762. var attributes;
  763. var titleAttr;
  764. var value;
  765. var terNode;
  766. var dayNode;
  767. var docFrag;
  768. var retval;
  769. var firstChild;
  770. var lastChild;
  771. var refChild;
  772. doc = hc_staff.hc_staff();
  773. acronymList = doc.getElementsByTagName("acronym");
  774. testNode = acronymList.item(3);
  775. attributes = testNode.attributes;
  776. titleAttr = attributes.getNamedItem("title");
  777. terNode = doc.createTextNode("ter");
  778. dayNode = doc.createTextNode("day");
  779. docFrag = doc.createDocumentFragment();
  780. retval = docFrag.appendChild(terNode);
  781. retval = docFrag.appendChild(dayNode);
  782. refChild = titleAttr.firstChild;
  783. retval = titleAttr.insertBefore(docFrag,refChild);
  784. value = titleAttr.value;
  785. test.equal(value, "terdayYes", 'attrValue');
  786. value = titleAttr.nodeValue;
  787. test.equal(value, "terdayYes", 'attrNodeValue');
  788. value = retval.nodeValue;
  789. test.equal(value, null, 'retvalValue');
  790. firstChild = titleAttr.firstChild;
  791. value = firstChild.nodeValue;
  792. test.equal(value, "ter", 'firstChildValue');
  793. lastChild = titleAttr.lastChild;
  794. value = lastChild.nodeValue;
  795. test.equal(value, "Yes", 'lastChildValue');
  796. test.done();
  797. },
  798. /**
  799. *
  800. Attempt to append a CDATASection to an attribute which should result
  801. in a HIERARCHY_REQUEST_ERR.
  802. * @author Curt Arnold
  803. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  804. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  805. */
  806. hc_attrinsertbefore5: function(test) {
  807. var doc = hc_staff.hc_staff();
  808. var success = false;
  809. try {
  810. doc.createCDATASection("terday");
  811. } catch(ex) {
  812. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  813. }
  814. test.ok(success, 'throw_NOT_SUPPORTED_ERR');
  815. test.done();
  816. },
  817. /**
  818. *
  819. Attempt to append a text node from another document to an attribute which should result
  820. in a WRONG_DOCUMENT_ERR.
  821. * @author Curt Arnold
  822. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  823. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  824. */
  825. hc_attrinsertbefore6: function(test) {
  826. var doc = hc_staff.hc_staff();
  827. var otherDoc = hc_staff.hc_staff();
  828. var titleAttr = doc.getElementsByTagName("acronym").item(3).attributes.getNamedItem("title");
  829. var textNode = otherDoc.createTextNode("terday");
  830. var success = false;
  831. try {
  832. titleAttr.insertBefore(textNode, null);
  833. } catch(ex) {
  834. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  835. }
  836. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  837. test.done();
  838. },
  839. /**
  840. *
  841. Appends a document fragment containing a CDATASection to an attribute.
  842. * @author Curt Arnold
  843. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  844. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  845. */
  846. hc_attrinsertbefore7: function(test) {
  847. var doc = hc_staff.hc_staff();
  848. var success = false;
  849. try {
  850. doc.createCDATASection("day");
  851. } catch(ex) {
  852. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  853. }
  854. test.ok(success, 'throw_NOT_SUPPORTED_ERR');
  855. test.done();
  856. },
  857. /**
  858. *
  859. Checks that Node.lastChild for an attribute node contains
  860. the expected text node.
  861. * @author Curt Arnold
  862. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  863. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-61AD09FB
  864. */
  865. hc_attrlastchild: function(test) {
  866. var success;
  867. var doc;
  868. var acronymList;
  869. var testNode;
  870. var attributes;
  871. var titleAttr;
  872. var value;
  873. var textNode;
  874. var otherChild;
  875. doc = hc_staff.hc_staff();
  876. acronymList = doc.getElementsByTagName("acronym");
  877. testNode = acronymList.item(3);
  878. attributes = testNode.attributes;
  879. titleAttr = attributes.getNamedItem("title");
  880. textNode = titleAttr.firstChild;
  881. test.notEqual(textNode, null, 'textNodeNotNull');
  882. value = textNode.nodeValue;
  883. test.equal(value, "Yes", 'child1IsYes');
  884. otherChild = textNode.nextSibling;
  885. test.equal(otherChild, null, 'nextSiblingIsNull');
  886. otherChild = textNode.previousSibling;
  887. test.equal(otherChild, null, 'previousSiblingIsNull');
  888. test.done();
  889. },
  890. /**
  891. *
  892. Retrieve the attribute named class from the last
  893. child of of the second "p" element and examine its
  894. NodeName.
  895. * @author Curt Arnold
  896. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  897. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1112119403
  898. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  899. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
  900. */
  901. hc_attrname: function(test) {
  902. var doc = hc_staff.hc_staff();
  903. var streetAttr = doc.getElementsByTagName("acronym").item(1).attributes.getNamedItem("class");
  904. test.equal(streetAttr.nodeName, 'class', 'attribute nodeName');
  905. test.equal(streetAttr.name, 'class', 'attribute name');
  906. test.done();
  907. },
  908. /**
  909. *
  910. The "getNextSibling()" method for an Attr node should return null.
  911. Retrieve the attribute named "domestic" from the last child of of the
  912. first employee and examine its NextSibling node. This test uses the
  913. "getNamedItem(name)" method from the NamedNodeMap interface.
  914. * @author Curt Arnold
  915. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F
  916. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  917. */
  918. hc_attrnextsiblingnull: function(test) {
  919. var success;
  920. var doc;
  921. var addressList;
  922. var testNode;
  923. var attributes;
  924. var domesticAttr;
  925. var s;
  926. doc = hc_staff.hc_staff();
  927. addressList = doc.getElementsByTagName("acronym");
  928. testNode = addressList.item(0);
  929. attributes = testNode.attributes;
  930. domesticAttr = attributes.getNamedItem("title");
  931. s = domesticAttr.nextSibling;
  932. test.equal(s, null, 'attrNextSiblingNullAssert');
  933. test.done();
  934. },
  935. /**
  936. *
  937. Appends a text node to an attribute, normalizes the attribute
  938. and checks for a single child node.
  939. * @author Curt Arnold
  940. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  941. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083
  942. */
  943. hc_attrnormalize: function(test) {
  944. var success;
  945. var doc;
  946. var acronymList;
  947. var testNode;
  948. var attributes;
  949. var titleAttr;
  950. var value;
  951. var textNode;
  952. var retval;
  953. var firstChild;
  954. var secondChild;
  955. doc = hc_staff.hc_staff();
  956. acronymList = doc.getElementsByTagName("acronym");
  957. testNode = acronymList.item(3);
  958. attributes = testNode.attributes;
  959. titleAttr = attributes.getNamedItem("title");
  960. textNode = doc.createTextNode("terday");
  961. retval = titleAttr.appendChild(textNode);
  962. textNode = doc.createTextNode("");
  963. retval = titleAttr.appendChild(textNode);
  964. testNode.normalize();
  965. value = titleAttr.nodeValue;
  966. test.equal(value, "Yesterday", 'attrNodeValue');
  967. firstChild = titleAttr.firstChild;
  968. value = firstChild.nodeValue;
  969. test.equal(value, "Yesterday", 'firstChildValue');
  970. secondChild = firstChild.nextSibling;
  971. test.equal(secondChild, null, 'secondChildIsNull');
  972. test.done();
  973. },
  974. /**
  975. *
  976. The "getParentNode()" method for an Attr node should return null. Retrieve
  977. the attribute named "domestic" from the last child of the first employee
  978. and examine its parentNode attribute. This test also uses the "getNamedItem(name)"
  979. method from the NamedNodeMap interface.
  980. * @author Curt Arnold
  981. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317
  982. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  983. */
  984. hc_attrparentnodenull: function(test) {
  985. var success;
  986. var doc;
  987. var addressList;
  988. var testNode;
  989. var attributes;
  990. var domesticAttr;
  991. var s;
  992. doc = hc_staff.hc_staff();
  993. addressList = doc.getElementsByTagName("acronym");
  994. testNode = addressList.item(0);
  995. attributes = testNode.attributes;
  996. domesticAttr = attributes.getNamedItem("title");
  997. s = domesticAttr.parentNode;
  998. test.equal(s, null, 'attrParentNodeNullAssert');
  999. test.done();
  1000. },
  1001. /**
  1002. *
  1003. The "getPreviousSibling()" method for an Attr node should return null.
  1004. Retrieve the attribute named "domestic" from the last child of of the
  1005. first employee and examine its PreviousSibling node. This test uses the
  1006. "getNamedItem(name)" method from the NamedNodeMap interface.
  1007. * @author Curt Arnold
  1008. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8
  1009. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  1010. */
  1011. hc_attrprevioussiblingnull: function(test) {
  1012. var success;
  1013. var doc;
  1014. var addressList;
  1015. var testNode;
  1016. var attributes;
  1017. var domesticAttr;
  1018. var s;
  1019. doc = hc_staff.hc_staff();
  1020. addressList = doc.getElementsByTagName("acronym");
  1021. testNode = addressList.item(0);
  1022. attributes = testNode.attributes;
  1023. domesticAttr = attributes.getNamedItem("title");
  1024. s = domesticAttr.previousSibling;
  1025. test.equal(s, null, 'attrPreviousSiblingNullAssert');
  1026. test.done();
  1027. },
  1028. /**
  1029. *
  1030. Removes the child node of an attribute and checks that the value is empty.
  1031. * @author Curt Arnold
  1032. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  1033. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  1034. */
  1035. hc_attrremovechild1: function(test) {
  1036. var success;
  1037. var doc;
  1038. var acronymList;
  1039. var testNode;
  1040. var attributes;
  1041. var titleAttr;
  1042. var value;
  1043. var textNode;
  1044. var retval;
  1045. var firstChild;
  1046. doc = hc_staff.hc_staff();
  1047. acronymList = doc.getElementsByTagName("acronym");
  1048. testNode = acronymList.item(3);
  1049. attributes = testNode.attributes;
  1050. titleAttr = attributes.getNamedItem("title");
  1051. textNode = titleAttr.firstChild;
  1052. test.notEqual(textNode, null, 'attrChildNotNull');
  1053. retval = titleAttr.removeChild(textNode);
  1054. value = titleAttr.value;
  1055. test.equal(value, "", 'attrValue');
  1056. value = titleAttr.nodeValue;
  1057. test.equal(value, "", 'attrNodeValue');
  1058. value = retval.nodeValue;
  1059. test.equal(value, "Yes", 'retvalValue');
  1060. firstChild = titleAttr.firstChild;
  1061. test.equal(firstChild, null, 'firstChildNull');
  1062. test.done();
  1063. },
  1064. /**
  1065. *
  1066. Attempts to remove a freshly created text node which should result in a NOT_FOUND_ERR exception.
  1067. * @author Curt Arnold
  1068. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  1069. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  1070. */
  1071. hc_attrremovechild2: function(test) {
  1072. var doc = hc_staff.hc_staff();
  1073. var titleAttr = doc.getElementsByTagName("acronym").item(3).attributes.getNamedItem("title");
  1074. var textNode = doc.createTextNode("Yesterday");
  1075. var success = false;
  1076. try {
  1077. titleAttr.removeChild(textNode);
  1078. } catch(ex) {
  1079. success = (typeof(ex.code) != 'undefined' && ex.code == 8);
  1080. }
  1081. test.ok(success, 'throw_NOT_FOUND_ERR');
  1082. test.done();
  1083. },
  1084. /**
  1085. *
  1086. Replaces a text node of an attribute and checks if the value of
  1087. the attribute is changed.
  1088. * @author Curt Arnold
  1089. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  1090. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  1091. */
  1092. hc_attrreplacechild1: function(test) {
  1093. var success;
  1094. var doc;
  1095. var acronymList;
  1096. var testNode;
  1097. var attributes;
  1098. var titleAttr;
  1099. var value;
  1100. var textNode;
  1101. var retval;
  1102. var firstChild;
  1103. doc = hc_staff.hc_staff();
  1104. acronymList = doc.getElementsByTagName("acronym");
  1105. testNode = acronymList.item(3);
  1106. attributes = testNode.attributes;
  1107. titleAttr = attributes.getNamedItem("title");
  1108. textNode = doc.createTextNode("terday");
  1109. firstChild = titleAttr.firstChild;
  1110. test.notEqual(firstChild, null, 'attrChildNotNull');
  1111. retval = titleAttr.replaceChild(textNode,firstChild);
  1112. value = titleAttr.value;
  1113. test.equal(value, "terday", 'attrValue');
  1114. value = titleAttr.nodeValue;
  1115. test.equal(value, "terday", 'attrNodeValue');
  1116. value = retval.nodeValue;
  1117. test.equal(value, "Yes", 'retvalValue');
  1118. firstChild = titleAttr.firstChild;
  1119. value = firstChild.nodeValue;
  1120. test.equal(value, "terday", 'firstChildValue');
  1121. test.done();
  1122. },
  1123. /**
  1124. *
  1125. Replaces a text node of an attribute with a document fragment and checks if the value of
  1126. the attribute is changed.
  1127. * @author Curt Arnold
  1128. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  1129. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  1130. */
  1131. hc_attrreplacechild2: function(test) {
  1132. var success;
  1133. var doc;
  1134. var acronymList;
  1135. var testNode;
  1136. var attributes;
  1137. var titleAttr;
  1138. var value;
  1139. var terNode;
  1140. var dayNode;
  1141. var docFrag;
  1142. var retval;
  1143. var firstChild;
  1144. doc = hc_staff.hc_staff();
  1145. acronymList = doc.getElementsByTagName("acronym");
  1146. testNode = acronymList.item(3);
  1147. attributes = testNode.attributes;
  1148. titleAttr = attributes.getNamedItem("title");
  1149. terNode = doc.createTextNode("ter");
  1150. dayNode = doc.createTextNode("day");
  1151. docFrag = doc.createDocumentFragment();
  1152. retval = docFrag.appendChild(terNode);
  1153. retval = docFrag.appendChild(dayNode);
  1154. firstChild = titleAttr.firstChild;
  1155. test.notEqual(firstChild, null, 'attrChildNotNull');
  1156. retval = titleAttr.replaceChild(docFrag,firstChild);
  1157. value = titleAttr.value;
  1158. test.equal(value, "terday", 'attrValue');
  1159. value = titleAttr.nodeValue;
  1160. test.equal(value, "terday", 'attrNodeValue');
  1161. value = retval.nodeValue;
  1162. test.equal(value, "Yes", 'retvalValue');
  1163. firstChild = titleAttr.firstChild;
  1164. value = firstChild.nodeValue;
  1165. test.equal(value, "ter", 'firstChildValue');
  1166. test.done();
  1167. },
  1168. /**
  1169. *
  1170. Sets Attr.value on an attribute that only has a simple value.
  1171. * @author Curt Arnold
  1172. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
  1173. */
  1174. hc_attrsetvalue1: function(test) {
  1175. var success;
  1176. var doc;
  1177. var acronymList;
  1178. var testNode;
  1179. var attributes;
  1180. var titleAttr;
  1181. var value;
  1182. var retval;
  1183. var firstChild;
  1184. var otherChild;
  1185. doc = hc_staff.hc_staff();
  1186. acronymList = doc.getElementsByTagName("acronym");
  1187. testNode = acronymList.item(3);
  1188. attributes = testNode.attributes;
  1189. titleAttr = attributes.getNamedItem("title");
  1190. firstChild = titleAttr.firstChild;
  1191. test.notEqual(firstChild, null, 'attrChildNotNull');
  1192. titleAttr.value = "Tomorrow";
  1193. firstChild.nodeValue = "impl reused node";
  1194. value = titleAttr.value;
  1195. test.equal(value, "Tomorrow", 'attrValue');
  1196. value = titleAttr.nodeValue;
  1197. test.equal(value, "Tomorrow", 'attrNodeValue');
  1198. firstChild = titleAttr.lastChild;
  1199. value = firstChild.nodeValue;
  1200. test.equal(value, "Tomorrow", 'firstChildValue');
  1201. otherChild = firstChild.nextSibling;
  1202. test.equal(otherChild, null, 'nextSiblingIsNull');
  1203. test.done();
  1204. },
  1205. /**
  1206. *
  1207. Sets Attr.value on an attribute that should contain multiple child nodes.
  1208. * @author Curt Arnold
  1209. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
  1210. */
  1211. hc_attrsetvalue2: function(test) {
  1212. var success;
  1213. var doc;
  1214. var acronymList;
  1215. var testNode;
  1216. var attributes;
  1217. var titleAttr;
  1218. var value;
  1219. var textNode;
  1220. var retval;
  1221. var firstChild;
  1222. var otherChild;
  1223. doc = hc_staff.hc_staff();
  1224. acronymList = doc.getElementsByTagName("acronym");
  1225. testNode = acronymList.item(3);
  1226. attributes = testNode.attributes;
  1227. titleAttr = attributes.getNamedItem("title");
  1228. textNode = doc.createTextNode("terday");
  1229. retval = titleAttr.appendChild(textNode);
  1230. firstChild = titleAttr.firstChild;
  1231. test.notEqual(firstChild, null, 'attrChildNotNull');
  1232. titleAttr.value = "Tomorrow";
  1233. firstChild.nodeValue = "impl reused node";
  1234. value = titleAttr.value;
  1235. test.equal(value, "Tomorrow", 'attrValue');
  1236. value = titleAttr.nodeValue;
  1237. test.equal(value, "Tomorrow", 'attrNodeValue');
  1238. firstChild = titleAttr.lastChild;
  1239. value = firstChild.nodeValue;
  1240. test.equal(value, "Tomorrow", 'firstChildValue');
  1241. otherChild = firstChild.nextSibling;
  1242. test.equal(otherChild, null, 'nextSiblingIsNull');
  1243. test.done();
  1244. },
  1245. /**
  1246. *
  1247. The "getSpecified()" method for an Attr node should
  1248. be set to true if the attribute was explicitly given
  1249. a value.
  1250. Retrieve the attribute named "domestic" from the last
  1251. child of of the first employee and examine the value
  1252. returned by the "getSpecified()" method. This test uses
  1253. the "getNamedItem(name)" method from the NamedNodeMap
  1254. interface.
  1255. * @author Curt Arnold
  1256. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-862529273
  1257. */
  1258. hc_attrspecifiedvalue: function(test) {
  1259. var success;
  1260. var doc;
  1261. var addressList;
  1262. var testNode;
  1263. var attributes;
  1264. var domesticAttr;
  1265. var state;
  1266. doc = hc_staff.hc_staff();
  1267. addressList = doc.getElementsByTagName("acronym");
  1268. testNode = addressList.item(0);
  1269. attributes = testNode.attributes;
  1270. domesticAttr = attributes.getNamedItem("title");
  1271. state = domesticAttr.specified;
  1272. test.ok(state, 'acronymTitleSpecified');
  1273. test.done();
  1274. },
  1275. /**
  1276. *
  1277. The "getSpecified()" method for an Attr node should return true if the
  1278. value of the attribute is changed.
  1279. Retrieve the attribute named "class" from the last
  1280. child of of the THIRD employee and change its
  1281. value to "Yes"(which is the default DTD value). This
  1282. should cause the "getSpecified()" method to be true.
  1283. This test uses the "setAttribute(name,value)" method
  1284. from the Element interface and the "getNamedItem(name)"
  1285. method from the NamedNodeMap interface.
  1286. * @author Curt Arnold
  1287. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-862529273
  1288. */
  1289. hc_attrspecifiedvaluechanged: function(test) {
  1290. var success;
  1291. var doc;
  1292. var addressList;
  1293. var testNode;
  1294. var attributes;
  1295. var streetAttr;
  1296. var state;
  1297. doc = hc_staff.hc_staff();
  1298. addressList = doc.getElementsByTagName("acronym");
  1299. testNode = addressList.item(2);
  1300. testNode.setAttribute("class","Yα");
  1301. attributes = testNode.attributes;
  1302. streetAttr = attributes.getNamedItem("class");
  1303. state = streetAttr.specified;
  1304. test.ok(state, 'acronymClassSpecified');
  1305. test.done();
  1306. },
  1307. /**
  1308. *
  1309. The "appendData(arg)" method appends a string to the end
  1310. of the character data of the node.
  1311. Retrieve the character data from the second child
  1312. of the first employee. The appendData(arg) method is
  1313. called with arg=", Esquire". The method should append
  1314. the specified data to the already existing character
  1315. data. The new value return by the "getLength()" method
  1316. should be 24.
  1317. * @author Curt Arnold
  1318. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1319. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F
  1320. */
  1321. hc_characterdataappenddata: function(test) {
  1322. var success;
  1323. var doc;
  1324. var elementList;
  1325. var nameNode;
  1326. var child;
  1327. var childValue;
  1328. var childLength;
  1329. doc = hc_staff.hc_staff();
  1330. elementList = doc.getElementsByTagName("strong");
  1331. nameNode = elementList.item(0);
  1332. child = nameNode.firstChild;
  1333. child.appendData(", Esquire");
  1334. childValue = child.data;
  1335. childLength = childValue.length;
  1336. test.equal(childLength, 24, 'characterdataAppendDataAssert');
  1337. test.done();
  1338. },
  1339. /**
  1340. *
  1341. On successful invocation of the "appendData(arg)"
  1342. method the "getData()" method provides access to the
  1343. concatentation of data and the specified string.
  1344. Retrieve the character data from the second child
  1345. of the first employee. The appendData(arg) method is
  1346. called with arg=", Esquire". The method should append
  1347. the specified data to the already existing character
  1348. data. The new value return by the "getData()" method
  1349. should be "Margaret Martin, Esquire".
  1350. * @author Curt Arnold
  1351. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1352. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F
  1353. */
  1354. hc_characterdataappenddatagetdata: function(test) {
  1355. var success;
  1356. var doc;
  1357. var elementList;
  1358. var nameNode;
  1359. var child;
  1360. var childData;
  1361. doc = hc_staff.hc_staff();
  1362. elementList = doc.getElementsByTagName("strong");
  1363. nameNode = elementList.item(0);
  1364. child = nameNode.firstChild;
  1365. child.appendData(", Esquire");
  1366. childData = child.data;
  1367. test.equal(childData, "Margaret Martin, Esquire", 'characterdataAppendDataGetDataAssert');
  1368. test.done();
  1369. },
  1370. /**
  1371. *
  1372. The "deleteData(offset,count)" method removes a range of
  1373. characters from the node. Delete data at the beginning
  1374. of the character data.
  1375. Retrieve the character data from the last child of the
  1376. first employee. The "deleteData(offset,count)"
  1377. method is then called with offset=0 and count=16.
  1378. The method should delete the characters from position
  1379. 0 thru position 16. The new value of the character data
  1380. should be "Dallas, Texas 98551".
  1381. * @author Curt Arnold
  1382. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1383. */
  1384. hc_characterdatadeletedatabegining: function(test) {
  1385. var success;
  1386. var doc;
  1387. var elementList;
  1388. var nameNode;
  1389. var child;
  1390. var childData;
  1391. doc = hc_staff.hc_staff();
  1392. elementList = doc.getElementsByTagName("acronym");
  1393. nameNode = elementList.item(0);
  1394. child = nameNode.firstChild;
  1395. child.deleteData(0,16);
  1396. childData = child.data;
  1397. test.equal(childData, "Dallas, Texas 98551", 'data');
  1398. test.done();
  1399. },
  1400. /**
  1401. *
  1402. The "deleteData(offset,count)" method removes a range of
  1403. characters from the node. Delete data at the end
  1404. of the character data.
  1405. Retrieve the character data from the last child of the
  1406. first employee. The "deleteData(offset,count)"
  1407. method is then called with offset=30 and count=5.
  1408. The method should delete the characters from position
  1409. 30 thru position 35. The new value of the character data
  1410. should be "1230 North Ave. Dallas, Texas".
  1411. * @author Curt Arnold
  1412. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1413. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1414. */
  1415. hc_characterdatadeletedataend: function(test) {
  1416. var success;
  1417. var doc;
  1418. var elementList;
  1419. var nameNode;
  1420. var child;
  1421. var childData;
  1422. doc = hc_staff.hc_staff();
  1423. elementList = doc.getElementsByTagName("acronym");
  1424. nameNode = elementList.item(0);
  1425. child = nameNode.firstChild;
  1426. child.deleteData(30,5);
  1427. childData = child.data;
  1428. test.equal(childData, "1230 North Ave. Dallas, Texas ", 'characterdataDeleteDataEndAssert');
  1429. test.done();
  1430. },
  1431. /**
  1432. *
  1433. If the sum of the offset and count used in the
  1434. "deleteData(offset,count) method is greater than the
  1435. length of the character data then all the characters
  1436. from the offset to the end of the data are deleted.
  1437. Retrieve the character data from the last child of the
  1438. first employee. The "deleteData(offset,count)"
  1439. method is then called with offset=4 and count=50.
  1440. The method should delete the characters from position 4
  1441. to the end of the data since the offset+count(50+4)
  1442. is greater than the length of the character data(35).
  1443. The new value of the character data should be "1230".
  1444. * @author Curt Arnold
  1445. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1446. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1447. */
  1448. hc_characterdatadeletedataexceedslength: function(test) {
  1449. var success;
  1450. var doc;
  1451. var elementList;
  1452. var nameNode;
  1453. var child;
  1454. var childData;
  1455. doc = hc_staff.hc_staff();
  1456. elementList = doc.getElementsByTagName("acronym");
  1457. nameNode = elementList.item(0);
  1458. child = nameNode.firstChild;
  1459. child.deleteData(4,50);
  1460. childData = child.data;
  1461. test.equal(childData, "1230", 'characterdataDeleteDataExceedsLengthAssert');
  1462. test.done();
  1463. },
  1464. /**
  1465. *
  1466. On successful invocation of the "deleteData(offset,count)"
  1467. method, the "getData()" and "getLength()" methods reflect
  1468. the changes.
  1469. Retrieve the character data from the last child of the
  1470. first employee. The "deleteData(offset,count)"
  1471. method is then called with offset=30 and count=5.
  1472. The method should delete the characters from position
  1473. 30 thru position 35. The new value of the character data
  1474. should be "1230 North Ave. Dallas, Texas" which is
  1475. returned by the "getData()" method and "getLength()"
  1476. method should return 30".
  1477. * @author Curt Arnold
  1478. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1479. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7D61178C
  1480. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1481. */
  1482. hc_characterdatadeletedatagetlengthanddata: function(test) {
  1483. var success;
  1484. var doc;
  1485. var elementList;
  1486. var nameNode;
  1487. var child;
  1488. var childData;
  1489. var childLength;
  1490. var result = new Array();
  1491. doc = hc_staff.hc_staff();
  1492. elementList = doc.getElementsByTagName("acronym");
  1493. nameNode = elementList.item(0);
  1494. child = nameNode.firstChild;
  1495. child.deleteData(30,5);
  1496. childData = child.data;
  1497. test.equal(childData, "1230 North Ave. Dallas, Texas ", 'data');
  1498. childLength = child.length;
  1499. test.equal(childLength, 30, 'length');
  1500. test.done();
  1501. },
  1502. /**
  1503. *
  1504. The "deleteData(offset,count)" method removes a range of
  1505. characters from the node. Delete data in the middle
  1506. of the character data.
  1507. Retrieve the character data from the last child of the
  1508. first employee. The "deleteData(offset,count)"
  1509. method is then called with offset=16 and count=8.
  1510. The method should delete the characters from position
  1511. 16 thru position 24. The new value of the character data
  1512. should be "1230 North Ave. Texas 98551".
  1513. * @author Curt Arnold
  1514. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1515. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1516. */
  1517. hc_characterdatadeletedatamiddle: function(test) {
  1518. var success;
  1519. var doc;
  1520. var elementList;
  1521. var nameNode;
  1522. var child;
  1523. var childData;
  1524. doc = hc_staff.hc_staff();
  1525. elementList = doc.getElementsByTagName("acronym");
  1526. nameNode = elementList.item(0);
  1527. child = nameNode.firstChild;
  1528. child.deleteData(16,8);
  1529. childData = child.data;
  1530. test.equal(childData, "1230 North Ave. Texas 98551", 'characterdataDeleteDataMiddleAssert');
  1531. test.done();
  1532. },
  1533. /**
  1534. *
  1535. The "getData()" method retrieves the character data
  1536. currently stored in the node.
  1537. Retrieve the character data from the second child
  1538. of the first employee and invoke the "getData()"
  1539. method. The method returns the character data
  1540. string.
  1541. * @author Curt Arnold
  1542. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1543. */
  1544. hc_characterdatagetdata: function(test) {
  1545. var success;
  1546. var doc;
  1547. var elementList;
  1548. var nameNode;
  1549. var child;
  1550. var childData;
  1551. doc = hc_staff.hc_staff();
  1552. elementList = doc.getElementsByTagName("strong");
  1553. nameNode = elementList.item(0);
  1554. child = nameNode.firstChild;
  1555. childData = child.data;
  1556. test.equal(childData, "Margaret Martin", 'characterdataGetDataAssert');
  1557. test.done();
  1558. },
  1559. /**
  1560. *
  1561. The "getLength()" method returns the number of characters
  1562. stored in this nodes data.
  1563. Retrieve the character data from the second
  1564. child of the first employee and examine the
  1565. value returned by the getLength() method.
  1566. * @author Curt Arnold
  1567. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1568. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7D61178C
  1569. */
  1570. hc_characterdatagetlength: function(test) {
  1571. var success;
  1572. var doc;
  1573. var elementList;
  1574. var nameNode;
  1575. var child;
  1576. var childValue;
  1577. var childLength;
  1578. doc = hc_staff.hc_staff();
  1579. elementList = doc.getElementsByTagName("strong");
  1580. nameNode = elementList.item(0);
  1581. child = nameNode.firstChild;
  1582. childValue = child.data;
  1583. childLength = childValue.length;
  1584. test.equal(childLength, 15, 'characterdataGetLengthAssert');
  1585. test.done();
  1586. },
  1587. /**
  1588. *
  1589. The "deleteData(offset,count)" method raises an
  1590. INDEX_SIZE_ERR DOMException if the specified count
  1591. is negative.
  1592. Retrieve the character data of the last child of the
  1593. first employee and invoke its "deleteData(offset,count)"
  1594. method with offset=10 and count=-3. It should raise the
  1595. desired exception since the count is negative.
  1596. * @author Curt Arnold
  1597. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1598. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  1599. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR'])
  1600. */
  1601. hc_characterdataindexsizeerrdeletedatacountnegative: function(test) {
  1602. var doc = hc_staff.hc_staff();
  1603. var child = doc.getElementsByTagName("acronym").item(0).firstChild;
  1604. var success = false;
  1605. try {
  1606. child.substringData(10,-3);
  1607. } catch(ex) {
  1608. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1609. }
  1610. test.ok(success, 'throws_INDEX_SIZE_ERR');
  1611. test.done();
  1612. },
  1613. /**
  1614. *
  1615. The "deleteData(offset,count)" method raises an
  1616. INDEX_SIZE_ERR DOMException if the specified offset
  1617. is greater that the number of characters in the string.
  1618. Retrieve the character data of the last child of the
  1619. first employee and invoke its "deleteData(offset,count)"
  1620. method with offset=40 and count=3. It should raise the
  1621. desired exception since the offset is greater than the
  1622. number of characters in the string.
  1623. * @author Curt Arnold
  1624. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1625. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1626. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR'])
  1627. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1628. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  1629. */
  1630. hc_characterdataindexsizeerrdeletedataoffsetgreater: function(test) {
  1631. var doc = hc_staff.hc_staff();
  1632. var child = doc.getElementsByTagName("acronym").item(0).firstChild;
  1633. var success = false;
  1634. try {
  1635. child.deleteData(40,3);
  1636. }
  1637. catch(ex) {
  1638. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1639. }
  1640. test.ok(success, 'throw_INDEX_SIZE_ERR');
  1641. test.done();
  1642. },
  1643. /**
  1644. *
  1645. The "deleteData(offset,count)" method raises an
  1646. INDEX_SIZE_ERR DOMException if the specified offset
  1647. is negative.
  1648. Retrieve the character data of the last child of the
  1649. first employee and invoke its "deleteData(offset,count)"
  1650. method with offset=-5 and count=3. It should raise the
  1651. desired exception since the offset is negative.
  1652. * @author Curt Arnold
  1653. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1654. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1655. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR'])
  1656. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1657. */
  1658. hc_characterdataindexsizeerrdeletedataoffsetnegative: function(test) {
  1659. var doc = hc_staff.hc_staff();
  1660. var child = doc.getElementsByTagName("acronym").item(0).firstChild;
  1661. var success = false;
  1662. try {
  1663. child.deleteData(-5,3);
  1664. } catch(ex) {
  1665. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1666. }
  1667. test.ok(success, 'throws_INDEX_SIZE_ERR');
  1668. test.done();
  1669. },
  1670. /**
  1671. *
  1672. The "insertData(offset,arg)" method raises an
  1673. INDEX_SIZE_ERR DOMException if the specified offset
  1674. is greater than the number of characters in the string.
  1675. Retrieve the character data of the last child of the
  1676. first employee and invoke its insertData"(offset,arg)"
  1677. method with offset=40 and arg="ABC". It should raise
  1678. the desired exception since the offset is greater than
  1679. the number of characters in the string.
  1680. * @author Curt Arnold
  1681. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1682. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1683. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR'])
  1684. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  1685. */
  1686. hc_characterdataindexsizeerrinsertdataoffsetgreater: function(test) {
  1687. var doc = hc_staff.hc_staff();
  1688. var child = doc.getElementsByTagName("acronym").item(0).firstChild;
  1689. var success = false;
  1690. try {
  1691. child.deleteData(40,3);
  1692. } catch(ex) {
  1693. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1694. }
  1695. test.ok(success, 'throw_INDEX_SIZE_ERR');
  1696. test.done();
  1697. },
  1698. /**
  1699. *
  1700. The "insertData(offset,arg)" method raises an
  1701. INDEX_SIZE_ERR DOMException if the specified offset
  1702. is negative.
  1703. Retrieve the character data of the last child of the
  1704. first employee and invoke its insertData"(offset,arg)"
  1705. method with offset=-5 and arg="ABC". It should raise
  1706. the desired exception since the offset is negative.
  1707. * @author Curt Arnold
  1708. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1709. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  1710. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-E5CBA7FB')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR'])
  1711. */
  1712. hc_characterdataindexsizeerrinsertdataoffsetnegative: function(test) {
  1713. var doc = hc_staff.hc_staff();
  1714. var child = doc.getElementsByTagName("acronym").item(0).firstChild;
  1715. var success = false;
  1716. try {
  1717. child.replaceData(-5,3,"ABC");
  1718. } catch(ex) {
  1719. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1720. }
  1721. test.ok(success, 'throws_INDEX_SIZE_ERR');
  1722. test.done();
  1723. },
  1724. /**
  1725. *
  1726. The "replaceData(offset,count,arg)" method raises an
  1727. INDEX_SIZE_ERR DOMException if the specified count
  1728. is negative.
  1729. Retrieve the character data of the last child of the
  1730. first employee and invoke its
  1731. "replaceData(offset,count,arg) method with offset=10
  1732. and count=-3 and arg="ABC". It should raise the
  1733. desired exception since the count is negative.
  1734. * @author Curt Arnold
  1735. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1736. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  1737. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR'])
  1738. */
  1739. hc_characterdataindexsizeerrreplacedatacountnegative: function(test) {
  1740. var doc = hc_staff.hc_staff();
  1741. var child = doc.getElementsByTagName("acronym").item(0).firstChild;
  1742. var success = false;
  1743. try {
  1744. child.substringData(10,-3);
  1745. }
  1746. catch(ex) {
  1747. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1748. }
  1749. test.ok(success, 'throws_INDEX_SIZE_ERR');
  1750. test.done();
  1751. },
  1752. /**
  1753. *
  1754. The "replaceData(offset,count,arg)" method raises an
  1755. INDEX_SIZE_ERR DOMException if the specified offset
  1756. is greater than the length of the string.
  1757. Retrieve the character data of the last child of the
  1758. first employee and invoke its
  1759. "replaceData(offset,count,arg) method with offset=40
  1760. and count=3 and arg="ABC". It should raise the
  1761. desired exception since the offset is greater than the
  1762. length of the string.
  1763. * @author Curt Arnold
  1764. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1765. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1766. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-7C603781')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR'])
  1767. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=242
  1768. */
  1769. hc_characterdataindexsizeerrreplacedataoffsetgreater: function(test) {
  1770. var doc = hc_staff.hc_staff();
  1771. var child = doc.getElementsByTagName("acronym").item(0).firstChild;
  1772. success = false;
  1773. try {
  1774. child.deleteData(40,3);
  1775. } catch(ex) {
  1776. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1777. }
  1778. test.ok(success, 'throw_INDEX_SIZE_ERR');
  1779. test.done();
  1780. },
  1781. /**
  1782. *
  1783. The "replaceData(offset,count,arg)" method raises an
  1784. INDEX_SIZE_ERR DOMException if the specified offset
  1785. is negative.
  1786. Retrieve the character data of the last child of the
  1787. first employee and invoke its
  1788. "replaceData(offset,count,arg) method with offset=-5
  1789. and count=3 and arg="ABC". It should raise the
  1790. desired exception since the offset is negative.
  1791. * @author Curt Arnold
  1792. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1793. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  1794. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-E5CBA7FB')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR'])
  1795. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  1796. */
  1797. hc_characterdataindexsizeerrreplacedataoffsetnegative: function(test) {
  1798. var doc = hc_staff.hc_staff();
  1799. var child = doc.getElementsByTagName("acronym").item(0).firstChild;
  1800. success = false;
  1801. try {
  1802. child.replaceData(-5,3,"ABC");
  1803. } catch(ex) {
  1804. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1805. }
  1806. test.ok(success, 'throws_INDEX_SIZE_ERR');
  1807. test.done();
  1808. },
  1809. /**
  1810. *
  1811. The "substringData(offset,count)" method raises an
  1812. INDEX_SIZE_ERR DOMException if the specified count
  1813. is negative.
  1814. Retrieve the character data of the last child of the
  1815. first employee and invoke its "substringData(offset,count)
  1816. method with offset=10 and count=-3. It should raise the
  1817. desired exception since the count is negative.
  1818. * @author Curt Arnold
  1819. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1820. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  1821. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR'])
  1822. */
  1823. hc_characterdataindexsizeerrsubstringcountnegative: function(test) {
  1824. var doc = hc_staff.hc_staff();
  1825. var child = doc.getElementsByTagName("acronym").item(0).firstChild;
  1826. var success = false;
  1827. try {
  1828. child.substringData(10,-3);
  1829. } catch(ex) {
  1830. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1831. }
  1832. test.ok(success, 'throws_INDEX_SIZE_ERR');
  1833. test.done();
  1834. },
  1835. /**
  1836. *
  1837. The "substringData(offset,count)" method raises an
  1838. INDEX_SIZE_ERR DOMException if the specified offset
  1839. is negative.
  1840. Retrieve the character data of the last child of the
  1841. first employee and invoke its "substringData(offset,count)
  1842. method with offset=-5 and count=3. It should raise the
  1843. desired exception since the offset is negative.
  1844. * @author Curt Arnold
  1845. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1846. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  1847. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR'])
  1848. */
  1849. hc_characterdataindexsizeerrsubstringnegativeoffset: function(test) {
  1850. var doc = hc_staff.hc_staff();
  1851. var child = doc.getElementsByTagName("acronym").item(0).firstChild;
  1852. success = false;
  1853. try {
  1854. child.substringData(-5,3);
  1855. } catch(ex) {
  1856. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1857. }
  1858. test.ok(success, 'throws_INDEX_SIZE_ERR');
  1859. test.done();
  1860. },
  1861. /**
  1862. *
  1863. The "substringData(offset,count)" method raises an
  1864. INDEX_SIZE_ERR DOMException if the specified offset
  1865. is greater than the number of characters in the string.
  1866. Retrieve the character data of the last child of the
  1867. first employee and invoke its "substringData(offset,count)
  1868. method with offset=40 and count=3. It should raise the
  1869. desired exception since the offsets value is greater
  1870. than the length.
  1871. * @author Curt Arnold
  1872. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1873. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  1874. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6531BCCF')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR'])
  1875. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  1876. */
  1877. hc_characterdataindexsizeerrsubstringoffsetgreater: function(test) {
  1878. var doc = hc_staff.hc_staff();
  1879. var child = doc.getElementsByTagName("acronym").item(0).firstChild;
  1880. success = false;
  1881. try {
  1882. child.substringData(40,3);
  1883. } catch(ex) {
  1884. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1885. }
  1886. test.ok(success, 'throw_INDEX_SIZE_ERR');
  1887. test.done();
  1888. },
  1889. /**
  1890. *
  1891. The "insertData(offset,arg)" method will insert a string
  1892. at the specified character offset. Insert the data at
  1893. the beginning of the character data.
  1894. Retrieve the character data from the second child of
  1895. the first employee. The "insertData(offset,arg)"
  1896. method is then called with offset=0 and arg="Mss.".
  1897. The method should insert the string "Mss." at position 0.
  1898. The new value of the character data should be
  1899. "Mss. Margaret Martin".
  1900. * @author Curt Arnold
  1901. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F
  1902. */
  1903. hc_characterdatainsertdatabeginning: function(test) {
  1904. var success;
  1905. var doc;
  1906. var elementList;
  1907. var nameNode;
  1908. var child;
  1909. var childData;
  1910. doc = hc_staff.hc_staff();
  1911. elementList = doc.getElementsByTagName("strong");
  1912. nameNode = elementList.item(0);
  1913. child = nameNode.firstChild;
  1914. child.insertData(0,"Mss. ");
  1915. childData = child.data;
  1916. test.equal(childData, "Mss. Margaret Martin", 'characterdataInsertDataBeginningAssert');
  1917. test.done();
  1918. },
  1919. /**
  1920. *
  1921. The "insertData(offset,arg)" method will insert a string
  1922. at the specified character offset. Insert the data at
  1923. the end of the character data.
  1924. Retrieve the character data from the second child of
  1925. the first employee. The "insertData(offset,arg)"
  1926. method is then called with offset=15 and arg=", Esquire".
  1927. The method should insert the string ", Esquire" at
  1928. position 15. The new value of the character data should
  1929. be "Margaret Martin, Esquire".
  1930. * @author Curt Arnold
  1931. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1932. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F
  1933. */
  1934. hc_characterdatainsertdataend: function(test) {
  1935. var success;
  1936. var doc;
  1937. var elementList;
  1938. var nameNode;
  1939. var child;
  1940. var childData;
  1941. doc = hc_staff.hc_staff();
  1942. elementList = doc.getElementsByTagName("strong");
  1943. nameNode = elementList.item(0);
  1944. child = nameNode.firstChild;
  1945. child.insertData(15,", Esquire");
  1946. childData = child.data;
  1947. test.equal(childData, "Margaret Martin, Esquire", 'characterdataInsertDataEndAssert');
  1948. test.done();
  1949. },
  1950. /**
  1951. *
  1952. The "insertData(offset,arg)" method will insert a string
  1953. at the specified character offset. Insert the data in
  1954. the middle of the character data.
  1955. Retrieve the character data from the second child of
  1956. the first employee. The "insertData(offset,arg)"
  1957. method is then called with offset=9 and arg="Ann".
  1958. The method should insert the string "Ann" at position 9.
  1959. The new value of the character data should be
  1960. "Margaret Ann Martin".
  1961. * @author Curt Arnold
  1962. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1963. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F
  1964. */
  1965. hc_characterdatainsertdatamiddle: function(test) {
  1966. var success;
  1967. var doc;
  1968. var elementList;
  1969. var nameNode;
  1970. var child;
  1971. var childData;
  1972. doc = hc_staff.hc_staff();
  1973. elementList = doc.getElementsByTagName("strong");
  1974. nameNode = elementList.item(0);
  1975. child = nameNode.firstChild;
  1976. child.insertData(9,"Ann ");
  1977. childData = child.data;
  1978. test.equal(childData, "Margaret Ann Martin", 'characterdataInsertDataMiddleAssert');
  1979. test.done();
  1980. },
  1981. /**
  1982. *
  1983. The "replaceData(offset,count,arg)" method replaces the
  1984. characters starting at the specified offset with the
  1985. specified string. Test for replacement in the
  1986. middle of the data.
  1987. Retrieve the character data from the last child of the
  1988. first employee. The "replaceData(offset,count,arg)"
  1989. method is then called with offset=5 and count=5 and
  1990. arg="South". The method should replace characters five
  1991. thru 9 of the character data with "South".
  1992. * @author Curt Arnold
  1993. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  1994. */
  1995. hc_characterdatareplacedatabegining: function(test) {
  1996. var success;
  1997. var doc;
  1998. var elementList;
  1999. var nameNode;
  2000. var child;
  2001. var childData;
  2002. doc = hc_staff.hc_staff();
  2003. elementList = doc.getElementsByTagName("acronym");
  2004. nameNode = elementList.item(0);
  2005. child = nameNode.firstChild;
  2006. child.replaceData(0,4,"2500");
  2007. childData = child.data;
  2008. test.equal(childData, "2500 North Ave. Dallas, Texas 98551", 'characterdataReplaceDataBeginingAssert');
  2009. test.done();
  2010. },
  2011. /**
  2012. *
  2013. The "replaceData(offset,count,arg)" method replaces the
  2014. characters starting at the specified offset with the
  2015. specified string. Test for replacement at the
  2016. end of the data.
  2017. Retrieve the character data from the last child of the
  2018. first employee. The "replaceData(offset,count,arg)"
  2019. method is then called with offset=30 and count=5 and
  2020. arg="98665". The method should replace characters 30
  2021. thru 34 of the character data with "98665".
  2022. * @author Curt Arnold
  2023. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  2024. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  2025. */
  2026. hc_characterdatareplacedataend: function(test) {
  2027. var success;
  2028. var doc;
  2029. var elementList;
  2030. var nameNode;
  2031. var child;
  2032. var childData;
  2033. doc = hc_staff.hc_staff();
  2034. elementList = doc.getElementsByTagName("acronym");
  2035. nameNode = elementList.item(0);
  2036. child = nameNode.firstChild;
  2037. child.replaceData(30,5,"98665");
  2038. childData = child.data;
  2039. test.equal(childData, "1230 North Ave. Dallas, Texas 98665", 'characterdataReplaceDataEndAssert');
  2040. test.done();
  2041. },
  2042. /**
  2043. *
  2044. The "replaceData(offset,count,arg)" method replaces the
  2045. characters starting at the specified offset with the
  2046. specified string. Test the situation where the length
  2047. of the arg string is greater than the specified offset.
  2048. Retrieve the character data from the last child of the
  2049. first employee. The "replaceData(offset,count,arg)"
  2050. method is then called with offset=0 and count=4 and
  2051. arg="260030". The method should replace characters one
  2052. thru four with "260030". Note that the length of the
  2053. specified string is greater that the specified offset.
  2054. * @author Curt Arnold
  2055. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  2056. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  2057. */
  2058. hc_characterdatareplacedataexceedslengthofarg: function(test) {
  2059. var success;
  2060. var doc;
  2061. var elementList;
  2062. var nameNode;
  2063. var child;
  2064. var childData;
  2065. doc = hc_staff.hc_staff();
  2066. elementList = doc.getElementsByTagName("acronym");
  2067. nameNode = elementList.item(0);
  2068. child = nameNode.firstChild;
  2069. child.replaceData(0,4,"260030");
  2070. childData = child.data;
  2071. test.equal(childData, "260030 North Ave. Dallas, Texas 98551", 'characterdataReplaceDataExceedsLengthOfArgAssert');
  2072. test.done();
  2073. },
  2074. /**
  2075. *
  2076. If the sum of the offset and count exceeds the length then
  2077. all the characters to the end of the data are replaced.
  2078. Retrieve the character data from the last child of the
  2079. first employee. The "replaceData(offset,count,arg)"
  2080. method is then called with offset=0 and count=50 and
  2081. arg="2600". The method should replace all the characters
  2082. with "2600". This is because the sum of the offset and
  2083. count exceeds the length of the character data.
  2084. * @author Curt Arnold
  2085. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  2086. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  2087. */
  2088. hc_characterdatareplacedataexceedslengthofdata: function(test) {
  2089. var success;
  2090. var doc;
  2091. var elementList;
  2092. var nameNode;
  2093. var child;
  2094. var childData;
  2095. doc = hc_staff.hc_staff();
  2096. elementList = doc.getElementsByTagName("acronym");
  2097. nameNode = elementList.item(0);
  2098. child = nameNode.firstChild;
  2099. child.replaceData(0,50,"2600");
  2100. childData = child.data;
  2101. test.equal(childData, "2600", 'characterdataReplaceDataExceedsLengthOfDataAssert');
  2102. test.done();
  2103. },
  2104. /**
  2105. *
  2106. The "replaceData(offset,count,arg)" method replaces the
  2107. characters starting at the specified offset with the
  2108. specified string. Test for replacement in the
  2109. middle of the data.
  2110. Retrieve the character data from the last child of the
  2111. first employee. The "replaceData(offset,count,arg)"
  2112. method is then called with offset=5 and count=5 and
  2113. arg="South". The method should replace characters five
  2114. thru 9 of the character data with "South".
  2115. * @author Curt Arnold
  2116. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  2117. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  2118. */
  2119. hc_characterdatareplacedatamiddle: function(test) {
  2120. var success;
  2121. var doc;
  2122. var elementList;
  2123. var nameNode;
  2124. var child;
  2125. var childData;
  2126. doc = hc_staff.hc_staff();
  2127. elementList = doc.getElementsByTagName("acronym");
  2128. nameNode = elementList.item(0);
  2129. child = nameNode.firstChild;
  2130. child.replaceData(5,5,"South");
  2131. childData = child.data;
  2132. test.equal(childData, "1230 South Ave. Dallas, Texas 98551", 'characterdataReplaceDataMiddleAssert');
  2133. test.done();
  2134. },
  2135. /**
  2136. *
  2137. The "setNodeValue()" method changes the character data
  2138. currently stored in the node.
  2139. Retrieve the character data from the second child
  2140. of the first employee and invoke the "setNodeValue()"
  2141. method, call "getData()" and compare.
  2142. * @author Curt Arnold
  2143. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  2144. */
  2145. hc_characterdatasetnodevalue: function(test) {
  2146. var success;
  2147. var doc;
  2148. var elementList;
  2149. var nameNode;
  2150. var child;
  2151. var childData;
  2152. var childValue;
  2153. doc = hc_staff.hc_staff();
  2154. elementList = doc.getElementsByTagName("strong");
  2155. nameNode = elementList.item(0);
  2156. child = nameNode.firstChild;
  2157. child.nodeValue = "Marilyn Martin";
  2158. childData = child.data;
  2159. test.equal(childData, "Marilyn Martin", 'data');
  2160. childValue = child.nodeValue;
  2161. test.equal(childValue, "Marilyn Martin", 'value');
  2162. test.done();
  2163. },
  2164. /**
  2165. *
  2166. If the sum of the "offset" and "count" exceeds the
  2167. "length" then the "substringData(offset,count)" method
  2168. returns all the characters to the end of the data.
  2169. Retrieve the character data from the second child
  2170. of the first employee and access part of the data
  2171. by using the substringData(offset,count) method
  2172. with offset=9 and count=10. The method should return
  2173. the substring "Martin" since offset+count > length
  2174. (19 > 15).
  2175. * @author Curt Arnold
  2176. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  2177. */
  2178. hc_characterdatasubstringexceedsvalue: function(test) {
  2179. var success;
  2180. var doc;
  2181. var elementList;
  2182. var nameNode;
  2183. var child;
  2184. var substring;
  2185. doc = hc_staff.hc_staff();
  2186. elementList = doc.getElementsByTagName("strong");
  2187. nameNode = elementList.item(0);
  2188. child = nameNode.firstChild;
  2189. substring = child.substringData(9,10);
  2190. test.equal(substring, "Martin", 'characterdataSubStringExceedsValueAssert');
  2191. test.done();
  2192. },
  2193. /**
  2194. *
  2195. The "substringData(offset,count)" method returns the
  2196. specified string.
  2197. Retrieve the character data from the second child
  2198. of the first employee and access part of the data
  2199. by using the substringData(offset,count) method. The
  2200. method should return the specified substring starting
  2201. at position "offset" and extract "count" characters.
  2202. The method should return the string "Margaret".
  2203. * @author Curt Arnold
  2204. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  2205. */
  2206. hc_characterdatasubstringvalue: function(test) {
  2207. var success;
  2208. var doc;
  2209. var elementList;
  2210. var nameNode;
  2211. var child;
  2212. var substring;
  2213. doc = hc_staff.hc_staff();
  2214. elementList = doc.getElementsByTagName("strong");
  2215. nameNode = elementList.item(0);
  2216. child = nameNode.firstChild;
  2217. substring = child.substringData(0,8);
  2218. test.equal(substring, "Margaret", 'characterdataSubStringValueAssert');
  2219. test.done();
  2220. },
  2221. /**
  2222. *
  2223. A comment is all the characters between the starting
  2224. '<!--' and ending '-->'
  2225. Retrieve the nodes of the DOM document. Search for a
  2226. comment node and the content is its value.
  2227. * @author Curt Arnold
  2228. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1334481328
  2229. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  2230. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  2231. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  2232. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  2233. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=509
  2234. */
  2235. hc_commentgetcomment: function(test) {
  2236. var success;
  2237. var doc;
  2238. var elementList;
  2239. var child;
  2240. var childName;
  2241. var childValue;
  2242. var commentCount = 0;
  2243. var childType;
  2244. var attributes;
  2245. doc = hc_staff.hc_staff();
  2246. elementList = doc.childNodes;
  2247. for(var indexN1005E = 0;indexN1005E < elementList.length; indexN1005E++) {
  2248. child = elementList.item(indexN1005E);
  2249. childType = child.nodeType;
  2250. if(
  2251. (8 == childType)
  2252. ) {
  2253. childName = child.nodeName;
  2254. test.equal(childName, "#comment", 'nodeName');
  2255. childValue = child.nodeValue;
  2256. test.equal(childValue, " This is comment number 1.", 'nodeValue');
  2257. attributes = child.attributes;
  2258. test.equal(attributes, null, 'attributes');
  2259. commentCount += 1;
  2260. }
  2261. }
  2262. test.ok(commentCount < 2, 'atMostOneComment');
  2263. test.done();
  2264. },
  2265. /**
  2266. *
  2267. Retrieve the entire DOM document and invoke its
  2268. "createAttribute(name)" method. It should create a
  2269. new Attribute node with the given name. The name, value
  2270. and type of the newly created object are retrieved and
  2271. output.
  2272. * @author Curt Arnold
  2273. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198
  2274. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  2275. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
  2276. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  2277. */
  2278. hc_documentcreateattribute: function(test) {
  2279. var doc = hc_staff.hc_staff();
  2280. var newAttrNode = doc.createAttribute("title");
  2281. test.equal(newAttrNode.nodeValue, "", 'value');
  2282. test.equal(newAttrNode.nodeName, 'title', 'attribute name');
  2283. test.equal(newAttrNode.nodeType, 2, 'type');
  2284. test.done();
  2285. },
  2286. /**
  2287. *
  2288. The "createComment(data)" method creates a new Comment
  2289. node given the specified string.
  2290. Retrieve the entire DOM document and invoke its
  2291. "createComment(data)" method. It should create a new
  2292. Comment node whose "data" is the specified string.
  2293. The content, name and type are retrieved and output.
  2294. * @author Curt Arnold
  2295. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1334481328
  2296. */
  2297. hc_documentcreatecomment: function(test) {
  2298. var success;
  2299. var doc;
  2300. var newCommentNode;
  2301. var newCommentValue;
  2302. var newCommentName;
  2303. var newCommentType;
  2304. doc = hc_staff.hc_staff();
  2305. newCommentNode = doc.createComment("This is a new Comment node");
  2306. newCommentValue = newCommentNode.nodeValue;
  2307. test.equal(newCommentValue, "This is a new Comment node", 'value');
  2308. newCommentName = newCommentNode.nodeName;
  2309. test.equal(newCommentName, "#comment", 'strong');
  2310. newCommentType = newCommentNode.nodeType;
  2311. test.equal(newCommentType, 8, 'type');
  2312. test.done();
  2313. },
  2314. /**
  2315. *
  2316. The "createDocumentFragment()" method creates an empty
  2317. DocumentFragment object.
  2318. Retrieve the entire DOM document and invoke its
  2319. "createDocumentFragment()" method. The content, name,
  2320. type and value of the newly created object are output.
  2321. * @author Curt Arnold
  2322. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-35CB04B5
  2323. */
  2324. hc_documentcreatedocumentfragment: function(test) {
  2325. var doc = hc_staff.hc_staff();
  2326. var newDocFragment = doc.createDocumentFragment();
  2327. test.equal(newDocFragment.childNodes.length, 0, 'length');
  2328. test.equal(newDocFragment.nodeName, "#document-fragment", 'strong');
  2329. test.equal(newDocFragment.nodeType, 11, 'type');
  2330. test.equal(newDocFragment.nodeValue, null, 'value');
  2331. test.done();
  2332. },
  2333. /**
  2334. *
  2335. The "createElement(tagName)" method creates an Element
  2336. of the type specified.
  2337. Retrieve the entire DOM document and invoke its
  2338. "createElement(tagName)" method with tagName="acronym".
  2339. The method should create an instance of an Element node
  2340. whose tagName is "acronym". The NodeName, NodeType
  2341. and NodeValue are returned.
  2342. * @author Curt Arnold
  2343. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
  2344. */
  2345. hc_documentcreateelement: function(test) {
  2346. var doc = hc_staff.hc_staff();
  2347. var newElement = doc.createElement("acronym");
  2348. test.equal(newElement.nodeName, 'ACRONYM', 'element strong');
  2349. test.equal(newElement.nodeType, 1, 'type');
  2350. test.equal(newElement.nodeValue, null, 'valueInitiallyNull');
  2351. test.done();
  2352. },
  2353. /**
  2354. *
  2355. The tagName parameter in the "createElement(tagName)"
  2356. method is case-sensitive for XML documents.
  2357. Retrieve the entire DOM document and invoke its
  2358. "createElement(tagName)" method twice. Once for tagName
  2359. equal to "acronym" and once for tagName equal to "ACRONYM"
  2360. Each call should create a distinct Element node. The
  2361. newly created Elements are then assigned attributes
  2362. that are retrieved.
  2363. Modified on 27 June 2003 to avoid setting an invalid style
  2364. values and checked the node names to see if they matched expectations.
  2365. * @author Curt Arnold
  2366. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
  2367. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  2368. */
  2369. hc_documentcreateelementcasesensitive: function(test) {
  2370. var doc = hc_staff.hc_staff();
  2371. var newElement1 = doc.createElement("ACRONYM");
  2372. var newElement2 = doc.createElement("acronym");
  2373. newElement1.setAttribute("lang","EN");
  2374. newElement2.setAttribute("title","Dallas");
  2375. test.equal(newElement1.getAttribute("lang"), "EN", 'attrib1');
  2376. test.equal(newElement2.getAttribute("title"), "Dallas", 'attrib2');
  2377. test.equal(newElement1.nodeName, 'ACRONYM', 'element nodeName1');
  2378. test.equal(newElement2.nodeName, 'ACRONYM', 'element nodeName2');
  2379. test.done();
  2380. },
  2381. /**
  2382. *
  2383. The "createTextNode(data)" method creates a Text node
  2384. given the specfied string.
  2385. Retrieve the entire DOM document and invoke its
  2386. "createTextNode(data)" method. It should create a
  2387. new Text node whose "data" is the specified string.
  2388. The NodeName and NodeType are also checked.
  2389. * @author Curt Arnold
  2390. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1975348127
  2391. */
  2392. hc_documentcreatetextnode: function(test) {
  2393. var success;
  2394. var doc;
  2395. var newTextNode;
  2396. var newTextName;
  2397. var newTextValue;
  2398. var newTextType;
  2399. doc = hc_staff.hc_staff();
  2400. newTextNode = doc.createTextNode("This is a new Text node");
  2401. newTextValue = newTextNode.nodeValue;
  2402. test.equal(newTextValue, "This is a new Text node", 'value');
  2403. newTextName = newTextNode.nodeName;
  2404. test.equal(newTextName, "#text", 'strong');
  2405. newTextType = newTextNode.nodeType;
  2406. test.equal(newTextType, 3, 'type');
  2407. test.done();
  2408. },
  2409. /**
  2410. *
  2411. Access Document.doctype for hc_staff, if not text/html should return DocumentType node.
  2412. HTML implementations may return null.
  2413. * @author Curt Arnold
  2414. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31
  2415. */
  2416. hc_documentgetdoctype: function(test) {
  2417. var doc = hc_staff.hc_staff();
  2418. var docType = doc.doctype;
  2419. test.equal(docType.name, "html", 'nodeName');
  2420. test.equal(docType.nodeValue, null, 'nodeValue');
  2421. test.equal(docType.attributes, null, 'attributes');
  2422. test.done();
  2423. },
  2424. /**
  2425. *
  2426. The "getElementsByTagName(tagName)" method returns a
  2427. NodeList of all the Elements with a given tagName.
  2428. Retrieve the entire DOM document and invoke its
  2429. "getElementsByTagName(tagName)" method with tagName
  2430. equal to "strong". The method should return a NodeList
  2431. that contains 5 elements.
  2432. * @author Curt Arnold
  2433. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094
  2434. */
  2435. hc_documentgetelementsbytagnamelength: function(test) {
  2436. var success;
  2437. var doc;
  2438. var nameList;
  2439. doc = hc_staff.hc_staff();
  2440. nameList = doc.getElementsByTagName("strong");
  2441. test.equal(nameList.length, 5, 'documentGetElementsByTagNameLengthAssert');
  2442. test.done();
  2443. },
  2444. /**
  2445. *
  2446. Retrieve the entire DOM document and invoke its
  2447. "getElementsByTagName(tagName)" method with tagName
  2448. equal to "*". The method should return a NodeList
  2449. that contains all the elements of the document.
  2450. * @author Curt Arnold
  2451. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094
  2452. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
  2453. */
  2454. hc_documentgetelementsbytagnametotallength: function(test) {
  2455. var expectedNames = ["HTML", "HEAD", "META", "TITLE", "SCRIPT", "SCRIPT", "SCRIPT", "BODY",
  2456. "P", "EM", "STRONG", "CODE", "SUP", "VAR", "ACRONYM", "P", "EM", "STRONG",
  2457. "CODE", "SUP", "VAR", "ACRONYM", "P", "EM", "STRONG", "CODE", "SUP", "VAR",
  2458. "ACRONYM", "P", "EM", "STRONG", "CODE", "SUP", "VAR", "ACRONYM", "P", "EM",
  2459. "STRONG", "CODE", "SUP", "VAR", "ACRONYM"];
  2460. var actualNames = [];
  2461. var doc = hc_staff.hc_staff();
  2462. var nameList = doc.getElementsByTagName("*");
  2463. for(var i=0;i<nameList.length;i++) {
  2464. actualNames.push(nameList.item(i).tagName);
  2465. }
  2466. test.deepEqual(actualNames, expectedNames)
  2467. test.done();
  2468. },
  2469. /**
  2470. *
  2471. The "getElementsByTagName(tagName)" method returns a
  2472. NodeList of all the Elements with a given tagName
  2473. in a pre-order traversal of the tree.
  2474. Retrieve the entire DOM document and invoke its
  2475. "getElementsByTagName(tagName)" method with tagName
  2476. equal to "strong". The method should return a NodeList
  2477. that contains 5 elements. The FOURTH item in the
  2478. list is retrieved and output.
  2479. * @author Curt Arnold
  2480. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094
  2481. */
  2482. hc_documentgetelementsbytagnamevalue: function(test) {
  2483. var success;
  2484. var doc;
  2485. var nameList;
  2486. var nameNode;
  2487. var firstChild;
  2488. var childValue;
  2489. doc = hc_staff.hc_staff();
  2490. nameList = doc.getElementsByTagName("strong");
  2491. nameNode = nameList.item(3);
  2492. firstChild = nameNode.firstChild;
  2493. childValue = firstChild.nodeValue;
  2494. test.equal(childValue, "Jeny Oconnor", 'documentGetElementsByTagNameValueAssert');
  2495. test.done();
  2496. },
  2497. /**
  2498. *
  2499. Retrieve the entire DOM document and invoke its
  2500. "getImplementation()" method. If contentType="text/html",
  2501. DOMImplementation.hasFeature("HTML","1.0") should be true.
  2502. Otherwise, DOMImplementation.hasFeature("XML", "1.0")
  2503. should be true.
  2504. * @author Curt Arnold
  2505. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1B793EBA
  2506. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=245
  2507. */
  2508. hc_documentgetimplementation: function(test) {
  2509. var doc = hc_staff.hc_staff();
  2510. test.ok(doc.implementation.hasFeature("HTML","1.0"), 'supports_HTML_1.0');
  2511. test.done();
  2512. },
  2513. /**
  2514. *
  2515. Load a document and invoke its
  2516. "getDocumentElement()" method.
  2517. * @author Curt Arnold
  2518. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-87CD092
  2519. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
  2520. */
  2521. hc_documentgetrootnode: function(test) {
  2522. var doc = hc_staff.hc_staff();
  2523. test.equal(doc.documentElement.nodeName, 'HTML')
  2524. test.done();
  2525. },
  2526. /**
  2527. *
  2528. The "createAttribute(tagName)" method raises an
  2529. INVALID_CHARACTER_ERR DOMException if the specified
  2530. tagName contains an invalid character.
  2531. Retrieve the entire DOM document and invoke its
  2532. "createAttribute(tagName)" method with the tagName equal
  2533. to the string "invalid^Name". Due to the invalid
  2534. character the desired EXCEPTION should be raised.
  2535. * @author Curt Arnold
  2536. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  2537. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198
  2538. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1084891198')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR'])
  2539. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198
  2540. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  2541. */
  2542. hc_documentinvalidcharacterexceptioncreateattribute: function(test) {
  2543. var doc = hc_staff.hc_staff();
  2544. var success = false;
  2545. try {
  2546. doc.createAttribute("invalid^Name");
  2547. }
  2548. catch(ex) {
  2549. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  2550. }
  2551. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  2552. test.done();
  2553. },
  2554. /**
  2555. *
  2556. Creating an attribute with an empty name should cause an INVALID_CHARACTER_ERR.
  2557. * @author Curt Arnold
  2558. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  2559. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198
  2560. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1084891198')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR'])
  2561. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198
  2562. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525
  2563. */
  2564. hc_documentinvalidcharacterexceptioncreateattribute1: function(test) {
  2565. var doc = hc_staff.hc_staff();
  2566. var success = false;
  2567. try {
  2568. doc.createAttribute("");
  2569. } catch(ex) {
  2570. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  2571. }
  2572. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  2573. test.done();
  2574. },
  2575. /**
  2576. *
  2577. The "createElement(tagName)" method raises an
  2578. INVALID_CHARACTER_ERR DOMException if the specified
  2579. tagName contains an invalid character.
  2580. Retrieve the entire DOM document and invoke its
  2581. "createElement(tagName)" method with the tagName equal
  2582. to the string "invalid^Name". Due to the invalid
  2583. character the desired EXCEPTION should be raised.
  2584. * @author Curt Arnold
  2585. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  2586. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
  2587. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-2141741547')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR'])
  2588. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
  2589. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  2590. */
  2591. hc_documentinvalidcharacterexceptioncreateelement: function(test) {
  2592. var doc = hc_staff.hc_staff();
  2593. var success = false;
  2594. try {
  2595. doc.createElement("invalid^Name");
  2596. } catch(ex) {
  2597. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  2598. }
  2599. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  2600. test.done();
  2601. },
  2602. /**
  2603. *
  2604. Creating an element with an empty name should cause an INVALID_CHARACTER_ERR.
  2605. * @author Curt Arnold
  2606. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  2607. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
  2608. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-2141741547')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR'])
  2609. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
  2610. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525
  2611. */
  2612. hc_documentinvalidcharacterexceptioncreateelement1: function(test) {
  2613. var doc = hc_staff.hc_staff();
  2614. var success = false;
  2615. try {
  2616. doc.createElement("");
  2617. } catch(ex) {
  2618. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  2619. }
  2620. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  2621. test.done();
  2622. },
  2623. /**
  2624. *
  2625. Load a document and invoke its
  2626. "getImplementation()" method. This should create a
  2627. DOMImplementation object whose "hasFeature(feature,
  2628. version)" method is invoked with version equal to "".
  2629. If the version is not specified, supporting any version
  2630. feature will cause the method to return "true".
  2631. * @author Curt Arnold
  2632. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7
  2633. * @see http://www.w3.org/2000/11/DOM-Level-2-errata#core-14
  2634. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=245
  2635. */
  2636. hc_domimplementationfeaturenoversion: function(test) {
  2637. var doc = hc_staff.hc_staff();
  2638. test.ok(doc.implementation.hasFeature("HTML",""), 'hasFeatureBlank');
  2639. test.done();
  2640. },
  2641. /**
  2642. *
  2643. Load a document and invoke its
  2644. "getImplementation()" method. This should create a
  2645. DOMImplementation object whose "hasFeature(feature,
  2646. version)" method is invoked with version equal to null.
  2647. If the version is not specified, supporting any version
  2648. feature will cause the method to return "true".
  2649. * @author Curt Arnold
  2650. * @author Curt Arnold
  2651. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7
  2652. * @see http://www.w3.org/2000/11/DOM-Level-2-errata#core-14
  2653. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=245
  2654. */
  2655. hc_domimplementationfeaturenull: function(test) {
  2656. var doc = hc_staff.hc_staff();
  2657. test.ok(doc.implementation.hasFeature("HTML",null), 'supports_HTML_null');
  2658. test.done();
  2659. },
  2660. /**
  2661. *
  2662. Retrieve the entire DOM document and invoke its
  2663. "getImplementation()" method. This should create a
  2664. DOMImplementation object whose "hasFeature(feature,
  2665. version)" method is invoked with "feature" equal to "html" or "xml".
  2666. The method should return a boolean "true".
  2667. * @author Curt Arnold
  2668. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7
  2669. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=245
  2670. */
  2671. hc_domimplementationfeaturexml: function(test) {
  2672. var doc = hc_staff.hc_staff();
  2673. test.ok(doc.implementation.hasFeature("html","1.0"), 'supports_html_1.0');
  2674. test.done();
  2675. },
  2676. /**
  2677. *
  2678. The "setAttribute(name,value)" method adds a new attribute
  2679. to the Element
  2680. Retrieve the last child of the last employee, then
  2681. add an attribute to it by invoking the
  2682. "setAttribute(name,value)" method. It should create
  2683. a "strong" attribute with an assigned value equal to
  2684. "value".
  2685. * @author Curt Arnold
  2686. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
  2687. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  2688. */
  2689. hc_elementaddnewattribute: function(test) {
  2690. var success;
  2691. var doc;
  2692. var elementList;
  2693. var testEmployee;
  2694. var attrValue;
  2695. doc = hc_staff.hc_staff();
  2696. elementList = doc.getElementsByTagName("acronym");
  2697. testEmployee = elementList.item(4);
  2698. testEmployee.setAttribute("lang","EN-us");
  2699. attrValue = testEmployee.getAttribute("lang");
  2700. test.equal(attrValue, "EN-us", 'attrValue');
  2701. test.done();
  2702. },
  2703. /**
  2704. *
  2705. Retrieve the first attribute from the last child of
  2706. the first employee and invoke the "getSpecified()"
  2707. method. This test is only intended to show that
  2708. Elements can actually have attributes. This test uses
  2709. the "getNamedItem(name)" method from the NamedNodeMap
  2710. interface.
  2711. * @author Curt Arnold
  2712. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  2713. */
  2714. hc_elementassociatedattribute: function(test) {
  2715. var success;
  2716. var doc;
  2717. var elementList;
  2718. var testEmployee;
  2719. var attributes;
  2720. var domesticAttr;
  2721. var specified;
  2722. doc = hc_staff.hc_staff();
  2723. elementList = doc.getElementsByTagName("acronym");
  2724. testEmployee = elementList.item(0);
  2725. attributes = testEmployee.attributes;
  2726. domesticAttr = attributes.getNamedItem("title");
  2727. specified = domesticAttr.specified;
  2728. test.ok(specified, 'acronymTitleSpecified');
  2729. test.done();
  2730. },
  2731. /**
  2732. *
  2733. The "setAttribute(name,value)" method adds a new attribute
  2734. to the Element. If the "strong" is already present, then
  2735. its value should be changed to the new one that is in
  2736. the "value" parameter.
  2737. Retrieve the last child of the fourth employee, then add
  2738. an attribute to it by invoking the
  2739. "setAttribute(name,value)" method. Since the name of the
  2740. used attribute("class") is already present in this
  2741. element, then its value should be changed to the new one
  2742. of the "value" parameter.
  2743. * @author Curt Arnold
  2744. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
  2745. */
  2746. hc_elementchangeattributevalue: function(test) {
  2747. var success;
  2748. var doc;
  2749. var elementList;
  2750. var testEmployee;
  2751. var attrValue;
  2752. doc = hc_staff.hc_staff();
  2753. elementList = doc.getElementsByTagName("acronym");
  2754. testEmployee = elementList.item(3);
  2755. testEmployee.setAttribute("class","Neither");
  2756. attrValue = testEmployee.getAttribute("class");
  2757. test.equal(attrValue, "Neither", 'elementChangeAttributeValueAssert');
  2758. test.done();
  2759. },
  2760. /**
  2761. *
  2762. The "setAttributeNode(newAttr)" method adds a new
  2763. attribute to the Element.
  2764. Retrieve first address element and add
  2765. a new attribute node to it by invoking its
  2766. "setAttributeNode(newAttr)" method. This test makes use
  2767. of the "createAttribute(name)" method from the Document
  2768. interface.
  2769. * @author Curt Arnold
  2770. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  2771. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  2772. */
  2773. hc_elementcreatenewattribute: function(test) {
  2774. var success;
  2775. var doc;
  2776. var elementList;
  2777. var testAddress;
  2778. var newAttribute;
  2779. var oldAttr;
  2780. var districtAttr;
  2781. var attrVal;
  2782. doc = hc_staff.hc_staff();
  2783. elementList = doc.getElementsByTagName("acronym");
  2784. testAddress = elementList.item(0);
  2785. newAttribute = doc.createAttribute("lang");
  2786. oldAttr = testAddress.setAttributeNode(newAttribute);
  2787. test.equal(oldAttr, null, 'old_attr_doesnt_exist');
  2788. districtAttr = testAddress.getAttributeNode("lang");
  2789. test.notEqual(districtAttr, null, 'new_district_accessible');
  2790. attrVal = testAddress.getAttribute("lang");
  2791. test.equal(attrVal, "", 'attr_value');
  2792. test.done();
  2793. },
  2794. /**
  2795. *
  2796. Retrieve the attribute "title" from the last child
  2797. of the first "p" element and check its node name.
  2798. * @author Curt Arnold
  2799. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-217A91B8
  2800. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  2801. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
  2802. */
  2803. hc_elementgetattributenode: function(test) {
  2804. var doc = hc_staff.hc_staff();
  2805. var nodeName = doc.getElementsByTagName("acronym").item(0).getAttributeNode("title").nodeName;
  2806. test.equal(nodeName, 'title', 'attribute nodeName');
  2807. test.done();
  2808. },
  2809. /**
  2810. *
  2811. The "getAttributeNode(name)" method retrieves an
  2812. attribute node by name. It should return null if the
  2813. "strong" attribute does not exist.
  2814. Retrieve the last child of the first employee and attempt
  2815. to retrieve a non-existing attribute. The method should
  2816. return "null". The non-existing attribute to be used
  2817. is "invalidAttribute".
  2818. * @author Curt Arnold
  2819. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-217A91B8
  2820. */
  2821. hc_elementgetattributenodenull: function(test) {
  2822. var success;
  2823. var doc;
  2824. var elementList;
  2825. var testEmployee;
  2826. var domesticAttr;
  2827. doc = hc_staff.hc_staff();
  2828. elementList = doc.getElementsByTagName("acronym");
  2829. testEmployee = elementList.item(0);
  2830. domesticAttr = testEmployee.getAttributeNode("invalidAttribute");
  2831. test.equal(domesticAttr, null, 'elementGetAttributeNodeNullAssert');
  2832. test.done();
  2833. },
  2834. /**
  2835. *
  2836. The "getAttribute(name)" method returns an empty
  2837. string if no value was assigned to an attribute and
  2838. no default value was given in the DTD file.
  2839. Retrieve the last child of the last employee, then
  2840. invoke "getAttribute(name)" method, where "strong" is an
  2841. attribute without a specified or DTD default value.
  2842. The "getAttribute(name)" method should return the empty
  2843. string. This method makes use of the
  2844. "createAttribute(newAttr)" method from the Document
  2845. interface.
  2846. * @author Curt Arnold
  2847. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-666EE0F9
  2848. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  2849. */
  2850. hc_elementgetelementempty: function(test) {
  2851. var success;
  2852. var doc;
  2853. var newAttribute;
  2854. var elementList;
  2855. var testEmployee;
  2856. var domesticAttr;
  2857. var attrValue;
  2858. doc = hc_staff.hc_staff();
  2859. newAttribute = doc.createAttribute("lang");
  2860. elementList = doc.getElementsByTagName("acronym");
  2861. testEmployee = elementList.item(3);
  2862. domesticAttr = testEmployee.setAttributeNode(newAttribute);
  2863. attrValue = testEmployee.getAttribute("lang");
  2864. test.equal(attrValue, "", 'elementGetElementEmptyAssert');
  2865. test.done();
  2866. },
  2867. /**
  2868. *
  2869. The "getElementsByTagName(name)" method returns a list
  2870. of all descendant Elements with the given tag name.
  2871. Test for an empty list.
  2872. Create a NodeList of all the descendant elements
  2873. using the string "noMatch" as the tagName.
  2874. The method should return a NodeList whose length is
  2875. "0" since there are not any descendant elements
  2876. that match the given tag name.
  2877. * @author Curt Arnold
  2878. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D
  2879. */
  2880. hc_elementgetelementsbytagname: function(test) {
  2881. var success;
  2882. var doc;
  2883. var elementList;
  2884. doc = hc_staff.hc_staff();
  2885. elementList = doc.getElementsByTagName("p");
  2886. test.equal(elementList.length, 5, 'elementGetElementsByTagNameAssert');
  2887. test.done();
  2888. },
  2889. /**
  2890. *
  2891. The "getElementsByTagName(name)" method returns a list
  2892. of all descendant Elements in the order the children
  2893. were encountered in a pre order traversal of the element
  2894. tree.
  2895. Create a NodeList of all the descendant elements
  2896. using the string "p" as the tagName.
  2897. The method should return a NodeList whose length is
  2898. "5" in the order the children were encountered.
  2899. Access the FOURTH element in the NodeList. The FOURTH
  2900. element, the first or second should be an "em" node with
  2901. the content "EMP0004".
  2902. * @author Curt Arnold
  2903. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D
  2904. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  2905. */
  2906. hc_elementgetelementsbytagnameaccessnodelist: function(test) {
  2907. var doc = hc_staff.hc_staff();
  2908. var firstC = doc.getElementsByTagName("p").item(3).firstChild;
  2909. var nodeType = firstC.nodeType;
  2910. while (3 == nodeType) {
  2911. firstC = firstC.nextSibling;
  2912. nodeType = firstC.nodeType;
  2913. }
  2914. test.equal(firstC.nodeName, 'EM', 'element childName');
  2915. test.equal(firstC.firstChild.nodeValue, "EMP0004", 'employeeID');
  2916. test.done();
  2917. },
  2918. /**
  2919. *
  2920. The "getElementsByTagName(name)" method returns a list
  2921. of all descendant Elements with the given tag name.
  2922. Create a NodeList of all the descendant elements
  2923. using the string "employee" as the tagName.
  2924. The method should return a NodeList whose length is
  2925. "5".
  2926. * @author Curt Arnold
  2927. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D
  2928. */
  2929. hc_elementgetelementsbytagnamenomatch: function(test) {
  2930. var success;
  2931. var doc;
  2932. var elementList;
  2933. doc = hc_staff.hc_staff();
  2934. elementList = doc.getElementsByTagName("noMatch");
  2935. test.equal(elementList.length, 0, 'elementGetElementsByTagNameNoMatchNoMatchAssert');
  2936. test.done();
  2937. },
  2938. /**
  2939. *
  2940. The "getElementsByTagName(name)" method may use the
  2941. special value "*" to match all tags in the element
  2942. tree.
  2943. Create a NodeList of all the descendant elements
  2944. of the last employee by using the special value "*".
  2945. The method should return all the descendant children(6)
  2946. in the order the children were encountered.
  2947. * @author Curt Arnold
  2948. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D
  2949. */
  2950. hc_elementgetelementsbytagnamespecialvalue: function(test) {
  2951. var doc = hc_staff.hc_staff();
  2952. var lastempList = doc.getElementsByTagName("p").item(4).getElementsByTagName("*");
  2953. var actual = [];
  2954. for(var i=0;i<lastempList.length;i++) {
  2955. actual.push(lastempList.item(i).nodeName);
  2956. }
  2957. test.deepEqual(actual, ["EM", "STRONG", "CODE", "SUP", "VAR", "ACRONYM"], 'element tagNames');
  2958. test.done();
  2959. },
  2960. /**
  2961. *
  2962. Invoke the "getTagName()" method one the
  2963. root node. The value returned should be "html" or "svg".
  2964. * @author Curt Arnold
  2965. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-104682815
  2966. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
  2967. */
  2968. hc_elementgettagname: function(test) {
  2969. var doc = hc_staff.hc_staff();
  2970. test.equal(doc.documentElement.tagName, 'HTML')
  2971. test.done();
  2972. },
  2973. /**
  2974. *
  2975. The "setAttributeNode(newAttr)" method raises an
  2976. "INUSE_ATTRIBUTE_ERR DOMException if the "newAttr"
  2977. is already an attribute of another element.
  2978. * @author Curt Arnold
  2979. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])
  2980. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  2981. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-887236154')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR'])
  2982. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=244
  2983. */
  2984. hc_elementinuseattributeerr: function(test) {
  2985. var doc = hc_staff.hc_staff();
  2986. var testAddress = doc.getElementsByTagName("body").item(0);
  2987. var newElement = doc.createElement("p");
  2988. testAddress.appendChild(newElement);
  2989. var newAttribute = doc.createAttribute("title");
  2990. newElement.setAttributeNode(newAttribute);
  2991. var success = false;
  2992. try {
  2993. testAddress.setAttributeNode(newAttribute);
  2994. } catch(ex) {
  2995. success = (typeof(ex.code) != 'undefined' && ex.code == 10);
  2996. }
  2997. test.ok(success, 'throw_INUSE_ATTRIBUTE_ERR');
  2998. test.done();
  2999. },
  3000. /**
  3001. *
  3002. The "setAttribute(name,value)" method raises an
  3003. "INVALID_CHARACTER_ERR DOMException if the specified
  3004. name contains an invalid character.
  3005. Retrieve the last child of the first employee and
  3006. call its "setAttribute(name,value)" method with
  3007. "strong" containing an invalid character.
  3008. * @author Curt Arnold
  3009. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  3010. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
  3011. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-F68F082')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR'])
  3012. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  3013. */
  3014. hc_elementinvalidcharacterexception: function(test) {
  3015. var doc = hc_staff.hc_staff();
  3016. var testAddress = doc.getElementsByTagName("acronym").item(0);
  3017. var success = false;
  3018. try {
  3019. testAddress.setAttribute("invalid^Name","value");
  3020. } catch(ex) {
  3021. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  3022. }
  3023. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  3024. test.done();
  3025. },
  3026. /**
  3027. *
  3028. Calling Element.setAttribute with an empty name will cause an INVALID_CHARACTER_ERR.
  3029. * @author Curt Arnold
  3030. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  3031. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
  3032. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-F68F082')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INVALID_CHARACTER_ERR'])
  3033. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525
  3034. */
  3035. hc_elementinvalidcharacterexception1: function(test) {
  3036. var doc = hc_staff.hc_staff();
  3037. var testAddress = doc.getElementsByTagName("acronym").item(0);
  3038. var success = false;
  3039. try {
  3040. testAddress.setAttribute("","value");
  3041. } catch(ex) {
  3042. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  3043. }
  3044. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  3045. test.done();
  3046. },
  3047. /**
  3048. *
  3049. Append a couple of text nodes to the first sup element, normalize the
  3050. document element and check that the element has been normalized.
  3051. * @author Curt Arnold
  3052. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083
  3053. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=546
  3054. */
  3055. hc_elementnormalize: function(test) {
  3056. var success;
  3057. var doc;
  3058. var root;
  3059. var elementList;
  3060. var testName;
  3061. var firstChild;
  3062. var childValue;
  3063. var textNode;
  3064. var retNode;
  3065. doc = hc_staff.hc_staff();
  3066. elementList = doc.getElementsByTagName("sup");
  3067. testName = elementList.item(0);
  3068. textNode = doc.createTextNode("");
  3069. retNode = testName.appendChild(textNode);
  3070. textNode = doc.createTextNode(",000");
  3071. retNode = testName.appendChild(textNode);
  3072. root = doc.documentElement;
  3073. root.normalize();
  3074. elementList = doc.getElementsByTagName("sup");
  3075. testName = elementList.item(0);
  3076. firstChild = testName.firstChild;
  3077. childValue = firstChild.nodeValue;
  3078. test.equal(childValue, "56,000,000", 'elementNormalizeAssert');
  3079. test.done();
  3080. },
  3081. /**
  3082. *
  3083. Add an empty text node to an existing attribute node, normalize the containing element
  3084. and check that the attribute node has eliminated the empty text.
  3085. * @author Curt Arnold
  3086. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083
  3087. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=482
  3088. */
  3089. hc_elementnormalize2: function(test) {
  3090. var success;
  3091. var doc;
  3092. var root;
  3093. var elementList;
  3094. var element;
  3095. var firstChild;
  3096. var secondChild;
  3097. var childValue;
  3098. var emptyText;
  3099. var attrNode;
  3100. var retval;
  3101. doc = hc_staff.hc_staff();
  3102. root = doc.documentElement;
  3103. emptyText = doc.createTextNode("");
  3104. elementList = root.getElementsByTagName("acronym");
  3105. element = elementList.item(0);
  3106. attrNode = element.getAttributeNode("title");
  3107. retval = attrNode.appendChild(emptyText);
  3108. element.normalize();
  3109. attrNode = element.getAttributeNode("title");
  3110. firstChild = attrNode.firstChild;
  3111. childValue = firstChild.nodeValue;
  3112. test.equal(childValue, "Yes", 'firstChild');
  3113. secondChild = firstChild.nextSibling;
  3114. test.equal(secondChild, null, 'secondChildNull');
  3115. test.done();
  3116. },
  3117. /**
  3118. *
  3119. The "removeAttributeNode(oldAttr)" method raises a
  3120. NOT_FOUND_ERR DOMException if the "oldAttr" attribute
  3121. is not an attribute of the element.
  3122. Retrieve the last employee and attempt to remove
  3123. a non existing attribute node. This should cause the
  3124. intended exception to be raised. This test makes use
  3125. of the "createAttribute(name)" method from the Document
  3126. interface.
  3127. * @author Curt Arnold
  3128. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])
  3129. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198
  3130. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-D589198')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR'])
  3131. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  3132. */
  3133. hc_elementnotfounderr: function(test) {
  3134. var doc = hc_staff.hc_staff();
  3135. var testAddress = doc.getElementsByTagName("acronym").item(4);
  3136. var oldAttribute = doc.createAttribute("title");
  3137. var success = false;
  3138. try {
  3139. testAddress.removeAttributeNode(oldAttribute);
  3140. } catch(ex) {
  3141. success = (typeof(ex.code) != 'undefined' && ex.code == 8);
  3142. }
  3143. test.ok(success, 'throw_NOT_FOUND_ERR');
  3144. test.done();
  3145. },
  3146. /**
  3147. *
  3148. The "removeAttribute(name)" removes an attribute by name.
  3149. If the attribute has a default value, it is immediately
  3150. replaced. However, there is no default values in the HTML
  3151. compatible tests, so its value is "".
  3152. * @author Curt Arnold
  3153. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9
  3154. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html
  3155. */
  3156. hc_elementremoveattribute: function(test) {
  3157. var success;
  3158. var doc;
  3159. var elementList;
  3160. var testEmployee;
  3161. var attrValue;
  3162. doc = hc_staff.hc_staff();
  3163. elementList = doc.getElementsByTagName("acronym");
  3164. testEmployee = elementList.item(3);
  3165. testEmployee.removeAttribute("class");
  3166. attrValue = testEmployee.getAttribute("class");
  3167. test.equal(attrValue, "", 'attrValue');
  3168. test.done();
  3169. },
  3170. /**
  3171. *
  3172. The "removeAttributeNode(oldAttr)" method removes the
  3173. specified attribute.
  3174. Retrieve the last child of the third employee, add a
  3175. new "lang" attribute to it and then try to remove it.
  3176. To verify that the node was removed use the
  3177. "getNamedItem(name)" method from the NamedNodeMap
  3178. interface. It also uses the "getAttributes()" method
  3179. from the Node interface.
  3180. * @author Curt Arnold
  3181. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198
  3182. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  3183. */
  3184. hc_elementremoveattributeaftercreate: function(test) {
  3185. var success;
  3186. var doc;
  3187. var elementList;
  3188. var testEmployee;
  3189. var newAttribute;
  3190. var attributes;
  3191. var districtAttr;
  3192. doc = hc_staff.hc_staff();
  3193. elementList = doc.getElementsByTagName("acronym");
  3194. testEmployee = elementList.item(2);
  3195. newAttribute = doc.createAttribute("lang");
  3196. districtAttr = testEmployee.setAttributeNode(newAttribute);
  3197. districtAttr = testEmployee.removeAttributeNode(newAttribute);
  3198. attributes = testEmployee.attributes;
  3199. districtAttr = attributes.getNamedItem("lang");
  3200. test.equal(districtAttr, null, 'removed_item_null');
  3201. test.done();
  3202. },
  3203. /**
  3204. *
  3205. The "removeAttributeNode(oldAttr)" method returns the
  3206. node that was removed.
  3207. Retrieve the last child of the third employee and
  3208. remove its "class" Attr node. The method should
  3209. return the old attribute node.
  3210. * @author Curt Arnold
  3211. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198
  3212. */
  3213. hc_elementremoveattributenode: function(test) {
  3214. var success;
  3215. var doc;
  3216. var elementList;
  3217. var testEmployee;
  3218. var streetAttr;
  3219. var removedAttr;
  3220. var removedValue;
  3221. doc = hc_staff.hc_staff();
  3222. elementList = doc.getElementsByTagName("acronym");
  3223. testEmployee = elementList.item(2);
  3224. streetAttr = testEmployee.getAttributeNode("class");
  3225. removedAttr = testEmployee.removeAttributeNode(streetAttr);
  3226. test.notEqual(removedAttr, null, 'removedAttrNotNull');
  3227. removedValue = removedAttr.value;
  3228. test.equal(removedValue, "No", 'elementRemoveAttributeNodeAssert');
  3229. test.done();
  3230. },
  3231. /**
  3232. *
  3233. This test calls setAttributeNode to replace an attribute with itself.
  3234. Since the node is not an attribute of another Element, it would
  3235. be inappropriate to throw an INUSE_ATTRIBUTE_ERR.
  3236. This test was derived from elementinuserattributeerr which
  3237. inadvertanly made this test.
  3238. * @author Curt Arnold
  3239. * @author Curt Arnold
  3240. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  3241. */
  3242. hc_elementreplaceattributewithself: function(test) {
  3243. var doc = hc_staff.hc_staff();
  3244. var testEmployee = doc.getElementsByTagName("acronym").item(2);
  3245. var streetAttr = testEmployee.getAttributeNode("class");
  3246. var replacedAttr = testEmployee.setAttributeNode(streetAttr);
  3247. test.equal(replacedAttr, streetAttr, 'replacedAttr')
  3248. test.done();
  3249. },
  3250. /**
  3251. *
  3252. The "setAttributeNode(newAttr)" method adds a new
  3253. attribute to the Element. If the "newAttr" Attr node is
  3254. already present in this element, it should replace the
  3255. existing one.
  3256. Retrieve the last child of the third employee and add a
  3257. new attribute node by invoking the "setAttributeNode(new
  3258. Attr)" method. The new attribute node to be added is
  3259. "class", which is already present in this element. The
  3260. method should replace the existing Attr node with the
  3261. new one. This test uses the "createAttribute(name)"
  3262. method from the Document interface.
  3263. * @author Curt Arnold
  3264. */
  3265. hc_elementreplaceexistingattribute: function(test) {
  3266. var success;
  3267. var doc;
  3268. var elementList;
  3269. var testEmployee;
  3270. var newAttribute;
  3271. var strong;
  3272. var setAttr;
  3273. doc = hc_staff.hc_staff();
  3274. elementList = doc.getElementsByTagName("acronym");
  3275. testEmployee = elementList.item(2);
  3276. newAttribute = doc.createAttribute("class");
  3277. setAttr = testEmployee.setAttributeNode(newAttribute);
  3278. strong = testEmployee.getAttribute("class");
  3279. test.equal(strong, "", 'replacedValue');
  3280. test.done();
  3281. },
  3282. /**
  3283. *
  3284. If the "setAttributeNode(newAttr)" method replaces an
  3285. existing Attr node with the same name, then it should
  3286. return the previously existing Attr node.
  3287. Retrieve the last child of the third employee and add a
  3288. new attribute node. The new attribute node is "class",
  3289. which is already present in this Element. The method
  3290. should return the existing Attr node(old "class" Attr).
  3291. This test uses the "createAttribute(name)" method
  3292. from the Document interface.
  3293. * @author Curt Arnold
  3294. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  3295. */
  3296. hc_elementreplaceexistingattributegevalue: function(test) {
  3297. var success;
  3298. var doc;
  3299. var elementList;
  3300. var testEmployee;
  3301. var newAttribute;
  3302. var streetAttr;
  3303. var value;
  3304. doc = hc_staff.hc_staff();
  3305. elementList = doc.getElementsByTagName("acronym");
  3306. testEmployee = elementList.item(2);
  3307. newAttribute = doc.createAttribute("class");
  3308. streetAttr = testEmployee.setAttributeNode(newAttribute);
  3309. test.notEqual(streetAttr, null, 'previousAttrNotNull');
  3310. value = streetAttr.value;
  3311. test.equal(value, "No", 'previousAttrValue');
  3312. test.done();
  3313. },
  3314. /**
  3315. *
  3316. Create a list of all the attributes of the last child
  3317. of the first "p" element by using the "getAttributes()"
  3318. method.
  3319. * @author Curt Arnold
  3320. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  3321. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html
  3322. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
  3323. */
  3324. hc_elementretrieveallattributes: function(test) {
  3325. var doc = hc_staff.hc_staff();
  3326. var attributes = doc.getElementsByTagName("acronym").item(0).attributes;
  3327. var actual = [];
  3328. for(var i=0;i<attributes.length;i++) {
  3329. actual.push(attributes.item(i).nodeName);
  3330. }
  3331. test.deepEqual(actual, ['title'])
  3332. test.done();
  3333. },
  3334. /**
  3335. *
  3336. The "getAttribute(name)" method returns an attribute
  3337. value by name.
  3338. Retrieve the second address element, then
  3339. invoke the 'getAttribute("class")' method. This should
  3340. return the value of the attribute("No").
  3341. * @author Curt Arnold
  3342. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-666EE0F9
  3343. */
  3344. hc_elementretrieveattrvalue: function(test) {
  3345. var success;
  3346. var doc;
  3347. var elementList;
  3348. var testAddress;
  3349. var attrValue;
  3350. doc = hc_staff.hc_staff();
  3351. elementList = doc.getElementsByTagName("acronym");
  3352. testAddress = elementList.item(2);
  3353. attrValue = testAddress.getAttribute("class");
  3354. test.equal(attrValue, "No", 'attrValue');
  3355. test.done();
  3356. },
  3357. /**
  3358. *
  3359. The "getElementsByTagName()" method returns a NodeList
  3360. of all descendant elements with a given tagName.
  3361. Invoke the "getElementsByTagName()" method and create
  3362. a NodeList of "code" elements. Retrieve the second
  3363. "code" element in the list and return the NodeName.
  3364. * @author Curt Arnold
  3365. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  3366. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-104682815
  3367. */
  3368. hc_elementretrievetagname: function(test) {
  3369. var doc = hc_staff.hc_staff();
  3370. var testEmployee = doc.getElementsByTagName("code").item(1);
  3371. test.equal(testEmployee.nodeName, 'CODE', 'element nodeName');
  3372. test.equal(testEmployee.tagName, 'CODE', 'element tagName');
  3373. test.done();
  3374. },
  3375. /**
  3376. *
  3377. The "setAttributeNode(newAttr)" method returns the
  3378. null value if no previously existing Attr node with the
  3379. same name was replaced.
  3380. Retrieve the last child of the third employee and add a
  3381. new attribute to it. The new attribute node added is
  3382. "lang", which is not part of this Element. The
  3383. method should return the null value.
  3384. This test uses the "createAttribute(name)"
  3385. method from the Document interface.
  3386. * @author Curt Arnold
  3387. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  3388. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  3389. */
  3390. hc_elementsetattributenodenull: function(test) {
  3391. var success;
  3392. var doc;
  3393. var elementList;
  3394. var testEmployee;
  3395. var newAttribute;
  3396. var districtAttr;
  3397. doc = hc_staff.hc_staff();
  3398. elementList = doc.getElementsByTagName("acronym");
  3399. testEmployee = elementList.item(2);
  3400. newAttribute = doc.createAttribute("lang");
  3401. districtAttr = testEmployee.setAttributeNode(newAttribute);
  3402. test.equal(districtAttr, null, 'elementSetAttributeNodeNullAssert');
  3403. test.done();
  3404. },
  3405. /**
  3406. *
  3407. The "setAttributeNode(newAttr)" method raises an
  3408. "WRONG_DOCUMENT_ERR DOMException if the "newAttr"
  3409. was created from a different document than the one that
  3410. created this document.
  3411. Retrieve the last employee and attempt to set a new
  3412. attribute node for its "employee" element. The new
  3413. attribute was created from a document other than the
  3414. one that created this element, therefore a
  3415. WRONG_DOCUMENT_ERR DOMException should be raised.
  3416. This test uses the "createAttribute(newAttr)" method
  3417. from the Document interface.
  3418. * @author Curt Arnold
  3419. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])
  3420. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  3421. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-887236154')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR'])
  3422. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  3423. */
  3424. hc_elementwrongdocumenterr: function(test) {
  3425. var doc1 = hc_staff.hc_staff();
  3426. var doc2 = hc_staff.hc_staff();
  3427. var newAttribute = doc2.createAttribute("newAttribute");
  3428. var testAddress = doc1.getElementsByTagName("acronym").item(4);
  3429. var success = false;
  3430. try {
  3431. testAddress.setAttributeNode(newAttribute);
  3432. } catch(ex) {
  3433. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  3434. }
  3435. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  3436. test.done();
  3437. },
  3438. /**
  3439. *
  3440. An attempt to add remove an entity should result in a NO_MODIFICATION_ERR.
  3441. * @author Curt Arnold
  3442. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1788794630
  3443. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193
  3444. */
  3445. hc_entitiesremovenameditem1: function(test) {
  3446. // NOTE: no tests get run here...
  3447. test.done();
  3448. },
  3449. /**
  3450. *
  3451. An attempt to add an element to the named node map returned by entities should
  3452. result in a NO_MODIFICATION_ERR or HIERARCHY_REQUEST_ERR.
  3453. * @author Curt Arnold
  3454. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1788794630
  3455. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  3456. */
  3457. hc_entitiessetnameditem1: function(test) {
  3458. // NOTE: no tests get run here
  3459. test.done();
  3460. },
  3461. /**
  3462. *
  3463. Create a NamedNodeMap object from the attributes of the
  3464. last child of the third "p" element and traverse the
  3465. list from index 0 thru length -1. All indices should
  3466. be valid.
  3467. * @author Curt Arnold
  3468. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  3469. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  3470. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D0FB19E
  3471. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=250
  3472. */
  3473. hc_namednodemapchildnoderange: function(test) {
  3474. var doc = hc_staff.hc_staff();
  3475. var attributes = doc.getElementsByTagName("acronym").item(2).attributes;
  3476. test.equal(attributes.length, 2, 'htmlLength');
  3477. test.notEqual(attributes.item(0), null, 'attr0');
  3478. test.notEqual(attributes.item(1), null, 'attr1');
  3479. test.equal(attributes.item(3), null, 'attr3');
  3480. test.done();
  3481. },
  3482. /**
  3483. *
  3484. Retrieve the second "p" element and create a NamedNodeMap
  3485. listing of the attributes of the last child. Once the
  3486. list is created an invocation of the "getNamedItem(name)"
  3487. method is done with name="title". This should result
  3488. in the title Attr node being returned.
  3489. * @author Curt Arnold
  3490. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
  3491. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  3492. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  3493. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
  3494. */
  3495. hc_namednodemapgetnameditem: function(test) {
  3496. var doc = hc_staff.hc_staff();
  3497. var domesticAttr = doc.getElementsByTagName("acronym").item(1).attributes.getNamedItem("title");
  3498. test.equal(domesticAttr.nodeName, 'title', 'attribute nodeName');
  3499. test.done();
  3500. },
  3501. /**
  3502. *
  3503. The "setNamedItem(arg)" method raises a
  3504. INUSE_ATTRIBUTE_ERR DOMException if "arg" is an
  3505. Attr that is already in an attribute of another Element.
  3506. Create a NamedNodeMap object from the attributes of the
  3507. last child of the third employee and attempt to add
  3508. an attribute that is already being used by the first
  3509. employee. This should raise the desired exception.
  3510. * @author Curt Arnold
  3511. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])
  3512. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  3513. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1025163788')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR'])
  3514. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  3515. */
  3516. hc_namednodemapinuseattributeerr: function(test) {
  3517. var doc = hc_staff.hc_staff();
  3518. var firstNode = doc.getElementsByTagName("acronym").item(0);
  3519. var domesticAttr = doc.createAttribute("title");
  3520. domesticAttr.value = "Yα";
  3521. firstNode.setAttributeNode(domesticAttr);
  3522. var attributes = doc.getElementsByTagName("acronym").item(2).attributes;
  3523. var success = false;
  3524. try {
  3525. attributes.setNamedItem(domesticAttr);
  3526. } catch(ex) {
  3527. success = (typeof(ex.code) != 'undefined' && ex.code == 10);
  3528. }
  3529. test.ok(success, 'throw_INUSE_ATTRIBUTE_ERR');
  3530. test.done();
  3531. },
  3532. /**
  3533. *
  3534. The "removeNamedItem(name)" method raises a
  3535. NOT_FOUND_ERR DOMException if there is not a node
  3536. named "strong" in the map.
  3537. Create a NamedNodeMap object from the attributes of the
  3538. last child of the third employee and attempt to remove
  3539. the "lang" attribute. There is not a node named
  3540. "lang" in the list and therefore the desired
  3541. exception should be raised.
  3542. * @author Curt Arnold
  3543. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])
  3544. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193
  3545. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-D58B193')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INUSE_ATTRIBUTE_ERR'])
  3546. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  3547. */
  3548. hc_namednodemapnotfounderr: function(test) {
  3549. var doc = hc_staff.hc_staff();
  3550. var attributes = doc.getElementsByTagName("acronym").item(2).attributes;
  3551. var success = false;
  3552. try {
  3553. attributes.removeNamedItem("lang");
  3554. } catch(ex) {
  3555. success = (typeof(ex.code) != 'undefined' && ex.code == 8);
  3556. }
  3557. test.ok(success, 'throw_NOT_FOUND_ERR');
  3558. test.done();
  3559. },
  3560. /**
  3561. *
  3562. Retrieve the second "p" element and evaluate Node.attributes.length.
  3563. * @author Curt Arnold
  3564. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  3565. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D0FB19E
  3566. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=250
  3567. */
  3568. hc_namednodemapnumberofnodes: function(test) {
  3569. var doc = hc_staff.hc_staff();
  3570. var attributes = doc.getElementsByTagName("acronym").item(2).attributes;
  3571. test.equal(attributes.length, 2, 'htmlLength');
  3572. test.done();
  3573. },
  3574. /**
  3575. *
  3576. The "removeNamedItem(name)" method removes a node
  3577. specified by name.
  3578. Retrieve the third employee and create a NamedNodeMap
  3579. object of the attributes of the last child. Once the
  3580. list is created invoke the "removeNamedItem(name)"
  3581. method with name="class". This should result
  3582. in the removal of the specified attribute.
  3583. * @author Curt Arnold
  3584. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193
  3585. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  3586. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html
  3587. */
  3588. hc_namednodemapremovenameditem: function(test) {
  3589. var success;
  3590. var doc;
  3591. var elementList;
  3592. var newAttribute;
  3593. var testAddress;
  3594. var attributes;
  3595. var streetAttr;
  3596. var specified;
  3597. var removedNode;
  3598. doc = hc_staff.hc_staff();
  3599. elementList = doc.getElementsByTagName("acronym");
  3600. testAddress = elementList.item(2);
  3601. attributes = testAddress.attributes;
  3602. removedNode = attributes.removeNamedItem("class");
  3603. streetAttr = attributes.getNamedItem("class");
  3604. test.equal(streetAttr, null, 'isnull');
  3605. test.done();
  3606. },
  3607. /**
  3608. *
  3609. Retrieve the second p element and create a NamedNodeMap
  3610. listing of the attributes of the last child. Once the
  3611. list is created an invocation of the "getNamedItem(name)"
  3612. method is done with name="class". This should result
  3613. in the method returning an Attr node.
  3614. * @author Curt Arnold
  3615. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
  3616. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  3617. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  3618. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1112119403
  3619. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  3620. */
  3621. hc_namednodemapreturnattrnode: function(test) {
  3622. var doc = hc_staff.hc_staff();
  3623. var streetAttr = doc.getElementsByTagName("acronym").item(1).attributes.getNamedItem("class");
  3624. test.equal(streetAttr.nodeType, 2, 'typeAssert')
  3625. test.equal(streetAttr.nodeName, 'class', 'attribute nodeName');
  3626. test.equal(streetAttr.name, 'class', 'attribute name');
  3627. test.done();
  3628. },
  3629. /**
  3630. *
  3631. The "item(index)" method returns the indexth item in
  3632. the map(test for first item).
  3633. Retrieve the second "acronym" get the NamedNodeMap of the attributes. Since the
  3634. DOM does not specify an order of these nodes the contents
  3635. of the FIRST node can contain either "title", "class" or "dir".
  3636. * @author Curt Arnold
  3637. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  3638. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  3639. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
  3640. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
  3641. */
  3642. hc_namednodemapreturnfirstitem: function(test) {
  3643. var doc = hc_staff.hc_staff();
  3644. var attributes = doc.getElementsByTagName("acronym").item(1).attributes;
  3645. var actual = [];
  3646. for(var i=0;i<attributes.length;i++) {
  3647. actual.push(attributes.item(i).nodeName);
  3648. }
  3649. // assertEqualsCollection("attrName_html",toLowerArray(htmlExpected),toLowerArray(actual));
  3650. test.deepEqual(actual, ['title', 'class'])
  3651. test.done();
  3652. },
  3653. /**
  3654. *
  3655. The "item(index)" method returns the indexth item in
  3656. the map(test for last item).
  3657. Retrieve the second "acronym" and get the attribute name. Since the
  3658. DOM does not specify an order of these nodes the contents
  3659. of the LAST node can contain either "title" or "class".
  3660. The test should return "true" if the LAST node is either
  3661. of these values.
  3662. * @author Curt Arnold
  3663. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  3664. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  3665. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
  3666. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
  3667. */
  3668. hc_namednodemapreturnlastitem: function(test) {
  3669. var doc = hc_staff.hc_staff();
  3670. var attributes = doc.getElementsByTagName("acronym").item(1).attributes;
  3671. var actual = [];
  3672. for(var i=0;i<attributes.length;i++) {
  3673. actual.push(attributes.item(i).nodeName);
  3674. }
  3675. test.deepEqual(actual, ['title', 'class'])
  3676. test.done();
  3677. },
  3678. /**
  3679. *
  3680. The "getNamedItem(name)" method returns null of the
  3681. specified name did not identify any node in the map.
  3682. Retrieve the second employee and create a NamedNodeMap
  3683. listing of the attributes of the last child. Once the
  3684. list is created an invocation of the "getNamedItem(name)"
  3685. method is done with name="lang". This name does not
  3686. match any names in the list therefore the method should
  3687. return null.
  3688. * @author Curt Arnold
  3689. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
  3690. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  3691. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  3692. */
  3693. hc_namednodemapreturnnull: function(test) {
  3694. var success;
  3695. var doc;
  3696. var elementList;
  3697. var testEmployee;
  3698. var attributes;
  3699. var districtNode;
  3700. doc = hc_staff.hc_staff();
  3701. elementList = doc.getElementsByTagName("acronym");
  3702. testEmployee = elementList.item(1);
  3703. attributes = testEmployee.attributes;
  3704. districtNode = attributes.getNamedItem("lang");
  3705. test.equal(districtNode, null, 'langAttrNull');
  3706. test.done();
  3707. },
  3708. /**
  3709. *
  3710. Retrieve the second "p" element and create a NamedNodeMap
  3711. object from the attributes of the last child by
  3712. invoking the "getAttributes()" method. Once the
  3713. list is created an invocation of the "setNamedItem(arg)"
  3714. method is done with arg=newAttr, where newAttr is a
  3715. new Attr Node previously created. The "setNamedItem(arg)"
  3716. method should add then new node to the NamedNodeItem
  3717. object by using its "nodeName" attribute("lang').
  3718. This node is then retrieved using the "getNamedItem(name)"
  3719. method.
  3720. * @author Curt Arnold
  3721. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  3722. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  3723. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  3724. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
  3725. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  3726. */
  3727. hc_namednodemapsetnameditem: function(test) {
  3728. var doc = hc_staff.hc_staff();
  3729. var testAddress = doc.getElementsByTagName("acronym").item(1);
  3730. var newAttribute = doc.createAttribute("lang");
  3731. var attributes = testAddress.attributes;
  3732. attributes.setNamedItem(newAttribute);
  3733. test.equal(attributes.getNamedItem("lang").nodeName, 'lang', 'attribute nodeName');
  3734. test.done();
  3735. },
  3736. /**
  3737. *
  3738. If the "setNamedItem(arg)" method replaces an already
  3739. existing node with the same name then the already
  3740. existing node is returned.
  3741. Retrieve the third employee and create a NamedNodeMap
  3742. object from the attributes of the last child by
  3743. invoking the "getAttributes()" method. Once the
  3744. list is created an invocation of the "setNamedItem(arg)"
  3745. method is done with arg=newAttr, where newAttr is a
  3746. new Attr Node previously created and whose node name
  3747. already exists in the map. The "setNamedItem(arg)"
  3748. method should replace the already existing node with
  3749. the new one and return the existing node.
  3750. This test uses the "createAttribute(name)" method from
  3751. the document interface.
  3752. * @author Curt Arnold
  3753. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  3754. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  3755. */
  3756. hc_namednodemapsetnameditemreturnvalue: function(test) {
  3757. var success;
  3758. var doc;
  3759. var elementList;
  3760. var newAttribute;
  3761. var testAddress;
  3762. var attributes;
  3763. var newNode;
  3764. var attrValue;
  3765. doc = hc_staff.hc_staff();
  3766. elementList = doc.getElementsByTagName("acronym");
  3767. testAddress = elementList.item(2);
  3768. newAttribute = doc.createAttribute("class");
  3769. attributes = testAddress.attributes;
  3770. newNode = attributes.setNamedItem(newAttribute);
  3771. test.notEqual(newNode, null, 'previousAttrNotNull');
  3772. attrValue = newNode.nodeValue;
  3773. test.equal(attrValue, "No", 'previousAttrValue');
  3774. test.done();
  3775. },
  3776. /**
  3777. *
  3778. If the node to be added by the "setNamedItem(arg)" method
  3779. already exists in the NamedNodeMap, it is replaced by
  3780. the new one.
  3781. Retrieve the second employee and create a NamedNodeMap
  3782. object from the attributes of the last child by
  3783. invoking the "getAttributes()" method. Once the
  3784. list is created an invocation of the "setNamedItem(arg)"
  3785. method is done with arg=newAttr, where newAttr is a
  3786. new Attr Node previously created and whose node name
  3787. already exists in the map. The "setNamedItem(arg)"
  3788. method should replace the already existing node with
  3789. the new one.
  3790. This node is then retrieved using the "getNamedItem(name)"
  3791. method. This test uses the "createAttribute(name)"
  3792. method from the document interface
  3793. * @author Curt Arnold
  3794. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  3795. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  3796. */
  3797. hc_namednodemapsetnameditemthatexists: function(test) {
  3798. var success;
  3799. var doc;
  3800. var elementList;
  3801. var newAttribute;
  3802. var testAddress;
  3803. var attributes;
  3804. var districtNode;
  3805. var attrValue;
  3806. var setNode;
  3807. doc = hc_staff.hc_staff();
  3808. elementList = doc.getElementsByTagName("acronym");
  3809. testAddress = elementList.item(1);
  3810. newAttribute = doc.createAttribute("class");
  3811. attributes = testAddress.attributes;
  3812. setNode = attributes.setNamedItem(newAttribute);
  3813. districtNode = attributes.getNamedItem("class");
  3814. attrValue = districtNode.nodeValue;
  3815. test.equal(attrValue, "", 'namednodemapSetNamedItemThatExistsAssert');
  3816. test.done();
  3817. },
  3818. /**
  3819. *
  3820. If the "setNamedItem(arg)" method does not replace an
  3821. existing node with the same name then it returns null.
  3822. Retrieve the third employee and create a NamedNodeMap
  3823. object from the attributes of the last child.
  3824. Once the list is created the "setNamedItem(arg)" method
  3825. is invoked with arg=newAttr, where newAttr is a
  3826. newly created Attr Node and whose node name
  3827. already exists in the map. The "setNamedItem(arg)"
  3828. method should add the new node and return null.
  3829. This test uses the "createAttribute(name)" method from
  3830. the document interface.
  3831. * @author Curt Arnold
  3832. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  3833. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  3834. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  3835. */
  3836. hc_namednodemapsetnameditemwithnewvalue: function(test) {
  3837. var success;
  3838. var doc;
  3839. var elementList;
  3840. var newAttribute;
  3841. var testAddress;
  3842. var attributes;
  3843. var newNode;
  3844. doc = hc_staff.hc_staff();
  3845. elementList = doc.getElementsByTagName("acronym");
  3846. testAddress = elementList.item(2);
  3847. newAttribute = doc.createAttribute("lang");
  3848. attributes = testAddress.attributes;
  3849. newNode = attributes.setNamedItem(newAttribute);
  3850. test.equal(newNode, null, 'prevValueNull');
  3851. test.done();
  3852. },
  3853. /**
  3854. *
  3855. The "setNamedItem(arg)" method raises a
  3856. WRONG_DOCUMENT_ERR DOMException if "arg" was created
  3857. from a different document than the one that created
  3858. the NamedNodeMap.
  3859. Create a NamedNodeMap object from the attributes of the
  3860. last child of the third employee and attempt to add
  3861. another Attr node to it that was created from a
  3862. different DOM document. This should raise the desired
  3863. exception. This method uses the "createAttribute(name)"
  3864. method from the Document interface.
  3865. * @author Curt Arnold
  3866. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])
  3867. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  3868. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1025163788')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR'])
  3869. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  3870. */
  3871. hc_namednodemapwrongdocumenterr: function(test) {
  3872. var doc1 = hc_staff.hc_staff();
  3873. var doc2 = hc_staff.hc_staff();
  3874. var attributes = doc1.getElementsByTagName("acronym").item(2).attributes;
  3875. var newAttribute = doc2.createAttribute("newAttribute");
  3876. var success = false;
  3877. try {
  3878. attributes.setNamedItem(newAttribute);
  3879. } catch(ex) {
  3880. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  3881. }
  3882. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  3883. test.done();
  3884. },
  3885. /**
  3886. *
  3887. Retrieve the second "p" and append a "br" Element
  3888. node to the list of children. The last node in the list
  3889. is then retrieved and its NodeName examined. The
  3890. "getNodeName()" method should return "br".
  3891. * @author Curt Arnold
  3892. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  3893. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  3894. */
  3895. hc_nodeappendchild: function(test) {
  3896. var doc = hc_staff.hc_staff();
  3897. var employeeNode = doc.getElementsByTagName("p").item(1);
  3898. var createdNode = doc.createElement("br");
  3899. employeeNode.appendChild(createdNode);
  3900. var lchild = employeeNode.lastChild;
  3901. test.equal(lchild.nodeName, 'BR', 'element nodeName');
  3902. test.done();
  3903. },
  3904. /**
  3905. *
  3906. If the "newChild" is already in the tree, it is first
  3907. removed before the new one is appended.
  3908. Retrieve the "em" second employee and
  3909. append the first child to the end of the list. After
  3910. the "appendChild(newChild)" method is invoked the first
  3911. child should be the one that was second and the last
  3912. child should be the one that was first.
  3913. * @author Curt Arnold
  3914. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  3915. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  3916. */
  3917. hc_nodeappendchildchildexists: function(test) {
  3918. var expected = ["STRONG", "CODE", "SUP", "VAR", "ACRONYM", "EM"];
  3919. var doc = hc_staff.hc_staff();
  3920. var childNode = doc.getElementsByTagName("p").item(1);
  3921. var childList = childNode.getElementsByTagName("*");
  3922. childNode.appendChild(childList.item(0));
  3923. var actual = [];
  3924. for(var i=0;i<childList.length;i++) {
  3925. actual.push(childList.item(i).nodeName);
  3926. }
  3927. test.deepEqual(actual, expected, 'element liveByTagName');
  3928. childList = childNode.childNodes;
  3929. var refreshedActual = [];
  3930. for(var i=0;i<childList.length;i++) {
  3931. if (1 == childList.item(i).nodeType) {
  3932. refreshedActual.push(childList.item(i).nodeName);
  3933. }
  3934. }
  3935. test.deepEqual(refreshedActual, expected, 'element refreshedChildNodes');
  3936. test.done();
  3937. },
  3938. /**
  3939. *
  3940. If the "newChild" is a DocumentFragment object then
  3941. all its content is added to the child list of this node.
  3942. Create and populate a new DocumentFragment object and
  3943. append it to the second employee. After the
  3944. "appendChild(newChild)" method is invoked retrieve the
  3945. new nodes at the end of the list, they should be the
  3946. two Element nodes from the DocumentFragment.
  3947. * @author Curt Arnold
  3948. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  3949. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  3950. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  3951. */
  3952. hc_nodeappendchilddocfragment: function(test) {
  3953. var success;
  3954. var doc;
  3955. var elementList;
  3956. var employeeNode;
  3957. var childList;
  3958. var newdocFragment;
  3959. var newChild1;
  3960. var newChild2;
  3961. var child;
  3962. var childName;
  3963. var result = new Array();
  3964. var appendedChild;
  3965. var nodeType;
  3966. expected = ["EM", "STRONG", "CODE", "SUP", "VAR", "ACRONYM", "BR", "B"];
  3967. doc = hc_staff.hc_staff();
  3968. elementList = doc.getElementsByTagName("p");
  3969. employeeNode = elementList.item(1);
  3970. childList = employeeNode.childNodes;
  3971. newdocFragment = doc.createDocumentFragment();
  3972. newChild1 = doc.createElement("br");
  3973. newChild2 = doc.createElement("b");
  3974. appendedChild = newdocFragment.appendChild(newChild1);
  3975. appendedChild = newdocFragment.appendChild(newChild2);
  3976. appendedChild = employeeNode.appendChild(newdocFragment);
  3977. for(var indexN100A2 = 0;indexN100A2 < childList.length; indexN100A2++) {
  3978. child = childList.item(indexN100A2);
  3979. nodeType = child.nodeType;
  3980. if(
  3981. (1 == nodeType)
  3982. ) {
  3983. childName = child.nodeName;
  3984. result[result.length] = childName;
  3985. }
  3986. }
  3987. test.deepEqual(result, expected, 'element nodeNames');
  3988. test.done();
  3989. },
  3990. /**
  3991. *
  3992. The "appendChild(newChild)" method returns the node
  3993. added.
  3994. Append a newly created node to the child list of the
  3995. second employee and check the NodeName returned. The
  3996. "getNodeName()" method should return "br".
  3997. * @author Curt Arnold
  3998. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  3999. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  4000. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  4001. */
  4002. hc_nodeappendchildgetnodename: function(test) {
  4003. var doc = hc_staff.hc_staff();
  4004. var employeeNode = doc.getElementsByTagName("p").item(1);
  4005. var newChild = doc.createElement("br");
  4006. var appendNode = employeeNode.appendChild(newChild);
  4007. test.equal(appendNode.nodeName, 'BR', 'element nodeName');
  4008. test.done();
  4009. },
  4010. /**
  4011. *
  4012. The "appendChild(newChild)" method raises a
  4013. HIERARCHY_REQUEST_ERR DOMException if this node is of
  4014. a type that does not allow children of the type "newChild"
  4015. to be inserted.
  4016. Retrieve the root node and attempt to append a newly
  4017. created Attr node. An Element node cannot have children
  4018. of the "Attr" type, therefore the desired exception
  4019. should be raised.
  4020. * @author Curt Arnold
  4021. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
  4022. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  4023. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-184E7107')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='HIERARCHY_REQUEST_ERR'])
  4024. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  4025. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  4026. */
  4027. hc_nodeappendchildinvalidnodetype: function(test) {
  4028. var doc = hc_staff.hc_staff();
  4029. var rootNode = doc.documentElement;
  4030. var newChild = doc.createAttribute("newAttribute");
  4031. var success = false;
  4032. try {
  4033. rootNode.appendChild(newChild);
  4034. } catch(ex) {
  4035. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  4036. }
  4037. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  4038. test.done();
  4039. },
  4040. /**
  4041. *
  4042. The "appendChild(newChild)" method raises a
  4043. WRONG_DOCUMENT_ERR DOMException if the "newChild" was
  4044. created from a different document than the one that
  4045. created this node.
  4046. Retrieve the second employee and attempt to append
  4047. a node created from a different document. An attempt
  4048. to make such a replacement should raise the desired
  4049. exception.
  4050. * @author Curt Arnold
  4051. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
  4052. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  4053. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-184E7107')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NOT_FOUND_ERR'])
  4054. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  4055. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  4056. */
  4057. hc_nodeappendchildnewchilddiffdocument: function(test) {
  4058. doc1 = hc_staff.hc_staff();
  4059. doc2 = hc_staff.hc_staff();
  4060. var newChild = doc1.createElement("br");
  4061. var elementNode = doc2.getElementsByTagName("p").item(1);
  4062. var success = false;
  4063. try {
  4064. elementNode.appendChild(newChild);
  4065. } catch(ex) {
  4066. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  4067. }
  4068. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  4069. test.done();
  4070. },
  4071. /**
  4072. *
  4073. The "appendChild(newChild)" method raises a
  4074. HIERARCHY_REQUEST_ERR DOMException if the node to
  4075. append is one of this node's ancestors.
  4076. Retrieve the second employee and attempt to append
  4077. an ancestor node(root node) to it.
  4078. An attempt to make such an addition should raise the
  4079. desired exception.
  4080. * @author Curt Arnold
  4081. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
  4082. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  4083. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-184E7107')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='HIERARCHY_REQUEST_ERR'])
  4084. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  4085. */
  4086. hc_nodeappendchildnodeancestor: function(test) {
  4087. var doc = hc_staff.hc_staff();
  4088. var newChild = doc.documentElement;
  4089. var employeeNode = doc.getElementsByTagName("p").item(1);
  4090. var success = false;
  4091. try {
  4092. employeeNode.appendChild(newChild);
  4093. } catch(ex) {
  4094. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  4095. }
  4096. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  4097. test.done();
  4098. },
  4099. /**
  4100. *
  4101. The "getAttributes()" method invoked on an Attribute
  4102. Node returns null.
  4103. Retrieve the first attribute from the last child of the
  4104. first employee and invoke the "getAttributes()" method
  4105. on the Attribute Node. It should return null.
  4106. * @author Curt Arnold
  4107. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  4108. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  4109. */
  4110. hc_nodeattributenodeattribute: function(test) {
  4111. var success;
  4112. var doc;
  4113. var elementList;
  4114. var testAddr;
  4115. var addrAttr;
  4116. var attrNode;
  4117. var attrList;
  4118. doc = hc_staff.hc_staff();
  4119. elementList = doc.getElementsByTagName("acronym");
  4120. testAddr = elementList.item(0);
  4121. addrAttr = testAddr.attributes;
  4122. attrNode = addrAttr.item(0);
  4123. attrList = attrNode.attributes;
  4124. test.equal(attrList, null, 'nodeAttributeNodeAttributeAssert1');
  4125. test.done();
  4126. },
  4127. /**
  4128. *
  4129. Retrieve the Attribute named "title" from the last
  4130. child of the first p element and check the string returned
  4131. by the "getNodeName()" method. It should be equal to
  4132. "title".
  4133. * @author Curt Arnold
  4134. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  4135. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  4136. */
  4137. hc_nodeattributenodename: function(test) {
  4138. var doc = hc_staff.hc_staff();
  4139. var addrAttr = doc.getElementsByTagName("acronym").item(0).getAttributeNode("title");
  4140. test.equal(addrAttr.nodeName, 'title', 'attribute nodeName');
  4141. test.done();
  4142. },
  4143. /**
  4144. *
  4145. The "getNodeType()" method for an Attribute Node
  4146. returns the constant value 2.
  4147. Retrieve the first attribute from the last child of
  4148. the first employee and invoke the "getNodeType()"
  4149. method. The method should return 2.
  4150. * @author Curt Arnold
  4151. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  4152. */
  4153. hc_nodeattributenodetype: function(test) {
  4154. var success;
  4155. var doc;
  4156. var elementList;
  4157. var testAddr;
  4158. var addrAttr;
  4159. var nodeType;
  4160. doc = hc_staff.hc_staff();
  4161. elementList = doc.getElementsByTagName("acronym");
  4162. testAddr = elementList.item(0);
  4163. addrAttr = testAddr.getAttributeNode("title");
  4164. nodeType = addrAttr.nodeType;
  4165. test.equal(nodeType, 2, 'nodeAttrNodeTypeAssert1');
  4166. test.done();
  4167. },
  4168. /**
  4169. *
  4170. The string returned by the "getNodeValue()" method for an
  4171. Attribute Node is the value of the Attribute.
  4172. Retrieve the Attribute named "title" from the last
  4173. child of the first "p" and check the string returned
  4174. by the "getNodeValue()" method. It should be equal to
  4175. "Yes".
  4176. * @author Curt Arnold
  4177. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  4178. */
  4179. hc_nodeattributenodevalue: function(test) {
  4180. var success;
  4181. var doc;
  4182. var elementList;
  4183. var testAddr;
  4184. var addrAttr;
  4185. var attrValue;
  4186. doc = hc_staff.hc_staff();
  4187. elementList = doc.getElementsByTagName("acronym");
  4188. testAddr = elementList.item(0);
  4189. addrAttr = testAddr.getAttributeNode("title");
  4190. attrValue = addrAttr.nodeValue;
  4191. test.equal(attrValue, "Yes", 'nodeValue');
  4192. test.done();
  4193. },
  4194. /**
  4195. *
  4196. The "getChildNodes()" method returns a NodeList
  4197. that contains all children of this node.
  4198. Retrieve the second employee and check the NodeList
  4199. returned by the "getChildNodes()" method. The
  4200. length of the list should be 13.
  4201. * @author Curt Arnold
  4202. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  4203. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  4204. */
  4205. hc_nodechildnodes: function(test) {
  4206. var success;
  4207. var doc;
  4208. var elementList;
  4209. var employeeNode;
  4210. var childNode;
  4211. var childNodes;
  4212. var nodeType;
  4213. var childName;
  4214. var actual = new Array();
  4215. expected = ["EM", "STRONG", "CODE", "SUP", "VAR", "ACRONYM"];
  4216. doc = hc_staff.hc_staff();
  4217. elementList = doc.getElementsByTagName("p");
  4218. employeeNode = elementList.item(1);
  4219. childNodes = employeeNode.childNodes;
  4220. for(var indexN1006C = 0;indexN1006C < childNodes.length; indexN1006C++) {
  4221. childNode = childNodes.item(indexN1006C);
  4222. nodeType = childNode.nodeType;
  4223. childName = childNode.nodeName;
  4224. if(
  4225. (1 == nodeType)
  4226. ) {
  4227. actual[actual.length] = childName;
  4228. }
  4229. else {
  4230. test.equal(nodeType, 3, 'textNodeType');
  4231. }
  4232. }
  4233. test.deepEqual(actual, expected, 'element elementNames');
  4234. test.done();
  4235. },
  4236. /**
  4237. *
  4238. The NodeList returned by the "getChildNodes()" method
  4239. is live. Changes on the node's children are immediately
  4240. reflected on the nodes returned in the NodeList.
  4241. Create a NodeList of the children of the second employee
  4242. and then add a newly created element that was created
  4243. by the "createElement()" method(Document Interface) to
  4244. the second employee by using the "appendChild()" method.
  4245. The length of the NodeList should reflect this new
  4246. addition to the child list. It should return the value 14.
  4247. * @author Curt Arnold
  4248. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  4249. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  4250. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  4251. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  4252. */
  4253. hc_nodechildnodesappendchild: function(test) {
  4254. var success;
  4255. var doc;
  4256. var elementList;
  4257. var employeeNode;
  4258. var childList;
  4259. var createdNode;
  4260. var childNode;
  4261. var childName;
  4262. var childType;
  4263. var textNode;
  4264. var actual = new Array();
  4265. expected = ["EM", "STRONG", "CODE", "SUP", "VAR", "ACRONYM", "BR"];
  4266. doc = hc_staff.hc_staff();
  4267. elementList = doc.getElementsByTagName("p");
  4268. employeeNode = elementList.item(1);
  4269. childList = employeeNode.childNodes;
  4270. createdNode = doc.createElement("br");
  4271. employeeNode = employeeNode.appendChild(createdNode);
  4272. for(var indexN10087 = 0;indexN10087 < childList.length; indexN10087++) {
  4273. childNode = childList.item(indexN10087);
  4274. childName = childNode.nodeName;
  4275. childType = childNode.nodeType;
  4276. if(
  4277. (1 == childType)
  4278. ) {
  4279. actual[actual.length] = childName;
  4280. }
  4281. else {
  4282. test.equal(childType, 3, 'textNodeType');
  4283. }
  4284. }
  4285. test.deepEqual(actual, expected, 'element childElements');
  4286. test.done();
  4287. },
  4288. /**
  4289. *
  4290. The "getChildNodes()" method returns a NodeList
  4291. that contains all children of this node. If there
  4292. are not any children, this is a NodeList that does not
  4293. contain any nodes.
  4294. Retrieve the character data of the second "em" node and
  4295. invoke the "getChildNodes()" method. The
  4296. NodeList returned should not have any nodes.
  4297. * @author Curt Arnold
  4298. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  4299. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  4300. */
  4301. hc_nodechildnodesempty: function(test) {
  4302. var success;
  4303. var doc;
  4304. var elementList;
  4305. var childList;
  4306. var employeeNode;
  4307. var textNode;
  4308. var length;
  4309. doc = hc_staff.hc_staff();
  4310. elementList = doc.getElementsByTagName("em");
  4311. employeeNode = elementList.item(1);
  4312. textNode = employeeNode.firstChild;
  4313. childList = textNode.childNodes;
  4314. length = childList.length;
  4315. test.equal(length, 0, 'length_zero');
  4316. test.done();
  4317. },
  4318. /**
  4319. *
  4320. Retrieve the second acronym element and invoke
  4321. the cloneNode method. The
  4322. duplicate node returned by the method should copy the
  4323. attributes associated with this node.
  4324. * @author Curt Arnold
  4325. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  4326. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  4327. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
  4328. */
  4329. hc_nodecloneattributescopied: function(test) {
  4330. var doc = hc_staff.hc_staff();
  4331. var attributes = doc.getElementsByTagName("acronym").item(1).cloneNode(false).attributes;
  4332. var actual = [];
  4333. for(var i=0;i<attributes.length;i++) {
  4334. actual.push(attributes.item(i).nodeName);
  4335. }
  4336. test.deepEqual(actual, ['title', 'class'])
  4337. test.done();
  4338. },
  4339. /**
  4340. *
  4341. The "cloneNode(deep)" method does not copy text unless it
  4342. is deep cloned.(Test for deep=false)
  4343. Retrieve the fourth child of the second employee and
  4344. the "cloneNode(deep)" method with deep=false. The
  4345. duplicate node returned by the method should not copy
  4346. any text data contained in this node.
  4347. * @author Curt Arnold
  4348. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
  4349. */
  4350. hc_nodeclonefalsenocopytext: function(test) {
  4351. var success;
  4352. var doc;
  4353. var elementList;
  4354. var employeeNode;
  4355. var childList;
  4356. var childNode;
  4357. var clonedNode;
  4358. var lastChildNode;
  4359. doc = hc_staff.hc_staff();
  4360. elementList = doc.getElementsByTagName("p");
  4361. employeeNode = elementList.item(1);
  4362. childList = employeeNode.childNodes;
  4363. childNode = childList.item(3);
  4364. clonedNode = childNode.cloneNode(false);
  4365. lastChildNode = clonedNode.lastChild;
  4366. test.equal(lastChildNode, null, 'nodeCloneFalseNoCopyTextAssert1');
  4367. test.done();
  4368. },
  4369. /**
  4370. *
  4371. The duplicate node returned by the "cloneNode(deep)"
  4372. method does not have a ParentNode.
  4373. Retrieve the second employee and invoke the
  4374. "cloneNode(deep)" method with deep=false. The
  4375. duplicate node returned should return null when the
  4376. "getParentNode()" is invoked.
  4377. * @author Curt Arnold
  4378. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
  4379. */
  4380. hc_nodeclonegetparentnull: function(test) {
  4381. var success;
  4382. var doc;
  4383. var elementList;
  4384. var employeeNode;
  4385. var clonedNode;
  4386. var parentNode;
  4387. doc = hc_staff.hc_staff();
  4388. elementList = doc.getElementsByTagName("p");
  4389. employeeNode = elementList.item(1);
  4390. clonedNode = employeeNode.cloneNode(false);
  4391. parentNode = clonedNode.parentNode;
  4392. test.equal(parentNode, null, 'nodeCloneGetParentNullAssert1');
  4393. test.done();
  4394. },
  4395. /**
  4396. *
  4397. The "cloneNode(deep)" method returns a copy of the node
  4398. only if deep=false.
  4399. Retrieve the second employee and invoke the
  4400. "cloneNode(deep)" method with deep=false. The
  4401. method should only clone this node. The NodeName and
  4402. length of the NodeList are checked. The "getNodeName()"
  4403. method should return "employee" and the "getLength()"
  4404. method should return 0.
  4405. * @author Curt Arnold
  4406. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
  4407. */
  4408. hc_nodeclonenodefalse: function(test) {
  4409. var doc = hc_staff.hc_staff();
  4410. var clonedNode = doc.getElementsByTagName("p").item(1).cloneNode(false);
  4411. test.equal(clonedNode.nodeName, 'P', 'element strong');
  4412. test.equal(clonedNode.childNodes.length, 0, 'length');
  4413. test.done();
  4414. },
  4415. /**
  4416. *
  4417. The "cloneNode(deep)" method returns a copy of the node
  4418. and the subtree under it if deep=true.
  4419. Retrieve the second employee and invoke the
  4420. "cloneNode(deep)" method with deep=true. The
  4421. method should clone this node and the subtree under it.
  4422. The NodeName of each child in the returned node is
  4423. checked to insure the entire subtree under the second
  4424. employee was cloned.
  4425. * @author Curt Arnold
  4426. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
  4427. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  4428. */
  4429. hc_nodeclonenodetrue: function(test) {
  4430. var success;
  4431. var doc;
  4432. var elementList;
  4433. var employeeNode;
  4434. var clonedNode;
  4435. var clonedList;
  4436. var clonedChild;
  4437. var clonedChildName;
  4438. var origList;
  4439. var origChild;
  4440. var origChildName;
  4441. var result = new Array();
  4442. var expected = new Array();
  4443. doc = hc_staff.hc_staff();
  4444. elementList = doc.getElementsByTagName("p");
  4445. employeeNode = elementList.item(1);
  4446. origList = employeeNode.childNodes;
  4447. for(var indexN10065 = 0;indexN10065 < origList.length; indexN10065++) {
  4448. origChild = origList.item(indexN10065);
  4449. origChildName = origChild.nodeName;
  4450. expected[expected.length] = origChildName;
  4451. }
  4452. clonedNode = employeeNode.cloneNode(true);
  4453. clonedList = clonedNode.childNodes;
  4454. for(var indexN1007B = 0;indexN1007B < clonedList.length; indexN1007B++) {
  4455. clonedChild = clonedList.item(indexN1007B);
  4456. clonedChildName = clonedChild.nodeName;
  4457. result[result.length] = clonedChildName;
  4458. }
  4459. test.deepEqual(result, expected, 'clone');
  4460. test.done();
  4461. },
  4462. /**
  4463. *
  4464. The "cloneNode(deep)" method does not copy text unless it
  4465. is deep cloned.(Test for deep=true)
  4466. Retrieve the eighth child of the second employee and
  4467. the "cloneNode(deep)" method with deep=true. The
  4468. duplicate node returned by the method should copy
  4469. any text data contained in this node.
  4470. * @author Curt Arnold
  4471. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
  4472. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  4473. */
  4474. hc_nodeclonetruecopytext: function(test) {
  4475. var success;
  4476. var doc;
  4477. var elementList;
  4478. var childNode;
  4479. var clonedNode;
  4480. var lastChildNode;
  4481. var childValue;
  4482. doc = hc_staff.hc_staff();
  4483. elementList = doc.getElementsByTagName("sup");
  4484. childNode = elementList.item(1);
  4485. clonedNode = childNode.cloneNode(true);
  4486. lastChildNode = clonedNode.lastChild;
  4487. childValue = lastChildNode.nodeValue;
  4488. test.equal(childValue, "35,000", 'cloneContainsText');
  4489. test.done();
  4490. },
  4491. /**
  4492. *
  4493. The "getAttributes()" method invoked on a Comment
  4494. Node returns null.
  4495. Find any comment that is an immediate child of the root
  4496. and assert that Node.attributes is null. Then create
  4497. a new comment node (in case they had been omitted) and
  4498. make the assertion.
  4499. * @author Curt Arnold
  4500. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  4501. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
  4502. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=248
  4503. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=263
  4504. */
  4505. hc_nodecommentnodeattributes: function(test) {
  4506. var success;
  4507. var doc;
  4508. var commentNode;
  4509. var nodeList;
  4510. var attrList;
  4511. var nodeType;
  4512. doc = hc_staff.hc_staff();
  4513. nodeList = doc.childNodes;
  4514. for(var indexN10043 = 0;indexN10043 < nodeList.length; indexN10043++) {
  4515. commentNode = nodeList.item(indexN10043);
  4516. nodeType = commentNode.nodeType;
  4517. if(
  4518. (8 == nodeType)
  4519. ) {
  4520. attrList = commentNode.attributes;
  4521. test.equal(attrList, null, 'existingCommentAttributesNull');
  4522. }
  4523. }
  4524. commentNode = doc.createComment("This is a comment");
  4525. attrList = commentNode.attributes;
  4526. test.equal(attrList, null, 'createdCommentAttributesNull');
  4527. test.done();
  4528. },
  4529. /**
  4530. *
  4531. The string returned by the "getNodeName()" method for a
  4532. Comment Node is "#comment".
  4533. Retrieve the Comment node in the XML file
  4534. and check the string returned by the "getNodeName()"
  4535. method. It should be equal to "#comment".
  4536. * @author Curt Arnold
  4537. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  4538. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
  4539. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=248
  4540. */
  4541. hc_nodecommentnodename: function(test) {
  4542. var success;
  4543. var doc;
  4544. var elementList;
  4545. var commentNode;
  4546. var nodeType;
  4547. var commentName;
  4548. var commentNodeName;
  4549. doc = hc_staff.hc_staff();
  4550. elementList = doc.childNodes;
  4551. for(var indexN10044 = 0;indexN10044 < elementList.length; indexN10044++) {
  4552. commentNode = elementList.item(indexN10044);
  4553. nodeType = commentNode.nodeType;
  4554. if(
  4555. (8 == nodeType)
  4556. ) {
  4557. commentNodeName = commentNode.nodeName;
  4558. test.equal(commentNodeName, "#comment", 'existingNodeName');
  4559. }
  4560. }
  4561. commentNode = doc.createComment("This is a comment");
  4562. commentNodeName = commentNode.nodeName;
  4563. test.equal(commentNodeName, "#comment", 'createdNodeName');
  4564. test.done();
  4565. },
  4566. /**
  4567. *
  4568. The "getNodeType()" method for a Comment Node
  4569. returns the constant value 8.
  4570. Retrieve the nodes from the document and check for
  4571. a comment node and invoke the "getNodeType()" method. This should
  4572. return 8.
  4573. * @author Curt Arnold
  4574. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  4575. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
  4576. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=248
  4577. */
  4578. hc_nodecommentnodetype: function(test) {
  4579. var success;
  4580. var doc;
  4581. var testList;
  4582. var commentNode;
  4583. var commentNodeName;
  4584. var nodeType;
  4585. doc = hc_staff.hc_staff();
  4586. testList = doc.childNodes;
  4587. for(var indexN10040 = 0;indexN10040 < testList.length; indexN10040++) {
  4588. commentNode = testList.item(indexN10040);
  4589. commentNodeName = commentNode.nodeName;
  4590. if(
  4591. ("#comment" == commentNodeName)
  4592. ) {
  4593. nodeType = commentNode.nodeType;
  4594. test.equal(nodeType, 8, 'existingCommentNodeType');
  4595. }
  4596. }
  4597. commentNode = doc.createComment("This is a comment");
  4598. nodeType = commentNode.nodeType;
  4599. test.equal(nodeType, 8, 'createdCommentNodeType');
  4600. test.done();
  4601. },
  4602. /**
  4603. *
  4604. The string returned by the "getNodeValue()" method for a
  4605. Comment Node is the content of the comment.
  4606. Retrieve the comment in the XML file and
  4607. check the string returned by the "getNodeValue()" method.
  4608. It should be equal to "This is comment number 1".
  4609. * @author Curt Arnold
  4610. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  4611. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
  4612. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=248
  4613. */
  4614. hc_nodecommentnodevalue: function(test) {
  4615. var success;
  4616. var doc;
  4617. var elementList;
  4618. var commentNode;
  4619. var commentName;
  4620. var commentValue;
  4621. doc = hc_staff.hc_staff();
  4622. elementList = doc.childNodes;
  4623. for(var indexN10040 = 0;indexN10040 < elementList.length; indexN10040++) {
  4624. commentNode = elementList.item(indexN10040);
  4625. commentName = commentNode.nodeName;
  4626. if(
  4627. ("#comment" == commentName)
  4628. ) {
  4629. commentValue = commentNode.nodeValue;
  4630. test.equal(commentValue, " This is comment number 1.", 'value');
  4631. }
  4632. }
  4633. commentNode = doc.createComment(" This is a comment");
  4634. commentValue = commentNode.nodeValue;
  4635. test.equal(commentValue, " This is a comment", 'createdCommentNodeValue');
  4636. test.done();
  4637. },
  4638. /**
  4639. *
  4640. The string returned by the "getNodeName()" method for a
  4641. DocumentFragment Node is "#document-frament".
  4642. Retrieve the DOM document and invoke the
  4643. "createDocumentFragment()" method and check the string
  4644. returned by the "getNodeName()" method. It should be
  4645. equal to "#document-fragment".
  4646. * @author Curt Arnold
  4647. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  4648. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
  4649. */
  4650. hc_nodedocumentfragmentnodename: function(test) {
  4651. var doc = hc_staff.hc_staff();
  4652. var docFragment = doc.createDocumentFragment();
  4653. test.equal(docFragment.nodeName, "#document-fragment", 'nodeDocumentFragmentNodeNameAssert1');
  4654. test.done();
  4655. },
  4656. /**
  4657. *
  4658. The "getNodeType()" method for a DocumentFragment Node
  4659. returns the constant value 11.
  4660. Invoke the "createDocumentFragment()" method and
  4661. examine the NodeType of the document fragment
  4662. returned by the "getNodeType()" method. The method
  4663. should return 11.
  4664. * @author Curt Arnold
  4665. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  4666. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
  4667. */
  4668. hc_nodedocumentfragmentnodetype: function(test) {
  4669. var success;
  4670. var doc;
  4671. var documentFragmentNode;
  4672. var nodeType;
  4673. doc = hc_staff.hc_staff();
  4674. documentFragmentNode = doc.createDocumentFragment();
  4675. nodeType = documentFragmentNode.nodeType;
  4676. test.equal(nodeType, 11, 'nodeDocumentFragmentNodeTypeAssert1');
  4677. test.done();
  4678. },
  4679. /**
  4680. *
  4681. The string returned by the "getNodeValue()" method for a
  4682. DocumentFragment Node is null.
  4683. Retrieve the DOM document and invoke the
  4684. "createDocumentFragment()" method and check the string
  4685. returned by the "getNodeValue()" method. It should be
  4686. equal to null.
  4687. * @author Curt Arnold
  4688. * @author Curt Arnold
  4689. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
  4690. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  4691. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  4692. */
  4693. hc_nodedocumentfragmentnodevalue: function(test) {
  4694. var success;
  4695. var doc;
  4696. var docFragment;
  4697. var attrList;
  4698. var value;
  4699. doc = hc_staff.hc_staff();
  4700. docFragment = doc.createDocumentFragment();
  4701. attrList = docFragment.attributes;
  4702. test.equal(attrList, null, 'attributesNull');
  4703. value = docFragment.nodeValue;
  4704. test.equal(value, null, 'initiallyNull');
  4705. test.done();
  4706. },
  4707. /**
  4708. *
  4709. The "getAttributes()" method invoked on a Document
  4710. Node returns null.
  4711. Retrieve the DOM Document and invoke the
  4712. "getAttributes()" method on the Document Node.
  4713. It should return null.
  4714. * @author Curt Arnold
  4715. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  4716. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
  4717. */
  4718. hc_nodedocumentnodeattribute: function(test) {
  4719. var success;
  4720. var doc;
  4721. var attrList;
  4722. doc = hc_staff.hc_staff();
  4723. attrList = doc.attributes;
  4724. test.equal(attrList, null, 'doc_attributes_is_null');
  4725. test.done();
  4726. },
  4727. /**
  4728. *
  4729. The string returned by the "getNodeName()" method for a
  4730. Document Node is "#document".
  4731. Retrieve the DOM document and check the string returned
  4732. by the "getNodeName()" method. It should be equal to
  4733. "#document".
  4734. * @author Curt Arnold
  4735. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
  4736. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  4737. */
  4738. hc_nodedocumentnodename: function(test) {
  4739. var success;
  4740. var doc;
  4741. var documentName;
  4742. doc = hc_staff.hc_staff();
  4743. documentName = doc.nodeName;
  4744. test.equal(documentName, "#document", 'documentNodeName');
  4745. test.done();
  4746. },
  4747. /**
  4748. *
  4749. The "getNodeType()" method for a Document Node
  4750. returns the constant value 9.
  4751. Retrieve the document and invoke the "getNodeType()"
  4752. method. The method should return 9.
  4753. * @author Curt Arnold
  4754. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
  4755. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  4756. */
  4757. hc_nodedocumentnodetype: function(test) {
  4758. var success;
  4759. var doc;
  4760. var nodeType;
  4761. doc = hc_staff.hc_staff();
  4762. nodeType = doc.nodeType;
  4763. test.equal(nodeType, 9, 'nodeDocumentNodeTypeAssert1');
  4764. test.done();
  4765. },
  4766. /**
  4767. *
  4768. The string returned by the "getNodeValue()" method for a
  4769. Document Node is null.
  4770. Retrieve the DOM Document and check the string returned
  4771. by the "getNodeValue()" method. It should be equal to
  4772. null.
  4773. * @author Curt Arnold
  4774. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
  4775. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  4776. */
  4777. hc_nodedocumentnodevalue: function(test) {
  4778. var success;
  4779. var doc;
  4780. var documentValue;
  4781. doc = hc_staff.hc_staff();
  4782. documentValue = doc.nodeValue;
  4783. test.equal(documentValue, null, 'documentNodeValue');
  4784. test.done();
  4785. },
  4786. /**
  4787. *
  4788. Retrieve the third "acronym" element and evaluate Node.attributes.
  4789. * @author Curt Arnold
  4790. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  4791. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  4792. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
  4793. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
  4794. */
  4795. hc_nodeelementnodeattributes: function(test) {
  4796. var doc = hc_staff.hc_staff();
  4797. var attributes = doc.getElementsByTagName("acronym").item(2).attributes;
  4798. var actual = [];
  4799. for(var i=0;i<attributes.length;i++) {
  4800. actual.push(attributes.item(i).nodeName);
  4801. }
  4802. test.deepEqual(actual, ['title', 'class'])
  4803. test.done();
  4804. },
  4805. /**
  4806. *
  4807. Retrieve the first Element Node(Root Node) of the
  4808. DOM object and check the string returned by the
  4809. "getNodeName()" method. It should be equal to its
  4810. tagName.
  4811. * @author Curt Arnold
  4812. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  4813. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
  4814. */
  4815. hc_nodeelementnodename: function(test) {
  4816. var doc = hc_staff.hc_staff();
  4817. test.equal(doc.documentElement.nodeName, 'HTML')
  4818. test.done();
  4819. },
  4820. /**
  4821. *
  4822. The "getNodeType()" method for an Element Node
  4823. returns the constant value 1.
  4824. Retrieve the root node and invoke the "getNodeType()"
  4825. method. The method should return 1.
  4826. * @author Curt Arnold
  4827. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  4828. */
  4829. hc_nodeelementnodetype: function(test) {
  4830. var success;
  4831. var doc;
  4832. var rootNode;
  4833. var nodeType;
  4834. doc = hc_staff.hc_staff();
  4835. rootNode = doc.documentElement;
  4836. nodeType = rootNode.nodeType;
  4837. test.equal(nodeType, 1, 'nodeElementNodeTypeAssert1');
  4838. test.done();
  4839. },
  4840. /**
  4841. *
  4842. The string returned by the "getNodeValue()" method for an
  4843. Element Node is null.
  4844. * @author Curt Arnold
  4845. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  4846. */
  4847. hc_nodeelementnodevalue: function(test) {
  4848. var success;
  4849. var doc;
  4850. var elementNode;
  4851. var elementValue;
  4852. doc = hc_staff.hc_staff();
  4853. elementNode = doc.documentElement;
  4854. elementValue = elementNode.nodeValue;
  4855. test.equal(elementValue, null, 'elementNodeValue');
  4856. test.done();
  4857. },
  4858. /**
  4859. *
  4860. The "getFirstChild()" method returns the first child
  4861. of this node.
  4862. Retrieve the second employee and invoke the
  4863. "getFirstChild()" method. The NodeName returned
  4864. should be "#text" or "EM".
  4865. * @author Curt Arnold
  4866. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-169727388
  4867. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  4868. */
  4869. hc_nodegetfirstchild: function(test) {
  4870. var doc = hc_staff.hc_staff();
  4871. var fchildNode = doc.getElementsByTagName("p").item(1).firstChild;
  4872. test.equal(fchildNode.nodeName, "#text", 'firstChild_w_whitespace');
  4873. test.done();
  4874. },
  4875. /**
  4876. *
  4877. If there is not a first child then the "getFirstChild()"
  4878. method returns null.
  4879. Retrieve the text of the first "em" element and invoke the "getFirstChild()" method. It
  4880. should return null.
  4881. * @author Curt Arnold
  4882. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-169727388
  4883. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  4884. */
  4885. hc_nodegetfirstchildnull: function(test) {
  4886. var doc = hc_staff.hc_staff();
  4887. emText = doc.getElementsByTagName("em").item(0).firstChild;
  4888. test.equal(emText.firstChild, null, 'nullChild');
  4889. test.done();
  4890. },
  4891. /**
  4892. *
  4893. The "getLastChild()" method returns the last child
  4894. of this node.
  4895. Retrieve the second employee and invoke the
  4896. "getLastChild()" method. The NodeName returned
  4897. should be "#text".
  4898. * @author Curt Arnold
  4899. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-61AD09FB
  4900. */
  4901. hc_nodegetlastchild: function(test) {
  4902. var success;
  4903. var doc;
  4904. var elementList;
  4905. var employeeNode;
  4906. var lchildNode;
  4907. var childName;
  4908. doc = hc_staff.hc_staff();
  4909. elementList = doc.getElementsByTagName("p");
  4910. employeeNode = elementList.item(1);
  4911. lchildNode = employeeNode.lastChild;
  4912. childName = lchildNode.nodeName;
  4913. test.equal(childName, "#text", 'whitespace');
  4914. test.done();
  4915. },
  4916. /**
  4917. *
  4918. If there is not a last child then the "getLastChild()"
  4919. method returns null.
  4920. Retrieve the text of the first "em" element and invoke the "getFirstChild()" method. It
  4921. should return null.
  4922. * @author Curt Arnold
  4923. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-61AD09FB
  4924. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  4925. */
  4926. hc_nodegetlastchildnull: function(test) {
  4927. var success;
  4928. var doc;
  4929. var emList;
  4930. var emNode;
  4931. var emText;
  4932. var nullChild;
  4933. doc = hc_staff.hc_staff();
  4934. emList = doc.getElementsByTagName("em");
  4935. emNode = emList.item(0);
  4936. emText = emNode.firstChild;
  4937. nullChild = emText.lastChild;
  4938. test.equal(nullChild, null, 'nullChild');
  4939. test.done();
  4940. },
  4941. /**
  4942. *
  4943. The "getNextSibling()" method returns the node immediately
  4944. following this node.
  4945. Retrieve the first child of the second employee and
  4946. invoke the "getNextSibling()" method. It should return
  4947. a node with the NodeName of "#text".
  4948. * @author Curt Arnold
  4949. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F
  4950. */
  4951. hc_nodegetnextsibling: function(test) {
  4952. var success;
  4953. var doc;
  4954. var elementList;
  4955. var emNode;
  4956. var nsNode;
  4957. var nsName;
  4958. doc = hc_staff.hc_staff();
  4959. elementList = doc.getElementsByTagName("em");
  4960. emNode = elementList.item(1);
  4961. nsNode = emNode.nextSibling;
  4962. nsName = nsNode.nodeName;
  4963. test.equal(nsName, "#text", 'whitespace');
  4964. test.done();
  4965. },
  4966. /**
  4967. *
  4968. If there is not a node immediately following this node the
  4969. "getNextSibling()" method returns null.
  4970. Retrieve the first child of the second employee and
  4971. invoke the "getNextSibling()" method. It should
  4972. be set to null.
  4973. * @author Curt Arnold
  4974. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F
  4975. */
  4976. hc_nodegetnextsiblingnull: function(test) {
  4977. var success;
  4978. var doc;
  4979. var elementList;
  4980. var employeeNode;
  4981. var lcNode;
  4982. var nsNode;
  4983. doc = hc_staff.hc_staff();
  4984. elementList = doc.getElementsByTagName("p");
  4985. employeeNode = elementList.item(1);
  4986. lcNode = employeeNode.lastChild;
  4987. nsNode = lcNode.nextSibling;
  4988. test.equal(nsNode, null, 'nodeGetNextSiblingNullAssert1');
  4989. test.done();
  4990. },
  4991. /**
  4992. *
  4993. Evaluate Node.ownerDocument on the second "p" element.
  4994. * @author Curt Arnold
  4995. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#node-ownerDoc
  4996. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
  4997. */
  4998. hc_nodegetownerdocument: function(test) {
  4999. var doc = hc_staff.hc_staff();
  5000. var elementName = doc.getElementsByTagName("p").item(1).ownerDocument.documentElement.nodeName;
  5001. test.equal(elementName, 'HTML')
  5002. test.done();
  5003. },
  5004. /**
  5005. *
  5006. The "getOwnerDocument()" method returns null if the target
  5007. node itself is a document.
  5008. Invoke the "getOwnerDocument()" method on the master
  5009. document. The Document returned should be null.
  5010. * @author Curt Arnold
  5011. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#node-ownerDoc
  5012. */
  5013. hc_nodegetownerdocumentnull: function(test) {
  5014. var success;
  5015. var doc;
  5016. var ownerDocument;
  5017. doc = hc_staff.hc_staff();
  5018. ownerDocument = doc.ownerDocument;
  5019. test.equal(ownerDocument, null, 'nodeGetOwnerDocumentNullAssert1');
  5020. test.done();
  5021. },
  5022. /**
  5023. *
  5024. The "getPreviousSibling()" method returns the node
  5025. immediately preceding this node.
  5026. Retrieve the second child of the second employee and
  5027. invoke the "getPreviousSibling()" method. It should
  5028. return a node with a NodeName of "#text".
  5029. * @author Curt Arnold
  5030. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8
  5031. */
  5032. hc_nodegetprevioussibling: function(test) {
  5033. var success;
  5034. var doc;
  5035. var elementList;
  5036. var nameNode;
  5037. var psNode;
  5038. var psName;
  5039. doc = hc_staff.hc_staff();
  5040. elementList = doc.getElementsByTagName("strong");
  5041. nameNode = elementList.item(1);
  5042. psNode = nameNode.previousSibling;
  5043. psName = psNode.nodeName;
  5044. test.equal(psName, "#text", 'whitespace');
  5045. test.done();
  5046. },
  5047. /**
  5048. *
  5049. If there is not a node immediately preceding this node the
  5050. "getPreviousSibling()" method returns null.
  5051. Retrieve the first child of the second employee and
  5052. invoke the "getPreviousSibling()" method. It should
  5053. be set to null.
  5054. * @author Curt Arnold
  5055. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8
  5056. */
  5057. hc_nodegetprevioussiblingnull: function(test) {
  5058. var success;
  5059. var doc;
  5060. var elementList;
  5061. var employeeNode;
  5062. var fcNode;
  5063. var psNode;
  5064. doc = hc_staff.hc_staff();
  5065. elementList = doc.getElementsByTagName("p");
  5066. employeeNode = elementList.item(2);
  5067. fcNode = employeeNode.firstChild;
  5068. psNode = fcNode.previousSibling;
  5069. test.equal(psNode, null, 'nodeGetPreviousSiblingNullAssert1');
  5070. test.done();
  5071. },
  5072. /**
  5073. *
  5074. The "hasChildNodes()" method returns true if the node
  5075. has children.
  5076. Retrieve the root node("staff") and invoke the
  5077. "hasChildNodes()" method. It should return the boolean
  5078. value "true".
  5079. * @author Curt Arnold
  5080. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-810594187
  5081. */
  5082. hc_nodehaschildnodes: function(test) {
  5083. var success;
  5084. var doc;
  5085. var elementList;
  5086. var employeeNode;
  5087. var state;
  5088. doc = hc_staff.hc_staff();
  5089. elementList = doc.getElementsByTagName("p");
  5090. employeeNode = elementList.item(1);
  5091. state = employeeNode.hasChildNodes();
  5092. test.ok(state, 'nodeHasChildAssert1');
  5093. test.done();
  5094. },
  5095. /**
  5096. *
  5097. The "hasChildNodes()" method returns false if the node
  5098. does not have any children.
  5099. Retrieve the text of the first "em" element and invoke the "hasChildNodes()" method. It
  5100. should return false.
  5101. * @author Curt Arnold
  5102. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  5103. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-810594187
  5104. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  5105. */
  5106. hc_nodehaschildnodesfalse: function(test) {
  5107. var success;
  5108. var doc;
  5109. var emList;
  5110. var emNode;
  5111. var emText;
  5112. var hasChild;
  5113. doc = hc_staff.hc_staff();
  5114. emList = doc.getElementsByTagName("em");
  5115. emNode = emList.item(0);
  5116. emText = emNode.firstChild;
  5117. hasChild = emText.hasChildNodes();
  5118. test.equal(hasChild, false, 'hasChild');
  5119. test.done();
  5120. },
  5121. /**
  5122. *
  5123. The "insertBefore(newChild,refChild)" method inserts the
  5124. node "newChild" before the node "refChild".
  5125. Insert a newly created Element node before the second
  5126. sup element in the document and check the "newChild"
  5127. and "refChild" after insertion for correct placement.
  5128. * @author Curt Arnold
  5129. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5130. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  5131. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  5132. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=261
  5133. */
  5134. hc_nodeinsertbefore: function(test) {
  5135. var success;
  5136. var doc;
  5137. var elementList;
  5138. var employeeNode;
  5139. var childList;
  5140. var refChild;
  5141. var newChild;
  5142. var child;
  5143. var childName;
  5144. var insertedNode;
  5145. var actual = new Array();
  5146. expected = ["EM", "STRONG", "CODE", "BR", "SUP", "VAR", "ACRONYM"];
  5147. var nodeType;
  5148. doc = hc_staff.hc_staff();
  5149. elementList = doc.getElementsByTagName("sup");
  5150. refChild = elementList.item(2);
  5151. employeeNode = refChild.parentNode;
  5152. childList = employeeNode.childNodes;
  5153. newChild = doc.createElement("br");
  5154. insertedNode = employeeNode.insertBefore(newChild,refChild);
  5155. for(var indexN10091 = 0;indexN10091 < childList.length; indexN10091++) {
  5156. child = childList.item(indexN10091);
  5157. nodeType = child.nodeType;
  5158. if(
  5159. (1 == nodeType)
  5160. ) {
  5161. childName = child.nodeName;
  5162. actual[actual.length] = childName;
  5163. }
  5164. }
  5165. test.deepEqual(actual, expected, 'element nodeNames');
  5166. test.done();
  5167. },
  5168. /**
  5169. *
  5170. If the "newChild" is a DocumentFragment object then all
  5171. its children are inserted in the same order before the
  5172. the "refChild".
  5173. Create a DocumentFragment object and populate it with
  5174. two Element nodes. Retrieve the second employee and
  5175. insert the newly created DocumentFragment before its
  5176. fourth child. The second employee should now have two
  5177. extra children("newChild1" and "newChild2") at
  5178. positions fourth and fifth respectively.
  5179. * @author Curt Arnold
  5180. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5181. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  5182. */
  5183. hc_nodeinsertbeforedocfragment: function(test) {
  5184. var doc = hc_staff.hc_staff();
  5185. var employeeNode = doc.getElementsByTagName("p").item(1);
  5186. refChild = employeeNode.childNodes.item(3);
  5187. var newdocFragment = doc.createDocumentFragment();
  5188. newdocFragment.appendChild(doc.createElement("br"));
  5189. newdocFragment.appendChild(doc.createElement("b"));
  5190. employeeNode.insertBefore(newdocFragment,refChild);
  5191. test.equal(employeeNode.childNodes.item(3).nodeName, 'BR', 'element childName3');
  5192. test.equal(employeeNode.childNodes.item(4).nodeName, 'B', 'element childName4');
  5193. test.done();
  5194. },
  5195. /**
  5196. *
  5197. The "insertBefore(newChild,refChild)" method raises a
  5198. HIERARCHY_REQUEST_ERR DOMException if this node is of
  5199. a type that does not allow children of the type "newChild"
  5200. to be inserted.
  5201. Retrieve the root node and attempt to insert a newly
  5202. created Attr node. An Element node cannot have children
  5203. of the "Attr" type, therefore the desired exception
  5204. should be raised.
  5205. * @author Curt Arnold
  5206. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
  5207. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5208. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-952280727')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='HIERARCHY_REQUEST_ERR'])
  5209. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5210. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  5211. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  5212. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=406
  5213. */
  5214. hc_nodeinsertbeforeinvalidnodetype: function(test) {
  5215. var doc = hc_staff.hc_staff();
  5216. var newChild = doc.createAttribute("title");
  5217. var refChild = doc.getElementsByTagName("p").item(1);
  5218. var rootNode = refChild.parentNode;
  5219. var success = false;
  5220. try {
  5221. rootNode.insertBefore(newChild,refChild);
  5222. }
  5223. catch(ex) {
  5224. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  5225. }
  5226. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  5227. test.done();
  5228. },
  5229. /**
  5230. *
  5231. The "insertBefore(newChild,refChild)" method raises a
  5232. WRONG_DOCUMENT_ERR DOMException if the "newChild" was
  5233. created from a different document than the one that
  5234. created this node.
  5235. Retrieve the second employee and attempt to insert a new
  5236. child that was created from a different document than the
  5237. one that created the second employee. An attempt to
  5238. insert such a child should raise the desired exception.
  5239. * @author Curt Arnold
  5240. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])
  5241. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5242. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-952280727')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='WRONG_DOCUMENT_ERR'])
  5243. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5244. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  5245. */
  5246. hc_nodeinsertbeforenewchilddiffdocument: function(test) {
  5247. var doc1 = hc_staff.hc_staff();
  5248. var doc2 = hc_staff.hc_staff();
  5249. var newChild = doc1.createElement("br");
  5250. var elementNode = doc2.getElementsByTagName("p").item(1);
  5251. var refChild = elementNode.firstChild;
  5252. var success = false;
  5253. try {
  5254. elementNode.insertBefore(newChild,refChild);
  5255. } catch(ex) {
  5256. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  5257. }
  5258. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  5259. test.done();
  5260. },
  5261. /**
  5262. *
  5263. If the "newChild" is already in the tree, the
  5264. "insertBefore(newChild,refChild)" method must first
  5265. remove it before the insertion takes place.
  5266. Insert a node Element ("em") that is already
  5267. present in the tree. The existing node should be
  5268. removed first and the new one inserted. The node is
  5269. inserted at a different position in the tree to assure
  5270. that it was indeed inserted.
  5271. * @author Curt Arnold
  5272. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5273. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  5274. */
  5275. hc_nodeinsertbeforenewchildexists: function(test) {
  5276. var success;
  5277. var doc;
  5278. var elementList;
  5279. var employeeNode;
  5280. var childList;
  5281. var refChild;
  5282. var newChild;
  5283. var child;
  5284. var childName;
  5285. var insertedNode;
  5286. expected = ["STRONG", "CODE", "SUP", "VAR", "EM", "ACRONYM"];
  5287. var result = new Array();
  5288. var nodeType;
  5289. doc = hc_staff.hc_staff();
  5290. elementList = doc.getElementsByTagName("p");
  5291. employeeNode = elementList.item(1);
  5292. childList = employeeNode.getElementsByTagName("*");
  5293. refChild = childList.item(5);
  5294. newChild = childList.item(0);
  5295. insertedNode = employeeNode.insertBefore(newChild,refChild);
  5296. for(var indexN1008C = 0;indexN1008C < childList.length; indexN1008C++) {
  5297. child = childList.item(indexN1008C);
  5298. nodeType = child.nodeType;
  5299. if(
  5300. (1 == nodeType)
  5301. ) {
  5302. childName = child.nodeName;
  5303. result[result.length] = childName;
  5304. }
  5305. }
  5306. test.deepEqual(result, expected, 'element childNames');
  5307. test.done();
  5308. },
  5309. /**
  5310. *
  5311. The "insertBefore(newChild,refChild)" method raises a
  5312. HIERARCHY_REQUEST_ERR DOMException if the node to be
  5313. inserted is one of this nodes ancestors.
  5314. Retrieve the second employee and attempt to insert a
  5315. node that is one of its ancestors(root node). An
  5316. attempt to insert such a node should raise the
  5317. desired exception.
  5318. * @author Curt Arnold
  5319. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
  5320. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5321. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-952280727')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='HIERARCHY_REQUEST_ERR'])
  5322. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5323. */
  5324. hc_nodeinsertbeforenodeancestor: function(test) {
  5325. var doc = hc_staff.hc_staff();
  5326. var newChild = doc.documentElement;
  5327. var employeeNode = doc.getElementsByTagName("p").item(1);
  5328. var refChild = employeeNode.childNodes.item(0);
  5329. var success = false;
  5330. try {
  5331. employeeNode.insertBefore(newChild,refChild);
  5332. } catch(ex) {
  5333. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  5334. }
  5335. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  5336. test.done();
  5337. },
  5338. /**
  5339. *
  5340. The "insertBefore(newChild,refchild)" method returns
  5341. the node being inserted.
  5342. Insert an Element node before the fourth
  5343. child of the second employee and check the node
  5344. returned from the "insertBefore(newChild,refChild)"
  5345. method. The node returned should be "newChild".
  5346. * @author Curt Arnold
  5347. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  5348. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5349. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  5350. */
  5351. hc_nodeinsertbeforenodename: function(test) {
  5352. var doc = hc_staff.hc_staff();
  5353. var employeeNode = doc.getElementsByTagName("p").item(1);
  5354. var refChild = employeeNode.childNodes.item(3);
  5355. var newChild = doc.createElement("br");
  5356. var insertedNode = employeeNode.insertBefore(newChild,refChild);
  5357. test.equal(insertedNode.nodeName, 'BR', 'element nodeName');
  5358. test.done();
  5359. },
  5360. /**
  5361. *
  5362. The "insertBefore(newChild,refChild)" method raises a
  5363. NOT_FOUND_ERR DOMException if the reference child is
  5364. not a child of this node.
  5365. Retrieve the second employee and attempt to insert a
  5366. new node before a reference node that is not a child
  5367. of this node. An attempt to insert before a non child
  5368. node should raise the desired exception.
  5369. * @author Curt Arnold
  5370. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
  5371. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5372. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-952280727')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NOT_FOUND_ERR'])
  5373. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5374. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  5375. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  5376. */
  5377. hc_nodeinsertbeforerefchildnonexistent: function(test) {
  5378. var doc = hc_staff.hc_staff();
  5379. var newChild = doc.createElement("br");
  5380. var refChild = doc.createElement("b");
  5381. var elementNode = doc.getElementsByTagName("p").item(1);
  5382. var success = false;
  5383. try {
  5384. elementNode.insertBefore(newChild,refChild);
  5385. }
  5386. catch(ex) {
  5387. success = (typeof(ex.code) != 'undefined' && ex.code == 8);
  5388. }
  5389. test.ok(success, 'throw_NOT_FOUND_ERR');
  5390. test.done();
  5391. },
  5392. /**
  5393. *
  5394. If the "refChild" is null then the
  5395. "insertBefore(newChild,refChild)" method inserts the
  5396. node "newChild" at the end of the list of children.
  5397. Retrieve the second employee and invoke the
  5398. "insertBefore(newChild,refChild)" method with
  5399. refChild=null. Since "refChild" is null the "newChild"
  5400. should be added to the end of the list. The last item
  5401. in the list is checked after insertion. The last Element
  5402. node of the list should be "newChild".
  5403. * @author Curt Arnold
  5404. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5405. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  5406. */
  5407. hc_nodeinsertbeforerefchildnull: function(test) {
  5408. var refChild = null;
  5409. var doc = hc_staff.hc_staff();
  5410. var employeeNode = doc.getElementsByTagName("p").item(1);
  5411. var newChild = doc.createElement("br");
  5412. employeeNode.insertBefore(newChild,refChild);
  5413. test.equal(employeeNode.lastChild.nodeName, 'BR', 'element nodeName');
  5414. test.done();
  5415. },
  5416. /**
  5417. *
  5418. Create a list of all the children elements of the third
  5419. employee and access its first child by using an index
  5420. of 0. This should result in the whitspace before "em" being
  5421. selected (em when ignoring whitespace).
  5422. Further we evaluate its content(by using
  5423. the "getNodeName()" method) to ensure the proper
  5424. element was accessed.
  5425. * @author Curt Arnold
  5426. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
  5427. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  5428. */
  5429. hc_nodelistindexequalzero: function(test) {
  5430. var doc = hc_staff.hc_staff();
  5431. employeeList = doc.getElementsByTagName("p").item(2).childNodes;
  5432. test.equal(employeeList.item(0).nodeName, "#text", 'childName_w_whitespace');
  5433. test.done();
  5434. },
  5435. /**
  5436. *
  5437. The "getLength()" method returns the number of nodes
  5438. in the list.
  5439. Create a list of all the children elements of the third
  5440. employee and invoke the "getLength()" method.
  5441. It should contain the value 13.
  5442. * @author Curt Arnold
  5443. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337
  5444. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  5445. */
  5446. hc_nodelistindexgetlength: function(test) {
  5447. var success;
  5448. var doc;
  5449. var elementList;
  5450. var employeeNode;
  5451. var employeeList;
  5452. var length;
  5453. doc = hc_staff.hc_staff();
  5454. elementList = doc.getElementsByTagName("p");
  5455. employeeNode = elementList.item(2);
  5456. employeeList = employeeNode.childNodes;
  5457. length = employeeList.length;
  5458. if(
  5459. (6 == length)
  5460. ) {
  5461. test.equal(length, 6, 'length_wo_space');
  5462. }
  5463. else {
  5464. test.equal(length, 13, 'length_w_space');
  5465. }
  5466. test.done();
  5467. },
  5468. /**
  5469. *
  5470. The "getLength()" method returns the number of nodes
  5471. in the list.(Test for EMPTY list)
  5472. Create a list of all the children of the Text node
  5473. inside the first child of the third employee and
  5474. invoke the "getLength()" method. It should contain
  5475. the value 0.
  5476. * @author Curt Arnold
  5477. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337
  5478. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  5479. */
  5480. hc_nodelistindexgetlengthofemptylist: function(test) {
  5481. var success;
  5482. var doc;
  5483. var emList;
  5484. var emNode;
  5485. var textNode;
  5486. var textList;
  5487. var length;
  5488. doc = hc_staff.hc_staff();
  5489. emList = doc.getElementsByTagName("em");
  5490. emNode = emList.item(2);
  5491. textNode = emNode.firstChild;
  5492. textList = textNode.childNodes;
  5493. length = textList.length;
  5494. test.equal(length, 0, 'length');
  5495. test.done();
  5496. },
  5497. /**
  5498. *
  5499. The items in the list are accessible via an integral
  5500. index starting from zero.
  5501. (Index not equal 0)
  5502. Create a list of all the children elements of the third
  5503. employee and access its fourth child by using an index
  5504. of 3 and calling getNodeName() which should return
  5505. "strong" (no whitespace) or "#text" (with whitespace).
  5506. * @author Curt Arnold
  5507. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
  5508. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  5509. */
  5510. hc_nodelistindexnotzero: function(test) {
  5511. var doc = hc_staff.hc_staff();
  5512. child = doc.getElementsByTagName("p").item(2).childNodes.item(3);
  5513. test.equal(child.nodeName, 'STRONG', 'element childName_strong');
  5514. test.done();
  5515. },
  5516. /**
  5517. *
  5518. Create a list of all the children elements of the third
  5519. employee and access its first child by invoking the
  5520. "item(index)" method with an index=0. This should
  5521. result in node with a nodeName of "#text" or "em".
  5522. * @author Curt Arnold
  5523. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
  5524. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  5525. */
  5526. hc_nodelistreturnfirstitem: function(test) {
  5527. var doc = hc_staff.hc_staff();
  5528. var child = doc.getElementsByTagName("p").item(2).childNodes.item(0);
  5529. test.equal(child.nodeName, "#text", 'nodeName_w_space');
  5530. test.done();
  5531. },
  5532. /**
  5533. *
  5534. Create a list of all the children elements of the third
  5535. employee and access its last child by invoking the
  5536. "item(index)" method with an index=length-1. This should
  5537. result in node with nodeName="#text" or acronym.
  5538. * @author Curt Arnold
  5539. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
  5540. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  5541. */
  5542. hc_nodelistreturnlastitem: function(test) {
  5543. var doc = hc_staff.hc_staff();
  5544. var employeeList = doc.getElementsByTagName("p").item(2).childNodes;
  5545. var child = employeeList.item(employeeList.length-1);
  5546. test.equal(child.nodeName, "#text", 'lastNodeName_w_whitespace');
  5547. test.done();
  5548. },
  5549. /**
  5550. *
  5551. The range of valid child node indices is 0 thru length -1
  5552. Create a list of all the children elements of the third
  5553. employee and traverse the list from index=0 thru
  5554. length -1.
  5555. * @author Curt Arnold
  5556. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337
  5557. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
  5558. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  5559. */
  5560. hc_nodelisttraverselist: function(test) {
  5561. var success;
  5562. var doc;
  5563. var elementList;
  5564. var employeeNode;
  5565. var employeeList;
  5566. var child;
  5567. var childName;
  5568. var nodeType;
  5569. var result = new Array();
  5570. expected = ["EM", "STRONG", "CODE", "SUP", "VAR", "ACRONYM"];
  5571. doc = hc_staff.hc_staff();
  5572. elementList = doc.getElementsByTagName("p");
  5573. employeeNode = elementList.item(2);
  5574. employeeList = employeeNode.childNodes;
  5575. for(var indexN10073 = 0;indexN10073 < employeeList.length; indexN10073++) {
  5576. child = employeeList.item(indexN10073);
  5577. nodeType = child.nodeType;
  5578. childName = child.nodeName;
  5579. if(
  5580. (1 == nodeType)
  5581. ) {
  5582. result[result.length] = childName;
  5583. }
  5584. else {
  5585. test.equal(nodeType, 3, 'textNodeType');
  5586. test.equal(childName, "#text", 'textNodeName');
  5587. }
  5588. }
  5589. test.deepEqual(result, expected, 'element nodeNames');
  5590. test.done();
  5591. },
  5592. /**
  5593. *
  5594. The "getParentNode()" method returns the parent
  5595. of this node.
  5596. Retrieve the second employee and invoke the
  5597. "getParentNode()" method on this node. It should
  5598. be set to "body".
  5599. * @author Curt Arnold
  5600. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317
  5601. */
  5602. hc_nodeparentnode: function(test) {
  5603. var doc = hc_staff.hc_staff();
  5604. var parentNode = doc.getElementsByTagName("p").item(1).parentNode;
  5605. test.equal(parentNode.nodeName, 'BODY', 'element parentNodeName');
  5606. test.done();
  5607. },
  5608. /**
  5609. *
  5610. The "getParentNode()" method invoked on a node that has
  5611. just been created and not yet added to the tree is null.
  5612. Create a new "employee" Element node using the
  5613. "createElement(name)" method from the Document interface.
  5614. Since this new node has not yet been added to the tree,
  5615. the "getParentNode()" method will return null.
  5616. * @author Curt Arnold
  5617. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317
  5618. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  5619. */
  5620. hc_nodeparentnodenull: function(test) {
  5621. var success;
  5622. var doc;
  5623. var createdNode;
  5624. var parentNode;
  5625. doc = hc_staff.hc_staff();
  5626. createdNode = doc.createElement("br");
  5627. parentNode = createdNode.parentNode;
  5628. test.equal(parentNode, null, 'parentNode');
  5629. test.done();
  5630. },
  5631. /**
  5632. *
  5633. The "removeChild(oldChild)" method removes the child node
  5634. indicated by "oldChild" from the list of children and
  5635. returns it.
  5636. Remove the first employee by invoking the
  5637. "removeChild(oldChild)" method an checking the
  5638. node returned by the "getParentNode()" method. It
  5639. should be set to null.
  5640. * @author Curt Arnold
  5641. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  5642. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  5643. */
  5644. hc_noderemovechild: function(test) {
  5645. var success;
  5646. var doc;
  5647. var rootNode;
  5648. var childList;
  5649. var childToRemove;
  5650. var removedChild;
  5651. var parentNode;
  5652. doc = hc_staff.hc_staff();
  5653. rootNode = doc.documentElement;
  5654. childList = rootNode.childNodes;
  5655. childToRemove = childList.item(1);
  5656. removedChild = rootNode.removeChild(childToRemove);
  5657. parentNode = removedChild.parentNode;
  5658. test.equal(parentNode, null, 'parentNodeNull');
  5659. test.done();
  5660. },
  5661. /**
  5662. *
  5663. The "removeChild(oldChild)" method returns
  5664. the node being removed.
  5665. Remove the first child of the second employee
  5666. and check the NodeName returned by the
  5667. "removeChild(oldChild)" method. The returned node
  5668. should have a NodeName equal to "#text".
  5669. * @author Curt Arnold
  5670. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  5671. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  5672. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  5673. */
  5674. hc_noderemovechildgetnodename: function(test) {
  5675. var success;
  5676. var doc;
  5677. var elementList;
  5678. var employeeNode;
  5679. var childList;
  5680. var oldChild;
  5681. var removedChild;
  5682. var childName;
  5683. var oldName;
  5684. doc = hc_staff.hc_staff();
  5685. elementList = doc.getElementsByTagName("p");
  5686. employeeNode = elementList.item(1);
  5687. childList = employeeNode.childNodes;
  5688. oldChild = childList.item(0);
  5689. oldName = oldChild.nodeName;
  5690. removedChild = employeeNode.removeChild(oldChild);
  5691. test.notEqual(removedChild, null, 'notnull');
  5692. childName = removedChild.nodeName;
  5693. test.equal(childName, oldName, 'nodeName');
  5694. test.done();
  5695. },
  5696. /**
  5697. *
  5698. The "removeChild(oldChild)" method removes the node
  5699. indicated by "oldChild".
  5700. Retrieve the second p element and remove its first child.
  5701. After the removal, the second p element should have 5 element
  5702. children and the first child should now be the child
  5703. that used to be at the second position in the list.
  5704. * @author Curt Arnold
  5705. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  5706. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  5707. */
  5708. hc_noderemovechildnode: function(test) {
  5709. var doc = hc_staff.hc_staff();
  5710. var employeeNode = doc.getElementsByTagName("p").item(1);
  5711. var childList = employeeNode.childNodes;
  5712. var oldChild = employeeNode.getElementsByTagName("em").item(0);
  5713. var removedChild = employeeNode.removeChild(oldChild);
  5714. test.equal(removedChild.nodeName, 'EM', 'element removedName');
  5715. var actual = [];
  5716. for(var i=0;i<childList.length;i++) {
  5717. if (1 == childList.item(i).nodeType) {
  5718. actual.push(childList.item(i).nodeName);
  5719. } else {
  5720. test.equal(childList.item(i).nodeType, 3, 'textNodeType');
  5721. test.equal(childList.item(i).nodeName, "#text", 'textNodeName');
  5722. }
  5723. }
  5724. test.deepEqual(actual, ['STRONG', 'CODE', 'SUP', 'VAR', 'ACRONYM'], 'element childNames')
  5725. test.done();
  5726. },
  5727. /**
  5728. *
  5729. The "removeChild(oldChild)" method raises a
  5730. NOT_FOUND_ERR DOMException if the old child is
  5731. not a child of this node.
  5732. Retrieve the second employee and attempt to remove a
  5733. node that is not one of its children. An attempt to
  5734. remove such a node should raise the desired exception.
  5735. * @author Curt Arnold
  5736. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
  5737. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  5738. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-1734834066')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NOT_FOUND_ERR'])
  5739. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  5740. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  5741. */
  5742. hc_noderemovechildoldchildnonexistent: function(test) {
  5743. var doc = hc_staff.hc_staff();
  5744. var oldChild = doc.createElement("br");
  5745. var elementNode = doc.getElementsByTagName("p").item(1);
  5746. var success = false;
  5747. try {
  5748. elementNode.removeChild(oldChild);
  5749. }
  5750. catch(ex) {
  5751. success = (typeof(ex.code) != 'undefined' && ex.code == 8);
  5752. }
  5753. test.ok(success, 'throw_NOT_FOUND_ERR');
  5754. test.done();
  5755. },
  5756. /**
  5757. *
  5758. The "replaceChild(newChild,oldChild)" method replaces
  5759. the node "oldChild" with the node "newChild".
  5760. Replace the first element of the second employee with
  5761. a newly created Element node. Check the first position
  5762. after the replacement operation is completed. The new
  5763. Element should be "newChild".
  5764. * @author Curt Arnold
  5765. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  5766. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  5767. */
  5768. hc_nodereplacechild: function(test) {
  5769. var doc = hc_staff.hc_staff();
  5770. var employeeNode = doc.getElementsByTagName("p").item(1);
  5771. var oldChild = employeeNode.childNodes.item(0);
  5772. var newChild = doc.createElement("br");
  5773. employeeNode.replaceChild(newChild,oldChild);
  5774. var child = employeeNode.childNodes.item(0);
  5775. test.equal(child.nodeName, 'BR', 'element nodeName');
  5776. test.done();
  5777. },
  5778. /**
  5779. *
  5780. The "replaceChild(newChild,oldChild)" method raises a
  5781. HIERARCHY_REQUEST_ERR DOMException if this node is of
  5782. a type that does not allow children of the type "newChild"
  5783. to be inserted.
  5784. Retrieve the root node and attempt to replace
  5785. one of its children with a newly created Attr node.
  5786. An Element node cannot have children of the "Attr"
  5787. type, therefore the desired exception should be raised.
  5788. * @author Curt Arnold
  5789. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
  5790. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  5791. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-785887307')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='HIERARCHY_REQUEST_ERR'])
  5792. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  5793. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  5794. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  5795. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=406
  5796. */
  5797. hc_nodereplacechildinvalidnodetype: function(test) {
  5798. var doc = hc_staff.hc_staff();
  5799. var newChild = doc.createAttribute("lang");
  5800. var oldChild = doc.getElementsByTagName("p").item(1);
  5801. var rootNode = oldChild.parentNode;
  5802. var success = false;
  5803. try {
  5804. rootNode.replaceChild(newChild,oldChild);
  5805. } catch(ex) {
  5806. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  5807. }
  5808. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  5809. test.done();
  5810. },
  5811. /**
  5812. *
  5813. The "replaceChild(newChild,oldChild)" method raises a
  5814. WRONG_DOCUMENT_ERR DOMException if the "newChild" was
  5815. created from a different document than the one that
  5816. created this node.
  5817. Retrieve the second employee and attempt to replace one
  5818. of its children with a node created from a different
  5819. document. An attempt to make such a replacement
  5820. should raise the desired exception.
  5821. * @author Curt Arnold
  5822. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
  5823. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  5824. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-785887307')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NOT_FOUND_ERR'])
  5825. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  5826. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  5827. */
  5828. hc_nodereplacechildnewchilddiffdocument: function(test) {
  5829. var doc1 = hc_staff.hc_staff();
  5830. var doc2 = hc_staff.hc_staff();
  5831. var newChild = doc1.createElement("br");
  5832. var elementNode = doc2.getElementsByTagName("p").item(1);
  5833. var oldChild = elementNode.firstChild;
  5834. var success = false;
  5835. try {
  5836. elementNode.replaceChild(newChild,oldChild);
  5837. }
  5838. catch(ex) {
  5839. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  5840. }
  5841. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  5842. test.done();
  5843. },
  5844. /**
  5845. *
  5846. If the "newChild" is already in the tree, it is first
  5847. removed before the new one is added.
  5848. Retrieve the second "p" and replace "acronym" with its "em".
  5849. * @author Curt Arnold
  5850. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  5851. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  5852. */
  5853. hc_nodereplacechildnewchildexists: function(test) {
  5854. var actual = [];
  5855. var expected = ["STRONG", "CODE", "SUP", "VAR", "EM"];
  5856. var doc = hc_staff.hc_staff();
  5857. var employeeNode = doc.getElementsByTagName("p").item(1);
  5858. var childList = employeeNode.getElementsByTagName("*");
  5859. var newChild = childList.item(0);
  5860. var oldChild = childList.item(5);
  5861. var replacedChild = employeeNode.replaceChild(newChild,oldChild);
  5862. test.equal(replacedChild, oldChild, 'return_value_same');
  5863. for(var i=0;i<childList.length;i++) {
  5864. if (1 == childList.item(i).nodeType) {
  5865. actual.push(childList.item(i).nodeName)
  5866. } else {
  5867. test.equal(childList.item(i).nodeType, 3, 'textNodeType');
  5868. test.equal(childList.item(i).nodeName, "#text", 'textNodeName');
  5869. }
  5870. }
  5871. test.deepEqual(actual, expected, 'element childNames');
  5872. test.done();
  5873. },
  5874. /**
  5875. *
  5876. The "replaceChild(newChild,oldChild)" method raises a
  5877. HIERARCHY_REQUEST_ERR DOMException if the node to put
  5878. in is one of this node's ancestors.
  5879. Retrieve the second employee and attempt to replace
  5880. one of its children with an ancestor node(root node).
  5881. An attempt to make such a replacement should raise the
  5882. desired exception.
  5883. * @author Curt Arnold
  5884. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
  5885. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  5886. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-785887307')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='HIERARCHY_REQUEST_ERR'])
  5887. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  5888. */
  5889. hc_nodereplacechildnodeancestor: function(test) {
  5890. var doc = hc_staff.hc_staff();
  5891. var newChild = doc.documentElement;
  5892. var employeeNode = doc.getElementsByTagName("p").item(1);
  5893. var oldChild = employeeNode.childNodes.item(0);
  5894. var success = false;
  5895. try {
  5896. employeeNode.replaceChild(newChild,oldChild);
  5897. }
  5898. catch(ex) {
  5899. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  5900. }
  5901. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  5902. test.done();
  5903. },
  5904. /**
  5905. *
  5906. The "replaceChild(newChild,oldChild)" method returns
  5907. the node being replaced.
  5908. Replace the second Element of the second employee with
  5909. a newly created node Element and check the NodeName
  5910. returned by the "replaceChild(newChild,oldChild)"
  5911. method. The returned node should have a NodeName equal
  5912. to "em".
  5913. * @author Curt Arnold
  5914. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  5915. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  5916. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  5917. */
  5918. hc_nodereplacechildnodename: function(test) {
  5919. var doc = hc_staff.hc_staff();
  5920. var employeeNode = doc.getElementsByTagName("p").item(1);
  5921. var oldChild = employeeNode.getElementsByTagName("em").item(0);
  5922. var newChild = doc.createElement("br");
  5923. var replacedNode = employeeNode.replaceChild(newChild,oldChild);
  5924. test.equal(replacedNode.nodeName, 'EM', 'element replacedNodeName');
  5925. test.done();
  5926. },
  5927. /**
  5928. *
  5929. The "replaceChild(newChild,oldChild)" method raises a
  5930. NOT_FOUND_ERR DOMException if the old child is
  5931. not a child of this node.
  5932. Retrieve the second employee and attempt to replace a
  5933. node that is not one of its children. An attempt to
  5934. replace such a node should raise the desired exception.
  5935. * @author Curt Arnold
  5936. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
  5937. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  5938. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-785887307')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NOT_FOUND_ERR'])
  5939. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  5940. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  5941. */
  5942. hc_nodereplacechildoldchildnonexistent: function(test) {
  5943. var doc = hc_staff.hc_staff();
  5944. var newChild = doc.createElement("br");
  5945. var oldChild = doc.createElement("b");
  5946. var elementNode = doc.getElementsByTagName("p").item(1);
  5947. var success = false;
  5948. try {
  5949. elementNode.replaceChild(newChild,oldChild);
  5950. }
  5951. catch(ex) {
  5952. success = (typeof(ex.code) != 'undefined' && ex.code == 8);
  5953. }
  5954. test.ok(success, 'throw_NOT_FOUND_ERR');
  5955. test.done();
  5956. },
  5957. /**
  5958. *
  5959. The "getAttributes()" method invoked on a Text
  5960. Node returns null.
  5961. Retrieve the Text node from the last child of the
  5962. first employee and invoke the "getAttributes()" method
  5963. on the Text Node. It should return null.
  5964. * @author Curt Arnold
  5965. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  5966. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1312295772
  5967. */
  5968. hc_nodetextnodeattribute: function(test) {
  5969. var success;
  5970. var doc;
  5971. var elementList;
  5972. var testAddr;
  5973. var textNode;
  5974. var attrList;
  5975. doc = hc_staff.hc_staff();
  5976. elementList = doc.getElementsByTagName("acronym");
  5977. testAddr = elementList.item(0);
  5978. textNode = testAddr.firstChild;
  5979. attrList = textNode.attributes;
  5980. test.equal(attrList, null, 'text_attributes_is_null');
  5981. test.done();
  5982. },
  5983. /**
  5984. *
  5985. The string returned by the "getNodeName()" method for a
  5986. Text Node is "#text".
  5987. * @author Curt Arnold
  5988. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  5989. */
  5990. hc_nodetextnodename: function(test) {
  5991. var success;
  5992. var doc;
  5993. var elementList;
  5994. var testAddr;
  5995. var textNode;
  5996. var textName;
  5997. doc = hc_staff.hc_staff();
  5998. elementList = doc.getElementsByTagName("acronym");
  5999. testAddr = elementList.item(0);
  6000. textNode = testAddr.firstChild;
  6001. textName = textNode.nodeName;
  6002. test.equal(textName, "#text", 'textNodeName');
  6003. test.done();
  6004. },
  6005. /**
  6006. *
  6007. The "getNodeType()" method for a Text Node
  6008. returns the constant value 3.
  6009. Retrieve the Text node from the last child of
  6010. the first employee and invoke the "getNodeType()"
  6011. method. The method should return 3.
  6012. * @author Curt Arnold
  6013. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  6014. */
  6015. hc_nodetextnodetype: function(test) {
  6016. var success;
  6017. var doc;
  6018. var elementList;
  6019. var testAddr;
  6020. var textNode;
  6021. var nodeType;
  6022. doc = hc_staff.hc_staff();
  6023. elementList = doc.getElementsByTagName("acronym");
  6024. testAddr = elementList.item(0);
  6025. textNode = testAddr.firstChild;
  6026. nodeType = textNode.nodeType;
  6027. test.equal(nodeType, 3, 'nodeTextNodeTypeAssert1');
  6028. test.done();
  6029. },
  6030. /**
  6031. *
  6032. The string returned by the "getNodeValue()" method for a
  6033. Text Node is the content of the Text node.
  6034. Retrieve the Text node from the last child of the first
  6035. employee and check the string returned by the
  6036. "getNodeValue()" method. It should be equal to
  6037. "1230 North Ave. Dallas, Texas 98551".
  6038. * @author Curt Arnold
  6039. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  6040. */
  6041. hc_nodetextnodevalue: function(test) {
  6042. var success;
  6043. var doc;
  6044. var elementList;
  6045. var testAddr;
  6046. var textNode;
  6047. var textValue;
  6048. doc = hc_staff.hc_staff();
  6049. elementList = doc.getElementsByTagName("acronym");
  6050. testAddr = elementList.item(0);
  6051. textNode = testAddr.firstChild;
  6052. textValue = textNode.nodeValue;
  6053. test.equal(textValue, "1230 North Ave. Dallas, Texas 98551", 'textNodeValue');
  6054. test.done();
  6055. },
  6056. /**
  6057. *
  6058. An element is created, setNodeValue is called with a non-null argument, but getNodeValue
  6059. should still return null.
  6060. * @author Curt Arnold
  6061. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  6062. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
  6063. */
  6064. hc_nodevalue01: function(test) {
  6065. var success;
  6066. var doc;
  6067. var newNode;
  6068. var newValue;
  6069. doc = hc_staff.hc_staff();
  6070. newNode = doc.createElement("acronym");
  6071. newValue = newNode.nodeValue;
  6072. test.equal(newValue, null, 'initiallyNull');
  6073. newNode.nodeValue = "This should have no effect";
  6074. newValue = newNode.nodeValue;
  6075. test.equal(newValue, null, 'nullAfterAttemptedChange');
  6076. test.done();
  6077. },
  6078. /**
  6079. *
  6080. An comment is created, setNodeValue is called with a non-null argument, but getNodeValue
  6081. should still return null.
  6082. * @author Curt Arnold
  6083. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  6084. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
  6085. */
  6086. hc_nodevalue02: function(test) {
  6087. var success;
  6088. var doc;
  6089. var newNode;
  6090. var newValue;
  6091. doc = hc_staff.hc_staff();
  6092. newNode = doc.createComment("This is a new Comment node");
  6093. newValue = newNode.nodeValue;
  6094. test.equal(newValue, "This is a new Comment node", 'initial');
  6095. newNode.nodeValue = "This should have an effect";
  6096. newValue = newNode.nodeValue;
  6097. test.equal(newValue, "This should have an effect", 'afterChange');
  6098. test.done();
  6099. },
  6100. /**
  6101. *
  6102. An entity reference is created, setNodeValue is called with a non-null argument, but getNodeValue
  6103. should still return null.
  6104. * @author Curt Arnold
  6105. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  6106. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-11C98490
  6107. */
  6108. hc_nodevalue03: function(test) {
  6109. doc = hc_staff.hc_staff();
  6110. success = false;
  6111. try {
  6112. doc.createEntityReference("ent1");
  6113. } catch(ex) {
  6114. success = (typeof(ex.code) != 'undefined' && ex.code == 9);
  6115. }
  6116. test.ok(success, 'throw_NOT_SUPPORTED_ERR');
  6117. test.done();
  6118. },
  6119. /**
  6120. *
  6121. An document type accessed, setNodeValue is called with a non-null argument, but getNodeValue
  6122. should still return null.
  6123. * @author Curt Arnold
  6124. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  6125. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31
  6126. */
  6127. hc_nodevalue04: function(test) {
  6128. var doc = hc_staff.hc_staff();
  6129. var newNode = doc.doctype;
  6130. test.notEqual(newNode, null, 'docTypeNotNullOrDocIsHTML');
  6131. test.notEqual(newNode, null, 'docTypeNotNull');
  6132. test.equal(newNode.nodeValue, null, 'initiallyNull');
  6133. newNode.nodeValue = "This should have no effect";
  6134. test.equal(newNode.nodeValue, null, 'nullAfterAttemptedChange');
  6135. test.done();
  6136. },
  6137. /**
  6138. *
  6139. A document fragment is created, setNodeValue is called with a non-null argument, but getNodeValue
  6140. should still return null.
  6141. * @author Curt Arnold
  6142. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  6143. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
  6144. */
  6145. hc_nodevalue05: function(test) {
  6146. var success;
  6147. var doc;
  6148. var newNode;
  6149. var newValue;
  6150. doc = hc_staff.hc_staff();
  6151. newNode = doc.createDocumentFragment();
  6152. newValue = newNode.nodeValue;
  6153. test.equal(newValue, null, 'initiallyNull');
  6154. newNode.nodeValue = "This should have no effect";
  6155. newValue = newNode.nodeValue;
  6156. test.equal(newValue, null, 'nullAfterAttemptedChange');
  6157. test.done();
  6158. },
  6159. /**
  6160. *
  6161. An document is accessed, setNodeValue is called with a non-null argument, but getNodeValue
  6162. should still return null.
  6163. * @author Curt Arnold
  6164. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  6165. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
  6166. */
  6167. hc_nodevalue06: function(test) {
  6168. var success;
  6169. var newNode;
  6170. var newValue;
  6171. newNode = hc_staff.hc_staff();
  6172. newValue = newNode.nodeValue;
  6173. test.equal(newValue, null, 'initiallyNull');
  6174. newNode.nodeValue = "This should have no effect";
  6175. newValue = newNode.nodeValue;
  6176. test.equal(newValue, null, 'nullAfterAttemptedChange');
  6177. test.done();
  6178. },
  6179. /**
  6180. *
  6181. An Entity is accessed, setNodeValue is called with a non-null argument, but getNodeValue
  6182. should still return null.
  6183. * @author Curt Arnold
  6184. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  6185. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-527DCFF2
  6186. */
  6187. hc_nodevalue07: function(test) {
  6188. // NOTE: no tests run here...
  6189. test.done();
  6190. },
  6191. /**
  6192. *
  6193. An notation is accessed, setNodeValue is called with a non-null argument, but getNodeValue
  6194. should still return null.
  6195. * @author Curt Arnold
  6196. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  6197. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5431D1B9
  6198. */
  6199. hc_nodevalue08: function(test) {
  6200. // NOTE: no tests run here...
  6201. test.done();
  6202. },
  6203. /**
  6204. *
  6205. An attempt to add remove an notation should result in a NO_MODIFICATION_ERR.
  6206. * @author Curt Arnold
  6207. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D46829EF
  6208. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193
  6209. */
  6210. hc_notationsremovenameditem1: function(test) {
  6211. // NOTE: no tests run here
  6212. test.done();
  6213. },
  6214. /**
  6215. *
  6216. An attempt to add an element to the named node map returned by notations should
  6217. result in a NO_MODIFICATION_ERR or HIERARCHY_REQUEST_ERR.
  6218. * @author Curt Arnold
  6219. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D46829EF
  6220. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  6221. */
  6222. hc_notationssetnameditem1: function(test) {
  6223. // NOTE: no tests run here
  6224. test.done();
  6225. },
  6226. /**
  6227. *
  6228. The "splitText(offset)" method raises an
  6229. INDEX_SIZE_ERR DOMException if the specified offset is
  6230. negative.
  6231. Retrieve the textual data from the second child of the
  6232. third employee and invoke the "splitText(offset)" method.
  6233. The desired exception should be raised since the offset
  6234. is a negative number.
  6235. * @author Curt Arnold
  6236. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  6237. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  6238. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-38853C1D')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR'])
  6239. */
  6240. hc_textindexsizeerrnegativeoffset: function(test) {
  6241. var doc = hc_staff.hc_staff();
  6242. var textNode = doc.getElementsByTagName("strong").item(2).firstChild;
  6243. var success = false;
  6244. try {
  6245. textNode.splitText(-69);
  6246. } catch(ex) {
  6247. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  6248. }
  6249. test.ok(success, 'throws_INDEX_SIZE_ERR');
  6250. test.done();
  6251. },
  6252. /**
  6253. *
  6254. The "splitText(offset)" method raises an
  6255. INDEX_SIZE_ERR DOMException if the specified offset is
  6256. greater than the number of characters in the Text node.
  6257. Retrieve the textual data from the second child of the
  6258. third employee and invoke the "splitText(offset)" method.
  6259. The desired exception should be raised since the offset
  6260. is a greater than the number of characters in the Text
  6261. node.
  6262. * @author Curt Arnold
  6263. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  6264. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  6265. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-38853C1D')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='INDEX_SIZE_ERR'])
  6266. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  6267. */
  6268. hc_textindexsizeerroffsetoutofbounds: function(test) {
  6269. var doc = hc_staff.hc_staff();
  6270. var textNode = doc.getElementsByTagName("strong").item(2).firstChild;
  6271. var success = false;
  6272. try {
  6273. textNode.splitText(300);
  6274. } catch(ex) {
  6275. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  6276. }
  6277. test.ok(success, 'throw_INDEX_SIZE_ERR');
  6278. test.done();
  6279. },
  6280. /**
  6281. *
  6282. Retrieve the textual data from the last child of the
  6283. second employee. That node is composed of two
  6284. EntityReference nodes and two Text nodes. After
  6285. the content node is parsed, the "acronym" Element
  6286. should contain four children with each one of the
  6287. EntityReferences containing one child.
  6288. * @author Curt Arnold
  6289. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  6290. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-11C98490
  6291. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-745549614
  6292. */
  6293. hc_textparseintolistofelements: function(test) {
  6294. var expectedNormal = ["β", " Dallas, ", "γ", "\n 98554"];
  6295. var expectedExpanded = ["β Dallas, γ\n 98554"];
  6296. var doc = hc_staff.hc_staff();
  6297. var childList = doc.getElementsByTagName("acronym").item(1).childNodes;
  6298. var actual = [];
  6299. for(var i=0;i<childList.length;i++) {
  6300. if (childList.item(i).nodeValue == null) {
  6301. test.notEqual(childList.item(i).firstChild, null, 'grandChildNotNull');
  6302. actual.push(childList.item(i).firstChild.nodeValue);
  6303. } else {
  6304. actual.push(childList.item(i).nodeValue);
  6305. }
  6306. }
  6307. if (1 == childList.length) {
  6308. test.deepEqual(actual, expectedExpanded, 'assertEqCoalescing');
  6309. } else {
  6310. test.deepEqual(actual, expectedNormal, 'assertEqNormal');
  6311. }
  6312. test.done();
  6313. },
  6314. /**
  6315. *
  6316. The "splitText(offset)" method returns the new Text node.
  6317. Retrieve the textual data from the last child of the
  6318. first employee and invoke the "splitText(offset)" method.
  6319. The method should return the new Text node. The offset
  6320. value used for this test is 30. The "getNodeValue()"
  6321. method is called to check that the new node now contains
  6322. the characters at and after position 30.
  6323. (Starting count at 0)
  6324. * @author Curt Arnold
  6325. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  6326. */
  6327. hc_textsplittextfour: function(test) {
  6328. var success;
  6329. var doc;
  6330. var elementList;
  6331. var addressNode;
  6332. var textNode;
  6333. var splitNode;
  6334. var value;
  6335. doc = hc_staff.hc_staff();
  6336. elementList = doc.getElementsByTagName("acronym");
  6337. addressNode = elementList.item(0);
  6338. textNode = addressNode.firstChild;
  6339. splitNode = textNode.splitText(30);
  6340. value = splitNode.nodeValue;
  6341. test.equal(value, "98551", 'textSplitTextFourAssert');
  6342. test.done();
  6343. },
  6344. /**
  6345. *
  6346. The "splitText(offset)" method breaks the Text node into
  6347. two Text nodes at the specified offset keeping each node
  6348. as siblings in the tree.
  6349. Retrieve the textual data from the second child of the
  6350. third employee and invoke the "splitText(offset)" method.
  6351. The method splits the Text node into two new sibling
  6352. Text nodes keeping both of them in the tree. This test
  6353. checks the "nextSibling()" method of the original node
  6354. to ensure that the two nodes are indeed siblings.
  6355. * @author Curt Arnold
  6356. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  6357. */
  6358. hc_textsplittextone: function(test) {
  6359. var success;
  6360. var doc;
  6361. var elementList;
  6362. var nameNode;
  6363. var textNode;
  6364. var splitNode;
  6365. var secondPart;
  6366. var value;
  6367. doc = hc_staff.hc_staff();
  6368. elementList = doc.getElementsByTagName("strong");
  6369. nameNode = elementList.item(2);
  6370. textNode = nameNode.firstChild;
  6371. splitNode = textNode.splitText(7);
  6372. secondPart = textNode.nextSibling;
  6373. value = secondPart.nodeValue;
  6374. test.equal(value, "Jones", 'textSplitTextOneAssert');
  6375. test.done();
  6376. },
  6377. /**
  6378. *
  6379. After the "splitText(offset)" method breaks the Text node
  6380. into two Text nodes, the new Text node contains all the
  6381. content at and after the offset point.
  6382. Retrieve the textual data from the second child of the
  6383. third employee and invoke the "splitText(offset)" method.
  6384. The new Text node should contain all the content
  6385. at and after the offset point. The "getNodeValue()"
  6386. method is called to check that the new node now contains
  6387. the characters at and after position seven.
  6388. (Starting count at 0)
  6389. * @author Curt Arnold
  6390. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  6391. */
  6392. hc_textsplittextthree: function(test) {
  6393. var success;
  6394. var doc;
  6395. var elementList;
  6396. var nameNode;
  6397. var textNode;
  6398. var splitNode;
  6399. var value;
  6400. doc = hc_staff.hc_staff();
  6401. elementList = doc.getElementsByTagName("strong");
  6402. nameNode = elementList.item(2);
  6403. textNode = nameNode.firstChild;
  6404. splitNode = textNode.splitText(6);
  6405. value = splitNode.nodeValue;
  6406. test.equal(value, " Jones", 'textSplitTextThreeAssert');
  6407. test.done();
  6408. },
  6409. /**
  6410. *
  6411. After the "splitText(offset)" method breaks the Text node
  6412. into two Text nodes, the original node contains all the
  6413. content up to the offset point.
  6414. Retrieve the textual data from the second child of the
  6415. third employee and invoke the "splitText(offset)" method.
  6416. The original Text node should contain all the content
  6417. up to the offset point. The "getNodeValue()" method
  6418. is called to check that the original node now contains
  6419. the first five characters.
  6420. * @author Curt Arnold
  6421. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  6422. */
  6423. hc_textsplittexttwo: function(test) {
  6424. var success;
  6425. var doc;
  6426. var elementList;
  6427. var nameNode;
  6428. var textNode;
  6429. var splitNode;
  6430. var value;
  6431. doc = hc_staff.hc_staff();
  6432. elementList = doc.getElementsByTagName("strong");
  6433. nameNode = elementList.item(2);
  6434. textNode = nameNode.firstChild;
  6435. splitNode = textNode.splitText(5);
  6436. value = textNode.nodeValue;
  6437. test.equal(value, "Roger", 'textSplitTextTwoAssert');
  6438. test.done();
  6439. },
  6440. /**
  6441. *
  6442. If there is not any markup inside an Element or Attr node
  6443. content, then the text is contained in a single object
  6444. implementing the Text interface that is the only child
  6445. of the element.
  6446. Retrieve the textual data from the second child of the
  6447. third employee. That Text node contains a block of
  6448. multiple text lines without markup, so they should be
  6449. treated as a single Text node. The "getNodeValue()"
  6450. method should contain the combination of the two lines.
  6451. * @author Curt Arnold
  6452. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1312295772
  6453. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  6454. */
  6455. hc_textwithnomarkup: function(test) {
  6456. var success;
  6457. var doc;
  6458. var elementList;
  6459. var nameNode;
  6460. var nodeV;
  6461. var value;
  6462. doc = hc_staff.hc_staff();
  6463. elementList = doc.getElementsByTagName("strong");
  6464. nameNode = elementList.item(2);
  6465. nodeV = nameNode.firstChild;
  6466. value = nodeV.nodeValue;
  6467. test.equal(value, "Roger\n Jones", 'textWithNoMarkupAssert');
  6468. test.done();
  6469. },
  6470. };