| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778 |
- var hc_staff = require('./html/files/hc_staff.html');
- exports.tests = {
- /**
- *
- The "getDoctype()" method returns null for XML documents
- without a document type declaration.
- Retrieve the XML document without a DTD and invoke the
- "getDoctype()" method. It should return null.
- * @author NIST
- * @author Mary Brady
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31
- */
- documentgetdoctypenodtd: function(test) {
- var doc = require('./html/files/hc_nodtdstaff.html').hc_nodtdstaff();
- test.equal(doc.doctype, null, 'documentGetDocTypeNoDTDAssert');
- test.done();
- },
- /**
- *
- The "createEntityReference(tagName)" method raises an
- INVALID_CHARACTER_ERR DOMException if the specified
- tagName contains an invalid character.
- * @author NIST
- * @author Mary Brady
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-392B75AE
- * @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'])
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- */
- documentinvalidcharacterexceptioncreateentref: function(test) {
- var badEntityRef;
- var doc = hc_staff.hc_staff();
- var success = false;
- try {
- badEntityRef = doc.createEntityReference("foo");
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 9);
- }
- test.ok(success, 'throw_NOT_SUPPORTED_ERR');
- test.done();
- },
- /**
- *
- Creating an entity reference with an empty name should cause an INVALID_CHARACTER_ERR.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-392B75AE
- * @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'])
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525
- */
- documentinvalidcharacterexceptioncreateentref1: function(test) {
- var badEntityRef;
- var doc = hc_staff.hc_staff();
- var success = false;
- try {
- badEntityRef = doc.createEntityReference("foo");
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 9);
- }
- test.ok(success, 'throw_NOT_SUPPORTED_ERR');
- test.done();
- },
- /**
- *
- The "createProcessingInstruction(target,data) method
- raises an INVALID_CHARACTER_ERR DOMException if the
- specified tagName contains an invalid character.
- * @author NIST
- * @author Mary Brady
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-135944439
- * @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'])
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- */
- documentinvalidcharacterexceptioncreatepi: function(test) {
- var success;
- var badPI;
- var doc = hc_staff.hc_staff();
- success = false;
- try {
- badPI = doc.createProcessingInstruction("foo","data");
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 9);
- }
- test.ok(success, 'throw_NOT_SUPPORTED_ERR');
- test.done();
- },
- /**
- *
- Creating a processing instruction with an empty target should cause an INVALID_CHARACTER_ERR.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-135944439
- * @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'])
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525
- */
- documentinvalidcharacterexceptioncreatepi1: function(test) {
- var success;
- var badPI;
- var doc = hc_staff.hc_staff();
- success = false;
- try {
- badPI = doc.createProcessingInstruction("foo","data");
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 9);
- }
- test.ok(success, 'throw_NOT_SUPPORTED_ERR');
- test.done();
- },
- /**
- *
- Appends a text node to an attribute and checks if the value of
- the attribute is changed.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
- */
- hc_attrappendchild1: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var textNode;
- var retval;
- var lastChild;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("title");
- textNode = doc.createTextNode("terday");
- retval = titleAttr.appendChild(textNode);
- value = titleAttr.value;
- test.equal(value, "Yesterday", 'attrValue');
- value = titleAttr.nodeValue;
- test.equal(value, "Yesterday", 'attrNodeValue');
- value = retval.nodeValue;
- test.equal(value, "terday", 'retvalValue');
- lastChild = titleAttr.lastChild;
- value = lastChild.nodeValue;
- test.equal(value, "terday", 'lastChildValue');
- test.done();
- },
- /**
- *
- Attempts to append an element to the child nodes of an attribute.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
- */
- hc_attrappendchild2: function(test) {
- var doc = hc_staff.hc_staff();
- var titleAttr = doc.getElementsByTagName("acronym").item(3).attributes.getNamedItem("title");
- var newChild = doc.createElement("terday");
- var success = false;
- try {
- titleAttr.appendChild(newChild);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 3);
- }
- test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
- test.done();
- },
- /**
- *
- Appends a document fragment to an attribute and checks if the value of
- the attribute is changed.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
- */
- hc_attrappendchild3: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var terNode;
- var dayNode;
- var retval;
- var lastChild;
- var docFrag;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("title");
- terNode = doc.createTextNode("ter");
- dayNode = doc.createTextNode("day");
- docFrag = doc.createDocumentFragment();
- retval = docFrag.appendChild(terNode);
- retval = docFrag.appendChild(dayNode);
- retval = titleAttr.appendChild(docFrag);
- value = titleAttr.value;
- test.equal(value, "Yesterday", 'attrValue');
- value = titleAttr.nodeValue;
- test.equal(value, "Yesterday", 'attrNodeValue');
- value = retval.nodeValue;
- test.equal(value, null, 'retvalValue');
- lastChild = titleAttr.lastChild;
- value = lastChild.nodeValue;
- test.equal(value, "day", 'lastChildValue');
- test.done();
- },
- /**
- *
- Attempt to append a CDATASection to an attribute which should result
- in a HIERARCHY_REQUEST_ERR.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
- */
- hc_attrappendchild4: function(test) {
- var doc = hc_staff.hc_staff();
- var success = false;
- try {
- doc.createCDATASection("terday");
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 9);
- }
- test.ok(success, 'throw_NOT_SUPPORTED_ERR');
- test.done();
- },
- /**
- *
- Attempt to append a node from another document to an attribute which should result
- in a WRONG_DOCUMENT_ERR.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
- */
- hc_attrappendchild5: function(test) {
- var doc = hc_staff.hc_staff();
- var otherDoc = hc_staff.hc_staff();
- var titleAttr = doc.getElementsByTagName("acronym").item(3).attributes.getNamedItem("title");
- var textNode = otherDoc.createTextNode("terday");
- var success = false;
- try {
- titleAttr.appendChild(textNode);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 4);
- }
- test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
- test.done();
- },
- /**
- *
- Creates an new attribute node and appends a text node.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
- */
- hc_attrappendchild6: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var textNode;
- var retval;
- var lastChild;
- doc = hc_staff.hc_staff();
- titleAttr = doc.createAttribute("title");
- textNode = doc.createTextNode("Yesterday");
- retval = titleAttr.appendChild(textNode);
- value = titleAttr.value;
- test.equal(value, "Yesterday", 'attrValue');
- value = titleAttr.nodeValue;
- test.equal(value, "Yesterday", 'attrNodeValue');
- value = retval.nodeValue;
- test.equal(value, "Yesterday", 'retvalValue');
- lastChild = titleAttr.lastChild;
- value = lastChild.nodeValue;
- test.equal(value, "Yesterday", 'lastChildValue');
- test.done();
- },
- /**
- *
- Checks that Node.childNodes for an attribute node contains
- the expected text node.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
- */
- hc_attrchildnodes1: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var textNode;
- var childNodes;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("title");
- childNodes = titleAttr.childNodes;
- test.equal(childNodes.length, 1, 'childNodesSize');
- textNode = childNodes.item(0);
- value = textNode.nodeValue;
- test.equal(value, "Yes", 'child1IsYes');
- textNode = childNodes.item(1);
- test.equal(textNode, null, 'secondItemIsNull');
- test.done();
- },
- /**
- *
- Checks Node.childNodes for an attribute with multiple child nodes.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
- */
- hc_attrchildnodes2: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var textNode;
- var childNodes;
- var retval;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("title");
- childNodes = titleAttr.childNodes;
- textNode = doc.createTextNode("terday");
- retval = titleAttr.appendChild(textNode);
- test.equal(childNodes.length, 2, 'childNodesSize');
- textNode = childNodes.item(0);
- value = textNode.nodeValue;
- test.equal(value, "Yes", 'child1IsYes');
- textNode = childNodes.item(1);
- value = textNode.nodeValue;
- test.equal(value, "terday", 'child2IsTerday');
- textNode = childNodes.item(2);
- test.equal(textNode, null, 'thirdItemIsNull');
- test.done();
- },
- /**
- *
- Appends a text node to an attribute and clones the node.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
- */
- hc_attrclonenode1: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var textNode;
- var retval;
- var lastChild;
- var clonedTitle;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("title");
- textNode = doc.createTextNode("terday");
- retval = titleAttr.appendChild(textNode);
- clonedTitle = titleAttr.cloneNode(false);
- textNode.nodeValue = "text_node_not_cloned";
- value = clonedTitle.value;
- test.equal(value, "Yesterday", 'attrValue');
- value = clonedTitle.nodeValue;
- test.equal(value, "Yesterday", 'attrNodeValue');
- lastChild = clonedTitle.lastChild;
- value = lastChild.nodeValue;
- test.equal(value, "terday", 'lastChildValue');
- test.done();
- },
- /**
- *
- Create a new DocumentFragment and add a newly created Element node(with one attribute).
- Once the element is added, its attribute should be available as an attribute associated
- with an Element within a DocumentFragment.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-35CB04B5
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
- * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
- */
- hc_attrcreatedocumentfragment: function(test) {
- var langAttrCount = 0;
- var doc = hc_staff.hc_staff();
- var docFragment = doc.createDocumentFragment();
- var newOne = doc.createElement("html");
- newOne.setAttribute("lang","EN");
- docFragment.appendChild(newOne);
- var attributes = docFragment.firstChild.attributes;
- for(var i=0;i<attributes.length;i++) {
- attribute = attributes.item(i);
- attrName = attribute.nodeName;
- if(attrName == "lang") {
- langAttrCount += 1;
- }
- }
- test.equal(langAttrCount, 1, 'hasLangAttr');
- test.done();
- },
- /**
- *
- The "setValue()" method for an attribute creates a
- Text node with the unparsed content of the string.
- Retrieve the attribute named "class" from the last
- child of of the fourth employee and assign the "Y&ent1;"
- string to its value attribute. This value is not yet
- parsed and therefore should still be the same upon
- retrieval. This test uses the "getNamedItem(name)" method
- from the NamedNodeMap interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
- * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Apr/0057.html
- */
- hc_attrcreatetextnode: function(test) {
- var success;
- var doc;
- var addressList;
- var testNode;
- var attributes;
- var streetAttr;
- var value;
- doc = hc_staff.hc_staff();
- addressList = doc.getElementsByTagName("acronym");
- testNode = addressList.item(3);
- attributes = testNode.attributes;
- streetAttr = attributes.getNamedItem("class");
- streetAttr.value = "Y&ent1;";
- value = streetAttr.value;
- test.equal(value, "Y&ent1;", 'value');
- value = streetAttr.nodeValue;
- test.equal(value, "Y&ent1;", 'nodeValue');
- test.done();
- },
- /**
- *
- The "setNodeValue()" method for an attribute creates a
- Text node with the unparsed content of the string.
- Retrieve the attribute named "class" from the last
- child of of the fourth employee and assign the "Y&ent1;"
- string to its value attribute. This value is not yet
- parsed and therefore should still be the same upon
- retrieval. This test uses the "getNamedItem(name)" method
- from the NamedNodeMap interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
- * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Apr/0057.html
- */
- hc_attrcreatetextnode2: function(test) {
- var success;
- var doc;
- var addressList;
- var testNode;
- var attributes;
- var streetAttr;
- var value;
- doc = hc_staff.hc_staff();
- addressList = doc.getElementsByTagName("acronym");
- testNode = addressList.item(3);
- attributes = testNode.attributes;
- streetAttr = attributes.getNamedItem("class");
- streetAttr.nodeValue = "Y&ent1;";
- value = streetAttr.value;
- test.equal(value, "Y&ent1;", 'value');
- value = streetAttr.nodeValue;
- test.equal(value, "Y&ent1;", 'nodeValue');
- test.done();
- },
- /**
- *
- If an Attr is explicitly assigned any value, then that value is the attributes effective value.
- Retrieve the attribute named "domestic" from the last child of of the first employee
- and examine its nodeValue attribute. This test uses the "getNamedItem(name)" method
- from the NamedNodeMap interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
- */
- hc_attreffectivevalue: function(test) {
- var success;
- var doc;
- var addressList;
- var testNode;
- var attributes;
- var domesticAttr;
- var value;
- doc = hc_staff.hc_staff();
- addressList = doc.getElementsByTagName("acronym");
- testNode = addressList.item(0);
- attributes = testNode.attributes;
- domesticAttr = attributes.getNamedItem("title");
- value = domesticAttr.nodeValue;
- test.equal(value, "Yes", 'attrEffectiveValueAssert');
- test.done();
- },
- /**
- *
- Checks that Node.firstChild for an attribute node contains
- the expected text node.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-169727388
- */
- hc_attrfirstchild: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var textNode;
- var otherChild;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("title");
- textNode = titleAttr.firstChild;
- test.notEqual(textNode, null, 'textNodeNotNull');
- value = textNode.nodeValue;
- test.equal(value, "Yes", 'child1IsYes');
- otherChild = textNode.nextSibling;
- test.equal(otherChild, null, 'nextSiblingIsNull');
- otherChild = textNode.previousSibling;
- test.equal(otherChild, null, 'previousSiblingIsNull');
- test.done();
- },
- /**
- *
- Checks the value of an attribute that contains entity references.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
- */
- hc_attrgetvalue1: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var textNode;
- var retval;
- var lastChild;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("class");
- value = titleAttr.value;
- test.equal(value, "Yα", 'attrValue1');
- test.done();
- },
- /**
- *
- Checks the value of an attribute that contains entity references.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
- */
- hc_attrgetvalue2: function(test) {
- var doc = hc_staff.hc_staff();
- var success = false;
- try {
- doc.createEntityReference("alpha");
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 9);
- }
- test.ok(success, 'throw_NOT_SUPPORTED_ERR');
- test.done();
- },
- /**
- *
- Checks that Node.hasChildNodes() is true for an attribute with content.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-810594187
- */
- hc_attrhaschildnodes: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var hasChildNodes;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("title");
- hasChildNodes = titleAttr.hasChildNodes();
- test.ok(hasChildNodes, 'hasChildrenIsTrue');
- test.done();
- },
- /**
- *
- Appends a text node to an attribute and checks if the value of
- the attribute is changed.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- */
- hc_attrinsertbefore1: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var textNode;
- var retval;
- var firstChild;
- var lastChild;
- var refChild = null;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("title");
- textNode = doc.createTextNode("terday");
- retval = titleAttr.insertBefore(textNode,refChild);
- value = titleAttr.value;
- test.equal(value, "Yesterday", 'attrValue');
- value = titleAttr.nodeValue;
- test.equal(value, "Yesterday", 'attrNodeValue');
- value = retval.nodeValue;
- test.equal(value, "terday", 'retvalValue');
- firstChild = titleAttr.firstChild;
- value = firstChild.nodeValue;
- test.equal(value, "Yes", 'firstChildValue');
- lastChild = titleAttr.lastChild;
- value = lastChild.nodeValue;
- test.equal(value, "terday", 'lastChildValue');
- test.done();
- },
- /**
- *
- Prepends a text node to an attribute and checks if the value of
- the attribute is changed.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- */
- hc_attrinsertbefore2: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var textNode;
- var retval;
- var lastChild;
- var firstChild;
- var refChild;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("title");
- textNode = doc.createTextNode("terday");
- refChild = titleAttr.firstChild;
- retval = titleAttr.insertBefore(textNode,refChild);
- value = titleAttr.value;
- test.equal(value, "terdayYes", 'attrValue');
- value = titleAttr.nodeValue;
- test.equal(value, "terdayYes", 'attrNodeValue');
- value = retval.nodeValue;
- test.equal(value, "terday", 'retvalValue');
- firstChild = titleAttr.firstChild;
- value = firstChild.nodeValue;
- test.equal(value, "terday", 'firstChildValue');
- lastChild = titleAttr.lastChild;
- value = lastChild.nodeValue;
- test.equal(value, "Yes", 'lastChildValue');
- test.done();
- },
- /**
- *
- Appends a document fragment to an attribute and checks if the value of
- the attribute is changed.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- */
- hc_attrinsertbefore3: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var terNode;
- var dayNode;
- var docFrag;
- var retval;
- var firstChild;
- var lastChild;
- var refChild = null;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("title");
- terNode = doc.createTextNode("ter");
- dayNode = doc.createTextNode("day");
- docFrag = doc.createDocumentFragment();
- retval = docFrag.appendChild(terNode);
- retval = docFrag.appendChild(dayNode);
- retval = titleAttr.insertBefore(docFrag,refChild);
- value = titleAttr.value;
- test.equal(value, "Yesterday", 'attrValue');
- value = titleAttr.nodeValue;
- test.equal(value, "Yesterday", 'attrNodeValue');
- value = retval.nodeValue;
- test.equal(value, null, 'retvalValue');
- firstChild = titleAttr.firstChild;
- value = firstChild.nodeValue;
- test.equal(value, "Yes", 'firstChildValue');
- lastChild = titleAttr.lastChild;
- value = lastChild.nodeValue;
- test.equal(value, "day", 'lastChildValue');
- test.done();
- },
- /**
- *
- Prepends a document fragment to an attribute and checks if the value of
- the attribute is changed.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- */
- hc_attrinsertbefore4: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var terNode;
- var dayNode;
- var docFrag;
- var retval;
- var firstChild;
- var lastChild;
- var refChild;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("title");
- terNode = doc.createTextNode("ter");
- dayNode = doc.createTextNode("day");
- docFrag = doc.createDocumentFragment();
- retval = docFrag.appendChild(terNode);
- retval = docFrag.appendChild(dayNode);
- refChild = titleAttr.firstChild;
- retval = titleAttr.insertBefore(docFrag,refChild);
- value = titleAttr.value;
- test.equal(value, "terdayYes", 'attrValue');
- value = titleAttr.nodeValue;
- test.equal(value, "terdayYes", 'attrNodeValue');
- value = retval.nodeValue;
- test.equal(value, null, 'retvalValue');
- firstChild = titleAttr.firstChild;
- value = firstChild.nodeValue;
- test.equal(value, "ter", 'firstChildValue');
- lastChild = titleAttr.lastChild;
- value = lastChild.nodeValue;
- test.equal(value, "Yes", 'lastChildValue');
- test.done();
- },
- /**
- *
- Attempt to append a CDATASection to an attribute which should result
- in a HIERARCHY_REQUEST_ERR.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- */
- hc_attrinsertbefore5: function(test) {
- var doc = hc_staff.hc_staff();
- var success = false;
- try {
- doc.createCDATASection("terday");
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 9);
- }
- test.ok(success, 'throw_NOT_SUPPORTED_ERR');
- test.done();
- },
- /**
- *
- Attempt to append a text node from another document to an attribute which should result
- in a WRONG_DOCUMENT_ERR.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- */
- hc_attrinsertbefore6: function(test) {
- var doc = hc_staff.hc_staff();
- var otherDoc = hc_staff.hc_staff();
- var titleAttr = doc.getElementsByTagName("acronym").item(3).attributes.getNamedItem("title");
- var textNode = otherDoc.createTextNode("terday");
- var success = false;
- try {
- titleAttr.insertBefore(textNode, null);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 4);
- }
- test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
- test.done();
- },
- /**
- *
- Appends a document fragment containing a CDATASection to an attribute.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- */
- hc_attrinsertbefore7: function(test) {
- var doc = hc_staff.hc_staff();
- var success = false;
- try {
- doc.createCDATASection("day");
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 9);
- }
- test.ok(success, 'throw_NOT_SUPPORTED_ERR');
- test.done();
- },
- /**
- *
- Checks that Node.lastChild for an attribute node contains
- the expected text node.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-61AD09FB
- */
- hc_attrlastchild: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var textNode;
- var otherChild;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("title");
- textNode = titleAttr.firstChild;
- test.notEqual(textNode, null, 'textNodeNotNull');
- value = textNode.nodeValue;
- test.equal(value, "Yes", 'child1IsYes');
- otherChild = textNode.nextSibling;
- test.equal(otherChild, null, 'nextSiblingIsNull');
- otherChild = textNode.previousSibling;
- test.equal(otherChild, null, 'previousSiblingIsNull');
- test.done();
- },
- /**
- *
- Retrieve the attribute named class from the last
- child of of the second "p" element and examine its
- NodeName.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1112119403
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
- * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
- */
- hc_attrname: function(test) {
- var doc = hc_staff.hc_staff();
- var streetAttr = doc.getElementsByTagName("acronym").item(1).attributes.getNamedItem("class");
- test.equal(streetAttr.nodeName, 'class', 'attribute nodeName');
- test.equal(streetAttr.name, 'class', 'attribute name');
- test.done();
- },
- /**
- *
- The "getNextSibling()" method for an Attr node should return null.
- Retrieve the attribute named "domestic" from the last child of of the
- first employee and examine its NextSibling node. This test uses the
- "getNamedItem(name)" method from the NamedNodeMap interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- */
- hc_attrnextsiblingnull: function(test) {
- var success;
- var doc;
- var addressList;
- var testNode;
- var attributes;
- var domesticAttr;
- var s;
- doc = hc_staff.hc_staff();
- addressList = doc.getElementsByTagName("acronym");
- testNode = addressList.item(0);
- attributes = testNode.attributes;
- domesticAttr = attributes.getNamedItem("title");
- s = domesticAttr.nextSibling;
- test.equal(s, null, 'attrNextSiblingNullAssert');
- test.done();
- },
- /**
- *
- Appends a text node to an attribute, normalizes the attribute
- and checks for a single child node.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083
- */
- hc_attrnormalize: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var textNode;
- var retval;
- var firstChild;
- var secondChild;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("title");
- textNode = doc.createTextNode("terday");
- retval = titleAttr.appendChild(textNode);
- textNode = doc.createTextNode("");
- retval = titleAttr.appendChild(textNode);
- testNode.normalize();
- value = titleAttr.nodeValue;
- test.equal(value, "Yesterday", 'attrNodeValue');
- firstChild = titleAttr.firstChild;
- value = firstChild.nodeValue;
- test.equal(value, "Yesterday", 'firstChildValue');
- secondChild = firstChild.nextSibling;
- test.equal(secondChild, null, 'secondChildIsNull');
- test.done();
- },
- /**
- *
- The "getParentNode()" method for an Attr node should return null. Retrieve
- the attribute named "domestic" from the last child of the first employee
- and examine its parentNode attribute. This test also uses the "getNamedItem(name)"
- method from the NamedNodeMap interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- */
- hc_attrparentnodenull: function(test) {
- var success;
- var doc;
- var addressList;
- var testNode;
- var attributes;
- var domesticAttr;
- var s;
- doc = hc_staff.hc_staff();
- addressList = doc.getElementsByTagName("acronym");
- testNode = addressList.item(0);
- attributes = testNode.attributes;
- domesticAttr = attributes.getNamedItem("title");
- s = domesticAttr.parentNode;
- test.equal(s, null, 'attrParentNodeNullAssert');
- test.done();
- },
- /**
- *
- The "getPreviousSibling()" method for an Attr node should return null.
- Retrieve the attribute named "domestic" from the last child of of the
- first employee and examine its PreviousSibling node. This test uses the
- "getNamedItem(name)" method from the NamedNodeMap interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- */
- hc_attrprevioussiblingnull: function(test) {
- var success;
- var doc;
- var addressList;
- var testNode;
- var attributes;
- var domesticAttr;
- var s;
- doc = hc_staff.hc_staff();
- addressList = doc.getElementsByTagName("acronym");
- testNode = addressList.item(0);
- attributes = testNode.attributes;
- domesticAttr = attributes.getNamedItem("title");
- s = domesticAttr.previousSibling;
- test.equal(s, null, 'attrPreviousSiblingNullAssert');
- test.done();
- },
- /**
- *
- Removes the child node of an attribute and checks that the value is empty.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
- */
- hc_attrremovechild1: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var textNode;
- var retval;
- var firstChild;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("title");
- textNode = titleAttr.firstChild;
- test.notEqual(textNode, null, 'attrChildNotNull');
- retval = titleAttr.removeChild(textNode);
- value = titleAttr.value;
- test.equal(value, "", 'attrValue');
- value = titleAttr.nodeValue;
- test.equal(value, "", 'attrNodeValue');
- value = retval.nodeValue;
- test.equal(value, "Yes", 'retvalValue');
- firstChild = titleAttr.firstChild;
- test.equal(firstChild, null, 'firstChildNull');
- test.done();
- },
- /**
- *
- Attempts to remove a freshly created text node which should result in a NOT_FOUND_ERR exception.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
- */
- hc_attrremovechild2: function(test) {
- var doc = hc_staff.hc_staff();
- var titleAttr = doc.getElementsByTagName("acronym").item(3).attributes.getNamedItem("title");
- var textNode = doc.createTextNode("Yesterday");
- var success = false;
- try {
- titleAttr.removeChild(textNode);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 8);
- }
- test.ok(success, 'throw_NOT_FOUND_ERR');
- test.done();
- },
- /**
- *
- Replaces a text node of an attribute and checks if the value of
- the attribute is changed.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
- */
- hc_attrreplacechild1: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var textNode;
- var retval;
- var firstChild;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("title");
- textNode = doc.createTextNode("terday");
- firstChild = titleAttr.firstChild;
- test.notEqual(firstChild, null, 'attrChildNotNull');
- retval = titleAttr.replaceChild(textNode,firstChild);
- value = titleAttr.value;
- test.equal(value, "terday", 'attrValue');
- value = titleAttr.nodeValue;
- test.equal(value, "terday", 'attrNodeValue');
- value = retval.nodeValue;
- test.equal(value, "Yes", 'retvalValue');
- firstChild = titleAttr.firstChild;
- value = firstChild.nodeValue;
- test.equal(value, "terday", 'firstChildValue');
- test.done();
- },
- /**
- *
- Replaces a text node of an attribute with a document fragment and checks if the value of
- the attribute is changed.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
- */
- hc_attrreplacechild2: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var terNode;
- var dayNode;
- var docFrag;
- var retval;
- var firstChild;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("title");
- terNode = doc.createTextNode("ter");
- dayNode = doc.createTextNode("day");
- docFrag = doc.createDocumentFragment();
- retval = docFrag.appendChild(terNode);
- retval = docFrag.appendChild(dayNode);
- firstChild = titleAttr.firstChild;
- test.notEqual(firstChild, null, 'attrChildNotNull');
- retval = titleAttr.replaceChild(docFrag,firstChild);
- value = titleAttr.value;
- test.equal(value, "terday", 'attrValue');
- value = titleAttr.nodeValue;
- test.equal(value, "terday", 'attrNodeValue');
- value = retval.nodeValue;
- test.equal(value, "Yes", 'retvalValue');
- firstChild = titleAttr.firstChild;
- value = firstChild.nodeValue;
- test.equal(value, "ter", 'firstChildValue');
- test.done();
- },
- /**
- *
- Sets Attr.value on an attribute that only has a simple value.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
- */
- hc_attrsetvalue1: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var retval;
- var firstChild;
- var otherChild;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("title");
- firstChild = titleAttr.firstChild;
- test.notEqual(firstChild, null, 'attrChildNotNull');
- titleAttr.value = "Tomorrow";
- firstChild.nodeValue = "impl reused node";
- value = titleAttr.value;
- test.equal(value, "Tomorrow", 'attrValue');
- value = titleAttr.nodeValue;
- test.equal(value, "Tomorrow", 'attrNodeValue');
- firstChild = titleAttr.lastChild;
- value = firstChild.nodeValue;
- test.equal(value, "Tomorrow", 'firstChildValue');
- otherChild = firstChild.nextSibling;
- test.equal(otherChild, null, 'nextSiblingIsNull');
- test.done();
- },
- /**
- *
- Sets Attr.value on an attribute that should contain multiple child nodes.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
- */
- hc_attrsetvalue2: function(test) {
- var success;
- var doc;
- var acronymList;
- var testNode;
- var attributes;
- var titleAttr;
- var value;
- var textNode;
- var retval;
- var firstChild;
- var otherChild;
- doc = hc_staff.hc_staff();
- acronymList = doc.getElementsByTagName("acronym");
- testNode = acronymList.item(3);
- attributes = testNode.attributes;
- titleAttr = attributes.getNamedItem("title");
- textNode = doc.createTextNode("terday");
- retval = titleAttr.appendChild(textNode);
- firstChild = titleAttr.firstChild;
- test.notEqual(firstChild, null, 'attrChildNotNull');
- titleAttr.value = "Tomorrow";
- firstChild.nodeValue = "impl reused node";
- value = titleAttr.value;
- test.equal(value, "Tomorrow", 'attrValue');
- value = titleAttr.nodeValue;
- test.equal(value, "Tomorrow", 'attrNodeValue');
- firstChild = titleAttr.lastChild;
- value = firstChild.nodeValue;
- test.equal(value, "Tomorrow", 'firstChildValue');
- otherChild = firstChild.nextSibling;
- test.equal(otherChild, null, 'nextSiblingIsNull');
- test.done();
- },
- /**
- *
- The "getSpecified()" method for an Attr node should
- be set to true if the attribute was explicitly given
- a value.
- Retrieve the attribute named "domestic" from the last
- child of of the first employee and examine the value
- returned by the "getSpecified()" method. This test uses
- the "getNamedItem(name)" method from the NamedNodeMap
- interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-862529273
- */
- hc_attrspecifiedvalue: function(test) {
- var success;
- var doc;
- var addressList;
- var testNode;
- var attributes;
- var domesticAttr;
- var state;
- doc = hc_staff.hc_staff();
- addressList = doc.getElementsByTagName("acronym");
- testNode = addressList.item(0);
- attributes = testNode.attributes;
- domesticAttr = attributes.getNamedItem("title");
- state = domesticAttr.specified;
- test.ok(state, 'acronymTitleSpecified');
- test.done();
- },
- /**
- *
- The "getSpecified()" method for an Attr node should return true if the
- value of the attribute is changed.
- Retrieve the attribute named "class" from the last
- child of of the THIRD employee and change its
- value to "Yes"(which is the default DTD value). This
- should cause the "getSpecified()" method to be true.
- This test uses the "setAttribute(name,value)" method
- from the Element interface and the "getNamedItem(name)"
- method from the NamedNodeMap interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-862529273
- */
- hc_attrspecifiedvaluechanged: function(test) {
- var success;
- var doc;
- var addressList;
- var testNode;
- var attributes;
- var streetAttr;
- var state;
- doc = hc_staff.hc_staff();
- addressList = doc.getElementsByTagName("acronym");
- testNode = addressList.item(2);
- testNode.setAttribute("class","Yα");
- attributes = testNode.attributes;
- streetAttr = attributes.getNamedItem("class");
- state = streetAttr.specified;
- test.ok(state, 'acronymClassSpecified');
- test.done();
- },
- /**
- *
- The "appendData(arg)" method appends a string to the end
- of the character data of the node.
- Retrieve the character data from the second child
- of the first employee. The appendData(arg) method is
- called with arg=", Esquire". The method should append
- the specified data to the already existing character
- data. The new value return by the "getLength()" method
- should be 24.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F
- */
- hc_characterdataappenddata: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var childValue;
- var childLength;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("strong");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- child.appendData(", Esquire");
- childValue = child.data;
- childLength = childValue.length;
- test.equal(childLength, 24, 'characterdataAppendDataAssert');
- test.done();
- },
- /**
- *
- On successful invocation of the "appendData(arg)"
- method the "getData()" method provides access to the
- concatentation of data and the specified string.
- Retrieve the character data from the second child
- of the first employee. The appendData(arg) method is
- called with arg=", Esquire". The method should append
- the specified data to the already existing character
- data. The new value return by the "getData()" method
- should be "Margaret Martin, Esquire".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F
- */
- hc_characterdataappenddatagetdata: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var childData;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("strong");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- child.appendData(", Esquire");
- childData = child.data;
- test.equal(childData, "Margaret Martin, Esquire", 'characterdataAppendDataGetDataAssert');
- test.done();
- },
- /**
- *
- The "deleteData(offset,count)" method removes a range of
- characters from the node. Delete data at the beginning
- of the character data.
- Retrieve the character data from the last child of the
- first employee. The "deleteData(offset,count)"
- method is then called with offset=0 and count=16.
- The method should delete the characters from position
- 0 thru position 16. The new value of the character data
- should be "Dallas, Texas 98551".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
- */
- hc_characterdatadeletedatabegining: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var childData;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- child.deleteData(0,16);
- childData = child.data;
- test.equal(childData, "Dallas, Texas 98551", 'data');
- test.done();
- },
- /**
- *
- The "deleteData(offset,count)" method removes a range of
- characters from the node. Delete data at the end
- of the character data.
- Retrieve the character data from the last child of the
- first employee. The "deleteData(offset,count)"
- method is then called with offset=30 and count=5.
- The method should delete the characters from position
- 30 thru position 35. The new value of the character data
- should be "1230 North Ave. Dallas, Texas".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
- */
- hc_characterdatadeletedataend: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var childData;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- child.deleteData(30,5);
- childData = child.data;
- test.equal(childData, "1230 North Ave. Dallas, Texas ", 'characterdataDeleteDataEndAssert');
- test.done();
- },
- /**
- *
- If the sum of the offset and count used in the
- "deleteData(offset,count) method is greater than the
- length of the character data then all the characters
- from the offset to the end of the data are deleted.
- Retrieve the character data from the last child of the
- first employee. The "deleteData(offset,count)"
- method is then called with offset=4 and count=50.
- The method should delete the characters from position 4
- to the end of the data since the offset+count(50+4)
- is greater than the length of the character data(35).
- The new value of the character data should be "1230".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
- */
- hc_characterdatadeletedataexceedslength: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var childData;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- child.deleteData(4,50);
- childData = child.data;
- test.equal(childData, "1230", 'characterdataDeleteDataExceedsLengthAssert');
- test.done();
- },
- /**
- *
- On successful invocation of the "deleteData(offset,count)"
- method, the "getData()" and "getLength()" methods reflect
- the changes.
- Retrieve the character data from the last child of the
- first employee. The "deleteData(offset,count)"
- method is then called with offset=30 and count=5.
- The method should delete the characters from position
- 30 thru position 35. The new value of the character data
- should be "1230 North Ave. Dallas, Texas" which is
- returned by the "getData()" method and "getLength()"
- method should return 30".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7D61178C
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
- */
- hc_characterdatadeletedatagetlengthanddata: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var childData;
- var childLength;
- var result = new Array();
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- child.deleteData(30,5);
- childData = child.data;
- test.equal(childData, "1230 North Ave. Dallas, Texas ", 'data');
- childLength = child.length;
- test.equal(childLength, 30, 'length');
- test.done();
- },
- /**
- *
- The "deleteData(offset,count)" method removes a range of
- characters from the node. Delete data in the middle
- of the character data.
- Retrieve the character data from the last child of the
- first employee. The "deleteData(offset,count)"
- method is then called with offset=16 and count=8.
- The method should delete the characters from position
- 16 thru position 24. The new value of the character data
- should be "1230 North Ave. Texas 98551".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
- */
- hc_characterdatadeletedatamiddle: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var childData;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- child.deleteData(16,8);
- childData = child.data;
- test.equal(childData, "1230 North Ave. Texas 98551", 'characterdataDeleteDataMiddleAssert');
- test.done();
- },
- /**
- *
- The "getData()" method retrieves the character data
- currently stored in the node.
- Retrieve the character data from the second child
- of the first employee and invoke the "getData()"
- method. The method returns the character data
- string.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
- */
- hc_characterdatagetdata: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var childData;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("strong");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- childData = child.data;
- test.equal(childData, "Margaret Martin", 'characterdataGetDataAssert');
- test.done();
- },
- /**
- *
- The "getLength()" method returns the number of characters
- stored in this nodes data.
- Retrieve the character data from the second
- child of the first employee and examine the
- value returned by the getLength() method.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7D61178C
- */
- hc_characterdatagetlength: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var childValue;
- var childLength;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("strong");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- childValue = child.data;
- childLength = childValue.length;
- test.equal(childLength, 15, 'characterdataGetLengthAssert');
- test.done();
- },
- /**
- *
- The "deleteData(offset,count)" method raises an
- INDEX_SIZE_ERR DOMException if the specified count
- is negative.
- Retrieve the character data of the last child of the
- first employee and invoke its "deleteData(offset,count)"
- method with offset=10 and count=-3. It should raise the
- desired exception since the count is negative.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
- * @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'])
- */
- hc_characterdataindexsizeerrdeletedatacountnegative: function(test) {
- var doc = hc_staff.hc_staff();
- var child = doc.getElementsByTagName("acronym").item(0).firstChild;
- var success = false;
- try {
- child.substringData(10,-3);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 1);
- }
- test.ok(success, 'throws_INDEX_SIZE_ERR');
- test.done();
- },
- /**
- *
- The "deleteData(offset,count)" method raises an
- INDEX_SIZE_ERR DOMException if the specified offset
- is greater that the number of characters in the string.
- Retrieve the character data of the last child of the
- first employee and invoke its "deleteData(offset,count)"
- method with offset=40 and count=3. It should raise the
- desired exception since the offset is greater than the
- number of characters in the string.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- */
- hc_characterdataindexsizeerrdeletedataoffsetgreater: function(test) {
- var doc = hc_staff.hc_staff();
- var child = doc.getElementsByTagName("acronym").item(0).firstChild;
- var success = false;
- try {
- child.deleteData(40,3);
- }
- catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 1);
- }
- test.ok(success, 'throw_INDEX_SIZE_ERR');
- test.done();
- },
- /**
- *
- The "deleteData(offset,count)" method raises an
- INDEX_SIZE_ERR DOMException if the specified offset
- is negative.
- Retrieve the character data of the last child of the
- first employee and invoke its "deleteData(offset,count)"
- method with offset=-5 and count=3. It should raise the
- desired exception since the offset is negative.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
- */
- hc_characterdataindexsizeerrdeletedataoffsetnegative: function(test) {
- var doc = hc_staff.hc_staff();
- var child = doc.getElementsByTagName("acronym").item(0).firstChild;
- var success = false;
- try {
- child.deleteData(-5,3);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 1);
- }
- test.ok(success, 'throws_INDEX_SIZE_ERR');
- test.done();
- },
- /**
- *
- The "insertData(offset,arg)" method raises an
- INDEX_SIZE_ERR DOMException if the specified offset
- is greater than the number of characters in the string.
- Retrieve the character data of the last child of the
- first employee and invoke its insertData"(offset,arg)"
- method with offset=40 and arg="ABC". It should raise
- the desired exception since the offset is greater than
- the number of characters in the string.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
- * @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'])
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- */
- hc_characterdataindexsizeerrinsertdataoffsetgreater: function(test) {
- var doc = hc_staff.hc_staff();
- var child = doc.getElementsByTagName("acronym").item(0).firstChild;
- var success = false;
- try {
- child.deleteData(40,3);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 1);
- }
- test.ok(success, 'throw_INDEX_SIZE_ERR');
- test.done();
- },
- /**
- *
- The "insertData(offset,arg)" method raises an
- INDEX_SIZE_ERR DOMException if the specified offset
- is negative.
- Retrieve the character data of the last child of the
- first employee and invoke its insertData"(offset,arg)"
- method with offset=-5 and arg="ABC". It should raise
- the desired exception since the offset is negative.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
- * @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'])
- */
- hc_characterdataindexsizeerrinsertdataoffsetnegative: function(test) {
- var doc = hc_staff.hc_staff();
- var child = doc.getElementsByTagName("acronym").item(0).firstChild;
- var success = false;
- try {
- child.replaceData(-5,3,"ABC");
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 1);
- }
- test.ok(success, 'throws_INDEX_SIZE_ERR');
- test.done();
- },
- /**
- *
- The "replaceData(offset,count,arg)" method raises an
- INDEX_SIZE_ERR DOMException if the specified count
- is negative.
- Retrieve the character data of the last child of the
- first employee and invoke its
- "replaceData(offset,count,arg) method with offset=10
- and count=-3 and arg="ABC". It should raise the
- desired exception since the count is negative.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
- * @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'])
- */
- hc_characterdataindexsizeerrreplacedatacountnegative: function(test) {
- var doc = hc_staff.hc_staff();
- var child = doc.getElementsByTagName("acronym").item(0).firstChild;
- var success = false;
- try {
- child.substringData(10,-3);
- }
- catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 1);
- }
- test.ok(success, 'throws_INDEX_SIZE_ERR');
- test.done();
- },
- /**
- *
- The "replaceData(offset,count,arg)" method raises an
- INDEX_SIZE_ERR DOMException if the specified offset
- is greater than the length of the string.
- Retrieve the character data of the last child of the
- first employee and invoke its
- "replaceData(offset,count,arg) method with offset=40
- and count=3 and arg="ABC". It should raise the
- desired exception since the offset is greater than the
- length of the string.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
- * @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'])
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=242
- */
- hc_characterdataindexsizeerrreplacedataoffsetgreater: function(test) {
- var doc = hc_staff.hc_staff();
- var child = doc.getElementsByTagName("acronym").item(0).firstChild;
- success = false;
- try {
- child.deleteData(40,3);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 1);
- }
- test.ok(success, 'throw_INDEX_SIZE_ERR');
- test.done();
- },
- /**
- *
- The "replaceData(offset,count,arg)" method raises an
- INDEX_SIZE_ERR DOMException if the specified offset
- is negative.
- Retrieve the character data of the last child of the
- first employee and invoke its
- "replaceData(offset,count,arg) method with offset=-5
- and count=3 and arg="ABC". It should raise the
- desired exception since the offset is negative.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
- */
- hc_characterdataindexsizeerrreplacedataoffsetnegative: function(test) {
- var doc = hc_staff.hc_staff();
- var child = doc.getElementsByTagName("acronym").item(0).firstChild;
- success = false;
- try {
- child.replaceData(-5,3,"ABC");
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 1);
- }
- test.ok(success, 'throws_INDEX_SIZE_ERR');
- test.done();
- },
- /**
- *
- The "substringData(offset,count)" method raises an
- INDEX_SIZE_ERR DOMException if the specified count
- is negative.
- Retrieve the character data of the last child of the
- first employee and invoke its "substringData(offset,count)
- method with offset=10 and count=-3. It should raise the
- desired exception since the count is negative.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
- * @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'])
- */
- hc_characterdataindexsizeerrsubstringcountnegative: function(test) {
- var doc = hc_staff.hc_staff();
- var child = doc.getElementsByTagName("acronym").item(0).firstChild;
- var success = false;
- try {
- child.substringData(10,-3);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 1);
- }
- test.ok(success, 'throws_INDEX_SIZE_ERR');
- test.done();
- },
- /**
- *
- The "substringData(offset,count)" method raises an
- INDEX_SIZE_ERR DOMException if the specified offset
- is negative.
- Retrieve the character data of the last child of the
- first employee and invoke its "substringData(offset,count)
- method with offset=-5 and count=3. It should raise the
- desired exception since the offset is negative.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
- * @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'])
- */
- hc_characterdataindexsizeerrsubstringnegativeoffset: function(test) {
- var doc = hc_staff.hc_staff();
- var child = doc.getElementsByTagName("acronym").item(0).firstChild;
- success = false;
- try {
- child.substringData(-5,3);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 1);
- }
- test.ok(success, 'throws_INDEX_SIZE_ERR');
- test.done();
- },
- /**
- *
- The "substringData(offset,count)" method raises an
- INDEX_SIZE_ERR DOMException if the specified offset
- is greater than the number of characters in the string.
- Retrieve the character data of the last child of the
- first employee and invoke its "substringData(offset,count)
- method with offset=40 and count=3. It should raise the
- desired exception since the offsets value is greater
- than the length.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
- * @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'])
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- */
- hc_characterdataindexsizeerrsubstringoffsetgreater: function(test) {
- var doc = hc_staff.hc_staff();
- var child = doc.getElementsByTagName("acronym").item(0).firstChild;
- success = false;
- try {
- child.substringData(40,3);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 1);
- }
- test.ok(success, 'throw_INDEX_SIZE_ERR');
- test.done();
- },
- /**
- *
- The "insertData(offset,arg)" method will insert a string
- at the specified character offset. Insert the data at
- the beginning of the character data.
- Retrieve the character data from the second child of
- the first employee. The "insertData(offset,arg)"
- method is then called with offset=0 and arg="Mss.".
- The method should insert the string "Mss." at position 0.
- The new value of the character data should be
- "Mss. Margaret Martin".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F
- */
- hc_characterdatainsertdatabeginning: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var childData;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("strong");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- child.insertData(0,"Mss. ");
- childData = child.data;
- test.equal(childData, "Mss. Margaret Martin", 'characterdataInsertDataBeginningAssert');
- test.done();
- },
- /**
- *
- The "insertData(offset,arg)" method will insert a string
- at the specified character offset. Insert the data at
- the end of the character data.
- Retrieve the character data from the second child of
- the first employee. The "insertData(offset,arg)"
- method is then called with offset=15 and arg=", Esquire".
- The method should insert the string ", Esquire" at
- position 15. The new value of the character data should
- be "Margaret Martin, Esquire".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F
- */
- hc_characterdatainsertdataend: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var childData;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("strong");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- child.insertData(15,", Esquire");
- childData = child.data;
- test.equal(childData, "Margaret Martin, Esquire", 'characterdataInsertDataEndAssert');
- test.done();
- },
- /**
- *
- The "insertData(offset,arg)" method will insert a string
- at the specified character offset. Insert the data in
- the middle of the character data.
- Retrieve the character data from the second child of
- the first employee. The "insertData(offset,arg)"
- method is then called with offset=9 and arg="Ann".
- The method should insert the string "Ann" at position 9.
- The new value of the character data should be
- "Margaret Ann Martin".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F
- */
- hc_characterdatainsertdatamiddle: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var childData;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("strong");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- child.insertData(9,"Ann ");
- childData = child.data;
- test.equal(childData, "Margaret Ann Martin", 'characterdataInsertDataMiddleAssert');
- test.done();
- },
- /**
- *
- The "replaceData(offset,count,arg)" method replaces the
- characters starting at the specified offset with the
- specified string. Test for replacement in the
- middle of the data.
- Retrieve the character data from the last child of the
- first employee. The "replaceData(offset,count,arg)"
- method is then called with offset=5 and count=5 and
- arg="South". The method should replace characters five
- thru 9 of the character data with "South".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
- */
- hc_characterdatareplacedatabegining: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var childData;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- child.replaceData(0,4,"2500");
- childData = child.data;
- test.equal(childData, "2500 North Ave. Dallas, Texas 98551", 'characterdataReplaceDataBeginingAssert');
- test.done();
- },
- /**
- *
- The "replaceData(offset,count,arg)" method replaces the
- characters starting at the specified offset with the
- specified string. Test for replacement at the
- end of the data.
- Retrieve the character data from the last child of the
- first employee. The "replaceData(offset,count,arg)"
- method is then called with offset=30 and count=5 and
- arg="98665". The method should replace characters 30
- thru 34 of the character data with "98665".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
- */
- hc_characterdatareplacedataend: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var childData;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- child.replaceData(30,5,"98665");
- childData = child.data;
- test.equal(childData, "1230 North Ave. Dallas, Texas 98665", 'characterdataReplaceDataEndAssert');
- test.done();
- },
- /**
- *
- The "replaceData(offset,count,arg)" method replaces the
- characters starting at the specified offset with the
- specified string. Test the situation where the length
- of the arg string is greater than the specified offset.
- Retrieve the character data from the last child of the
- first employee. The "replaceData(offset,count,arg)"
- method is then called with offset=0 and count=4 and
- arg="260030". The method should replace characters one
- thru four with "260030". Note that the length of the
- specified string is greater that the specified offset.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
- */
- hc_characterdatareplacedataexceedslengthofarg: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var childData;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- child.replaceData(0,4,"260030");
- childData = child.data;
- test.equal(childData, "260030 North Ave. Dallas, Texas 98551", 'characterdataReplaceDataExceedsLengthOfArgAssert');
- test.done();
- },
- /**
- *
- If the sum of the offset and count exceeds the length then
- all the characters to the end of the data are replaced.
- Retrieve the character data from the last child of the
- first employee. The "replaceData(offset,count,arg)"
- method is then called with offset=0 and count=50 and
- arg="2600". The method should replace all the characters
- with "2600". This is because the sum of the offset and
- count exceeds the length of the character data.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
- */
- hc_characterdatareplacedataexceedslengthofdata: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var childData;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- child.replaceData(0,50,"2600");
- childData = child.data;
- test.equal(childData, "2600", 'characterdataReplaceDataExceedsLengthOfDataAssert');
- test.done();
- },
- /**
- *
- The "replaceData(offset,count,arg)" method replaces the
- characters starting at the specified offset with the
- specified string. Test for replacement in the
- middle of the data.
- Retrieve the character data from the last child of the
- first employee. The "replaceData(offset,count,arg)"
- method is then called with offset=5 and count=5 and
- arg="South". The method should replace characters five
- thru 9 of the character data with "South".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
- */
- hc_characterdatareplacedatamiddle: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var childData;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- child.replaceData(5,5,"South");
- childData = child.data;
- test.equal(childData, "1230 South Ave. Dallas, Texas 98551", 'characterdataReplaceDataMiddleAssert');
- test.done();
- },
- /**
- *
- The "setNodeValue()" method changes the character data
- currently stored in the node.
- Retrieve the character data from the second child
- of the first employee and invoke the "setNodeValue()"
- method, call "getData()" and compare.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
- */
- hc_characterdatasetnodevalue: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var childData;
- var childValue;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("strong");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- child.nodeValue = "Marilyn Martin";
- childData = child.data;
- test.equal(childData, "Marilyn Martin", 'data');
- childValue = child.nodeValue;
- test.equal(childValue, "Marilyn Martin", 'value');
- test.done();
- },
- /**
- *
- If the sum of the "offset" and "count" exceeds the
- "length" then the "substringData(offset,count)" method
- returns all the characters to the end of the data.
- Retrieve the character data from the second child
- of the first employee and access part of the data
- by using the substringData(offset,count) method
- with offset=9 and count=10. The method should return
- the substring "Martin" since offset+count > length
- (19 > 15).
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
- */
- hc_characterdatasubstringexceedsvalue: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var substring;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("strong");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- substring = child.substringData(9,10);
- test.equal(substring, "Martin", 'characterdataSubStringExceedsValueAssert');
- test.done();
- },
- /**
- *
- The "substringData(offset,count)" method returns the
- specified string.
- Retrieve the character data from the second child
- of the first employee and access part of the data
- by using the substringData(offset,count) method. The
- method should return the specified substring starting
- at position "offset" and extract "count" characters.
- The method should return the string "Margaret".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
- */
- hc_characterdatasubstringvalue: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var child;
- var substring;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("strong");
- nameNode = elementList.item(0);
- child = nameNode.firstChild;
- substring = child.substringData(0,8);
- test.equal(substring, "Margaret", 'characterdataSubStringValueAssert');
- test.done();
- },
- /**
- *
- A comment is all the characters between the starting
- '<!--' and ending '-->'
- Retrieve the nodes of the DOM document. Search for a
- comment node and the content is its value.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1334481328
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=509
- */
- hc_commentgetcomment: function(test) {
- var success;
- var doc;
- var elementList;
- var child;
- var childName;
- var childValue;
- var commentCount = 0;
- var childType;
- var attributes;
- doc = hc_staff.hc_staff();
- elementList = doc.childNodes;
- for(var indexN1005E = 0;indexN1005E < elementList.length; indexN1005E++) {
- child = elementList.item(indexN1005E);
- childType = child.nodeType;
- if(
- (8 == childType)
- ) {
- childName = child.nodeName;
- test.equal(childName, "#comment", 'nodeName');
- childValue = child.nodeValue;
- test.equal(childValue, " This is comment number 1.", 'nodeValue');
- attributes = child.attributes;
- test.equal(attributes, null, 'attributes');
- commentCount += 1;
- }
- }
- test.ok(commentCount < 2, 'atMostOneComment');
- test.done();
- },
- /**
- *
- Retrieve the entire DOM document and invoke its
- "createAttribute(name)" method. It should create a
- new Attribute node with the given name. The name, value
- and type of the newly created object are retrieved and
- output.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
- * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
- */
- hc_documentcreateattribute: function(test) {
- var doc = hc_staff.hc_staff();
- var newAttrNode = doc.createAttribute("title");
- test.equal(newAttrNode.nodeValue, "", 'value');
- test.equal(newAttrNode.nodeName, 'title', 'attribute name');
- test.equal(newAttrNode.nodeType, 2, 'type');
- test.done();
- },
- /**
- *
- The "createComment(data)" method creates a new Comment
- node given the specified string.
- Retrieve the entire DOM document and invoke its
- "createComment(data)" method. It should create a new
- Comment node whose "data" is the specified string.
- The content, name and type are retrieved and output.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1334481328
- */
- hc_documentcreatecomment: function(test) {
- var success;
- var doc;
- var newCommentNode;
- var newCommentValue;
- var newCommentName;
- var newCommentType;
- doc = hc_staff.hc_staff();
- newCommentNode = doc.createComment("This is a new Comment node");
- newCommentValue = newCommentNode.nodeValue;
- test.equal(newCommentValue, "This is a new Comment node", 'value');
- newCommentName = newCommentNode.nodeName;
- test.equal(newCommentName, "#comment", 'strong');
- newCommentType = newCommentNode.nodeType;
- test.equal(newCommentType, 8, 'type');
- test.done();
- },
- /**
- *
- The "createDocumentFragment()" method creates an empty
- DocumentFragment object.
- Retrieve the entire DOM document and invoke its
- "createDocumentFragment()" method. The content, name,
- type and value of the newly created object are output.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-35CB04B5
- */
- hc_documentcreatedocumentfragment: function(test) {
- var doc = hc_staff.hc_staff();
- var newDocFragment = doc.createDocumentFragment();
- test.equal(newDocFragment.childNodes.length, 0, 'length');
- test.equal(newDocFragment.nodeName, "#document-fragment", 'strong');
- test.equal(newDocFragment.nodeType, 11, 'type');
- test.equal(newDocFragment.nodeValue, null, 'value');
- test.done();
- },
- /**
- *
- The "createElement(tagName)" method creates an Element
- of the type specified.
- Retrieve the entire DOM document and invoke its
- "createElement(tagName)" method with tagName="acronym".
- The method should create an instance of an Element node
- whose tagName is "acronym". The NodeName, NodeType
- and NodeValue are returned.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
- */
- hc_documentcreateelement: function(test) {
- var doc = hc_staff.hc_staff();
- var newElement = doc.createElement("acronym");
- test.equal(newElement.nodeName, 'ACRONYM', 'element strong');
- test.equal(newElement.nodeType, 1, 'type');
- test.equal(newElement.nodeValue, null, 'valueInitiallyNull');
- test.done();
- },
- /**
- *
- The tagName parameter in the "createElement(tagName)"
- method is case-sensitive for XML documents.
- Retrieve the entire DOM document and invoke its
- "createElement(tagName)" method twice. Once for tagName
- equal to "acronym" and once for tagName equal to "ACRONYM"
- Each call should create a distinct Element node. The
- newly created Elements are then assigned attributes
- that are retrieved.
- Modified on 27 June 2003 to avoid setting an invalid style
- values and checked the node names to see if they matched expectations.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
- */
- hc_documentcreateelementcasesensitive: function(test) {
- var doc = hc_staff.hc_staff();
- var newElement1 = doc.createElement("ACRONYM");
- var newElement2 = doc.createElement("acronym");
- newElement1.setAttribute("lang","EN");
- newElement2.setAttribute("title","Dallas");
- test.equal(newElement1.getAttribute("lang"), "EN", 'attrib1');
- test.equal(newElement2.getAttribute("title"), "Dallas", 'attrib2');
- test.equal(newElement1.nodeName, 'ACRONYM', 'element nodeName1');
- test.equal(newElement2.nodeName, 'ACRONYM', 'element nodeName2');
- test.done();
- },
- /**
- *
- The "createTextNode(data)" method creates a Text node
- given the specfied string.
- Retrieve the entire DOM document and invoke its
- "createTextNode(data)" method. It should create a
- new Text node whose "data" is the specified string.
- The NodeName and NodeType are also checked.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1975348127
- */
- hc_documentcreatetextnode: function(test) {
- var success;
- var doc;
- var newTextNode;
- var newTextName;
- var newTextValue;
- var newTextType;
- doc = hc_staff.hc_staff();
- newTextNode = doc.createTextNode("This is a new Text node");
- newTextValue = newTextNode.nodeValue;
- test.equal(newTextValue, "This is a new Text node", 'value');
- newTextName = newTextNode.nodeName;
- test.equal(newTextName, "#text", 'strong');
- newTextType = newTextNode.nodeType;
- test.equal(newTextType, 3, 'type');
- test.done();
- },
- /**
- *
- Access Document.doctype for hc_staff, if not text/html should return DocumentType node.
- HTML implementations may return null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31
- */
- hc_documentgetdoctype: function(test) {
- var doc = hc_staff.hc_staff();
- var docType = doc.doctype;
- test.equal(docType.name, "html", 'nodeName');
- test.equal(docType.nodeValue, null, 'nodeValue');
- test.equal(docType.attributes, null, 'attributes');
- test.done();
- },
- /**
- *
- The "getElementsByTagName(tagName)" method returns a
- NodeList of all the Elements with a given tagName.
- Retrieve the entire DOM document and invoke its
- "getElementsByTagName(tagName)" method with tagName
- equal to "strong". The method should return a NodeList
- that contains 5 elements.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094
- */
- hc_documentgetelementsbytagnamelength: function(test) {
- var success;
- var doc;
- var nameList;
- doc = hc_staff.hc_staff();
- nameList = doc.getElementsByTagName("strong");
- test.equal(nameList.length, 5, 'documentGetElementsByTagNameLengthAssert');
- test.done();
- },
- /**
- *
- Retrieve the entire DOM document and invoke its
- "getElementsByTagName(tagName)" method with tagName
- equal to "*". The method should return a NodeList
- that contains all the elements of the document.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
- */
- hc_documentgetelementsbytagnametotallength: function(test) {
- var expectedNames = ["HTML", "HEAD", "META", "TITLE", "SCRIPT", "SCRIPT", "SCRIPT", "BODY",
- "P", "EM", "STRONG", "CODE", "SUP", "VAR", "ACRONYM", "P", "EM", "STRONG",
- "CODE", "SUP", "VAR", "ACRONYM", "P", "EM", "STRONG", "CODE", "SUP", "VAR",
- "ACRONYM", "P", "EM", "STRONG", "CODE", "SUP", "VAR", "ACRONYM", "P", "EM",
- "STRONG", "CODE", "SUP", "VAR", "ACRONYM"];
- var actualNames = [];
- var doc = hc_staff.hc_staff();
- var nameList = doc.getElementsByTagName("*");
- for(var i=0;i<nameList.length;i++) {
- actualNames.push(nameList.item(i).tagName);
- }
- test.deepEqual(actualNames, expectedNames)
- test.done();
- },
- /**
- *
- The "getElementsByTagName(tagName)" method returns a
- NodeList of all the Elements with a given tagName
- in a pre-order traversal of the tree.
- Retrieve the entire DOM document and invoke its
- "getElementsByTagName(tagName)" method with tagName
- equal to "strong". The method should return a NodeList
- that contains 5 elements. The FOURTH item in the
- list is retrieved and output.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094
- */
- hc_documentgetelementsbytagnamevalue: function(test) {
- var success;
- var doc;
- var nameList;
- var nameNode;
- var firstChild;
- var childValue;
- doc = hc_staff.hc_staff();
- nameList = doc.getElementsByTagName("strong");
- nameNode = nameList.item(3);
- firstChild = nameNode.firstChild;
- childValue = firstChild.nodeValue;
- test.equal(childValue, "Jeny Oconnor", 'documentGetElementsByTagNameValueAssert');
- test.done();
- },
- /**
- *
- Retrieve the entire DOM document and invoke its
- "getImplementation()" method. If contentType="text/html",
- DOMImplementation.hasFeature("HTML","1.0") should be true.
- Otherwise, DOMImplementation.hasFeature("XML", "1.0")
- should be true.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1B793EBA
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=245
- */
- hc_documentgetimplementation: function(test) {
- var doc = hc_staff.hc_staff();
- test.ok(doc.implementation.hasFeature("HTML","1.0"), 'supports_HTML_1.0');
- test.done();
- },
- /**
- *
- Load a document and invoke its
- "getDocumentElement()" method.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-87CD092
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
- */
- hc_documentgetrootnode: function(test) {
- var doc = hc_staff.hc_staff();
- test.equal(doc.documentElement.nodeName, 'HTML')
- test.done();
- },
- /**
- *
- The "createAttribute(tagName)" method raises an
- INVALID_CHARACTER_ERR DOMException if the specified
- tagName contains an invalid character.
- Retrieve the entire DOM document and invoke its
- "createAttribute(tagName)" method with the tagName equal
- to the string "invalid^Name". Due to the invalid
- character the desired EXCEPTION should be raised.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- */
- hc_documentinvalidcharacterexceptioncreateattribute: function(test) {
- var doc = hc_staff.hc_staff();
- var success = false;
- try {
- doc.createAttribute("invalid^Name");
- }
- catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 5);
- }
- test.ok(success, 'throw_INVALID_CHARACTER_ERR');
- test.done();
- },
- /**
- *
- Creating an attribute with an empty name should cause an INVALID_CHARACTER_ERR.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525
- */
- hc_documentinvalidcharacterexceptioncreateattribute1: function(test) {
- var doc = hc_staff.hc_staff();
- var success = false;
- try {
- doc.createAttribute("");
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 5);
- }
- test.ok(success, 'throw_INVALID_CHARACTER_ERR');
- test.done();
- },
- /**
- *
- The "createElement(tagName)" method raises an
- INVALID_CHARACTER_ERR DOMException if the specified
- tagName contains an invalid character.
- Retrieve the entire DOM document and invoke its
- "createElement(tagName)" method with the tagName equal
- to the string "invalid^Name". Due to the invalid
- character the desired EXCEPTION should be raised.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- */
- hc_documentinvalidcharacterexceptioncreateelement: function(test) {
- var doc = hc_staff.hc_staff();
- var success = false;
- try {
- doc.createElement("invalid^Name");
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 5);
- }
- test.ok(success, 'throw_INVALID_CHARACTER_ERR');
- test.done();
- },
- /**
- *
- Creating an element with an empty name should cause an INVALID_CHARACTER_ERR.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525
- */
- hc_documentinvalidcharacterexceptioncreateelement1: function(test) {
- var doc = hc_staff.hc_staff();
- var success = false;
- try {
- doc.createElement("");
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 5);
- }
- test.ok(success, 'throw_INVALID_CHARACTER_ERR');
- test.done();
- },
- /**
- *
- Load a document and invoke its
- "getImplementation()" method. This should create a
- DOMImplementation object whose "hasFeature(feature,
- version)" method is invoked with version equal to "".
- If the version is not specified, supporting any version
- feature will cause the method to return "true".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7
- * @see http://www.w3.org/2000/11/DOM-Level-2-errata#core-14
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=245
- */
- hc_domimplementationfeaturenoversion: function(test) {
- var doc = hc_staff.hc_staff();
- test.ok(doc.implementation.hasFeature("HTML",""), 'hasFeatureBlank');
- test.done();
- },
- /**
- *
- Load a document and invoke its
- "getImplementation()" method. This should create a
- DOMImplementation object whose "hasFeature(feature,
- version)" method is invoked with version equal to null.
- If the version is not specified, supporting any version
- feature will cause the method to return "true".
- * @author Curt Arnold
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7
- * @see http://www.w3.org/2000/11/DOM-Level-2-errata#core-14
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=245
- */
- hc_domimplementationfeaturenull: function(test) {
- var doc = hc_staff.hc_staff();
- test.ok(doc.implementation.hasFeature("HTML",null), 'supports_HTML_null');
- test.done();
- },
- /**
- *
- Retrieve the entire DOM document and invoke its
- "getImplementation()" method. This should create a
- DOMImplementation object whose "hasFeature(feature,
- version)" method is invoked with "feature" equal to "html" or "xml".
- The method should return a boolean "true".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=245
- */
- hc_domimplementationfeaturexml: function(test) {
- var doc = hc_staff.hc_staff();
- test.ok(doc.implementation.hasFeature("html","1.0"), 'supports_html_1.0');
- test.done();
- },
- /**
- *
- The "setAttribute(name,value)" method adds a new attribute
- to the Element
- Retrieve the last child of the last employee, then
- add an attribute to it by invoking the
- "setAttribute(name,value)" method. It should create
- a "strong" attribute with an assigned value equal to
- "value".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
- */
- hc_elementaddnewattribute: function(test) {
- var success;
- var doc;
- var elementList;
- var testEmployee;
- var attrValue;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testEmployee = elementList.item(4);
- testEmployee.setAttribute("lang","EN-us");
- attrValue = testEmployee.getAttribute("lang");
- test.equal(attrValue, "EN-us", 'attrValue');
- test.done();
- },
- /**
- *
- Retrieve the first attribute from the last child of
- the first employee and invoke the "getSpecified()"
- method. This test is only intended to show that
- Elements can actually have attributes. This test uses
- the "getNamedItem(name)" method from the NamedNodeMap
- interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
- */
- hc_elementassociatedattribute: function(test) {
- var success;
- var doc;
- var elementList;
- var testEmployee;
- var attributes;
- var domesticAttr;
- var specified;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testEmployee = elementList.item(0);
- attributes = testEmployee.attributes;
- domesticAttr = attributes.getNamedItem("title");
- specified = domesticAttr.specified;
- test.ok(specified, 'acronymTitleSpecified');
- test.done();
- },
- /**
- *
- The "setAttribute(name,value)" method adds a new attribute
- to the Element. If the "strong" is already present, then
- its value should be changed to the new one that is in
- the "value" parameter.
- Retrieve the last child of the fourth employee, then add
- an attribute to it by invoking the
- "setAttribute(name,value)" method. Since the name of the
- used attribute("class") is already present in this
- element, then its value should be changed to the new one
- of the "value" parameter.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
- */
- hc_elementchangeattributevalue: function(test) {
- var success;
- var doc;
- var elementList;
- var testEmployee;
- var attrValue;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testEmployee = elementList.item(3);
- testEmployee.setAttribute("class","Neither");
- attrValue = testEmployee.getAttribute("class");
- test.equal(attrValue, "Neither", 'elementChangeAttributeValueAssert');
- test.done();
- },
- /**
- *
- The "setAttributeNode(newAttr)" method adds a new
- attribute to the Element.
- Retrieve first address element and add
- a new attribute node to it by invoking its
- "setAttributeNode(newAttr)" method. This test makes use
- of the "createAttribute(name)" method from the Document
- interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
- */
- hc_elementcreatenewattribute: function(test) {
- var success;
- var doc;
- var elementList;
- var testAddress;
- var newAttribute;
- var oldAttr;
- var districtAttr;
- var attrVal;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testAddress = elementList.item(0);
- newAttribute = doc.createAttribute("lang");
- oldAttr = testAddress.setAttributeNode(newAttribute);
- test.equal(oldAttr, null, 'old_attr_doesnt_exist');
- districtAttr = testAddress.getAttributeNode("lang");
- test.notEqual(districtAttr, null, 'new_district_accessible');
- attrVal = testAddress.getAttribute("lang");
- test.equal(attrVal, "", 'attr_value');
- test.done();
- },
- /**
- *
- Retrieve the attribute "title" from the last child
- of the first "p" element and check its node name.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-217A91B8
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
- * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
- */
- hc_elementgetattributenode: function(test) {
- var doc = hc_staff.hc_staff();
- var nodeName = doc.getElementsByTagName("acronym").item(0).getAttributeNode("title").nodeName;
- test.equal(nodeName, 'title', 'attribute nodeName');
- test.done();
- },
- /**
- *
- The "getAttributeNode(name)" method retrieves an
- attribute node by name. It should return null if the
- "strong" attribute does not exist.
- Retrieve the last child of the first employee and attempt
- to retrieve a non-existing attribute. The method should
- return "null". The non-existing attribute to be used
- is "invalidAttribute".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-217A91B8
- */
- hc_elementgetattributenodenull: function(test) {
- var success;
- var doc;
- var elementList;
- var testEmployee;
- var domesticAttr;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testEmployee = elementList.item(0);
- domesticAttr = testEmployee.getAttributeNode("invalidAttribute");
- test.equal(domesticAttr, null, 'elementGetAttributeNodeNullAssert');
- test.done();
- },
- /**
- *
- The "getAttribute(name)" method returns an empty
- string if no value was assigned to an attribute and
- no default value was given in the DTD file.
- Retrieve the last child of the last employee, then
- invoke "getAttribute(name)" method, where "strong" is an
- attribute without a specified or DTD default value.
- The "getAttribute(name)" method should return the empty
- string. This method makes use of the
- "createAttribute(newAttr)" method from the Document
- interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-666EE0F9
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
- */
- hc_elementgetelementempty: function(test) {
- var success;
- var doc;
- var newAttribute;
- var elementList;
- var testEmployee;
- var domesticAttr;
- var attrValue;
- doc = hc_staff.hc_staff();
- newAttribute = doc.createAttribute("lang");
- elementList = doc.getElementsByTagName("acronym");
- testEmployee = elementList.item(3);
- domesticAttr = testEmployee.setAttributeNode(newAttribute);
- attrValue = testEmployee.getAttribute("lang");
- test.equal(attrValue, "", 'elementGetElementEmptyAssert');
- test.done();
- },
- /**
- *
- The "getElementsByTagName(name)" method returns a list
- of all descendant Elements with the given tag name.
- Test for an empty list.
- Create a NodeList of all the descendant elements
- using the string "noMatch" as the tagName.
- The method should return a NodeList whose length is
- "0" since there are not any descendant elements
- that match the given tag name.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D
- */
- hc_elementgetelementsbytagname: function(test) {
- var success;
- var doc;
- var elementList;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("p");
- test.equal(elementList.length, 5, 'elementGetElementsByTagNameAssert');
- test.done();
- },
- /**
- *
- The "getElementsByTagName(name)" method returns a list
- of all descendant Elements in the order the children
- were encountered in a pre order traversal of the element
- tree.
- Create a NodeList of all the descendant elements
- using the string "p" as the tagName.
- The method should return a NodeList whose length is
- "5" in the order the children were encountered.
- Access the FOURTH element in the NodeList. The FOURTH
- element, the first or second should be an "em" node with
- the content "EMP0004".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_elementgetelementsbytagnameaccessnodelist: function(test) {
- var doc = hc_staff.hc_staff();
- var firstC = doc.getElementsByTagName("p").item(3).firstChild;
- var nodeType = firstC.nodeType;
- while (3 == nodeType) {
- firstC = firstC.nextSibling;
- nodeType = firstC.nodeType;
- }
- test.equal(firstC.nodeName, 'EM', 'element childName');
- test.equal(firstC.firstChild.nodeValue, "EMP0004", 'employeeID');
- test.done();
- },
- /**
- *
- The "getElementsByTagName(name)" method returns a list
- of all descendant Elements with the given tag name.
- Create a NodeList of all the descendant elements
- using the string "employee" as the tagName.
- The method should return a NodeList whose length is
- "5".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D
- */
- hc_elementgetelementsbytagnamenomatch: function(test) {
- var success;
- var doc;
- var elementList;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("noMatch");
- test.equal(elementList.length, 0, 'elementGetElementsByTagNameNoMatchNoMatchAssert');
- test.done();
- },
- /**
- *
- The "getElementsByTagName(name)" method may use the
- special value "*" to match all tags in the element
- tree.
- Create a NodeList of all the descendant elements
- of the last employee by using the special value "*".
- The method should return all the descendant children(6)
- in the order the children were encountered.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D
- */
- hc_elementgetelementsbytagnamespecialvalue: function(test) {
- var doc = hc_staff.hc_staff();
- var lastempList = doc.getElementsByTagName("p").item(4).getElementsByTagName("*");
- var actual = [];
- for(var i=0;i<lastempList.length;i++) {
- actual.push(lastempList.item(i).nodeName);
- }
- test.deepEqual(actual, ["EM", "STRONG", "CODE", "SUP", "VAR", "ACRONYM"], 'element tagNames');
- test.done();
- },
- /**
- *
- Invoke the "getTagName()" method one the
- root node. The value returned should be "html" or "svg".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-104682815
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
- */
- hc_elementgettagname: function(test) {
- var doc = hc_staff.hc_staff();
- test.equal(doc.documentElement.tagName, 'HTML')
- test.done();
- },
- /**
- *
- The "setAttributeNode(newAttr)" method raises an
- "INUSE_ATTRIBUTE_ERR DOMException if the "newAttr"
- is already an attribute of another element.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
- * @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'])
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=244
- */
- hc_elementinuseattributeerr: function(test) {
- var doc = hc_staff.hc_staff();
- var testAddress = doc.getElementsByTagName("body").item(0);
- var newElement = doc.createElement("p");
- testAddress.appendChild(newElement);
- var newAttribute = doc.createAttribute("title");
- newElement.setAttributeNode(newAttribute);
- var success = false;
- try {
- testAddress.setAttributeNode(newAttribute);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 10);
- }
- test.ok(success, 'throw_INUSE_ATTRIBUTE_ERR');
- test.done();
- },
- /**
- *
- The "setAttribute(name,value)" method raises an
- "INVALID_CHARACTER_ERR DOMException if the specified
- name contains an invalid character.
- Retrieve the last child of the first employee and
- call its "setAttribute(name,value)" method with
- "strong" containing an invalid character.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
- * @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'])
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- */
- hc_elementinvalidcharacterexception: function(test) {
- var doc = hc_staff.hc_staff();
- var testAddress = doc.getElementsByTagName("acronym").item(0);
- var success = false;
- try {
- testAddress.setAttribute("invalid^Name","value");
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 5);
- }
- test.ok(success, 'throw_INVALID_CHARACTER_ERR');
- test.done();
- },
- /**
- *
- Calling Element.setAttribute with an empty name will cause an INVALID_CHARACTER_ERR.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
- * @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'])
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525
- */
- hc_elementinvalidcharacterexception1: function(test) {
- var doc = hc_staff.hc_staff();
- var testAddress = doc.getElementsByTagName("acronym").item(0);
- var success = false;
- try {
- testAddress.setAttribute("","value");
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 5);
- }
- test.ok(success, 'throw_INVALID_CHARACTER_ERR');
- test.done();
- },
- /**
- *
- Append a couple of text nodes to the first sup element, normalize the
- document element and check that the element has been normalized.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=546
- */
- hc_elementnormalize: function(test) {
- var success;
- var doc;
- var root;
- var elementList;
- var testName;
- var firstChild;
- var childValue;
- var textNode;
- var retNode;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("sup");
- testName = elementList.item(0);
- textNode = doc.createTextNode("");
- retNode = testName.appendChild(textNode);
- textNode = doc.createTextNode(",000");
- retNode = testName.appendChild(textNode);
- root = doc.documentElement;
- root.normalize();
- elementList = doc.getElementsByTagName("sup");
- testName = elementList.item(0);
- firstChild = testName.firstChild;
- childValue = firstChild.nodeValue;
- test.equal(childValue, "56,000,000", 'elementNormalizeAssert');
- test.done();
- },
- /**
- *
- Add an empty text node to an existing attribute node, normalize the containing element
- and check that the attribute node has eliminated the empty text.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=482
- */
- hc_elementnormalize2: function(test) {
- var success;
- var doc;
- var root;
- var elementList;
- var element;
- var firstChild;
- var secondChild;
- var childValue;
- var emptyText;
- var attrNode;
- var retval;
- doc = hc_staff.hc_staff();
- root = doc.documentElement;
- emptyText = doc.createTextNode("");
- elementList = root.getElementsByTagName("acronym");
- element = elementList.item(0);
- attrNode = element.getAttributeNode("title");
- retval = attrNode.appendChild(emptyText);
- element.normalize();
- attrNode = element.getAttributeNode("title");
- firstChild = attrNode.firstChild;
- childValue = firstChild.nodeValue;
- test.equal(childValue, "Yes", 'firstChild');
- secondChild = firstChild.nextSibling;
- test.equal(secondChild, null, 'secondChildNull');
- test.done();
- },
- /**
- *
- The "removeAttributeNode(oldAttr)" method raises a
- NOT_FOUND_ERR DOMException if the "oldAttr" attribute
- is not an attribute of the element.
- Retrieve the last employee and attempt to remove
- a non existing attribute node. This should cause the
- intended exception to be raised. This test makes use
- of the "createAttribute(name)" method from the Document
- interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198
- * @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'])
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- */
- hc_elementnotfounderr: function(test) {
- var doc = hc_staff.hc_staff();
- var testAddress = doc.getElementsByTagName("acronym").item(4);
- var oldAttribute = doc.createAttribute("title");
- var success = false;
- try {
- testAddress.removeAttributeNode(oldAttribute);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 8);
- }
- test.ok(success, 'throw_NOT_FOUND_ERR');
- test.done();
- },
- /**
- *
- The "removeAttribute(name)" removes an attribute by name.
- If the attribute has a default value, it is immediately
- replaced. However, there is no default values in the HTML
- compatible tests, so its value is "".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9
- * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html
- */
- hc_elementremoveattribute: function(test) {
- var success;
- var doc;
- var elementList;
- var testEmployee;
- var attrValue;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testEmployee = elementList.item(3);
- testEmployee.removeAttribute("class");
- attrValue = testEmployee.getAttribute("class");
- test.equal(attrValue, "", 'attrValue');
- test.done();
- },
- /**
- *
- The "removeAttributeNode(oldAttr)" method removes the
- specified attribute.
- Retrieve the last child of the third employee, add a
- new "lang" attribute to it and then try to remove it.
- To verify that the node was removed use the
- "getNamedItem(name)" method from the NamedNodeMap
- interface. It also uses the "getAttributes()" method
- from the Node interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
- */
- hc_elementremoveattributeaftercreate: function(test) {
- var success;
- var doc;
- var elementList;
- var testEmployee;
- var newAttribute;
- var attributes;
- var districtAttr;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testEmployee = elementList.item(2);
- newAttribute = doc.createAttribute("lang");
- districtAttr = testEmployee.setAttributeNode(newAttribute);
- districtAttr = testEmployee.removeAttributeNode(newAttribute);
- attributes = testEmployee.attributes;
- districtAttr = attributes.getNamedItem("lang");
- test.equal(districtAttr, null, 'removed_item_null');
- test.done();
- },
- /**
- *
- The "removeAttributeNode(oldAttr)" method returns the
- node that was removed.
- Retrieve the last child of the third employee and
- remove its "class" Attr node. The method should
- return the old attribute node.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198
- */
- hc_elementremoveattributenode: function(test) {
- var success;
- var doc;
- var elementList;
- var testEmployee;
- var streetAttr;
- var removedAttr;
- var removedValue;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testEmployee = elementList.item(2);
- streetAttr = testEmployee.getAttributeNode("class");
- removedAttr = testEmployee.removeAttributeNode(streetAttr);
- test.notEqual(removedAttr, null, 'removedAttrNotNull');
- removedValue = removedAttr.value;
- test.equal(removedValue, "No", 'elementRemoveAttributeNodeAssert');
- test.done();
- },
- /**
- *
- This test calls setAttributeNode to replace an attribute with itself.
- Since the node is not an attribute of another Element, it would
- be inappropriate to throw an INUSE_ATTRIBUTE_ERR.
- This test was derived from elementinuserattributeerr which
- inadvertanly made this test.
- * @author Curt Arnold
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
- */
- hc_elementreplaceattributewithself: function(test) {
- var doc = hc_staff.hc_staff();
- var testEmployee = doc.getElementsByTagName("acronym").item(2);
- var streetAttr = testEmployee.getAttributeNode("class");
- var replacedAttr = testEmployee.setAttributeNode(streetAttr);
- test.equal(replacedAttr, streetAttr, 'replacedAttr')
- test.done();
- },
- /**
- *
- The "setAttributeNode(newAttr)" method adds a new
- attribute to the Element. If the "newAttr" Attr node is
- already present in this element, it should replace the
- existing one.
- Retrieve the last child of the third employee and add a
- new attribute node by invoking the "setAttributeNode(new
- Attr)" method. The new attribute node to be added is
- "class", which is already present in this element. The
- method should replace the existing Attr node with the
- new one. This test uses the "createAttribute(name)"
- method from the Document interface.
- * @author Curt Arnold
- */
- hc_elementreplaceexistingattribute: function(test) {
- var success;
- var doc;
- var elementList;
- var testEmployee;
- var newAttribute;
- var strong;
- var setAttr;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testEmployee = elementList.item(2);
- newAttribute = doc.createAttribute("class");
- setAttr = testEmployee.setAttributeNode(newAttribute);
- strong = testEmployee.getAttribute("class");
- test.equal(strong, "", 'replacedValue');
- test.done();
- },
- /**
- *
- If the "setAttributeNode(newAttr)" method replaces an
- existing Attr node with the same name, then it should
- return the previously existing Attr node.
- Retrieve the last child of the third employee and add a
- new attribute node. The new attribute node is "class",
- which is already present in this Element. The method
- should return the existing Attr node(old "class" Attr).
- This test uses the "createAttribute(name)" method
- from the Document interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
- */
- hc_elementreplaceexistingattributegevalue: function(test) {
- var success;
- var doc;
- var elementList;
- var testEmployee;
- var newAttribute;
- var streetAttr;
- var value;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testEmployee = elementList.item(2);
- newAttribute = doc.createAttribute("class");
- streetAttr = testEmployee.setAttributeNode(newAttribute);
- test.notEqual(streetAttr, null, 'previousAttrNotNull');
- value = streetAttr.value;
- test.equal(value, "No", 'previousAttrValue');
- test.done();
- },
- /**
- *
- Create a list of all the attributes of the last child
- of the first "p" element by using the "getAttributes()"
- method.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
- * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
- */
- hc_elementretrieveallattributes: function(test) {
- var doc = hc_staff.hc_staff();
- var attributes = doc.getElementsByTagName("acronym").item(0).attributes;
- var actual = [];
- for(var i=0;i<attributes.length;i++) {
- actual.push(attributes.item(i).nodeName);
- }
- test.deepEqual(actual, ['title'])
- test.done();
- },
- /**
- *
- The "getAttribute(name)" method returns an attribute
- value by name.
- Retrieve the second address element, then
- invoke the 'getAttribute("class")' method. This should
- return the value of the attribute("No").
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-666EE0F9
- */
- hc_elementretrieveattrvalue: function(test) {
- var success;
- var doc;
- var elementList;
- var testAddress;
- var attrValue;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testAddress = elementList.item(2);
- attrValue = testAddress.getAttribute("class");
- test.equal(attrValue, "No", 'attrValue');
- test.done();
- },
- /**
- *
- The "getElementsByTagName()" method returns a NodeList
- of all descendant elements with a given tagName.
- Invoke the "getElementsByTagName()" method and create
- a NodeList of "code" elements. Retrieve the second
- "code" element in the list and return the NodeName.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-104682815
- */
- hc_elementretrievetagname: function(test) {
- var doc = hc_staff.hc_staff();
- var testEmployee = doc.getElementsByTagName("code").item(1);
- test.equal(testEmployee.nodeName, 'CODE', 'element nodeName');
- test.equal(testEmployee.tagName, 'CODE', 'element tagName');
- test.done();
- },
- /**
- *
- The "setAttributeNode(newAttr)" method returns the
- null value if no previously existing Attr node with the
- same name was replaced.
- Retrieve the last child of the third employee and add a
- new attribute to it. The new attribute node added is
- "lang", which is not part of this Element. The
- method should return the null value.
- This test uses the "createAttribute(name)"
- method from the Document interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
- */
- hc_elementsetattributenodenull: function(test) {
- var success;
- var doc;
- var elementList;
- var testEmployee;
- var newAttribute;
- var districtAttr;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testEmployee = elementList.item(2);
- newAttribute = doc.createAttribute("lang");
- districtAttr = testEmployee.setAttributeNode(newAttribute);
- test.equal(districtAttr, null, 'elementSetAttributeNodeNullAssert');
- test.done();
- },
- /**
- *
- The "setAttributeNode(newAttr)" method raises an
- "WRONG_DOCUMENT_ERR DOMException if the "newAttr"
- was created from a different document than the one that
- created this document.
- Retrieve the last employee and attempt to set a new
- attribute node for its "employee" element. The new
- attribute was created from a document other than the
- one that created this element, therefore a
- WRONG_DOCUMENT_ERR DOMException should be raised.
- This test uses the "createAttribute(newAttr)" method
- from the Document interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
- * @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'])
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- */
- hc_elementwrongdocumenterr: function(test) {
- var doc1 = hc_staff.hc_staff();
- var doc2 = hc_staff.hc_staff();
- var newAttribute = doc2.createAttribute("newAttribute");
- var testAddress = doc1.getElementsByTagName("acronym").item(4);
- var success = false;
- try {
- testAddress.setAttributeNode(newAttribute);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 4);
- }
- test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
- test.done();
- },
- /**
- *
- An attempt to add remove an entity should result in a NO_MODIFICATION_ERR.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1788794630
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193
- */
- hc_entitiesremovenameditem1: function(test) {
- // NOTE: no tests get run here...
- test.done();
- },
- /**
- *
- An attempt to add an element to the named node map returned by entities should
- result in a NO_MODIFICATION_ERR or HIERARCHY_REQUEST_ERR.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1788794630
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
- */
- hc_entitiessetnameditem1: function(test) {
- // NOTE: no tests get run here
- test.done();
- },
- /**
- *
- Create a NamedNodeMap object from the attributes of the
- last child of the third "p" element and traverse the
- list from index 0 thru length -1. All indices should
- be valid.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D0FB19E
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=250
- */
- hc_namednodemapchildnoderange: function(test) {
- var doc = hc_staff.hc_staff();
- var attributes = doc.getElementsByTagName("acronym").item(2).attributes;
- test.equal(attributes.length, 2, 'htmlLength');
- test.notEqual(attributes.item(0), null, 'attr0');
- test.notEqual(attributes.item(1), null, 'attr1');
- test.equal(attributes.item(3), null, 'attr3');
- test.done();
- },
- /**
- *
- Retrieve the second "p" element and create a NamedNodeMap
- listing of the attributes of the last child. Once the
- list is created an invocation of the "getNamedItem(name)"
- method is done with name="title". This should result
- in the title Attr node being returned.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
- * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
- */
- hc_namednodemapgetnameditem: function(test) {
- var doc = hc_staff.hc_staff();
- var domesticAttr = doc.getElementsByTagName("acronym").item(1).attributes.getNamedItem("title");
- test.equal(domesticAttr.nodeName, 'title', 'attribute nodeName');
- test.done();
- },
- /**
- *
- The "setNamedItem(arg)" method raises a
- INUSE_ATTRIBUTE_ERR DOMException if "arg" is an
- Attr that is already in an attribute of another Element.
- Create a NamedNodeMap object from the attributes of the
- last child of the third employee and attempt to add
- an attribute that is already being used by the first
- employee. This should raise the desired exception.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
- * @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'])
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- */
- hc_namednodemapinuseattributeerr: function(test) {
- var doc = hc_staff.hc_staff();
- var firstNode = doc.getElementsByTagName("acronym").item(0);
- var domesticAttr = doc.createAttribute("title");
- domesticAttr.value = "Yα";
- firstNode.setAttributeNode(domesticAttr);
- var attributes = doc.getElementsByTagName("acronym").item(2).attributes;
- var success = false;
- try {
- attributes.setNamedItem(domesticAttr);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 10);
- }
- test.ok(success, 'throw_INUSE_ATTRIBUTE_ERR');
- test.done();
- },
- /**
- *
- The "removeNamedItem(name)" method raises a
- NOT_FOUND_ERR DOMException if there is not a node
- named "strong" in the map.
- Create a NamedNodeMap object from the attributes of the
- last child of the third employee and attempt to remove
- the "lang" attribute. There is not a node named
- "lang" in the list and therefore the desired
- exception should be raised.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193
- * @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'])
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
- */
- hc_namednodemapnotfounderr: function(test) {
- var doc = hc_staff.hc_staff();
- var attributes = doc.getElementsByTagName("acronym").item(2).attributes;
- var success = false;
- try {
- attributes.removeNamedItem("lang");
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 8);
- }
- test.ok(success, 'throw_NOT_FOUND_ERR');
- test.done();
- },
- /**
- *
- Retrieve the second "p" element and evaluate Node.attributes.length.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D0FB19E
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=250
- */
- hc_namednodemapnumberofnodes: function(test) {
- var doc = hc_staff.hc_staff();
- var attributes = doc.getElementsByTagName("acronym").item(2).attributes;
- test.equal(attributes.length, 2, 'htmlLength');
- test.done();
- },
- /**
- *
- The "removeNamedItem(name)" method removes a node
- specified by name.
- Retrieve the third employee and create a NamedNodeMap
- object of the attributes of the last child. Once the
- list is created invoke the "removeNamedItem(name)"
- method with name="class". This should result
- in the removal of the specified attribute.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
- * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html
- */
- hc_namednodemapremovenameditem: function(test) {
- var success;
- var doc;
- var elementList;
- var newAttribute;
- var testAddress;
- var attributes;
- var streetAttr;
- var specified;
- var removedNode;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testAddress = elementList.item(2);
- attributes = testAddress.attributes;
- removedNode = attributes.removeNamedItem("class");
- streetAttr = attributes.getNamedItem("class");
- test.equal(streetAttr, null, 'isnull');
- test.done();
- },
- /**
- *
- Retrieve the second p element and create a NamedNodeMap
- listing of the attributes of the last child. Once the
- list is created an invocation of the "getNamedItem(name)"
- method is done with name="class". This should result
- in the method returning an Attr node.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1112119403
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
- */
- hc_namednodemapreturnattrnode: function(test) {
- var doc = hc_staff.hc_staff();
- var streetAttr = doc.getElementsByTagName("acronym").item(1).attributes.getNamedItem("class");
- test.equal(streetAttr.nodeType, 2, 'typeAssert')
- test.equal(streetAttr.nodeName, 'class', 'attribute nodeName');
- test.equal(streetAttr.name, 'class', 'attribute name');
- test.done();
- },
- /**
- *
- The "item(index)" method returns the indexth item in
- the map(test for first item).
- Retrieve the second "acronym" get the NamedNodeMap of the attributes. Since the
- DOM does not specify an order of these nodes the contents
- of the FIRST node can contain either "title", "class" or "dir".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
- * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
- */
- hc_namednodemapreturnfirstitem: function(test) {
- var doc = hc_staff.hc_staff();
- var attributes = doc.getElementsByTagName("acronym").item(1).attributes;
- var actual = [];
- for(var i=0;i<attributes.length;i++) {
- actual.push(attributes.item(i).nodeName);
- }
- // assertEqualsCollection("attrName_html",toLowerArray(htmlExpected),toLowerArray(actual));
- test.deepEqual(actual, ['title', 'class'])
- test.done();
- },
- /**
- *
- The "item(index)" method returns the indexth item in
- the map(test for last item).
- Retrieve the second "acronym" and get the attribute name. Since the
- DOM does not specify an order of these nodes the contents
- of the LAST node can contain either "title" or "class".
- The test should return "true" if the LAST node is either
- of these values.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
- * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
- */
- hc_namednodemapreturnlastitem: function(test) {
- var doc = hc_staff.hc_staff();
- var attributes = doc.getElementsByTagName("acronym").item(1).attributes;
- var actual = [];
- for(var i=0;i<attributes.length;i++) {
- actual.push(attributes.item(i).nodeName);
- }
- test.deepEqual(actual, ['title', 'class'])
- test.done();
- },
- /**
- *
- The "getNamedItem(name)" method returns null of the
- specified name did not identify any node in the map.
- Retrieve the second employee and create a NamedNodeMap
- listing of the attributes of the last child. Once the
- list is created an invocation of the "getNamedItem(name)"
- method is done with name="lang". This name does not
- match any names in the list therefore the method should
- return null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- */
- hc_namednodemapreturnnull: function(test) {
- var success;
- var doc;
- var elementList;
- var testEmployee;
- var attributes;
- var districtNode;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testEmployee = elementList.item(1);
- attributes = testEmployee.attributes;
- districtNode = attributes.getNamedItem("lang");
- test.equal(districtNode, null, 'langAttrNull');
- test.done();
- },
- /**
- *
- Retrieve the second "p" element and create a NamedNodeMap
- object from the attributes of the last child by
- invoking the "getAttributes()" method. Once the
- list is created an invocation of the "setNamedItem(arg)"
- method is done with arg=newAttr, where newAttr is a
- new Attr Node previously created. The "setNamedItem(arg)"
- method should add then new node to the NamedNodeItem
- object by using its "nodeName" attribute("lang').
- This node is then retrieved using the "getNamedItem(name)"
- method.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
- * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
- */
- hc_namednodemapsetnameditem: function(test) {
- var doc = hc_staff.hc_staff();
- var testAddress = doc.getElementsByTagName("acronym").item(1);
- var newAttribute = doc.createAttribute("lang");
- var attributes = testAddress.attributes;
- attributes.setNamedItem(newAttribute);
- test.equal(attributes.getNamedItem("lang").nodeName, 'lang', 'attribute nodeName');
- test.done();
- },
- /**
- *
- If the "setNamedItem(arg)" method replaces an already
- existing node with the same name then the already
- existing node is returned.
- Retrieve the third employee and create a NamedNodeMap
- object from the attributes of the last child by
- invoking the "getAttributes()" method. Once the
- list is created an invocation of the "setNamedItem(arg)"
- method is done with arg=newAttr, where newAttr is a
- new Attr Node previously created and whose node name
- already exists in the map. The "setNamedItem(arg)"
- method should replace the already existing node with
- the new one and return the existing node.
- This test uses the "createAttribute(name)" method from
- the document interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
- */
- hc_namednodemapsetnameditemreturnvalue: function(test) {
- var success;
- var doc;
- var elementList;
- var newAttribute;
- var testAddress;
- var attributes;
- var newNode;
- var attrValue;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testAddress = elementList.item(2);
- newAttribute = doc.createAttribute("class");
- attributes = testAddress.attributes;
- newNode = attributes.setNamedItem(newAttribute);
- test.notEqual(newNode, null, 'previousAttrNotNull');
- attrValue = newNode.nodeValue;
- test.equal(attrValue, "No", 'previousAttrValue');
- test.done();
- },
- /**
- *
- If the node to be added by the "setNamedItem(arg)" method
- already exists in the NamedNodeMap, it is replaced by
- the new one.
- Retrieve the second employee and create a NamedNodeMap
- object from the attributes of the last child by
- invoking the "getAttributes()" method. Once the
- list is created an invocation of the "setNamedItem(arg)"
- method is done with arg=newAttr, where newAttr is a
- new Attr Node previously created and whose node name
- already exists in the map. The "setNamedItem(arg)"
- method should replace the already existing node with
- the new one.
- This node is then retrieved using the "getNamedItem(name)"
- method. This test uses the "createAttribute(name)"
- method from the document interface
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
- */
- hc_namednodemapsetnameditemthatexists: function(test) {
- var success;
- var doc;
- var elementList;
- var newAttribute;
- var testAddress;
- var attributes;
- var districtNode;
- var attrValue;
- var setNode;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testAddress = elementList.item(1);
- newAttribute = doc.createAttribute("class");
- attributes = testAddress.attributes;
- setNode = attributes.setNamedItem(newAttribute);
- districtNode = attributes.getNamedItem("class");
- attrValue = districtNode.nodeValue;
- test.equal(attrValue, "", 'namednodemapSetNamedItemThatExistsAssert');
- test.done();
- },
- /**
- *
- If the "setNamedItem(arg)" method does not replace an
- existing node with the same name then it returns null.
- Retrieve the third employee and create a NamedNodeMap
- object from the attributes of the last child.
- Once the list is created the "setNamedItem(arg)" method
- is invoked with arg=newAttr, where newAttr is a
- newly created Attr Node and whose node name
- already exists in the map. The "setNamedItem(arg)"
- method should add the new node and return null.
- This test uses the "createAttribute(name)" method from
- the document interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
- */
- hc_namednodemapsetnameditemwithnewvalue: function(test) {
- var success;
- var doc;
- var elementList;
- var newAttribute;
- var testAddress;
- var attributes;
- var newNode;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testAddress = elementList.item(2);
- newAttribute = doc.createAttribute("lang");
- attributes = testAddress.attributes;
- newNode = attributes.setNamedItem(newAttribute);
- test.equal(newNode, null, 'prevValueNull');
- test.done();
- },
- /**
- *
- The "setNamedItem(arg)" method raises a
- WRONG_DOCUMENT_ERR DOMException if "arg" was created
- from a different document than the one that created
- the NamedNodeMap.
- Create a NamedNodeMap object from the attributes of the
- last child of the third employee and attempt to add
- another Attr node to it that was created from a
- different DOM document. This should raise the desired
- exception. This method uses the "createAttribute(name)"
- method from the Document interface.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
- * @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'])
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- */
- hc_namednodemapwrongdocumenterr: function(test) {
- var doc1 = hc_staff.hc_staff();
- var doc2 = hc_staff.hc_staff();
- var attributes = doc1.getElementsByTagName("acronym").item(2).attributes;
- var newAttribute = doc2.createAttribute("newAttribute");
- var success = false;
- try {
- attributes.setNamedItem(newAttribute);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 4);
- }
- test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
- test.done();
- },
- /**
- *
- Retrieve the second "p" and append a "br" Element
- node to the list of children. The last node in the list
- is then retrieved and its NodeName examined. The
- "getNodeName()" method should return "br".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- */
- hc_nodeappendchild: function(test) {
- var doc = hc_staff.hc_staff();
- var employeeNode = doc.getElementsByTagName("p").item(1);
- var createdNode = doc.createElement("br");
- employeeNode.appendChild(createdNode);
- var lchild = employeeNode.lastChild;
- test.equal(lchild.nodeName, 'BR', 'element nodeName');
- test.done();
- },
- /**
- *
- If the "newChild" is already in the tree, it is first
- removed before the new one is appended.
- Retrieve the "em" second employee and
- append the first child to the end of the list. After
- the "appendChild(newChild)" method is invoked the first
- child should be the one that was second and the last
- child should be the one that was first.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_nodeappendchildchildexists: function(test) {
- var expected = ["STRONG", "CODE", "SUP", "VAR", "ACRONYM", "EM"];
- var doc = hc_staff.hc_staff();
- var childNode = doc.getElementsByTagName("p").item(1);
- var childList = childNode.getElementsByTagName("*");
- childNode.appendChild(childList.item(0));
- var actual = [];
- for(var i=0;i<childList.length;i++) {
- actual.push(childList.item(i).nodeName);
- }
- test.deepEqual(actual, expected, 'element liveByTagName');
- childList = childNode.childNodes;
- var refreshedActual = [];
- for(var i=0;i<childList.length;i++) {
- if (1 == childList.item(i).nodeType) {
- refreshedActual.push(childList.item(i).nodeName);
- }
- }
- test.deepEqual(refreshedActual, expected, 'element refreshedChildNodes');
- test.done();
- },
- /**
- *
- If the "newChild" is a DocumentFragment object then
- all its content is added to the child list of this node.
- Create and populate a new DocumentFragment object and
- append it to the second employee. After the
- "appendChild(newChild)" method is invoked retrieve the
- new nodes at the end of the list, they should be the
- two Element nodes from the DocumentFragment.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- */
- hc_nodeappendchilddocfragment: function(test) {
- var success;
- var doc;
- var elementList;
- var employeeNode;
- var childList;
- var newdocFragment;
- var newChild1;
- var newChild2;
- var child;
- var childName;
- var result = new Array();
- var appendedChild;
- var nodeType;
- expected = ["EM", "STRONG", "CODE", "SUP", "VAR", "ACRONYM", "BR", "B"];
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("p");
- employeeNode = elementList.item(1);
- childList = employeeNode.childNodes;
- newdocFragment = doc.createDocumentFragment();
- newChild1 = doc.createElement("br");
- newChild2 = doc.createElement("b");
- appendedChild = newdocFragment.appendChild(newChild1);
- appendedChild = newdocFragment.appendChild(newChild2);
- appendedChild = employeeNode.appendChild(newdocFragment);
- for(var indexN100A2 = 0;indexN100A2 < childList.length; indexN100A2++) {
- child = childList.item(indexN100A2);
- nodeType = child.nodeType;
- if(
- (1 == nodeType)
- ) {
- childName = child.nodeName;
- result[result.length] = childName;
- }
- }
- test.deepEqual(result, expected, 'element nodeNames');
- test.done();
- },
- /**
- *
- The "appendChild(newChild)" method returns the node
- added.
- Append a newly created node to the child list of the
- second employee and check the NodeName returned. The
- "getNodeName()" method should return "br".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- */
- hc_nodeappendchildgetnodename: function(test) {
- var doc = hc_staff.hc_staff();
- var employeeNode = doc.getElementsByTagName("p").item(1);
- var newChild = doc.createElement("br");
- var appendNode = employeeNode.appendChild(newChild);
- test.equal(appendNode.nodeName, 'BR', 'element nodeName');
- test.done();
- },
- /**
- *
- The "appendChild(newChild)" method raises a
- HIERARCHY_REQUEST_ERR DOMException if this node is of
- a type that does not allow children of the type "newChild"
- to be inserted.
- Retrieve the root node and attempt to append a newly
- created Attr node. An Element node cannot have children
- of the "Attr" type, therefore the desired exception
- should be raised.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- */
- hc_nodeappendchildinvalidnodetype: function(test) {
- var doc = hc_staff.hc_staff();
- var rootNode = doc.documentElement;
- var newChild = doc.createAttribute("newAttribute");
- var success = false;
- try {
- rootNode.appendChild(newChild);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 3);
- }
- test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
- test.done();
- },
- /**
- *
- The "appendChild(newChild)" method raises a
- WRONG_DOCUMENT_ERR DOMException if the "newChild" was
- created from a different document than the one that
- created this node.
- Retrieve the second employee and attempt to append
- a node created from a different document. An attempt
- to make such a replacement should raise the desired
- exception.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- */
- hc_nodeappendchildnewchilddiffdocument: function(test) {
- doc1 = hc_staff.hc_staff();
- doc2 = hc_staff.hc_staff();
- var newChild = doc1.createElement("br");
- var elementNode = doc2.getElementsByTagName("p").item(1);
- var success = false;
- try {
- elementNode.appendChild(newChild);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 4);
- }
- test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
- test.done();
- },
- /**
- *
- The "appendChild(newChild)" method raises a
- HIERARCHY_REQUEST_ERR DOMException if the node to
- append is one of this node's ancestors.
- Retrieve the second employee and attempt to append
- an ancestor node(root node) to it.
- An attempt to make such an addition should raise the
- desired exception.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
- */
- hc_nodeappendchildnodeancestor: function(test) {
- var doc = hc_staff.hc_staff();
- var newChild = doc.documentElement;
- var employeeNode = doc.getElementsByTagName("p").item(1);
- var success = false;
- try {
- employeeNode.appendChild(newChild);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 3);
- }
- test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
- test.done();
- },
- /**
- *
- The "getAttributes()" method invoked on an Attribute
- Node returns null.
- Retrieve the first attribute from the last child of the
- first employee and invoke the "getAttributes()" method
- on the Attribute Node. It should return null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
- */
- hc_nodeattributenodeattribute: function(test) {
- var success;
- var doc;
- var elementList;
- var testAddr;
- var addrAttr;
- var attrNode;
- var attrList;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testAddr = elementList.item(0);
- addrAttr = testAddr.attributes;
- attrNode = addrAttr.item(0);
- attrList = attrNode.attributes;
- test.equal(attrList, null, 'nodeAttributeNodeAttributeAssert1');
- test.done();
- },
- /**
- *
- Retrieve the Attribute named "title" from the last
- child of the first p element and check the string returned
- by the "getNodeName()" method. It should be equal to
- "title".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
- */
- hc_nodeattributenodename: function(test) {
- var doc = hc_staff.hc_staff();
- var addrAttr = doc.getElementsByTagName("acronym").item(0).getAttributeNode("title");
- test.equal(addrAttr.nodeName, 'title', 'attribute nodeName');
- test.done();
- },
- /**
- *
- The "getNodeType()" method for an Attribute Node
- returns the constant value 2.
- Retrieve the first attribute from the last child of
- the first employee and invoke the "getNodeType()"
- method. The method should return 2.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
- */
- hc_nodeattributenodetype: function(test) {
- var success;
- var doc;
- var elementList;
- var testAddr;
- var addrAttr;
- var nodeType;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testAddr = elementList.item(0);
- addrAttr = testAddr.getAttributeNode("title");
- nodeType = addrAttr.nodeType;
- test.equal(nodeType, 2, 'nodeAttrNodeTypeAssert1');
- test.done();
- },
- /**
- *
- The string returned by the "getNodeValue()" method for an
- Attribute Node is the value of the Attribute.
- Retrieve the Attribute named "title" from the last
- child of the first "p" and check the string returned
- by the "getNodeValue()" method. It should be equal to
- "Yes".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
- */
- hc_nodeattributenodevalue: function(test) {
- var success;
- var doc;
- var elementList;
- var testAddr;
- var addrAttr;
- var attrValue;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testAddr = elementList.item(0);
- addrAttr = testAddr.getAttributeNode("title");
- attrValue = addrAttr.nodeValue;
- test.equal(attrValue, "Yes", 'nodeValue');
- test.done();
- },
- /**
- *
- The "getChildNodes()" method returns a NodeList
- that contains all children of this node.
- Retrieve the second employee and check the NodeList
- returned by the "getChildNodes()" method. The
- length of the list should be 13.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_nodechildnodes: function(test) {
- var success;
- var doc;
- var elementList;
- var employeeNode;
- var childNode;
- var childNodes;
- var nodeType;
- var childName;
- var actual = new Array();
- expected = ["EM", "STRONG", "CODE", "SUP", "VAR", "ACRONYM"];
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("p");
- employeeNode = elementList.item(1);
- childNodes = employeeNode.childNodes;
- for(var indexN1006C = 0;indexN1006C < childNodes.length; indexN1006C++) {
- childNode = childNodes.item(indexN1006C);
- nodeType = childNode.nodeType;
- childName = childNode.nodeName;
- if(
- (1 == nodeType)
- ) {
- actual[actual.length] = childName;
- }
- else {
- test.equal(nodeType, 3, 'textNodeType');
- }
- }
- test.deepEqual(actual, expected, 'element elementNames');
- test.done();
- },
- /**
- *
- The NodeList returned by the "getChildNodes()" method
- is live. Changes on the node's children are immediately
- reflected on the nodes returned in the NodeList.
- Create a NodeList of the children of the second employee
- and then add a newly created element that was created
- by the "createElement()" method(Document Interface) to
- the second employee by using the "appendChild()" method.
- The length of the NodeList should reflect this new
- addition to the child list. It should return the value 14.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- */
- hc_nodechildnodesappendchild: function(test) {
- var success;
- var doc;
- var elementList;
- var employeeNode;
- var childList;
- var createdNode;
- var childNode;
- var childName;
- var childType;
- var textNode;
- var actual = new Array();
- expected = ["EM", "STRONG", "CODE", "SUP", "VAR", "ACRONYM", "BR"];
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("p");
- employeeNode = elementList.item(1);
- childList = employeeNode.childNodes;
- createdNode = doc.createElement("br");
- employeeNode = employeeNode.appendChild(createdNode);
- for(var indexN10087 = 0;indexN10087 < childList.length; indexN10087++) {
- childNode = childList.item(indexN10087);
- childName = childNode.nodeName;
- childType = childNode.nodeType;
- if(
- (1 == childType)
- ) {
- actual[actual.length] = childName;
- }
- else {
- test.equal(childType, 3, 'textNodeType');
- }
- }
- test.deepEqual(actual, expected, 'element childElements');
- test.done();
- },
- /**
- *
- The "getChildNodes()" method returns a NodeList
- that contains all children of this node. If there
- are not any children, this is a NodeList that does not
- contain any nodes.
- Retrieve the character data of the second "em" node and
- invoke the "getChildNodes()" method. The
- NodeList returned should not have any nodes.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_nodechildnodesempty: function(test) {
- var success;
- var doc;
- var elementList;
- var childList;
- var employeeNode;
- var textNode;
- var length;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("em");
- employeeNode = elementList.item(1);
- textNode = employeeNode.firstChild;
- childList = textNode.childNodes;
- length = childList.length;
- test.equal(length, 0, 'length_zero');
- test.done();
- },
- /**
- *
- Retrieve the second acronym element and invoke
- the cloneNode method. The
- duplicate node returned by the method should copy the
- attributes associated with this node.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
- */
- hc_nodecloneattributescopied: function(test) {
- var doc = hc_staff.hc_staff();
- var attributes = doc.getElementsByTagName("acronym").item(1).cloneNode(false).attributes;
- var actual = [];
- for(var i=0;i<attributes.length;i++) {
- actual.push(attributes.item(i).nodeName);
- }
- test.deepEqual(actual, ['title', 'class'])
- test.done();
- },
- /**
- *
- The "cloneNode(deep)" method does not copy text unless it
- is deep cloned.(Test for deep=false)
- Retrieve the fourth child of the second employee and
- the "cloneNode(deep)" method with deep=false. The
- duplicate node returned by the method should not copy
- any text data contained in this node.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
- */
- hc_nodeclonefalsenocopytext: function(test) {
- var success;
- var doc;
- var elementList;
- var employeeNode;
- var childList;
- var childNode;
- var clonedNode;
- var lastChildNode;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("p");
- employeeNode = elementList.item(1);
- childList = employeeNode.childNodes;
- childNode = childList.item(3);
- clonedNode = childNode.cloneNode(false);
- lastChildNode = clonedNode.lastChild;
- test.equal(lastChildNode, null, 'nodeCloneFalseNoCopyTextAssert1');
- test.done();
- },
- /**
- *
- The duplicate node returned by the "cloneNode(deep)"
- method does not have a ParentNode.
- Retrieve the second employee and invoke the
- "cloneNode(deep)" method with deep=false. The
- duplicate node returned should return null when the
- "getParentNode()" is invoked.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
- */
- hc_nodeclonegetparentnull: function(test) {
- var success;
- var doc;
- var elementList;
- var employeeNode;
- var clonedNode;
- var parentNode;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("p");
- employeeNode = elementList.item(1);
- clonedNode = employeeNode.cloneNode(false);
- parentNode = clonedNode.parentNode;
- test.equal(parentNode, null, 'nodeCloneGetParentNullAssert1');
- test.done();
- },
- /**
- *
- The "cloneNode(deep)" method returns a copy of the node
- only if deep=false.
- Retrieve the second employee and invoke the
- "cloneNode(deep)" method with deep=false. The
- method should only clone this node. The NodeName and
- length of the NodeList are checked. The "getNodeName()"
- method should return "employee" and the "getLength()"
- method should return 0.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
- */
- hc_nodeclonenodefalse: function(test) {
- var doc = hc_staff.hc_staff();
- var clonedNode = doc.getElementsByTagName("p").item(1).cloneNode(false);
- test.equal(clonedNode.nodeName, 'P', 'element strong');
- test.equal(clonedNode.childNodes.length, 0, 'length');
- test.done();
- },
- /**
- *
- The "cloneNode(deep)" method returns a copy of the node
- and the subtree under it if deep=true.
- Retrieve the second employee and invoke the
- "cloneNode(deep)" method with deep=true. The
- method should clone this node and the subtree under it.
- The NodeName of each child in the returned node is
- checked to insure the entire subtree under the second
- employee was cloned.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_nodeclonenodetrue: function(test) {
- var success;
- var doc;
- var elementList;
- var employeeNode;
- var clonedNode;
- var clonedList;
- var clonedChild;
- var clonedChildName;
- var origList;
- var origChild;
- var origChildName;
- var result = new Array();
- var expected = new Array();
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("p");
- employeeNode = elementList.item(1);
- origList = employeeNode.childNodes;
- for(var indexN10065 = 0;indexN10065 < origList.length; indexN10065++) {
- origChild = origList.item(indexN10065);
- origChildName = origChild.nodeName;
- expected[expected.length] = origChildName;
- }
- clonedNode = employeeNode.cloneNode(true);
- clonedList = clonedNode.childNodes;
- for(var indexN1007B = 0;indexN1007B < clonedList.length; indexN1007B++) {
- clonedChild = clonedList.item(indexN1007B);
- clonedChildName = clonedChild.nodeName;
- result[result.length] = clonedChildName;
- }
- test.deepEqual(result, expected, 'clone');
- test.done();
- },
- /**
- *
- The "cloneNode(deep)" method does not copy text unless it
- is deep cloned.(Test for deep=true)
- Retrieve the eighth child of the second employee and
- the "cloneNode(deep)" method with deep=true. The
- duplicate node returned by the method should copy
- any text data contained in this node.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_nodeclonetruecopytext: function(test) {
- var success;
- var doc;
- var elementList;
- var childNode;
- var clonedNode;
- var lastChildNode;
- var childValue;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("sup");
- childNode = elementList.item(1);
- clonedNode = childNode.cloneNode(true);
- lastChildNode = clonedNode.lastChild;
- childValue = lastChildNode.nodeValue;
- test.equal(childValue, "35,000", 'cloneContainsText');
- test.done();
- },
- /**
- *
- The "getAttributes()" method invoked on a Comment
- Node returns null.
- Find any comment that is an immediate child of the root
- and assert that Node.attributes is null. Then create
- a new comment node (in case they had been omitted) and
- make the assertion.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=248
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=263
- */
- hc_nodecommentnodeattributes: function(test) {
- var success;
- var doc;
- var commentNode;
- var nodeList;
- var attrList;
- var nodeType;
- doc = hc_staff.hc_staff();
- nodeList = doc.childNodes;
- for(var indexN10043 = 0;indexN10043 < nodeList.length; indexN10043++) {
- commentNode = nodeList.item(indexN10043);
- nodeType = commentNode.nodeType;
- if(
- (8 == nodeType)
- ) {
- attrList = commentNode.attributes;
- test.equal(attrList, null, 'existingCommentAttributesNull');
- }
- }
- commentNode = doc.createComment("This is a comment");
- attrList = commentNode.attributes;
- test.equal(attrList, null, 'createdCommentAttributesNull');
- test.done();
- },
- /**
- *
- The string returned by the "getNodeName()" method for a
- Comment Node is "#comment".
- Retrieve the Comment node in the XML file
- and check the string returned by the "getNodeName()"
- method. It should be equal to "#comment".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=248
- */
- hc_nodecommentnodename: function(test) {
- var success;
- var doc;
- var elementList;
- var commentNode;
- var nodeType;
- var commentName;
- var commentNodeName;
- doc = hc_staff.hc_staff();
- elementList = doc.childNodes;
- for(var indexN10044 = 0;indexN10044 < elementList.length; indexN10044++) {
- commentNode = elementList.item(indexN10044);
- nodeType = commentNode.nodeType;
- if(
- (8 == nodeType)
- ) {
- commentNodeName = commentNode.nodeName;
- test.equal(commentNodeName, "#comment", 'existingNodeName');
- }
- }
- commentNode = doc.createComment("This is a comment");
- commentNodeName = commentNode.nodeName;
- test.equal(commentNodeName, "#comment", 'createdNodeName');
- test.done();
- },
- /**
- *
- The "getNodeType()" method for a Comment Node
- returns the constant value 8.
- Retrieve the nodes from the document and check for
- a comment node and invoke the "getNodeType()" method. This should
- return 8.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=248
- */
- hc_nodecommentnodetype: function(test) {
- var success;
- var doc;
- var testList;
- var commentNode;
- var commentNodeName;
- var nodeType;
- doc = hc_staff.hc_staff();
- testList = doc.childNodes;
- for(var indexN10040 = 0;indexN10040 < testList.length; indexN10040++) {
- commentNode = testList.item(indexN10040);
- commentNodeName = commentNode.nodeName;
- if(
- ("#comment" == commentNodeName)
- ) {
- nodeType = commentNode.nodeType;
- test.equal(nodeType, 8, 'existingCommentNodeType');
- }
- }
- commentNode = doc.createComment("This is a comment");
- nodeType = commentNode.nodeType;
- test.equal(nodeType, 8, 'createdCommentNodeType');
- test.done();
- },
- /**
- *
- The string returned by the "getNodeValue()" method for a
- Comment Node is the content of the comment.
- Retrieve the comment in the XML file and
- check the string returned by the "getNodeValue()" method.
- It should be equal to "This is comment number 1".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=248
- */
- hc_nodecommentnodevalue: function(test) {
- var success;
- var doc;
- var elementList;
- var commentNode;
- var commentName;
- var commentValue;
- doc = hc_staff.hc_staff();
- elementList = doc.childNodes;
- for(var indexN10040 = 0;indexN10040 < elementList.length; indexN10040++) {
- commentNode = elementList.item(indexN10040);
- commentName = commentNode.nodeName;
- if(
- ("#comment" == commentName)
- ) {
- commentValue = commentNode.nodeValue;
- test.equal(commentValue, " This is comment number 1.", 'value');
- }
- }
- commentNode = doc.createComment(" This is a comment");
- commentValue = commentNode.nodeValue;
- test.equal(commentValue, " This is a comment", 'createdCommentNodeValue');
- test.done();
- },
- /**
- *
- The string returned by the "getNodeName()" method for a
- DocumentFragment Node is "#document-frament".
- Retrieve the DOM document and invoke the
- "createDocumentFragment()" method and check the string
- returned by the "getNodeName()" method. It should be
- equal to "#document-fragment".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
- */
- hc_nodedocumentfragmentnodename: function(test) {
- var doc = hc_staff.hc_staff();
- var docFragment = doc.createDocumentFragment();
- test.equal(docFragment.nodeName, "#document-fragment", 'nodeDocumentFragmentNodeNameAssert1');
- test.done();
- },
- /**
- *
- The "getNodeType()" method for a DocumentFragment Node
- returns the constant value 11.
- Invoke the "createDocumentFragment()" method and
- examine the NodeType of the document fragment
- returned by the "getNodeType()" method. The method
- should return 11.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
- */
- hc_nodedocumentfragmentnodetype: function(test) {
- var success;
- var doc;
- var documentFragmentNode;
- var nodeType;
- doc = hc_staff.hc_staff();
- documentFragmentNode = doc.createDocumentFragment();
- nodeType = documentFragmentNode.nodeType;
- test.equal(nodeType, 11, 'nodeDocumentFragmentNodeTypeAssert1');
- test.done();
- },
- /**
- *
- The string returned by the "getNodeValue()" method for a
- DocumentFragment Node is null.
- Retrieve the DOM document and invoke the
- "createDocumentFragment()" method and check the string
- returned by the "getNodeValue()" method. It should be
- equal to null.
- * @author Curt Arnold
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
- */
- hc_nodedocumentfragmentnodevalue: function(test) {
- var success;
- var doc;
- var docFragment;
- var attrList;
- var value;
- doc = hc_staff.hc_staff();
- docFragment = doc.createDocumentFragment();
- attrList = docFragment.attributes;
- test.equal(attrList, null, 'attributesNull');
- value = docFragment.nodeValue;
- test.equal(value, null, 'initiallyNull');
- test.done();
- },
- /**
- *
- The "getAttributes()" method invoked on a Document
- Node returns null.
- Retrieve the DOM Document and invoke the
- "getAttributes()" method on the Document Node.
- It should return null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
- */
- hc_nodedocumentnodeattribute: function(test) {
- var success;
- var doc;
- var attrList;
- doc = hc_staff.hc_staff();
- attrList = doc.attributes;
- test.equal(attrList, null, 'doc_attributes_is_null');
- test.done();
- },
- /**
- *
- The string returned by the "getNodeName()" method for a
- Document Node is "#document".
- Retrieve the DOM document and check the string returned
- by the "getNodeName()" method. It should be equal to
- "#document".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
- */
- hc_nodedocumentnodename: function(test) {
- var success;
- var doc;
- var documentName;
- doc = hc_staff.hc_staff();
- documentName = doc.nodeName;
- test.equal(documentName, "#document", 'documentNodeName');
- test.done();
- },
- /**
- *
- The "getNodeType()" method for a Document Node
- returns the constant value 9.
- Retrieve the document and invoke the "getNodeType()"
- method. The method should return 9.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
- */
- hc_nodedocumentnodetype: function(test) {
- var success;
- var doc;
- var nodeType;
- doc = hc_staff.hc_staff();
- nodeType = doc.nodeType;
- test.equal(nodeType, 9, 'nodeDocumentNodeTypeAssert1');
- test.done();
- },
- /**
- *
- The string returned by the "getNodeValue()" method for a
- Document Node is null.
- Retrieve the DOM Document and check the string returned
- by the "getNodeValue()" method. It should be equal to
- null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
- */
- hc_nodedocumentnodevalue: function(test) {
- var success;
- var doc;
- var documentValue;
- doc = hc_staff.hc_staff();
- documentValue = doc.nodeValue;
- test.equal(documentValue, null, 'documentNodeValue');
- test.done();
- },
- /**
- *
- Retrieve the third "acronym" element and evaluate Node.attributes.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
- * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
- */
- hc_nodeelementnodeattributes: function(test) {
- var doc = hc_staff.hc_staff();
- var attributes = doc.getElementsByTagName("acronym").item(2).attributes;
- var actual = [];
- for(var i=0;i<attributes.length;i++) {
- actual.push(attributes.item(i).nodeName);
- }
- test.deepEqual(actual, ['title', 'class'])
- test.done();
- },
- /**
- *
- Retrieve the first Element Node(Root Node) of the
- DOM object and check the string returned by the
- "getNodeName()" method. It should be equal to its
- tagName.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
- */
- hc_nodeelementnodename: function(test) {
- var doc = hc_staff.hc_staff();
- test.equal(doc.documentElement.nodeName, 'HTML')
- test.done();
- },
- /**
- *
- The "getNodeType()" method for an Element Node
- returns the constant value 1.
- Retrieve the root node and invoke the "getNodeType()"
- method. The method should return 1.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
- */
- hc_nodeelementnodetype: function(test) {
- var success;
- var doc;
- var rootNode;
- var nodeType;
- doc = hc_staff.hc_staff();
- rootNode = doc.documentElement;
- nodeType = rootNode.nodeType;
- test.equal(nodeType, 1, 'nodeElementNodeTypeAssert1');
- test.done();
- },
- /**
- *
- The string returned by the "getNodeValue()" method for an
- Element Node is null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
- */
- hc_nodeelementnodevalue: function(test) {
- var success;
- var doc;
- var elementNode;
- var elementValue;
- doc = hc_staff.hc_staff();
- elementNode = doc.documentElement;
- elementValue = elementNode.nodeValue;
- test.equal(elementValue, null, 'elementNodeValue');
- test.done();
- },
- /**
- *
- The "getFirstChild()" method returns the first child
- of this node.
- Retrieve the second employee and invoke the
- "getFirstChild()" method. The NodeName returned
- should be "#text" or "EM".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-169727388
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_nodegetfirstchild: function(test) {
- var doc = hc_staff.hc_staff();
- var fchildNode = doc.getElementsByTagName("p").item(1).firstChild;
- test.equal(fchildNode.nodeName, "#text", 'firstChild_w_whitespace');
- test.done();
- },
- /**
- *
- If there is not a first child then the "getFirstChild()"
- method returns null.
- Retrieve the text of the first "em" element and invoke the "getFirstChild()" method. It
- should return null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-169727388
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_nodegetfirstchildnull: function(test) {
- var doc = hc_staff.hc_staff();
- emText = doc.getElementsByTagName("em").item(0).firstChild;
- test.equal(emText.firstChild, null, 'nullChild');
- test.done();
- },
- /**
- *
- The "getLastChild()" method returns the last child
- of this node.
- Retrieve the second employee and invoke the
- "getLastChild()" method. The NodeName returned
- should be "#text".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-61AD09FB
- */
- hc_nodegetlastchild: function(test) {
- var success;
- var doc;
- var elementList;
- var employeeNode;
- var lchildNode;
- var childName;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("p");
- employeeNode = elementList.item(1);
- lchildNode = employeeNode.lastChild;
- childName = lchildNode.nodeName;
- test.equal(childName, "#text", 'whitespace');
- test.done();
- },
- /**
- *
- If there is not a last child then the "getLastChild()"
- method returns null.
- Retrieve the text of the first "em" element and invoke the "getFirstChild()" method. It
- should return null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-61AD09FB
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_nodegetlastchildnull: function(test) {
- var success;
- var doc;
- var emList;
- var emNode;
- var emText;
- var nullChild;
- doc = hc_staff.hc_staff();
- emList = doc.getElementsByTagName("em");
- emNode = emList.item(0);
- emText = emNode.firstChild;
- nullChild = emText.lastChild;
- test.equal(nullChild, null, 'nullChild');
- test.done();
- },
- /**
- *
- The "getNextSibling()" method returns the node immediately
- following this node.
- Retrieve the first child of the second employee and
- invoke the "getNextSibling()" method. It should return
- a node with the NodeName of "#text".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F
- */
- hc_nodegetnextsibling: function(test) {
- var success;
- var doc;
- var elementList;
- var emNode;
- var nsNode;
- var nsName;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("em");
- emNode = elementList.item(1);
- nsNode = emNode.nextSibling;
- nsName = nsNode.nodeName;
- test.equal(nsName, "#text", 'whitespace');
- test.done();
- },
- /**
- *
- If there is not a node immediately following this node the
- "getNextSibling()" method returns null.
- Retrieve the first child of the second employee and
- invoke the "getNextSibling()" method. It should
- be set to null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F
- */
- hc_nodegetnextsiblingnull: function(test) {
- var success;
- var doc;
- var elementList;
- var employeeNode;
- var lcNode;
- var nsNode;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("p");
- employeeNode = elementList.item(1);
- lcNode = employeeNode.lastChild;
- nsNode = lcNode.nextSibling;
- test.equal(nsNode, null, 'nodeGetNextSiblingNullAssert1');
- test.done();
- },
- /**
- *
- Evaluate Node.ownerDocument on the second "p" element.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#node-ownerDoc
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
- */
- hc_nodegetownerdocument: function(test) {
- var doc = hc_staff.hc_staff();
- var elementName = doc.getElementsByTagName("p").item(1).ownerDocument.documentElement.nodeName;
- test.equal(elementName, 'HTML')
- test.done();
- },
- /**
- *
- The "getOwnerDocument()" method returns null if the target
- node itself is a document.
- Invoke the "getOwnerDocument()" method on the master
- document. The Document returned should be null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#node-ownerDoc
- */
- hc_nodegetownerdocumentnull: function(test) {
- var success;
- var doc;
- var ownerDocument;
- doc = hc_staff.hc_staff();
- ownerDocument = doc.ownerDocument;
- test.equal(ownerDocument, null, 'nodeGetOwnerDocumentNullAssert1');
- test.done();
- },
- /**
- *
- The "getPreviousSibling()" method returns the node
- immediately preceding this node.
- Retrieve the second child of the second employee and
- invoke the "getPreviousSibling()" method. It should
- return a node with a NodeName of "#text".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8
- */
- hc_nodegetprevioussibling: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var psNode;
- var psName;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("strong");
- nameNode = elementList.item(1);
- psNode = nameNode.previousSibling;
- psName = psNode.nodeName;
- test.equal(psName, "#text", 'whitespace');
- test.done();
- },
- /**
- *
- If there is not a node immediately preceding this node the
- "getPreviousSibling()" method returns null.
- Retrieve the first child of the second employee and
- invoke the "getPreviousSibling()" method. It should
- be set to null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8
- */
- hc_nodegetprevioussiblingnull: function(test) {
- var success;
- var doc;
- var elementList;
- var employeeNode;
- var fcNode;
- var psNode;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("p");
- employeeNode = elementList.item(2);
- fcNode = employeeNode.firstChild;
- psNode = fcNode.previousSibling;
- test.equal(psNode, null, 'nodeGetPreviousSiblingNullAssert1');
- test.done();
- },
- /**
- *
- The "hasChildNodes()" method returns true if the node
- has children.
- Retrieve the root node("staff") and invoke the
- "hasChildNodes()" method. It should return the boolean
- value "true".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-810594187
- */
- hc_nodehaschildnodes: function(test) {
- var success;
- var doc;
- var elementList;
- var employeeNode;
- var state;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("p");
- employeeNode = elementList.item(1);
- state = employeeNode.hasChildNodes();
- test.ok(state, 'nodeHasChildAssert1');
- test.done();
- },
- /**
- *
- The "hasChildNodes()" method returns false if the node
- does not have any children.
- Retrieve the text of the first "em" element and invoke the "hasChildNodes()" method. It
- should return false.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-810594187
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_nodehaschildnodesfalse: function(test) {
- var success;
- var doc;
- var emList;
- var emNode;
- var emText;
- var hasChild;
- doc = hc_staff.hc_staff();
- emList = doc.getElementsByTagName("em");
- emNode = emList.item(0);
- emText = emNode.firstChild;
- hasChild = emText.hasChildNodes();
- test.equal(hasChild, false, 'hasChild');
- test.done();
- },
- /**
- *
- The "insertBefore(newChild,refChild)" method inserts the
- node "newChild" before the node "refChild".
- Insert a newly created Element node before the second
- sup element in the document and check the "newChild"
- and "refChild" after insertion for correct placement.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=261
- */
- hc_nodeinsertbefore: function(test) {
- var success;
- var doc;
- var elementList;
- var employeeNode;
- var childList;
- var refChild;
- var newChild;
- var child;
- var childName;
- var insertedNode;
- var actual = new Array();
- expected = ["EM", "STRONG", "CODE", "BR", "SUP", "VAR", "ACRONYM"];
- var nodeType;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("sup");
- refChild = elementList.item(2);
- employeeNode = refChild.parentNode;
- childList = employeeNode.childNodes;
- newChild = doc.createElement("br");
- insertedNode = employeeNode.insertBefore(newChild,refChild);
- for(var indexN10091 = 0;indexN10091 < childList.length; indexN10091++) {
- child = childList.item(indexN10091);
- nodeType = child.nodeType;
- if(
- (1 == nodeType)
- ) {
- childName = child.nodeName;
- actual[actual.length] = childName;
- }
- }
- test.deepEqual(actual, expected, 'element nodeNames');
- test.done();
- },
- /**
- *
- If the "newChild" is a DocumentFragment object then all
- its children are inserted in the same order before the
- the "refChild".
- Create a DocumentFragment object and populate it with
- two Element nodes. Retrieve the second employee and
- insert the newly created DocumentFragment before its
- fourth child. The second employee should now have two
- extra children("newChild1" and "newChild2") at
- positions fourth and fifth respectively.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- */
- hc_nodeinsertbeforedocfragment: function(test) {
- var doc = hc_staff.hc_staff();
- var employeeNode = doc.getElementsByTagName("p").item(1);
- refChild = employeeNode.childNodes.item(3);
- var newdocFragment = doc.createDocumentFragment();
- newdocFragment.appendChild(doc.createElement("br"));
- newdocFragment.appendChild(doc.createElement("b"));
- employeeNode.insertBefore(newdocFragment,refChild);
- test.equal(employeeNode.childNodes.item(3).nodeName, 'BR', 'element childName3');
- test.equal(employeeNode.childNodes.item(4).nodeName, 'B', 'element childName4');
- test.done();
- },
- /**
- *
- The "insertBefore(newChild,refChild)" method raises a
- HIERARCHY_REQUEST_ERR DOMException if this node is of
- a type that does not allow children of the type "newChild"
- to be inserted.
- Retrieve the root node and attempt to insert a newly
- created Attr node. An Element node cannot have children
- of the "Attr" type, therefore the desired exception
- should be raised.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=406
- */
- hc_nodeinsertbeforeinvalidnodetype: function(test) {
- var doc = hc_staff.hc_staff();
- var newChild = doc.createAttribute("title");
- var refChild = doc.getElementsByTagName("p").item(1);
- var rootNode = refChild.parentNode;
- var success = false;
- try {
- rootNode.insertBefore(newChild,refChild);
- }
- catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 3);
- }
- test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
- test.done();
- },
- /**
- *
- The "insertBefore(newChild,refChild)" method raises a
- WRONG_DOCUMENT_ERR DOMException if the "newChild" was
- created from a different document than the one that
- created this node.
- Retrieve the second employee and attempt to insert a new
- child that was created from a different document than the
- one that created the second employee. An attempt to
- insert such a child should raise the desired exception.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- */
- hc_nodeinsertbeforenewchilddiffdocument: function(test) {
- var doc1 = hc_staff.hc_staff();
- var doc2 = hc_staff.hc_staff();
- var newChild = doc1.createElement("br");
- var elementNode = doc2.getElementsByTagName("p").item(1);
- var refChild = elementNode.firstChild;
- var success = false;
- try {
- elementNode.insertBefore(newChild,refChild);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 4);
- }
- test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
- test.done();
- },
- /**
- *
- If the "newChild" is already in the tree, the
- "insertBefore(newChild,refChild)" method must first
- remove it before the insertion takes place.
- Insert a node Element ("em") that is already
- present in the tree. The existing node should be
- removed first and the new one inserted. The node is
- inserted at a different position in the tree to assure
- that it was indeed inserted.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_nodeinsertbeforenewchildexists: function(test) {
- var success;
- var doc;
- var elementList;
- var employeeNode;
- var childList;
- var refChild;
- var newChild;
- var child;
- var childName;
- var insertedNode;
- expected = ["STRONG", "CODE", "SUP", "VAR", "EM", "ACRONYM"];
- var result = new Array();
- var nodeType;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("p");
- employeeNode = elementList.item(1);
- childList = employeeNode.getElementsByTagName("*");
- refChild = childList.item(5);
- newChild = childList.item(0);
- insertedNode = employeeNode.insertBefore(newChild,refChild);
- for(var indexN1008C = 0;indexN1008C < childList.length; indexN1008C++) {
- child = childList.item(indexN1008C);
- nodeType = child.nodeType;
- if(
- (1 == nodeType)
- ) {
- childName = child.nodeName;
- result[result.length] = childName;
- }
- }
- test.deepEqual(result, expected, 'element childNames');
- test.done();
- },
- /**
- *
- The "insertBefore(newChild,refChild)" method raises a
- HIERARCHY_REQUEST_ERR DOMException if the node to be
- inserted is one of this nodes ancestors.
- Retrieve the second employee and attempt to insert a
- node that is one of its ancestors(root node). An
- attempt to insert such a node should raise the
- desired exception.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- */
- hc_nodeinsertbeforenodeancestor: function(test) {
- var doc = hc_staff.hc_staff();
- var newChild = doc.documentElement;
- var employeeNode = doc.getElementsByTagName("p").item(1);
- var refChild = employeeNode.childNodes.item(0);
- var success = false;
- try {
- employeeNode.insertBefore(newChild,refChild);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 3);
- }
- test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
- test.done();
- },
- /**
- *
- The "insertBefore(newChild,refchild)" method returns
- the node being inserted.
- Insert an Element node before the fourth
- child of the second employee and check the node
- returned from the "insertBefore(newChild,refChild)"
- method. The node returned should be "newChild".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- */
- hc_nodeinsertbeforenodename: function(test) {
- var doc = hc_staff.hc_staff();
- var employeeNode = doc.getElementsByTagName("p").item(1);
- var refChild = employeeNode.childNodes.item(3);
- var newChild = doc.createElement("br");
- var insertedNode = employeeNode.insertBefore(newChild,refChild);
- test.equal(insertedNode.nodeName, 'BR', 'element nodeName');
- test.done();
- },
- /**
- *
- The "insertBefore(newChild,refChild)" method raises a
- NOT_FOUND_ERR DOMException if the reference child is
- not a child of this node.
- Retrieve the second employee and attempt to insert a
- new node before a reference node that is not a child
- of this node. An attempt to insert before a non child
- node should raise the desired exception.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- */
- hc_nodeinsertbeforerefchildnonexistent: function(test) {
- var doc = hc_staff.hc_staff();
- var newChild = doc.createElement("br");
- var refChild = doc.createElement("b");
- var elementNode = doc.getElementsByTagName("p").item(1);
- var success = false;
- try {
- elementNode.insertBefore(newChild,refChild);
- }
- catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 8);
- }
- test.ok(success, 'throw_NOT_FOUND_ERR');
- test.done();
- },
- /**
- *
- If the "refChild" is null then the
- "insertBefore(newChild,refChild)" method inserts the
- node "newChild" at the end of the list of children.
- Retrieve the second employee and invoke the
- "insertBefore(newChild,refChild)" method with
- refChild=null. Since "refChild" is null the "newChild"
- should be added to the end of the list. The last item
- in the list is checked after insertion. The last Element
- node of the list should be "newChild".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- */
- hc_nodeinsertbeforerefchildnull: function(test) {
- var refChild = null;
- var doc = hc_staff.hc_staff();
- var employeeNode = doc.getElementsByTagName("p").item(1);
- var newChild = doc.createElement("br");
- employeeNode.insertBefore(newChild,refChild);
- test.equal(employeeNode.lastChild.nodeName, 'BR', 'element nodeName');
- test.done();
- },
- /**
- *
- Create a list of all the children elements of the third
- employee and access its first child by using an index
- of 0. This should result in the whitspace before "em" being
- selected (em when ignoring whitespace).
- Further we evaluate its content(by using
- the "getNodeName()" method) to ensure the proper
- element was accessed.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_nodelistindexequalzero: function(test) {
- var doc = hc_staff.hc_staff();
- employeeList = doc.getElementsByTagName("p").item(2).childNodes;
- test.equal(employeeList.item(0).nodeName, "#text", 'childName_w_whitespace');
- test.done();
- },
- /**
- *
- The "getLength()" method returns the number of nodes
- in the list.
- Create a list of all the children elements of the third
- employee and invoke the "getLength()" method.
- It should contain the value 13.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_nodelistindexgetlength: function(test) {
- var success;
- var doc;
- var elementList;
- var employeeNode;
- var employeeList;
- var length;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("p");
- employeeNode = elementList.item(2);
- employeeList = employeeNode.childNodes;
- length = employeeList.length;
- if(
- (6 == length)
- ) {
- test.equal(length, 6, 'length_wo_space');
- }
- else {
- test.equal(length, 13, 'length_w_space');
- }
- test.done();
- },
- /**
- *
- The "getLength()" method returns the number of nodes
- in the list.(Test for EMPTY list)
- Create a list of all the children of the Text node
- inside the first child of the third employee and
- invoke the "getLength()" method. It should contain
- the value 0.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_nodelistindexgetlengthofemptylist: function(test) {
- var success;
- var doc;
- var emList;
- var emNode;
- var textNode;
- var textList;
- var length;
- doc = hc_staff.hc_staff();
- emList = doc.getElementsByTagName("em");
- emNode = emList.item(2);
- textNode = emNode.firstChild;
- textList = textNode.childNodes;
- length = textList.length;
- test.equal(length, 0, 'length');
- test.done();
- },
- /**
- *
- The items in the list are accessible via an integral
- index starting from zero.
- (Index not equal 0)
- Create a list of all the children elements of the third
- employee and access its fourth child by using an index
- of 3 and calling getNodeName() which should return
- "strong" (no whitespace) or "#text" (with whitespace).
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_nodelistindexnotzero: function(test) {
- var doc = hc_staff.hc_staff();
- child = doc.getElementsByTagName("p").item(2).childNodes.item(3);
- test.equal(child.nodeName, 'STRONG', 'element childName_strong');
- test.done();
- },
- /**
- *
- Create a list of all the children elements of the third
- employee and access its first child by invoking the
- "item(index)" method with an index=0. This should
- result in node with a nodeName of "#text" or "em".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_nodelistreturnfirstitem: function(test) {
- var doc = hc_staff.hc_staff();
- var child = doc.getElementsByTagName("p").item(2).childNodes.item(0);
- test.equal(child.nodeName, "#text", 'nodeName_w_space');
- test.done();
- },
- /**
- *
- Create a list of all the children elements of the third
- employee and access its last child by invoking the
- "item(index)" method with an index=length-1. This should
- result in node with nodeName="#text" or acronym.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_nodelistreturnlastitem: function(test) {
- var doc = hc_staff.hc_staff();
- var employeeList = doc.getElementsByTagName("p").item(2).childNodes;
- var child = employeeList.item(employeeList.length-1);
- test.equal(child.nodeName, "#text", 'lastNodeName_w_whitespace');
- test.done();
- },
- /**
- *
- The range of valid child node indices is 0 thru length -1
- Create a list of all the children elements of the third
- employee and traverse the list from index=0 thru
- length -1.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_nodelisttraverselist: function(test) {
- var success;
- var doc;
- var elementList;
- var employeeNode;
- var employeeList;
- var child;
- var childName;
- var nodeType;
- var result = new Array();
- expected = ["EM", "STRONG", "CODE", "SUP", "VAR", "ACRONYM"];
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("p");
- employeeNode = elementList.item(2);
- employeeList = employeeNode.childNodes;
- for(var indexN10073 = 0;indexN10073 < employeeList.length; indexN10073++) {
- child = employeeList.item(indexN10073);
- nodeType = child.nodeType;
- childName = child.nodeName;
- if(
- (1 == nodeType)
- ) {
- result[result.length] = childName;
- }
- else {
- test.equal(nodeType, 3, 'textNodeType');
- test.equal(childName, "#text", 'textNodeName');
- }
- }
- test.deepEqual(result, expected, 'element nodeNames');
- test.done();
- },
- /**
- *
- The "getParentNode()" method returns the parent
- of this node.
- Retrieve the second employee and invoke the
- "getParentNode()" method on this node. It should
- be set to "body".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317
- */
- hc_nodeparentnode: function(test) {
- var doc = hc_staff.hc_staff();
- var parentNode = doc.getElementsByTagName("p").item(1).parentNode;
- test.equal(parentNode.nodeName, 'BODY', 'element parentNodeName');
- test.done();
- },
- /**
- *
- The "getParentNode()" method invoked on a node that has
- just been created and not yet added to the tree is null.
- Create a new "employee" Element node using the
- "createElement(name)" method from the Document interface.
- Since this new node has not yet been added to the tree,
- the "getParentNode()" method will return null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- */
- hc_nodeparentnodenull: function(test) {
- var success;
- var doc;
- var createdNode;
- var parentNode;
- doc = hc_staff.hc_staff();
- createdNode = doc.createElement("br");
- parentNode = createdNode.parentNode;
- test.equal(parentNode, null, 'parentNode');
- test.done();
- },
- /**
- *
- The "removeChild(oldChild)" method removes the child node
- indicated by "oldChild" from the list of children and
- returns it.
- Remove the first employee by invoking the
- "removeChild(oldChild)" method an checking the
- node returned by the "getParentNode()" method. It
- should be set to null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- */
- hc_noderemovechild: function(test) {
- var success;
- var doc;
- var rootNode;
- var childList;
- var childToRemove;
- var removedChild;
- var parentNode;
- doc = hc_staff.hc_staff();
- rootNode = doc.documentElement;
- childList = rootNode.childNodes;
- childToRemove = childList.item(1);
- removedChild = rootNode.removeChild(childToRemove);
- parentNode = removedChild.parentNode;
- test.equal(parentNode, null, 'parentNodeNull');
- test.done();
- },
- /**
- *
- The "removeChild(oldChild)" method returns
- the node being removed.
- Remove the first child of the second employee
- and check the NodeName returned by the
- "removeChild(oldChild)" method. The returned node
- should have a NodeName equal to "#text".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_noderemovechildgetnodename: function(test) {
- var success;
- var doc;
- var elementList;
- var employeeNode;
- var childList;
- var oldChild;
- var removedChild;
- var childName;
- var oldName;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("p");
- employeeNode = elementList.item(1);
- childList = employeeNode.childNodes;
- oldChild = childList.item(0);
- oldName = oldChild.nodeName;
- removedChild = employeeNode.removeChild(oldChild);
- test.notEqual(removedChild, null, 'notnull');
- childName = removedChild.nodeName;
- test.equal(childName, oldName, 'nodeName');
- test.done();
- },
- /**
- *
- The "removeChild(oldChild)" method removes the node
- indicated by "oldChild".
- Retrieve the second p element and remove its first child.
- After the removal, the second p element should have 5 element
- children and the first child should now be the child
- that used to be at the second position in the list.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_noderemovechildnode: function(test) {
- var doc = hc_staff.hc_staff();
- var employeeNode = doc.getElementsByTagName("p").item(1);
- var childList = employeeNode.childNodes;
- var oldChild = employeeNode.getElementsByTagName("em").item(0);
- var removedChild = employeeNode.removeChild(oldChild);
- test.equal(removedChild.nodeName, 'EM', 'element removedName');
- var actual = [];
- for(var i=0;i<childList.length;i++) {
- if (1 == childList.item(i).nodeType) {
- actual.push(childList.item(i).nodeName);
- } else {
- test.equal(childList.item(i).nodeType, 3, 'textNodeType');
- test.equal(childList.item(i).nodeName, "#text", 'textNodeName');
- }
- }
- test.deepEqual(actual, ['STRONG', 'CODE', 'SUP', 'VAR', 'ACRONYM'], 'element childNames')
- test.done();
- },
- /**
- *
- The "removeChild(oldChild)" method raises a
- NOT_FOUND_ERR DOMException if the old child is
- not a child of this node.
- Retrieve the second employee and attempt to remove a
- node that is not one of its children. An attempt to
- remove such a node should raise the desired exception.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- */
- hc_noderemovechildoldchildnonexistent: function(test) {
- var doc = hc_staff.hc_staff();
- var oldChild = doc.createElement("br");
- var elementNode = doc.getElementsByTagName("p").item(1);
- var success = false;
- try {
- elementNode.removeChild(oldChild);
- }
- catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 8);
- }
- test.ok(success, 'throw_NOT_FOUND_ERR');
- test.done();
- },
- /**
- *
- The "replaceChild(newChild,oldChild)" method replaces
- the node "oldChild" with the node "newChild".
- Replace the first element of the second employee with
- a newly created Element node. Check the first position
- after the replacement operation is completed. The new
- Element should be "newChild".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- */
- hc_nodereplacechild: function(test) {
- var doc = hc_staff.hc_staff();
- var employeeNode = doc.getElementsByTagName("p").item(1);
- var oldChild = employeeNode.childNodes.item(0);
- var newChild = doc.createElement("br");
- employeeNode.replaceChild(newChild,oldChild);
- var child = employeeNode.childNodes.item(0);
- test.equal(child.nodeName, 'BR', 'element nodeName');
- test.done();
- },
- /**
- *
- The "replaceChild(newChild,oldChild)" method raises a
- HIERARCHY_REQUEST_ERR DOMException if this node is of
- a type that does not allow children of the type "newChild"
- to be inserted.
- Retrieve the root node and attempt to replace
- one of its children with a newly created Attr node.
- An Element node cannot have children of the "Attr"
- type, therefore the desired exception should be raised.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=406
- */
- hc_nodereplacechildinvalidnodetype: function(test) {
- var doc = hc_staff.hc_staff();
- var newChild = doc.createAttribute("lang");
- var oldChild = doc.getElementsByTagName("p").item(1);
- var rootNode = oldChild.parentNode;
- var success = false;
- try {
- rootNode.replaceChild(newChild,oldChild);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 3);
- }
- test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
- test.done();
- },
- /**
- *
- The "replaceChild(newChild,oldChild)" method raises a
- WRONG_DOCUMENT_ERR DOMException if the "newChild" was
- created from a different document than the one that
- created this node.
- Retrieve the second employee and attempt to replace one
- of its children with a node created from a different
- document. An attempt to make such a replacement
- should raise the desired exception.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- */
- hc_nodereplacechildnewchilddiffdocument: function(test) {
- var doc1 = hc_staff.hc_staff();
- var doc2 = hc_staff.hc_staff();
- var newChild = doc1.createElement("br");
- var elementNode = doc2.getElementsByTagName("p").item(1);
- var oldChild = elementNode.firstChild;
- var success = false;
- try {
- elementNode.replaceChild(newChild,oldChild);
- }
- catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 4);
- }
- test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
- test.done();
- },
- /**
- *
- If the "newChild" is already in the tree, it is first
- removed before the new one is added.
- Retrieve the second "p" and replace "acronym" with its "em".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
- */
- hc_nodereplacechildnewchildexists: function(test) {
- var actual = [];
- var expected = ["STRONG", "CODE", "SUP", "VAR", "EM"];
- var doc = hc_staff.hc_staff();
- var employeeNode = doc.getElementsByTagName("p").item(1);
- var childList = employeeNode.getElementsByTagName("*");
- var newChild = childList.item(0);
- var oldChild = childList.item(5);
- var replacedChild = employeeNode.replaceChild(newChild,oldChild);
- test.equal(replacedChild, oldChild, 'return_value_same');
- for(var i=0;i<childList.length;i++) {
- if (1 == childList.item(i).nodeType) {
- actual.push(childList.item(i).nodeName)
- } else {
- test.equal(childList.item(i).nodeType, 3, 'textNodeType');
- test.equal(childList.item(i).nodeName, "#text", 'textNodeName');
- }
- }
- test.deepEqual(actual, expected, 'element childNames');
- test.done();
- },
- /**
- *
- The "replaceChild(newChild,oldChild)" method raises a
- HIERARCHY_REQUEST_ERR DOMException if the node to put
- in is one of this node's ancestors.
- Retrieve the second employee and attempt to replace
- one of its children with an ancestor node(root node).
- An attempt to make such a replacement should raise the
- desired exception.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
- */
- hc_nodereplacechildnodeancestor: function(test) {
- var doc = hc_staff.hc_staff();
- var newChild = doc.documentElement;
- var employeeNode = doc.getElementsByTagName("p").item(1);
- var oldChild = employeeNode.childNodes.item(0);
- var success = false;
- try {
- employeeNode.replaceChild(newChild,oldChild);
- }
- catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 3);
- }
- test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
- test.done();
- },
- /**
- *
- The "replaceChild(newChild,oldChild)" method returns
- the node being replaced.
- Replace the second Element of the second employee with
- a newly created node Element and check the NodeName
- returned by the "replaceChild(newChild,oldChild)"
- method. The returned node should have a NodeName equal
- to "em".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- */
- hc_nodereplacechildnodename: function(test) {
- var doc = hc_staff.hc_staff();
- var employeeNode = doc.getElementsByTagName("p").item(1);
- var oldChild = employeeNode.getElementsByTagName("em").item(0);
- var newChild = doc.createElement("br");
- var replacedNode = employeeNode.replaceChild(newChild,oldChild);
- test.equal(replacedNode.nodeName, 'EM', 'element replacedNodeName');
- test.done();
- },
- /**
- *
- The "replaceChild(newChild,oldChild)" method raises a
- NOT_FOUND_ERR DOMException if the old child is
- not a child of this node.
- Retrieve the second employee and attempt to replace a
- node that is not one of its children. An attempt to
- replace such a node should raise the desired exception.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
- * @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'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
- */
- hc_nodereplacechildoldchildnonexistent: function(test) {
- var doc = hc_staff.hc_staff();
- var newChild = doc.createElement("br");
- var oldChild = doc.createElement("b");
- var elementNode = doc.getElementsByTagName("p").item(1);
- var success = false;
- try {
- elementNode.replaceChild(newChild,oldChild);
- }
- catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 8);
- }
- test.ok(success, 'throw_NOT_FOUND_ERR');
- test.done();
- },
- /**
- *
- The "getAttributes()" method invoked on a Text
- Node returns null.
- Retrieve the Text node from the last child of the
- first employee and invoke the "getAttributes()" method
- on the Text Node. It should return null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1312295772
- */
- hc_nodetextnodeattribute: function(test) {
- var success;
- var doc;
- var elementList;
- var testAddr;
- var textNode;
- var attrList;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testAddr = elementList.item(0);
- textNode = testAddr.firstChild;
- attrList = textNode.attributes;
- test.equal(attrList, null, 'text_attributes_is_null');
- test.done();
- },
- /**
- *
- The string returned by the "getNodeName()" method for a
- Text Node is "#text".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
- */
- hc_nodetextnodename: function(test) {
- var success;
- var doc;
- var elementList;
- var testAddr;
- var textNode;
- var textName;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testAddr = elementList.item(0);
- textNode = testAddr.firstChild;
- textName = textNode.nodeName;
- test.equal(textName, "#text", 'textNodeName');
- test.done();
- },
- /**
- *
- The "getNodeType()" method for a Text Node
- returns the constant value 3.
- Retrieve the Text node from the last child of
- the first employee and invoke the "getNodeType()"
- method. The method should return 3.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
- */
- hc_nodetextnodetype: function(test) {
- var success;
- var doc;
- var elementList;
- var testAddr;
- var textNode;
- var nodeType;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testAddr = elementList.item(0);
- textNode = testAddr.firstChild;
- nodeType = textNode.nodeType;
- test.equal(nodeType, 3, 'nodeTextNodeTypeAssert1');
- test.done();
- },
- /**
- *
- The string returned by the "getNodeValue()" method for a
- Text Node is the content of the Text node.
- Retrieve the Text node from the last child of the first
- employee and check the string returned by the
- "getNodeValue()" method. It should be equal to
- "1230 North Ave. Dallas, Texas 98551".
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
- */
- hc_nodetextnodevalue: function(test) {
- var success;
- var doc;
- var elementList;
- var testAddr;
- var textNode;
- var textValue;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- testAddr = elementList.item(0);
- textNode = testAddr.firstChild;
- textValue = textNode.nodeValue;
- test.equal(textValue, "1230 North Ave. Dallas, Texas 98551", 'textNodeValue');
- test.done();
- },
- /**
- *
- An element is created, setNodeValue is called with a non-null argument, but getNodeValue
- should still return null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
- */
- hc_nodevalue01: function(test) {
- var success;
- var doc;
- var newNode;
- var newValue;
- doc = hc_staff.hc_staff();
- newNode = doc.createElement("acronym");
- newValue = newNode.nodeValue;
- test.equal(newValue, null, 'initiallyNull');
- newNode.nodeValue = "This should have no effect";
- newValue = newNode.nodeValue;
- test.equal(newValue, null, 'nullAfterAttemptedChange');
- test.done();
- },
- /**
- *
- An comment is created, setNodeValue is called with a non-null argument, but getNodeValue
- should still return null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
- */
- hc_nodevalue02: function(test) {
- var success;
- var doc;
- var newNode;
- var newValue;
- doc = hc_staff.hc_staff();
- newNode = doc.createComment("This is a new Comment node");
- newValue = newNode.nodeValue;
- test.equal(newValue, "This is a new Comment node", 'initial');
- newNode.nodeValue = "This should have an effect";
- newValue = newNode.nodeValue;
- test.equal(newValue, "This should have an effect", 'afterChange');
- test.done();
- },
- /**
- *
- An entity reference is created, setNodeValue is called with a non-null argument, but getNodeValue
- should still return null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-11C98490
- */
- hc_nodevalue03: function(test) {
- doc = hc_staff.hc_staff();
- success = false;
- try {
- doc.createEntityReference("ent1");
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 9);
- }
- test.ok(success, 'throw_NOT_SUPPORTED_ERR');
- test.done();
- },
- /**
- *
- An document type accessed, setNodeValue is called with a non-null argument, but getNodeValue
- should still return null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31
- */
- hc_nodevalue04: function(test) {
- var doc = hc_staff.hc_staff();
- var newNode = doc.doctype;
- test.notEqual(newNode, null, 'docTypeNotNullOrDocIsHTML');
- test.notEqual(newNode, null, 'docTypeNotNull');
- test.equal(newNode.nodeValue, null, 'initiallyNull');
- newNode.nodeValue = "This should have no effect";
- test.equal(newNode.nodeValue, null, 'nullAfterAttemptedChange');
- test.done();
- },
- /**
- *
- A document fragment is created, setNodeValue is called with a non-null argument, but getNodeValue
- should still return null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
- */
- hc_nodevalue05: function(test) {
- var success;
- var doc;
- var newNode;
- var newValue;
- doc = hc_staff.hc_staff();
- newNode = doc.createDocumentFragment();
- newValue = newNode.nodeValue;
- test.equal(newValue, null, 'initiallyNull');
- newNode.nodeValue = "This should have no effect";
- newValue = newNode.nodeValue;
- test.equal(newValue, null, 'nullAfterAttemptedChange');
- test.done();
- },
- /**
- *
- An document is accessed, setNodeValue is called with a non-null argument, but getNodeValue
- should still return null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
- */
- hc_nodevalue06: function(test) {
- var success;
- var newNode;
- var newValue;
- newNode = hc_staff.hc_staff();
- newValue = newNode.nodeValue;
- test.equal(newValue, null, 'initiallyNull');
- newNode.nodeValue = "This should have no effect";
- newValue = newNode.nodeValue;
- test.equal(newValue, null, 'nullAfterAttemptedChange');
- test.done();
- },
- /**
- *
- An Entity is accessed, setNodeValue is called with a non-null argument, but getNodeValue
- should still return null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-527DCFF2
- */
- hc_nodevalue07: function(test) {
- // NOTE: no tests run here...
- test.done();
- },
- /**
- *
- An notation is accessed, setNodeValue is called with a non-null argument, but getNodeValue
- should still return null.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5431D1B9
- */
- hc_nodevalue08: function(test) {
- // NOTE: no tests run here...
- test.done();
- },
- /**
- *
- An attempt to add remove an notation should result in a NO_MODIFICATION_ERR.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D46829EF
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193
- */
- hc_notationsremovenameditem1: function(test) {
- // NOTE: no tests run here
- test.done();
- },
- /**
- *
- An attempt to add an element to the named node map returned by notations should
- result in a NO_MODIFICATION_ERR or HIERARCHY_REQUEST_ERR.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D46829EF
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
- */
- hc_notationssetnameditem1: function(test) {
- // NOTE: no tests run here
- test.done();
- },
- /**
- *
- The "splitText(offset)" method raises an
- INDEX_SIZE_ERR DOMException if the specified offset is
- negative.
- Retrieve the textual data from the second child of the
- third employee and invoke the "splitText(offset)" method.
- The desired exception should be raised since the offset
- is a negative number.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
- * @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'])
- */
- hc_textindexsizeerrnegativeoffset: function(test) {
- var doc = hc_staff.hc_staff();
- var textNode = doc.getElementsByTagName("strong").item(2).firstChild;
- var success = false;
- try {
- textNode.splitText(-69);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 1);
- }
- test.ok(success, 'throws_INDEX_SIZE_ERR');
- test.done();
- },
- /**
- *
- The "splitText(offset)" method raises an
- INDEX_SIZE_ERR DOMException if the specified offset is
- greater than the number of characters in the Text node.
- Retrieve the textual data from the second child of the
- third employee and invoke the "splitText(offset)" method.
- The desired exception should be raised since the offset
- is a greater than the number of characters in the Text
- node.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
- * @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'])
- * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
- */
- hc_textindexsizeerroffsetoutofbounds: function(test) {
- var doc = hc_staff.hc_staff();
- var textNode = doc.getElementsByTagName("strong").item(2).firstChild;
- var success = false;
- try {
- textNode.splitText(300);
- } catch(ex) {
- success = (typeof(ex.code) != 'undefined' && ex.code == 1);
- }
- test.ok(success, 'throw_INDEX_SIZE_ERR');
- test.done();
- },
- /**
- *
- Retrieve the textual data from the last child of the
- second employee. That node is composed of two
- EntityReference nodes and two Text nodes. After
- the content node is parsed, the "acronym" Element
- should contain four children with each one of the
- EntityReferences containing one child.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-11C98490
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-745549614
- */
- hc_textparseintolistofelements: function(test) {
- var expectedNormal = ["β", " Dallas, ", "γ", "\n 98554"];
- var expectedExpanded = ["β Dallas, γ\n 98554"];
- var doc = hc_staff.hc_staff();
- var childList = doc.getElementsByTagName("acronym").item(1).childNodes;
- var actual = [];
- for(var i=0;i<childList.length;i++) {
- if (childList.item(i).nodeValue == null) {
- test.notEqual(childList.item(i).firstChild, null, 'grandChildNotNull');
- actual.push(childList.item(i).firstChild.nodeValue);
- } else {
- actual.push(childList.item(i).nodeValue);
- }
- }
- if (1 == childList.length) {
- test.deepEqual(actual, expectedExpanded, 'assertEqCoalescing');
- } else {
- test.deepEqual(actual, expectedNormal, 'assertEqNormal');
- }
- test.done();
- },
- /**
- *
- The "splitText(offset)" method returns the new Text node.
- Retrieve the textual data from the last child of the
- first employee and invoke the "splitText(offset)" method.
- The method should return the new Text node. The offset
- value used for this test is 30. The "getNodeValue()"
- method is called to check that the new node now contains
- the characters at and after position 30.
- (Starting count at 0)
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
- */
- hc_textsplittextfour: function(test) {
- var success;
- var doc;
- var elementList;
- var addressNode;
- var textNode;
- var splitNode;
- var value;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("acronym");
- addressNode = elementList.item(0);
- textNode = addressNode.firstChild;
- splitNode = textNode.splitText(30);
- value = splitNode.nodeValue;
- test.equal(value, "98551", 'textSplitTextFourAssert');
- test.done();
- },
- /**
- *
- The "splitText(offset)" method breaks the Text node into
- two Text nodes at the specified offset keeping each node
- as siblings in the tree.
- Retrieve the textual data from the second child of the
- third employee and invoke the "splitText(offset)" method.
- The method splits the Text node into two new sibling
- Text nodes keeping both of them in the tree. This test
- checks the "nextSibling()" method of the original node
- to ensure that the two nodes are indeed siblings.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
- */
- hc_textsplittextone: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var textNode;
- var splitNode;
- var secondPart;
- var value;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("strong");
- nameNode = elementList.item(2);
- textNode = nameNode.firstChild;
- splitNode = textNode.splitText(7);
- secondPart = textNode.nextSibling;
- value = secondPart.nodeValue;
- test.equal(value, "Jones", 'textSplitTextOneAssert');
- test.done();
- },
- /**
- *
- After the "splitText(offset)" method breaks the Text node
- into two Text nodes, the new Text node contains all the
- content at and after the offset point.
- Retrieve the textual data from the second child of the
- third employee and invoke the "splitText(offset)" method.
- The new Text node should contain all the content
- at and after the offset point. The "getNodeValue()"
- method is called to check that the new node now contains
- the characters at and after position seven.
- (Starting count at 0)
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
- */
- hc_textsplittextthree: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var textNode;
- var splitNode;
- var value;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("strong");
- nameNode = elementList.item(2);
- textNode = nameNode.firstChild;
- splitNode = textNode.splitText(6);
- value = splitNode.nodeValue;
- test.equal(value, " Jones", 'textSplitTextThreeAssert');
- test.done();
- },
- /**
- *
- After the "splitText(offset)" method breaks the Text node
- into two Text nodes, the original node contains all the
- content up to the offset point.
- Retrieve the textual data from the second child of the
- third employee and invoke the "splitText(offset)" method.
- The original Text node should contain all the content
- up to the offset point. The "getNodeValue()" method
- is called to check that the original node now contains
- the first five characters.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
- */
- hc_textsplittexttwo: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var textNode;
- var splitNode;
- var value;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("strong");
- nameNode = elementList.item(2);
- textNode = nameNode.firstChild;
- splitNode = textNode.splitText(5);
- value = textNode.nodeValue;
- test.equal(value, "Roger", 'textSplitTextTwoAssert');
- test.done();
- },
- /**
- *
- If there is not any markup inside an Element or Attr node
- content, then the text is contained in a single object
- implementing the Text interface that is the only child
- of the element.
- Retrieve the textual data from the second child of the
- third employee. That Text node contains a block of
- multiple text lines without markup, so they should be
- treated as a single Text node. The "getNodeValue()"
- method should contain the combination of the two lines.
- * @author Curt Arnold
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1312295772
- * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
- */
- hc_textwithnomarkup: function(test) {
- var success;
- var doc;
- var elementList;
- var nameNode;
- var nodeV;
- var value;
- doc = hc_staff.hc_staff();
- elementList = doc.getElementsByTagName("strong");
- nameNode = elementList.item(2);
- nodeV = nameNode.firstChild;
- value = nodeV.nodeValue;
- test.equal(value, "Roger\n Jones", 'textWithNoMarkupAssert');
- test.done();
- },
- };
|