svg.js 617 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720
  1. var hc_staff = require('./svg/files/hc_staff.svg');
  2. var staff = require('./svg/files/staff.svg');
  3. var hc_nodtdstaff = require('./svg/files/hc_nodtdstaff.svg');
  4. var domTestHelper = require('../DOMTestCase');
  5. exports.tests = {
  6. /**
  7. *
  8. Attr nodes may be associated with Element nodes contained within a DocumentFragment.
  9. Create a new DocumentFragment and add a newly created Element node(with one attribute).
  10. Once the element is added, its attribute should be available as an attribute associated
  11. with an Element within a DocumentFragment.
  12. * @author NIST
  13. * @author Mary Brady
  14. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-35CB04B5
  15. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
  16. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
  17. */
  18. attrcreatedocumentfragment: function(test) {
  19. var success;
  20. var doc;
  21. var docFragment;
  22. var newOne;
  23. var domesticNode;
  24. var domesticAttr;
  25. var attrs;
  26. var attrName;
  27. var appendedChild;
  28. doc = staff.staff();
  29. docFragment = doc.createDocumentFragment();
  30. newOne = doc.createElement("newElement");
  31. newOne.setAttribute("newdomestic","Yes");
  32. appendedChild = docFragment.appendChild(newOne);
  33. domesticNode = docFragment.firstChild;
  34. domesticAttr = domesticNode.attributes;
  35. attrs = domesticAttr.item(0);
  36. attrName = attrs.name;
  37. test.equal(attrName, 'newdomestic', 'attrCreateDocumentFragmentAssert');
  38. test.done();
  39. },
  40. /**
  41. *
  42. The "setValue()" method for an attribute creates a
  43. Text node with the unparsed content of the string.
  44. Retrieve the attribute named "street" from the last
  45. child of of the fourth employee and assign the "Y&ent1;"
  46. string to its value attribute. This value is not yet
  47. parsed and therefore should still be the same upon
  48. retrieval. This test uses the "getNamedItem(name)" method
  49. from the NamedNodeMap interface.
  50. * @author NIST
  51. * @author Mary Brady
  52. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
  53. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Apr/0057.html
  54. */
  55. attrcreatetextnode: function(test) {
  56. var success;
  57. var doc;
  58. var addressList;
  59. var testNode;
  60. var attributes;
  61. var streetAttr;
  62. var value;
  63. doc = staff.staff();
  64. addressList = doc.getElementsByTagName("address");
  65. testNode = addressList.item(3);
  66. attributes = testNode.attributes;
  67. streetAttr = attributes.getNamedItem("street");
  68. streetAttr.value = "Y&ent1;";
  69. value = streetAttr.value;
  70. test.equal(value, 'Y&ent1;', 'value');
  71. value = streetAttr.nodeValue;
  72. test.equal(value, 'Y&ent1;', 'nodeValue');
  73. test.done();
  74. },
  75. /**
  76. *
  77. The "setNodeValue()" method for an attribute creates a
  78. Text node with the unparsed content of the string.
  79. Retrieve the attribute named "street" from the last
  80. child of of the fourth employee and assign the "Y&ent1;"
  81. string to its value attribute. This value is not yet
  82. parsed and therefore should still be the same upon
  83. retrieval. This test uses the "getNamedItem(name)" method
  84. from the NamedNodeMap interface.
  85. * @author Curt Arnold
  86. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  87. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Apr/0057.html
  88. */
  89. attrcreatetextnode2: function(test) {
  90. var success;
  91. var doc;
  92. var addressList;
  93. var testNode;
  94. var attributes;
  95. var streetAttr;
  96. var value;
  97. doc = staff.staff();
  98. addressList = doc.getElementsByTagName("address");
  99. testNode = addressList.item(3);
  100. attributes = testNode.attributes;
  101. streetAttr = attributes.getNamedItem("street");
  102. streetAttr.nodeValue = "Y&ent1;";
  103. value = streetAttr.value;
  104. test.equal(value, 'Y&ent1;', 'value');
  105. value = streetAttr.nodeValue;
  106. test.equal(value, 'Y&ent1;', 'nodeValue');
  107. test.done();
  108. },
  109. /**
  110. *
  111. If there is not an explicit value assigned to an attribute
  112. and there is a declaration for this attribute and that
  113. declaration includes a default value, then that default
  114. value is the attributes default value.
  115. Retrieve the attribute named "street" from the last
  116. child of of the first employee and examine its
  117. value. That value should be the value given the
  118. attribute in the DTD file. The test uses the
  119. "getNamedItem(name)" method from the NamedNodeMap
  120. interface.
  121. * @author NIST
  122. * @author Mary Brady
  123. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  124. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
  125. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html
  126. */
  127. attrdefaultvalue: function(test) {
  128. var success;
  129. var doc;
  130. var addressList;
  131. var testNode;
  132. var attributes;
  133. var streetAttr;
  134. var value;
  135. doc = staff.staff();
  136. addressList = doc.getElementsByTagName("address");
  137. testNode = addressList.item(0);
  138. attributes = testNode.attributes;
  139. streetAttr = attributes.getNamedItem("street");
  140. value = streetAttr.nodeValue;
  141. test.equal(value, 'Yes', 'attrDefaultValueAssert');
  142. test.done();
  143. },
  144. /**
  145. *
  146. If an Attr is explicitly assigned any value, then that value is the attributes effective value.
  147. Retrieve the attribute named "domestic" from the last child of of the first employee
  148. and examine its nodeValue attribute. This test uses the "getNamedItem(name)" method
  149. from the NamedNodeMap interface.
  150. * @author NIST
  151. * @author Mary Brady
  152. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  153. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
  154. */
  155. attreffectivevalue: function(test) {
  156. var success;
  157. var doc;
  158. var addressList;
  159. var testNode;
  160. var attributes;
  161. var domesticAttr;
  162. var value;
  163. doc = staff.staff();
  164. addressList = doc.getElementsByTagName("address");
  165. testNode = addressList.item(0);
  166. attributes = testNode.attributes;
  167. domesticAttr = attributes.getNamedItem("domestic");
  168. value = domesticAttr.nodeValue;
  169. test.equal(value, 'Yes', 'attrEffectiveValueAssert');
  170. test.done();
  171. },
  172. /**
  173. *
  174. The "getValue()" method will return the value of the
  175. attribute as a string. The general entity references
  176. are replaced with their values.
  177. Retrieve the attribute named "street" from the last
  178. child of of the fourth employee and examine the string
  179. returned by the "getValue()" method. The value should
  180. be set to "Yes" after the EntityReference is
  181. replaced with its value. This test uses the
  182. "getNamedItem(name)" method from the NamedNodeMap
  183. interface.
  184. * @author NIST
  185. * @author Mary Brady
  186. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
  187. */
  188. attrentityreplacement: function(test) {
  189. var success;
  190. var doc;
  191. var addressList;
  192. var testNode;
  193. var attributes;
  194. var streetAttr;
  195. var value;
  196. doc = staff.staff();
  197. addressList = doc.getElementsByTagName("address");
  198. testNode = addressList.item(3);
  199. attributes = testNode.attributes;
  200. streetAttr = attributes.getNamedItem("street");
  201. value = streetAttr.value;
  202. test.equal(value, 'Yes', 'streetYes');
  203. test.done();
  204. },
  205. /**
  206. *
  207. The getNodeName() method of an Attribute node.
  208. Retrieve the attribute named street from the last
  209. child of of the second employee and examine its
  210. NodeName. This test uses the getNamedItem(name) method from the NamedNodeMap
  211. interface.
  212. * @author NIST
  213. * @author Mary Brady
  214. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  215. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1112119403
  216. */
  217. attrname: function(test) {
  218. var success;
  219. var doc;
  220. var addressList;
  221. var testNode;
  222. var attributes;
  223. var streetAttr;
  224. var name;
  225. doc = staff.staff();
  226. addressList = doc.getElementsByTagName("address");
  227. testNode = addressList.item(1);
  228. attributes = testNode.attributes;
  229. streetAttr = attributes.getNamedItem("street");
  230. name = streetAttr.nodeName;
  231. test.equal(name, 'street', 'nodeName');
  232. name = streetAttr.name;
  233. test.equal(name, 'street', 'name');
  234. test.done();
  235. },
  236. /**
  237. *
  238. The "getNextSibling()" method for an Attr node should return null.
  239. Retrieve the attribute named "domestic" from the last child of of the
  240. first employee and examine its NextSibling node. This test uses the
  241. "getNamedItem(name)" method from the NamedNodeMap interface.
  242. * @author NIST
  243. * @author Mary Brady
  244. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F
  245. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  246. */
  247. attrnextsiblingnull: function(test) {
  248. var success;
  249. var doc;
  250. var addressList;
  251. var testNode;
  252. var attributes;
  253. var domesticAttr;
  254. var s;
  255. doc = staff.staff();
  256. addressList = doc.getElementsByTagName("address");
  257. testNode = addressList.item(0);
  258. attributes = testNode.attributes;
  259. domesticAttr = attributes.getNamedItem("domestic");
  260. s = domesticAttr.nextSibling;
  261. test.equal(s, null, 'attrNextSiblingNullAssert');
  262. test.done();
  263. },
  264. /**
  265. *
  266. The "getSpecified()" method for an Attr node should
  267. be set to false if the attribute was not explicitly given
  268. a value.
  269. Retrieve the attribute named "street" from the last
  270. child of of the first employee and examine the value
  271. returned by the "getSpecified()" method. This test uses
  272. the "getNamedItem(name)" method from the NamedNodeMap
  273. interface.
  274. * @author NIST
  275. * @author Mary Brady
  276. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-862529273
  277. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html
  278. */
  279. attrnotspecifiedvalue: function(test) {
  280. var success;
  281. var doc;
  282. var addressList;
  283. var testNode;
  284. var attributes;
  285. var streetAttr;
  286. var state;
  287. doc = staff.staff();
  288. addressList = doc.getElementsByTagName("address");
  289. testNode = addressList.item(0);
  290. attributes = testNode.attributes;
  291. streetAttr = attributes.getNamedItem("street");
  292. state = streetAttr.specified;
  293. test.equal(state, false, 'streetNotSpecified');
  294. test.done();
  295. },
  296. /**
  297. *
  298. The "getParentNode()" method for an Attr node should return null. Retrieve
  299. the attribute named "domestic" from the last child of the first employee
  300. and examine its parentNode attribute. This test also uses the "getNamedItem(name)"
  301. method from the NamedNodeMap interface.
  302. * @author NIST
  303. * @author Mary Brady
  304. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317
  305. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  306. */
  307. attrparentnodenull: function(test) {
  308. var success;
  309. var doc;
  310. var addressList;
  311. var testNode;
  312. var attributes;
  313. var domesticAttr;
  314. var s;
  315. doc = staff.staff();
  316. addressList = doc.getElementsByTagName("address");
  317. testNode = addressList.item(0);
  318. attributes = testNode.attributes;
  319. domesticAttr = attributes.getNamedItem("domestic");
  320. s = domesticAttr.parentNode;
  321. test.equal(s, null, 'attrParentNodeNullAssert');
  322. test.done();
  323. },
  324. /**
  325. *
  326. The "getPreviousSibling()" method for an Attr node should return null.
  327. Retrieve the attribute named "domestic" from the last child of of the
  328. first employee and examine its PreviousSibling node. This test uses the
  329. "getNamedItem(name)" method from the NamedNodeMap interface.
  330. * @author NIST
  331. * @author Mary Brady
  332. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8
  333. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  334. */
  335. attrprevioussiblingnull: function(test) {
  336. var success;
  337. var doc;
  338. var addressList;
  339. var testNode;
  340. var attributes;
  341. var domesticAttr;
  342. var s;
  343. doc = staff.staff();
  344. addressList = doc.getElementsByTagName("address");
  345. testNode = addressList.item(0);
  346. attributes = testNode.attributes;
  347. domesticAttr = attributes.getNamedItem("domestic");
  348. s = domesticAttr.previousSibling;
  349. test.equal(s, null, 'attrPreviousSiblingNullAssert');
  350. test.done();
  351. },
  352. /**
  353. *
  354. Removing a child node from an attribute in an entity reference
  355. should result in an NO_MODIFICATION_ALLOWED_ERR DOMException.
  356. * @author Curt Arnold
  357. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  358. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  359. */
  360. attrremovechild1: function(test) {
  361. var success;
  362. var doc;
  363. var entRef;
  364. var entElement;
  365. var attrNode;
  366. var textNode;
  367. var removedNode;
  368. doc = staff.staff();
  369. entRef = doc.createEntityReference("ent4");
  370. test.notEqual(entRef, null, 'createdEntRefNotNull');
  371. entElement = entRef.firstChild;
  372. test.notEqual(entElement, null, 'entElementNotNull');
  373. attrNode = entElement.getAttributeNode("domestic");
  374. textNode = attrNode.firstChild;
  375. test.notEqual(textNode, null, 'attrChildNotNull');
  376. {
  377. success = false;
  378. try {
  379. removedNode = attrNode.removeChild(textNode);
  380. }
  381. catch(ex) {
  382. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  383. }
  384. test.ok(success, 'setValue_throws_NO_MODIFICATION_ERR');
  385. }
  386. test.done();
  387. },
  388. /**
  389. *
  390. Replacing a child node from an attribute in an entity reference
  391. should result in an NO_MODIFICATION_ALLOWED_ERR DOMException.
  392. * @author Curt Arnold
  393. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  394. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  395. */
  396. attrreplacechild1: function(test) {
  397. var success;
  398. var doc;
  399. var entRef;
  400. var entElement;
  401. var attrNode;
  402. var textNode;
  403. var removedNode;
  404. var newChild;
  405. doc = staff.staff();
  406. entRef = doc.createEntityReference("ent4");
  407. test.notEqual(entRef, null, 'createdEntRefNotNull');
  408. entElement = entRef.firstChild;
  409. test.notEqual(entElement, null, 'entElementNotNull');
  410. attrNode = entElement.getAttributeNode("domestic");
  411. textNode = attrNode.firstChild;
  412. test.notEqual(textNode, null, 'attrChildNotNull');
  413. newChild = doc.createTextNode("Yesterday");
  414. {
  415. success = false;
  416. try {
  417. removedNode = attrNode.replaceChild(newChild,textNode);
  418. }
  419. catch(ex) {
  420. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  421. }
  422. test.ok(success, 'setValue_throws_NO_MODIFICATION_ERR');
  423. }
  424. test.done();
  425. },
  426. /**
  427. *
  428. The "setValue()" method for an attribute causes the
  429. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  430. if the node is readonly.
  431. Obtain the children of the THIRD "gender" element. The elements
  432. content is an entity reference. Get the "domestic" attribute
  433. from the entity reference and execute the "setValue()" method.
  434. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  435. * @author NIST
  436. * @author Mary Brady
  437. * @see http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  438. * @see http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#ID-221662474
  439. * @see http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#xpointer(id('ID-221662474')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  440. * @see http://www.w3.org/DOM/updates/REC-DOM-Level-1-19981001-errata.html
  441. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
  442. */
  443. attrsetvaluenomodificationallowederr: function(test) {
  444. var success;
  445. var doc;
  446. var genderList;
  447. var gender;
  448. var genList;
  449. var gen;
  450. var gList;
  451. var g;
  452. var attrList;
  453. var attrNode;
  454. doc = staff.staff();
  455. genderList = doc.getElementsByTagName("gender");
  456. gender = genderList.item(2);
  457. test.notEqual(gender, null, 'genderNotNull');
  458. genList = gender.childNodes;
  459. gen = genList.item(0);
  460. test.notEqual(gen, null, 'genderFirstChildNotNull');
  461. gList = gen.childNodes;
  462. g = gList.item(0);
  463. test.notEqual(g, null, 'genderFirstGrandchildNotNull');
  464. attrList = g.attributes;
  465. test.notEqual(attrList, null, 'attributesNotNull');
  466. attrNode = attrList.getNamedItem("domestic");
  467. test.notEqual(attrNode, null, 'attrNotNull');
  468. {
  469. success = false;
  470. try {
  471. attrNode.value = "newvalue";
  472. }
  473. catch(ex) {
  474. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  475. }
  476. test.ok(success, 'setValue_throws_NO_MODIFICATION');
  477. }
  478. {
  479. success = false;
  480. try {
  481. attrNode.nodeValue = "newvalue2";
  482. }
  483. catch(ex) {
  484. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  485. }
  486. test.ok(success, 'setNodeValue_throws_NO_MODIFICATION');
  487. }
  488. test.done();
  489. },
  490. /**
  491. *
  492. The "setValue()" method for an attribute causes the
  493. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  494. if the node is readonly.
  495. Create an entity reference using document.createEntityReference()
  496. Get the "domestic" attribute from the entity
  497. reference and execute the "setValue()" method.
  498. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  499. * @author Curt Arnold
  500. * @see http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  501. * @see http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#ID-221662474
  502. * @see http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core#xpointer(id('ID-221662474')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  503. * @see http://www.w3.org/DOM/updates/REC-DOM-Level-1-19981001-errata.html
  504. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
  505. * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/attrsetvaluenomodificationallowederr.xml
  506. */
  507. attrsetvaluenomodificationallowederrEE: function(test) {
  508. var success;
  509. var doc;
  510. var entRef;
  511. var entElement;
  512. var attrList;
  513. var attrNode;
  514. var gender;
  515. var genderList;
  516. var appendedChild;
  517. doc = staff.staff();
  518. genderList = doc.getElementsByTagName("gender");
  519. gender = genderList.item(2);
  520. test.notEqual(gender, null, 'genderNotNull');
  521. entRef = doc.createEntityReference("ent4");
  522. test.notEqual(entRef, null, 'entRefNotNull');
  523. appendedChild = gender.appendChild(entRef);
  524. entElement = entRef.firstChild;
  525. test.notEqual(entElement, null, 'entElementNotNull');
  526. attrList = entElement.attributes;
  527. attrNode = attrList.getNamedItem("domestic");
  528. {
  529. success = false;
  530. try {
  531. attrNode.value = "newvalue";
  532. }
  533. catch(ex) {
  534. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  535. }
  536. test.ok(success, 'setValue_throws_NO_MODIFICATION');
  537. }
  538. {
  539. success = false;
  540. try {
  541. attrNode.nodeValue = "newvalue2";
  542. }
  543. catch(ex) {
  544. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  545. }
  546. test.ok(success, 'setNodeValue_throws_NO_MODIFICATION');
  547. }
  548. test.done();
  549. },
  550. /**
  551. *
  552. The "getSpecified()" method for an Attr node should
  553. be set to true if the attribute was explicitly given
  554. a value.
  555. Retrieve the attribute named "domestic" from the last
  556. child of of the first employee and examine the value
  557. returned by the "getSpecified()" method. This test uses
  558. the "getNamedItem(name)" method from the NamedNodeMap
  559. interface.
  560. * @author NIST
  561. * @author Mary Brady
  562. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-862529273
  563. */
  564. attrspecifiedvalue: function(test) {
  565. var success;
  566. var doc;
  567. var addressList;
  568. var testNode;
  569. var attributes;
  570. var domesticAttr;
  571. var state;
  572. doc = staff.staff();
  573. addressList = doc.getElementsByTagName("address");
  574. testNode = addressList.item(0);
  575. attributes = testNode.attributes;
  576. domesticAttr = attributes.getNamedItem("domestic");
  577. state = domesticAttr.specified;
  578. test.ok(state, 'domesticSpecified');
  579. test.done();
  580. },
  581. /**
  582. *
  583. The "getSpecified()" method for an Attr node should return true if the
  584. value of the attribute is changed.
  585. Retrieve the attribute named "street" from the last
  586. child of of the THIRD employee and change its
  587. value to "Yes"(which is the default DTD value). This
  588. should cause the "getSpecified()" method to be true.
  589. This test uses the "setAttribute(name,value)" method
  590. from the Element interface and the "getNamedItem(name)"
  591. method from the NamedNodeMap interface.
  592. * @author NIST
  593. * @author Mary Brady
  594. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-862529273
  595. */
  596. attrspecifiedvaluechanged: function(test) {
  597. var success;
  598. var doc;
  599. var addressList;
  600. var testNode;
  601. var attributes;
  602. var streetAttr;
  603. var state;
  604. doc = staff.staff();
  605. addressList = doc.getElementsByTagName("address");
  606. testNode = addressList.item(2);
  607. testNode.setAttribute("street","Yes");
  608. attributes = testNode.attributes;
  609. streetAttr = attributes.getNamedItem("street");
  610. state = streetAttr.specified;
  611. test.ok(state, 'streetSpecified');
  612. test.done();
  613. },
  614. /**
  615. *
  616. To respecify the attribute to its default value from
  617. the DTD, the attribute must be deleted. This will then
  618. make a new attribute available with the "getSpecified()"
  619. method value set to false.
  620. Retrieve the attribute named "street" from the last
  621. child of of the THIRD employee and delete it. This
  622. should then create a new attribute with its default
  623. value and also cause the "getSpecified()" method to
  624. return false.
  625. This test uses the "removeAttribute(name)" method
  626. from the Element interface and the "getNamedItem(name)"
  627. method from the NamedNodeMap interface.
  628. * @author NIST
  629. * @author Mary Brady
  630. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9
  631. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html
  632. */
  633. attrspecifiedvalueremove: function(test) {
  634. var success;
  635. var doc;
  636. var addressList;
  637. var testNode;
  638. var attributes;
  639. var streetAttr;
  640. var state;
  641. doc = staff.staff();
  642. addressList = doc.getElementsByTagName("address");
  643. testNode = addressList.item(2);
  644. testNode.removeAttribute("street");
  645. attributes = testNode.attributes;
  646. streetAttr = attributes.getNamedItem("street");
  647. test.notEqual(streetAttr, null, 'streetAttrNotNull');
  648. state = streetAttr.specified;
  649. test.equal(state, false, 'attrSpecifiedValueRemoveAssert');
  650. test.done();
  651. },
  652. /**
  653. *
  654. Retrieve the last CDATASection node located inside the
  655. second child of the second employee and examine its
  656. content. Since the CDATASection interface inherits
  657. from the CharacterData interface(via the Text node),
  658. the "getData()" method can be used to access the
  659. CDATA content.
  660. * @author NIST
  661. * @author Mary Brady
  662. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  663. */
  664. cdatasectiongetdata: function(test) {
  665. var success;
  666. var doc;
  667. var nameList;
  668. var child;
  669. var lastChild;
  670. var data;
  671. var nodeType;
  672. doc = staff.staff();
  673. nameList = doc.getElementsByTagName("name");
  674. child = nameList.item(1);
  675. lastChild = child.lastChild;
  676. nodeType = lastChild.nodeType;
  677. test.equal(nodeType, 4, 'isCDATA');
  678. data = lastChild.data;
  679. test.equal(data, 'This is an adjacent CDATASection with a reference to a tab &tab;', 'data');
  680. test.done();
  681. },
  682. /**
  683. *
  684. Adjacent CDATASection nodes cannot be merged together by
  685. use of the "normalize()" method from the Element interface.
  686. Retrieve second child of the second employee and invoke
  687. the "normalize()" method. The Element under contains
  688. two CDATASection nodes that should not be merged together
  689. by the "normalize()" method.
  690. * @author NIST
  691. * @author Mary Brady
  692. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083
  693. */
  694. cdatasectionnormalize: function(test) {
  695. var success;
  696. var doc;
  697. var nameList;
  698. var lChild;
  699. var childNodes;
  700. var cdataN;
  701. var data;
  702. doc = staff.staff();
  703. nameList = doc.getElementsByTagName("name");
  704. lChild = nameList.item(1);
  705. lChild.normalize();
  706. childNodes = lChild.childNodes;
  707. cdataN = childNodes.item(1);
  708. test.notEqual(cdataN, null, 'firstCDATASection');
  709. data = cdataN.data;
  710. test.equal(data, 'This is a CDATASection with EntityReference number 2 &ent2;', 'data1');
  711. cdataN = childNodes.item(3);
  712. test.notEqual(cdataN, null, 'secondCDATASection');
  713. data = cdataN.data;
  714. test.equal(data, 'This is an adjacent CDATASection with a reference to a tab &tab;', 'data3');
  715. test.done();
  716. },
  717. /**
  718. *
  719. The "appendData(arg)" method appends a string to the end
  720. of the character data of the node.
  721. Retrieve the character data from the second child
  722. of the first employee. The appendData(arg) method is
  723. called with arg=", Esquire". The method should append
  724. the specified data to the already existing character
  725. data. The new value return by the "getLength()" method
  726. should be 24.
  727. * @author NIST
  728. * @author Mary Brady
  729. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  730. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F
  731. */
  732. characterdataappenddata: function(test) {
  733. var success;
  734. var doc;
  735. var elementList;
  736. var nameNode;
  737. var child;
  738. var childValue;
  739. var childLength;
  740. doc = staff.staff();
  741. elementList = doc.getElementsByTagName("name");
  742. nameNode = elementList.item(0);
  743. child = nameNode.firstChild;
  744. child.appendData(", Esquire");
  745. childValue = child.data;
  746. childLength = childValue.length;
  747. test.equal(childLength, 24, 'characterdataAppendDataAssert');
  748. test.done();
  749. },
  750. /**
  751. *
  752. On successful invocation of the "appendData(arg)"
  753. method the "getData()" method provides access to the
  754. concatentation of data and the specified string.
  755. Retrieve the character data from the second child
  756. of the first employee. The appendData(arg) method is
  757. called with arg=", Esquire". The method should append
  758. the specified data to the already existing character
  759. data. The new value return by the "getData()" method
  760. should be "Margaret Martin, Esquire".
  761. * @author NIST
  762. * @author Mary Brady
  763. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  764. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F
  765. */
  766. characterdataappenddatagetdata: function(test) {
  767. var success;
  768. var doc;
  769. var elementList;
  770. var nameNode;
  771. var child;
  772. var childData;
  773. doc = staff.staff();
  774. elementList = doc.getElementsByTagName("name");
  775. nameNode = elementList.item(0);
  776. child = nameNode.firstChild;
  777. child.appendData(", Esquire");
  778. childData = child.data;
  779. test.equal(childData, 'Margaret Martin, Esquire', 'characterdataAppendDataGetDataAssert');
  780. test.done();
  781. },
  782. /**
  783. *
  784. The "appendData(arg)" method raises a NO_MODIFICATION_ALLOWED_ERR
  785. DOMException if the node is readonly.
  786. Obtain the children of the THIRD "gender" element. The elements
  787. content is an entity reference. Get the FIRST item
  788. from the entity reference and execute the "appendData(arg)" method.
  789. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  790. * @author NIST
  791. * @author Mary Brady
  792. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  793. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F
  794. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-32791A2F')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  795. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F
  796. */
  797. characterdataappenddatanomodificationallowederr: function(test) {
  798. var success;
  799. var doc;
  800. var genderList;
  801. var genderNode;
  802. var entElement;
  803. var entElementContent;
  804. var entReference;
  805. var nodeType;
  806. doc = staff.staff();
  807. genderList = doc.getElementsByTagName("gender");
  808. genderNode = genderList.item(2);
  809. entReference = genderNode.firstChild;
  810. test.notEqual(entReference, null, 'entReferenceNotNull');
  811. nodeType = entReference.nodeType;
  812. if(
  813. (1 == nodeType)
  814. ) {
  815. entReference = doc.createEntityReference("ent4");
  816. test.notEqual(entReference, null, 'createdEntRefNotNull');
  817. }
  818. entElement = entReference.firstChild;
  819. test.notEqual(entElement, null, 'entElementNotNull');
  820. entElementContent = entElement.firstChild;
  821. test.notEqual(entElementContent, null, 'entElementContentNotNull');
  822. {
  823. success = false;
  824. try {
  825. entElementContent.appendData("newString");
  826. }
  827. catch(ex) {
  828. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  829. }
  830. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  831. }
  832. test.done();
  833. },
  834. /**
  835. *
  836. Create an ent3 entity reference and call appendData on a text child, should thrown a NO_MODIFICATION_ALLOWED_ERR.
  837. * @author Curt Arnold
  838. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  839. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F
  840. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-32791A2F')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  841. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F
  842. * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdataappenddatanomodificationallowederr.xml
  843. */
  844. characterdataappenddatanomodificationallowederrEE: function(test) {
  845. var success;
  846. var doc;
  847. var genderList;
  848. var genderNode;
  849. var entText;
  850. var entReference;
  851. var appendedChild;
  852. doc = staff.staff();
  853. genderList = doc.getElementsByTagName("gender");
  854. genderNode = genderList.item(2);
  855. entReference = doc.createEntityReference("ent3");
  856. test.notEqual(entReference, null, 'createdEntRefNotNull');
  857. appendedChild = genderNode.appendChild(entReference);
  858. entText = entReference.firstChild;
  859. test.notEqual(entText, null, 'entTextNotNull');
  860. {
  861. success = false;
  862. try {
  863. entText.appendData("newString");
  864. }
  865. catch(ex) {
  866. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  867. }
  868. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  869. }
  870. test.done();
  871. },
  872. /**
  873. *
  874. The "deleteData(offset,count)" method removes a range of
  875. characters from the node. Delete data at the beginning
  876. of the character data.
  877. Retrieve the character data from the last child of the
  878. first employee. The "deleteData(offset,count)"
  879. method is then called with offset=0 and count=16.
  880. The method should delete the characters from position
  881. 0 thru position 16. The new value of the character data
  882. should be "Dallas, Texas 98551".
  883. * @author NIST
  884. * @author Mary Brady
  885. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  886. */
  887. characterdatadeletedatabegining: function(test) {
  888. var success;
  889. var doc;
  890. var elementList;
  891. var nameNode;
  892. var child;
  893. var childData;
  894. doc = staff.staff();
  895. elementList = doc.getElementsByTagName("address");
  896. nameNode = elementList.item(0);
  897. child = nameNode.firstChild;
  898. child.deleteData(0,16);
  899. childData = child.data;
  900. test.equal(childData, 'Dallas, Texas 98551', 'characterdataDeleteDataBeginingAssert');
  901. test.done();
  902. },
  903. /**
  904. *
  905. The "deleteData(offset,count)" method removes a range of
  906. characters from the node. Delete data at the end
  907. of the character data.
  908. Retrieve the character data from the last child of the
  909. first employee. The "deleteData(offset,count)"
  910. method is then called with offset=30 and count=5.
  911. The method should delete the characters from position
  912. 30 thru position 35. The new value of the character data
  913. should be "1230 North Ave. Dallas, Texas".
  914. * @author NIST
  915. * @author Mary Brady
  916. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  917. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  918. */
  919. characterdatadeletedataend: function(test) {
  920. var success;
  921. var doc;
  922. var elementList;
  923. var nameNode;
  924. var child;
  925. var childData;
  926. doc = staff.staff();
  927. elementList = doc.getElementsByTagName("address");
  928. nameNode = elementList.item(0);
  929. child = nameNode.firstChild;
  930. child.deleteData(30,5);
  931. childData = child.data;
  932. test.equal(childData, '1230 North Ave. Dallas, Texas ', 'characterdataDeleteDataEndAssert');
  933. test.done();
  934. },
  935. /**
  936. *
  937. If the sum of the offset and count used in the
  938. "deleteData(offset,count) method is greater than the
  939. length of the character data then all the characters
  940. from the offset to the end of the data are deleted.
  941. Retrieve the character data from the last child of the
  942. first employee. The "deleteData(offset,count)"
  943. method is then called with offset=4 and count=50.
  944. The method should delete the characters from position 4
  945. to the end of the data since the offset+count(50+4)
  946. is greater than the length of the character data(35).
  947. The new value of the character data should be "1230".
  948. * @author NIST
  949. * @author Mary Brady
  950. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  951. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  952. */
  953. characterdatadeletedataexceedslength: function(test) {
  954. var success;
  955. var doc;
  956. var elementList;
  957. var nameNode;
  958. var child;
  959. var childData;
  960. doc = staff.staff();
  961. elementList = doc.getElementsByTagName("address");
  962. nameNode = elementList.item(0);
  963. child = nameNode.firstChild;
  964. child.deleteData(4,50);
  965. childData = child.data;
  966. test.equal(childData, '1230', 'characterdataDeleteDataExceedsLengthAssert');
  967. test.done();
  968. },
  969. /**
  970. *
  971. On successful invocation of the "deleteData(offset,count)"
  972. method, the "getData()" and "getLength()" methods reflect
  973. the changes.
  974. Retrieve the character data from the last child of the
  975. first employee. The "deleteData(offset,count)"
  976. method is then called with offset=30 and count=5.
  977. The method should delete the characters from position
  978. 30 thru position 35. The new value of the character data
  979. should be "1230 North Ave. Dallas, Texas" which is
  980. returned by the "getData()" method and "getLength()"
  981. method should return 30".
  982. * @author NIST
  983. * @author Mary Brady
  984. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  985. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7D61178C
  986. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  987. */
  988. characterdatadeletedatagetlengthanddata: function(test) {
  989. var success;
  990. var doc;
  991. var elementList;
  992. var nameNode;
  993. var child;
  994. var childData;
  995. var childLength;
  996. var result = new Array();
  997. doc = staff.staff();
  998. elementList = doc.getElementsByTagName("address");
  999. nameNode = elementList.item(0);
  1000. child = nameNode.firstChild;
  1001. child.deleteData(30,5);
  1002. childData = child.data;
  1003. test.equal(childData, '1230 North Ave. Dallas, Texas ', 'data');
  1004. childLength = child.length;
  1005. test.equal(childLength, 30, 'length');
  1006. test.done();
  1007. },
  1008. /**
  1009. *
  1010. The "deleteData(offset,count)" method removes a range of
  1011. characters from the node. Delete data in the middle
  1012. of the character data.
  1013. Retrieve the character data from the last child of the
  1014. first employee. The "deleteData(offset,count)"
  1015. method is then called with offset=16 and count=8.
  1016. The method should delete the characters from position
  1017. 16 thru position 24. The new value of the character data
  1018. should be "1230 North Ave. Texas 98551".
  1019. * @author NIST
  1020. * @author Mary Brady
  1021. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1022. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1023. */
  1024. characterdatadeletedatamiddle: function(test) {
  1025. var success;
  1026. var doc;
  1027. var elementList;
  1028. var nameNode;
  1029. var child;
  1030. var childData;
  1031. doc = staff.staff();
  1032. elementList = doc.getElementsByTagName("address");
  1033. nameNode = elementList.item(0);
  1034. child = nameNode.firstChild;
  1035. child.deleteData(16,8);
  1036. childData = child.data;
  1037. test.equal(childData, '1230 North Ave. Texas 98551', 'characterdataDeleteDataMiddleAssert');
  1038. test.done();
  1039. },
  1040. /**
  1041. *
  1042. The "deleteData(offset,count)" method raises a NO_MODIFICATION_ALLOWED_ERR
  1043. DOMException if the node is readonly.
  1044. Obtain the children of the THIRD "gender" element. The elements
  1045. content is an entity reference. Get the FIRST item
  1046. from the entity reference and execute the "deleteData(offset,count)" method.
  1047. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  1048. * @author NIST
  1049. * @author Mary Brady
  1050. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  1051. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1052. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  1053. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1054. */
  1055. characterdatadeletedatanomodificationallowederr: function(test) {
  1056. var success;
  1057. var doc;
  1058. var genderList;
  1059. var genderNode;
  1060. var entElement;
  1061. var entElementContent;
  1062. var nodeType;
  1063. var entReference;
  1064. doc = staff.staff();
  1065. genderList = doc.getElementsByTagName("gender");
  1066. genderNode = genderList.item(2);
  1067. entReference = genderNode.firstChild;
  1068. test.notEqual(entReference, null, 'entReferenceNotNull');
  1069. nodeType = entReference.nodeType;
  1070. if(
  1071. (3 == nodeType)
  1072. ) {
  1073. entReference = doc.createEntityReference("ent4");
  1074. test.notEqual(entReference, null, 'createdEntRefNotNull');
  1075. }
  1076. entElement = entReference.firstChild;
  1077. test.notEqual(entElement, null, 'entElementNotNull');
  1078. entElementContent = entElement.firstChild;
  1079. test.notEqual(entElementContent, null, 'entElementContentNotNull');
  1080. {
  1081. success = false;
  1082. try {
  1083. entElementContent.deleteData(1,3);
  1084. }
  1085. catch(ex) {
  1086. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  1087. }
  1088. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  1089. }
  1090. test.done();
  1091. },
  1092. /**
  1093. *
  1094. Create an ent3 entity reference and call deleteData on a text child, should thrown a NO_MODIFICATION_ALLOWED_ERR.
  1095. * @author Curt Arnold
  1096. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  1097. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1098. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  1099. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1100. * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatadeletedatanomodificationallowederr.xml
  1101. */
  1102. characterdatadeletedatanomodificationallowederrEE: function(test) {
  1103. var success;
  1104. var doc;
  1105. var genderList;
  1106. var genderNode;
  1107. var entText;
  1108. var entReference;
  1109. var appendedChild;
  1110. doc = staff.staff();
  1111. genderList = doc.getElementsByTagName("gender");
  1112. genderNode = genderList.item(2);
  1113. entReference = doc.createEntityReference("ent3");
  1114. test.notEqual(entReference, null, 'createdEntRefNotNull');
  1115. appendedChild = genderNode.appendChild(entReference);
  1116. entText = entReference.firstChild;
  1117. test.notEqual(entText, null, 'entTextNotNull');
  1118. {
  1119. success = false;
  1120. try {
  1121. entText.deleteData(1,3);
  1122. }
  1123. catch(ex) {
  1124. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  1125. }
  1126. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  1127. }
  1128. test.done();
  1129. },
  1130. /**
  1131. *
  1132. The "getData()" method retrieves the character data
  1133. currently stored in the node.
  1134. Retrieve the character data from the second child
  1135. of the first employee and invoke the "getData()"
  1136. method. The method returns the character data
  1137. string.
  1138. * @author NIST
  1139. * @author Mary Brady
  1140. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1141. */
  1142. characterdatagetdata: function(test) {
  1143. var success;
  1144. var doc;
  1145. var elementList;
  1146. var nameNode;
  1147. var child;
  1148. var childData;
  1149. doc = staff.staff();
  1150. elementList = doc.getElementsByTagName("name");
  1151. nameNode = elementList.item(0);
  1152. child = nameNode.firstChild;
  1153. childData = child.data;
  1154. test.equal(childData, 'Margaret Martin', 'characterdataGetDataAssert');
  1155. test.done();
  1156. },
  1157. /**
  1158. *
  1159. The "getLength()" method returns the number of characters
  1160. stored in this nodes data.
  1161. Retrieve the character data from the second
  1162. child of the first employee and examine the
  1163. value returned by the getLength() method.
  1164. * @author NIST
  1165. * @author Mary Brady
  1166. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1167. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7D61178C
  1168. */
  1169. characterdatagetlength: function(test) {
  1170. var success;
  1171. var doc;
  1172. var elementList;
  1173. var nameNode;
  1174. var child;
  1175. var childValue;
  1176. var childLength;
  1177. doc = staff.staff();
  1178. elementList = doc.getElementsByTagName("name");
  1179. nameNode = elementList.item(0);
  1180. child = nameNode.firstChild;
  1181. childValue = child.data;
  1182. childLength = childValue.length;
  1183. test.equal(childLength, 15, 'characterdataGetLengthAssert');
  1184. test.done();
  1185. },
  1186. /**
  1187. *
  1188. The "deleteData(offset,count)" method raises an
  1189. INDEX_SIZE_ERR DOMException if the specified count
  1190. is negative.
  1191. Retrieve the character data of the last child of the
  1192. first employee and invoke its "deleteData(offset,count)"
  1193. method with offset=10 and count=-3. It should raise the
  1194. desired exception since the count is negative.
  1195. * @author NIST
  1196. * @author Mary Brady
  1197. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1198. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  1199. * @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'])
  1200. */
  1201. characterdataindexsizeerrdeletedatacountnegative: function(test) {
  1202. var success;
  1203. var doc;
  1204. var elementList;
  1205. var nameNode;
  1206. var child;
  1207. doc = staff.staff();
  1208. elementList = doc.getElementsByTagName("address");
  1209. nameNode = elementList.item(0);
  1210. child = nameNode.firstChild;
  1211. {
  1212. success = false;
  1213. try {
  1214. child.deleteData(10,-3);
  1215. }
  1216. catch(ex) {
  1217. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1218. }
  1219. test.ok(success, 'throws_INDEX_SIZE_ERR');
  1220. }
  1221. test.done();
  1222. },
  1223. /**
  1224. *
  1225. The "deleteData(offset,count)" method raises an
  1226. INDEX_SIZE_ERR DOMException if the specified offset
  1227. is greater that the number of characters in the string.
  1228. Retrieve the character data of the last child of the
  1229. first employee and invoke its "deleteData(offset,count)"
  1230. method with offset=40 and count=3. It should raise the
  1231. desired exception since the offset is greater than the
  1232. number of characters in the string.
  1233. * @author NIST
  1234. * @author Mary Brady
  1235. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1236. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1237. * @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'])
  1238. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1239. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  1240. */
  1241. characterdataindexsizeerrdeletedataoffsetgreater: function(test) {
  1242. var success;
  1243. var doc;
  1244. var elementList;
  1245. var nameNode;
  1246. var child;
  1247. doc = staff.staff();
  1248. elementList = doc.getElementsByTagName("address");
  1249. nameNode = elementList.item(0);
  1250. child = nameNode.firstChild;
  1251. {
  1252. success = false;
  1253. try {
  1254. child.deleteData(40,3);
  1255. }
  1256. catch(ex) {
  1257. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1258. }
  1259. test.ok(success, 'throw_INDEX_SIZE_ERR');
  1260. }
  1261. test.done();
  1262. },
  1263. /**
  1264. *
  1265. The "deleteData(offset,count)" method raises an
  1266. INDEX_SIZE_ERR DOMException if the specified offset
  1267. is negative.
  1268. Retrieve the character data of the last child of the
  1269. first employee and invoke its "deleteData(offset,count)"
  1270. method with offset=-5 and count=3. It should raise the
  1271. desired exception since the offset is negative.
  1272. * @author NIST
  1273. * @author Mary Brady
  1274. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1275. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1276. * @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'])
  1277. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1278. */
  1279. characterdataindexsizeerrdeletedataoffsetnegative: function(test) {
  1280. var success;
  1281. var doc;
  1282. var elementList;
  1283. var nameNode;
  1284. var child;
  1285. doc = staff.staff();
  1286. elementList = doc.getElementsByTagName("address");
  1287. nameNode = elementList.item(0);
  1288. child = nameNode.firstChild;
  1289. {
  1290. success = false;
  1291. try {
  1292. child.deleteData(-5,3);
  1293. }
  1294. catch(ex) {
  1295. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1296. }
  1297. test.ok(success, 'throws_INDEX_SIZE_ERR');
  1298. }
  1299. test.done();
  1300. },
  1301. /**
  1302. *
  1303. The "insertData(offset,arg)" method raises an
  1304. INDEX_SIZE_ERR DOMException if the specified offset
  1305. is greater than the number of characters in the string.
  1306. Retrieve the character data of the last child of the
  1307. first employee and invoke its insertData"(offset,arg)"
  1308. method with offset=40 and arg="ABC". It should raise
  1309. the desired exception since the offset is greater than
  1310. the number of characters in the string.
  1311. * @author NIST
  1312. * @author Mary Brady
  1313. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1314. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1315. * @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'])
  1316. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  1317. */
  1318. characterdataindexsizeerrinsertdataoffsetgreater: function(test) {
  1319. var success;
  1320. var doc;
  1321. var elementList;
  1322. var nameNode;
  1323. var child;
  1324. doc = staff.staff();
  1325. elementList = doc.getElementsByTagName("address");
  1326. nameNode = elementList.item(0);
  1327. child = nameNode.firstChild;
  1328. {
  1329. success = false;
  1330. try {
  1331. child.insertData(40,"ABC");
  1332. }
  1333. catch(ex) {
  1334. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1335. }
  1336. test.ok(success, 'throw_INDEX_SIZE_ERR');
  1337. }
  1338. test.done();
  1339. },
  1340. /**
  1341. *
  1342. The "insertData(offset,arg)" method raises an
  1343. INDEX_SIZE_ERR DOMException if the specified offset
  1344. is negative.
  1345. Retrieve the character data of the last child of the
  1346. first employee and invoke its insertData"(offset,arg)"
  1347. method with offset=-5 and arg="ABC". It should raise
  1348. the desired exception since the offset is negative.
  1349. * @author NIST
  1350. * @author Mary Brady
  1351. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1352. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  1353. * @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'])
  1354. */
  1355. characterdataindexsizeerrinsertdataoffsetnegative: function(test) {
  1356. var success;
  1357. var doc;
  1358. var elementList;
  1359. var nameNode;
  1360. var child;
  1361. doc = staff.staff();
  1362. elementList = doc.getElementsByTagName("address");
  1363. nameNode = elementList.item(0);
  1364. child = nameNode.firstChild;
  1365. {
  1366. success = false;
  1367. try {
  1368. child.insertData(-5,"ABC");
  1369. }
  1370. catch(ex) {
  1371. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1372. }
  1373. test.ok(success, 'throws_INDEX_SIZE_ERR');
  1374. }
  1375. test.done();
  1376. },
  1377. /**
  1378. *
  1379. The "replaceData(offset,count,arg)" method raises an
  1380. INDEX_SIZE_ERR DOMException if the specified count
  1381. is negative.
  1382. Retrieve the character data of the last child of the
  1383. first employee and invoke its
  1384. "replaceData(offset,count,arg) method with offset=10
  1385. and count=-3 and arg="ABC". It should raise the
  1386. desired exception since the count is negative.
  1387. * @author NIST
  1388. * @author Mary Brady
  1389. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1390. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  1391. * @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'])
  1392. */
  1393. characterdataindexsizeerrreplacedatacountnegative: function(test) {
  1394. var success;
  1395. var doc;
  1396. var elementList;
  1397. var nameNode;
  1398. var child;
  1399. doc = staff.staff();
  1400. elementList = doc.getElementsByTagName("address");
  1401. nameNode = elementList.item(0);
  1402. child = nameNode.firstChild;
  1403. {
  1404. success = false;
  1405. try {
  1406. child.replaceData(10,-3,"ABC");
  1407. }
  1408. catch(ex) {
  1409. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1410. }
  1411. test.ok(success, 'throws_INDEX_SIZE_ERR');
  1412. }
  1413. test.done();
  1414. },
  1415. /**
  1416. *
  1417. The "replaceData(offset,count,arg)" method raises an
  1418. INDEX_SIZE_ERR DOMException if the specified offset
  1419. is greater than the length of the string.
  1420. Retrieve the character data of the last child of the
  1421. first employee and invoke its
  1422. "replaceData(offset,count,arg) method with offset=40
  1423. and count=3 and arg="ABC". It should raise the
  1424. desired exception since the offset is greater than the
  1425. length of the string.
  1426. * @author NIST
  1427. * @author Mary Brady
  1428. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1429. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  1430. * @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'])
  1431. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  1432. */
  1433. characterdataindexsizeerrreplacedataoffsetgreater: function(test) {
  1434. var success;
  1435. var doc;
  1436. var elementList;
  1437. var nameNode;
  1438. var child;
  1439. doc = staff.staff();
  1440. elementList = doc.getElementsByTagName("address");
  1441. nameNode = elementList.item(0);
  1442. child = nameNode.firstChild;
  1443. {
  1444. success = false;
  1445. try {
  1446. child.replaceData(40,3,"ABC");
  1447. }
  1448. catch(ex) {
  1449. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1450. }
  1451. test.ok(success, 'throw_INDEX_SIZE_ERR');
  1452. }
  1453. test.done();
  1454. },
  1455. /**
  1456. *
  1457. The "replaceData(offset,count,arg)" method raises an
  1458. INDEX_SIZE_ERR DOMException if the specified offset
  1459. is negative.
  1460. Retrieve the character data of the last child of the
  1461. first employee and invoke its
  1462. "replaceData(offset,count,arg) method with offset=-5
  1463. and count=3 and arg="ABC". It should raise the
  1464. desired exception since the offset is negative.
  1465. * @author NIST
  1466. * @author Mary Brady
  1467. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1468. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  1469. * @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'])
  1470. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  1471. */
  1472. characterdataindexsizeerrreplacedataoffsetnegative: function(test) {
  1473. var success;
  1474. var doc;
  1475. var elementList;
  1476. var nameNode;
  1477. var child;
  1478. doc = staff.staff();
  1479. elementList = doc.getElementsByTagName("address");
  1480. nameNode = elementList.item(0);
  1481. child = nameNode.firstChild;
  1482. {
  1483. success = false;
  1484. try {
  1485. child.replaceData(-5,3,"ABC");
  1486. }
  1487. catch(ex) {
  1488. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1489. }
  1490. test.ok(success, 'throws_INDEX_SIZE_ERR');
  1491. }
  1492. test.done();
  1493. },
  1494. /**
  1495. *
  1496. The "substringData(offset,count)" method raises an
  1497. INDEX_SIZE_ERR DOMException if the specified count
  1498. is negative.
  1499. Retrieve the character data of the last child of the
  1500. first employee and invoke its "substringData(offset,count)
  1501. method with offset=10 and count=-3. It should raise the
  1502. desired exception since the count is negative.
  1503. * @author NIST
  1504. * @author Mary Brady
  1505. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1506. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  1507. * @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'])
  1508. */
  1509. characterdataindexsizeerrsubstringcountnegative: function(test) {
  1510. var success;
  1511. var doc;
  1512. var elementList;
  1513. var nameNode;
  1514. var child;
  1515. var badSubstring;
  1516. doc = staff.staff();
  1517. elementList = doc.getElementsByTagName("address");
  1518. nameNode = elementList.item(0);
  1519. child = nameNode.firstChild;
  1520. {
  1521. success = false;
  1522. try {
  1523. badSubstring = child.substringData(10,-3);
  1524. }
  1525. catch(ex) {
  1526. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1527. }
  1528. test.ok(success, 'throws_INDEX_SIZE_ERR');
  1529. }
  1530. test.done();
  1531. },
  1532. /**
  1533. *
  1534. The "substringData(offset,count)" method raises an
  1535. INDEX_SIZE_ERR DOMException if the specified offset
  1536. is negative.
  1537. Retrieve the character data of the last child of the
  1538. first employee and invoke its "substringData(offset,count)
  1539. method with offset=-5 and count=3. It should raise the
  1540. desired exception since the offset is negative.
  1541. * @author NIST
  1542. * @author Mary Brady
  1543. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1544. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  1545. * @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'])
  1546. */
  1547. characterdataindexsizeerrsubstringnegativeoffset: function(test) {
  1548. var success;
  1549. var doc;
  1550. var elementList;
  1551. var nameNode;
  1552. var child;
  1553. var badString;
  1554. doc = staff.staff();
  1555. elementList = doc.getElementsByTagName("address");
  1556. nameNode = elementList.item(0);
  1557. child = nameNode.firstChild;
  1558. {
  1559. success = false;
  1560. try {
  1561. badString = child.substringData(-5,3);
  1562. }
  1563. catch(ex) {
  1564. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1565. }
  1566. test.ok(success, 'throws_INDEX_SIZE_ERR');
  1567. }
  1568. test.done();
  1569. },
  1570. /**
  1571. *
  1572. The "substringData(offset,count)" method raises an
  1573. INDEX_SIZE_ERR DOMException if the specified offset
  1574. is greater than the number of characters in the string.
  1575. Retrieve the character data of the last child of the
  1576. first employee and invoke its "substringData(offset,count)
  1577. method with offset=40 and count=3. It should raise the
  1578. desired exception since the offsets value is greater
  1579. than the length.
  1580. * @author NIST
  1581. * @author Mary Brady
  1582. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  1583. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  1584. * @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'])
  1585. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  1586. */
  1587. characterdataindexsizeerrsubstringoffsetgreater: function(test) {
  1588. var success;
  1589. var doc;
  1590. var elementList;
  1591. var nameNode;
  1592. var child;
  1593. var badString;
  1594. doc = staff.staff();
  1595. elementList = doc.getElementsByTagName("address");
  1596. nameNode = elementList.item(0);
  1597. child = nameNode.firstChild;
  1598. {
  1599. success = false;
  1600. try {
  1601. badString = child.substringData(40,3);
  1602. }
  1603. catch(ex) {
  1604. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  1605. }
  1606. test.ok(success, 'throw_INDEX_SIZE_ERR');
  1607. }
  1608. test.done();
  1609. },
  1610. /**
  1611. *
  1612. The "insertData(offset,arg)" method will insert a string
  1613. at the specified character offset. Insert the data at
  1614. the beginning of the character data.
  1615. Retrieve the character data from the second child of
  1616. the first employee. The "insertData(offset,arg)"
  1617. method is then called with offset=0 and arg="Mss.".
  1618. The method should insert the string "Mss." at position 0.
  1619. The new value of the character data should be
  1620. "Mss. Margaret Martin".
  1621. * @author NIST
  1622. * @author Mary Brady
  1623. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F
  1624. */
  1625. characterdatainsertdatabeginning: function(test) {
  1626. var success;
  1627. var doc;
  1628. var elementList;
  1629. var nameNode;
  1630. var child;
  1631. var childData;
  1632. doc = staff.staff();
  1633. elementList = doc.getElementsByTagName("name");
  1634. nameNode = elementList.item(0);
  1635. child = nameNode.firstChild;
  1636. child.insertData(0,"Mss. ");
  1637. childData = child.data;
  1638. test.equal(childData, 'Mss. Margaret Martin', 'characterdataInsertDataBeginningAssert');
  1639. test.done();
  1640. },
  1641. /**
  1642. *
  1643. The "insertData(offset,arg)" method will insert a string
  1644. at the specified character offset. Insert the data at
  1645. the end of the character data.
  1646. Retrieve the character data from the second child of
  1647. the first employee. The "insertData(offset,arg)"
  1648. method is then called with offset=15 and arg=", Esquire".
  1649. The method should insert the string ", Esquire" at
  1650. position 15. The new value of the character data should
  1651. be "Margaret Martin, Esquire".
  1652. * @author NIST
  1653. * @author Mary Brady
  1654. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1655. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F
  1656. */
  1657. characterdatainsertdataend: function(test) {
  1658. var success;
  1659. var doc;
  1660. var elementList;
  1661. var nameNode;
  1662. var child;
  1663. var childData;
  1664. doc = staff.staff();
  1665. elementList = doc.getElementsByTagName("name");
  1666. nameNode = elementList.item(0);
  1667. child = nameNode.firstChild;
  1668. child.insertData(15,", Esquire");
  1669. childData = child.data;
  1670. test.equal(childData, 'Margaret Martin, Esquire', 'characterdataInsertDataEndAssert');
  1671. test.done();
  1672. },
  1673. /**
  1674. *
  1675. The "insertData(offset,arg)" method will insert a string
  1676. at the specified character offset. Insert the data in
  1677. the middle of the character data.
  1678. Retrieve the character data from the second child of
  1679. the first employee. The "insertData(offset,arg)"
  1680. method is then called with offset=9 and arg="Ann".
  1681. The method should insert the string "Ann" at position 9.
  1682. The new value of the character data should be
  1683. "Margaret Ann Martin".
  1684. * @author NIST
  1685. * @author Mary Brady
  1686. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1687. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F
  1688. */
  1689. characterdatainsertdatamiddle: function(test) {
  1690. var success;
  1691. var doc;
  1692. var elementList;
  1693. var nameNode;
  1694. var child;
  1695. var childData;
  1696. doc = staff.staff();
  1697. elementList = doc.getElementsByTagName("name");
  1698. nameNode = elementList.item(0);
  1699. child = nameNode.firstChild;
  1700. child.insertData(9,"Ann ");
  1701. childData = child.data;
  1702. test.equal(childData, 'Margaret Ann Martin', 'characterdataInsertDataMiddleAssert');
  1703. test.done();
  1704. },
  1705. /**
  1706. *
  1707. The "insertData(offset,arg)" method raises a NO_MODIFICATION_ALLOWED_ERR
  1708. DOMException if the node is readonly.
  1709. Obtain the children of the THIRD "gender" element. The elements
  1710. content is an entity reference. Get the FIRST item
  1711. from the entity reference and execute the "insertData(offset,arg)" method.
  1712. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  1713. * @author NIST
  1714. * @author Mary Brady
  1715. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  1716. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F
  1717. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-3EDB695F')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  1718. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F
  1719. */
  1720. characterdatainsertdatanomodificationallowederr: function(test) {
  1721. var success;
  1722. var doc;
  1723. var genderList;
  1724. var genderNode;
  1725. var entElement;
  1726. var nodeType;
  1727. var entElementContent;
  1728. var entReference;
  1729. doc = staff.staff();
  1730. genderList = doc.getElementsByTagName("gender");
  1731. genderNode = genderList.item(2);
  1732. entReference = genderNode.firstChild;
  1733. test.notEqual(entReference, null, 'entReferenceNotNull');
  1734. nodeType = entReference.nodeType;
  1735. if(
  1736. (1 == nodeType)
  1737. ) {
  1738. entReference = doc.createEntityReference("ent4");
  1739. test.notEqual(entReference, null, 'createdEntRefNotNull');
  1740. }
  1741. entElement = entReference.firstChild;
  1742. test.notEqual(entElement, null, 'entElementNotNull');
  1743. entElementContent = entElement.firstChild;
  1744. test.notEqual(entElementContent, null, 'entElementContentNotNull');
  1745. {
  1746. success = false;
  1747. try {
  1748. entElementContent.insertData(1,"newArg");
  1749. }
  1750. catch(ex) {
  1751. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  1752. }
  1753. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  1754. }
  1755. test.done();
  1756. },
  1757. /**
  1758. *
  1759. Create an ent3 entity reference and call insertData on a text child, should thrown a NO_MODIFICATION_ALLOWED_ERR.
  1760. * @author Curt Arnold
  1761. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  1762. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F
  1763. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-3EDB695F')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  1764. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F
  1765. * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatainsertdatanomodificationallowederr.xml
  1766. */
  1767. characterdatainsertdatanomodificationallowederrEE: function(test) {
  1768. var success;
  1769. var doc;
  1770. var genderList;
  1771. var genderNode;
  1772. var entText;
  1773. var entReference;
  1774. doc = staff.staff();
  1775. genderList = doc.getElementsByTagName("gender");
  1776. genderNode = genderList.item(2);
  1777. entReference = doc.createEntityReference("ent3");
  1778. test.notEqual(entReference, null, 'createdEntRefNotNull');
  1779. entText = entReference.firstChild;
  1780. test.notEqual(entText, null, 'entTextNotNull');
  1781. {
  1782. success = false;
  1783. try {
  1784. entText.insertData(1,"newArg");
  1785. }
  1786. catch(ex) {
  1787. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  1788. }
  1789. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  1790. }
  1791. test.done();
  1792. },
  1793. /**
  1794. *
  1795. The "replaceData(offset,count,arg)" method replaces the
  1796. characters starting at the specified offset with the
  1797. specified string. Test for replacement in the
  1798. middle of the data.
  1799. Retrieve the character data from the last child of the
  1800. first employee. The "replaceData(offset,count,arg)"
  1801. method is then called with offset=5 and count=5 and
  1802. arg="South". The method should replace characters five
  1803. thru 9 of the character data with "South".
  1804. * @author NIST
  1805. * @author Mary Brady
  1806. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  1807. */
  1808. characterdatareplacedatabegining: function(test) {
  1809. var success;
  1810. var doc;
  1811. var elementList;
  1812. var nameNode;
  1813. var child;
  1814. var childData;
  1815. doc = staff.staff();
  1816. elementList = doc.getElementsByTagName("address");
  1817. nameNode = elementList.item(0);
  1818. child = nameNode.firstChild;
  1819. child.replaceData(0,4,"2500");
  1820. childData = child.data;
  1821. test.equal(childData, '2500 North Ave. Dallas, Texas 98551', 'characterdataReplaceDataBeginingAssert');
  1822. test.done();
  1823. },
  1824. /**
  1825. *
  1826. The "replaceData(offset,count,arg)" method replaces the
  1827. characters starting at the specified offset with the
  1828. specified string. Test for replacement at the
  1829. end of the data.
  1830. Retrieve the character data from the last child of the
  1831. first employee. The "replaceData(offset,count,arg)"
  1832. method is then called with offset=30 and count=5 and
  1833. arg="98665". The method should replace characters 30
  1834. thru 34 of the character data with "98665".
  1835. * @author NIST
  1836. * @author Mary Brady
  1837. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1838. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  1839. */
  1840. characterdatareplacedataend: function(test) {
  1841. var success;
  1842. var doc;
  1843. var elementList;
  1844. var nameNode;
  1845. var child;
  1846. var childData;
  1847. doc = staff.staff();
  1848. elementList = doc.getElementsByTagName("address");
  1849. nameNode = elementList.item(0);
  1850. child = nameNode.firstChild;
  1851. child.replaceData(30,5,"98665");
  1852. childData = child.data;
  1853. test.equal(childData, '1230 North Ave. Dallas, Texas 98665', 'characterdataReplaceDataEndAssert');
  1854. test.done();
  1855. },
  1856. /**
  1857. *
  1858. The "replaceData(offset,count,arg)" method replaces the
  1859. characters starting at the specified offset with the
  1860. specified string. Test the situation where the length
  1861. of the arg string is greater than the specified offset.
  1862. Retrieve the character data from the last child of the
  1863. first employee. The "replaceData(offset,count,arg)"
  1864. method is then called with offset=0 and count=4 and
  1865. arg="260030". The method should replace characters one
  1866. thru four with "260030". Note that the length of the
  1867. specified string is greater that the specified offset.
  1868. * @author NIST
  1869. * @author Mary Brady
  1870. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1871. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  1872. */
  1873. characterdatareplacedataexceedslengthofarg: function(test) {
  1874. var success;
  1875. var doc;
  1876. var elementList;
  1877. var nameNode;
  1878. var child;
  1879. var childData;
  1880. doc = staff.staff();
  1881. elementList = doc.getElementsByTagName("address");
  1882. nameNode = elementList.item(0);
  1883. child = nameNode.firstChild;
  1884. child.replaceData(0,4,"260030");
  1885. childData = child.data;
  1886. test.equal(childData, '260030 North Ave. Dallas, Texas 98551', 'characterdataReplaceDataExceedsLengthOfArgAssert');
  1887. test.done();
  1888. },
  1889. /**
  1890. *
  1891. If the sum of the offset and count exceeds the length then
  1892. all the characters to the end of the data are replaced.
  1893. Retrieve the character data from the last child of the
  1894. first employee. The "replaceData(offset,count,arg)"
  1895. method is then called with offset=0 and count=50 and
  1896. arg="2600". The method should replace all the characters
  1897. with "2600". This is because the sum of the offset and
  1898. count exceeds the length of the character data.
  1899. * @author NIST
  1900. * @author Mary Brady
  1901. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1902. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  1903. */
  1904. characterdatareplacedataexceedslengthofdata: function(test) {
  1905. var success;
  1906. var doc;
  1907. var elementList;
  1908. var nameNode;
  1909. var child;
  1910. var childData;
  1911. doc = staff.staff();
  1912. elementList = doc.getElementsByTagName("address");
  1913. nameNode = elementList.item(0);
  1914. child = nameNode.firstChild;
  1915. child.replaceData(0,50,"2600");
  1916. childData = child.data;
  1917. test.equal(childData, '2600', 'characterdataReplaceDataExceedsLengthOfDataAssert');
  1918. test.done();
  1919. },
  1920. /**
  1921. *
  1922. The "replaceData(offset,count,arg)" method replaces the
  1923. characters starting at the specified offset with the
  1924. specified string. Test for replacement in the
  1925. middle of the data.
  1926. Retrieve the character data from the last child of the
  1927. first employee. The "replaceData(offset,count,arg)"
  1928. method is then called with offset=5 and count=5 and
  1929. arg="South". The method should replace characters five
  1930. thru 9 of the character data with "South".
  1931. * @author NIST
  1932. * @author Mary Brady
  1933. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  1934. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  1935. */
  1936. characterdatareplacedatamiddle: function(test) {
  1937. var success;
  1938. var doc;
  1939. var elementList;
  1940. var nameNode;
  1941. var child;
  1942. var childData;
  1943. doc = staff.staff();
  1944. elementList = doc.getElementsByTagName("address");
  1945. nameNode = elementList.item(0);
  1946. child = nameNode.firstChild;
  1947. child.replaceData(5,5,"South");
  1948. childData = child.data;
  1949. test.equal(childData, '1230 South Ave. Dallas, Texas 98551', 'characterdataReplaceDataMiddleAssert');
  1950. test.done();
  1951. },
  1952. /**
  1953. *
  1954. The "replaceData(offset,count,arg)" method raises a NO_MODIFICATION_ALLOWED_ERR
  1955. DOMException if the node is readonly.
  1956. Obtain the children of the THIRD "gender" element. The elements
  1957. content is an entity reference. Get the FIRST item
  1958. from the entity reference and execute the "replaceData(offset,count,arg)" method.
  1959. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  1960. * @author NIST
  1961. * @author Mary Brady
  1962. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  1963. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  1964. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  1965. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  1966. */
  1967. characterdatareplacedatanomodificationallowederr: function(test) {
  1968. var success;
  1969. var doc;
  1970. var genderList;
  1971. var genderNode;
  1972. var entElement;
  1973. var entElementContent;
  1974. var entReference;
  1975. var nodeType;
  1976. doc = staff.staff();
  1977. genderList = doc.getElementsByTagName("gender");
  1978. genderNode = genderList.item(2);
  1979. entReference = genderNode.firstChild;
  1980. test.notEqual(entReference, null, 'entReferenceNotNull');
  1981. nodeType = entReference.nodeType;
  1982. if(
  1983. (1 == nodeType)
  1984. ) {
  1985. entReference = doc.createEntityReference("ent4");
  1986. test.notEqual(entReference, null, 'createdEntRefNotNull');
  1987. }
  1988. entElement = entReference.firstChild;
  1989. test.notEqual(entElement, null, 'entElementNotNull');
  1990. entElementContent = entElement.firstChild;
  1991. test.notEqual(entElementContent, null, 'entElementContentNotNull');
  1992. {
  1993. success = false;
  1994. try {
  1995. entElementContent.replaceData(1,3,"newArg");
  1996. }
  1997. catch(ex) {
  1998. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  1999. }
  2000. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  2001. }
  2002. test.done();
  2003. },
  2004. /**
  2005. *
  2006. Create an ent3 entity reference and call replaceData on a text child, should thrown a NO_MODIFICATION_ALLOWED_ERR.
  2007. * @author Curt Arnold
  2008. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  2009. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  2010. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  2011. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  2012. * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatareplacedatanomodificationallowederr.xml
  2013. */
  2014. characterdatareplacedatanomodificationallowederrEE: function(test) {
  2015. var success;
  2016. var doc;
  2017. var genderList;
  2018. var genderNode;
  2019. var entText;
  2020. var entReference;
  2021. var appendedNode;
  2022. doc = staff.staff();
  2023. genderList = doc.getElementsByTagName("gender");
  2024. genderNode = genderList.item(2);
  2025. entReference = doc.createEntityReference("ent3");
  2026. test.notEqual(entReference, null, 'createdEntRefNotNull');
  2027. appendedNode = genderNode.appendChild(entReference);
  2028. entText = entReference.firstChild;
  2029. test.notEqual(entText, null, 'entTextNotNull');
  2030. {
  2031. success = false;
  2032. try {
  2033. entText.replaceData(1,3,"newArg");
  2034. }
  2035. catch(ex) {
  2036. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  2037. }
  2038. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  2039. }
  2040. test.done();
  2041. },
  2042. /**
  2043. *
  2044. The "setData(data)" method raises a NO_MODIFICATION_ALLOWED_ERR
  2045. DOMException if the node is readonly.
  2046. Obtain the children of the THIRD "gender" element. The elements
  2047. content is an entity reference. Get the FIRST item
  2048. from the entity reference and execute the "setData(data)" method.
  2049. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  2050. * @author NIST
  2051. * @author Mary Brady
  2052. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  2053. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  2054. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-72AB8359')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  2055. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  2056. */
  2057. characterdatasetdatanomodificationallowederr: function(test) {
  2058. var success;
  2059. var doc;
  2060. var genderList;
  2061. var genderNode;
  2062. var entElement;
  2063. var entElementContent;
  2064. var entReference;
  2065. var nodeType;
  2066. doc = staff.staff();
  2067. genderList = doc.getElementsByTagName("gender");
  2068. genderNode = genderList.item(2);
  2069. entReference = genderNode.firstChild;
  2070. test.notEqual(entReference, null, 'entReferenceNotNull');
  2071. nodeType = entReference.nodeType;
  2072. if(
  2073. (1 == nodeType)
  2074. ) {
  2075. entReference = doc.createEntityReference("ent4");
  2076. test.notEqual(entReference, null, 'createdEntRefNotNull');
  2077. }
  2078. entElement = entReference.firstChild;
  2079. test.notEqual(entElement, null, 'entElementNotNull');
  2080. entElementContent = entElement.firstChild;
  2081. test.notEqual(entElementContent, null, 'entElementContentNotNull');
  2082. {
  2083. success = false;
  2084. try {
  2085. entElementContent.data = "newData";
  2086. }
  2087. catch(ex) {
  2088. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  2089. }
  2090. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  2091. }
  2092. test.done();
  2093. },
  2094. /**
  2095. *
  2096. Create an ent3 entity reference and call setData on a text child, should thrown a NO_MODIFICATION_ALLOWED_ERR.
  2097. * @author Curt Arnold
  2098. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  2099. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  2100. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-72AB8359')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  2101. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  2102. * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/characterdatasetdatanomodificationallowederr.xml
  2103. */
  2104. characterdatasetdatanomodificationallowederrEE: function(test) {
  2105. var success;
  2106. var doc;
  2107. var genderList;
  2108. var genderNode;
  2109. var entText;
  2110. var entReference;
  2111. doc = staff.staff();
  2112. genderList = doc.getElementsByTagName("gender");
  2113. genderNode = genderList.item(4);
  2114. entReference = doc.createEntityReference("ent3");
  2115. test.notEqual(entReference, null, 'createdEntRefNotNull');
  2116. entText = entReference.firstChild;
  2117. test.notEqual(entText, null, 'entTextNotNull');
  2118. {
  2119. success = false;
  2120. try {
  2121. entText.data = "newData";
  2122. }
  2123. catch(ex) {
  2124. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  2125. }
  2126. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  2127. }
  2128. test.done();
  2129. },
  2130. /**
  2131. *
  2132. The "setNodeValue()" method changes the character data
  2133. currently stored in the node.
  2134. Retrieve the character data from the second child
  2135. of the first employee and invoke the "setNodeValue()"
  2136. method, call "getData()" and compare.
  2137. * @author Curt Arnold
  2138. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  2139. */
  2140. characterdatasetnodevalue: function(test) {
  2141. var success;
  2142. var doc;
  2143. var elementList;
  2144. var nameNode;
  2145. var child;
  2146. var childData;
  2147. var childValue;
  2148. doc = staff.staff();
  2149. elementList = doc.getElementsByTagName("name");
  2150. nameNode = elementList.item(0);
  2151. child = nameNode.firstChild;
  2152. child.nodeValue = "Marilyn Martin";
  2153. childData = child.data;
  2154. test.equal(childData, 'Marilyn Martin', 'data');
  2155. childValue = child.nodeValue;
  2156. test.equal(childValue, 'Marilyn Martin', 'value');
  2157. test.done();
  2158. },
  2159. /**
  2160. *
  2161. If the sum of the "offset" and "count" exceeds the
  2162. "length" then the "substringData(offset,count)" method
  2163. returns all the characters to the end of the data.
  2164. Retrieve the character data from the second child
  2165. of the first employee and access part of the data
  2166. by using the substringData(offset,count) method
  2167. with offset=9 and count=10. The method should return
  2168. the substring "Martin" since offset+count > length
  2169. (19 > 15).
  2170. * @author NIST
  2171. * @author Mary Brady
  2172. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  2173. */
  2174. characterdatasubstringexceedsvalue: function(test) {
  2175. var success;
  2176. var doc;
  2177. var elementList;
  2178. var nameNode;
  2179. var child;
  2180. var substring;
  2181. doc = staff.staff();
  2182. elementList = doc.getElementsByTagName("name");
  2183. nameNode = elementList.item(0);
  2184. child = nameNode.firstChild;
  2185. substring = child.substringData(9,10);
  2186. test.equal(substring, 'Martin', 'characterdataSubStringExceedsValueAssert');
  2187. test.done();
  2188. },
  2189. /**
  2190. *
  2191. The "substringData(offset,count)" method returns the
  2192. specified string.
  2193. Retrieve the character data from the second child
  2194. of the first employee and access part of the data
  2195. by using the substringData(offset,count) method. The
  2196. method should return the specified substring starting
  2197. at position "offset" and extract "count" characters.
  2198. The method should return the string "Margaret".
  2199. * @author NIST
  2200. * @author Mary Brady
  2201. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  2202. */
  2203. characterdatasubstringvalue: function(test) {
  2204. var success;
  2205. var doc;
  2206. var elementList;
  2207. var nameNode;
  2208. var child;
  2209. var substring;
  2210. doc = staff.staff();
  2211. elementList = doc.getElementsByTagName("name");
  2212. nameNode = elementList.item(0);
  2213. child = nameNode.firstChild;
  2214. substring = child.substringData(0,8);
  2215. test.equal(substring, 'Margaret', 'characterdataSubStringValueAssert');
  2216. test.done();
  2217. },
  2218. /**
  2219. *
  2220. A comment is all the characters between the starting
  2221. '<!--' and ending '-->'
  2222. Retrieve the nodes of the DOM document. Search for a
  2223. comment node and the content is its value.
  2224. * @author NIST
  2225. * @author Mary Brady
  2226. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1334481328
  2227. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  2228. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  2229. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  2230. */
  2231. commentgetcomment: function(test) {
  2232. var success;
  2233. var doc;
  2234. var elementList;
  2235. var child;
  2236. var childName;
  2237. var childValue;
  2238. var commentCount = 0;
  2239. var childType;
  2240. doc = staff.staff();
  2241. elementList = doc.childNodes;
  2242. for(var indexN10057 = 0;indexN10057 < elementList.length; indexN10057++) {
  2243. child = elementList.item(indexN10057);
  2244. childType = child.nodeType;
  2245. if(
  2246. (8 == childType)
  2247. ) {
  2248. childName = child.nodeName;
  2249. test.equal(childName, '#comment', 'nodeName');
  2250. childValue = child.nodeValue;
  2251. test.equal(childValue, ' This is comment number 1.', 'nodeValue');
  2252. commentCount = commentCount + 1;
  2253. }
  2254. }
  2255. test.equal(commentCount, 1, 'commentCount');
  2256. test.done();
  2257. },
  2258. /**
  2259. *
  2260. The "createAttribute(name)" method creates an Attribute
  2261. node of the given name.
  2262. Retrieve the entire DOM document and invoke its
  2263. "createAttribute(name)" method. It should create a
  2264. new Attribute node with the given name. The name, value
  2265. and type of the newly created object are retrieved and
  2266. output.
  2267. * @author NIST
  2268. * @author Mary Brady
  2269. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198
  2270. */
  2271. documentcreateattribute: function(test) {
  2272. var success;
  2273. var doc;
  2274. var newAttrNode;
  2275. var attrValue;
  2276. var attrName;
  2277. var attrType;
  2278. doc = staff.staff();
  2279. newAttrNode = doc.createAttribute("district");
  2280. attrValue = newAttrNode.nodeValue;
  2281. test.equal(attrValue, '', 'value');
  2282. attrName = newAttrNode.nodeName;
  2283. test.equal(attrName, 'district', 'name');
  2284. attrType = newAttrNode.nodeType;
  2285. test.equal(attrType, 2, 'type');
  2286. test.done();
  2287. },
  2288. /**
  2289. *
  2290. The "createCDATASection(data)" method creates a new
  2291. CDATASection node whose value is the specified string.
  2292. Retrieve the entire DOM document and invoke its
  2293. "createCDATASection(data)" method. It should create a
  2294. new CDATASection node whose "data" is the specified
  2295. string. The content, name and type are retrieved and
  2296. output.
  2297. * @author NIST
  2298. * @author Mary Brady
  2299. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D26C0AF8
  2300. */
  2301. documentcreatecdatasection: function(test) {
  2302. var success;
  2303. var doc;
  2304. var newCDATASectionNode;
  2305. var newCDATASectionValue;
  2306. var newCDATASectionName;
  2307. var newCDATASectionType;
  2308. doc = staff.staff();
  2309. newCDATASectionNode = doc.createCDATASection("This is a new CDATASection node");
  2310. newCDATASectionValue = newCDATASectionNode.nodeValue;
  2311. test.equal(newCDATASectionValue, 'This is a new CDATASection node', 'nodeValue');
  2312. newCDATASectionName = newCDATASectionNode.nodeName;
  2313. test.equal(newCDATASectionName, '#cdata-section', 'nodeName');
  2314. newCDATASectionType = newCDATASectionNode.nodeType;
  2315. test.equal(newCDATASectionType, 4, 'nodeType');
  2316. test.done();
  2317. },
  2318. /**
  2319. *
  2320. The "createComment(data)" method creates a new Comment
  2321. node given the specified string.
  2322. Retrieve the entire DOM document and invoke its
  2323. "createComment(data)" method. It should create a new
  2324. Comment node whose "data" is the specified string.
  2325. The content, name and type are retrieved and output.
  2326. * @author NIST
  2327. * @author Mary Brady
  2328. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1334481328
  2329. */
  2330. documentcreatecomment: function(test) {
  2331. var success;
  2332. var doc;
  2333. var newCommentNode;
  2334. var newCommentValue;
  2335. var newCommentName;
  2336. var newCommentType;
  2337. doc = staff.staff();
  2338. newCommentNode = doc.createComment("This is a new Comment node");
  2339. newCommentValue = newCommentNode.nodeValue;
  2340. test.equal(newCommentValue, 'This is a new Comment node', 'value');
  2341. newCommentName = newCommentNode.nodeName;
  2342. test.equal(newCommentName, '#comment', 'name');
  2343. newCommentType = newCommentNode.nodeType;
  2344. test.equal(newCommentType, 8, 'type');
  2345. test.done();
  2346. },
  2347. /**
  2348. *
  2349. The "createDocumentFragment()" method creates an empty
  2350. DocumentFragment object.
  2351. Retrieve the entire DOM document and invoke its
  2352. "createDocumentFragment()" method. The content, name,
  2353. type and value of the newly created object are output.
  2354. * @author NIST
  2355. * @author Mary Brady
  2356. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-35CB04B5
  2357. */
  2358. documentcreatedocumentfragment: function(test) {
  2359. var success;
  2360. var doc;
  2361. var newDocFragment;
  2362. var children;
  2363. var length;
  2364. var newDocFragmentName;
  2365. var newDocFragmentType;
  2366. var newDocFragmentValue;
  2367. doc = staff.staff();
  2368. newDocFragment = doc.createDocumentFragment();
  2369. children = newDocFragment.childNodes;
  2370. length = children.length;
  2371. test.equal(length, 0, 'length');
  2372. newDocFragmentName = newDocFragment.nodeName;
  2373. test.equal(newDocFragmentName, '#document-fragment', 'name');
  2374. newDocFragmentType = newDocFragment.nodeType;
  2375. test.equal(newDocFragmentType, 11, 'type');
  2376. newDocFragmentValue = newDocFragment.nodeValue;
  2377. test.equal(newDocFragmentValue, null, 'value');
  2378. test.done();
  2379. },
  2380. /**
  2381. *
  2382. The "createElement(tagName)" method creates an Element
  2383. of the type specified.
  2384. Retrieve the entire DOM document and invoke its
  2385. "createElement(tagName)" method with tagName="address".
  2386. The method should create an instance of an Element node
  2387. whose tagName is "address". The NodeName, NodeType
  2388. and NodeValue are returned.
  2389. * @author NIST
  2390. * @author Mary Brady
  2391. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
  2392. */
  2393. documentcreateelement: function(test) {
  2394. var success;
  2395. var doc;
  2396. var newElement;
  2397. var newElementName;
  2398. var newElementType;
  2399. var newElementValue;
  2400. doc = staff.staff();
  2401. newElement = doc.createElement("address");
  2402. newElementName = newElement.nodeName;
  2403. test.equal(newElementName, 'address', 'name');
  2404. newElementType = newElement.nodeType;
  2405. test.equal(newElementType, 1, 'type');
  2406. newElementValue = newElement.nodeValue;
  2407. test.equal(newElementValue, null, 'valueInitiallyNull');
  2408. test.done();
  2409. },
  2410. /**
  2411. *
  2412. The tagName parameter in the "createElement(tagName)"
  2413. method is case-sensitive for XML documents.
  2414. Retrieve the entire DOM document and invoke its
  2415. "createElement(tagName)" method twice. Once for tagName
  2416. equal to "address" and once for tagName equal to "ADDRESS"
  2417. Each call should create a distinct Element node. The
  2418. newly created Elements are then assigned attributes
  2419. that are retrieved.
  2420. * @author NIST
  2421. * @author Mary Brady
  2422. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
  2423. */
  2424. documentcreateelementcasesensitive: function(test) {
  2425. var success;
  2426. var doc;
  2427. var newElement1;
  2428. var newElement2;
  2429. var attribute1;
  2430. var attribute2;
  2431. doc = staff.staff();
  2432. newElement1 = doc.createElement("ADDRESS");
  2433. newElement2 = doc.createElement("address");
  2434. newElement1.setAttribute("district","Fort Worth");
  2435. newElement2.setAttribute("county","Dallas");
  2436. attribute1 = newElement1.getAttribute("district");
  2437. attribute2 = newElement2.getAttribute("county");
  2438. test.equal(attribute1, 'Fort Worth', 'attrib1');
  2439. test.equal(attribute2, 'Dallas', 'attrib2');
  2440. test.done();
  2441. },
  2442. /**
  2443. *
  2444. The "createElement(tagName)" method creates an Element
  2445. of the type specified. In addition, if there are known attributes
  2446. with default values, Attr nodes representing them are automatically
  2447. created and attached to the element.
  2448. Retrieve the entire DOM document and invoke its
  2449. "createElement(tagName)" method with tagName="address".
  2450. The method should create an instance of an Element node
  2451. whose tagName is "address". The tagName "address" has an
  2452. attribute with default values, therefore the newly created element
  2453. will have them.
  2454. * @author NIST
  2455. * @author Mary Brady
  2456. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
  2457. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html
  2458. */
  2459. documentcreateelementdefaultattr: function(test) {
  2460. var success;
  2461. var doc;
  2462. var newElement;
  2463. var defaultAttr;
  2464. var child;
  2465. var name;
  2466. var value;
  2467. doc = staff.staff();
  2468. newElement = doc.createElement("address");
  2469. defaultAttr = newElement.attributes;
  2470. child = defaultAttr.item(0);
  2471. test.notEqual(child, null, 'defaultAttrNotNull');
  2472. name = child.nodeName;
  2473. test.equal(name, 'street', 'attrName');
  2474. value = child.nodeValue;
  2475. test.equal(value, 'Yes', 'attrValue');
  2476. test.equal(defaultAttr.length, 1, 'attrCount');
  2477. test.done();
  2478. },
  2479. /**
  2480. *
  2481. The "createEntityReference(name)" method creates an
  2482. EntityReferrence node.
  2483. Retrieve the entire DOM document and invoke its
  2484. "createEntityReference(name)" method. It should create
  2485. a new EntityReference node for the Entity with the
  2486. given name. The name, value and type are retrieved and
  2487. output.
  2488. * @author NIST
  2489. * @author Mary Brady
  2490. * @author Curt Arnold
  2491. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-392B75AE
  2492. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  2493. */
  2494. documentcreateentityreference: function(test) {
  2495. var success;
  2496. var doc;
  2497. var newEntRefNode;
  2498. var entRefValue;
  2499. var entRefName;
  2500. var entRefType;
  2501. doc = staff.staff();
  2502. newEntRefNode = doc.createEntityReference("ent1");
  2503. test.notEqual(newEntRefNode, null, 'createdEntRefNotNull');
  2504. entRefValue = newEntRefNode.nodeValue;
  2505. test.equal(entRefValue, null, 'value');
  2506. entRefName = newEntRefNode.nodeName;
  2507. test.equal(entRefName, 'ent1', 'name');
  2508. entRefType = newEntRefNode.nodeType;
  2509. test.equal(entRefType, 5, 'type');
  2510. test.done();
  2511. },
  2512. /**
  2513. *
  2514. The "createEntityReference(name)" method creates an
  2515. EntityReference node. In addition, if the referenced entity
  2516. is known, the child list of the "EntityReference" node
  2517. is the same as the corresponding "Entity" node.
  2518. Retrieve the entire DOM document and invoke its
  2519. "createEntityReference(name)" method. It should create
  2520. a new EntityReference node for the Entity with the
  2521. given name. The referenced entity is known, therefore the child
  2522. list of the "EntityReference" node is the same as the corresponding
  2523. "Entity" node.
  2524. * @author NIST
  2525. * @author Mary Brady
  2526. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-392B75AE
  2527. */
  2528. documentcreateentityreferenceknown: function(test) {
  2529. var success;
  2530. var doc;
  2531. var newEntRefNode;
  2532. var newEntRefList;
  2533. var child;
  2534. var name;
  2535. var value;
  2536. doc = staff.staff();
  2537. newEntRefNode = doc.createEntityReference("ent3");
  2538. test.notEqual(newEntRefNode, null, 'createdEntRefNotNull');
  2539. newEntRefList = newEntRefNode.childNodes;
  2540. test.equal(newEntRefList.length, 1, 'size');
  2541. child = newEntRefNode.firstChild;
  2542. name = child.nodeName;
  2543. test.equal(name, '#text', 'name');
  2544. value = child.nodeValue;
  2545. test.equal(value, 'Texas', 'value');
  2546. test.done();
  2547. },
  2548. /**
  2549. *
  2550. The "createProcessingInstruction(target,data)" method
  2551. creates a new ProcessingInstruction node with the
  2552. specified name and data string.
  2553. Retrieve the entire DOM document and invoke its
  2554. "createProcessingInstruction(target,data)" method.
  2555. It should create a new PI node with the specified target
  2556. and data. The target, data and type are retrieved and
  2557. output.
  2558. * @author NIST
  2559. * @author Mary Brady
  2560. * @author Curt Arnold
  2561. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#
  2562. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2001Apr/0020.html
  2563. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-135944439
  2564. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  2565. */
  2566. documentcreateprocessinginstruction: function(test) {
  2567. var success;
  2568. var doc;
  2569. var newPINode;
  2570. var piValue;
  2571. var piName;
  2572. var piType;
  2573. doc = staff.staff();
  2574. newPINode = doc.createProcessingInstruction("TESTPI","This is a new PI node");
  2575. test.notEqual(newPINode, null, 'createdPINotNull');
  2576. piName = newPINode.nodeName;
  2577. test.equal(piName, 'TESTPI', 'name');
  2578. piValue = newPINode.nodeValue;
  2579. test.equal(piValue, 'This is a new PI node', 'value');
  2580. piType = newPINode.nodeType;
  2581. test.equal(piType, 7, 'type');
  2582. test.done();
  2583. },
  2584. /**
  2585. *
  2586. The "createTextNode(data)" method creates a Text node
  2587. given the specfied string.
  2588. Retrieve the entire DOM document and invoke its
  2589. "createTextNode(data)" method. It should create a
  2590. new Text node whose "data" is the specified string.
  2591. The NodeName and NodeType are also checked.
  2592. * @author NIST
  2593. * @author Mary Brady
  2594. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1975348127
  2595. */
  2596. documentcreatetextnode: function(test) {
  2597. var success;
  2598. var doc;
  2599. var newTextNode;
  2600. var newTextName;
  2601. var newTextValue;
  2602. var newTextType;
  2603. doc = staff.staff();
  2604. newTextNode = doc.createTextNode("This is a new Text node");
  2605. newTextValue = newTextNode.nodeValue;
  2606. test.equal(newTextValue, 'This is a new Text node', 'value');
  2607. newTextName = newTextNode.nodeName;
  2608. test.equal(newTextName, '#text', 'name');
  2609. newTextType = newTextNode.nodeType;
  2610. test.equal(newTextType, 3, 'type');
  2611. test.done();
  2612. },
  2613. /**
  2614. *
  2615. The "getDoctype()" method returns the Document
  2616. Type Declaration associated with this document.
  2617. Retrieve the entire DOM document and invoke its
  2618. "getDoctype()" method. The name of the document
  2619. type should be returned. The "getName()" method
  2620. should be equal to "staff" or "svg".
  2621. * @author NIST
  2622. * @author Mary Brady
  2623. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31
  2624. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  2625. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  2626. */
  2627. documentgetdoctype: function(test) {
  2628. var success;
  2629. var doc;
  2630. var docType;
  2631. var docTypeName;
  2632. var nodeValue;
  2633. doc = staff.staff();
  2634. docType = doc.doctype;
  2635. test.notEqual(docType, null, 'docTypeNotNull');
  2636. docTypeName = docType.name;
  2637. test.equal(docTypeName, 'svg', 'doctypeNameSVG');
  2638. nodeValue = docType.nodeValue;
  2639. test.equal(nodeValue, null, 'initiallyNull');
  2640. test.done();
  2641. },
  2642. /**
  2643. *
  2644. The "getDoctype()" method returns null for XML documents
  2645. without a document type declaration.
  2646. Retrieve the XML document without a DTD and invoke the
  2647. "getDoctype()" method. It should return null.
  2648. * @author NIST
  2649. * @author Mary Brady
  2650. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31
  2651. */
  2652. documentgetdoctypenodtd: function(test) {
  2653. var success;
  2654. var doc;
  2655. var docType;
  2656. doc = hc_nodtdstaff.hc_nodtdstaff();
  2657. docType = doc.doctype;
  2658. test.equal(docType, null, 'documentGetDocTypeNoDTDAssert');
  2659. test.done();
  2660. },
  2661. /**
  2662. *
  2663. The "getElementsByTagName(tagName)" method returns a
  2664. NodeList of all the Elements with a given tagName.
  2665. Retrieve the entire DOM document and invoke its
  2666. "getElementsByTagName(tagName)" method with tagName
  2667. equal to "name". The method should return a NodeList
  2668. that contains 5 elements.
  2669. * @author NIST
  2670. * @author Mary Brady
  2671. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094
  2672. */
  2673. documentgetelementsbytagnamelength: function(test) {
  2674. var success;
  2675. var doc;
  2676. var nameList;
  2677. doc = staff.staff();
  2678. nameList = doc.getElementsByTagName("name");
  2679. test.equal(nameList.length, 5, 'documentGetElementsByTagNameLengthAssert');
  2680. test.done();
  2681. },
  2682. /**
  2683. *
  2684. Retrieve the entire DOM document, invoke
  2685. getElementsByTagName("*") and check the length of the NodeList.
  2686. * @author NIST
  2687. * @author Mary Brady
  2688. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094
  2689. */
  2690. documentgetelementsbytagnametotallength: function(test) {
  2691. var success;
  2692. var doc;
  2693. var nameList;
  2694. doc = staff.staff();
  2695. nameList = doc.getElementsByTagName("*");
  2696. test.equal(nameList.length, 39, 'elementCountSVG');
  2697. test.done();
  2698. },
  2699. /**
  2700. *
  2701. The "getElementsByTagName(tagName)" method returns a
  2702. NodeList of all the Elements with a given tagName
  2703. in a pre-order traversal of the tree.
  2704. Retrieve the entire DOM document and invoke its
  2705. "getElementsByTagName(tagName)" method with tagName
  2706. equal to "name". The method should return a NodeList
  2707. that contains 5 elements. The FOURTH item in the
  2708. list is retrieved and output.
  2709. * @author NIST
  2710. * @author Mary Brady
  2711. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094
  2712. */
  2713. documentgetelementsbytagnamevalue: function(test) {
  2714. var success;
  2715. var doc;
  2716. var nameList;
  2717. var nameNode;
  2718. var firstChild;
  2719. var childValue;
  2720. doc = staff.staff();
  2721. nameList = doc.getElementsByTagName("name");
  2722. nameNode = nameList.item(3);
  2723. firstChild = nameNode.firstChild;
  2724. childValue = firstChild.nodeValue;
  2725. test.equal(childValue, 'Jeny Oconnor', 'documentGetElementsByTagNameValueAssert');
  2726. test.done();
  2727. },
  2728. /**
  2729. *
  2730. The "getImplementation()" method returns the
  2731. DOMImplementation object that handles this document.
  2732. Retrieve the entire DOM document and invoke its
  2733. "getImplementation()" method. It should return a
  2734. DOMImplementation whose "hasFeature("XML","1.0")
  2735. method returns the boolean value "true".
  2736. * @author NIST
  2737. * @author Mary Brady
  2738. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1B793EBA
  2739. */
  2740. documentgetimplementation: function(test) {
  2741. var success;
  2742. var doc;
  2743. var docImpl;
  2744. var state;
  2745. doc = staff.staff();
  2746. docImpl = doc.implementation;
  2747. state = docImpl.hasFeature("XML","1.0");
  2748. test.ok(state, 'documentGetImplementationAssert');
  2749. test.done();
  2750. },
  2751. /**
  2752. *
  2753. The "getDocumentElement()" method provides direct access
  2754. to the child node that is the root element of the document.
  2755. Retrieve the entire DOM document and invoke its
  2756. "getDocumentElement()" method. It should return an
  2757. Element node whose NodeName is "staff" (or "svg").
  2758. * @author NIST
  2759. * @author Mary Brady
  2760. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-87CD092
  2761. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
  2762. */
  2763. documentgetrootnode: function(test) {
  2764. var success;
  2765. var doc;
  2766. var root;
  2767. var rootName;
  2768. doc = staff.staff();
  2769. root = doc.documentElement;
  2770. rootName = root.nodeName;
  2771. test.equal(rootName, 'svg', 'svgRootNode');
  2772. test.done();
  2773. },
  2774. /**
  2775. *
  2776. The "createAttribute(tagName)" method raises an
  2777. INVALID_CHARACTER_ERR DOMException if the specified
  2778. tagName contains an invalid character.
  2779. Retrieve the entire DOM document and invoke its
  2780. "createAttribute(tagName)" method with the tagName equal
  2781. to the string "invalid^Name". Due to the invalid
  2782. character the desired EXCEPTION should be raised.
  2783. * @author NIST
  2784. * @author Mary Brady
  2785. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  2786. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198
  2787. * @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'])
  2788. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198
  2789. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  2790. */
  2791. documentinvalidcharacterexceptioncreateattribute: function(test) {
  2792. var success;
  2793. var doc;
  2794. var createdAttr;
  2795. doc = staff.staff();
  2796. {
  2797. success = false;
  2798. try {
  2799. createdAttr = doc.createAttribute("invalid^Name");
  2800. }
  2801. catch(ex) {
  2802. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  2803. }
  2804. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  2805. }
  2806. test.done();
  2807. },
  2808. /**
  2809. *
  2810. The "createElement(tagName)" method raises an
  2811. INVALID_CHARACTER_ERR DOMException if the specified
  2812. tagName contains an invalid character.
  2813. Retrieve the entire DOM document and invoke its
  2814. "createElement(tagName)" method with the tagName equal
  2815. to the string "invalid^Name". Due to the invalid
  2816. character the desired EXCEPTION should be raised.
  2817. * @author NIST
  2818. * @author Mary Brady
  2819. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  2820. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
  2821. * @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'])
  2822. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
  2823. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  2824. */
  2825. documentinvalidcharacterexceptioncreateelement: function(test) {
  2826. var success;
  2827. var doc;
  2828. var badElement;
  2829. doc = staff.staff();
  2830. {
  2831. success = false;
  2832. try {
  2833. badElement = doc.createElement("invalid^Name");
  2834. }
  2835. catch(ex) {
  2836. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  2837. }
  2838. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  2839. }
  2840. test.done();
  2841. },
  2842. /**
  2843. *
  2844. The "createEntityReference(tagName)" method raises an
  2845. INVALID_CHARACTER_ERR DOMException if the specified
  2846. tagName contains an invalid character.
  2847. * @author NIST
  2848. * @author Mary Brady
  2849. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  2850. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-392B75AE
  2851. * @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'])
  2852. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  2853. */
  2854. documentinvalidcharacterexceptioncreateentref: function(test) {
  2855. var success;
  2856. var doc;
  2857. var badEntityRef;
  2858. doc = hc_staff.hc_staff();
  2859. success = false;
  2860. try {
  2861. badEntityRef = doc.createEntityReference("invalid^Name");
  2862. } catch(ex) {
  2863. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  2864. }
  2865. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  2866. test.done();
  2867. },
  2868. /**
  2869. *
  2870. Creating an entity reference with an empty name should cause an INVALID_CHARACTER_ERR.
  2871. * @author Curt Arnold
  2872. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  2873. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-392B75AE
  2874. * @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'])
  2875. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525
  2876. */
  2877. documentinvalidcharacterexceptioncreateentref1: function(test) {
  2878. var success;
  2879. var doc;
  2880. var badEntityRef;
  2881. doc = hc_staff.hc_staff();
  2882. success = false;
  2883. try {
  2884. badEntityRef = doc.createEntityReference("");
  2885. }
  2886. catch(ex) {
  2887. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  2888. }
  2889. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  2890. test.done();
  2891. },
  2892. /**
  2893. *
  2894. The "createProcessingInstruction(target,data) method
  2895. raises an INVALID_CHARACTER_ERR DOMException if the
  2896. specified tagName contains an invalid character.
  2897. * @author NIST
  2898. * @author Mary Brady
  2899. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  2900. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-135944439
  2901. * @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'])
  2902. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  2903. */
  2904. documentinvalidcharacterexceptioncreatepi: function(test) {
  2905. var success;
  2906. var doc;
  2907. var badPI;
  2908. doc = hc_staff.hc_staff();
  2909. success = false;
  2910. try {
  2911. badPI = doc.createProcessingInstruction("invalid^Name","data");
  2912. }
  2913. catch(ex) {
  2914. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  2915. }
  2916. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  2917. test.done();
  2918. },
  2919. /**
  2920. *
  2921. Creating a processing instruction with an empty target should cause an INVALID_CHARACTER_ERR.
  2922. * @author Curt Arnold
  2923. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  2924. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-135944439
  2925. * @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'])
  2926. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525
  2927. */
  2928. documentinvalidcharacterexceptioncreatepi1: function(test) {
  2929. var success;
  2930. var doc;
  2931. var badPI;
  2932. doc = hc_staff.hc_staff();
  2933. success = false;
  2934. try {
  2935. badPI = doc.createProcessingInstruction("","data");
  2936. }
  2937. catch(ex) {
  2938. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  2939. }
  2940. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  2941. test.done();
  2942. },
  2943. /**
  2944. *
  2945. The "getName()" method contains the name of the DTD.
  2946. Retrieve the Document Type for this document and examine
  2947. the string returned by the "getName()" method.
  2948. It should be set to "staff".
  2949. * @author NIST
  2950. * @author Mary Brady
  2951. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31
  2952. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1844763134
  2953. */
  2954. documenttypegetdoctype: function(test) {
  2955. var success;
  2956. var doc;
  2957. var docType;
  2958. var name;
  2959. doc = staff.staff();
  2960. docType = doc.doctype;
  2961. test.notEqual(docType, null, 'docTypeNotNull');
  2962. name = docType.name;
  2963. test.equal(name, 'svg', 'doctypeName');
  2964. test.done();
  2965. },
  2966. /**
  2967. *
  2968. The "getEntities()" method is a NamedNodeMap that contains
  2969. the general entities for this document.
  2970. Retrieve the Document Type for this document and create
  2971. a NamedNodeMap of all its entities. The entire map is
  2972. traversed and the names of the entities are retrieved.
  2973. There should be 5 entities. Duplicates should be ignored.
  2974. * @author NIST
  2975. * @author Mary Brady
  2976. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1788794630
  2977. */
  2978. documenttypegetentities: function(test) {
  2979. var success;
  2980. var doc;
  2981. var docType;
  2982. var entityList;
  2983. var name;
  2984. expectedResult = new Array();
  2985. expectedResult[0] = "ent1";
  2986. expectedResult[1] = "ent2";
  2987. expectedResult[2] = "ent3";
  2988. expectedResult[3] = "ent4";
  2989. expectedResult[4] = "ent5";
  2990. expectedResultSVG = new Array();
  2991. expectedResultSVG[0] = "ent1";
  2992. expectedResultSVG[1] = "ent2";
  2993. expectedResultSVG[2] = "ent3";
  2994. expectedResultSVG[3] = "ent4";
  2995. expectedResultSVG[4] = "ent5";
  2996. expectedResultSVG[5] = "svgunit";
  2997. expectedResultSVG[6] = "svgtest";
  2998. var nameList = new Array();
  2999. var entity;
  3000. doc = staff.staff();
  3001. docType = doc.doctype;
  3002. test.notEqual(docType, null, 'docTypeNotNull');
  3003. entityList = docType.entities;
  3004. test.notEqual(entityList, null, 'entitiesNotNull');
  3005. for(var indexN1007B = 0;indexN1007B < entityList.length; indexN1007B++) {
  3006. entity = entityList.item(indexN1007B);
  3007. name = entity.nodeName;
  3008. nameList[nameList.length] = name;
  3009. }
  3010. test.deepEqual(nameList, expectedResultSVG, 'entityNamesSVG');
  3011. test.done();
  3012. },
  3013. /**
  3014. *
  3015. Duplicate entities are to be discarded.
  3016. Retrieve the Document Type for this document and create
  3017. a NamedNodeMap of all its entities. The entity named
  3018. "ent1" is defined twice and therefore that last
  3019. occurrance should be discarded.
  3020. * @author NIST
  3021. * @author Mary Brady
  3022. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1788794630
  3023. */
  3024. documenttypegetentitieslength: function(test) {
  3025. var success;
  3026. var doc;
  3027. var docType;
  3028. var entityList;
  3029. doc = staff.staff();
  3030. docType = doc.doctype;
  3031. test.notEqual(docType, null, 'docTypeNotNull');
  3032. entityList = docType.entities;
  3033. test.notEqual(entityList, null, 'entitiesNotNull');
  3034. test.equal(entityList.length, 7, 'entitySizeSVG');
  3035. test.done();
  3036. },
  3037. /**
  3038. *
  3039. Every node in the map returned by the "getEntities()"
  3040. method implements the Entity interface.
  3041. Retrieve the Document Type for this document and create
  3042. a NamedNodeMap of all its entities. Traverse the
  3043. entire list and examine the NodeType of each node
  3044. in the list.
  3045. * @author NIST
  3046. * @author Mary Brady
  3047. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1788794630
  3048. */
  3049. documenttypegetentitiestype: function(test) {
  3050. var success;
  3051. var doc;
  3052. var docType;
  3053. var entityList;
  3054. var entity;
  3055. var entityType;
  3056. doc = staff.staff();
  3057. docType = doc.doctype;
  3058. test.notEqual(docType, null, 'docTypeNotNull');
  3059. entityList = docType.entities;
  3060. test.notEqual(entityList, null, 'entitiesNotNull');
  3061. for(var indexN10049 = 0;indexN10049 < entityList.length; indexN10049++) {
  3062. entity = entityList.item(indexN10049);
  3063. entityType = entity.nodeType;
  3064. test.equal(entityType, 6, 'documenttypeGetEntitiesTypeAssert');
  3065. }
  3066. test.done();
  3067. },
  3068. /**
  3069. *
  3070. The "getNotations()" method creates a NamedNodeMap that
  3071. contains all the notations declared in the DTD.
  3072. Retrieve the Document Type for this document and create
  3073. a NamedNodeMap object of all the notations. There
  3074. should be two items in the list (notation1 and notation2).
  3075. * @author NIST
  3076. * @author Mary Brady
  3077. * @author Curt Arnold
  3078. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D46829EF
  3079. */
  3080. documenttypegetnotations: function(test) {
  3081. var success;
  3082. var doc;
  3083. var docType;
  3084. var notationList;
  3085. var notation;
  3086. var notationName;
  3087. var actual = new Array();
  3088. expected = new Array();
  3089. expected[0] = "notation1";
  3090. expected[1] = "notation2";
  3091. doc = staff.staff();
  3092. docType = doc.doctype;
  3093. test.notEqual(docType, null, 'docTypeNotNull');
  3094. notationList = docType.notations;
  3095. test.notEqual(notationList, null, 'notationsNotNull');
  3096. for(var indexN1005B = 0;indexN1005B < notationList.length; indexN1005B++) {
  3097. notation = notationList.item(indexN1005B);
  3098. notationName = notation.nodeName;
  3099. actual[actual.length] = notationName;
  3100. }
  3101. test.deepEqual(actual, expected, 'names');
  3102. test.done();
  3103. },
  3104. /**
  3105. *
  3106. Every node in the map returned by the "getNotations()"
  3107. method implements the Notation interface.
  3108. Retrieve the Document Type for this document and create
  3109. a NamedNodeMap object of all the notations. Traverse
  3110. the entire list and examine the NodeType of each node.
  3111. * @author NIST
  3112. * @author Mary Brady
  3113. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D46829EF
  3114. */
  3115. documenttypegetnotationstype: function(test) {
  3116. var success;
  3117. var doc;
  3118. var docType;
  3119. var notationList;
  3120. var notation;
  3121. var notationType;
  3122. doc = staff.staff();
  3123. docType = doc.doctype;
  3124. test.notEqual(docType, null, 'docTypeNotNull');
  3125. notationList = docType.notations;
  3126. test.notEqual(notationList, null, 'notationsNotNull');
  3127. for(var indexN10049 = 0;indexN10049 < notationList.length; indexN10049++) {
  3128. notation = notationList.item(indexN10049);
  3129. notationType = notation.nodeType;
  3130. test.equal(notationType, 12, 'documenttypeGetNotationsTypeAssert');
  3131. }
  3132. test.done();
  3133. },
  3134. /**
  3135. *
  3136. hasFeature("XML", "") should return true for implementations that can read staff files.
  3137. * @author NIST
  3138. * @author Mary Brady
  3139. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7
  3140. * @see http://www.w3.org/2000/11/DOM-Level-2-errata#core-14
  3141. */
  3142. domimplementationfeaturenoversion: function(test) {
  3143. var success;
  3144. var doc;
  3145. var domImpl;
  3146. var state;
  3147. doc = staff.staff();
  3148. domImpl = doc.implementation;
  3149. state = domImpl.hasFeature("XML","");
  3150. test.ok(state, 'hasXMLEmpty');
  3151. test.done();
  3152. },
  3153. /**
  3154. *
  3155. hasFeature("XML", null) should return true for implementations that can read staff documents.
  3156. * @author NIST
  3157. * @author Curt Arnold
  3158. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7
  3159. * @see http://www.w3.org/2000/11/DOM-Level-2-errata#core-14
  3160. */
  3161. domimplementationfeaturenull: function(test) {
  3162. var success;
  3163. var doc;
  3164. var domImpl;
  3165. var state;
  3166. var nullVersion = null;
  3167. doc = staff.staff();
  3168. domImpl = doc.implementation;
  3169. state = domImpl.hasFeature("XML",nullVersion);
  3170. test.ok(state, 'hasXMLnull');
  3171. test.done();
  3172. },
  3173. /**
  3174. *
  3175. hasFeature("xml", "1.0") should return true for implementations that can read staff documents.
  3176. * @author NIST
  3177. * @author Mary Brady
  3178. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7
  3179. */
  3180. domimplementationfeaturexml: function(test) {
  3181. var success;
  3182. var doc;
  3183. var domImpl;
  3184. var state;
  3185. doc = staff.staff();
  3186. domImpl = doc.implementation;
  3187. state = domImpl.hasFeature("xml","1.0");
  3188. test.ok(state, 'hasXML1');
  3189. test.done();
  3190. },
  3191. /**
  3192. *
  3193. The "setAttribute(name,value)" method adds a new attribute
  3194. to the Element
  3195. Retrieve the last child of the last employee, then
  3196. add an attribute to it by invoking the
  3197. "setAttribute(name,value)" method. It should create
  3198. a "name" attribute with an assigned value equal to
  3199. "value".
  3200. * @author NIST
  3201. * @author Mary Brady
  3202. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
  3203. */
  3204. elementaddnewattribute: function(test) {
  3205. var success;
  3206. var doc;
  3207. var elementList;
  3208. var testEmployee;
  3209. var attrValue;
  3210. doc = staff.staff();
  3211. elementList = doc.getElementsByTagName("address");
  3212. testEmployee = elementList.item(4);
  3213. testEmployee.setAttribute("district","dallas");
  3214. attrValue = testEmployee.getAttribute("district");
  3215. test.equal(attrValue, 'dallas', 'elementAddNewAttributeAssert');
  3216. test.done();
  3217. },
  3218. /**
  3219. *
  3220. Elements may have attributes associated with them.
  3221. Retrieve the first attribute from the last child of
  3222. the first employee and invoke the "getSpecified()"
  3223. method. This test is only intended to show that
  3224. Elements can actually have attributes. This test uses
  3225. the "getNamedItem(name)" method from the NamedNodeMap
  3226. interface.
  3227. * @author NIST
  3228. * @author Mary Brady
  3229. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  3230. */
  3231. elementassociatedattribute: function(test) {
  3232. var success;
  3233. var doc;
  3234. var elementList;
  3235. var testEmployee;
  3236. var attributes;
  3237. var domesticAttr;
  3238. var specified;
  3239. doc = staff.staff();
  3240. elementList = doc.getElementsByTagName("address");
  3241. testEmployee = elementList.item(0);
  3242. attributes = testEmployee.attributes;
  3243. domesticAttr = attributes.getNamedItem("domestic");
  3244. specified = domesticAttr.specified;
  3245. test.ok(specified, 'domesticSpecified');
  3246. test.done();
  3247. },
  3248. /**
  3249. *
  3250. The "setAttribute(name,value)" method adds a new attribute
  3251. to the Element. If the "name" is already present, then
  3252. its value should be changed to the new one that is in
  3253. the "value" parameter.
  3254. Retrieve the last child of the fourth employee, then add
  3255. an attribute to it by invoking the
  3256. "setAttribute(name,value)" method. Since the name of the
  3257. used attribute("street") is already present in this
  3258. element, then its value should be changed to the new one
  3259. of the "value" parameter.
  3260. * @author NIST
  3261. * @author Mary Brady
  3262. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
  3263. */
  3264. elementchangeattributevalue: function(test) {
  3265. var success;
  3266. var doc;
  3267. var elementList;
  3268. var testEmployee;
  3269. var attrValue;
  3270. doc = staff.staff();
  3271. elementList = doc.getElementsByTagName("address");
  3272. testEmployee = elementList.item(3);
  3273. testEmployee.setAttribute("street","Neither");
  3274. attrValue = testEmployee.getAttribute("street");
  3275. test.equal(attrValue, 'Neither', 'elementChangeAttributeValueAssert');
  3276. test.done();
  3277. },
  3278. /**
  3279. *
  3280. The "setAttributeNode(newAttr)" method adds a new
  3281. attribute to the Element.
  3282. Retrieve first address element and add
  3283. a new attribute node to it by invoking its
  3284. "setAttributeNode(newAttr)" method. This test makes use
  3285. of the "createAttribute(name)" method from the Document
  3286. interface.
  3287. * @author NIST
  3288. * @author Mary Brady
  3289. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  3290. */
  3291. elementcreatenewattribute: function(test) {
  3292. var success;
  3293. var doc;
  3294. var elementList;
  3295. var testAddress;
  3296. var newAttribute;
  3297. var oldAttr;
  3298. var districtAttr;
  3299. var attrVal;
  3300. doc = staff.staff();
  3301. elementList = doc.getElementsByTagName("address");
  3302. testAddress = elementList.item(0);
  3303. newAttribute = doc.createAttribute("district");
  3304. oldAttr = testAddress.setAttributeNode(newAttribute);
  3305. test.equal(oldAttr, null, 'old_attr_doesnt_exist');
  3306. districtAttr = testAddress.getAttributeNode("district");
  3307. test.notEqual(districtAttr, null, 'new_district_accessible');
  3308. attrVal = testAddress.getAttribute("district");
  3309. test.equal(attrVal, '', 'attr_value');
  3310. test.done();
  3311. },
  3312. /**
  3313. *
  3314. The "getAttributeNode(name)" method retrieves an
  3315. attribute node by name.
  3316. Retrieve the attribute "domestic" from the last child
  3317. of the first employee. Since the method returns an
  3318. Attr object, the "name" can be examined to ensure the
  3319. proper attribute was retrieved.
  3320. * @author NIST
  3321. * @author Mary Brady
  3322. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-217A91B8
  3323. */
  3324. elementgetattributenode: function(test) {
  3325. var success;
  3326. var doc;
  3327. var elementList;
  3328. var testEmployee;
  3329. var domesticAttr;
  3330. var name;
  3331. doc = staff.staff();
  3332. elementList = doc.getElementsByTagName("address");
  3333. testEmployee = elementList.item(0);
  3334. domesticAttr = testEmployee.getAttributeNode("domestic");
  3335. name = domesticAttr.nodeName;
  3336. test.equal(name, 'domestic', 'elementGetAttributeNodeAssert');
  3337. test.done();
  3338. },
  3339. /**
  3340. *
  3341. The "getAttributeNode(name)" method retrieves an
  3342. attribute node by name. It should return null if the
  3343. "name" attribute does not exist.
  3344. Retrieve the last child of the first employee and attempt
  3345. to retrieve a non-existing attribute. The method should
  3346. return "null". The non-existing attribute to be used
  3347. is "invalidAttribute".
  3348. * @author NIST
  3349. * @author Mary Brady
  3350. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-217A91B8
  3351. */
  3352. elementgetattributenodenull: function(test) {
  3353. var success;
  3354. var doc;
  3355. var elementList;
  3356. var testEmployee;
  3357. var domesticAttr;
  3358. doc = staff.staff();
  3359. elementList = doc.getElementsByTagName("address");
  3360. testEmployee = elementList.item(0);
  3361. domesticAttr = testEmployee.getAttributeNode("invalidAttribute");
  3362. test.equal(domesticAttr, null, 'elementGetAttributeNodeNullAssert');
  3363. test.done();
  3364. },
  3365. /**
  3366. *
  3367. The "getAttribute(name)" method returns an empty
  3368. string if no value was assigned to an attribute and
  3369. no default value was given in the DTD file.
  3370. Retrieve the last child of the last employee, then
  3371. invoke "getAttribute(name)" method, where "name" is an
  3372. attribute without a specified or DTD default value.
  3373. The "getAttribute(name)" method should return the empty
  3374. string. This method makes use of the
  3375. "createAttribute(newAttr)" method from the Document
  3376. interface.
  3377. * @author NIST
  3378. * @author Mary Brady
  3379. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-666EE0F9
  3380. */
  3381. elementgetelementempty: function(test) {
  3382. var success;
  3383. var doc;
  3384. var newAttribute;
  3385. var elementList;
  3386. var testEmployee;
  3387. var domesticAttr;
  3388. var attrValue;
  3389. doc = staff.staff();
  3390. newAttribute = doc.createAttribute("district");
  3391. elementList = doc.getElementsByTagName("address");
  3392. testEmployee = elementList.item(3);
  3393. domesticAttr = testEmployee.setAttributeNode(newAttribute);
  3394. attrValue = testEmployee.getAttribute("district");
  3395. test.equal(attrValue, '', 'elementGetElementEmptyAssert');
  3396. test.done();
  3397. },
  3398. /**
  3399. *
  3400. The "getElementsByTagName(name)" method returns a list
  3401. of all descendant Elements with the given tag name.
  3402. Test for an empty list.
  3403. Create a NodeList of all the descendant elements
  3404. using the string "noMatch" as the tagName.
  3405. The method should return a NodeList whose length is
  3406. "0" since there are not any descendant elements
  3407. that match the given tag name.
  3408. * @author NIST
  3409. * @author Mary Brady
  3410. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D
  3411. */
  3412. elementgetelementsbytagname: function(test) {
  3413. var success;
  3414. var doc;
  3415. var elementList;
  3416. doc = staff.staff();
  3417. elementList = doc.getElementsByTagName("employee");
  3418. test.equal(elementList.length, 5, 'elementGetElementsByTagNameAssert');
  3419. test.done();
  3420. },
  3421. /**
  3422. *
  3423. Element.getElementsByTagName("employee") should return a NodeList whose length is
  3424. "5" in the order the children were encountered.
  3425. * @author NIST
  3426. * @author Mary Brady
  3427. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D
  3428. */
  3429. elementgetelementsbytagnameaccessnodelist: function(test) {
  3430. var success;
  3431. var doc;
  3432. var elementList;
  3433. var testEmployee;
  3434. var child;
  3435. var childName;
  3436. var childValue;
  3437. var childType;
  3438. doc = staff.staff();
  3439. elementList = doc.getElementsByTagName("employee");
  3440. testEmployee = elementList.item(3);
  3441. child = testEmployee.firstChild;
  3442. childType = child.nodeType;
  3443. if(
  3444. (3 == childType)
  3445. ) {
  3446. child = child.nextSibling;
  3447. }
  3448. childName = child.nodeName;
  3449. test.equal(childName, 'employeeId', 'nodename');
  3450. child = child.firstChild;
  3451. childValue = child.nodeValue;
  3452. test.equal(childValue, 'EMP0004', 'emp0004');
  3453. test.done();
  3454. },
  3455. /**
  3456. *
  3457. The "getElementsByTagName(name)" method returns a list
  3458. of all descendant Elements with the given tag name.
  3459. Create a NodeList of all the descendant elements
  3460. using the string "employee" as the tagName.
  3461. The method should return a NodeList whose length is
  3462. "5".
  3463. * @author NIST
  3464. * @author Mary Brady
  3465. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D
  3466. */
  3467. elementgetelementsbytagnamenomatch: function(test) {
  3468. var success;
  3469. var doc;
  3470. var elementList;
  3471. doc = staff.staff();
  3472. elementList = doc.getElementsByTagName("noMatch");
  3473. test.equal(elementList.length, 0, 'elementGetElementsByTagNameNoMatchNoMatchAssert');
  3474. test.done();
  3475. },
  3476. /**
  3477. *
  3478. The "getElementsByTagName(name)" method may use the
  3479. special value "*" to match all tags in the element
  3480. tree.
  3481. Create a NodeList of all the descendant elements
  3482. of the last employee by using the special value "*".
  3483. The method should return all the descendant children(6)
  3484. in the order the children were encountered.
  3485. * @author NIST
  3486. * @author Mary Brady
  3487. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D
  3488. */
  3489. elementgetelementsbytagnamespecialvalue: function(test) {
  3490. var success;
  3491. var doc;
  3492. var elementList;
  3493. var lastEmployee;
  3494. var lastempList;
  3495. var child;
  3496. var childName;
  3497. var result = new Array();
  3498. expectedResult = new Array();
  3499. expectedResult[0] = "employeeId";
  3500. expectedResult[1] = "name";
  3501. expectedResult[2] = "position";
  3502. expectedResult[3] = "salary";
  3503. expectedResult[4] = "gender";
  3504. expectedResult[5] = "address";
  3505. doc = staff.staff();
  3506. elementList = doc.getElementsByTagName("employee");
  3507. lastEmployee = elementList.item(4);
  3508. lastempList = lastEmployee.getElementsByTagName("*");
  3509. for(var indexN1006A = 0;indexN1006A < lastempList.length; indexN1006A++) {
  3510. child = lastempList.item(indexN1006A);
  3511. childName = child.nodeName;
  3512. result[result.length] = childName;
  3513. }
  3514. test.deepEqual(result, expectedResult, 'tagNames');
  3515. test.done();
  3516. },
  3517. /**
  3518. *
  3519. The "getTagName()" method returns the
  3520. tagName of an element.
  3521. Invoke the "getTagName()" method one the
  3522. root node. The value returned should be "staff".
  3523. * @author NIST
  3524. * @author Mary Brady
  3525. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-104682815
  3526. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
  3527. */
  3528. elementgettagname: function(test) {
  3529. var success;
  3530. var doc;
  3531. var root;
  3532. var tagname;
  3533. doc = staff.staff();
  3534. root = doc.documentElement;
  3535. tagname = root.tagName;
  3536. test.equal(tagname, 'svg', 'svgTagName');
  3537. test.done();
  3538. },
  3539. /**
  3540. *
  3541. The "setAttributeNode(newAttr)" method raises an
  3542. "INUSE_ATTRIBUTE_ERR DOMException if the "newAttr"
  3543. is already an attribute of another element.
  3544. Retrieve the last child of the second employee and append
  3545. a newly created element. The "createAttribute(name)"
  3546. and "setAttributeNode(newAttr)" methods are invoked
  3547. to create and add a new attribute to the newly created
  3548. Element. The "setAttributeNode(newAttr)" method is
  3549. once again called to add the new attribute causing an
  3550. exception to be raised since the attribute is already
  3551. an attribute of another element.
  3552. * @author NIST
  3553. * @author Mary Brady
  3554. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])
  3555. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  3556. * @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'])
  3557. */
  3558. elementinuseattributeerr: function(test) {
  3559. var success;
  3560. var doc;
  3561. var newAttribute;
  3562. var addressElementList;
  3563. var testAddress;
  3564. var newElement;
  3565. var appendedChild;
  3566. var setAttr1;
  3567. var setAttr2;
  3568. doc = staff.staff();
  3569. addressElementList = doc.getElementsByTagName("address");
  3570. testAddress = addressElementList.item(1);
  3571. newElement = doc.createElement("newElement");
  3572. appendedChild = testAddress.appendChild(newElement);
  3573. newAttribute = doc.createAttribute("newAttribute");
  3574. setAttr1 = newElement.setAttributeNode(newAttribute);
  3575. {
  3576. success = false;
  3577. try {
  3578. setAttr2 = testAddress.setAttributeNode(newAttribute);
  3579. }
  3580. catch(ex) {
  3581. success = (typeof(ex.code) != 'undefined' && ex.code == 10);
  3582. }
  3583. test.ok(success, 'throw_INUSE_ATTRIBUTE_ERR');
  3584. }
  3585. test.done();
  3586. },
  3587. /**
  3588. *
  3589. The "setAttribute(name,value)" method raises an
  3590. "INVALID_CHARACTER_ERR DOMException if the specified
  3591. name contains an invalid character.
  3592. Retrieve the last child of the first employee and
  3593. call its "setAttribute(name,value)" method with
  3594. "name" containing an invalid character.
  3595. * @author NIST
  3596. * @author Mary Brady
  3597. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  3598. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
  3599. * @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'])
  3600. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  3601. */
  3602. elementinvalidcharacterexception: function(test) {
  3603. var success;
  3604. var doc;
  3605. var elementList;
  3606. var testAddress;
  3607. doc = staff.staff();
  3608. elementList = doc.getElementsByTagName("address");
  3609. testAddress = elementList.item(0);
  3610. {
  3611. success = false;
  3612. try {
  3613. testAddress.setAttribute("invalid^Name","value");
  3614. }
  3615. catch(ex) {
  3616. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  3617. }
  3618. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  3619. }
  3620. test.done();
  3621. },
  3622. /**
  3623. *
  3624. The "normalize()" method puts all the nodes in the full
  3625. depth of the sub-tree underneath this element into a
  3626. "normal" form.
  3627. Retrieve the third employee and access its second child.
  3628. This child contains a block of text that is spread
  3629. across multiple lines. The content of the "name" child
  3630. should be parsed and treated as a single Text node.
  3631. * @author NIST
  3632. * @author Mary Brady
  3633. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083
  3634. */
  3635. elementnormalize: function(test) {
  3636. var success;
  3637. var doc;
  3638. var root;
  3639. var elementList;
  3640. var testName;
  3641. var firstChild;
  3642. var childValue;
  3643. doc = staff.staff();
  3644. root = doc.documentElement;
  3645. root.normalize();
  3646. elementList = root.getElementsByTagName("name");
  3647. testName = elementList.item(2);
  3648. firstChild = testName.firstChild;
  3649. childValue = firstChild.nodeValue;
  3650. test.equal(childValue, 'Roger\n Jones', 'elementNormalizeAssert');
  3651. test.done();
  3652. },
  3653. /**
  3654. *
  3655. The "removeAttributeNode(oldAttr)" method raises a
  3656. NOT_FOUND_ERR DOMException if the "oldAttr" attribute
  3657. is not an attribute of the element.
  3658. Retrieve the last employee and attempt to remove
  3659. a non existing attribute node. This should cause the
  3660. intended exception to be raised. This test makes use
  3661. of the "createAttribute(name)" method from the Document
  3662. interface.
  3663. * @author NIST
  3664. * @author Mary Brady
  3665. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])
  3666. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198
  3667. * @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'])
  3668. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  3669. */
  3670. elementnotfounderr: function(test) {
  3671. var success;
  3672. var doc;
  3673. var oldAttribute;
  3674. var addressElementList;
  3675. var testAddress;
  3676. var attrAddress;
  3677. doc = staff.staff();
  3678. addressElementList = doc.getElementsByTagName("address");
  3679. testAddress = addressElementList.item(4);
  3680. oldAttribute = doc.createAttribute("oldAttribute");
  3681. {
  3682. success = false;
  3683. try {
  3684. attrAddress = testAddress.removeAttributeNode(oldAttribute);
  3685. }
  3686. catch(ex) {
  3687. success = (typeof(ex.code) != 'undefined' && ex.code == 8);
  3688. }
  3689. test.ok(success, 'throw_NOT_FOUND_ERR');
  3690. }
  3691. test.done();
  3692. },
  3693. /**
  3694. *
  3695. The "removeAttribute(name)" removes an attribute by name.
  3696. If the attribute has a default value, it is immediately
  3697. replaced.
  3698. Retrieve the attribute named "street" from the last child
  3699. of the fourth employee, then remove the "street"
  3700. attribute by invoking the "removeAttribute(name)" method.
  3701. The "street" attribute has a default value defined in the
  3702. DTD file, that value should immediately replace the old
  3703. value.
  3704. * @author NIST
  3705. * @author Mary Brady
  3706. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9
  3707. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html
  3708. */
  3709. elementremoveattribute: function(test) {
  3710. var success;
  3711. var doc;
  3712. var elementList;
  3713. var testEmployee;
  3714. var attrValue;
  3715. doc = staff.staff();
  3716. elementList = doc.getElementsByTagName("address");
  3717. testEmployee = elementList.item(3);
  3718. testEmployee.removeAttribute("street");
  3719. attrValue = testEmployee.getAttribute("street");
  3720. test.equal(attrValue, 'Yes', 'streetYes');
  3721. test.done();
  3722. },
  3723. /**
  3724. *
  3725. The "removeAttributeNode(oldAttr)" method removes the
  3726. specified attribute.
  3727. Retrieve the last child of the third employee, add a
  3728. new "district" node to it and then try to remove it.
  3729. To verify that the node was removed use the
  3730. "getNamedItem(name)" method from the NamedNodeMap
  3731. interface. It also uses the "getAttributes()" method
  3732. from the Node interface.
  3733. * @author NIST
  3734. * @author Mary Brady
  3735. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198
  3736. */
  3737. elementremoveattributeaftercreate: function(test) {
  3738. var success;
  3739. var doc;
  3740. var elementList;
  3741. var testEmployee;
  3742. var newAttribute;
  3743. var attributes;
  3744. var districtAttr;
  3745. doc = staff.staff();
  3746. elementList = doc.getElementsByTagName("address");
  3747. testEmployee = elementList.item(2);
  3748. newAttribute = doc.createAttribute("district");
  3749. districtAttr = testEmployee.setAttributeNode(newAttribute);
  3750. districtAttr = testEmployee.removeAttributeNode(newAttribute);
  3751. attributes = testEmployee.attributes;
  3752. districtAttr = attributes.getNamedItem("district");
  3753. test.equal(districtAttr, null, 'elementRemoveAttributeAfterCreateAssert');
  3754. test.done();
  3755. },
  3756. /**
  3757. *
  3758. The "removeAttributeNode(oldAttr)" method returns the
  3759. node that was removed.
  3760. Retrieve the last child of the third employee and
  3761. remove its "street" Attr node. The method should
  3762. return the old attribute node.
  3763. * @author NIST
  3764. * @author Mary Brady
  3765. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198
  3766. */
  3767. elementremoveattributenode: function(test) {
  3768. var success;
  3769. var doc;
  3770. var elementList;
  3771. var testEmployee;
  3772. var streetAttr;
  3773. var removedAttr;
  3774. var removedValue;
  3775. doc = staff.staff();
  3776. elementList = doc.getElementsByTagName("address");
  3777. testEmployee = elementList.item(2);
  3778. streetAttr = testEmployee.getAttributeNode("street");
  3779. removedAttr = testEmployee.removeAttributeNode(streetAttr);
  3780. removedValue = removedAttr.value;
  3781. test.equal(removedValue, 'No', 'elementRemoveAttributeNodeAssert');
  3782. test.done();
  3783. },
  3784. /**
  3785. *
  3786. The "removeAttributeNode(oldAttr)" method for an attribute causes the
  3787. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  3788. if the node is readonly.
  3789. Obtain the children of the THIRD "gender" element. The elements
  3790. content is an entity reference. Try to remove the "domestic" attribute
  3791. from the entity reference by executing the "removeAttributeNode(oldAttr)" method.
  3792. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  3793. * @author NIST
  3794. * @author Mary Brady
  3795. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  3796. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198
  3797. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  3798. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198
  3799. */
  3800. elementremoveattributenodenomodificationallowederr: function(test) {
  3801. var success;
  3802. var doc;
  3803. var genderList;
  3804. var gender;
  3805. var genList;
  3806. var gen;
  3807. var nodeType;
  3808. var gList;
  3809. var genElement;
  3810. var attrList;
  3811. var attrNode;
  3812. var removedAttr;
  3813. doc = staff.staff();
  3814. genderList = doc.getElementsByTagName("gender");
  3815. gender = genderList.item(2);
  3816. genList = gender.childNodes;
  3817. gen = genList.item(0);
  3818. test.notEqual(gen, null, 'genNotNull');
  3819. nodeType = gen.nodeType;
  3820. if(
  3821. (1 == nodeType)
  3822. ) {
  3823. gen = doc.createEntityReference("ent4");
  3824. test.notEqual(gen, null, 'createdEntRefNotNull');
  3825. }
  3826. gList = gen.childNodes;
  3827. genElement = gList.item(0);
  3828. test.notEqual(genElement, null, 'genElementNotNull');
  3829. attrList = genElement.attributes;
  3830. attrNode = attrList.getNamedItem("domestic");
  3831. {
  3832. success = false;
  3833. try {
  3834. removedAttr = genElement.removeAttributeNode(attrNode);
  3835. }
  3836. catch(ex) {
  3837. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  3838. }
  3839. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  3840. }
  3841. test.done();
  3842. },
  3843. /**
  3844. *
  3845. The "removeAttributeNode(oldAttr)" method for an attribute causes the
  3846. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  3847. if the node is readonly.
  3848. Create an entity reference and add it to the children of the THIRD "gender" element.
  3849. Try to remove the "domestic" attribute from the entity
  3850. reference by executing the "removeAttributeNode(oldAttr)" method.
  3851. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  3852. * @author Curt Arnold
  3853. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  3854. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198
  3855. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  3856. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198
  3857. * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementremoveattributenodenomodificationallowederr.xml
  3858. */
  3859. elementremoveattributenodenomodificationallowederrEE: function(test) {
  3860. var success;
  3861. var doc;
  3862. var genderList;
  3863. var gender;
  3864. var entRef;
  3865. var entElement;
  3866. var attrList;
  3867. var attrNode;
  3868. var nodeType;
  3869. var removedAttr;
  3870. var appendedChild;
  3871. doc = staff.staff();
  3872. genderList = doc.getElementsByTagName("gender");
  3873. gender = genderList.item(2);
  3874. entRef = doc.createEntityReference("ent4");
  3875. test.notEqual(entRef, null, 'createdEntRefNotNull');
  3876. appendedChild = gender.appendChild(entRef);
  3877. entElement = entRef.firstChild;
  3878. test.notEqual(entElement, null, 'entElementNotNull');
  3879. attrList = entElement.attributes;
  3880. attrNode = attrList.getNamedItem("domestic");
  3881. test.notEqual(attrNode, null, 'attrNodeNotNull');
  3882. {
  3883. success = false;
  3884. try {
  3885. removedAttr = entElement.removeAttributeNode(attrNode);
  3886. }
  3887. catch(ex) {
  3888. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  3889. }
  3890. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  3891. }
  3892. test.done();
  3893. },
  3894. /**
  3895. *
  3896. The "removeAttribute(name)" method for an attribute causes the
  3897. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  3898. if the node is readonly.
  3899. Obtain the children of the THIRD "gender" element. The elements
  3900. content is an entity reference. Try to remove the "domestic" attribute
  3901. from the entity reference by executing the "removeAttribute(name)" method.
  3902. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  3903. * @author NIST
  3904. * @author Mary Brady
  3905. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  3906. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9
  3907. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6D6AC0F9')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  3908. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9
  3909. */
  3910. elementremoveattributenomodificationallowederr: function(test) {
  3911. var success;
  3912. var doc;
  3913. var genderList;
  3914. var gender;
  3915. var genList;
  3916. var gen;
  3917. var gList;
  3918. var nodeType;
  3919. var genElement;
  3920. doc = staff.staff();
  3921. genderList = doc.getElementsByTagName("gender");
  3922. gender = genderList.item(2);
  3923. genList = gender.childNodes;
  3924. gen = genList.item(0);
  3925. test.notEqual(gen, null, 'genNotNull');
  3926. nodeType = gen.nodeType;
  3927. if(
  3928. (1 == nodeType)
  3929. ) {
  3930. gen = doc.createEntityReference("ent4");
  3931. test.notEqual(gen, null, 'createdEntRefNotNull');
  3932. }
  3933. gList = gen.childNodes;
  3934. genElement = gList.item(0);
  3935. test.notEqual(genElement, null, 'genElementNotNull');
  3936. {
  3937. success = false;
  3938. try {
  3939. genElement.removeAttribute("domestic");
  3940. }
  3941. catch(ex) {
  3942. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  3943. }
  3944. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  3945. }
  3946. test.done();
  3947. },
  3948. /**
  3949. *
  3950. The "removeAttribute(name)" method for an attribute causes the
  3951. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  3952. if the node is readonly.
  3953. Create an reference the entity ent4 and add it to the THIRD "gender" element.
  3954. Try to remove the "domestic" attribute from the entity reference by executing the "removeAttribute(name)" method.
  3955. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  3956. * @author Curt Arnold
  3957. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  3958. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9
  3959. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-6D6AC0F9')/raises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  3960. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9
  3961. * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementremoveattributenomodificationallowederr.xml
  3962. */
  3963. elementremoveattributenomodificationallowederrEE: function(test) {
  3964. var success;
  3965. var doc;
  3966. var genderList;
  3967. var gender;
  3968. var entRef;
  3969. var entElement;
  3970. var appendedChild;
  3971. doc = staff.staff();
  3972. genderList = doc.getElementsByTagName("gender");
  3973. gender = genderList.item(2);
  3974. entRef = doc.createEntityReference("ent4");
  3975. test.notEqual(entRef, null, 'createdEntRefNotNull');
  3976. appendedChild = gender.appendChild(entRef);
  3977. entElement = entRef.firstChild;
  3978. test.notEqual(entElement, null, 'entElementNotNull');
  3979. {
  3980. success = false;
  3981. try {
  3982. entElement.removeAttribute("domestic");
  3983. }
  3984. catch(ex) {
  3985. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  3986. }
  3987. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  3988. }
  3989. test.done();
  3990. },
  3991. /**
  3992. *
  3993. The "removeAttributeNode(oldAttr)" method removes the
  3994. specified attribute node and restores any default values.
  3995. Retrieve the last child of the third employeed and
  3996. remove its "street" Attr node. Since this node has a
  3997. default value defined in the DTD file, that default
  3998. should immediately be the new value.
  3999. * @author NIST
  4000. * @author Mary Brady
  4001. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198
  4002. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html
  4003. */
  4004. elementremoveattributerestoredefaultvalue: function(test) {
  4005. var success;
  4006. var doc;
  4007. var elementList;
  4008. var testEmployee;
  4009. var streetAttr;
  4010. var attribute;
  4011. var removedAttr;
  4012. doc = staff.staff();
  4013. elementList = doc.getElementsByTagName("address");
  4014. testEmployee = elementList.item(2);
  4015. streetAttr = testEmployee.getAttributeNode("street");
  4016. removedAttr = testEmployee.removeAttributeNode(streetAttr);
  4017. attribute = testEmployee.getAttribute("street");
  4018. test.equal(attribute, 'Yes', 'streetYes');
  4019. test.done();
  4020. },
  4021. /**
  4022. *
  4023. This test calls setAttributeNode to replace an attribute with itself.
  4024. Since the node is not an attribute of another Element, it would
  4025. be inappropriate to throw an INUSE_ATTRIBUTE_ERR.
  4026. This test was derived from elementinuserattributeerr which
  4027. inadvertanly made this test.
  4028. * @author Curt Arnold
  4029. * @author Curt Arnold
  4030. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  4031. */
  4032. elementreplaceattributewithself: function(test) {
  4033. var success;
  4034. var doc;
  4035. var elementList;
  4036. var testEmployee;
  4037. var streetAttr;
  4038. var replacedAttr;
  4039. doc = staff.staff();
  4040. elementList = doc.getElementsByTagName("address");
  4041. testEmployee = elementList.item(2);
  4042. streetAttr = testEmployee.getAttributeNode("street");
  4043. replacedAttr = testEmployee.setAttributeNode(streetAttr);
  4044. test.equal(replacedAttr, streetAttr, 'replacedAttr');
  4045. test.done();
  4046. },
  4047. /**
  4048. *
  4049. The "setAttributeNode(newAttr)" method adds a new
  4050. attribute to the Element. If the "newAttr" Attr node is
  4051. already present in this element, it should replace the
  4052. existing one.
  4053. Retrieve the last child of the third employee and add a
  4054. new attribute node by invoking the "setAttributeNode(new
  4055. Attr)" method. The new attribute node to be added is
  4056. "street", which is already present in this element. The
  4057. method should replace the existing Attr node with the
  4058. new one. This test uses the "createAttribute(name)"
  4059. method from the Document interface.
  4060. * @author NIST
  4061. * @author Mary Brady
  4062. */
  4063. elementreplaceexistingattribute: function(test) {
  4064. var success;
  4065. var doc;
  4066. var elementList;
  4067. var testEmployee;
  4068. var newAttribute;
  4069. var name;
  4070. var setAttr;
  4071. doc = staff.staff();
  4072. elementList = doc.getElementsByTagName("address");
  4073. testEmployee = elementList.item(2);
  4074. newAttribute = doc.createAttribute("street");
  4075. setAttr = testEmployee.setAttributeNode(newAttribute);
  4076. name = testEmployee.getAttribute("street");
  4077. test.equal(name, '', 'elementReplaceExistingAttributeAssert');
  4078. test.done();
  4079. },
  4080. /**
  4081. *
  4082. If the "setAttributeNode(newAttr)" method replaces an
  4083. existing Attr node with the same name, then it should
  4084. return the previously existing Attr node.
  4085. Retrieve the last child of the third employee and add a
  4086. new attribute node. The new attribute node is "street",
  4087. which is already present in this Element. The method
  4088. should return the existing Attr node(old "street" Attr).
  4089. This test uses the "createAttribute(name)" method
  4090. from the Document interface.
  4091. * @author NIST
  4092. * @author Mary Brady
  4093. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  4094. */
  4095. elementreplaceexistingattributegevalue: function(test) {
  4096. var success;
  4097. var doc;
  4098. var elementList;
  4099. var testEmployee;
  4100. var newAttribute;
  4101. var streetAttr;
  4102. var value;
  4103. doc = staff.staff();
  4104. elementList = doc.getElementsByTagName("address");
  4105. testEmployee = elementList.item(2);
  4106. newAttribute = doc.createAttribute("street");
  4107. streetAttr = testEmployee.setAttributeNode(newAttribute);
  4108. value = streetAttr.value;
  4109. test.equal(value, 'No', 'streetNo');
  4110. test.done();
  4111. },
  4112. /**
  4113. *
  4114. The "getAttributes()" method(Node Interface) may
  4115. be used to retrieve the set of all attributes of an
  4116. element.
  4117. Create a list of all the attributes of the last child
  4118. of the first employee by using the "getAttributes()"
  4119. method. Examine the length of the attribute list.
  4120. This test uses the "getLength()" method from the
  4121. NameNodeMap interface.
  4122. * @author NIST
  4123. * @author Mary Brady
  4124. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  4125. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html
  4126. */
  4127. elementretrieveallattributes: function(test) {
  4128. var success;
  4129. var doc;
  4130. var addressList;
  4131. var testAddress;
  4132. var attributes;
  4133. doc = staff.staff();
  4134. addressList = doc.getElementsByTagName("address");
  4135. testAddress = addressList.item(0);
  4136. attributes = testAddress.attributes;
  4137. test.equal(attributes.length, 2, 'elementRetrieveAllAttributesAssert');
  4138. test.done();
  4139. },
  4140. /**
  4141. *
  4142. The "getAttribute(name)" method returns an attribute
  4143. value by name.
  4144. Retrieve the second address element, then
  4145. invoke the 'getAttribute("street")' method. This should
  4146. return the value of the attribute("No").
  4147. * @author NIST
  4148. * @author Mary Brady
  4149. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-666EE0F9
  4150. */
  4151. elementretrieveattrvalue: function(test) {
  4152. var success;
  4153. var doc;
  4154. var elementList;
  4155. var testAddress;
  4156. var attrValue;
  4157. doc = staff.staff();
  4158. elementList = doc.getElementsByTagName("address");
  4159. testAddress = elementList.item(2);
  4160. attrValue = testAddress.getAttribute("street");
  4161. test.equal(attrValue, 'No', 'attrValue');
  4162. test.done();
  4163. },
  4164. /**
  4165. *
  4166. The "getElementsByTagName()" method returns a NodeList
  4167. of all descendant elements with a given tagName.
  4168. Invoke the "getElementsByTagName()" method and create
  4169. a NodeList of "position" elements. Retrieve the second
  4170. "position" element in the list and return the NodeName.
  4171. * @author NIST
  4172. * @author Mary Brady
  4173. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  4174. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-104682815
  4175. */
  4176. elementretrievetagname: function(test) {
  4177. var success;
  4178. var doc;
  4179. var elementList;
  4180. var testEmployee;
  4181. var name;
  4182. doc = staff.staff();
  4183. elementList = doc.getElementsByTagName("position");
  4184. testEmployee = elementList.item(1);
  4185. name = testEmployee.nodeName;
  4186. test.equal(name, 'position', 'nodename');
  4187. name = testEmployee.tagName;
  4188. test.equal(name, 'position', 'tagname');
  4189. test.done();
  4190. },
  4191. /**
  4192. *
  4193. The "setAttributeNode(newAttr)" method for an attribute causes the
  4194. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  4195. if the node is readonly.
  4196. Obtain the children of the THIRD "gender" element. The elements
  4197. content is an entity reference. Try to remove the "domestic" attribute
  4198. from the entity reference by executing the "setAttributeNode(newAttr)" method.
  4199. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  4200. * @author NIST
  4201. * @author Mary Brady
  4202. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  4203. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  4204. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  4205. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  4206. */
  4207. elementsetattributenodenomodificationallowederr: function(test) {
  4208. var success;
  4209. var doc;
  4210. var genderList;
  4211. var gender;
  4212. var entRef;
  4213. var entElement;
  4214. var newAttr;
  4215. var nodeType;
  4216. var badAttr;
  4217. doc = staff.staff();
  4218. genderList = doc.getElementsByTagName("gender");
  4219. gender = genderList.item(2);
  4220. entRef = gender.firstChild;
  4221. test.notEqual(entRef, null, 'entRefNotNull');
  4222. nodeType = entRef.nodeType;
  4223. if(
  4224. (1 == nodeType)
  4225. ) {
  4226. entRef = doc.createEntityReference("ent4");
  4227. test.notEqual(entRef, null, 'createdEntRefNotNull');
  4228. }
  4229. entElement = entRef.firstChild;
  4230. test.notEqual(entElement, null, 'entElementNotNull');
  4231. newAttr = doc.createAttribute("newAttr");
  4232. {
  4233. success = false;
  4234. try {
  4235. badAttr = entElement.setAttributeNode(newAttr);
  4236. }
  4237. catch(ex) {
  4238. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  4239. }
  4240. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  4241. }
  4242. test.done();
  4243. },
  4244. /**
  4245. *
  4246. The "setAttributeNode(newAttr)" method for an attribute causes the
  4247. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  4248. if the node is readonly.
  4249. Create an entity reference and add to the THIRD "gender" element. The elements
  4250. content is an entity reference. Try to remove the "domestic" attribute
  4251. from the entity reference by executing the "setAttributeNode(newAttr)" method.
  4252. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  4253. * @author Curt Arnold
  4254. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  4255. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  4256. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  4257. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  4258. * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementsetattributenodenomodificationallowederr.xml
  4259. */
  4260. elementsetattributenodenomodificationallowederrEE: function(test) {
  4261. var success;
  4262. var doc;
  4263. var genderList;
  4264. var gender;
  4265. var entRef;
  4266. var entElement;
  4267. var newAttr;
  4268. var badAttr;
  4269. var appendedChild;
  4270. doc = staff.staff();
  4271. genderList = doc.getElementsByTagName("gender");
  4272. gender = genderList.item(2);
  4273. entRef = doc.createEntityReference("ent4");
  4274. test.notEqual(entRef, null, 'createdEntRefNotNull');
  4275. appendedChild = gender.appendChild(entRef);
  4276. entElement = entRef.firstChild;
  4277. test.notEqual(entElement, null, 'entElementNotNull');
  4278. newAttr = doc.createAttribute("newAttr");
  4279. {
  4280. success = false;
  4281. try {
  4282. badAttr = entElement.setAttributeNode(newAttr);
  4283. }
  4284. catch(ex) {
  4285. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  4286. }
  4287. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  4288. }
  4289. test.done();
  4290. },
  4291. /**
  4292. *
  4293. The "setAttributeNode(newAttr)" method returns the
  4294. null value if no previously existing Attr node with the
  4295. same name was replaced.
  4296. Retrieve the last child of the third employee and add a
  4297. new attribute to it. The new attribute node added is
  4298. "district", which is not part of this Element. The
  4299. method should return the null value.
  4300. This test uses the "createAttribute(name)"
  4301. method from the Document interface.
  4302. * @author NIST
  4303. * @author Mary Brady
  4304. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  4305. */
  4306. elementsetattributenodenull: function(test) {
  4307. var success;
  4308. var doc;
  4309. var elementList;
  4310. var testEmployee;
  4311. var newAttribute;
  4312. var districtAttr;
  4313. doc = staff.staff();
  4314. elementList = doc.getElementsByTagName("address");
  4315. testEmployee = elementList.item(2);
  4316. newAttribute = doc.createAttribute("district");
  4317. districtAttr = testEmployee.setAttributeNode(newAttribute);
  4318. test.equal(districtAttr, null, 'elementSetAttributeNodeNullAssert');
  4319. test.done();
  4320. },
  4321. /**
  4322. *
  4323. The "setAttribute(name,value)" method for an attribute causes the
  4324. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  4325. if the node is readonly.
  4326. Obtain the children of the THIRD "gender" element. The elements
  4327. content is an entity reference. Try to remove the "domestic" attribute
  4328. from the entity reference by executing the "setAttribute(name,value)" method.
  4329. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  4330. * @author NIST
  4331. * @author Mary Brady
  4332. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  4333. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
  4334. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  4335. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
  4336. */
  4337. elementsetattributenomodificationallowederr: function(test) {
  4338. var success;
  4339. var doc;
  4340. var genderList;
  4341. var gender;
  4342. var entRef;
  4343. var entElement;
  4344. doc = staff.staff();
  4345. genderList = doc.getElementsByTagName("gender");
  4346. gender = genderList.item(2);
  4347. entRef = gender.firstChild;
  4348. test.notEqual(entRef, null, 'entRefNotNull');
  4349. entElement = entRef.firstChild;
  4350. test.notEqual(entElement, null, 'entElementNotNull');
  4351. {
  4352. success = false;
  4353. try {
  4354. entElement.setAttribute("newAttr","newValue");
  4355. }
  4356. catch(ex) {
  4357. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  4358. }
  4359. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  4360. }
  4361. test.done();
  4362. },
  4363. /**
  4364. *
  4365. The "setAttribute(name,value)" method for an attribute causes the
  4366. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  4367. if the node is readonly.
  4368. Add an ent4 reference to the children of the THIRD "gender" element.
  4369. Try to remove the "domestic" attribute
  4370. from the entity reference by executing the "setAttribute(name,value)" method.
  4371. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  4372. * @author Curt Arnold
  4373. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  4374. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
  4375. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  4376. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
  4377. * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementsetattributenomodificationallowederr.xml
  4378. */
  4379. elementsetattributenomodificationallowederrEE: function(test) {
  4380. var success;
  4381. var doc;
  4382. var genderList;
  4383. var gender;
  4384. var entRef;
  4385. var entElement;
  4386. var appendedChild;
  4387. doc = staff.staff();
  4388. genderList = doc.getElementsByTagName("gender");
  4389. gender = genderList.item(2);
  4390. entRef = doc.createEntityReference("ent4");
  4391. appendedChild = gender.appendChild(entRef);
  4392. entElement = entRef.firstChild;
  4393. test.notEqual(entElement, null, 'entElementNotNull');
  4394. {
  4395. success = false;
  4396. try {
  4397. entElement.setAttribute("newAttr","newValue");
  4398. }
  4399. catch(ex) {
  4400. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  4401. }
  4402. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  4403. }
  4404. test.done();
  4405. },
  4406. /**
  4407. *
  4408. The "setAttributeNode(newAttr)" method raises an
  4409. "WRONG_DOCUMENT_ERR DOMException if the "newAttr"
  4410. was created from a different document than the one that
  4411. created this document.
  4412. Retrieve the last employee and attempt to set a new
  4413. attribute node for its "employee" element. The new
  4414. attribute was created from a document other than the
  4415. one that created this element, therefore a
  4416. WRONG_DOCUMENT_ERR DOMException should be raised.
  4417. This test uses the "createAttribute(newAttr)" method
  4418. from the Document interface.
  4419. * @author NIST
  4420. * @author Mary Brady
  4421. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])
  4422. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  4423. * @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'])
  4424. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  4425. */
  4426. elementwrongdocumenterr: function(test) {
  4427. var success;
  4428. var doc1;
  4429. var doc2;
  4430. var newAttribute;
  4431. var addressElementList;
  4432. var testAddress;
  4433. var attrAddress;
  4434. var doc1Ref = null;
  4435. if (typeof(this.doc1) != 'undefined') {
  4436. doc1Ref = this.doc1;
  4437. }
  4438. doc1 = staff.staff();
  4439. var doc2Ref = null;
  4440. if (typeof(this.doc2) != 'undefined') {
  4441. doc2Ref = this.doc2;
  4442. }
  4443. doc2 = staff.staff();
  4444. newAttribute = doc2.createAttribute("newAttribute");
  4445. addressElementList = doc1.getElementsByTagName("address");
  4446. testAddress = addressElementList.item(4);
  4447. {
  4448. success = false;
  4449. try {
  4450. attrAddress = testAddress.setAttributeNode(newAttribute);
  4451. }
  4452. catch(ex) {
  4453. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  4454. }
  4455. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  4456. }
  4457. test.done();
  4458. },
  4459. /**
  4460. *
  4461. The nodeName attribute that is inherited from Node
  4462. contains the name of the entity.
  4463. Retrieve the entity named "ent1" and access its name by
  4464. invoking the "getNodeName()" method inherited from
  4465. the Node interface.
  4466. * @author NIST
  4467. * @author Mary Brady
  4468. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-527DCFF2
  4469. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  4470. */
  4471. entitygetentityname: function(test) {
  4472. var success;
  4473. var doc;
  4474. var docType;
  4475. var entityList;
  4476. var entityNode;
  4477. var entityName;
  4478. doc = staff.staff();
  4479. docType = doc.doctype;
  4480. test.notEqual(docType, null, 'docTypeNotNull');
  4481. entityList = docType.entities;
  4482. test.notEqual(entityList, null, 'entitiesNotNull');
  4483. entityNode = entityList.getNamedItem("ent1");
  4484. entityName = entityNode.nodeName;
  4485. test.equal(entityName, 'ent1', 'entityGetEntityNameAssert');
  4486. test.done();
  4487. },
  4488. /**
  4489. *
  4490. The "getPublicId()" method of an Entity node contains
  4491. the public identifier associated with the entity, if
  4492. one was specified.
  4493. Retrieve the entity named "ent5" and access its
  4494. public identifier. The string "entityURI" should be
  4495. returned.
  4496. * @author NIST
  4497. * @author Mary Brady
  4498. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D7303025
  4499. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6ABAEB38
  4500. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D7C29F3E
  4501. */
  4502. entitygetpublicid: function(test) {
  4503. var doc = staff.staff();
  4504. test.notEqual(doc.doctype, null, 'docTypeNotNull');
  4505. test.notEqual(doc.doctype.entities, null, 'entitiesNotNull');
  4506. var entityNode = doc.doctype.entities.getNamedItem("ent5");
  4507. test.equal(entityNode.publicId, 'entityURI', 'publicId');
  4508. test.equal(entityNode.systemId, 'entityFile');
  4509. test.equal(entityNode.notationName, 'notation1', 'notation');
  4510. test.done();
  4511. },
  4512. /**
  4513. *
  4514. The "getPublicId()" method of an Entity node contains
  4515. the public identifier associated with the entity, if
  4516. one was not specified a null value should be returned.
  4517. Retrieve the entity named "ent1" and access its
  4518. public identifier. Since a public identifier was not
  4519. specified for this entity, the "getPublicId()" method
  4520. should return null.
  4521. * @author NIST
  4522. * @author Mary Brady
  4523. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D7303025
  4524. */
  4525. entitygetpublicidnull: function(test) {
  4526. var success;
  4527. var doc;
  4528. var docType;
  4529. var entityList;
  4530. var entityNode;
  4531. var publicId;
  4532. doc = staff.staff();
  4533. docType = doc.doctype;
  4534. test.notEqual(docType, null, 'docTypeNotNull');
  4535. entityList = docType.entities;
  4536. test.notEqual(entityList, null, 'entitiesNotNull');
  4537. entityNode = entityList.getNamedItem("ent1");
  4538. publicId = entityNode.publicId;
  4539. test.equal(publicId, null, 'entityGetPublicIdNullAssert');
  4540. test.done();
  4541. },
  4542. /**
  4543. *
  4544. Appends a text node to an attribute and checks if the value of
  4545. the attribute is changed.
  4546. * @author Curt Arnold
  4547. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  4548. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  4549. */
  4550. hc_attrappendchild1: function(test) {
  4551. var success;
  4552. var doc;
  4553. var acronymList;
  4554. var testNode;
  4555. var attributes;
  4556. var titleAttr;
  4557. var value;
  4558. var textNode;
  4559. var retval;
  4560. var lastChild;
  4561. doc = hc_staff.hc_staff();
  4562. acronymList = doc.getElementsByTagName("acronym");
  4563. testNode = acronymList.item(3);
  4564. attributes = testNode.attributes;
  4565. titleAttr = attributes.getNamedItem("title");
  4566. textNode = doc.createTextNode("terday");
  4567. retval = titleAttr.appendChild(textNode);
  4568. value = titleAttr.value;
  4569. test.equal(value, 'Yesterday', 'attrValue');
  4570. value = titleAttr.nodeValue;
  4571. test.equal(value, 'Yesterday', 'attrNodeValue');
  4572. value = retval.nodeValue;
  4573. test.equal(value, 'terday', 'retvalValue');
  4574. lastChild = titleAttr.lastChild;
  4575. value = lastChild.nodeValue;
  4576. test.equal(value, 'terday', 'lastChildValue');
  4577. test.done();
  4578. },
  4579. /**
  4580. *
  4581. Attempts to append an element to the child nodes of an attribute.
  4582. * @author Curt Arnold
  4583. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  4584. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  4585. */
  4586. hc_attrappendchild2: function(test) {
  4587. var success;
  4588. var doc;
  4589. var acronymList;
  4590. var testNode;
  4591. var attributes;
  4592. var titleAttr;
  4593. var value;
  4594. var newChild;
  4595. var retval;
  4596. var lastChild;
  4597. doc = hc_staff.hc_staff();
  4598. acronymList = doc.getElementsByTagName("acronym");
  4599. testNode = acronymList.item(3);
  4600. attributes = testNode.attributes;
  4601. titleAttr = attributes.getNamedItem("title");
  4602. newChild = doc.createElement("terday");
  4603. {
  4604. success = false;
  4605. try {
  4606. retval = titleAttr.appendChild(newChild);
  4607. }
  4608. catch(ex) {
  4609. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  4610. }
  4611. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  4612. }
  4613. test.done();
  4614. },
  4615. /**
  4616. *
  4617. Appends a document fragment to an attribute and checks if the value of
  4618. the attribute is changed.
  4619. * @author Curt Arnold
  4620. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  4621. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  4622. */
  4623. hc_attrappendchild3: function(test) {
  4624. var success;
  4625. var doc;
  4626. var acronymList;
  4627. var testNode;
  4628. var attributes;
  4629. var titleAttr;
  4630. var value;
  4631. var terNode;
  4632. var dayNode;
  4633. var retval;
  4634. var lastChild;
  4635. var docFrag;
  4636. doc = hc_staff.hc_staff();
  4637. acronymList = doc.getElementsByTagName("acronym");
  4638. testNode = acronymList.item(3);
  4639. attributes = testNode.attributes;
  4640. titleAttr = attributes.getNamedItem("title");
  4641. terNode = doc.createTextNode("ter");
  4642. dayNode = doc.createTextNode("day");
  4643. docFrag = doc.createDocumentFragment();
  4644. retval = docFrag.appendChild(terNode);
  4645. retval = docFrag.appendChild(dayNode);
  4646. retval = titleAttr.appendChild(docFrag);
  4647. value = titleAttr.value;
  4648. test.equal(value, 'Yesterday', 'attrValue');
  4649. value = titleAttr.nodeValue;
  4650. test.equal(value, 'Yesterday', 'attrNodeValue');
  4651. value = retval.nodeValue;
  4652. test.equal(value, null, 'retvalValue');
  4653. lastChild = titleAttr.lastChild;
  4654. value = lastChild.nodeValue;
  4655. test.equal(value, 'day', 'lastChildValue');
  4656. test.done();
  4657. },
  4658. /**
  4659. *
  4660. Attempt to append a CDATASection to an attribute which should result
  4661. in a HIERARCHY_REQUEST_ERR.
  4662. * @author Curt Arnold
  4663. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  4664. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  4665. */
  4666. hc_attrappendchild4: function(test) {
  4667. var success;
  4668. var doc;
  4669. var acronymList;
  4670. var testNode;
  4671. var attributes;
  4672. var titleAttr;
  4673. var value;
  4674. var textNode;
  4675. var retval;
  4676. var lastChild;
  4677. doc = hc_staff.hc_staff();
  4678. acronymList = doc.getElementsByTagName("acronym");
  4679. testNode = acronymList.item(3);
  4680. attributes = testNode.attributes;
  4681. titleAttr = attributes.getNamedItem("title");
  4682. textNode = doc.createCDATASection("terday");
  4683. success = false;
  4684. try {
  4685. retval = titleAttr.appendChild(textNode);
  4686. }
  4687. catch(ex) {
  4688. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  4689. }
  4690. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  4691. test.done();
  4692. },
  4693. /**
  4694. *
  4695. Attempt to append a node from another document to an attribute which should result
  4696. in a WRONG_DOCUMENT_ERR.
  4697. * @author Curt Arnold
  4698. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  4699. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  4700. */
  4701. hc_attrappendchild5: function(test) {
  4702. var success;
  4703. var doc;
  4704. var acronymList;
  4705. var testNode;
  4706. var attributes;
  4707. var titleAttr;
  4708. var value;
  4709. var textNode;
  4710. var retval;
  4711. var lastChild;
  4712. var otherDoc;
  4713. doc = hc_staff.hc_staff();
  4714. var otherDocRef = null;
  4715. if (typeof(this.otherDoc) != 'undefined') {
  4716. otherDocRef = this.otherDoc;
  4717. }
  4718. otherDoc = hc_staff.hc_staff();
  4719. acronymList = doc.getElementsByTagName("acronym");
  4720. testNode = acronymList.item(3);
  4721. attributes = testNode.attributes;
  4722. titleAttr = attributes.getNamedItem("title");
  4723. textNode = otherDoc.createTextNode("terday");
  4724. {
  4725. success = false;
  4726. try {
  4727. retval = titleAttr.appendChild(textNode);
  4728. }
  4729. catch(ex) {
  4730. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  4731. }
  4732. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  4733. }
  4734. test.done();
  4735. },
  4736. /**
  4737. *
  4738. Creates an new attribute node and appends a text node.
  4739. * @author Curt Arnold
  4740. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  4741. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  4742. */
  4743. hc_attrappendchild6: function(test) {
  4744. var success;
  4745. var doc;
  4746. var acronymList;
  4747. var testNode;
  4748. var attributes;
  4749. var titleAttr;
  4750. var value;
  4751. var textNode;
  4752. var retval;
  4753. var lastChild;
  4754. doc = hc_staff.hc_staff();
  4755. titleAttr = doc.createAttribute("title");
  4756. textNode = doc.createTextNode("Yesterday");
  4757. retval = titleAttr.appendChild(textNode);
  4758. value = titleAttr.value;
  4759. test.equal(value, 'Yesterday', 'attrValue');
  4760. value = titleAttr.nodeValue;
  4761. test.equal(value, 'Yesterday', 'attrNodeValue');
  4762. value = retval.nodeValue;
  4763. test.equal(value, 'Yesterday', 'retvalValue');
  4764. lastChild = titleAttr.lastChild;
  4765. value = lastChild.nodeValue;
  4766. test.equal(value, 'Yesterday', 'lastChildValue');
  4767. test.done();
  4768. },
  4769. /**
  4770. *
  4771. Checks that Node.childNodes for an attribute node contains
  4772. the expected text node.
  4773. * @author Curt Arnold
  4774. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  4775. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  4776. */
  4777. hc_attrchildnodes1: function(test) {
  4778. var success;
  4779. var doc;
  4780. var acronymList;
  4781. var testNode;
  4782. var attributes;
  4783. var titleAttr;
  4784. var value;
  4785. var textNode;
  4786. var childNodes;
  4787. doc = hc_staff.hc_staff();
  4788. acronymList = doc.getElementsByTagName("acronym");
  4789. testNode = acronymList.item(3);
  4790. attributes = testNode.attributes;
  4791. titleAttr = attributes.getNamedItem("title");
  4792. childNodes = titleAttr.childNodes;
  4793. test.equal(childNodes.length, 1, 'childNodesSize');
  4794. textNode = childNodes.item(0);
  4795. value = textNode.nodeValue;
  4796. test.equal(value, 'Yes', 'child1IsYes');
  4797. textNode = childNodes.item(1);
  4798. test.equal(textNode, null, 'secondItemIsNull');
  4799. test.done();
  4800. },
  4801. /**
  4802. *
  4803. Checks Node.childNodes for an attribute with multiple child nodes.
  4804. * @author Curt Arnold
  4805. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  4806. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  4807. */
  4808. hc_attrchildnodes2: function(test) {
  4809. var success;
  4810. var doc;
  4811. var acronymList;
  4812. var testNode;
  4813. var attributes;
  4814. var titleAttr;
  4815. var value;
  4816. var textNode;
  4817. var childNodes;
  4818. var retval;
  4819. doc = hc_staff.hc_staff();
  4820. acronymList = doc.getElementsByTagName("acronym");
  4821. testNode = acronymList.item(3);
  4822. attributes = testNode.attributes;
  4823. titleAttr = attributes.getNamedItem("title");
  4824. childNodes = titleAttr.childNodes;
  4825. textNode = doc.createTextNode("terday");
  4826. retval = titleAttr.appendChild(textNode);
  4827. test.equal(childNodes.length, 2, 'childNodesSize');
  4828. textNode = childNodes.item(0);
  4829. value = textNode.nodeValue;
  4830. test.equal(value, 'Yes', 'child1IsYes');
  4831. textNode = childNodes.item(1);
  4832. value = textNode.nodeValue;
  4833. test.equal(value, 'terday', 'child2IsTerday');
  4834. textNode = childNodes.item(2);
  4835. test.equal(textNode, null, 'thirdItemIsNull');
  4836. test.done();
  4837. },
  4838. /**
  4839. *
  4840. Appends a text node to an attribute and clones the node.
  4841. * @author Curt Arnold
  4842. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  4843. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
  4844. */
  4845. hc_attrclonenode1: function(test) {
  4846. var success;
  4847. var doc;
  4848. var acronymList;
  4849. var testNode;
  4850. var attributes;
  4851. var titleAttr;
  4852. var value;
  4853. var textNode;
  4854. var retval;
  4855. var lastChild;
  4856. var clonedTitle;
  4857. doc = hc_staff.hc_staff();
  4858. acronymList = doc.getElementsByTagName("acronym");
  4859. testNode = acronymList.item(3);
  4860. attributes = testNode.attributes;
  4861. titleAttr = attributes.getNamedItem("title");
  4862. textNode = doc.createTextNode("terday");
  4863. retval = titleAttr.appendChild(textNode);
  4864. clonedTitle = titleAttr.cloneNode(false);
  4865. textNode.nodeValue = "text_node_not_cloned";
  4866. value = clonedTitle.value;
  4867. test.equal(value, 'Yesterday', 'attrValue');
  4868. value = clonedTitle.nodeValue;
  4869. test.equal(value, 'Yesterday', 'attrNodeValue');
  4870. lastChild = clonedTitle.lastChild;
  4871. value = lastChild.nodeValue;
  4872. test.equal(value, 'terday', 'lastChildValue');
  4873. test.done();
  4874. },
  4875. /**
  4876. *
  4877. Create a new DocumentFragment and add a newly created Element node(with one attribute).
  4878. Once the element is added, its attribute should be available as an attribute associated
  4879. with an Element within a DocumentFragment.
  4880. * @author Curt Arnold
  4881. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-35CB04B5
  4882. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
  4883. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
  4884. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  4885. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
  4886. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
  4887. */
  4888. hc_attrcreatedocumentfragment: function(test) {
  4889. var doc = hc_staff.hc_staff();
  4890. var docFragment = doc.createDocumentFragment();
  4891. var newOne = doc.createElement("html");
  4892. newOne.setAttribute("lang","EN");
  4893. docFragment.appendChild(newOne);
  4894. var attributes = docFragment.firstChild.attributes;
  4895. var count = 0
  4896. for(var i=0;i<attributes.length;i++) {
  4897. if (attributes.item(i).nodeName == "lang") {
  4898. count += 1;
  4899. }
  4900. }
  4901. test.equal(count, 1, 'hasLangAttr');
  4902. test.done();
  4903. },
  4904. /**
  4905. *
  4906. The "setValue()" method for an attribute creates a
  4907. Text node with the unparsed content of the string.
  4908. Retrieve the attribute named "class" from the last
  4909. child of of the fourth employee and assign the "Y&ent1;"
  4910. string to its value attribute. This value is not yet
  4911. parsed and therefore should still be the same upon
  4912. retrieval. This test uses the "getNamedItem(name)" method
  4913. from the NamedNodeMap interface.
  4914. * @author Curt Arnold
  4915. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
  4916. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Apr/0057.html
  4917. */
  4918. hc_attrcreatetextnode: function(test) {
  4919. var success;
  4920. var doc;
  4921. var addressList;
  4922. var testNode;
  4923. var attributes;
  4924. var streetAttr;
  4925. var value;
  4926. doc = hc_staff.hc_staff();
  4927. addressList = doc.getElementsByTagName("acronym");
  4928. testNode = addressList.item(3);
  4929. attributes = testNode.attributes;
  4930. streetAttr = attributes.getNamedItem("class");
  4931. streetAttr.value = "Y&ent1;";
  4932. value = streetAttr.value;
  4933. test.equal(value, 'Y&ent1;', 'value');
  4934. value = streetAttr.nodeValue;
  4935. test.equal(value, 'Y&ent1;', 'nodeValue');
  4936. test.done();
  4937. },
  4938. /**
  4939. *
  4940. The "setNodeValue()" method for an attribute creates a
  4941. Text node with the unparsed content of the string.
  4942. Retrieve the attribute named "class" from the last
  4943. child of of the fourth employee and assign the "Y&ent1;"
  4944. string to its value attribute. This value is not yet
  4945. parsed and therefore should still be the same upon
  4946. retrieval. This test uses the "getNamedItem(name)" method
  4947. from the NamedNodeMap interface.
  4948. * @author Curt Arnold
  4949. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  4950. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Apr/0057.html
  4951. */
  4952. hc_attrcreatetextnode2: function(test) {
  4953. var success;
  4954. var doc;
  4955. var addressList;
  4956. var testNode;
  4957. var attributes;
  4958. var streetAttr;
  4959. var value;
  4960. doc = hc_staff.hc_staff();
  4961. addressList = doc.getElementsByTagName("acronym");
  4962. testNode = addressList.item(3);
  4963. attributes = testNode.attributes;
  4964. streetAttr = attributes.getNamedItem("class");
  4965. streetAttr.nodeValue = "Y&ent1;";
  4966. value = streetAttr.value;
  4967. test.equal(value, 'Y&ent1;', 'value');
  4968. value = streetAttr.nodeValue;
  4969. test.equal(value, 'Y&ent1;', 'nodeValue');
  4970. test.done();
  4971. },
  4972. /**
  4973. *
  4974. If an Attr is explicitly assigned any value, then that value is the attributes effective value.
  4975. Retrieve the attribute named "domestic" from the last child of of the first employee
  4976. and examine its nodeValue attribute. This test uses the "getNamedItem(name)" method
  4977. from the NamedNodeMap interface.
  4978. * @author Curt Arnold
  4979. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  4980. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
  4981. */
  4982. hc_attreffectivevalue: function(test) {
  4983. var success;
  4984. var doc;
  4985. var addressList;
  4986. var testNode;
  4987. var attributes;
  4988. var domesticAttr;
  4989. var value;
  4990. doc = hc_staff.hc_staff();
  4991. addressList = doc.getElementsByTagName("acronym");
  4992. testNode = addressList.item(0);
  4993. attributes = testNode.attributes;
  4994. domesticAttr = attributes.getNamedItem("title");
  4995. value = domesticAttr.nodeValue;
  4996. test.equal(value, 'Yes', 'attrEffectiveValueAssert');
  4997. test.done();
  4998. },
  4999. /**
  5000. *
  5001. Checks that Node.firstChild for an attribute node contains
  5002. the expected text node.
  5003. * @author Curt Arnold
  5004. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  5005. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-169727388
  5006. */
  5007. hc_attrfirstchild: function(test) {
  5008. var success;
  5009. var doc;
  5010. var acronymList;
  5011. var testNode;
  5012. var attributes;
  5013. var titleAttr;
  5014. var value;
  5015. var textNode;
  5016. var otherChild;
  5017. doc = hc_staff.hc_staff();
  5018. acronymList = doc.getElementsByTagName("acronym");
  5019. testNode = acronymList.item(3);
  5020. attributes = testNode.attributes;
  5021. titleAttr = attributes.getNamedItem("title");
  5022. textNode = titleAttr.firstChild;
  5023. test.notEqual(textNode, null, 'textNodeNotNull');
  5024. value = textNode.nodeValue;
  5025. test.equal(value, 'Yes', 'child1IsYes');
  5026. otherChild = textNode.nextSibling;
  5027. test.equal(otherChild, null, 'nextSiblingIsNull');
  5028. otherChild = textNode.previousSibling;
  5029. test.equal(otherChild, null, 'previousSiblingIsNull');
  5030. test.done();
  5031. },
  5032. /**
  5033. *
  5034. Checks the value of an attribute that contains entity references.
  5035. * @author Curt Arnold
  5036. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
  5037. */
  5038. hc_attrgetvalue1: function(test) {
  5039. var success;
  5040. var doc;
  5041. var acronymList;
  5042. var testNode;
  5043. var attributes;
  5044. var titleAttr;
  5045. var value;
  5046. var textNode;
  5047. var retval;
  5048. var lastChild;
  5049. doc = hc_staff.hc_staff();
  5050. acronymList = doc.getElementsByTagName("acronym");
  5051. testNode = acronymList.item(3);
  5052. attributes = testNode.attributes;
  5053. titleAttr = attributes.getNamedItem("class");
  5054. value = titleAttr.value;
  5055. test.equal(value, 'Yα', 'attrValue1');
  5056. test.done();
  5057. },
  5058. /**
  5059. *
  5060. Checks the value of an attribute that contains entity references.
  5061. * @author Curt Arnold
  5062. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
  5063. */
  5064. hc_attrgetvalue2: function(test) {
  5065. var success;
  5066. var doc;
  5067. var acronymList;
  5068. var testNode;
  5069. var attributes;
  5070. var titleAttr;
  5071. var value;
  5072. var textNode;
  5073. var retval;
  5074. var firstChild;
  5075. var alphaRef;
  5076. doc = hc_staff.hc_staff();
  5077. acronymList = doc.getElementsByTagName("acronym");
  5078. testNode = acronymList.item(3);
  5079. attributes = testNode.attributes;
  5080. titleAttr = attributes.getNamedItem("class");
  5081. alphaRef = doc.createEntityReference("alpha");
  5082. firstChild = titleAttr.firstChild;
  5083. retval = titleAttr.insertBefore(alphaRef,firstChild);
  5084. value = titleAttr.value;
  5085. test.equal(value, 'αYα', 'attrValue1');
  5086. test.done();
  5087. },
  5088. /**
  5089. *
  5090. Checks that Node.hasChildNodes() is true for an attribute with content.
  5091. * @author Curt Arnold
  5092. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  5093. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-810594187
  5094. */
  5095. hc_attrhaschildnodes: function(test) {
  5096. var success;
  5097. var doc;
  5098. var acronymList;
  5099. var testNode;
  5100. var attributes;
  5101. var titleAttr;
  5102. var hasChildNodes;
  5103. doc = hc_staff.hc_staff();
  5104. acronymList = doc.getElementsByTagName("acronym");
  5105. testNode = acronymList.item(3);
  5106. attributes = testNode.attributes;
  5107. titleAttr = attributes.getNamedItem("title");
  5108. hasChildNodes = titleAttr.hasChildNodes();
  5109. test.ok(hasChildNodes, 'hasChildrenIsTrue');
  5110. test.done();
  5111. },
  5112. /**
  5113. *
  5114. Appends a text node to an attribute and checks if the value of
  5115. the attribute is changed.
  5116. * @author Curt Arnold
  5117. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  5118. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5119. */
  5120. hc_attrinsertbefore1: function(test) {
  5121. var success;
  5122. var doc;
  5123. var acronymList;
  5124. var testNode;
  5125. var attributes;
  5126. var titleAttr;
  5127. var value;
  5128. var textNode;
  5129. var retval;
  5130. var firstChild;
  5131. var lastChild;
  5132. var refChild = null;
  5133. doc = hc_staff.hc_staff();
  5134. acronymList = doc.getElementsByTagName("acronym");
  5135. testNode = acronymList.item(3);
  5136. attributes = testNode.attributes;
  5137. titleAttr = attributes.getNamedItem("title");
  5138. textNode = doc.createTextNode("terday");
  5139. retval = titleAttr.insertBefore(textNode,refChild);
  5140. value = titleAttr.value;
  5141. test.equal(value, 'Yesterday', 'attrValue');
  5142. value = titleAttr.nodeValue;
  5143. test.equal(value, 'Yesterday', 'attrNodeValue');
  5144. value = retval.nodeValue;
  5145. test.equal(value, 'terday', 'retvalValue');
  5146. firstChild = titleAttr.firstChild;
  5147. value = firstChild.nodeValue;
  5148. test.equal(value, 'Yes', 'firstChildValue');
  5149. lastChild = titleAttr.lastChild;
  5150. value = lastChild.nodeValue;
  5151. test.equal(value, 'terday', 'lastChildValue');
  5152. test.done();
  5153. },
  5154. /**
  5155. *
  5156. Prepends a text node to an attribute and checks if the value of
  5157. the attribute is changed.
  5158. * @author Curt Arnold
  5159. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  5160. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5161. */
  5162. hc_attrinsertbefore2: function(test) {
  5163. var success;
  5164. var doc;
  5165. var acronymList;
  5166. var testNode;
  5167. var attributes;
  5168. var titleAttr;
  5169. var value;
  5170. var textNode;
  5171. var retval;
  5172. var lastChild;
  5173. var firstChild;
  5174. var refChild;
  5175. doc = hc_staff.hc_staff();
  5176. acronymList = doc.getElementsByTagName("acronym");
  5177. testNode = acronymList.item(3);
  5178. attributes = testNode.attributes;
  5179. titleAttr = attributes.getNamedItem("title");
  5180. textNode = doc.createTextNode("terday");
  5181. refChild = titleAttr.firstChild;
  5182. retval = titleAttr.insertBefore(textNode,refChild);
  5183. value = titleAttr.value;
  5184. test.equal(value, 'terdayYes', 'attrValue');
  5185. value = titleAttr.nodeValue;
  5186. test.equal(value, 'terdayYes', 'attrNodeValue');
  5187. value = retval.nodeValue;
  5188. test.equal(value, 'terday', 'retvalValue');
  5189. firstChild = titleAttr.firstChild;
  5190. value = firstChild.nodeValue;
  5191. test.equal(value, 'terday', 'firstChildValue');
  5192. lastChild = titleAttr.lastChild;
  5193. value = lastChild.nodeValue;
  5194. test.equal(value, 'Yes', 'lastChildValue');
  5195. test.done();
  5196. },
  5197. /**
  5198. *
  5199. Appends a document fragment to an attribute and checks if the value of
  5200. the attribute is changed.
  5201. * @author Curt Arnold
  5202. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  5203. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5204. */
  5205. hc_attrinsertbefore3: function(test) {
  5206. var success;
  5207. var doc;
  5208. var acronymList;
  5209. var testNode;
  5210. var attributes;
  5211. var titleAttr;
  5212. var value;
  5213. var terNode;
  5214. var dayNode;
  5215. var docFrag;
  5216. var retval;
  5217. var firstChild;
  5218. var lastChild;
  5219. var refChild = null;
  5220. doc = hc_staff.hc_staff();
  5221. acronymList = doc.getElementsByTagName("acronym");
  5222. testNode = acronymList.item(3);
  5223. attributes = testNode.attributes;
  5224. titleAttr = attributes.getNamedItem("title");
  5225. terNode = doc.createTextNode("ter");
  5226. dayNode = doc.createTextNode("day");
  5227. docFrag = doc.createDocumentFragment();
  5228. retval = docFrag.appendChild(terNode);
  5229. retval = docFrag.appendChild(dayNode);
  5230. retval = titleAttr.insertBefore(docFrag,refChild);
  5231. value = titleAttr.value;
  5232. test.equal(value, 'Yesterday', 'attrValue');
  5233. value = titleAttr.nodeValue;
  5234. test.equal(value, 'Yesterday', 'attrNodeValue');
  5235. value = retval.nodeValue;
  5236. test.equal(value, null, 'retvalValue');
  5237. firstChild = titleAttr.firstChild;
  5238. value = firstChild.nodeValue;
  5239. test.equal(value, 'Yes', 'firstChildValue');
  5240. lastChild = titleAttr.lastChild;
  5241. value = lastChild.nodeValue;
  5242. test.equal(value, 'day', 'lastChildValue');
  5243. test.done();
  5244. },
  5245. /**
  5246. *
  5247. Prepends a document fragment to an attribute and checks if the value of
  5248. the attribute is changed.
  5249. * @author Curt Arnold
  5250. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  5251. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5252. */
  5253. hc_attrinsertbefore4: function(test) {
  5254. var success;
  5255. var doc;
  5256. var acronymList;
  5257. var testNode;
  5258. var attributes;
  5259. var titleAttr;
  5260. var value;
  5261. var terNode;
  5262. var dayNode;
  5263. var docFrag;
  5264. var retval;
  5265. var firstChild;
  5266. var lastChild;
  5267. var refChild;
  5268. doc = hc_staff.hc_staff();
  5269. acronymList = doc.getElementsByTagName("acronym");
  5270. testNode = acronymList.item(3);
  5271. attributes = testNode.attributes;
  5272. titleAttr = attributes.getNamedItem("title");
  5273. terNode = doc.createTextNode("ter");
  5274. dayNode = doc.createTextNode("day");
  5275. docFrag = doc.createDocumentFragment();
  5276. retval = docFrag.appendChild(terNode);
  5277. retval = docFrag.appendChild(dayNode);
  5278. refChild = titleAttr.firstChild;
  5279. retval = titleAttr.insertBefore(docFrag,refChild);
  5280. value = titleAttr.value;
  5281. test.equal(value, 'terdayYes', 'attrValue');
  5282. value = titleAttr.nodeValue;
  5283. test.equal(value, 'terdayYes', 'attrNodeValue');
  5284. value = retval.nodeValue;
  5285. test.equal(value, null, 'retvalValue');
  5286. firstChild = titleAttr.firstChild;
  5287. value = firstChild.nodeValue;
  5288. test.equal(value, 'ter', 'firstChildValue');
  5289. lastChild = titleAttr.lastChild;
  5290. value = lastChild.nodeValue;
  5291. test.equal(value, 'Yes', 'lastChildValue');
  5292. test.done();
  5293. },
  5294. /**
  5295. *
  5296. Attempt to append a CDATASection to an attribute which should result
  5297. in a HIERARCHY_REQUEST_ERR.
  5298. * @author Curt Arnold
  5299. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  5300. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5301. */
  5302. hc_attrinsertbefore5: function(test) {
  5303. var success;
  5304. var doc;
  5305. var acronymList;
  5306. var testNode;
  5307. var attributes;
  5308. var titleAttr;
  5309. var value;
  5310. var textNode;
  5311. var retval;
  5312. var refChild = null;
  5313. doc = hc_staff.hc_staff();
  5314. acronymList = doc.getElementsByTagName("acronym");
  5315. testNode = acronymList.item(3);
  5316. attributes = testNode.attributes;
  5317. titleAttr = attributes.getNamedItem("title");
  5318. textNode = doc.createCDATASection("terday");
  5319. success = false;
  5320. try {
  5321. retval = titleAttr.insertBefore(textNode,refChild);
  5322. }
  5323. catch(ex) {
  5324. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  5325. }
  5326. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  5327. test.done();
  5328. },
  5329. /**
  5330. *
  5331. Attempt to append a text node from another document to an attribute which should result
  5332. in a WRONG_DOCUMENT_ERR.
  5333. * @author Curt Arnold
  5334. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  5335. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5336. */
  5337. hc_attrinsertbefore6: function(test) {
  5338. var success;
  5339. var doc;
  5340. var acronymList;
  5341. var testNode;
  5342. var attributes;
  5343. var titleAttr;
  5344. var value;
  5345. var textNode;
  5346. var retval;
  5347. var refChild = null;
  5348. var otherDoc;
  5349. doc = hc_staff.hc_staff();
  5350. var otherDocRef = null;
  5351. if (typeof(this.otherDoc) != 'undefined') {
  5352. otherDocRef = this.otherDoc;
  5353. }
  5354. otherDoc = hc_staff.hc_staff();
  5355. acronymList = doc.getElementsByTagName("acronym");
  5356. testNode = acronymList.item(3);
  5357. attributes = testNode.attributes;
  5358. titleAttr = attributes.getNamedItem("title");
  5359. textNode = otherDoc.createTextNode("terday");
  5360. {
  5361. success = false;
  5362. try {
  5363. retval = titleAttr.insertBefore(textNode,refChild);
  5364. }
  5365. catch(ex) {
  5366. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  5367. }
  5368. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  5369. }
  5370. test.done();
  5371. },
  5372. /**
  5373. *
  5374. Appends a document fragment containing a CDATASection to an attribute.
  5375. * @author Curt Arnold
  5376. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  5377. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  5378. */
  5379. hc_attrinsertbefore7: function(test) {
  5380. var success;
  5381. var doc;
  5382. var acronymList;
  5383. var testNode;
  5384. var attributes;
  5385. var titleAttr;
  5386. var value;
  5387. var terNode;
  5388. var dayNode;
  5389. var docFrag;
  5390. var retval;
  5391. var firstChild;
  5392. var lastChild;
  5393. var refChild = null;
  5394. doc = hc_staff.hc_staff();
  5395. acronymList = doc.getElementsByTagName("acronym");
  5396. testNode = acronymList.item(3);
  5397. attributes = testNode.attributes;
  5398. titleAttr = attributes.getNamedItem("title");
  5399. terNode = doc.createTextNode("ter");
  5400. dayNode = doc.createCDATASection("day");
  5401. docFrag = doc.createDocumentFragment();
  5402. retval = docFrag.appendChild(terNode);
  5403. retval = docFrag.appendChild(dayNode);
  5404. success = false;
  5405. try {
  5406. retval = titleAttr.insertBefore(docFrag,refChild);
  5407. }
  5408. catch(ex) {
  5409. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  5410. }
  5411. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  5412. test.done();
  5413. },
  5414. /**
  5415. *
  5416. Checks that Node.lastChild for an attribute node contains
  5417. the expected text node.
  5418. * @author Curt Arnold
  5419. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  5420. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-61AD09FB
  5421. */
  5422. hc_attrlastchild: function(test) {
  5423. var success;
  5424. var doc;
  5425. var acronymList;
  5426. var testNode;
  5427. var attributes;
  5428. var titleAttr;
  5429. var value;
  5430. var textNode;
  5431. var otherChild;
  5432. doc = hc_staff.hc_staff();
  5433. acronymList = doc.getElementsByTagName("acronym");
  5434. testNode = acronymList.item(3);
  5435. attributes = testNode.attributes;
  5436. titleAttr = attributes.getNamedItem("title");
  5437. textNode = titleAttr.firstChild;
  5438. test.notEqual(textNode, null, 'textNodeNotNull');
  5439. value = textNode.nodeValue;
  5440. test.equal(value, 'Yes', 'child1IsYes');
  5441. otherChild = textNode.nextSibling;
  5442. test.equal(otherChild, null, 'nextSiblingIsNull');
  5443. otherChild = textNode.previousSibling;
  5444. test.equal(otherChild, null, 'previousSiblingIsNull');
  5445. test.done();
  5446. },
  5447. /**
  5448. *
  5449. Retrieve the attribute named class from the last
  5450. child of of the second "p" element and examine its
  5451. NodeName.
  5452. * @author Curt Arnold
  5453. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  5454. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1112119403
  5455. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  5456. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
  5457. */
  5458. hc_attrname: function(test) {
  5459. var success;
  5460. var doc;
  5461. var addressList;
  5462. var testNode;
  5463. var attributes;
  5464. var streetAttr;
  5465. var strong1;
  5466. var strong2;
  5467. doc = hc_staff.hc_staff();
  5468. addressList = doc.getElementsByTagName("acronym");
  5469. testNode = addressList.item(1);
  5470. attributes = testNode.attributes;
  5471. streetAttr = attributes.getNamedItem("class");
  5472. strong1 = streetAttr.nodeName;
  5473. strong2 = streetAttr.name;
  5474. test.equal(strong1, 'class', 'attribute nodeName');
  5475. test.equal(strong2, 'class', 'attribute name');
  5476. test.done();
  5477. },
  5478. /**
  5479. *
  5480. The "getNextSibling()" method for an Attr node should return null.
  5481. Retrieve the attribute named "domestic" from the last child of of the
  5482. first employee and examine its NextSibling node. This test uses the
  5483. "getNamedItem(name)" method from the NamedNodeMap interface.
  5484. * @author Curt Arnold
  5485. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F
  5486. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  5487. */
  5488. hc_attrnextsiblingnull: function(test) {
  5489. var success;
  5490. var doc;
  5491. var addressList;
  5492. var testNode;
  5493. var attributes;
  5494. var domesticAttr;
  5495. var s;
  5496. doc = hc_staff.hc_staff();
  5497. addressList = doc.getElementsByTagName("acronym");
  5498. testNode = addressList.item(0);
  5499. attributes = testNode.attributes;
  5500. domesticAttr = attributes.getNamedItem("title");
  5501. s = domesticAttr.nextSibling;
  5502. test.equal(s, null, 'attrNextSiblingNullAssert');
  5503. test.done();
  5504. },
  5505. /**
  5506. *
  5507. Appends a text node to an attribute, normalizes the attribute
  5508. and checks for a single child node.
  5509. * @author Curt Arnold
  5510. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  5511. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083
  5512. */
  5513. hc_attrnormalize: function(test) {
  5514. var success;
  5515. var doc;
  5516. var acronymList;
  5517. var testNode;
  5518. var attributes;
  5519. var titleAttr;
  5520. var value;
  5521. var textNode;
  5522. var retval;
  5523. var firstChild;
  5524. var secondChild;
  5525. doc = hc_staff.hc_staff();
  5526. acronymList = doc.getElementsByTagName("acronym");
  5527. testNode = acronymList.item(3);
  5528. attributes = testNode.attributes;
  5529. titleAttr = attributes.getNamedItem("title");
  5530. textNode = doc.createTextNode("terday");
  5531. retval = titleAttr.appendChild(textNode);
  5532. textNode = doc.createTextNode("");
  5533. retval = titleAttr.appendChild(textNode);
  5534. testNode.normalize();
  5535. value = titleAttr.nodeValue;
  5536. test.equal(value, 'Yesterday', 'attrNodeValue');
  5537. firstChild = titleAttr.firstChild;
  5538. value = firstChild.nodeValue;
  5539. test.equal(value, 'Yesterday', 'firstChildValue');
  5540. secondChild = firstChild.nextSibling;
  5541. test.equal(secondChild, null, 'secondChildIsNull');
  5542. test.done();
  5543. },
  5544. /**
  5545. *
  5546. The "getParentNode()" method for an Attr node should return null. Retrieve
  5547. the attribute named "domestic" from the last child of the first employee
  5548. and examine its parentNode attribute. This test also uses the "getNamedItem(name)"
  5549. method from the NamedNodeMap interface.
  5550. * @author Curt Arnold
  5551. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317
  5552. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  5553. */
  5554. hc_attrparentnodenull: function(test) {
  5555. var success;
  5556. var doc;
  5557. var addressList;
  5558. var testNode;
  5559. var attributes;
  5560. var domesticAttr;
  5561. var s;
  5562. doc = hc_staff.hc_staff();
  5563. addressList = doc.getElementsByTagName("acronym");
  5564. testNode = addressList.item(0);
  5565. attributes = testNode.attributes;
  5566. domesticAttr = attributes.getNamedItem("title");
  5567. s = domesticAttr.parentNode;
  5568. test.equal(s, null, 'attrParentNodeNullAssert');
  5569. test.done();
  5570. },
  5571. /**
  5572. *
  5573. The "getPreviousSibling()" method for an Attr node should return null.
  5574. Retrieve the attribute named "domestic" from the last child of of the
  5575. first employee and examine its PreviousSibling node. This test uses the
  5576. "getNamedItem(name)" method from the NamedNodeMap interface.
  5577. * @author Curt Arnold
  5578. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8
  5579. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  5580. */
  5581. hc_attrprevioussiblingnull: function(test) {
  5582. var success;
  5583. var doc;
  5584. var addressList;
  5585. var testNode;
  5586. var attributes;
  5587. var domesticAttr;
  5588. var s;
  5589. doc = hc_staff.hc_staff();
  5590. addressList = doc.getElementsByTagName("acronym");
  5591. testNode = addressList.item(0);
  5592. attributes = testNode.attributes;
  5593. domesticAttr = attributes.getNamedItem("title");
  5594. s = domesticAttr.previousSibling;
  5595. test.equal(s, null, 'attrPreviousSiblingNullAssert');
  5596. test.done();
  5597. },
  5598. /**
  5599. *
  5600. Removes the child node of an attribute and checks that the value is empty.
  5601. * @author Curt Arnold
  5602. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  5603. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  5604. */
  5605. hc_attrremovechild1: function(test) {
  5606. var success;
  5607. var doc;
  5608. var acronymList;
  5609. var testNode;
  5610. var attributes;
  5611. var titleAttr;
  5612. var value;
  5613. var textNode;
  5614. var retval;
  5615. var firstChild;
  5616. doc = hc_staff.hc_staff();
  5617. acronymList = doc.getElementsByTagName("acronym");
  5618. testNode = acronymList.item(3);
  5619. attributes = testNode.attributes;
  5620. titleAttr = attributes.getNamedItem("title");
  5621. textNode = titleAttr.firstChild;
  5622. test.notEqual(textNode, null, 'attrChildNotNull');
  5623. retval = titleAttr.removeChild(textNode);
  5624. value = titleAttr.value;
  5625. test.equal(value, '', 'attrValue');
  5626. value = titleAttr.nodeValue;
  5627. test.equal(value, '', 'attrNodeValue');
  5628. value = retval.nodeValue;
  5629. test.equal(value, 'Yes', 'retvalValue');
  5630. firstChild = titleAttr.firstChild;
  5631. test.equal(firstChild, null, 'firstChildNull');
  5632. test.done();
  5633. },
  5634. /**
  5635. *
  5636. Attempts to remove a freshly created text node which should result in a NOT_FOUND_ERR exception.
  5637. * @author Curt Arnold
  5638. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  5639. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  5640. */
  5641. hc_attrremovechild2: function(test) {
  5642. var success;
  5643. var doc;
  5644. var acronymList;
  5645. var testNode;
  5646. var attributes;
  5647. var titleAttr;
  5648. var value;
  5649. var textNode;
  5650. var retval;
  5651. doc = hc_staff.hc_staff();
  5652. acronymList = doc.getElementsByTagName("acronym");
  5653. testNode = acronymList.item(3);
  5654. attributes = testNode.attributes;
  5655. titleAttr = attributes.getNamedItem("title");
  5656. textNode = doc.createTextNode("Yesterday");
  5657. {
  5658. success = false;
  5659. try {
  5660. retval = titleAttr.removeChild(textNode);
  5661. }
  5662. catch(ex) {
  5663. success = (typeof(ex.code) != 'undefined' && ex.code == 8);
  5664. }
  5665. test.ok(success, 'throw_NOT_FOUND_ERR');
  5666. }
  5667. test.done();
  5668. },
  5669. /**
  5670. *
  5671. Replaces a text node of an attribute and checks if the value of
  5672. the attribute is changed.
  5673. * @author Curt Arnold
  5674. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  5675. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  5676. */
  5677. hc_attrreplacechild1: function(test) {
  5678. var success;
  5679. var doc;
  5680. var acronymList;
  5681. var testNode;
  5682. var attributes;
  5683. var titleAttr;
  5684. var value;
  5685. var textNode;
  5686. var retval;
  5687. var firstChild;
  5688. doc = hc_staff.hc_staff();
  5689. acronymList = doc.getElementsByTagName("acronym");
  5690. testNode = acronymList.item(3);
  5691. attributes = testNode.attributes;
  5692. titleAttr = attributes.getNamedItem("title");
  5693. textNode = doc.createTextNode("terday");
  5694. firstChild = titleAttr.firstChild;
  5695. test.notEqual(firstChild, null, 'attrChildNotNull');
  5696. retval = titleAttr.replaceChild(textNode,firstChild);
  5697. value = titleAttr.value;
  5698. test.equal(value, 'terday', 'attrValue');
  5699. value = titleAttr.nodeValue;
  5700. test.equal(value, 'terday', 'attrNodeValue');
  5701. value = retval.nodeValue;
  5702. test.equal(value, 'Yes', 'retvalValue');
  5703. firstChild = titleAttr.firstChild;
  5704. value = firstChild.nodeValue;
  5705. test.equal(value, 'terday', 'firstChildValue');
  5706. test.done();
  5707. },
  5708. /**
  5709. *
  5710. Replaces a text node of an attribute with a document fragment and checks if the value of
  5711. the attribute is changed.
  5712. * @author Curt Arnold
  5713. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  5714. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  5715. */
  5716. hc_attrreplacechild2: function(test) {
  5717. var success;
  5718. var doc;
  5719. var acronymList;
  5720. var testNode;
  5721. var attributes;
  5722. var titleAttr;
  5723. var value;
  5724. var terNode;
  5725. var dayNode;
  5726. var docFrag;
  5727. var retval;
  5728. var firstChild;
  5729. doc = hc_staff.hc_staff();
  5730. acronymList = doc.getElementsByTagName("acronym");
  5731. testNode = acronymList.item(3);
  5732. attributes = testNode.attributes;
  5733. titleAttr = attributes.getNamedItem("title");
  5734. terNode = doc.createTextNode("ter");
  5735. dayNode = doc.createTextNode("day");
  5736. docFrag = doc.createDocumentFragment();
  5737. retval = docFrag.appendChild(terNode);
  5738. retval = docFrag.appendChild(dayNode);
  5739. firstChild = titleAttr.firstChild;
  5740. test.notEqual(firstChild, null, 'attrChildNotNull');
  5741. retval = titleAttr.replaceChild(docFrag,firstChild);
  5742. value = titleAttr.value;
  5743. test.equal(value, 'terday', 'attrValue');
  5744. value = titleAttr.nodeValue;
  5745. test.equal(value, 'terday', 'attrNodeValue');
  5746. value = retval.nodeValue;
  5747. test.equal(value, 'Yes', 'retvalValue');
  5748. firstChild = titleAttr.firstChild;
  5749. value = firstChild.nodeValue;
  5750. test.equal(value, 'ter', 'firstChildValue');
  5751. test.done();
  5752. },
  5753. /**
  5754. *
  5755. Sets Attr.value on an attribute that only has a simple value.
  5756. * @author Curt Arnold
  5757. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
  5758. */
  5759. hc_attrsetvalue1: function(test) {
  5760. var success;
  5761. var doc;
  5762. var acronymList;
  5763. var testNode;
  5764. var attributes;
  5765. var titleAttr;
  5766. var value;
  5767. var retval;
  5768. var firstChild;
  5769. var otherChild;
  5770. doc = hc_staff.hc_staff();
  5771. acronymList = doc.getElementsByTagName("acronym");
  5772. testNode = acronymList.item(3);
  5773. attributes = testNode.attributes;
  5774. titleAttr = attributes.getNamedItem("title");
  5775. firstChild = titleAttr.firstChild;
  5776. test.notEqual(firstChild, null, 'attrChildNotNull');
  5777. titleAttr.value = "Tomorrow";
  5778. firstChild.nodeValue = "impl reused node";
  5779. value = titleAttr.value;
  5780. test.equal(value, 'Tomorrow', 'attrValue');
  5781. value = titleAttr.nodeValue;
  5782. test.equal(value, 'Tomorrow', 'attrNodeValue');
  5783. firstChild = titleAttr.lastChild;
  5784. value = firstChild.nodeValue;
  5785. test.equal(value, 'Tomorrow', 'firstChildValue');
  5786. otherChild = firstChild.nextSibling;
  5787. test.equal(otherChild, null, 'nextSiblingIsNull');
  5788. test.done();
  5789. },
  5790. /**
  5791. *
  5792. Sets Attr.value on an attribute that should contain multiple child nodes.
  5793. * @author Curt Arnold
  5794. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-221662474
  5795. */
  5796. hc_attrsetvalue2: function(test) {
  5797. var success;
  5798. var doc;
  5799. var acronymList;
  5800. var testNode;
  5801. var attributes;
  5802. var titleAttr;
  5803. var value;
  5804. var textNode;
  5805. var retval;
  5806. var firstChild;
  5807. var otherChild;
  5808. doc = hc_staff.hc_staff();
  5809. acronymList = doc.getElementsByTagName("acronym");
  5810. testNode = acronymList.item(3);
  5811. attributes = testNode.attributes;
  5812. titleAttr = attributes.getNamedItem("title");
  5813. textNode = doc.createTextNode("terday");
  5814. retval = titleAttr.appendChild(textNode);
  5815. firstChild = titleAttr.firstChild;
  5816. test.notEqual(firstChild, null, 'attrChildNotNull');
  5817. titleAttr.value = "Tomorrow";
  5818. firstChild.nodeValue = "impl reused node";
  5819. value = titleAttr.value;
  5820. test.equal(value, 'Tomorrow', 'attrValue');
  5821. value = titleAttr.nodeValue;
  5822. test.equal(value, 'Tomorrow', 'attrNodeValue');
  5823. firstChild = titleAttr.lastChild;
  5824. value = firstChild.nodeValue;
  5825. test.equal(value, 'Tomorrow', 'firstChildValue');
  5826. otherChild = firstChild.nextSibling;
  5827. test.equal(otherChild, null, 'nextSiblingIsNull');
  5828. test.done();
  5829. },
  5830. /**
  5831. *
  5832. The "getSpecified()" method for an Attr node should
  5833. be set to true if the attribute was explicitly given
  5834. a value.
  5835. Retrieve the attribute named "domestic" from the last
  5836. child of of the first employee and examine the value
  5837. returned by the "getSpecified()" method. This test uses
  5838. the "getNamedItem(name)" method from the NamedNodeMap
  5839. interface.
  5840. * @author Curt Arnold
  5841. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-862529273
  5842. */
  5843. hc_attrspecifiedvalue: function(test) {
  5844. var success;
  5845. var doc;
  5846. var addressList;
  5847. var testNode;
  5848. var attributes;
  5849. var domesticAttr;
  5850. var state;
  5851. doc = hc_staff.hc_staff();
  5852. addressList = doc.getElementsByTagName("acronym");
  5853. testNode = addressList.item(0);
  5854. attributes = testNode.attributes;
  5855. domesticAttr = attributes.getNamedItem("title");
  5856. state = domesticAttr.specified;
  5857. test.ok(state, 'acronymTitleSpecified');
  5858. test.done();
  5859. },
  5860. /**
  5861. *
  5862. The "getSpecified()" method for an Attr node should return true if the
  5863. value of the attribute is changed.
  5864. Retrieve the attribute named "class" from the last
  5865. child of of the THIRD employee and change its
  5866. value to "Yes"(which is the default DTD value). This
  5867. should cause the "getSpecified()" method to be true.
  5868. This test uses the "setAttribute(name,value)" method
  5869. from the Element interface and the "getNamedItem(name)"
  5870. method from the NamedNodeMap interface.
  5871. * @author Curt Arnold
  5872. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-862529273
  5873. */
  5874. hc_attrspecifiedvaluechanged: function(test) {
  5875. var success;
  5876. var doc;
  5877. var addressList;
  5878. var testNode;
  5879. var attributes;
  5880. var streetAttr;
  5881. var state;
  5882. doc = hc_staff.hc_staff();
  5883. addressList = doc.getElementsByTagName("acronym");
  5884. testNode = addressList.item(2);
  5885. testNode.setAttribute("class","Yα");
  5886. attributes = testNode.attributes;
  5887. streetAttr = attributes.getNamedItem("class");
  5888. state = streetAttr.specified;
  5889. test.ok(state, 'acronymClassSpecified');
  5890. test.done();
  5891. },
  5892. /**
  5893. *
  5894. The "appendData(arg)" method appends a string to the end
  5895. of the character data of the node.
  5896. Retrieve the character data from the second child
  5897. of the first employee. The appendData(arg) method is
  5898. called with arg=", Esquire". The method should append
  5899. the specified data to the already existing character
  5900. data. The new value return by the "getLength()" method
  5901. should be 24.
  5902. * @author Curt Arnold
  5903. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  5904. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F
  5905. */
  5906. hc_characterdataappenddata: function(test) {
  5907. var success;
  5908. var doc;
  5909. var elementList;
  5910. var nameNode;
  5911. var child;
  5912. var childValue;
  5913. var childLength;
  5914. doc = hc_staff.hc_staff();
  5915. elementList = doc.getElementsByTagName("strong");
  5916. nameNode = elementList.item(0);
  5917. child = nameNode.firstChild;
  5918. child.appendData(", Esquire");
  5919. childValue = child.data;
  5920. childLength = childValue.length;
  5921. test.equal(childLength, 24, 'characterdataAppendDataAssert');
  5922. test.done();
  5923. },
  5924. /**
  5925. *
  5926. On successful invocation of the "appendData(arg)"
  5927. method the "getData()" method provides access to the
  5928. concatentation of data and the specified string.
  5929. Retrieve the character data from the second child
  5930. of the first employee. The appendData(arg) method is
  5931. called with arg=", Esquire". The method should append
  5932. the specified data to the already existing character
  5933. data. The new value return by the "getData()" method
  5934. should be "Margaret Martin, Esquire".
  5935. * @author Curt Arnold
  5936. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  5937. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-32791A2F
  5938. */
  5939. hc_characterdataappenddatagetdata: function(test) {
  5940. var success;
  5941. var doc;
  5942. var elementList;
  5943. var nameNode;
  5944. var child;
  5945. var childData;
  5946. doc = hc_staff.hc_staff();
  5947. elementList = doc.getElementsByTagName("strong");
  5948. nameNode = elementList.item(0);
  5949. child = nameNode.firstChild;
  5950. child.appendData(", Esquire");
  5951. childData = child.data;
  5952. test.equal(childData, 'Margaret Martin, Esquire', 'characterdataAppendDataGetDataAssert');
  5953. test.done();
  5954. },
  5955. /**
  5956. *
  5957. The "deleteData(offset,count)" method removes a range of
  5958. characters from the node. Delete data at the beginning
  5959. of the character data.
  5960. Retrieve the character data from the last child of the
  5961. first employee. The "deleteData(offset,count)"
  5962. method is then called with offset=0 and count=16.
  5963. The method should delete the characters from position
  5964. 0 thru position 16. The new value of the character data
  5965. should be "Dallas, Texas 98551".
  5966. * @author Curt Arnold
  5967. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  5968. */
  5969. hc_characterdatadeletedatabegining: function(test) {
  5970. var success;
  5971. var doc;
  5972. var elementList;
  5973. var nameNode;
  5974. var child;
  5975. var childData;
  5976. doc = hc_staff.hc_staff();
  5977. elementList = doc.getElementsByTagName("acronym");
  5978. nameNode = elementList.item(0);
  5979. child = nameNode.firstChild;
  5980. child.deleteData(0,16);
  5981. childData = child.data;
  5982. test.equal(childData, 'Dallas, Texas 98551', 'data');
  5983. test.done();
  5984. },
  5985. /**
  5986. *
  5987. The "deleteData(offset,count)" method removes a range of
  5988. characters from the node. Delete data at the end
  5989. of the character data.
  5990. Retrieve the character data from the last child of the
  5991. first employee. The "deleteData(offset,count)"
  5992. method is then called with offset=30 and count=5.
  5993. The method should delete the characters from position
  5994. 30 thru position 35. The new value of the character data
  5995. should be "1230 North Ave. Dallas, Texas".
  5996. * @author Curt Arnold
  5997. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  5998. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  5999. */
  6000. hc_characterdatadeletedataend: function(test) {
  6001. var success;
  6002. var doc;
  6003. var elementList;
  6004. var nameNode;
  6005. var child;
  6006. var childData;
  6007. doc = hc_staff.hc_staff();
  6008. elementList = doc.getElementsByTagName("acronym");
  6009. nameNode = elementList.item(0);
  6010. child = nameNode.firstChild;
  6011. child.deleteData(30,5);
  6012. childData = child.data;
  6013. test.equal(childData, '1230 North Ave. Dallas, Texas ', 'characterdataDeleteDataEndAssert');
  6014. test.done();
  6015. },
  6016. /**
  6017. *
  6018. If the sum of the offset and count used in the
  6019. "deleteData(offset,count) method is greater than the
  6020. length of the character data then all the characters
  6021. from the offset to the end of the data are deleted.
  6022. Retrieve the character data from the last child of the
  6023. first employee. The "deleteData(offset,count)"
  6024. method is then called with offset=4 and count=50.
  6025. The method should delete the characters from position 4
  6026. to the end of the data since the offset+count(50+4)
  6027. is greater than the length of the character data(35).
  6028. The new value of the character data should be "1230".
  6029. * @author Curt Arnold
  6030. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  6031. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  6032. */
  6033. hc_characterdatadeletedataexceedslength: function(test) {
  6034. var success;
  6035. var doc;
  6036. var elementList;
  6037. var nameNode;
  6038. var child;
  6039. var childData;
  6040. doc = hc_staff.hc_staff();
  6041. elementList = doc.getElementsByTagName("acronym");
  6042. nameNode = elementList.item(0);
  6043. child = nameNode.firstChild;
  6044. child.deleteData(4,50);
  6045. childData = child.data;
  6046. test.equal(childData, '1230', 'characterdataDeleteDataExceedsLengthAssert');
  6047. test.done();
  6048. },
  6049. /**
  6050. *
  6051. On successful invocation of the "deleteData(offset,count)"
  6052. method, the "getData()" and "getLength()" methods reflect
  6053. the changes.
  6054. Retrieve the character data from the last child of the
  6055. first employee. The "deleteData(offset,count)"
  6056. method is then called with offset=30 and count=5.
  6057. The method should delete the characters from position
  6058. 30 thru position 35. The new value of the character data
  6059. should be "1230 North Ave. Dallas, Texas" which is
  6060. returned by the "getData()" method and "getLength()"
  6061. method should return 30".
  6062. * @author Curt Arnold
  6063. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  6064. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7D61178C
  6065. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  6066. */
  6067. hc_characterdatadeletedatagetlengthanddata: function(test) {
  6068. var success;
  6069. var doc;
  6070. var elementList;
  6071. var nameNode;
  6072. var child;
  6073. var childData;
  6074. var childLength;
  6075. var result = new Array();
  6076. doc = hc_staff.hc_staff();
  6077. elementList = doc.getElementsByTagName("acronym");
  6078. nameNode = elementList.item(0);
  6079. child = nameNode.firstChild;
  6080. child.deleteData(30,5);
  6081. childData = child.data;
  6082. test.equal(childData, '1230 North Ave. Dallas, Texas ', 'data');
  6083. childLength = child.length;
  6084. test.equal(childLength, 30, 'length');
  6085. test.done();
  6086. },
  6087. /**
  6088. *
  6089. The "deleteData(offset,count)" method removes a range of
  6090. characters from the node. Delete data in the middle
  6091. of the character data.
  6092. Retrieve the character data from the last child of the
  6093. first employee. The "deleteData(offset,count)"
  6094. method is then called with offset=16 and count=8.
  6095. The method should delete the characters from position
  6096. 16 thru position 24. The new value of the character data
  6097. should be "1230 North Ave. Texas 98551".
  6098. * @author Curt Arnold
  6099. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  6100. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  6101. */
  6102. hc_characterdatadeletedatamiddle: function(test) {
  6103. var success;
  6104. var doc;
  6105. var elementList;
  6106. var nameNode;
  6107. var child;
  6108. var childData;
  6109. doc = hc_staff.hc_staff();
  6110. elementList = doc.getElementsByTagName("acronym");
  6111. nameNode = elementList.item(0);
  6112. child = nameNode.firstChild;
  6113. child.deleteData(16,8);
  6114. childData = child.data;
  6115. test.equal(childData, '1230 North Ave. Texas 98551', 'characterdataDeleteDataMiddleAssert');
  6116. test.done();
  6117. },
  6118. /**
  6119. *
  6120. The "getData()" method retrieves the character data
  6121. currently stored in the node.
  6122. Retrieve the character data from the second child
  6123. of the first employee and invoke the "getData()"
  6124. method. The method returns the character data
  6125. string.
  6126. * @author Curt Arnold
  6127. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  6128. */
  6129. hc_characterdatagetdata: function(test) {
  6130. var success;
  6131. var doc;
  6132. var elementList;
  6133. var nameNode;
  6134. var child;
  6135. var childData;
  6136. doc = hc_staff.hc_staff();
  6137. elementList = doc.getElementsByTagName("strong");
  6138. nameNode = elementList.item(0);
  6139. child = nameNode.firstChild;
  6140. childData = child.data;
  6141. test.equal(childData, 'Margaret Martin', 'characterdataGetDataAssert');
  6142. test.done();
  6143. },
  6144. /**
  6145. *
  6146. The "getLength()" method returns the number of characters
  6147. stored in this nodes data.
  6148. Retrieve the character data from the second
  6149. child of the first employee and examine the
  6150. value returned by the getLength() method.
  6151. * @author Curt Arnold
  6152. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  6153. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7D61178C
  6154. */
  6155. hc_characterdatagetlength: function(test) {
  6156. var success;
  6157. var doc;
  6158. var elementList;
  6159. var nameNode;
  6160. var child;
  6161. var childValue;
  6162. var childLength;
  6163. doc = hc_staff.hc_staff();
  6164. elementList = doc.getElementsByTagName("strong");
  6165. nameNode = elementList.item(0);
  6166. child = nameNode.firstChild;
  6167. childValue = child.data;
  6168. childLength = childValue.length;
  6169. test.equal(childLength, 15, 'characterdataGetLengthAssert');
  6170. test.done();
  6171. },
  6172. /**
  6173. *
  6174. The "deleteData(offset,count)" method raises an
  6175. INDEX_SIZE_ERR DOMException if the specified count
  6176. is negative.
  6177. Retrieve the character data of the last child of the
  6178. first employee and invoke its "deleteData(offset,count)"
  6179. method with offset=10 and count=-3. It should raise the
  6180. desired exception since the count is negative.
  6181. * @author Curt Arnold
  6182. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  6183. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  6184. * @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'])
  6185. */
  6186. hc_characterdataindexsizeerrdeletedatacountnegative: function(test) {
  6187. var success;
  6188. var doc;
  6189. var elementList;
  6190. var nameNode;
  6191. var child;
  6192. var childSubstring;
  6193. doc = hc_staff.hc_staff();
  6194. elementList = doc.getElementsByTagName("acronym");
  6195. nameNode = elementList.item(0);
  6196. child = nameNode.firstChild;
  6197. {
  6198. success = false;
  6199. try {
  6200. childSubstring = child.substringData(10,-3);
  6201. }
  6202. catch(ex) {
  6203. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  6204. }
  6205. test.ok(success, 'throws_INDEX_SIZE_ERR');
  6206. }
  6207. test.done();
  6208. },
  6209. /**
  6210. *
  6211. The "deleteData(offset,count)" method raises an
  6212. INDEX_SIZE_ERR DOMException if the specified offset
  6213. is greater that the number of characters in the string.
  6214. Retrieve the character data of the last child of the
  6215. first employee and invoke its "deleteData(offset,count)"
  6216. method with offset=40 and count=3. It should raise the
  6217. desired exception since the offset is greater than the
  6218. number of characters in the string.
  6219. * @author Curt Arnold
  6220. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  6221. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  6222. * @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'])
  6223. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  6224. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  6225. */
  6226. hc_characterdataindexsizeerrdeletedataoffsetgreater: function(test) {
  6227. var success;
  6228. var doc;
  6229. var elementList;
  6230. var nameNode;
  6231. var child;
  6232. doc = hc_staff.hc_staff();
  6233. elementList = doc.getElementsByTagName("acronym");
  6234. nameNode = elementList.item(0);
  6235. child = nameNode.firstChild;
  6236. {
  6237. success = false;
  6238. try {
  6239. child.deleteData(40,3);
  6240. }
  6241. catch(ex) {
  6242. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  6243. }
  6244. test.ok(success, 'throw_INDEX_SIZE_ERR');
  6245. }
  6246. test.done();
  6247. },
  6248. /**
  6249. *
  6250. The "deleteData(offset,count)" method raises an
  6251. INDEX_SIZE_ERR DOMException if the specified offset
  6252. is negative.
  6253. Retrieve the character data of the last child of the
  6254. first employee and invoke its "deleteData(offset,count)"
  6255. method with offset=-5 and count=3. It should raise the
  6256. desired exception since the offset is negative.
  6257. * @author Curt Arnold
  6258. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  6259. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  6260. * @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'])
  6261. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  6262. */
  6263. hc_characterdataindexsizeerrdeletedataoffsetnegative: function(test) {
  6264. var success;
  6265. var doc;
  6266. var elementList;
  6267. var nameNode;
  6268. var child;
  6269. doc = hc_staff.hc_staff();
  6270. elementList = doc.getElementsByTagName("acronym");
  6271. nameNode = elementList.item(0);
  6272. child = nameNode.firstChild;
  6273. {
  6274. success = false;
  6275. try {
  6276. child.deleteData(-5,3);
  6277. }
  6278. catch(ex) {
  6279. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  6280. }
  6281. test.ok(success, 'throws_INDEX_SIZE_ERR');
  6282. }
  6283. test.done();
  6284. },
  6285. /**
  6286. *
  6287. The "insertData(offset,arg)" method raises an
  6288. INDEX_SIZE_ERR DOMException if the specified offset
  6289. is greater than the number of characters in the string.
  6290. Retrieve the character data of the last child of the
  6291. first employee and invoke its insertData"(offset,arg)"
  6292. method with offset=40 and arg="ABC". It should raise
  6293. the desired exception since the offset is greater than
  6294. the number of characters in the string.
  6295. * @author Curt Arnold
  6296. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  6297. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  6298. * @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'])
  6299. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  6300. */
  6301. hc_characterdataindexsizeerrinsertdataoffsetgreater: function(test) {
  6302. var success;
  6303. var doc;
  6304. var elementList;
  6305. var nameNode;
  6306. var child;
  6307. doc = hc_staff.hc_staff();
  6308. elementList = doc.getElementsByTagName("acronym");
  6309. nameNode = elementList.item(0);
  6310. child = nameNode.firstChild;
  6311. {
  6312. success = false;
  6313. try {
  6314. child.deleteData(40,3);
  6315. }
  6316. catch(ex) {
  6317. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  6318. }
  6319. test.ok(success, 'throw_INDEX_SIZE_ERR');
  6320. }
  6321. test.done();
  6322. },
  6323. /**
  6324. *
  6325. The "insertData(offset,arg)" method raises an
  6326. INDEX_SIZE_ERR DOMException if the specified offset
  6327. is negative.
  6328. Retrieve the character data of the last child of the
  6329. first employee and invoke its insertData"(offset,arg)"
  6330. method with offset=-5 and arg="ABC". It should raise
  6331. the desired exception since the offset is negative.
  6332. * @author Curt Arnold
  6333. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  6334. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  6335. * @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'])
  6336. */
  6337. hc_characterdataindexsizeerrinsertdataoffsetnegative: function(test) {
  6338. var success;
  6339. var doc;
  6340. var elementList;
  6341. var nameNode;
  6342. var child;
  6343. doc = hc_staff.hc_staff();
  6344. elementList = doc.getElementsByTagName("acronym");
  6345. nameNode = elementList.item(0);
  6346. child = nameNode.firstChild;
  6347. {
  6348. success = false;
  6349. try {
  6350. child.replaceData(-5,3,"ABC");
  6351. }
  6352. catch(ex) {
  6353. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  6354. }
  6355. test.ok(success, 'throws_INDEX_SIZE_ERR');
  6356. }
  6357. test.done();
  6358. },
  6359. /**
  6360. *
  6361. The "replaceData(offset,count,arg)" method raises an
  6362. INDEX_SIZE_ERR DOMException if the specified count
  6363. is negative.
  6364. Retrieve the character data of the last child of the
  6365. first employee and invoke its
  6366. "replaceData(offset,count,arg) method with offset=10
  6367. and count=-3 and arg="ABC". It should raise the
  6368. desired exception since the count is negative.
  6369. * @author Curt Arnold
  6370. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  6371. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  6372. * @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'])
  6373. */
  6374. hc_characterdataindexsizeerrreplacedatacountnegative: function(test) {
  6375. var success;
  6376. var doc;
  6377. var elementList;
  6378. var nameNode;
  6379. var child;
  6380. var badString;
  6381. doc = hc_staff.hc_staff();
  6382. elementList = doc.getElementsByTagName("acronym");
  6383. nameNode = elementList.item(0);
  6384. child = nameNode.firstChild;
  6385. {
  6386. success = false;
  6387. try {
  6388. badString = child.substringData(10,-3);
  6389. }
  6390. catch(ex) {
  6391. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  6392. }
  6393. test.ok(success, 'throws_INDEX_SIZE_ERR');
  6394. }
  6395. test.done();
  6396. },
  6397. /**
  6398. *
  6399. The "replaceData(offset,count,arg)" method raises an
  6400. INDEX_SIZE_ERR DOMException if the specified offset
  6401. is greater than the length of the string.
  6402. Retrieve the character data of the last child of the
  6403. first employee and invoke its
  6404. "replaceData(offset,count,arg) method with offset=40
  6405. and count=3 and arg="ABC". It should raise the
  6406. desired exception since the offset is greater than the
  6407. length of the string.
  6408. * @author Curt Arnold
  6409. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  6410. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-7C603781
  6411. * @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'])
  6412. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=242
  6413. */
  6414. hc_characterdataindexsizeerrreplacedataoffsetgreater: function(test) {
  6415. var success;
  6416. var doc;
  6417. var elementList;
  6418. var nameNode;
  6419. var child;
  6420. doc = hc_staff.hc_staff();
  6421. elementList = doc.getElementsByTagName("acronym");
  6422. nameNode = elementList.item(0);
  6423. child = nameNode.firstChild;
  6424. {
  6425. success = false;
  6426. try {
  6427. child.deleteData(40,3);
  6428. }
  6429. catch(ex) {
  6430. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  6431. }
  6432. test.ok(success, 'throw_INDEX_SIZE_ERR');
  6433. }
  6434. test.done();
  6435. },
  6436. /**
  6437. *
  6438. The "replaceData(offset,count,arg)" method raises an
  6439. INDEX_SIZE_ERR DOMException if the specified offset
  6440. is negative.
  6441. Retrieve the character data of the last child of the
  6442. first employee and invoke its
  6443. "replaceData(offset,count,arg) method with offset=-5
  6444. and count=3 and arg="ABC". It should raise the
  6445. desired exception since the offset is negative.
  6446. * @author Curt Arnold
  6447. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  6448. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  6449. * @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'])
  6450. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  6451. */
  6452. hc_characterdataindexsizeerrreplacedataoffsetnegative: function(test) {
  6453. var success;
  6454. var doc;
  6455. var elementList;
  6456. var nameNode;
  6457. var child;
  6458. doc = hc_staff.hc_staff();
  6459. elementList = doc.getElementsByTagName("acronym");
  6460. nameNode = elementList.item(0);
  6461. child = nameNode.firstChild;
  6462. {
  6463. success = false;
  6464. try {
  6465. child.replaceData(-5,3,"ABC");
  6466. }
  6467. catch(ex) {
  6468. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  6469. }
  6470. test.ok(success, 'throws_INDEX_SIZE_ERR');
  6471. }
  6472. test.done();
  6473. },
  6474. /**
  6475. *
  6476. The "substringData(offset,count)" method raises an
  6477. INDEX_SIZE_ERR DOMException if the specified count
  6478. is negative.
  6479. Retrieve the character data of the last child of the
  6480. first employee and invoke its "substringData(offset,count)
  6481. method with offset=10 and count=-3. It should raise the
  6482. desired exception since the count is negative.
  6483. * @author Curt Arnold
  6484. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  6485. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  6486. * @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'])
  6487. */
  6488. hc_characterdataindexsizeerrsubstringcountnegative: function(test) {
  6489. var success;
  6490. var doc;
  6491. var elementList;
  6492. var nameNode;
  6493. var child;
  6494. var badSubstring;
  6495. doc = hc_staff.hc_staff();
  6496. elementList = doc.getElementsByTagName("acronym");
  6497. nameNode = elementList.item(0);
  6498. child = nameNode.firstChild;
  6499. {
  6500. success = false;
  6501. try {
  6502. badSubstring = child.substringData(10,-3);
  6503. }
  6504. catch(ex) {
  6505. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  6506. }
  6507. test.ok(success, 'throws_INDEX_SIZE_ERR');
  6508. }
  6509. test.done();
  6510. },
  6511. /**
  6512. *
  6513. The "substringData(offset,count)" method raises an
  6514. INDEX_SIZE_ERR DOMException if the specified offset
  6515. is negative.
  6516. Retrieve the character data of the last child of the
  6517. first employee and invoke its "substringData(offset,count)
  6518. method with offset=-5 and count=3. It should raise the
  6519. desired exception since the offset is negative.
  6520. * @author Curt Arnold
  6521. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  6522. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  6523. * @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'])
  6524. */
  6525. hc_characterdataindexsizeerrsubstringnegativeoffset: function(test) {
  6526. var success;
  6527. var doc;
  6528. var elementList;
  6529. var nameNode;
  6530. var child;
  6531. var badString;
  6532. doc = hc_staff.hc_staff();
  6533. elementList = doc.getElementsByTagName("acronym");
  6534. nameNode = elementList.item(0);
  6535. child = nameNode.firstChild;
  6536. {
  6537. success = false;
  6538. try {
  6539. badString = child.substringData(-5,3);
  6540. }
  6541. catch(ex) {
  6542. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  6543. }
  6544. test.ok(success, 'throws_INDEX_SIZE_ERR');
  6545. }
  6546. test.done();
  6547. },
  6548. /**
  6549. *
  6550. The "substringData(offset,count)" method raises an
  6551. INDEX_SIZE_ERR DOMException if the specified offset
  6552. is greater than the number of characters in the string.
  6553. Retrieve the character data of the last child of the
  6554. first employee and invoke its "substringData(offset,count)
  6555. method with offset=40 and count=3. It should raise the
  6556. desired exception since the offsets value is greater
  6557. than the length.
  6558. * @author Curt Arnold
  6559. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  6560. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  6561. * @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'])
  6562. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  6563. */
  6564. hc_characterdataindexsizeerrsubstringoffsetgreater: function(test) {
  6565. var success;
  6566. var doc;
  6567. var elementList;
  6568. var nameNode;
  6569. var child;
  6570. var badString;
  6571. doc = hc_staff.hc_staff();
  6572. elementList = doc.getElementsByTagName("acronym");
  6573. nameNode = elementList.item(0);
  6574. child = nameNode.firstChild;
  6575. {
  6576. success = false;
  6577. try {
  6578. badString = child.substringData(40,3);
  6579. }
  6580. catch(ex) {
  6581. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  6582. }
  6583. test.ok(success, 'throw_INDEX_SIZE_ERR');
  6584. }
  6585. test.done();
  6586. },
  6587. /**
  6588. *
  6589. The "insertData(offset,arg)" method will insert a string
  6590. at the specified character offset. Insert the data at
  6591. the beginning of the character data.
  6592. Retrieve the character data from the second child of
  6593. the first employee. The "insertData(offset,arg)"
  6594. method is then called with offset=0 and arg="Mss.".
  6595. The method should insert the string "Mss." at position 0.
  6596. The new value of the character data should be
  6597. "Mss. Margaret Martin".
  6598. * @author Curt Arnold
  6599. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F
  6600. */
  6601. hc_characterdatainsertdatabeginning: function(test) {
  6602. var success;
  6603. var doc;
  6604. var elementList;
  6605. var nameNode;
  6606. var child;
  6607. var childData;
  6608. doc = hc_staff.hc_staff();
  6609. elementList = doc.getElementsByTagName("strong");
  6610. nameNode = elementList.item(0);
  6611. child = nameNode.firstChild;
  6612. child.insertData(0,"Mss. ");
  6613. childData = child.data;
  6614. test.equal(childData, 'Mss. Margaret Martin', 'characterdataInsertDataBeginningAssert');
  6615. test.done();
  6616. },
  6617. /**
  6618. *
  6619. The "insertData(offset,arg)" method will insert a string
  6620. at the specified character offset. Insert the data at
  6621. the end of the character data.
  6622. Retrieve the character data from the second child of
  6623. the first employee. The "insertData(offset,arg)"
  6624. method is then called with offset=15 and arg=", Esquire".
  6625. The method should insert the string ", Esquire" at
  6626. position 15. The new value of the character data should
  6627. be "Margaret Martin, Esquire".
  6628. * @author Curt Arnold
  6629. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  6630. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F
  6631. */
  6632. hc_characterdatainsertdataend: function(test) {
  6633. var success;
  6634. var doc;
  6635. var elementList;
  6636. var nameNode;
  6637. var child;
  6638. var childData;
  6639. doc = hc_staff.hc_staff();
  6640. elementList = doc.getElementsByTagName("strong");
  6641. nameNode = elementList.item(0);
  6642. child = nameNode.firstChild;
  6643. child.insertData(15,", Esquire");
  6644. childData = child.data;
  6645. test.equal(childData, 'Margaret Martin, Esquire', 'characterdataInsertDataEndAssert');
  6646. test.done();
  6647. },
  6648. /**
  6649. *
  6650. The "insertData(offset,arg)" method will insert a string
  6651. at the specified character offset. Insert the data in
  6652. the middle of the character data.
  6653. Retrieve the character data from the second child of
  6654. the first employee. The "insertData(offset,arg)"
  6655. method is then called with offset=9 and arg="Ann".
  6656. The method should insert the string "Ann" at position 9.
  6657. The new value of the character data should be
  6658. "Margaret Ann Martin".
  6659. * @author Curt Arnold
  6660. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  6661. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3EDB695F
  6662. */
  6663. hc_characterdatainsertdatamiddle: function(test) {
  6664. var success;
  6665. var doc;
  6666. var elementList;
  6667. var nameNode;
  6668. var child;
  6669. var childData;
  6670. doc = hc_staff.hc_staff();
  6671. elementList = doc.getElementsByTagName("strong");
  6672. nameNode = elementList.item(0);
  6673. child = nameNode.firstChild;
  6674. child.insertData(9,"Ann ");
  6675. childData = child.data;
  6676. test.equal(childData, 'Margaret Ann Martin', 'characterdataInsertDataMiddleAssert');
  6677. test.done();
  6678. },
  6679. /**
  6680. *
  6681. The "replaceData(offset,count,arg)" method replaces the
  6682. characters starting at the specified offset with the
  6683. specified string. Test for replacement in the
  6684. middle of the data.
  6685. Retrieve the character data from the last child of the
  6686. first employee. The "replaceData(offset,count,arg)"
  6687. method is then called with offset=5 and count=5 and
  6688. arg="South". The method should replace characters five
  6689. thru 9 of the character data with "South".
  6690. * @author Curt Arnold
  6691. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  6692. */
  6693. hc_characterdatareplacedatabegining: function(test) {
  6694. var success;
  6695. var doc;
  6696. var elementList;
  6697. var nameNode;
  6698. var child;
  6699. var childData;
  6700. doc = hc_staff.hc_staff();
  6701. elementList = doc.getElementsByTagName("acronym");
  6702. nameNode = elementList.item(0);
  6703. child = nameNode.firstChild;
  6704. child.replaceData(0,4,"2500");
  6705. childData = child.data;
  6706. test.equal(childData, '2500 North Ave. Dallas, Texas 98551', 'characterdataReplaceDataBeginingAssert');
  6707. test.done();
  6708. },
  6709. /**
  6710. *
  6711. The "replaceData(offset,count,arg)" method replaces the
  6712. characters starting at the specified offset with the
  6713. specified string. Test for replacement at the
  6714. end of the data.
  6715. Retrieve the character data from the last child of the
  6716. first employee. The "replaceData(offset,count,arg)"
  6717. method is then called with offset=30 and count=5 and
  6718. arg="98665". The method should replace characters 30
  6719. thru 34 of the character data with "98665".
  6720. * @author Curt Arnold
  6721. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  6722. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  6723. */
  6724. hc_characterdatareplacedataend: function(test) {
  6725. var success;
  6726. var doc;
  6727. var elementList;
  6728. var nameNode;
  6729. var child;
  6730. var childData;
  6731. doc = hc_staff.hc_staff();
  6732. elementList = doc.getElementsByTagName("acronym");
  6733. nameNode = elementList.item(0);
  6734. child = nameNode.firstChild;
  6735. child.replaceData(30,5,"98665");
  6736. childData = child.data;
  6737. test.equal(childData, '1230 North Ave. Dallas, Texas 98665', 'characterdataReplaceDataEndAssert');
  6738. test.done();
  6739. },
  6740. /**
  6741. *
  6742. The "replaceData(offset,count,arg)" method replaces the
  6743. characters starting at the specified offset with the
  6744. specified string. Test the situation where the length
  6745. of the arg string is greater than the specified offset.
  6746. Retrieve the character data from the last child of the
  6747. first employee. The "replaceData(offset,count,arg)"
  6748. method is then called with offset=0 and count=4 and
  6749. arg="260030". The method should replace characters one
  6750. thru four with "260030". Note that the length of the
  6751. specified string is greater that the specified offset.
  6752. * @author Curt Arnold
  6753. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  6754. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  6755. */
  6756. hc_characterdatareplacedataexceedslengthofarg: function(test) {
  6757. var success;
  6758. var doc;
  6759. var elementList;
  6760. var nameNode;
  6761. var child;
  6762. var childData;
  6763. doc = hc_staff.hc_staff();
  6764. elementList = doc.getElementsByTagName("acronym");
  6765. nameNode = elementList.item(0);
  6766. child = nameNode.firstChild;
  6767. child.replaceData(0,4,"260030");
  6768. childData = child.data;
  6769. test.equal(childData, '260030 North Ave. Dallas, Texas 98551', 'characterdataReplaceDataExceedsLengthOfArgAssert');
  6770. test.done();
  6771. },
  6772. /**
  6773. *
  6774. If the sum of the offset and count exceeds the length then
  6775. all the characters to the end of the data are replaced.
  6776. Retrieve the character data from the last child of the
  6777. first employee. The "replaceData(offset,count,arg)"
  6778. method is then called with offset=0 and count=50 and
  6779. arg="2600". The method should replace all the characters
  6780. with "2600". This is because the sum of the offset and
  6781. count exceeds the length of the character data.
  6782. * @author Curt Arnold
  6783. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  6784. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  6785. */
  6786. hc_characterdatareplacedataexceedslengthofdata: function(test) {
  6787. var success;
  6788. var doc;
  6789. var elementList;
  6790. var nameNode;
  6791. var child;
  6792. var childData;
  6793. doc = hc_staff.hc_staff();
  6794. elementList = doc.getElementsByTagName("acronym");
  6795. nameNode = elementList.item(0);
  6796. child = nameNode.firstChild;
  6797. child.replaceData(0,50,"2600");
  6798. childData = child.data;
  6799. test.equal(childData, '2600', 'characterdataReplaceDataExceedsLengthOfDataAssert');
  6800. test.done();
  6801. },
  6802. /**
  6803. *
  6804. The "replaceData(offset,count,arg)" method replaces the
  6805. characters starting at the specified offset with the
  6806. specified string. Test for replacement in the
  6807. middle of the data.
  6808. Retrieve the character data from the last child of the
  6809. first employee. The "replaceData(offset,count,arg)"
  6810. method is then called with offset=5 and count=5 and
  6811. arg="South". The method should replace characters five
  6812. thru 9 of the character data with "South".
  6813. * @author Curt Arnold
  6814. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  6815. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E5CBA7FB
  6816. */
  6817. hc_characterdatareplacedatamiddle: function(test) {
  6818. var success;
  6819. var doc;
  6820. var elementList;
  6821. var nameNode;
  6822. var child;
  6823. var childData;
  6824. doc = hc_staff.hc_staff();
  6825. elementList = doc.getElementsByTagName("acronym");
  6826. nameNode = elementList.item(0);
  6827. child = nameNode.firstChild;
  6828. child.replaceData(5,5,"South");
  6829. childData = child.data;
  6830. test.equal(childData, '1230 South Ave. Dallas, Texas 98551', 'characterdataReplaceDataMiddleAssert');
  6831. test.done();
  6832. },
  6833. /**
  6834. *
  6835. The "setNodeValue()" method changes the character data
  6836. currently stored in the node.
  6837. Retrieve the character data from the second child
  6838. of the first employee and invoke the "setNodeValue()"
  6839. method, call "getData()" and compare.
  6840. * @author Curt Arnold
  6841. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-72AB8359
  6842. */
  6843. hc_characterdatasetnodevalue: function(test) {
  6844. var success;
  6845. var doc;
  6846. var elementList;
  6847. var nameNode;
  6848. var child;
  6849. var childData;
  6850. var childValue;
  6851. doc = hc_staff.hc_staff();
  6852. elementList = doc.getElementsByTagName("strong");
  6853. nameNode = elementList.item(0);
  6854. child = nameNode.firstChild;
  6855. child.nodeValue = "Marilyn Martin";
  6856. childData = child.data;
  6857. test.equal(childData, 'Marilyn Martin', 'data');
  6858. childValue = child.nodeValue;
  6859. test.equal(childValue, 'Marilyn Martin', 'value');
  6860. test.done();
  6861. },
  6862. /**
  6863. *
  6864. If the sum of the "offset" and "count" exceeds the
  6865. "length" then the "substringData(offset,count)" method
  6866. returns all the characters to the end of the data.
  6867. Retrieve the character data from the second child
  6868. of the first employee and access part of the data
  6869. by using the substringData(offset,count) method
  6870. with offset=9 and count=10. The method should return
  6871. the substring "Martin" since offset+count > length
  6872. (19 > 15).
  6873. * @author Curt Arnold
  6874. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  6875. */
  6876. hc_characterdatasubstringexceedsvalue: function(test) {
  6877. var success;
  6878. var doc;
  6879. var elementList;
  6880. var nameNode;
  6881. var child;
  6882. var substring;
  6883. doc = hc_staff.hc_staff();
  6884. elementList = doc.getElementsByTagName("strong");
  6885. nameNode = elementList.item(0);
  6886. child = nameNode.firstChild;
  6887. substring = child.substringData(9,10);
  6888. test.equal(substring, 'Martin', 'characterdataSubStringExceedsValueAssert');
  6889. test.done();
  6890. },
  6891. /**
  6892. *
  6893. The "substringData(offset,count)" method returns the
  6894. specified string.
  6895. Retrieve the character data from the second child
  6896. of the first employee and access part of the data
  6897. by using the substringData(offset,count) method. The
  6898. method should return the specified substring starting
  6899. at position "offset" and extract "count" characters.
  6900. The method should return the string "Margaret".
  6901. * @author Curt Arnold
  6902. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6531BCCF
  6903. */
  6904. hc_characterdatasubstringvalue: function(test) {
  6905. var success;
  6906. var doc;
  6907. var elementList;
  6908. var nameNode;
  6909. var child;
  6910. var substring;
  6911. doc = hc_staff.hc_staff();
  6912. elementList = doc.getElementsByTagName("strong");
  6913. nameNode = elementList.item(0);
  6914. child = nameNode.firstChild;
  6915. substring = child.substringData(0,8);
  6916. test.equal(substring, 'Margaret', 'characterdataSubStringValueAssert');
  6917. test.done();
  6918. },
  6919. /**
  6920. *
  6921. A comment is all the characters between the starting
  6922. '<!--' and ending '-->'
  6923. Retrieve the nodes of the DOM document. Search for a
  6924. comment node and the content is its value.
  6925. * @author Curt Arnold
  6926. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1334481328
  6927. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  6928. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  6929. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  6930. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  6931. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=509
  6932. */
  6933. hc_commentgetcomment: function(test) {
  6934. var doc = hc_staff.hc_staff();
  6935. var elementList = doc.childNodes;
  6936. test.expect(3); // the three tests in the for loop should run only once
  6937. for(var i=0;i<elementList.length;i++) {
  6938. if (8 == elementList.item(i).nodeType) {
  6939. test.equal(elementList.item(i).nodeName, '#comment', 'nodeName');
  6940. test.equal(elementList.item(i).nodeValue, ' This is comment number 1.', 'nodeValue');
  6941. test.equal(elementList.item(i).attributes, null, 'attributes');
  6942. }
  6943. }
  6944. test.done();
  6945. },
  6946. /**
  6947. *
  6948. Retrieve the entire DOM document and invoke its
  6949. "createAttribute(name)" method. It should create a
  6950. new Attribute node with the given name. The name, value
  6951. and type of the newly created object are retrieved and
  6952. output.
  6953. * @author Curt Arnold
  6954. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198
  6955. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  6956. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
  6957. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  6958. */
  6959. hc_documentcreateattribute: function(test) {
  6960. var success;
  6961. var doc;
  6962. var newAttrNode;
  6963. var attrValue;
  6964. var attrName;
  6965. var attrType;
  6966. doc = hc_staff.hc_staff();
  6967. newAttrNode = doc.createAttribute("title");
  6968. attrValue = newAttrNode.nodeValue;
  6969. test.equal(attrValue, '', 'value');
  6970. attrName = newAttrNode.nodeName;
  6971. test.equal(attrName, 'title', 'attribute name');
  6972. attrType = newAttrNode.nodeType;
  6973. test.equal(attrType, 2, 'type');
  6974. test.done();
  6975. },
  6976. /**
  6977. *
  6978. The "createComment(data)" method creates a new Comment
  6979. node given the specified string.
  6980. Retrieve the entire DOM document and invoke its
  6981. "createComment(data)" method. It should create a new
  6982. Comment node whose "data" is the specified string.
  6983. The content, name and type are retrieved and output.
  6984. * @author Curt Arnold
  6985. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1334481328
  6986. */
  6987. hc_documentcreatecomment: function(test) {
  6988. var success;
  6989. var doc;
  6990. var newCommentNode;
  6991. var newCommentValue;
  6992. var newCommentName;
  6993. var newCommentType;
  6994. doc = hc_staff.hc_staff();
  6995. newCommentNode = doc.createComment("This is a new Comment node");
  6996. newCommentValue = newCommentNode.nodeValue;
  6997. test.equal(newCommentValue, 'This is a new Comment node', 'value');
  6998. newCommentName = newCommentNode.nodeName;
  6999. test.equal(newCommentName, '#comment', 'strong');
  7000. newCommentType = newCommentNode.nodeType;
  7001. test.equal(newCommentType, 8, 'type');
  7002. test.done();
  7003. },
  7004. /**
  7005. *
  7006. The "createDocumentFragment()" method creates an empty
  7007. DocumentFragment object.
  7008. Retrieve the entire DOM document and invoke its
  7009. "createDocumentFragment()" method. The content, name,
  7010. type and value of the newly created object are output.
  7011. * @author Curt Arnold
  7012. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-35CB04B5
  7013. */
  7014. hc_documentcreatedocumentfragment: function(test) {
  7015. var success;
  7016. var doc;
  7017. var newDocFragment;
  7018. var children;
  7019. var length;
  7020. var newDocFragmentName;
  7021. var newDocFragmentType;
  7022. var newDocFragmentValue;
  7023. doc = hc_staff.hc_staff();
  7024. newDocFragment = doc.createDocumentFragment();
  7025. children = newDocFragment.childNodes;
  7026. length = children.length;
  7027. test.equal(length, 0, 'length');
  7028. newDocFragmentName = newDocFragment.nodeName;
  7029. test.equal(newDocFragmentName, '#document-fragment', 'strong');
  7030. newDocFragmentType = newDocFragment.nodeType;
  7031. test.equal(newDocFragmentType, 11, 'type');
  7032. newDocFragmentValue = newDocFragment.nodeValue;
  7033. test.equal(newDocFragmentValue, null, 'value');
  7034. test.done();
  7035. },
  7036. /**
  7037. *
  7038. The "createElement(tagName)" method creates an Element
  7039. of the type specified.
  7040. Retrieve the entire DOM document and invoke its
  7041. "createElement(tagName)" method with tagName="acronym".
  7042. The method should create an instance of an Element node
  7043. whose tagName is "acronym". The NodeName, NodeType
  7044. and NodeValue are returned.
  7045. * @author Curt Arnold
  7046. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
  7047. */
  7048. hc_documentcreateelement: function(test) {
  7049. var success;
  7050. var doc;
  7051. var newElement;
  7052. var newElementName;
  7053. var newElementType;
  7054. var newElementValue;
  7055. doc = hc_staff.hc_staff();
  7056. newElement = doc.createElement("acronym");
  7057. newElementName = newElement.nodeName;
  7058. test.equal(newElementName, 'acronym', 'element strong');
  7059. newElementType = newElement.nodeType;
  7060. test.equal(newElementType, 1, 'type');
  7061. newElementValue = newElement.nodeValue;
  7062. test.equal(newElementValue, null, 'valueInitiallyNull');
  7063. test.done();
  7064. },
  7065. /**
  7066. *
  7067. The tagName parameter in the "createElement(tagName)"
  7068. method is case-sensitive for XML documents.
  7069. Retrieve the entire DOM document and invoke its
  7070. "createElement(tagName)" method twice. Once for tagName
  7071. equal to "acronym" and once for tagName equal to "ACRONYM"
  7072. Each call should create a distinct Element node. The
  7073. newly created Elements are then assigned attributes
  7074. that are retrieved.
  7075. Modified on 27 June 2003 to avoid setting an invalid style
  7076. values and checked the node names to see if they matched expectations.
  7077. * @author Curt Arnold
  7078. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
  7079. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  7080. */
  7081. hc_documentcreateelementcasesensitive: function(test) {
  7082. var success;
  7083. var doc;
  7084. var newElement1;
  7085. var newElement2;
  7086. var attribute1;
  7087. var attribute2;
  7088. var nodeName1;
  7089. var nodeName2;
  7090. doc = hc_staff.hc_staff();
  7091. newElement1 = doc.createElement("ACRONYM");
  7092. newElement2 = doc.createElement("acronym");
  7093. newElement1.setAttribute("lang","EN");
  7094. newElement2.setAttribute("title","Dallas");
  7095. attribute1 = newElement1.getAttribute("lang");
  7096. attribute2 = newElement2.getAttribute("title");
  7097. test.equal(attribute1, 'EN', 'attrib1');
  7098. test.equal(attribute2, 'Dallas', 'attrib2');
  7099. nodeName1 = newElement1.nodeName;
  7100. nodeName2 = newElement2.nodeName;
  7101. test.equal(nodeName1, 'ACRONYM', 'element nodeName1');
  7102. test.equal(nodeName2, 'acronym', 'element nodeName2');
  7103. test.done();
  7104. },
  7105. /**
  7106. *
  7107. The "createTextNode(data)" method creates a Text node
  7108. given the specfied string.
  7109. Retrieve the entire DOM document and invoke its
  7110. "createTextNode(data)" method. It should create a
  7111. new Text node whose "data" is the specified string.
  7112. The NodeName and NodeType are also checked.
  7113. * @author Curt Arnold
  7114. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1975348127
  7115. */
  7116. hc_documentcreatetextnode: function(test) {
  7117. var success;
  7118. var doc;
  7119. var newTextNode;
  7120. var newTextName;
  7121. var newTextValue;
  7122. var newTextType;
  7123. doc = hc_staff.hc_staff();
  7124. newTextNode = doc.createTextNode("This is a new Text node");
  7125. newTextValue = newTextNode.nodeValue;
  7126. test.equal(newTextValue, 'This is a new Text node', 'value');
  7127. newTextName = newTextNode.nodeName;
  7128. test.equal(newTextName, '#text', 'strong');
  7129. newTextType = newTextNode.nodeType;
  7130. test.equal(newTextType, 3, 'type');
  7131. test.done();
  7132. },
  7133. /**
  7134. *
  7135. Access Document.doctype for hc_staff, if not text/html should return DocumentType node.
  7136. HTML implementations may return null.
  7137. * @author Curt Arnold
  7138. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31
  7139. */
  7140. hc_documentgetdoctype: function(test) {
  7141. var success;
  7142. var doc;
  7143. var docType;
  7144. var docTypeName;
  7145. var nodeValue;
  7146. var attributes;
  7147. doc = hc_staff.hc_staff();
  7148. docType = doc.doctype;
  7149. test.notEqual(docType, null, 'docTypeNotNull');
  7150. if((docType != null)) {
  7151. docTypeName = docType.name;
  7152. test.equal(docTypeName, 'svg', 'nodeNameSVG');
  7153. nodeValue = docType.nodeValue;
  7154. test.equal(nodeValue, null, 'nodeValue');
  7155. attributes = docType.attributes;
  7156. test.equal(attributes, null, 'attributes');
  7157. }
  7158. test.done();
  7159. },
  7160. /**
  7161. *
  7162. The "getElementsByTagName(tagName)" method returns a
  7163. NodeList of all the Elements with a given tagName.
  7164. Retrieve the entire DOM document and invoke its
  7165. "getElementsByTagName(tagName)" method with tagName
  7166. equal to "strong". The method should return a NodeList
  7167. that contains 5 elements.
  7168. * @author Curt Arnold
  7169. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094
  7170. */
  7171. hc_documentgetelementsbytagnamelength: function(test) {
  7172. var success;
  7173. var doc;
  7174. var nameList;
  7175. doc = hc_staff.hc_staff();
  7176. nameList = doc.getElementsByTagName("strong");
  7177. test.equal(nameList.length, 5, 'documentGetElementsByTagNameLengthAssert');
  7178. test.done();
  7179. },
  7180. /**
  7181. *
  7182. Retrieve the entire DOM document and invoke its
  7183. "getElementsByTagName(tagName)" method with tagName
  7184. equal to "*". The method should return a NodeList
  7185. that contains all the elements of the document.
  7186. * @author Curt Arnold
  7187. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094
  7188. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
  7189. */
  7190. hc_documentgetelementsbytagnametotallength: function(test) {
  7191. var success;
  7192. var doc;
  7193. var nameList;
  7194. expectedNames = new Array();
  7195. expectedNames[0] = "html";
  7196. expectedNames[1] = "head";
  7197. expectedNames[2] = "meta";
  7198. expectedNames[3] = "title";
  7199. expectedNames[4] = "script";
  7200. expectedNames[5] = "script";
  7201. expectedNames[6] = "script";
  7202. expectedNames[7] = "body";
  7203. expectedNames[8] = "p";
  7204. expectedNames[9] = "em";
  7205. expectedNames[10] = "strong";
  7206. expectedNames[11] = "code";
  7207. expectedNames[12] = "sup";
  7208. expectedNames[13] = "var";
  7209. expectedNames[14] = "acronym";
  7210. expectedNames[15] = "p";
  7211. expectedNames[16] = "em";
  7212. expectedNames[17] = "strong";
  7213. expectedNames[18] = "code";
  7214. expectedNames[19] = "sup";
  7215. expectedNames[20] = "var";
  7216. expectedNames[21] = "acronym";
  7217. expectedNames[22] = "p";
  7218. expectedNames[23] = "em";
  7219. expectedNames[24] = "strong";
  7220. expectedNames[25] = "code";
  7221. expectedNames[26] = "sup";
  7222. expectedNames[27] = "var";
  7223. expectedNames[28] = "acronym";
  7224. expectedNames[29] = "p";
  7225. expectedNames[30] = "em";
  7226. expectedNames[31] = "strong";
  7227. expectedNames[32] = "code";
  7228. expectedNames[33] = "sup";
  7229. expectedNames[34] = "var";
  7230. expectedNames[35] = "acronym";
  7231. expectedNames[36] = "p";
  7232. expectedNames[37] = "em";
  7233. expectedNames[38] = "strong";
  7234. expectedNames[39] = "code";
  7235. expectedNames[40] = "sup";
  7236. expectedNames[41] = "var";
  7237. expectedNames[42] = "acronym";
  7238. svgExpectedNames = new Array();
  7239. svgExpectedNames[0] = "svg";
  7240. svgExpectedNames[1] = "rect";
  7241. svgExpectedNames[2] = "script";
  7242. svgExpectedNames[3] = "head";
  7243. svgExpectedNames[4] = "meta";
  7244. svgExpectedNames[5] = "title";
  7245. svgExpectedNames[6] = "body";
  7246. svgExpectedNames[7] = "p";
  7247. svgExpectedNames[8] = "em";
  7248. svgExpectedNames[9] = "strong";
  7249. svgExpectedNames[10] = "code";
  7250. svgExpectedNames[11] = "sup";
  7251. svgExpectedNames[12] = "var";
  7252. svgExpectedNames[13] = "acronym";
  7253. svgExpectedNames[14] = "p";
  7254. svgExpectedNames[15] = "em";
  7255. svgExpectedNames[16] = "strong";
  7256. svgExpectedNames[17] = "code";
  7257. svgExpectedNames[18] = "sup";
  7258. svgExpectedNames[19] = "var";
  7259. svgExpectedNames[20] = "acronym";
  7260. svgExpectedNames[21] = "p";
  7261. svgExpectedNames[22] = "em";
  7262. svgExpectedNames[23] = "strong";
  7263. svgExpectedNames[24] = "code";
  7264. svgExpectedNames[25] = "sup";
  7265. svgExpectedNames[26] = "var";
  7266. svgExpectedNames[27] = "acronym";
  7267. svgExpectedNames[28] = "p";
  7268. svgExpectedNames[29] = "em";
  7269. svgExpectedNames[30] = "strong";
  7270. svgExpectedNames[31] = "code";
  7271. svgExpectedNames[32] = "sup";
  7272. svgExpectedNames[33] = "var";
  7273. svgExpectedNames[34] = "acronym";
  7274. svgExpectedNames[35] = "p";
  7275. svgExpectedNames[36] = "em";
  7276. svgExpectedNames[37] = "strong";
  7277. svgExpectedNames[38] = "code";
  7278. svgExpectedNames[39] = "sup";
  7279. svgExpectedNames[40] = "var";
  7280. svgExpectedNames[41] = "acronym";
  7281. var actualNames = new Array();
  7282. var thisElement;
  7283. var thisTag;
  7284. doc = hc_staff.hc_staff();
  7285. nameList = doc.getElementsByTagName("*");
  7286. for(var indexN10148 = 0;indexN10148 < nameList.length; indexN10148++) {
  7287. thisElement = nameList.item(indexN10148);
  7288. thisTag = thisElement.tagName;
  7289. actualNames[actualNames.length] = thisTag;
  7290. }
  7291. test.deepEqual(actualNames, svgExpectedNames, 'element svgTagNames');
  7292. test.done();
  7293. },
  7294. /**
  7295. *
  7296. The "getElementsByTagName(tagName)" method returns a
  7297. NodeList of all the Elements with a given tagName
  7298. in a pre-order traversal of the tree.
  7299. Retrieve the entire DOM document and invoke its
  7300. "getElementsByTagName(tagName)" method with tagName
  7301. equal to "strong". The method should return a NodeList
  7302. that contains 5 elements. The FOURTH item in the
  7303. list is retrieved and output.
  7304. * @author Curt Arnold
  7305. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-A6C9094
  7306. */
  7307. hc_documentgetelementsbytagnamevalue: function(test) {
  7308. var success;
  7309. var doc;
  7310. var nameList;
  7311. var nameNode;
  7312. var firstChild;
  7313. var childValue;
  7314. doc = hc_staff.hc_staff();
  7315. nameList = doc.getElementsByTagName("strong");
  7316. nameNode = nameList.item(3);
  7317. firstChild = nameNode.firstChild;
  7318. childValue = firstChild.nodeValue;
  7319. test.equal(childValue, 'Jeny Oconnor', 'documentGetElementsByTagNameValueAssert');
  7320. test.done();
  7321. },
  7322. /**
  7323. *
  7324. Retrieve the entire DOM document and invoke its
  7325. "getImplementation()" method. If contentType="text/html",
  7326. DOMImplementation.hasFeature("HTML","1.0") should be true.
  7327. Otherwise, DOMImplementation.hasFeature("XML", "1.0")
  7328. should be true.
  7329. * @author Curt Arnold
  7330. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1B793EBA
  7331. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=245
  7332. */
  7333. hc_documentgetimplementation: function(test) {
  7334. var success;
  7335. var doc;
  7336. var docImpl;
  7337. var xmlstate;
  7338. var htmlstate;
  7339. doc = hc_staff.hc_staff();
  7340. docImpl = doc.implementation;
  7341. xmlstate = docImpl.hasFeature("XML","1.0");
  7342. htmlstate = docImpl.hasFeature("HTML","1.0");
  7343. test.ok(xmlstate, 'supports_XML_1.0');
  7344. test.done();
  7345. },
  7346. /**
  7347. *
  7348. Load a document and invoke its
  7349. "getDocumentElement()" method.
  7350. * @author Curt Arnold
  7351. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-87CD092
  7352. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
  7353. */
  7354. hc_documentgetrootnode: function(test) {
  7355. var success;
  7356. var doc;
  7357. var root;
  7358. var rootName;
  7359. doc = hc_staff.hc_staff();
  7360. root = doc.documentElement;
  7361. rootName = root.nodeName;
  7362. test.equal(rootName, 'svg', 'svgTagName');
  7363. test.done();
  7364. },
  7365. /**
  7366. *
  7367. The "createAttribute(tagName)" method raises an
  7368. INVALID_CHARACTER_ERR DOMException if the specified
  7369. tagName contains an invalid character.
  7370. Retrieve the entire DOM document and invoke its
  7371. "createAttribute(tagName)" method with the tagName equal
  7372. to the string "invalid^Name". Due to the invalid
  7373. character the desired EXCEPTION should be raised.
  7374. * @author Curt Arnold
  7375. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  7376. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198
  7377. * @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'])
  7378. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198
  7379. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  7380. */
  7381. hc_documentinvalidcharacterexceptioncreateattribute: function(test) {
  7382. var success;
  7383. var doc;
  7384. var createdAttr;
  7385. doc = hc_staff.hc_staff();
  7386. {
  7387. success = false;
  7388. try {
  7389. createdAttr = doc.createAttribute("invalid^Name");
  7390. }
  7391. catch(ex) {
  7392. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  7393. }
  7394. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  7395. }
  7396. test.done();
  7397. },
  7398. /**
  7399. *
  7400. Creating an attribute with an empty name should cause an INVALID_CHARACTER_ERR.
  7401. * @author Curt Arnold
  7402. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  7403. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198
  7404. * @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'])
  7405. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1084891198
  7406. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525
  7407. */
  7408. hc_documentinvalidcharacterexceptioncreateattribute1: function(test) {
  7409. var success;
  7410. var doc;
  7411. var createdAttr;
  7412. doc = hc_staff.hc_staff();
  7413. {
  7414. success = false;
  7415. try {
  7416. createdAttr = doc.createAttribute("");
  7417. }
  7418. catch(ex) {
  7419. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  7420. }
  7421. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  7422. }
  7423. test.done();
  7424. },
  7425. /**
  7426. *
  7427. The "createElement(tagName)" method raises an
  7428. INVALID_CHARACTER_ERR DOMException if the specified
  7429. tagName contains an invalid character.
  7430. Retrieve the entire DOM document and invoke its
  7431. "createElement(tagName)" method with the tagName equal
  7432. to the string "invalid^Name". Due to the invalid
  7433. character the desired EXCEPTION should be raised.
  7434. * @author Curt Arnold
  7435. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  7436. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
  7437. * @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'])
  7438. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
  7439. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  7440. */
  7441. hc_documentinvalidcharacterexceptioncreateelement: function(test) {
  7442. var success;
  7443. var doc;
  7444. var badElement;
  7445. doc = hc_staff.hc_staff();
  7446. {
  7447. success = false;
  7448. try {
  7449. badElement = doc.createElement("invalid^Name");
  7450. }
  7451. catch(ex) {
  7452. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  7453. }
  7454. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  7455. }
  7456. test.done();
  7457. },
  7458. /**
  7459. *
  7460. Creating an element with an empty name should cause an INVALID_CHARACTER_ERR.
  7461. * @author Curt Arnold
  7462. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  7463. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
  7464. * @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'])
  7465. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-2141741547
  7466. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525
  7467. */
  7468. hc_documentinvalidcharacterexceptioncreateelement1: function(test) {
  7469. var success;
  7470. var doc;
  7471. var badElement;
  7472. doc = hc_staff.hc_staff();
  7473. {
  7474. success = false;
  7475. try {
  7476. badElement = doc.createElement("");
  7477. }
  7478. catch(ex) {
  7479. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  7480. }
  7481. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  7482. }
  7483. test.done();
  7484. },
  7485. /**
  7486. *
  7487. Load a document and invoke its
  7488. "getImplementation()" method. This should create a
  7489. DOMImplementation object whose "hasFeature(feature,
  7490. version)" method is invoked with version equal to "".
  7491. If the version is not specified, supporting any version
  7492. feature will cause the method to return "true".
  7493. * @author Curt Arnold
  7494. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7
  7495. * @see http://www.w3.org/2000/11/DOM-Level-2-errata#core-14
  7496. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=245
  7497. */
  7498. hc_domimplementationfeaturenoversion: function(test) {
  7499. var success;
  7500. var doc;
  7501. var domImpl;
  7502. var state;
  7503. doc = hc_staff.hc_staff();
  7504. domImpl = doc.implementation;
  7505. state = domImpl.hasFeature("XML","");
  7506. test.ok(state, 'hasFeatureBlank');
  7507. test.done();
  7508. },
  7509. /**
  7510. *
  7511. Load a document and invoke its
  7512. "getImplementation()" method. This should create a
  7513. DOMImplementation object whose "hasFeature(feature,
  7514. version)" method is invoked with version equal to null.
  7515. If the version is not specified, supporting any version
  7516. feature will cause the method to return "true".
  7517. * @author Curt Arnold
  7518. * @author Curt Arnold
  7519. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7
  7520. * @see http://www.w3.org/2000/11/DOM-Level-2-errata#core-14
  7521. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=245
  7522. */
  7523. hc_domimplementationfeaturenull: function(test) {
  7524. var success;
  7525. var doc;
  7526. var domImpl;
  7527. var state;
  7528. doc = hc_staff.hc_staff();
  7529. domImpl = doc.implementation;
  7530. state = domImpl.hasFeature("XML",null);
  7531. test.ok(state, 'supports_XML_null');
  7532. test.done();
  7533. },
  7534. /**
  7535. *
  7536. Retrieve the entire DOM document and invoke its
  7537. "getImplementation()" method. This should create a
  7538. DOMImplementation object whose "hasFeature(feature,
  7539. version)" method is invoked with "feature" equal to "html" or "xml".
  7540. The method should return a boolean "true".
  7541. * @author Curt Arnold
  7542. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7
  7543. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=245
  7544. */
  7545. hc_domimplementationfeaturexml: function(test) {
  7546. var success;
  7547. var doc;
  7548. var domImpl;
  7549. var state;
  7550. doc = hc_staff.hc_staff();
  7551. domImpl = doc.implementation;
  7552. state = domImpl.hasFeature("xml","1.0");
  7553. test.ok(state, 'supports_xml_1.0');
  7554. test.done();
  7555. },
  7556. /**
  7557. *
  7558. The "setAttribute(name,value)" method adds a new attribute
  7559. to the Element
  7560. Retrieve the last child of the last employee, then
  7561. add an attribute to it by invoking the
  7562. "setAttribute(name,value)" method. It should create
  7563. a "strong" attribute with an assigned value equal to
  7564. "value".
  7565. * @author Curt Arnold
  7566. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
  7567. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  7568. */
  7569. hc_elementaddnewattribute: function(test) {
  7570. var success;
  7571. var doc;
  7572. var elementList;
  7573. var testEmployee;
  7574. var attrValue;
  7575. doc = hc_staff.hc_staff();
  7576. elementList = doc.getElementsByTagName("acronym");
  7577. testEmployee = elementList.item(4);
  7578. testEmployee.setAttribute("lang","EN-us");
  7579. attrValue = testEmployee.getAttribute("lang");
  7580. test.equal(attrValue, 'EN-us', 'attrValue');
  7581. test.done();
  7582. },
  7583. /**
  7584. *
  7585. Retrieve the first attribute from the last child of
  7586. the first employee and invoke the "getSpecified()"
  7587. method. This test is only intended to show that
  7588. Elements can actually have attributes. This test uses
  7589. the "getNamedItem(name)" method from the NamedNodeMap
  7590. interface.
  7591. * @author Curt Arnold
  7592. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  7593. */
  7594. hc_elementassociatedattribute: function(test) {
  7595. var success;
  7596. var doc;
  7597. var elementList;
  7598. var testEmployee;
  7599. var attributes;
  7600. var domesticAttr;
  7601. var specified;
  7602. doc = hc_staff.hc_staff();
  7603. elementList = doc.getElementsByTagName("acronym");
  7604. testEmployee = elementList.item(0);
  7605. attributes = testEmployee.attributes;
  7606. domesticAttr = attributes.getNamedItem("title");
  7607. specified = domesticAttr.specified;
  7608. test.ok(specified, 'acronymTitleSpecified');
  7609. test.done();
  7610. },
  7611. /**
  7612. *
  7613. The "setAttribute(name,value)" method adds a new attribute
  7614. to the Element. If the "strong" is already present, then
  7615. its value should be changed to the new one that is in
  7616. the "value" parameter.
  7617. Retrieve the last child of the fourth employee, then add
  7618. an attribute to it by invoking the
  7619. "setAttribute(name,value)" method. Since the name of the
  7620. used attribute("class") is already present in this
  7621. element, then its value should be changed to the new one
  7622. of the "value" parameter.
  7623. * @author Curt Arnold
  7624. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
  7625. */
  7626. hc_elementchangeattributevalue: function(test) {
  7627. var success;
  7628. var doc;
  7629. var elementList;
  7630. var testEmployee;
  7631. var attrValue;
  7632. doc = hc_staff.hc_staff();
  7633. elementList = doc.getElementsByTagName("acronym");
  7634. testEmployee = elementList.item(3);
  7635. testEmployee.setAttribute("class","Neither");
  7636. attrValue = testEmployee.getAttribute("class");
  7637. test.equal(attrValue, 'Neither', 'elementChangeAttributeValueAssert');
  7638. test.done();
  7639. },
  7640. /**
  7641. *
  7642. The "setAttributeNode(newAttr)" method adds a new
  7643. attribute to the Element.
  7644. Retrieve first address element and add
  7645. a new attribute node to it by invoking its
  7646. "setAttributeNode(newAttr)" method. This test makes use
  7647. of the "createAttribute(name)" method from the Document
  7648. interface.
  7649. * @author Curt Arnold
  7650. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  7651. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  7652. */
  7653. hc_elementcreatenewattribute: function(test) {
  7654. var success;
  7655. var doc;
  7656. var elementList;
  7657. var testAddress;
  7658. var newAttribute;
  7659. var oldAttr;
  7660. var districtAttr;
  7661. var attrVal;
  7662. doc = hc_staff.hc_staff();
  7663. elementList = doc.getElementsByTagName("acronym");
  7664. testAddress = elementList.item(0);
  7665. newAttribute = doc.createAttribute("lang");
  7666. oldAttr = testAddress.setAttributeNode(newAttribute);
  7667. test.equal(oldAttr, null, 'old_attr_doesnt_exist');
  7668. districtAttr = testAddress.getAttributeNode("lang");
  7669. test.notEqual(districtAttr, null, 'new_district_accessible');
  7670. attrVal = testAddress.getAttribute("lang");
  7671. test.equal(attrVal, '', 'attr_value');
  7672. test.done();
  7673. },
  7674. /**
  7675. *
  7676. Retrieve the attribute "title" from the last child
  7677. of the first "p" element and check its node name.
  7678. * @author Curt Arnold
  7679. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-217A91B8
  7680. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  7681. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
  7682. */
  7683. hc_elementgetattributenode: function(test) {
  7684. var success;
  7685. var doc;
  7686. var elementList;
  7687. var testEmployee;
  7688. var domesticAttr;
  7689. var nodeName;
  7690. doc = hc_staff.hc_staff();
  7691. elementList = doc.getElementsByTagName("acronym");
  7692. testEmployee = elementList.item(0);
  7693. domesticAttr = testEmployee.getAttributeNode("title");
  7694. nodeName = domesticAttr.nodeName;
  7695. test.equal(nodeName, 'title', 'attribute nodeName');
  7696. test.done();
  7697. },
  7698. /**
  7699. *
  7700. The "getAttributeNode(name)" method retrieves an
  7701. attribute node by name. It should return null if the
  7702. "strong" attribute does not exist.
  7703. Retrieve the last child of the first employee and attempt
  7704. to retrieve a non-existing attribute. The method should
  7705. return "null". The non-existing attribute to be used
  7706. is "invalidAttribute".
  7707. * @author Curt Arnold
  7708. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-217A91B8
  7709. */
  7710. hc_elementgetattributenodenull: function(test) {
  7711. var success;
  7712. var doc;
  7713. var elementList;
  7714. var testEmployee;
  7715. var domesticAttr;
  7716. doc = hc_staff.hc_staff();
  7717. elementList = doc.getElementsByTagName("acronym");
  7718. testEmployee = elementList.item(0);
  7719. domesticAttr = testEmployee.getAttributeNode("invalidAttribute");
  7720. test.equal(domesticAttr, null, 'elementGetAttributeNodeNullAssert');
  7721. test.done();
  7722. },
  7723. /**
  7724. *
  7725. The "getAttribute(name)" method returns an empty
  7726. string if no value was assigned to an attribute and
  7727. no default value was given in the DTD file.
  7728. Retrieve the last child of the last employee, then
  7729. invoke "getAttribute(name)" method, where "strong" is an
  7730. attribute without a specified or DTD default value.
  7731. The "getAttribute(name)" method should return the empty
  7732. string. This method makes use of the
  7733. "createAttribute(newAttr)" method from the Document
  7734. interface.
  7735. * @author Curt Arnold
  7736. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-666EE0F9
  7737. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  7738. */
  7739. hc_elementgetelementempty: function(test) {
  7740. var success;
  7741. var doc;
  7742. var newAttribute;
  7743. var elementList;
  7744. var testEmployee;
  7745. var domesticAttr;
  7746. var attrValue;
  7747. doc = hc_staff.hc_staff();
  7748. newAttribute = doc.createAttribute("lang");
  7749. elementList = doc.getElementsByTagName("acronym");
  7750. testEmployee = elementList.item(3);
  7751. domesticAttr = testEmployee.setAttributeNode(newAttribute);
  7752. attrValue = testEmployee.getAttribute("lang");
  7753. test.equal(attrValue, '', 'elementGetElementEmptyAssert');
  7754. test.done();
  7755. },
  7756. /**
  7757. *
  7758. The "getElementsByTagName(name)" method returns a list
  7759. of all descendant Elements with the given tag name.
  7760. Test for an empty list.
  7761. Create a NodeList of all the descendant elements
  7762. using the string "noMatch" as the tagName.
  7763. The method should return a NodeList whose length is
  7764. "0" since there are not any descendant elements
  7765. that match the given tag name.
  7766. * @author Curt Arnold
  7767. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D
  7768. */
  7769. hc_elementgetelementsbytagname: function(test) {
  7770. var success;
  7771. var doc;
  7772. var elementList;
  7773. doc = hc_staff.hc_staff();
  7774. elementList = doc.getElementsByTagName("p");
  7775. test.equal(elementList.length, 5, 'elementGetElementsByTagNameAssert');
  7776. test.done();
  7777. },
  7778. /**
  7779. *
  7780. The "getElementsByTagName(name)" method returns a list
  7781. of all descendant Elements in the order the children
  7782. were encountered in a pre order traversal of the element
  7783. tree.
  7784. Create a NodeList of all the descendant elements
  7785. using the string "p" as the tagName.
  7786. The method should return a NodeList whose length is
  7787. "5" in the order the children were encountered.
  7788. Access the FOURTH element in the NodeList. The FOURTH
  7789. element, the first or second should be an "em" node with
  7790. the content "EMP0004".
  7791. * @author Curt Arnold
  7792. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D
  7793. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  7794. */
  7795. hc_elementgetelementsbytagnameaccessnodelist: function(test) {
  7796. var success;
  7797. var doc;
  7798. var elementList;
  7799. var testEmployee;
  7800. var firstC;
  7801. var childName;
  7802. var nodeType;
  7803. var employeeIDNode;
  7804. var employeeID;
  7805. doc = hc_staff.hc_staff();
  7806. elementList = doc.getElementsByTagName("p");
  7807. testEmployee = elementList.item(3);
  7808. firstC = testEmployee.firstChild;
  7809. nodeType = firstC.nodeType;
  7810. while(
  7811. (3 == nodeType)
  7812. ) {
  7813. firstC = firstC.nextSibling;
  7814. nodeType = firstC.nodeType;
  7815. }
  7816. childName = firstC.nodeName;
  7817. test.equal(childName, 'em', 'element childName');
  7818. employeeIDNode = firstC.firstChild;
  7819. employeeID = employeeIDNode.nodeValue;
  7820. test.equal(employeeID, 'EMP0004', 'employeeID');
  7821. test.done();
  7822. },
  7823. /**
  7824. *
  7825. The "getElementsByTagName(name)" method returns a list
  7826. of all descendant Elements with the given tag name.
  7827. Create a NodeList of all the descendant elements
  7828. using the string "employee" as the tagName.
  7829. The method should return a NodeList whose length is
  7830. "5".
  7831. * @author Curt Arnold
  7832. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D
  7833. */
  7834. hc_elementgetelementsbytagnamenomatch: function(test) {
  7835. var success;
  7836. var doc;
  7837. var elementList;
  7838. doc = hc_staff.hc_staff();
  7839. elementList = doc.getElementsByTagName("noMatch");
  7840. test.equal(elementList.length, 0, 'elementGetElementsByTagNameNoMatchNoMatchAssert');
  7841. test.done();
  7842. },
  7843. /**
  7844. *
  7845. The "getElementsByTagName(name)" method may use the
  7846. special value "*" to match all tags in the element
  7847. tree.
  7848. Create a NodeList of all the descendant elements
  7849. of the last employee by using the special value "*".
  7850. The method should return all the descendant children(6)
  7851. in the order the children were encountered.
  7852. * @author Curt Arnold
  7853. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1938918D
  7854. */
  7855. hc_elementgetelementsbytagnamespecialvalue: function(test) {
  7856. var success;
  7857. var doc;
  7858. var elementList;
  7859. var lastEmployee;
  7860. var lastempList;
  7861. var child;
  7862. var childName;
  7863. var result = new Array();
  7864. expectedResult = new Array();
  7865. expectedResult[0] = "em";
  7866. expectedResult[1] = "strong";
  7867. expectedResult[2] = "code";
  7868. expectedResult[3] = "sup";
  7869. expectedResult[4] = "var";
  7870. expectedResult[5] = "acronym";
  7871. doc = hc_staff.hc_staff();
  7872. elementList = doc.getElementsByTagName("p");
  7873. lastEmployee = elementList.item(4);
  7874. lastempList = lastEmployee.getElementsByTagName("*");
  7875. for(var indexN10067 = 0;indexN10067 < lastempList.length; indexN10067++) {
  7876. child = lastempList.item(indexN10067);
  7877. childName = child.nodeName;
  7878. result[result.length] = childName;
  7879. }
  7880. test.deepEqual(result, expectedResult, 'element tagNames');
  7881. test.done();
  7882. },
  7883. /**
  7884. *
  7885. Invoke the "getTagName()" method one the
  7886. root node. The value returned should be "html" or "svg".
  7887. * @author Curt Arnold
  7888. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-104682815
  7889. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
  7890. */
  7891. hc_elementgettagname: function(test) {
  7892. var success;
  7893. var doc;
  7894. var root;
  7895. var tagname;
  7896. doc = hc_staff.hc_staff();
  7897. root = doc.documentElement;
  7898. tagname = root.tagName;
  7899. test.equal(tagname, 'svg', 'svgTagname');
  7900. test.done();
  7901. },
  7902. /**
  7903. *
  7904. The "setAttributeNode(newAttr)" method raises an
  7905. "INUSE_ATTRIBUTE_ERR DOMException if the "newAttr"
  7906. is already an attribute of another element.
  7907. * @author Curt Arnold
  7908. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])
  7909. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  7910. * @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'])
  7911. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=244
  7912. */
  7913. hc_elementinuseattributeerr: function(test) {
  7914. var success;
  7915. var doc;
  7916. var newAttribute;
  7917. var addressElementList;
  7918. var testAddress;
  7919. var newElement;
  7920. var attrAddress;
  7921. var appendedChild;
  7922. var setAttr1;
  7923. var setAttr2;
  7924. doc = hc_staff.hc_staff();
  7925. addressElementList = doc.getElementsByTagName("body");
  7926. testAddress = addressElementList.item(0);
  7927. newElement = doc.createElement("p");
  7928. appendedChild = testAddress.appendChild(newElement);
  7929. newAttribute = doc.createAttribute("title");
  7930. setAttr1 = newElement.setAttributeNode(newAttribute);
  7931. {
  7932. success = false;
  7933. try {
  7934. setAttr2 = testAddress.setAttributeNode(newAttribute);
  7935. }
  7936. catch(ex) {
  7937. success = (typeof(ex.code) != 'undefined' && ex.code == 10);
  7938. }
  7939. test.ok(success, 'throw_INUSE_ATTRIBUTE_ERR');
  7940. }
  7941. test.done();
  7942. },
  7943. /**
  7944. *
  7945. The "setAttribute(name,value)" method raises an
  7946. "INVALID_CHARACTER_ERR DOMException if the specified
  7947. name contains an invalid character.
  7948. Retrieve the last child of the first employee and
  7949. call its "setAttribute(name,value)" method with
  7950. "strong" containing an invalid character.
  7951. * @author Curt Arnold
  7952. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  7953. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
  7954. * @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'])
  7955. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  7956. */
  7957. hc_elementinvalidcharacterexception: function(test) {
  7958. var success;
  7959. var doc;
  7960. var elementList;
  7961. var testAddress;
  7962. doc = hc_staff.hc_staff();
  7963. elementList = doc.getElementsByTagName("acronym");
  7964. testAddress = elementList.item(0);
  7965. {
  7966. success = false;
  7967. try {
  7968. testAddress.setAttribute("invalid^Name","value");
  7969. }
  7970. catch(ex) {
  7971. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  7972. }
  7973. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  7974. }
  7975. test.done();
  7976. },
  7977. /**
  7978. *
  7979. Calling Element.setAttribute with an empty name will cause an INVALID_CHARACTER_ERR.
  7980. * @author Curt Arnold
  7981. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INVALID_CHARACTER_ERR'])
  7982. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68F082
  7983. * @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'])
  7984. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=525
  7985. */
  7986. hc_elementinvalidcharacterexception1: function(test) {
  7987. var success;
  7988. var doc;
  7989. var elementList;
  7990. var testAddress;
  7991. doc = hc_staff.hc_staff();
  7992. elementList = doc.getElementsByTagName("acronym");
  7993. testAddress = elementList.item(0);
  7994. {
  7995. success = false;
  7996. try {
  7997. testAddress.setAttribute("","value");
  7998. }
  7999. catch(ex) {
  8000. success = (typeof(ex.code) != 'undefined' && ex.code == 5);
  8001. }
  8002. test.ok(success, 'throw_INVALID_CHARACTER_ERR');
  8003. }
  8004. test.done();
  8005. },
  8006. /**
  8007. *
  8008. Append a couple of text nodes to the first sup element, normalize the
  8009. document element and check that the element has been normalized.
  8010. * @author Curt Arnold
  8011. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083
  8012. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=546
  8013. */
  8014. hc_elementnormalize: function(test) {
  8015. var success;
  8016. var doc;
  8017. var root;
  8018. var elementList;
  8019. var testName;
  8020. var firstChild;
  8021. var childValue;
  8022. var textNode;
  8023. var retNode;
  8024. doc = hc_staff.hc_staff();
  8025. elementList = doc.getElementsByTagName("sup");
  8026. testName = elementList.item(0);
  8027. textNode = doc.createTextNode("");
  8028. retNode = testName.appendChild(textNode);
  8029. textNode = doc.createTextNode(",000");
  8030. retNode = testName.appendChild(textNode);
  8031. root = doc.documentElement;
  8032. root.normalize();
  8033. elementList = doc.getElementsByTagName("sup");
  8034. testName = elementList.item(0);
  8035. firstChild = testName.firstChild;
  8036. childValue = firstChild.nodeValue;
  8037. test.equal(childValue, '56,000,000', 'elementNormalizeAssert');
  8038. test.done();
  8039. },
  8040. /**
  8041. *
  8042. Add an empty text node to an existing attribute node, normalize the containing element
  8043. and check that the attribute node has eliminated the empty text.
  8044. * @author Curt Arnold
  8045. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-162CF083
  8046. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=482
  8047. */
  8048. hc_elementnormalize2: function(test) {
  8049. var success;
  8050. var doc;
  8051. var root;
  8052. var elementList;
  8053. var element;
  8054. var firstChild;
  8055. var secondChild;
  8056. var childValue;
  8057. var emptyText;
  8058. var attrNode;
  8059. var retval;
  8060. doc = hc_staff.hc_staff();
  8061. root = doc.documentElement;
  8062. emptyText = doc.createTextNode("");
  8063. elementList = root.getElementsByTagName("acronym");
  8064. element = elementList.item(0);
  8065. attrNode = element.getAttributeNode("title");
  8066. retval = attrNode.appendChild(emptyText);
  8067. element.normalize();
  8068. attrNode = element.getAttributeNode("title");
  8069. firstChild = attrNode.firstChild;
  8070. childValue = firstChild.nodeValue;
  8071. test.equal(childValue, 'Yes', 'firstChild');
  8072. secondChild = firstChild.nextSibling;
  8073. test.equal(secondChild, null, 'secondChildNull');
  8074. test.done();
  8075. },
  8076. /**
  8077. *
  8078. The "removeAttributeNode(oldAttr)" method raises a
  8079. NOT_FOUND_ERR DOMException if the "oldAttr" attribute
  8080. is not an attribute of the element.
  8081. Retrieve the last employee and attempt to remove
  8082. a non existing attribute node. This should cause the
  8083. intended exception to be raised. This test makes use
  8084. of the "createAttribute(name)" method from the Document
  8085. interface.
  8086. * @author Curt Arnold
  8087. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])
  8088. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198
  8089. * @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'])
  8090. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  8091. */
  8092. hc_elementnotfounderr: function(test) {
  8093. var success;
  8094. var doc;
  8095. var oldAttribute;
  8096. var addressElementList;
  8097. var testAddress;
  8098. var attrAddress;
  8099. doc = hc_staff.hc_staff();
  8100. addressElementList = doc.getElementsByTagName("acronym");
  8101. testAddress = addressElementList.item(4);
  8102. oldAttribute = doc.createAttribute("title");
  8103. {
  8104. success = false;
  8105. try {
  8106. attrAddress = testAddress.removeAttributeNode(oldAttribute);
  8107. }
  8108. catch(ex) {
  8109. success = (typeof(ex.code) != 'undefined' && ex.code == 8);
  8110. }
  8111. test.ok(success, 'throw_NOT_FOUND_ERR');
  8112. }
  8113. test.done();
  8114. },
  8115. /**
  8116. *
  8117. The "removeAttribute(name)" removes an attribute by name.
  8118. If the attribute has a default value, it is immediately
  8119. replaced. However, there is no default values in the HTML
  8120. compatible tests, so its value is "".
  8121. * @author Curt Arnold
  8122. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D6AC0F9
  8123. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html
  8124. */
  8125. hc_elementremoveattribute: function(test) {
  8126. var success;
  8127. var doc;
  8128. var elementList;
  8129. var testEmployee;
  8130. var attrValue;
  8131. doc = hc_staff.hc_staff();
  8132. elementList = doc.getElementsByTagName("acronym");
  8133. testEmployee = elementList.item(3);
  8134. testEmployee.removeAttribute("class");
  8135. attrValue = testEmployee.getAttribute("class");
  8136. test.equal(attrValue, '', 'attrValue');
  8137. test.done();
  8138. },
  8139. /**
  8140. *
  8141. The "removeAttributeNode(oldAttr)" method removes the
  8142. specified attribute.
  8143. Retrieve the last child of the third employee, add a
  8144. new "lang" attribute to it and then try to remove it.
  8145. To verify that the node was removed use the
  8146. "getNamedItem(name)" method from the NamedNodeMap
  8147. interface. It also uses the "getAttributes()" method
  8148. from the Node interface.
  8149. * @author Curt Arnold
  8150. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198
  8151. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  8152. */
  8153. hc_elementremoveattributeaftercreate: function(test) {
  8154. var success;
  8155. var doc;
  8156. var elementList;
  8157. var testEmployee;
  8158. var newAttribute;
  8159. var attributes;
  8160. var districtAttr;
  8161. doc = hc_staff.hc_staff();
  8162. elementList = doc.getElementsByTagName("acronym");
  8163. testEmployee = elementList.item(2);
  8164. newAttribute = doc.createAttribute("lang");
  8165. districtAttr = testEmployee.setAttributeNode(newAttribute);
  8166. districtAttr = testEmployee.removeAttributeNode(newAttribute);
  8167. attributes = testEmployee.attributes;
  8168. districtAttr = attributes.getNamedItem("lang");
  8169. test.equal(districtAttr, null, 'removed_item_null');
  8170. test.done();
  8171. },
  8172. /**
  8173. *
  8174. The "removeAttributeNode(oldAttr)" method returns the
  8175. node that was removed.
  8176. Retrieve the last child of the third employee and
  8177. remove its "class" Attr node. The method should
  8178. return the old attribute node.
  8179. * @author Curt Arnold
  8180. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D589198
  8181. */
  8182. hc_elementremoveattributenode: function(test) {
  8183. var success;
  8184. var doc;
  8185. var elementList;
  8186. var testEmployee;
  8187. var streetAttr;
  8188. var removedAttr;
  8189. var removedValue;
  8190. doc = hc_staff.hc_staff();
  8191. elementList = doc.getElementsByTagName("acronym");
  8192. testEmployee = elementList.item(2);
  8193. streetAttr = testEmployee.getAttributeNode("class");
  8194. removedAttr = testEmployee.removeAttributeNode(streetAttr);
  8195. test.notEqual(removedAttr, null, 'removedAttrNotNull');
  8196. removedValue = removedAttr.value;
  8197. test.equal(removedValue, 'No', 'elementRemoveAttributeNodeAssert');
  8198. test.done();
  8199. },
  8200. /**
  8201. *
  8202. This test calls setAttributeNode to replace an attribute with itself.
  8203. Since the node is not an attribute of another Element, it would
  8204. be inappropriate to throw an INUSE_ATTRIBUTE_ERR.
  8205. This test was derived from elementinuserattributeerr which
  8206. inadvertanly made this test.
  8207. * @author Curt Arnold
  8208. * @author Curt Arnold
  8209. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  8210. */
  8211. hc_elementreplaceattributewithself: function(test) {
  8212. var success;
  8213. var doc;
  8214. var elementList;
  8215. var testEmployee;
  8216. var streetAttr;
  8217. var replacedAttr;
  8218. var value;
  8219. doc = hc_staff.hc_staff();
  8220. elementList = doc.getElementsByTagName("acronym");
  8221. testEmployee = elementList.item(2);
  8222. streetAttr = testEmployee.getAttributeNode("class");
  8223. replacedAttr = testEmployee.setAttributeNode(streetAttr);
  8224. test.equal(replacedAttr, streetAttr, 'replacedAttr');
  8225. test.done();
  8226. },
  8227. /**
  8228. *
  8229. The "setAttributeNode(newAttr)" method adds a new
  8230. attribute to the Element. If the "newAttr" Attr node is
  8231. already present in this element, it should replace the
  8232. existing one.
  8233. Retrieve the last child of the third employee and add a
  8234. new attribute node by invoking the "setAttributeNode(new
  8235. Attr)" method. The new attribute node to be added is
  8236. "class", which is already present in this element. The
  8237. method should replace the existing Attr node with the
  8238. new one. This test uses the "createAttribute(name)"
  8239. method from the Document interface.
  8240. * @author Curt Arnold
  8241. */
  8242. hc_elementreplaceexistingattribute: function(test) {
  8243. var success;
  8244. var doc;
  8245. var elementList;
  8246. var testEmployee;
  8247. var newAttribute;
  8248. var strong;
  8249. var setAttr;
  8250. doc = hc_staff.hc_staff();
  8251. elementList = doc.getElementsByTagName("acronym");
  8252. testEmployee = elementList.item(2);
  8253. newAttribute = doc.createAttribute("class");
  8254. setAttr = testEmployee.setAttributeNode(newAttribute);
  8255. strong = testEmployee.getAttribute("class");
  8256. test.equal(strong, '', 'replacedValue');
  8257. test.done();
  8258. },
  8259. /**
  8260. *
  8261. If the "setAttributeNode(newAttr)" method replaces an
  8262. existing Attr node with the same name, then it should
  8263. return the previously existing Attr node.
  8264. Retrieve the last child of the third employee and add a
  8265. new attribute node. The new attribute node is "class",
  8266. which is already present in this Element. The method
  8267. should return the existing Attr node(old "class" Attr).
  8268. This test uses the "createAttribute(name)" method
  8269. from the Document interface.
  8270. * @author Curt Arnold
  8271. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  8272. */
  8273. hc_elementreplaceexistingattributegevalue: function(test) {
  8274. var success;
  8275. var doc;
  8276. var elementList;
  8277. var testEmployee;
  8278. var newAttribute;
  8279. var streetAttr;
  8280. var value;
  8281. doc = hc_staff.hc_staff();
  8282. elementList = doc.getElementsByTagName("acronym");
  8283. testEmployee = elementList.item(2);
  8284. newAttribute = doc.createAttribute("class");
  8285. streetAttr = testEmployee.setAttributeNode(newAttribute);
  8286. test.notEqual(streetAttr, null, 'previousAttrNotNull');
  8287. value = streetAttr.value;
  8288. test.equal(value, 'No', 'previousAttrValue');
  8289. test.done();
  8290. },
  8291. /**
  8292. *
  8293. Create a list of all the attributes of the last child
  8294. of the first "p" element by using the "getAttributes()"
  8295. method.
  8296. * @author Curt Arnold
  8297. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  8298. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html
  8299. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
  8300. */
  8301. hc_elementretrieveallattributes: function(test) {
  8302. var doc = hc_staff.hc_staff();
  8303. var attributes = doc.getElementsByTagName("acronym").item(0).attributes;
  8304. var actual = [];
  8305. for(var i=0;i<attributes.length;i++) {
  8306. actual.push(attributes.item(i).nodeName);
  8307. }
  8308. test.deepEqual(actual, ['dir', 'title'], 'attributeNames');
  8309. test.done();
  8310. },
  8311. /**
  8312. *
  8313. The "getAttribute(name)" method returns an attribute
  8314. value by name.
  8315. Retrieve the second address element, then
  8316. invoke the 'getAttribute("class")' method. This should
  8317. return the value of the attribute("No").
  8318. * @author Curt Arnold
  8319. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-666EE0F9
  8320. */
  8321. hc_elementretrieveattrvalue: function(test) {
  8322. var success;
  8323. var doc;
  8324. var elementList;
  8325. var testAddress;
  8326. var attrValue;
  8327. doc = hc_staff.hc_staff();
  8328. elementList = doc.getElementsByTagName("acronym");
  8329. testAddress = elementList.item(2);
  8330. attrValue = testAddress.getAttribute("class");
  8331. test.equal(attrValue, 'No', 'attrValue');
  8332. test.done();
  8333. },
  8334. /**
  8335. *
  8336. The "getElementsByTagName()" method returns a NodeList
  8337. of all descendant elements with a given tagName.
  8338. Invoke the "getElementsByTagName()" method and create
  8339. a NodeList of "code" elements. Retrieve the second
  8340. "code" element in the list and return the NodeName.
  8341. * @author Curt Arnold
  8342. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  8343. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-104682815
  8344. */
  8345. hc_elementretrievetagname: function(test) {
  8346. var success;
  8347. var doc;
  8348. var elementList;
  8349. var testEmployee;
  8350. var strong;
  8351. doc = hc_staff.hc_staff();
  8352. elementList = doc.getElementsByTagName("code");
  8353. testEmployee = elementList.item(1);
  8354. strong = testEmployee.nodeName;
  8355. test.equal(strong, 'code', 'element nodename');
  8356. strong = testEmployee.tagName;
  8357. test.equal(strong, 'code', 'element tagname');
  8358. test.done();
  8359. },
  8360. /**
  8361. *
  8362. The "setAttributeNode(newAttr)" method returns the
  8363. null value if no previously existing Attr node with the
  8364. same name was replaced.
  8365. Retrieve the last child of the third employee and add a
  8366. new attribute to it. The new attribute node added is
  8367. "lang", which is not part of this Element. The
  8368. method should return the null value.
  8369. This test uses the "createAttribute(name)"
  8370. method from the Document interface.
  8371. * @author Curt Arnold
  8372. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  8373. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  8374. */
  8375. hc_elementsetattributenodenull: function(test) {
  8376. var success;
  8377. var doc;
  8378. var elementList;
  8379. var testEmployee;
  8380. var newAttribute;
  8381. var districtAttr;
  8382. doc = hc_staff.hc_staff();
  8383. elementList = doc.getElementsByTagName("acronym");
  8384. testEmployee = elementList.item(2);
  8385. newAttribute = doc.createAttribute("lang");
  8386. districtAttr = testEmployee.setAttributeNode(newAttribute);
  8387. test.equal(districtAttr, null, 'elementSetAttributeNodeNullAssert');
  8388. test.done();
  8389. },
  8390. /**
  8391. *
  8392. The "setAttributeNode(newAttr)" method raises an
  8393. "WRONG_DOCUMENT_ERR DOMException if the "newAttr"
  8394. was created from a different document than the one that
  8395. created this document.
  8396. Retrieve the last employee and attempt to set a new
  8397. attribute node for its "employee" element. The new
  8398. attribute was created from a document other than the
  8399. one that created this element, therefore a
  8400. WRONG_DOCUMENT_ERR DOMException should be raised.
  8401. This test uses the "createAttribute(newAttr)" method
  8402. from the Document interface.
  8403. * @author Curt Arnold
  8404. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])
  8405. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154
  8406. * @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'])
  8407. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  8408. */
  8409. hc_elementwrongdocumenterr: function(test) {
  8410. var success;
  8411. var doc1;
  8412. var doc2;
  8413. var newAttribute;
  8414. var addressElementList;
  8415. var testAddress;
  8416. var attrAddress;
  8417. var doc1Ref = null;
  8418. if (typeof(this.doc1) != 'undefined') {
  8419. doc1Ref = this.doc1;
  8420. }
  8421. doc1 = hc_staff.hc_staff();
  8422. var doc2Ref = null;
  8423. if (typeof(this.doc2) != 'undefined') {
  8424. doc2Ref = this.doc2;
  8425. }
  8426. doc2 = hc_staff.hc_staff();
  8427. newAttribute = doc2.createAttribute("newAttribute");
  8428. addressElementList = doc1.getElementsByTagName("acronym");
  8429. testAddress = addressElementList.item(4);
  8430. {
  8431. success = false;
  8432. try {
  8433. attrAddress = testAddress.setAttributeNode(newAttribute);
  8434. }
  8435. catch(ex) {
  8436. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  8437. }
  8438. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  8439. }
  8440. test.done();
  8441. },
  8442. /**
  8443. *
  8444. An attempt to add remove an entity should result in a NO_MODIFICATION_ERR.
  8445. * @author Curt Arnold
  8446. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1788794630
  8447. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193
  8448. */
  8449. hc_entitiesremovenameditem1: function(test) {
  8450. var success;
  8451. var doc;
  8452. var entities;
  8453. var docType;
  8454. var retval;
  8455. doc = hc_staff.hc_staff();
  8456. docType = doc.doctype;
  8457. test.notEqual(docType, null, 'docTypeNotNull');
  8458. entities = docType.entities;
  8459. test.notEqual(entities, null, 'entitiesNotNull');
  8460. success = false;
  8461. try {
  8462. retval = entities.removeNamedItem("alpha");
  8463. }
  8464. catch(ex) {
  8465. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  8466. }
  8467. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  8468. test.done();
  8469. },
  8470. /**
  8471. *
  8472. An attempt to add an element to the named node map returned by entities should
  8473. result in a NO_MODIFICATION_ERR or HIERARCHY_REQUEST_ERR.
  8474. * @author Curt Arnold
  8475. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1788794630
  8476. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  8477. */
  8478. hc_entitiessetnameditem1: function(test) {
  8479. var success;
  8480. var doc;
  8481. var entities;
  8482. var docType;
  8483. var retval;
  8484. var elem;
  8485. doc = hc_staff.hc_staff();
  8486. docType = doc.doctype;
  8487. test.notEqual(docType, null, 'docTypeNotNull');
  8488. entities = docType.entities;
  8489. test.notEqual(entities, null, 'entitiesNotNull');
  8490. elem = doc.createElement("br");
  8491. try {
  8492. retval = entities.setNamedItem(elem);
  8493. fail("throw_HIER_OR_NO_MOD_ERR");
  8494. } catch (ex) {
  8495. if (typeof(ex.code) != 'undefined') {
  8496. switch(ex.code) {
  8497. case /* HIERARCHY_REQUEST_ERR */ 3 :
  8498. break;
  8499. case /* NO_MODIFICATION_ALLOWED_ERR */ 7 :
  8500. break;
  8501. default:
  8502. throw ex;
  8503. }
  8504. } else {
  8505. throw ex;
  8506. }
  8507. }
  8508. test.done();
  8509. },
  8510. /**
  8511. *
  8512. Create a NamedNodeMap object from the attributes of the
  8513. last child of the third "p" element and traverse the
  8514. list from index 0 thru length -1. All indices should
  8515. be valid.
  8516. * @author Curt Arnold
  8517. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  8518. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  8519. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D0FB19E
  8520. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=250
  8521. */
  8522. hc_namednodemapchildnoderange: function(test) {
  8523. var success;
  8524. var doc;
  8525. var elementList;
  8526. var testEmployee;
  8527. var attributes;
  8528. var child;
  8529. var strong;
  8530. var length;
  8531. doc = hc_staff.hc_staff();
  8532. elementList = doc.getElementsByTagName("acronym");
  8533. testEmployee = elementList.item(2);
  8534. attributes = testEmployee.attributes;
  8535. length = attributes.length;
  8536. test.equal(length, 3, 'length');
  8537. child = attributes.item(2);
  8538. test.notEqual(child, null, 'attr2');
  8539. child = attributes.item(0);
  8540. test.notEqual(child, null, 'attr0');
  8541. child = attributes.item(1);
  8542. test.notEqual(child, null, 'attr1');
  8543. child = attributes.item(3);
  8544. test.equal(child, null, 'attr3');
  8545. test.done();
  8546. },
  8547. /**
  8548. *
  8549. Retrieve the second "p" element and create a NamedNodeMap
  8550. listing of the attributes of the last child. Once the
  8551. list is created an invocation of the "getNamedItem(name)"
  8552. method is done with name="title". This should result
  8553. in the title Attr node being returned.
  8554. * @author Curt Arnold
  8555. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
  8556. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  8557. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  8558. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
  8559. */
  8560. hc_namednodemapgetnameditem: function(test) {
  8561. var success;
  8562. var doc;
  8563. var elementList;
  8564. var testEmployee;
  8565. var attributes;
  8566. var domesticAttr;
  8567. var attrName;
  8568. doc = hc_staff.hc_staff();
  8569. elementList = doc.getElementsByTagName("acronym");
  8570. testEmployee = elementList.item(1);
  8571. attributes = testEmployee.attributes;
  8572. domesticAttr = attributes.getNamedItem("title");
  8573. attrName = domesticAttr.nodeName;
  8574. test.equal(attrName, 'title', 'attribute nodeName');
  8575. test.done();
  8576. },
  8577. /**
  8578. *
  8579. The "setNamedItem(arg)" method raises a
  8580. INUSE_ATTRIBUTE_ERR DOMException if "arg" is an
  8581. Attr that is already in an attribute of another Element.
  8582. Create a NamedNodeMap object from the attributes of the
  8583. last child of the third employee and attempt to add
  8584. an attribute that is already being used by the first
  8585. employee. This should raise the desired exception.
  8586. * @author Curt Arnold
  8587. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])
  8588. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  8589. * @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'])
  8590. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  8591. */
  8592. hc_namednodemapinuseattributeerr: function(test) {
  8593. var success;
  8594. var doc;
  8595. var elementList;
  8596. var firstNode;
  8597. var testNode;
  8598. var attributes;
  8599. var domesticAttr;
  8600. var setAttr;
  8601. var setNode;
  8602. doc = hc_staff.hc_staff();
  8603. elementList = doc.getElementsByTagName("acronym");
  8604. firstNode = elementList.item(0);
  8605. domesticAttr = doc.createAttribute("title");
  8606. domesticAttr.value = "Yα";
  8607. setAttr = firstNode.setAttributeNode(domesticAttr);
  8608. elementList = doc.getElementsByTagName("acronym");
  8609. testNode = elementList.item(2);
  8610. attributes = testNode.attributes;
  8611. {
  8612. success = false;
  8613. try {
  8614. setNode = attributes.setNamedItem(domesticAttr);
  8615. }
  8616. catch(ex) {
  8617. success = (typeof(ex.code) != 'undefined' && ex.code == 10);
  8618. }
  8619. test.ok(success, 'throw_INUSE_ATTRIBUTE_ERR');
  8620. }
  8621. test.done();
  8622. },
  8623. /**
  8624. *
  8625. The "removeNamedItem(name)" method raises a
  8626. NOT_FOUND_ERR DOMException if there is not a node
  8627. named "strong" in the map.
  8628. Create a NamedNodeMap object from the attributes of the
  8629. last child of the third employee and attempt to remove
  8630. the "lang" attribute. There is not a node named
  8631. "lang" in the list and therefore the desired
  8632. exception should be raised.
  8633. * @author Curt Arnold
  8634. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])
  8635. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193
  8636. * @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'])
  8637. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  8638. */
  8639. hc_namednodemapnotfounderr: function(test) {
  8640. var success;
  8641. var doc;
  8642. var elementList;
  8643. var testEmployee;
  8644. var attributes;
  8645. var removedNode;
  8646. doc = hc_staff.hc_staff();
  8647. elementList = doc.getElementsByTagName("acronym");
  8648. testEmployee = elementList.item(2);
  8649. attributes = testEmployee.attributes;
  8650. {
  8651. success = false;
  8652. try {
  8653. removedNode = attributes.removeNamedItem("lang");
  8654. }
  8655. catch(ex) {
  8656. success = (typeof(ex.code) != 'undefined' && ex.code == 8);
  8657. }
  8658. test.ok(success, 'throw_NOT_FOUND_ERR');
  8659. }
  8660. test.done();
  8661. },
  8662. /**
  8663. *
  8664. Retrieve the second "p" element and evaluate Node.attributes.length.
  8665. * @author Curt Arnold
  8666. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  8667. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D0FB19E
  8668. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=250
  8669. */
  8670. hc_namednodemapnumberofnodes: function(test) {
  8671. var success;
  8672. var doc;
  8673. var elementList;
  8674. var testEmployee;
  8675. var attributes;
  8676. var length;
  8677. doc = hc_staff.hc_staff();
  8678. elementList = doc.getElementsByTagName("acronym");
  8679. testEmployee = elementList.item(2);
  8680. attributes = testEmployee.attributes;
  8681. length = attributes.length;
  8682. test.equal(length, 3, 'length');
  8683. test.done();
  8684. },
  8685. /**
  8686. *
  8687. The "removeNamedItem(name)" method removes a node
  8688. specified by name.
  8689. Retrieve the third employee and create a NamedNodeMap
  8690. object of the attributes of the last child. Once the
  8691. list is created invoke the "removeNamedItem(name)"
  8692. method with name="class". This should result
  8693. in the removal of the specified attribute.
  8694. * @author Curt Arnold
  8695. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193
  8696. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  8697. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html
  8698. */
  8699. hc_namednodemapremovenameditem: function(test) {
  8700. var success;
  8701. var doc;
  8702. var elementList;
  8703. var newAttribute;
  8704. var testAddress;
  8705. var attributes;
  8706. var streetAttr;
  8707. var specified;
  8708. var removedNode;
  8709. doc = hc_staff.hc_staff();
  8710. elementList = doc.getElementsByTagName("acronym");
  8711. testAddress = elementList.item(2);
  8712. attributes = testAddress.attributes;
  8713. removedNode = attributes.removeNamedItem("class");
  8714. streetAttr = attributes.getNamedItem("class");
  8715. test.equal(streetAttr, null, 'isnull');
  8716. test.done();
  8717. },
  8718. /**
  8719. *
  8720. Retrieve the second p element and create a NamedNodeMap
  8721. listing of the attributes of the last child. Once the
  8722. list is created an invocation of the "getNamedItem(name)"
  8723. method is done with name="class". This should result
  8724. in the method returning an Attr node.
  8725. * @author Curt Arnold
  8726. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
  8727. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  8728. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  8729. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1112119403
  8730. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  8731. */
  8732. hc_namednodemapreturnattrnode: function(test) {
  8733. var doc = hc_staff.hc_staff();
  8734. var streetAttr = doc.getElementsByTagName("acronym").item(1).attributes.getNamedItem("class");
  8735. test.equal(streetAttr.nodeType, 2, 'typeAssert');
  8736. test.equal(streetAttr.nodeName, 'class', 'attribute nodeName');
  8737. test.equal(streetAttr.name, 'class', 'attribute name');
  8738. test.done();
  8739. },
  8740. /**
  8741. *
  8742. The "item(index)" method returns the indexth item in
  8743. the map(test for first item).
  8744. Retrieve the second "acronym" get the NamedNodeMap of the attributes. Since the
  8745. DOM does not specify an order of these nodes the contents
  8746. of the FIRST node can contain either "title", "class" or "dir".
  8747. * @author Curt Arnold
  8748. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  8749. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  8750. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
  8751. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
  8752. */
  8753. hc_namednodemapreturnfirstitem: function(test) {
  8754. var doc = hc_staff.hc_staff();
  8755. var attributes = doc.getElementsByTagName("acronym").item(1).attributes;
  8756. var actual = [];
  8757. for(var i=0;i<attributes.length;i++) {
  8758. actual.push(attributes.item(i).nodeName);
  8759. }
  8760. test.deepEqual(actual, ["dir", "title", "class"], 'attrName');
  8761. test.done();
  8762. },
  8763. /**
  8764. *
  8765. The "item(index)" method returns the indexth item in
  8766. the map(test for last item).
  8767. Retrieve the second "acronym" and get the attribute name. Since the
  8768. DOM does not specify an order of these nodes the contents
  8769. of the LAST node can contain either "title" or "class".
  8770. The test should return "true" if the LAST node is either
  8771. of these values.
  8772. * @author Curt Arnold
  8773. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  8774. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  8775. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
  8776. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
  8777. */
  8778. hc_namednodemapreturnlastitem: function(test) {
  8779. var doc = hc_staff.hc_staff();
  8780. var attributes = doc.getElementsByTagName("acronym").item(1).attributes;
  8781. var actual = [];
  8782. for(var i=0;i<attributes.length;i++) {
  8783. actual.push(attributes.item(i).nodeName);
  8784. }
  8785. test.deepEqual(actual, ["dir", "title", "class"], 'attrName');
  8786. test.done();
  8787. },
  8788. /**
  8789. *
  8790. The "getNamedItem(name)" method returns null of the
  8791. specified name did not identify any node in the map.
  8792. Retrieve the second employee and create a NamedNodeMap
  8793. listing of the attributes of the last child. Once the
  8794. list is created an invocation of the "getNamedItem(name)"
  8795. method is done with name="lang". This name does not
  8796. match any names in the list therefore the method should
  8797. return null.
  8798. * @author Curt Arnold
  8799. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
  8800. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  8801. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  8802. */
  8803. hc_namednodemapreturnnull: function(test) {
  8804. var success;
  8805. var doc;
  8806. var elementList;
  8807. var testEmployee;
  8808. var attributes;
  8809. var districtNode;
  8810. doc = hc_staff.hc_staff();
  8811. elementList = doc.getElementsByTagName("acronym");
  8812. testEmployee = elementList.item(1);
  8813. attributes = testEmployee.attributes;
  8814. districtNode = attributes.getNamedItem("lang");
  8815. test.equal(districtNode, null, 'langAttrNull');
  8816. test.done();
  8817. },
  8818. /**
  8819. *
  8820. Retrieve the second "p" element and create a NamedNodeMap
  8821. object from the attributes of the last child by
  8822. invoking the "getAttributes()" method. Once the
  8823. list is created an invocation of the "setNamedItem(arg)"
  8824. method is done with arg=newAttr, where newAttr is a
  8825. new Attr Node previously created. The "setNamedItem(arg)"
  8826. method should add then new node to the NamedNodeItem
  8827. object by using its "nodeName" attribute("lang').
  8828. This node is then retrieved using the "getNamedItem(name)"
  8829. method.
  8830. * @author Curt Arnold
  8831. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  8832. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  8833. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  8834. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
  8835. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  8836. */
  8837. hc_namednodemapsetnameditem: function(test) {
  8838. var success;
  8839. var doc;
  8840. var elementList;
  8841. var newAttribute;
  8842. var testAddress;
  8843. var attributes;
  8844. var districtNode;
  8845. var attrName;
  8846. var setNode;
  8847. doc = hc_staff.hc_staff();
  8848. elementList = doc.getElementsByTagName("acronym");
  8849. testAddress = elementList.item(1);
  8850. newAttribute = doc.createAttribute("lang");
  8851. attributes = testAddress.attributes;
  8852. setNode = attributes.setNamedItem(newAttribute);
  8853. districtNode = attributes.getNamedItem("lang");
  8854. attrName = districtNode.nodeName;
  8855. test.equal(attrName, 'lang', 'attribute nodeName');
  8856. test.done();
  8857. },
  8858. /**
  8859. *
  8860. If the "setNamedItem(arg)" method replaces an already
  8861. existing node with the same name then the already
  8862. existing node is returned.
  8863. Retrieve the third employee and create a NamedNodeMap
  8864. object from the attributes of the last child by
  8865. invoking the "getAttributes()" method. Once the
  8866. list is created an invocation of the "setNamedItem(arg)"
  8867. method is done with arg=newAttr, where newAttr is a
  8868. new Attr Node previously created and whose node name
  8869. already exists in the map. The "setNamedItem(arg)"
  8870. method should replace the already existing node with
  8871. the new one and return the existing node.
  8872. This test uses the "createAttribute(name)" method from
  8873. the document interface.
  8874. * @author Curt Arnold
  8875. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  8876. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  8877. */
  8878. hc_namednodemapsetnameditemreturnvalue: function(test) {
  8879. var success;
  8880. var doc;
  8881. var elementList;
  8882. var newAttribute;
  8883. var testAddress;
  8884. var attributes;
  8885. var newNode;
  8886. var attrValue;
  8887. doc = hc_staff.hc_staff();
  8888. elementList = doc.getElementsByTagName("acronym");
  8889. testAddress = elementList.item(2);
  8890. newAttribute = doc.createAttribute("class");
  8891. attributes = testAddress.attributes;
  8892. newNode = attributes.setNamedItem(newAttribute);
  8893. test.notEqual(newNode, null, 'previousAttrNotNull');
  8894. attrValue = newNode.nodeValue;
  8895. test.equal(attrValue, 'No', 'previousAttrValue');
  8896. test.done();
  8897. },
  8898. /**
  8899. *
  8900. If the node to be added by the "setNamedItem(arg)" method
  8901. already exists in the NamedNodeMap, it is replaced by
  8902. the new one.
  8903. Retrieve the second employee and create a NamedNodeMap
  8904. object from the attributes of the last child by
  8905. invoking the "getAttributes()" method. Once the
  8906. list is created an invocation of the "setNamedItem(arg)"
  8907. method is done with arg=newAttr, where newAttr is a
  8908. new Attr Node previously created and whose node name
  8909. already exists in the map. The "setNamedItem(arg)"
  8910. method should replace the already existing node with
  8911. the new one.
  8912. This node is then retrieved using the "getNamedItem(name)"
  8913. method. This test uses the "createAttribute(name)"
  8914. method from the document interface
  8915. * @author Curt Arnold
  8916. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  8917. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  8918. */
  8919. hc_namednodemapsetnameditemthatexists: function(test) {
  8920. var success;
  8921. var doc;
  8922. var elementList;
  8923. var newAttribute;
  8924. var testAddress;
  8925. var attributes;
  8926. var districtNode;
  8927. var attrValue;
  8928. var setNode;
  8929. doc = hc_staff.hc_staff();
  8930. elementList = doc.getElementsByTagName("acronym");
  8931. testAddress = elementList.item(1);
  8932. newAttribute = doc.createAttribute("class");
  8933. attributes = testAddress.attributes;
  8934. setNode = attributes.setNamedItem(newAttribute);
  8935. districtNode = attributes.getNamedItem("class");
  8936. attrValue = districtNode.nodeValue;
  8937. test.equal(attrValue, '', 'namednodemapSetNamedItemThatExistsAssert');
  8938. test.done();
  8939. },
  8940. /**
  8941. *
  8942. If the "setNamedItem(arg)" method does not replace an
  8943. existing node with the same name then it returns null.
  8944. Retrieve the third employee and create a NamedNodeMap
  8945. object from the attributes of the last child.
  8946. Once the list is created the "setNamedItem(arg)" method
  8947. is invoked with arg=newAttr, where newAttr is a
  8948. newly created Attr Node and whose node name
  8949. already exists in the map. The "setNamedItem(arg)"
  8950. method should add the new node and return null.
  8951. This test uses the "createAttribute(name)" method from
  8952. the document interface.
  8953. * @author Curt Arnold
  8954. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  8955. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  8956. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=243
  8957. */
  8958. hc_namednodemapsetnameditemwithnewvalue: function(test) {
  8959. var success;
  8960. var doc;
  8961. var elementList;
  8962. var newAttribute;
  8963. var testAddress;
  8964. var attributes;
  8965. var newNode;
  8966. doc = hc_staff.hc_staff();
  8967. elementList = doc.getElementsByTagName("acronym");
  8968. testAddress = elementList.item(2);
  8969. newAttribute = doc.createAttribute("lang");
  8970. attributes = testAddress.attributes;
  8971. newNode = attributes.setNamedItem(newAttribute);
  8972. test.equal(newNode, null, 'prevValueNull');
  8973. test.done();
  8974. },
  8975. /**
  8976. *
  8977. The "setNamedItem(arg)" method raises a
  8978. WRONG_DOCUMENT_ERR DOMException if "arg" was created
  8979. from a different document than the one that created
  8980. the NamedNodeMap.
  8981. Create a NamedNodeMap object from the attributes of the
  8982. last child of the third employee and attempt to add
  8983. another Attr node to it that was created from a
  8984. different DOM document. This should raise the desired
  8985. exception. This method uses the "createAttribute(name)"
  8986. method from the Document interface.
  8987. * @author Curt Arnold
  8988. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])
  8989. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  8990. * @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'])
  8991. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  8992. */
  8993. hc_namednodemapwrongdocumenterr: function(test) {
  8994. var success;
  8995. var doc1;
  8996. var doc2;
  8997. var elementList;
  8998. var testAddress;
  8999. var attributes;
  9000. var newAttribute;
  9001. var strong;
  9002. var setNode;
  9003. var doc1Ref = null;
  9004. if (typeof(this.doc1) != 'undefined') {
  9005. doc1Ref = this.doc1;
  9006. }
  9007. doc1 = hc_staff.hc_staff();
  9008. var doc2Ref = null;
  9009. if (typeof(this.doc2) != 'undefined') {
  9010. doc2Ref = this.doc2;
  9011. }
  9012. doc2 = hc_staff.hc_staff();
  9013. elementList = doc1.getElementsByTagName("acronym");
  9014. testAddress = elementList.item(2);
  9015. newAttribute = doc2.createAttribute("newAttribute");
  9016. attributes = testAddress.attributes;
  9017. {
  9018. success = false;
  9019. try {
  9020. setNode = attributes.setNamedItem(newAttribute);
  9021. }
  9022. catch(ex) {
  9023. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  9024. }
  9025. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  9026. }
  9027. test.done();
  9028. },
  9029. /**
  9030. *
  9031. Retrieve the second "p" and append a "br" Element
  9032. node to the list of children. The last node in the list
  9033. is then retrieved and its NodeName examined. The
  9034. "getNodeName()" method should return "br".
  9035. * @author Curt Arnold
  9036. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  9037. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  9038. */
  9039. hc_nodeappendchild: function(test) {
  9040. var success;
  9041. var doc;
  9042. var elementList;
  9043. var employeeNode;
  9044. var childList;
  9045. var createdNode;
  9046. var lchild;
  9047. var childName;
  9048. var appendedChild;
  9049. doc = hc_staff.hc_staff();
  9050. elementList = doc.getElementsByTagName("p");
  9051. employeeNode = elementList.item(1);
  9052. childList = employeeNode.childNodes;
  9053. createdNode = doc.createElement("br");
  9054. appendedChild = employeeNode.appendChild(createdNode);
  9055. lchild = employeeNode.lastChild;
  9056. childName = lchild.nodeName;
  9057. test.equal(childName, 'br', 'element nodeName');
  9058. test.done();
  9059. },
  9060. /**
  9061. *
  9062. If the "newChild" is already in the tree, it is first
  9063. removed before the new one is appended.
  9064. Retrieve the "em" second employee and
  9065. append the first child to the end of the list. After
  9066. the "appendChild(newChild)" method is invoked the first
  9067. child should be the one that was second and the last
  9068. child should be the one that was first.
  9069. * @author Curt Arnold
  9070. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  9071. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  9072. */
  9073. hc_nodeappendchildchildexists: function(test) {
  9074. var success;
  9075. var doc;
  9076. var elementList;
  9077. var childList;
  9078. var childNode;
  9079. var newChild;
  9080. var memberNode;
  9081. var memberName;
  9082. var refreshedActual = new Array();
  9083. var actual = new Array();
  9084. var nodeType;
  9085. expected = new Array();
  9086. expected[0] = "strong";
  9087. expected[1] = "code";
  9088. expected[2] = "sup";
  9089. expected[3] = "var";
  9090. expected[4] = "acronym";
  9091. expected[5] = "em";
  9092. var appendedChild;
  9093. doc = hc_staff.hc_staff();
  9094. elementList = doc.getElementsByTagName("p");
  9095. childNode = elementList.item(1);
  9096. childList = childNode.getElementsByTagName("*");
  9097. newChild = childList.item(0);
  9098. appendedChild = childNode.appendChild(newChild);
  9099. for(var indexN10085 = 0;indexN10085 < childList.length; indexN10085++) {
  9100. memberNode = childList.item(indexN10085);
  9101. memberName = memberNode.nodeName;
  9102. actual[actual.length] = memberName;
  9103. }
  9104. test.deepEqual(actual, expected, 'element liveByTagName');
  9105. childList = childNode.childNodes;
  9106. for(var indexN1009C = 0;indexN1009C < childList.length; indexN1009C++) {
  9107. memberNode = childList.item(indexN1009C);
  9108. nodeType = memberNode.nodeType;
  9109. if(
  9110. (1 == nodeType)
  9111. ) {
  9112. memberName = memberNode.nodeName;
  9113. refreshedActual[refreshedActual.length] = memberName;
  9114. }
  9115. }
  9116. test.deepEqual(refreshedActual, expected, 'element refreshedChildNodes');
  9117. test.done();
  9118. },
  9119. /**
  9120. *
  9121. If the "newChild" is a DocumentFragment object then
  9122. all its content is added to the child list of this node.
  9123. Create and populate a new DocumentFragment object and
  9124. append it to the second employee. After the
  9125. "appendChild(newChild)" method is invoked retrieve the
  9126. new nodes at the end of the list, they should be the
  9127. two Element nodes from the DocumentFragment.
  9128. * @author Curt Arnold
  9129. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  9130. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  9131. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  9132. */
  9133. hc_nodeappendchilddocfragment: function(test) {
  9134. var success;
  9135. var doc;
  9136. var elementList;
  9137. var employeeNode;
  9138. var childList;
  9139. var newdocFragment;
  9140. var newChild1;
  9141. var newChild2;
  9142. var child;
  9143. var childName;
  9144. var result = new Array();
  9145. var appendedChild;
  9146. var nodeType;
  9147. expected = new Array();
  9148. expected[0] = "em";
  9149. expected[1] = "strong";
  9150. expected[2] = "code";
  9151. expected[3] = "sup";
  9152. expected[4] = "var";
  9153. expected[5] = "acronym";
  9154. expected[6] = "br";
  9155. expected[7] = "b";
  9156. doc = hc_staff.hc_staff();
  9157. elementList = doc.getElementsByTagName("p");
  9158. employeeNode = elementList.item(1);
  9159. childList = employeeNode.childNodes;
  9160. newdocFragment = doc.createDocumentFragment();
  9161. newChild1 = doc.createElement("br");
  9162. newChild2 = doc.createElement("b");
  9163. appendedChild = newdocFragment.appendChild(newChild1);
  9164. appendedChild = newdocFragment.appendChild(newChild2);
  9165. appendedChild = employeeNode.appendChild(newdocFragment);
  9166. for(var indexN100A2 = 0;indexN100A2 < childList.length; indexN100A2++) {
  9167. child = childList.item(indexN100A2);
  9168. nodeType = child.nodeType;
  9169. if(
  9170. (1 == nodeType)
  9171. ) {
  9172. childName = child.nodeName;
  9173. result[result.length] = childName;
  9174. }
  9175. }
  9176. test.deepEqual(result, expected, 'element nodeNames');
  9177. test.done();
  9178. },
  9179. /**
  9180. *
  9181. The "appendChild(newChild)" method returns the node
  9182. added.
  9183. Append a newly created node to the child list of the
  9184. second employee and check the NodeName returned. The
  9185. "getNodeName()" method should return "br".
  9186. * @author Curt Arnold
  9187. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  9188. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  9189. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  9190. */
  9191. hc_nodeappendchildgetnodename: function(test) {
  9192. var success;
  9193. var doc;
  9194. var elementList;
  9195. var employeeNode;
  9196. var childList;
  9197. var newChild;
  9198. var appendNode;
  9199. var childName;
  9200. doc = hc_staff.hc_staff();
  9201. elementList = doc.getElementsByTagName("p");
  9202. employeeNode = elementList.item(1);
  9203. childList = employeeNode.childNodes;
  9204. newChild = doc.createElement("br");
  9205. appendNode = employeeNode.appendChild(newChild);
  9206. childName = appendNode.nodeName;
  9207. test.equal(childName, 'br', 'element nodeName');
  9208. test.done();
  9209. },
  9210. /**
  9211. *
  9212. The "appendChild(newChild)" method raises a
  9213. HIERARCHY_REQUEST_ERR DOMException if this node is of
  9214. a type that does not allow children of the type "newChild"
  9215. to be inserted.
  9216. Retrieve the root node and attempt to append a newly
  9217. created Attr node. An Element node cannot have children
  9218. of the "Attr" type, therefore the desired exception
  9219. should be raised.
  9220. * @author Curt Arnold
  9221. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
  9222. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  9223. * @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'])
  9224. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  9225. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  9226. */
  9227. hc_nodeappendchildinvalidnodetype: function(test) {
  9228. var success;
  9229. var doc;
  9230. var rootNode;
  9231. var newChild;
  9232. var appendedChild;
  9233. doc = hc_staff.hc_staff();
  9234. rootNode = doc.documentElement;
  9235. newChild = doc.createAttribute("newAttribute");
  9236. {
  9237. success = false;
  9238. try {
  9239. appendedChild = rootNode.appendChild(newChild);
  9240. }
  9241. catch(ex) {
  9242. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  9243. }
  9244. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  9245. }
  9246. test.done();
  9247. },
  9248. /**
  9249. *
  9250. The "appendChild(newChild)" method raises a
  9251. WRONG_DOCUMENT_ERR DOMException if the "newChild" was
  9252. created from a different document than the one that
  9253. created this node.
  9254. Retrieve the second employee and attempt to append
  9255. a node created from a different document. An attempt
  9256. to make such a replacement should raise the desired
  9257. exception.
  9258. * @author Curt Arnold
  9259. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
  9260. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  9261. * @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'])
  9262. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  9263. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  9264. */
  9265. hc_nodeappendchildnewchilddiffdocument: function(test) {
  9266. var success;
  9267. var doc1;
  9268. var doc2;
  9269. var newChild;
  9270. var elementList;
  9271. var elementNode;
  9272. var appendedChild;
  9273. var doc1Ref = null;
  9274. if (typeof(this.doc1) != 'undefined') {
  9275. doc1Ref = this.doc1;
  9276. }
  9277. doc1 = hc_staff.hc_staff();
  9278. var doc2Ref = null;
  9279. if (typeof(this.doc2) != 'undefined') {
  9280. doc2Ref = this.doc2;
  9281. }
  9282. doc2 = hc_staff.hc_staff();
  9283. newChild = doc1.createElement("br");
  9284. elementList = doc2.getElementsByTagName("p");
  9285. elementNode = elementList.item(1);
  9286. {
  9287. success = false;
  9288. try {
  9289. appendedChild = elementNode.appendChild(newChild);
  9290. }
  9291. catch(ex) {
  9292. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  9293. }
  9294. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  9295. }
  9296. test.done();
  9297. },
  9298. /**
  9299. *
  9300. The "appendChild(newChild)" method raises a
  9301. HIERARCHY_REQUEST_ERR DOMException if the node to
  9302. append is one of this node's ancestors.
  9303. Retrieve the second employee and attempt to append
  9304. an ancestor node(root node) to it.
  9305. An attempt to make such an addition should raise the
  9306. desired exception.
  9307. * @author Curt Arnold
  9308. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
  9309. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  9310. * @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'])
  9311. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  9312. */
  9313. hc_nodeappendchildnodeancestor: function(test) {
  9314. var success;
  9315. var doc;
  9316. var newChild;
  9317. var elementList;
  9318. var employeeNode;
  9319. var childList;
  9320. var oldChild;
  9321. var appendedChild;
  9322. doc = hc_staff.hc_staff();
  9323. newChild = doc.documentElement;
  9324. elementList = doc.getElementsByTagName("p");
  9325. employeeNode = elementList.item(1);
  9326. {
  9327. success = false;
  9328. try {
  9329. appendedChild = employeeNode.appendChild(newChild);
  9330. }
  9331. catch(ex) {
  9332. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  9333. }
  9334. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  9335. }
  9336. test.done();
  9337. },
  9338. /**
  9339. *
  9340. The "getAttributes()" method invoked on an Attribute
  9341. Node returns null.
  9342. Retrieve the first attribute from the last child of the
  9343. first employee and invoke the "getAttributes()" method
  9344. on the Attribute Node. It should return null.
  9345. * @author Curt Arnold
  9346. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  9347. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  9348. */
  9349. hc_nodeattributenodeattribute: function(test) {
  9350. var success;
  9351. var doc;
  9352. var elementList;
  9353. var testAddr;
  9354. var addrAttr;
  9355. var attrNode;
  9356. var attrList;
  9357. doc = hc_staff.hc_staff();
  9358. elementList = doc.getElementsByTagName("acronym");
  9359. testAddr = elementList.item(0);
  9360. addrAttr = testAddr.attributes;
  9361. attrNode = addrAttr.item(0);
  9362. attrList = attrNode.attributes;
  9363. test.equal(attrList, null, 'nodeAttributeNodeAttribute');
  9364. test.done();
  9365. },
  9366. /**
  9367. *
  9368. Retrieve the Attribute named "title" from the last
  9369. child of the first p element and check the string returned
  9370. by the "getNodeName()" method. It should be equal to
  9371. "title".
  9372. * @author Curt Arnold
  9373. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  9374. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  9375. */
  9376. hc_nodeattributenodename: function(test) {
  9377. var success;
  9378. var doc;
  9379. var elementList;
  9380. var testAddr;
  9381. var addrAttr;
  9382. var attrName;
  9383. doc = hc_staff.hc_staff();
  9384. elementList = doc.getElementsByTagName("acronym");
  9385. testAddr = elementList.item(0);
  9386. addrAttr = testAddr.getAttributeNode("title");
  9387. attrName = addrAttr.nodeName;
  9388. test.equal(attrName, 'title', 'attribute nodeName');
  9389. test.done();
  9390. },
  9391. /**
  9392. *
  9393. The "getNodeType()" method for an Attribute Node
  9394. returns the constant value 2.
  9395. Retrieve the first attribute from the last child of
  9396. the first employee and invoke the "getNodeType()"
  9397. method. The method should return 2.
  9398. * @author Curt Arnold
  9399. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  9400. */
  9401. hc_nodeattributenodetype: function(test) {
  9402. var success;
  9403. var doc;
  9404. var elementList;
  9405. var testAddr;
  9406. var addrAttr;
  9407. var nodeType;
  9408. doc = hc_staff.hc_staff();
  9409. elementList = doc.getElementsByTagName("acronym");
  9410. testAddr = elementList.item(0);
  9411. addrAttr = testAddr.getAttributeNode("title");
  9412. nodeType = addrAttr.nodeType;
  9413. test.equal(nodeType, 2, 'nodeAttrNodeType');
  9414. test.done();
  9415. },
  9416. /**
  9417. *
  9418. The string returned by the "getNodeValue()" method for an
  9419. Attribute Node is the value of the Attribute.
  9420. Retrieve the Attribute named "title" from the last
  9421. child of the first "p" and check the string returned
  9422. by the "getNodeValue()" method. It should be equal to
  9423. "Yes".
  9424. * @author Curt Arnold
  9425. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  9426. */
  9427. hc_nodeattributenodevalue: function(test) {
  9428. var success;
  9429. var doc;
  9430. var elementList;
  9431. var testAddr;
  9432. var addrAttr;
  9433. var attrValue;
  9434. doc = hc_staff.hc_staff();
  9435. elementList = doc.getElementsByTagName("acronym");
  9436. testAddr = elementList.item(0);
  9437. addrAttr = testAddr.getAttributeNode("title");
  9438. attrValue = addrAttr.nodeValue;
  9439. test.equal(attrValue, 'Yes', 'nodeValue');
  9440. test.done();
  9441. },
  9442. /**
  9443. *
  9444. The "getChildNodes()" method returns a NodeList
  9445. that contains all children of this node.
  9446. Retrieve the second employee and check the NodeList
  9447. returned by the "getChildNodes()" method. The
  9448. length of the list should be 13.
  9449. * @author Curt Arnold
  9450. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  9451. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  9452. */
  9453. hc_nodechildnodes: function(test) {
  9454. var success;
  9455. var doc;
  9456. var elementList;
  9457. var employeeNode;
  9458. var childNode;
  9459. var childNodes;
  9460. var nodeType;
  9461. var childName;
  9462. var actual = new Array();
  9463. expected = new Array();
  9464. expected[0] = "em";
  9465. expected[1] = "strong";
  9466. expected[2] = "code";
  9467. expected[3] = "sup";
  9468. expected[4] = "var";
  9469. expected[5] = "acronym";
  9470. doc = hc_staff.hc_staff();
  9471. elementList = doc.getElementsByTagName("p");
  9472. employeeNode = elementList.item(1);
  9473. childNodes = employeeNode.childNodes;
  9474. for(var indexN1006C = 0;indexN1006C < childNodes.length; indexN1006C++) {
  9475. childNode = childNodes.item(indexN1006C);
  9476. nodeType = childNode.nodeType;
  9477. childName = childNode.nodeName;
  9478. if(
  9479. (1 == nodeType)
  9480. ) {
  9481. actual[actual.length] = childName;
  9482. }
  9483. else {
  9484. test.equal(nodeType, 3, 'textNodeType');
  9485. }
  9486. }
  9487. test.deepEqual(actual, expected, 'element elementNames');
  9488. test.done();
  9489. },
  9490. /**
  9491. *
  9492. The NodeList returned by the "getChildNodes()" method
  9493. is live. Changes on the node's children are immediately
  9494. reflected on the nodes returned in the NodeList.
  9495. Create a NodeList of the children of the second employee
  9496. and then add a newly created element that was created
  9497. by the "createElement()" method(Document Interface) to
  9498. the second employee by using the "appendChild()" method.
  9499. The length of the NodeList should reflect this new
  9500. addition to the child list. It should return the value 14.
  9501. * @author Curt Arnold
  9502. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  9503. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  9504. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  9505. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  9506. */
  9507. hc_nodechildnodesappendchild: function(test) {
  9508. var success;
  9509. var doc;
  9510. var elementList;
  9511. var employeeNode;
  9512. var childList;
  9513. var createdNode;
  9514. var childNode;
  9515. var childName;
  9516. var childType;
  9517. var textNode;
  9518. var actual = new Array();
  9519. expected = new Array();
  9520. expected[0] = "em";
  9521. expected[1] = "strong";
  9522. expected[2] = "code";
  9523. expected[3] = "sup";
  9524. expected[4] = "var";
  9525. expected[5] = "acronym";
  9526. expected[6] = "br";
  9527. doc = hc_staff.hc_staff();
  9528. elementList = doc.getElementsByTagName("p");
  9529. employeeNode = elementList.item(1);
  9530. childList = employeeNode.childNodes;
  9531. createdNode = doc.createElement("br");
  9532. employeeNode = employeeNode.appendChild(createdNode);
  9533. for(var indexN10087 = 0;indexN10087 < childList.length; indexN10087++) {
  9534. childNode = childList.item(indexN10087);
  9535. childName = childNode.nodeName;
  9536. childType = childNode.nodeType;
  9537. if(
  9538. (1 == childType)
  9539. ) {
  9540. actual[actual.length] = childName;
  9541. }
  9542. else {
  9543. test.equal(childType, 3, 'textNodeType');
  9544. }
  9545. }
  9546. test.deepEqual(actual, expected, 'element childElements');
  9547. test.done();
  9548. },
  9549. /**
  9550. *
  9551. The "getChildNodes()" method returns a NodeList
  9552. that contains all children of this node. If there
  9553. are not any children, this is a NodeList that does not
  9554. contain any nodes.
  9555. Retrieve the character data of the second "em" node and
  9556. invoke the "getChildNodes()" method. The
  9557. NodeList returned should not have any nodes.
  9558. * @author Curt Arnold
  9559. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  9560. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  9561. */
  9562. hc_nodechildnodesempty: function(test) {
  9563. var success;
  9564. var doc;
  9565. var elementList;
  9566. var childList;
  9567. var employeeNode;
  9568. var textNode;
  9569. var length;
  9570. doc = hc_staff.hc_staff();
  9571. elementList = doc.getElementsByTagName("em");
  9572. employeeNode = elementList.item(1);
  9573. textNode = employeeNode.firstChild;
  9574. childList = textNode.childNodes;
  9575. length = childList.length;
  9576. test.equal(length, 0, 'length_zero');
  9577. test.done();
  9578. },
  9579. /**
  9580. *
  9581. Retrieve the second acronym element and invoke
  9582. the cloneNode method. The
  9583. duplicate node returned by the method should copy the
  9584. attributes associated with this node.
  9585. * @author Curt Arnold
  9586. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  9587. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  9588. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
  9589. */
  9590. hc_nodecloneattributescopied: function(test) {
  9591. var doc = hc_staff.hc_staff();
  9592. var attributes = doc.getElementsByTagName("acronym").item(1).cloneNode(false).attributes;
  9593. var actual = [];
  9594. for(var i=0;i<attributes.length;i++) {
  9595. actual.push(attributes.item(i).nodeName);
  9596. }
  9597. test.deepEqual(actual, ["dir", "title", "class"], 'nodeNames');
  9598. test.done();
  9599. },
  9600. /**
  9601. *
  9602. The "cloneNode(deep)" method does not copy text unless it
  9603. is deep cloned.(Test for deep=false)
  9604. Retrieve the fourth child of the second employee and
  9605. the "cloneNode(deep)" method with deep=false. The
  9606. duplicate node returned by the method should not copy
  9607. any text data contained in this node.
  9608. * @author Curt Arnold
  9609. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
  9610. */
  9611. hc_nodeclonefalsenocopytext: function(test) {
  9612. var success;
  9613. var doc;
  9614. var elementList;
  9615. var employeeNode;
  9616. var childList;
  9617. var childNode;
  9618. var clonedNode;
  9619. var lastChildNode;
  9620. doc = hc_staff.hc_staff();
  9621. elementList = doc.getElementsByTagName("p");
  9622. employeeNode = elementList.item(1);
  9623. childList = employeeNode.childNodes;
  9624. childNode = childList.item(3);
  9625. clonedNode = childNode.cloneNode(false);
  9626. lastChildNode = clonedNode.lastChild;
  9627. test.equal(lastChildNode, null, 'nodeCloneFalseNoCopyText');
  9628. test.done();
  9629. },
  9630. /**
  9631. *
  9632. The duplicate node returned by the "cloneNode(deep)"
  9633. method does not have a ParentNode.
  9634. Retrieve the second employee and invoke the
  9635. "cloneNode(deep)" method with deep=false. The
  9636. duplicate node returned should return null when the
  9637. "getParentNode()" is invoked.
  9638. * @author Curt Arnold
  9639. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
  9640. */
  9641. hc_nodeclonegetparentnull: function(test) {
  9642. var success;
  9643. var doc;
  9644. var elementList;
  9645. var employeeNode;
  9646. var clonedNode;
  9647. var parentNode;
  9648. doc = hc_staff.hc_staff();
  9649. elementList = doc.getElementsByTagName("p");
  9650. employeeNode = elementList.item(1);
  9651. clonedNode = employeeNode.cloneNode(false);
  9652. parentNode = clonedNode.parentNode;
  9653. test.equal(parentNode, null, 'nodeCloneGetParentNull');
  9654. test.done();
  9655. },
  9656. /**
  9657. *
  9658. The "cloneNode(deep)" method returns a copy of the node
  9659. only if deep=false.
  9660. Retrieve the second employee and invoke the
  9661. "cloneNode(deep)" method with deep=false. The
  9662. method should only clone this node. The NodeName and
  9663. length of the NodeList are checked. The "getNodeName()"
  9664. method should return "employee" and the "getLength()"
  9665. method should return 0.
  9666. * @author Curt Arnold
  9667. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
  9668. */
  9669. hc_nodeclonenodefalse: function(test) {
  9670. var success;
  9671. var doc;
  9672. var elementList;
  9673. var employeeNode;
  9674. var clonedNode;
  9675. var cloneName;
  9676. var cloneChildren;
  9677. var length;
  9678. doc = hc_staff.hc_staff();
  9679. elementList = doc.getElementsByTagName("p");
  9680. employeeNode = elementList.item(1);
  9681. clonedNode = employeeNode.cloneNode(false);
  9682. cloneName = clonedNode.nodeName;
  9683. test.equal(cloneName, 'p', 'element strong');
  9684. cloneChildren = clonedNode.childNodes;
  9685. length = cloneChildren.length;
  9686. test.equal(length, 0, 'length');
  9687. test.done();
  9688. },
  9689. /**
  9690. *
  9691. The "cloneNode(deep)" method returns a copy of the node
  9692. and the subtree under it if deep=true.
  9693. Retrieve the second employee and invoke the
  9694. "cloneNode(deep)" method with deep=true. The
  9695. method should clone this node and the subtree under it.
  9696. The NodeName of each child in the returned node is
  9697. checked to insure the entire subtree under the second
  9698. employee was cloned.
  9699. * @author Curt Arnold
  9700. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
  9701. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  9702. */
  9703. hc_nodeclonenodetrue: function(test) {
  9704. var success;
  9705. var doc;
  9706. var elementList;
  9707. var employeeNode;
  9708. var clonedNode;
  9709. var clonedList;
  9710. var clonedChild;
  9711. var clonedChildName;
  9712. var origList;
  9713. var origChild;
  9714. var origChildName;
  9715. var result = new Array();
  9716. var expected = new Array();
  9717. doc = hc_staff.hc_staff();
  9718. elementList = doc.getElementsByTagName("p");
  9719. employeeNode = elementList.item(1);
  9720. origList = employeeNode.childNodes;
  9721. for(var indexN10065 = 0;indexN10065 < origList.length; indexN10065++) {
  9722. origChild = origList.item(indexN10065);
  9723. origChildName = origChild.nodeName;
  9724. expected[expected.length] = origChildName;
  9725. }
  9726. clonedNode = employeeNode.cloneNode(true);
  9727. clonedList = clonedNode.childNodes;
  9728. for(var indexN1007B = 0;indexN1007B < clonedList.length; indexN1007B++) {
  9729. clonedChild = clonedList.item(indexN1007B);
  9730. clonedChildName = clonedChild.nodeName;
  9731. result[result.length] = clonedChildName;
  9732. }
  9733. test.deepEqual(result, expected, 'clone');
  9734. test.done();
  9735. },
  9736. /**
  9737. *
  9738. The "cloneNode(deep)" method does not copy text unless it
  9739. is deep cloned.(Test for deep=true)
  9740. Retrieve the eighth child of the second employee and
  9741. the "cloneNode(deep)" method with deep=true. The
  9742. duplicate node returned by the method should copy
  9743. any text data contained in this node.
  9744. * @author Curt Arnold
  9745. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
  9746. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  9747. */
  9748. hc_nodeclonetruecopytext: function(test) {
  9749. var success;
  9750. var doc;
  9751. var elementList;
  9752. var childNode;
  9753. var clonedNode;
  9754. var lastChildNode;
  9755. var childValue;
  9756. doc = hc_staff.hc_staff();
  9757. elementList = doc.getElementsByTagName("sup");
  9758. childNode = elementList.item(1);
  9759. clonedNode = childNode.cloneNode(true);
  9760. lastChildNode = clonedNode.lastChild;
  9761. childValue = lastChildNode.nodeValue;
  9762. test.equal(childValue, '35,000', 'cloneContainsText');
  9763. test.done();
  9764. },
  9765. /**
  9766. *
  9767. The "getAttributes()" method invoked on a Comment
  9768. Node returns null.
  9769. Find any comment that is an immediate child of the root
  9770. and assert that Node.attributes is null. Then create
  9771. a new comment node (in case they had been omitted) and
  9772. make the assertion.
  9773. * @author Curt Arnold
  9774. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  9775. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
  9776. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=248
  9777. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=263
  9778. */
  9779. hc_nodecommentnodeattributes: function(test) {
  9780. var success;
  9781. var doc;
  9782. var commentNode;
  9783. var nodeList;
  9784. var attrList;
  9785. var nodeType;
  9786. doc = hc_staff.hc_staff();
  9787. nodeList = doc.childNodes;
  9788. for(var indexN10043 = 0;indexN10043 < nodeList.length; indexN10043++) {
  9789. commentNode = nodeList.item(indexN10043);
  9790. nodeType = commentNode.nodeType;
  9791. if(
  9792. (8 == nodeType)
  9793. ) {
  9794. attrList = commentNode.attributes;
  9795. test.equal(attrList, null, 'existingCommentAttributesNull');
  9796. }
  9797. }
  9798. commentNode = doc.createComment("This is a comment");
  9799. attrList = commentNode.attributes;
  9800. test.equal(attrList, null, 'createdCommentAttributesNull');
  9801. test.done();
  9802. },
  9803. /**
  9804. *
  9805. The string returned by the "getNodeName()" method for a
  9806. Comment Node is "#comment".
  9807. Retrieve the Comment node in the XML file
  9808. and check the string returned by the "getNodeName()"
  9809. method. It should be equal to "#comment".
  9810. * @author Curt Arnold
  9811. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  9812. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
  9813. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=248
  9814. */
  9815. hc_nodecommentnodename: function(test) {
  9816. var success;
  9817. var doc;
  9818. var elementList;
  9819. var commentNode;
  9820. var nodeType;
  9821. var commentName;
  9822. var commentNodeName;
  9823. doc = hc_staff.hc_staff();
  9824. elementList = doc.childNodes;
  9825. for(var indexN10044 = 0;indexN10044 < elementList.length; indexN10044++) {
  9826. commentNode = elementList.item(indexN10044);
  9827. nodeType = commentNode.nodeType;
  9828. if(
  9829. (8 == nodeType)
  9830. ) {
  9831. commentNodeName = commentNode.nodeName;
  9832. test.equal(commentNodeName, '#comment', 'existingNodeName');
  9833. }
  9834. }
  9835. commentNode = doc.createComment("This is a comment");
  9836. commentNodeName = commentNode.nodeName;
  9837. test.equal(commentNodeName, '#comment', 'createdNodeName');
  9838. test.done();
  9839. },
  9840. /**
  9841. *
  9842. The "getNodeType()" method for a Comment Node
  9843. returns the constant value 8.
  9844. Retrieve the nodes from the document and check for
  9845. a comment node and invoke the "getNodeType()" method. This should
  9846. return 8.
  9847. * @author Curt Arnold
  9848. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  9849. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
  9850. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=248
  9851. */
  9852. hc_nodecommentnodetype: function(test) {
  9853. var success;
  9854. var doc;
  9855. var testList;
  9856. var commentNode;
  9857. var commentNodeName;
  9858. var nodeType;
  9859. doc = hc_staff.hc_staff();
  9860. testList = doc.childNodes;
  9861. for(var indexN10040 = 0;indexN10040 < testList.length; indexN10040++) {
  9862. commentNode = testList.item(indexN10040);
  9863. commentNodeName = commentNode.nodeName;
  9864. if(
  9865. ("#comment" == commentNodeName)
  9866. ) {
  9867. nodeType = commentNode.nodeType;
  9868. test.equal(nodeType, 8, 'existingCommentNodeType');
  9869. }
  9870. }
  9871. commentNode = doc.createComment("This is a comment");
  9872. nodeType = commentNode.nodeType;
  9873. test.equal(nodeType, 8, 'createdCommentNodeType');
  9874. test.done();
  9875. },
  9876. /**
  9877. *
  9878. The string returned by the "getNodeValue()" method for a
  9879. Comment Node is the content of the comment.
  9880. Retrieve the comment in the XML file and
  9881. check the string returned by the "getNodeValue()" method.
  9882. It should be equal to "This is comment number 1".
  9883. * @author Curt Arnold
  9884. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  9885. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
  9886. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=248
  9887. */
  9888. hc_nodecommentnodevalue: function(test) {
  9889. var success;
  9890. var doc;
  9891. var elementList;
  9892. var commentNode;
  9893. var commentName;
  9894. var commentValue;
  9895. doc = hc_staff.hc_staff();
  9896. elementList = doc.childNodes;
  9897. for(var indexN10040 = 0;indexN10040 < elementList.length; indexN10040++) {
  9898. commentNode = elementList.item(indexN10040);
  9899. commentName = commentNode.nodeName;
  9900. if(
  9901. ("#comment" == commentName)
  9902. ) {
  9903. commentValue = commentNode.nodeValue;
  9904. test.equal(commentValue, ' This is comment number 1.', 'value');
  9905. }
  9906. }
  9907. commentNode = doc.createComment(" This is a comment");
  9908. commentValue = commentNode.nodeValue;
  9909. test.equal(commentValue, ' This is a comment', 'createdCommentNodeValue');
  9910. test.done();
  9911. },
  9912. /**
  9913. *
  9914. The string returned by the "getNodeName()" method for a
  9915. DocumentFragment Node is "#document-frament".
  9916. Retrieve the DOM document and invoke the
  9917. "createDocumentFragment()" method and check the string
  9918. returned by the "getNodeName()" method. It should be
  9919. equal to "#document-fragment".
  9920. * @author Curt Arnold
  9921. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  9922. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
  9923. */
  9924. hc_nodedocumentfragmentnodename: function(test) {
  9925. var success;
  9926. var doc;
  9927. var docFragment;
  9928. var documentFragmentName;
  9929. doc = hc_staff.hc_staff();
  9930. docFragment = doc.createDocumentFragment();
  9931. documentFragmentName = docFragment.nodeName;
  9932. test.equal(documentFragmentName, '#document-fragment', 'nodeDocumentFragmentNodeName');
  9933. test.done();
  9934. },
  9935. /**
  9936. *
  9937. The "getNodeType()" method for a DocumentFragment Node
  9938. returns the constant value 11.
  9939. Invoke the "createDocumentFragment()" method and
  9940. examine the NodeType of the document fragment
  9941. returned by the "getNodeType()" method. The method
  9942. should return 11.
  9943. * @author Curt Arnold
  9944. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  9945. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
  9946. */
  9947. hc_nodedocumentfragmentnodetype: function(test) {
  9948. var success;
  9949. var doc;
  9950. var documentFragmentNode;
  9951. var nodeType;
  9952. doc = hc_staff.hc_staff();
  9953. documentFragmentNode = doc.createDocumentFragment();
  9954. nodeType = documentFragmentNode.nodeType;
  9955. test.equal(nodeType, 11, 'nodeDocumentFragmentNodeType');
  9956. test.done();
  9957. },
  9958. /**
  9959. *
  9960. The string returned by the "getNodeValue()" method for a
  9961. DocumentFragment Node is null.
  9962. Retrieve the DOM document and invoke the
  9963. "createDocumentFragment()" method and check the string
  9964. returned by the "getNodeValue()" method. It should be
  9965. equal to null.
  9966. * @author Curt Arnold
  9967. * @author Curt Arnold
  9968. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
  9969. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  9970. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  9971. */
  9972. hc_nodedocumentfragmentnodevalue: function(test) {
  9973. var success;
  9974. var doc;
  9975. var docFragment;
  9976. var attrList;
  9977. var value;
  9978. doc = hc_staff.hc_staff();
  9979. docFragment = doc.createDocumentFragment();
  9980. attrList = docFragment.attributes;
  9981. test.equal(attrList, null, 'attributesNull');
  9982. value = docFragment.nodeValue;
  9983. test.equal(value, null, 'initiallyNull');
  9984. test.done();
  9985. },
  9986. /**
  9987. *
  9988. The "getAttributes()" method invoked on a Document
  9989. Node returns null.
  9990. Retrieve the DOM Document and invoke the
  9991. "getAttributes()" method on the Document Node.
  9992. It should return null.
  9993. * @author Curt Arnold
  9994. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  9995. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
  9996. */
  9997. hc_nodedocumentnodeattribute: function(test) {
  9998. var success;
  9999. var doc;
  10000. var attrList;
  10001. doc = hc_staff.hc_staff();
  10002. attrList = doc.attributes;
  10003. test.equal(attrList, null, 'doc_attributes_is_null');
  10004. test.done();
  10005. },
  10006. /**
  10007. *
  10008. The string returned by the "getNodeName()" method for a
  10009. Document Node is "#document".
  10010. Retrieve the DOM document and check the string returned
  10011. by the "getNodeName()" method. It should be equal to
  10012. "#document".
  10013. * @author Curt Arnold
  10014. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
  10015. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  10016. */
  10017. hc_nodedocumentnodename: function(test) {
  10018. var success;
  10019. var doc;
  10020. var documentName;
  10021. doc = hc_staff.hc_staff();
  10022. documentName = doc.nodeName;
  10023. test.equal(documentName, '#document', 'documentNodeName');
  10024. test.done();
  10025. },
  10026. /**
  10027. *
  10028. The "getNodeType()" method for a Document Node
  10029. returns the constant value 9.
  10030. Retrieve the document and invoke the "getNodeType()"
  10031. method. The method should return 9.
  10032. * @author Curt Arnold
  10033. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
  10034. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  10035. */
  10036. hc_nodedocumentnodetype: function(test) {
  10037. var success;
  10038. var doc;
  10039. var nodeType;
  10040. doc = hc_staff.hc_staff();
  10041. nodeType = doc.nodeType;
  10042. test.equal(nodeType, 9, 'nodeDocumentNodeType');
  10043. test.done();
  10044. },
  10045. /**
  10046. *
  10047. The string returned by the "getNodeValue()" method for a
  10048. Document Node is null.
  10049. Retrieve the DOM Document and check the string returned
  10050. by the "getNodeValue()" method. It should be equal to
  10051. null.
  10052. * @author Curt Arnold
  10053. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
  10054. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  10055. */
  10056. hc_nodedocumentnodevalue: function(test) {
  10057. var success;
  10058. var doc;
  10059. var documentValue;
  10060. doc = hc_staff.hc_staff();
  10061. documentValue = doc.nodeValue;
  10062. test.equal(documentValue, null, 'documentNodeValue');
  10063. test.done();
  10064. },
  10065. /**
  10066. *
  10067. Retrieve the third "acronym" element and evaluate Node.attributes.
  10068. * @author Curt Arnold
  10069. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  10070. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=236
  10071. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2003Jun/0011.html
  10072. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=184
  10073. */
  10074. hc_nodeelementnodeattributes: function(test) {
  10075. var doc = hc_staff.hc_staff();
  10076. var attributes = doc.getElementsByTagName("acronym").item(2).attributes;
  10077. var actual = [];
  10078. for(var i=0;i<attributes.length;i++) {
  10079. actual.push(attributes.item(i).nodeName);
  10080. }
  10081. test.deepEqual(actual, ["dir", "title", "class"], 'attrNames');
  10082. test.done();
  10083. },
  10084. /**
  10085. *
  10086. Retrieve the first Element Node(Root Node) of the
  10087. DOM object and check the string returned by the
  10088. "getNodeName()" method. It should be equal to its
  10089. tagName.
  10090. * @author Curt Arnold
  10091. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  10092. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
  10093. */
  10094. hc_nodeelementnodename: function(test) {
  10095. var success;
  10096. var doc;
  10097. var elementNode;
  10098. var elementName;
  10099. doc = hc_staff.hc_staff();
  10100. elementNode = doc.documentElement;
  10101. elementName = elementNode.nodeName;
  10102. test.equal(elementName, 'svg', 'svgNodeName');
  10103. test.done();
  10104. },
  10105. /**
  10106. *
  10107. The "getNodeType()" method for an Element Node
  10108. returns the constant value 1.
  10109. Retrieve the root node and invoke the "getNodeType()"
  10110. method. The method should return 1.
  10111. * @author Curt Arnold
  10112. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  10113. */
  10114. hc_nodeelementnodetype: function(test) {
  10115. var success;
  10116. var doc;
  10117. var rootNode;
  10118. var nodeType;
  10119. doc = hc_staff.hc_staff();
  10120. rootNode = doc.documentElement;
  10121. nodeType = rootNode.nodeType;
  10122. test.equal(nodeType, 1, 'nodeElementNodeType');
  10123. test.done();
  10124. },
  10125. /**
  10126. *
  10127. The string returned by the "getNodeValue()" method for an
  10128. Element Node is null.
  10129. * @author Curt Arnold
  10130. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  10131. */
  10132. hc_nodeelementnodevalue: function(test) {
  10133. var success;
  10134. var doc;
  10135. var elementNode;
  10136. var elementValue;
  10137. doc = hc_staff.hc_staff();
  10138. elementNode = doc.documentElement;
  10139. elementValue = elementNode.nodeValue;
  10140. test.equal(elementValue, null, 'elementNodeValue');
  10141. test.done();
  10142. },
  10143. /**
  10144. *
  10145. The "getFirstChild()" method returns the first child
  10146. of this node.
  10147. Retrieve the second employee and invoke the
  10148. "getFirstChild()" method. The NodeName returned
  10149. should be "#text" or "EM".
  10150. * @author Curt Arnold
  10151. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-169727388
  10152. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  10153. */
  10154. hc_nodegetfirstchild: function(test) {
  10155. var success;
  10156. var doc;
  10157. var elementList;
  10158. var employeeNode;
  10159. var fchildNode;
  10160. var childName;
  10161. var nodeType;
  10162. doc = hc_staff.hc_staff();
  10163. elementList = doc.getElementsByTagName("p");
  10164. employeeNode = elementList.item(1);
  10165. fchildNode = employeeNode.firstChild;
  10166. childName = fchildNode.nodeName;
  10167. if(
  10168. ("#text" == childName)
  10169. ) {
  10170. test.equal(childName, '#text', 'firstChild_w_whitespace');
  10171. }
  10172. else {
  10173. test.equal(childName, 'em', 'element firstChild_wo_whitespace');
  10174. }
  10175. test.done();
  10176. },
  10177. /**
  10178. *
  10179. If there is not a first child then the "getFirstChild()"
  10180. method returns null.
  10181. Retrieve the text of the first "em" element and invoke the "getFirstChild()" method. It
  10182. should return null.
  10183. * @author Curt Arnold
  10184. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-169727388
  10185. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  10186. */
  10187. hc_nodegetfirstchildnull: function(test) {
  10188. var success;
  10189. var doc;
  10190. var emList;
  10191. var emNode;
  10192. var emText;
  10193. var nullChild;
  10194. doc = hc_staff.hc_staff();
  10195. emList = doc.getElementsByTagName("em");
  10196. emNode = emList.item(0);
  10197. emText = emNode.firstChild;
  10198. nullChild = emText.firstChild;
  10199. test.equal(nullChild, null, 'nullChild');
  10200. test.done();
  10201. },
  10202. /**
  10203. *
  10204. The "getLastChild()" method returns the last child
  10205. of this node.
  10206. Retrieve the second employee and invoke the
  10207. "getLastChild()" method. The NodeName returned
  10208. should be "#text".
  10209. * @author Curt Arnold
  10210. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-61AD09FB
  10211. */
  10212. hc_nodegetlastchild: function(test) {
  10213. var success;
  10214. var doc;
  10215. var elementList;
  10216. var employeeNode;
  10217. var lchildNode;
  10218. var childName;
  10219. doc = hc_staff.hc_staff();
  10220. elementList = doc.getElementsByTagName("p");
  10221. employeeNode = elementList.item(1);
  10222. lchildNode = employeeNode.lastChild;
  10223. childName = lchildNode.nodeName;
  10224. test.equal(childName, '#text', 'whitespace');
  10225. test.done();
  10226. },
  10227. /**
  10228. *
  10229. If there is not a last child then the "getLastChild()"
  10230. method returns null.
  10231. Retrieve the text of the first "em" element and invoke the "getFirstChild()" method. It
  10232. should return null.
  10233. * @author Curt Arnold
  10234. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-61AD09FB
  10235. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  10236. */
  10237. hc_nodegetlastchildnull: function(test) {
  10238. var success;
  10239. var doc;
  10240. var emList;
  10241. var emNode;
  10242. var emText;
  10243. var nullChild;
  10244. doc = hc_staff.hc_staff();
  10245. emList = doc.getElementsByTagName("em");
  10246. emNode = emList.item(0);
  10247. emText = emNode.firstChild;
  10248. nullChild = emText.lastChild;
  10249. test.equal(nullChild, null, 'nullChild');
  10250. test.done();
  10251. },
  10252. /**
  10253. *
  10254. The "getNextSibling()" method returns the node immediately
  10255. following this node.
  10256. Retrieve the first child of the second employee and
  10257. invoke the "getNextSibling()" method. It should return
  10258. a node with the NodeName of "#text".
  10259. * @author Curt Arnold
  10260. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F
  10261. */
  10262. hc_nodegetnextsibling: function(test) {
  10263. var success;
  10264. var doc;
  10265. var elementList;
  10266. var emNode;
  10267. var nsNode;
  10268. var nsName;
  10269. doc = hc_staff.hc_staff();
  10270. elementList = doc.getElementsByTagName("em");
  10271. emNode = elementList.item(1);
  10272. nsNode = emNode.nextSibling;
  10273. nsName = nsNode.nodeName;
  10274. test.equal(nsName, '#text', 'whitespace');
  10275. test.done();
  10276. },
  10277. /**
  10278. *
  10279. If there is not a node immediately following this node the
  10280. "getNextSibling()" method returns null.
  10281. Retrieve the first child of the second employee and
  10282. invoke the "getNextSibling()" method. It should
  10283. be set to null.
  10284. * @author Curt Arnold
  10285. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F
  10286. */
  10287. hc_nodegetnextsiblingnull: function(test) {
  10288. var success;
  10289. var doc;
  10290. var elementList;
  10291. var employeeNode;
  10292. var lcNode;
  10293. var nsNode;
  10294. doc = hc_staff.hc_staff();
  10295. elementList = doc.getElementsByTagName("p");
  10296. employeeNode = elementList.item(1);
  10297. lcNode = employeeNode.lastChild;
  10298. //debug(lcNode === employeeNode.children.item(employeeNode.children.length));
  10299. nsNode = lcNode.nextSibling;
  10300. //debug(nsNode === lcNode);
  10301. test.equal(nsNode, null, 'nodeGetNextSiblingNull');
  10302. test.done();
  10303. },
  10304. /**
  10305. *
  10306. Evaluate Node.ownerDocument on the second "p" element.
  10307. * @author Curt Arnold
  10308. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#node-ownerDoc
  10309. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
  10310. */
  10311. hc_nodegetownerdocument: function(test) {
  10312. var success;
  10313. var doc;
  10314. var elementList;
  10315. var docNode;
  10316. var ownerDocument;
  10317. var docElement;
  10318. var elementName;
  10319. doc = hc_staff.hc_staff();
  10320. elementList = doc.getElementsByTagName("p");
  10321. docNode = elementList.item(1);
  10322. ownerDocument = docNode.ownerDocument;
  10323. docElement = ownerDocument.documentElement;
  10324. elementName = docElement.nodeName;
  10325. test.equal(elementName, 'svg', 'svgNodeName');
  10326. test.done();
  10327. },
  10328. /**
  10329. *
  10330. The "getOwnerDocument()" method returns null if the target
  10331. node itself is a document.
  10332. Invoke the "getOwnerDocument()" method on the master
  10333. document. The Document returned should be null.
  10334. * @author Curt Arnold
  10335. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#node-ownerDoc
  10336. */
  10337. hc_nodegetownerdocumentnull: function(test) {
  10338. var success;
  10339. var doc;
  10340. var ownerDocument;
  10341. doc = hc_staff.hc_staff();
  10342. ownerDocument = doc.ownerDocument;
  10343. test.equal(ownerDocument, null, 'nodeGetOwnerDocumentNull');
  10344. test.done();
  10345. },
  10346. /**
  10347. *
  10348. The "getPreviousSibling()" method returns the node
  10349. immediately preceding this node.
  10350. Retrieve the second child of the second employee and
  10351. invoke the "getPreviousSibling()" method. It should
  10352. return a node with a NodeName of "#text".
  10353. * @author Curt Arnold
  10354. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8
  10355. */
  10356. hc_nodegetprevioussibling: function(test) {
  10357. var success;
  10358. var doc;
  10359. var elementList;
  10360. var nameNode;
  10361. var psNode;
  10362. var psName;
  10363. doc = hc_staff.hc_staff();
  10364. elementList = doc.getElementsByTagName("strong");
  10365. nameNode = elementList.item(1);
  10366. psNode = nameNode.previousSibling;
  10367. psName = psNode.nodeName;
  10368. test.equal(psName, '#text', 'whitespace');
  10369. test.done();
  10370. },
  10371. /**
  10372. *
  10373. If there is not a node immediately preceding this node the
  10374. "getPreviousSibling()" method returns null.
  10375. Retrieve the first child of the second employee and
  10376. invoke the "getPreviousSibling()" method. It should
  10377. be set to null.
  10378. * @author Curt Arnold
  10379. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8
  10380. */
  10381. hc_nodegetprevioussiblingnull: function(test) {
  10382. var success;
  10383. var doc;
  10384. var elementList;
  10385. var employeeNode;
  10386. var fcNode;
  10387. var psNode;
  10388. doc = hc_staff.hc_staff();
  10389. elementList = doc.getElementsByTagName("p");
  10390. employeeNode = elementList.item(2);
  10391. fcNode = employeeNode.firstChild;
  10392. psNode = fcNode.previousSibling;
  10393. test.equal(psNode, null, 'nodeGetPreviousSiblingNull');
  10394. test.done();
  10395. },
  10396. /**
  10397. *
  10398. The "hasChildNodes()" method returns true if the node
  10399. has children.
  10400. Retrieve the root node("staff") and invoke the
  10401. "hasChildNodes()" method. It should return the boolean
  10402. value "true".
  10403. * @author Curt Arnold
  10404. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-810594187
  10405. */
  10406. hc_nodehaschildnodes: function(test) {
  10407. var success;
  10408. var doc;
  10409. var elementList;
  10410. var employeeNode;
  10411. var state;
  10412. doc = hc_staff.hc_staff();
  10413. elementList = doc.getElementsByTagName("p");
  10414. employeeNode = elementList.item(1);
  10415. state = employeeNode.hasChildNodes();
  10416. test.ok(state, 'nodeHasChild');
  10417. test.done();
  10418. },
  10419. /**
  10420. *
  10421. The "hasChildNodes()" method returns false if the node
  10422. does not have any children.
  10423. Retrieve the text of the first "em" element and invoke the "hasChildNodes()" method. It
  10424. should return false.
  10425. * @author Curt Arnold
  10426. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  10427. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-810594187
  10428. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  10429. */
  10430. hc_nodehaschildnodesfalse: function(test) {
  10431. var success;
  10432. var doc;
  10433. var emList;
  10434. var emNode;
  10435. var emText;
  10436. var hasChild;
  10437. doc = hc_staff.hc_staff();
  10438. emList = doc.getElementsByTagName("em");
  10439. emNode = emList.item(0);
  10440. emText = emNode.firstChild;
  10441. hasChild = emText.hasChildNodes();
  10442. test.equal(hasChild, false, 'hasChild');
  10443. test.done();
  10444. },
  10445. /**
  10446. *
  10447. The "insertBefore(newChild,refChild)" method inserts the
  10448. node "newChild" before the node "refChild".
  10449. Insert a newly created Element node before the second
  10450. sup element in the document and check the "newChild"
  10451. and "refChild" after insertion for correct placement.
  10452. * @author Curt Arnold
  10453. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  10454. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  10455. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  10456. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=261
  10457. */
  10458. hc_nodeinsertbefore: function(test) {
  10459. var success;
  10460. var doc;
  10461. var elementList;
  10462. var employeeNode;
  10463. var childList;
  10464. var refChild;
  10465. var newChild;
  10466. var child;
  10467. var childName;
  10468. var insertedNode;
  10469. var actual = new Array();
  10470. expected = new Array();
  10471. expected[0] = "em";
  10472. expected[1] = "strong";
  10473. expected[2] = "code";
  10474. expected[3] = "br";
  10475. expected[4] = "sup";
  10476. expected[5] = "var";
  10477. expected[6] = "acronym";
  10478. var nodeType;
  10479. doc = hc_staff.hc_staff();
  10480. elementList = doc.getElementsByTagName("sup");
  10481. refChild = elementList.item(2);
  10482. employeeNode = refChild.parentNode;
  10483. childList = employeeNode.childNodes;
  10484. newChild = doc.createElement("br");
  10485. insertedNode = employeeNode.insertBefore(newChild,refChild);
  10486. for(var indexN10091 = 0;indexN10091 < childList.length; indexN10091++) {
  10487. child = childList.item(indexN10091);
  10488. nodeType = child.nodeType;
  10489. if(
  10490. (1 == nodeType)
  10491. ) {
  10492. childName = child.nodeName;
  10493. actual[actual.length] = childName;
  10494. }
  10495. }
  10496. test.deepEqual(actual, expected, 'element nodeNames');
  10497. test.done();
  10498. },
  10499. /**
  10500. *
  10501. If the "newChild" is a DocumentFragment object then all
  10502. its children are inserted in the same order before the
  10503. the "refChild".
  10504. Create a DocumentFragment object and populate it with
  10505. two Element nodes. Retrieve the second employee and
  10506. insert the newly created DocumentFragment before its
  10507. fourth child. The second employee should now have two
  10508. extra children("newChild1" and "newChild2") at
  10509. positions fourth and fifth respectively.
  10510. * @author Curt Arnold
  10511. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  10512. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  10513. */
  10514. hc_nodeinsertbeforedocfragment: function(test) {
  10515. var success;
  10516. var doc;
  10517. var elementList;
  10518. var employeeNode;
  10519. var childList;
  10520. var refChild;
  10521. var newdocFragment;
  10522. var newChild1;
  10523. var newChild2;
  10524. var child;
  10525. var childName;
  10526. var appendedChild;
  10527. var insertedNode;
  10528. doc = hc_staff.hc_staff();
  10529. elementList = doc.getElementsByTagName("p");
  10530. employeeNode = elementList.item(1);
  10531. childList = employeeNode.childNodes;
  10532. refChild = childList.item(3);
  10533. newdocFragment = doc.createDocumentFragment();
  10534. newChild1 = doc.createElement("br");
  10535. newChild2 = doc.createElement("b");
  10536. appendedChild = newdocFragment.appendChild(newChild1);
  10537. appendedChild = newdocFragment.appendChild(newChild2);
  10538. insertedNode = employeeNode.insertBefore(newdocFragment,refChild);
  10539. child = childList.item(3);
  10540. childName = child.nodeName;
  10541. test.equal(childName, 'br', 'element childName3');
  10542. child = childList.item(4);
  10543. childName = child.nodeName;
  10544. test.equal(childName, 'b', 'element childName4');
  10545. test.done();
  10546. },
  10547. /**
  10548. *
  10549. The "insertBefore(newChild,refChild)" method raises a
  10550. HIERARCHY_REQUEST_ERR DOMException if this node is of
  10551. a type that does not allow children of the type "newChild"
  10552. to be inserted.
  10553. Retrieve the root node and attempt to insert a newly
  10554. created Attr node. An Element node cannot have children
  10555. of the "Attr" type, therefore the desired exception
  10556. should be raised.
  10557. * @author Curt Arnold
  10558. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
  10559. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  10560. * @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'])
  10561. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  10562. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  10563. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  10564. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=406
  10565. */
  10566. hc_nodeinsertbeforeinvalidnodetype: function(test) {
  10567. var success;
  10568. var doc;
  10569. var rootNode;
  10570. var newChild;
  10571. var elementList;
  10572. var refChild;
  10573. var insertedNode;
  10574. doc = hc_staff.hc_staff();
  10575. newChild = doc.createAttribute("title");
  10576. elementList = doc.getElementsByTagName("p");
  10577. refChild = elementList.item(1);
  10578. rootNode = refChild.parentNode;
  10579. {
  10580. success = false;
  10581. try {
  10582. insertedNode = rootNode.insertBefore(newChild,refChild);
  10583. }
  10584. catch(ex) {
  10585. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  10586. }
  10587. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  10588. }
  10589. test.done();
  10590. },
  10591. /**
  10592. *
  10593. The "insertBefore(newChild,refChild)" method raises a
  10594. WRONG_DOCUMENT_ERR DOMException if the "newChild" was
  10595. created from a different document than the one that
  10596. created this node.
  10597. Retrieve the second employee and attempt to insert a new
  10598. child that was created from a different document than the
  10599. one that created the second employee. An attempt to
  10600. insert such a child should raise the desired exception.
  10601. * @author Curt Arnold
  10602. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])
  10603. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  10604. * @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'])
  10605. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  10606. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  10607. */
  10608. hc_nodeinsertbeforenewchilddiffdocument: function(test) {
  10609. var success;
  10610. var doc1;
  10611. var doc2;
  10612. var refChild;
  10613. var newChild;
  10614. var elementList;
  10615. var elementNode;
  10616. var insertedNode;
  10617. var doc1Ref = null;
  10618. if (typeof(this.doc1) != 'undefined') {
  10619. doc1Ref = this.doc1;
  10620. }
  10621. doc1 = hc_staff.hc_staff();
  10622. var doc2Ref = null;
  10623. if (typeof(this.doc2) != 'undefined') {
  10624. doc2Ref = this.doc2;
  10625. }
  10626. doc2 = hc_staff.hc_staff();
  10627. newChild = doc1.createElement("br");
  10628. elementList = doc2.getElementsByTagName("p");
  10629. elementNode = elementList.item(1);
  10630. refChild = elementNode.firstChild;
  10631. {
  10632. success = false;
  10633. try {
  10634. insertedNode = elementNode.insertBefore(newChild,refChild);
  10635. }
  10636. catch(ex) {
  10637. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  10638. }
  10639. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  10640. }
  10641. test.done();
  10642. },
  10643. /**
  10644. *
  10645. If the "newChild" is already in the tree, the
  10646. "insertBefore(newChild,refChild)" method must first
  10647. remove it before the insertion takes place.
  10648. Insert a node Element ("em") that is already
  10649. present in the tree. The existing node should be
  10650. removed first and the new one inserted. The node is
  10651. inserted at a different position in the tree to assure
  10652. that it was indeed inserted.
  10653. * @author Curt Arnold
  10654. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  10655. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  10656. */
  10657. hc_nodeinsertbeforenewchildexists: function(test) {
  10658. var success;
  10659. var doc;
  10660. var elementList;
  10661. var employeeNode;
  10662. var childList;
  10663. var refChild;
  10664. var newChild;
  10665. var child;
  10666. var childName;
  10667. var insertedNode;
  10668. expected = new Array();
  10669. expected[0] = "strong";
  10670. expected[1] = "code";
  10671. expected[2] = "sup";
  10672. expected[3] = "var";
  10673. expected[4] = "em";
  10674. expected[5] = "acronym";
  10675. var result = new Array();
  10676. var nodeType;
  10677. doc = hc_staff.hc_staff();
  10678. elementList = doc.getElementsByTagName("p");
  10679. employeeNode = elementList.item(1);
  10680. childList = employeeNode.getElementsByTagName("*");
  10681. refChild = childList.item(5);
  10682. newChild = childList.item(0);
  10683. insertedNode = employeeNode.insertBefore(newChild,refChild);
  10684. for(var indexN1008C = 0;indexN1008C < childList.length; indexN1008C++) {
  10685. child = childList.item(indexN1008C);
  10686. nodeType = child.nodeType;
  10687. if(
  10688. (1 == nodeType)
  10689. ) {
  10690. childName = child.nodeName;
  10691. result[result.length] = childName;
  10692. }
  10693. }
  10694. test.deepEqual(result, expected, 'element childNames');
  10695. test.done();
  10696. },
  10697. /**
  10698. *
  10699. The "insertBefore(newChild,refChild)" method raises a
  10700. HIERARCHY_REQUEST_ERR DOMException if the node to be
  10701. inserted is one of this nodes ancestors.
  10702. Retrieve the second employee and attempt to insert a
  10703. node that is one of its ancestors(root node). An
  10704. attempt to insert such a node should raise the
  10705. desired exception.
  10706. * @author Curt Arnold
  10707. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
  10708. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  10709. * @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'])
  10710. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  10711. */
  10712. hc_nodeinsertbeforenodeancestor: function(test) {
  10713. var success;
  10714. var doc;
  10715. var newChild;
  10716. var elementList;
  10717. var employeeNode;
  10718. var childList;
  10719. var refChild;
  10720. var insertedNode;
  10721. doc = hc_staff.hc_staff();
  10722. newChild = doc.documentElement;
  10723. elementList = doc.getElementsByTagName("p");
  10724. employeeNode = elementList.item(1);
  10725. childList = employeeNode.childNodes;
  10726. refChild = childList.item(0);
  10727. {
  10728. success = false;
  10729. try {
  10730. insertedNode = employeeNode.insertBefore(newChild,refChild);
  10731. }
  10732. catch(ex) {
  10733. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  10734. }
  10735. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  10736. }
  10737. test.done();
  10738. },
  10739. /**
  10740. *
  10741. The "insertBefore(newChild,refchild)" method returns
  10742. the node being inserted.
  10743. Insert an Element node before the fourth
  10744. child of the second employee and check the node
  10745. returned from the "insertBefore(newChild,refChild)"
  10746. method. The node returned should be "newChild".
  10747. * @author Curt Arnold
  10748. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  10749. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  10750. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  10751. */
  10752. hc_nodeinsertbeforenodename: function(test) {
  10753. var success;
  10754. var doc;
  10755. var elementList;
  10756. var employeeNode;
  10757. var childList;
  10758. var refChild;
  10759. var newChild;
  10760. var insertedNode;
  10761. var childName;
  10762. doc = hc_staff.hc_staff();
  10763. elementList = doc.getElementsByTagName("p");
  10764. employeeNode = elementList.item(1);
  10765. childList = employeeNode.childNodes;
  10766. refChild = childList.item(3);
  10767. newChild = doc.createElement("br");
  10768. insertedNode = employeeNode.insertBefore(newChild,refChild);
  10769. childName = insertedNode.nodeName;
  10770. test.equal(childName, 'br', 'element nodeName');
  10771. test.done();
  10772. },
  10773. /**
  10774. *
  10775. The "insertBefore(newChild,refChild)" method raises a
  10776. NOT_FOUND_ERR DOMException if the reference child is
  10777. not a child of this node.
  10778. Retrieve the second employee and attempt to insert a
  10779. new node before a reference node that is not a child
  10780. of this node. An attempt to insert before a non child
  10781. node should raise the desired exception.
  10782. * @author Curt Arnold
  10783. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
  10784. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  10785. * @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'])
  10786. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  10787. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  10788. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  10789. */
  10790. hc_nodeinsertbeforerefchildnonexistent: function(test) {
  10791. var success;
  10792. var doc;
  10793. var refChild;
  10794. var newChild;
  10795. var elementList;
  10796. var elementNode;
  10797. var insertedNode;
  10798. doc = hc_staff.hc_staff();
  10799. newChild = doc.createElement("br");
  10800. refChild = doc.createElement("b");
  10801. elementList = doc.getElementsByTagName("p");
  10802. elementNode = elementList.item(1);
  10803. {
  10804. success = false;
  10805. try {
  10806. insertedNode = elementNode.insertBefore(newChild,refChild);
  10807. }
  10808. catch(ex) {
  10809. success = (typeof(ex.code) != 'undefined' && ex.code == 8);
  10810. }
  10811. test.ok(success, 'throw_NOT_FOUND_ERR');
  10812. }
  10813. test.done();
  10814. },
  10815. /**
  10816. *
  10817. If the "refChild" is null then the
  10818. "insertBefore(newChild,refChild)" method inserts the
  10819. node "newChild" at the end of the list of children.
  10820. Retrieve the second employee and invoke the
  10821. "insertBefore(newChild,refChild)" method with
  10822. refChild=null. Since "refChild" is null the "newChild"
  10823. should be added to the end of the list. The last item
  10824. in the list is checked after insertion. The last Element
  10825. node of the list should be "newChild".
  10826. * @author Curt Arnold
  10827. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  10828. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  10829. */
  10830. hc_nodeinsertbeforerefchildnull: function(test) {
  10831. var success;
  10832. var doc;
  10833. var elementList;
  10834. var employeeNode;
  10835. var childList;
  10836. var refChild = null;
  10837. var newChild;
  10838. var child;
  10839. var childName;
  10840. var insertedNode;
  10841. doc = hc_staff.hc_staff();
  10842. elementList = doc.getElementsByTagName("p");
  10843. employeeNode = elementList.item(1);
  10844. childList = employeeNode.childNodes;
  10845. newChild = doc.createElement("br");
  10846. insertedNode = employeeNode.insertBefore(newChild,refChild);
  10847. child = employeeNode.lastChild;
  10848. childName = child.nodeName;
  10849. test.equal(childName, 'br', 'element nodeName');
  10850. test.done();
  10851. },
  10852. /**
  10853. *
  10854. Create a list of all the children elements of the third
  10855. employee and access its first child by using an index
  10856. of 0. This should result in the whitspace before "em" being
  10857. selected (em when ignoring whitespace).
  10858. Further we evaluate its content(by using
  10859. the "getNodeName()" method) to ensure the proper
  10860. element was accessed.
  10861. * @author Curt Arnold
  10862. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
  10863. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  10864. */
  10865. hc_nodelistindexequalzero: function(test) {
  10866. var success;
  10867. var doc;
  10868. var elementList;
  10869. var employeeNode;
  10870. var employeeList;
  10871. var child;
  10872. var childName;
  10873. var length;
  10874. doc = hc_staff.hc_staff();
  10875. elementList = doc.getElementsByTagName("p");
  10876. employeeNode = elementList.item(2);
  10877. employeeList = employeeNode.childNodes;
  10878. length = employeeList.length;
  10879. child = employeeList.item(0);
  10880. childName = child.nodeName;
  10881. if(
  10882. (13 == length)
  10883. ) {
  10884. test.equal(childName, '#text', 'childName_w_whitespace');
  10885. }
  10886. else {
  10887. test.equal(childName, 'em', 'element childName_wo_whitespace');
  10888. }
  10889. test.done();
  10890. },
  10891. /**
  10892. *
  10893. The "getLength()" method returns the number of nodes
  10894. in the list.
  10895. Create a list of all the children elements of the third
  10896. employee and invoke the "getLength()" method.
  10897. It should contain the value 13.
  10898. * @author Curt Arnold
  10899. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337
  10900. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  10901. */
  10902. hc_nodelistindexgetlength: function(test) {
  10903. var success;
  10904. var doc;
  10905. var elementList;
  10906. var employeeNode;
  10907. var employeeList;
  10908. var length;
  10909. doc = hc_staff.hc_staff();
  10910. elementList = doc.getElementsByTagName("p");
  10911. employeeNode = elementList.item(2);
  10912. employeeList = employeeNode.childNodes;
  10913. length = employeeList.length;
  10914. if(
  10915. (6 == length)
  10916. ) {
  10917. test.equal(length, 6, 'length_wo_space');
  10918. }
  10919. else {
  10920. test.equal(length, 13, 'length_w_space');
  10921. }
  10922. test.done();
  10923. },
  10924. /**
  10925. *
  10926. The "getLength()" method returns the number of nodes
  10927. in the list.(Test for EMPTY list)
  10928. Create a list of all the children of the Text node
  10929. inside the first child of the third employee and
  10930. invoke the "getLength()" method. It should contain
  10931. the value 0.
  10932. * @author Curt Arnold
  10933. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337
  10934. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  10935. */
  10936. hc_nodelistindexgetlengthofemptylist: function(test) {
  10937. var success;
  10938. var doc;
  10939. var emList;
  10940. var emNode;
  10941. var textNode;
  10942. var textList;
  10943. var length;
  10944. doc = hc_staff.hc_staff();
  10945. emList = doc.getElementsByTagName("em");
  10946. emNode = emList.item(2);
  10947. textNode = emNode.firstChild;
  10948. textList = textNode.childNodes;
  10949. length = textList.length;
  10950. test.equal(length, 0, 'length');
  10951. test.done();
  10952. },
  10953. /**
  10954. *
  10955. The items in the list are accessible via an integral
  10956. index starting from zero.
  10957. (Index not equal 0)
  10958. Create a list of all the children elements of the third
  10959. employee and access its fourth child by using an index
  10960. of 3 and calling getNodeName() which should return
  10961. "strong" (no whitespace) or "#text" (with whitespace).
  10962. * @author Curt Arnold
  10963. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
  10964. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  10965. */
  10966. hc_nodelistindexnotzero: function(test) {
  10967. var success;
  10968. var doc;
  10969. var elementList;
  10970. var employeeNode;
  10971. var employeeList;
  10972. var child;
  10973. var childName;
  10974. doc = hc_staff.hc_staff();
  10975. elementList = doc.getElementsByTagName("p");
  10976. employeeNode = elementList.item(2);
  10977. employeeList = employeeNode.childNodes;
  10978. child = employeeList.item(3);
  10979. childName = child.nodeName;
  10980. if(
  10981. ("#text" == childName)
  10982. ) {
  10983. test.equal(childName, '#text', 'childName_space');
  10984. }
  10985. else {
  10986. test.equal(childName, 'strong', 'element childName_strong');
  10987. }
  10988. test.done();
  10989. },
  10990. /**
  10991. *
  10992. Create a list of all the children elements of the third
  10993. employee and access its first child by invoking the
  10994. "item(index)" method with an index=0. This should
  10995. result in node with a nodeName of "#text" or "em".
  10996. * @author Curt Arnold
  10997. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
  10998. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  10999. */
  11000. hc_nodelistreturnfirstitem: function(test) {
  11001. var success;
  11002. var doc;
  11003. var elementList;
  11004. var employeeNode;
  11005. var employeeList;
  11006. var child;
  11007. var childName;
  11008. doc = hc_staff.hc_staff();
  11009. elementList = doc.getElementsByTagName("p");
  11010. employeeNode = elementList.item(2);
  11011. employeeList = employeeNode.childNodes;
  11012. child = employeeList.item(0);
  11013. childName = child.nodeName;
  11014. if(
  11015. ("#text" == childName)
  11016. ) {
  11017. test.equal(childName, '#text', 'nodeName_w_space');
  11018. }
  11019. else {
  11020. test.equal(childName, 'em', 'element nodeName_wo_space');
  11021. }
  11022. test.done();
  11023. },
  11024. /**
  11025. *
  11026. Create a list of all the children elements of the third
  11027. employee and access its last child by invoking the
  11028. "item(index)" method with an index=length-1. This should
  11029. result in node with nodeName="#text" or acronym.
  11030. * @author Curt Arnold
  11031. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
  11032. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  11033. */
  11034. hc_nodelistreturnlastitem: function(test) {
  11035. var success;
  11036. var doc;
  11037. var elementList;
  11038. var employeeNode;
  11039. var employeeList;
  11040. var child;
  11041. var childName;
  11042. var index;
  11043. doc = hc_staff.hc_staff();
  11044. elementList = doc.getElementsByTagName("p");
  11045. employeeNode = elementList.item(2);
  11046. employeeList = employeeNode.childNodes;
  11047. index = employeeList.length;
  11048. index -= 1;
  11049. child = employeeList.item(index);
  11050. childName = child.nodeName;
  11051. if(
  11052. (12 == index)
  11053. ) {
  11054. test.equal(childName, '#text', 'lastNodeName_w_whitespace');
  11055. }
  11056. else {
  11057. test.equal(childName, 'acronym', 'element lastNodeName');
  11058. test.equal(index, 5, 'index');
  11059. }
  11060. test.done();
  11061. },
  11062. /**
  11063. *
  11064. The range of valid child node indices is 0 thru length -1
  11065. Create a list of all the children elements of the third
  11066. employee and traverse the list from index=0 thru
  11067. length -1.
  11068. * @author Curt Arnold
  11069. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337
  11070. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
  11071. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  11072. */
  11073. hc_nodelisttraverselist: function(test) {
  11074. var success;
  11075. var doc;
  11076. var elementList;
  11077. var employeeNode;
  11078. var employeeList;
  11079. var child;
  11080. var childName;
  11081. var nodeType;
  11082. var result = new Array();
  11083. expected = new Array();
  11084. expected[0] = "em";
  11085. expected[1] = "strong";
  11086. expected[2] = "code";
  11087. expected[3] = "sup";
  11088. expected[4] = "var";
  11089. expected[5] = "acronym";
  11090. doc = hc_staff.hc_staff();
  11091. elementList = doc.getElementsByTagName("p");
  11092. employeeNode = elementList.item(2);
  11093. employeeList = employeeNode.childNodes;
  11094. for(var indexN10073 = 0;indexN10073 < employeeList.length; indexN10073++) {
  11095. child = employeeList.item(indexN10073);
  11096. nodeType = child.nodeType;
  11097. childName = child.nodeName;
  11098. if(
  11099. (1 == nodeType)
  11100. ) {
  11101. result[result.length] = childName;
  11102. }
  11103. else {
  11104. test.equal(nodeType, 3, 'textNodeType');
  11105. test.equal(childName, '#text', 'textNodeName');
  11106. }
  11107. }
  11108. test.deepEqual(result, expected, 'element nodeNames');
  11109. test.done();
  11110. },
  11111. /**
  11112. *
  11113. The "getParentNode()" method returns the parent
  11114. of this node.
  11115. Retrieve the second employee and invoke the
  11116. "getParentNode()" method on this node. It should
  11117. be set to "body".
  11118. * @author Curt Arnold
  11119. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317
  11120. */
  11121. hc_nodeparentnode: function(test) {
  11122. var success;
  11123. var doc;
  11124. var elementList;
  11125. var employeeNode;
  11126. var parentNode;
  11127. var parentName;
  11128. doc = hc_staff.hc_staff();
  11129. elementList = doc.getElementsByTagName("p");
  11130. employeeNode = elementList.item(1);
  11131. parentNode = employeeNode.parentNode;
  11132. parentName = parentNode.nodeName;
  11133. test.equal(parentName, 'body', 'element parentNodeName');
  11134. test.done();
  11135. },
  11136. /**
  11137. *
  11138. The "getParentNode()" method invoked on a node that has
  11139. just been created and not yet added to the tree is null.
  11140. Create a new "employee" Element node using the
  11141. "createElement(name)" method from the Document interface.
  11142. Since this new node has not yet been added to the tree,
  11143. the "getParentNode()" method will return null.
  11144. * @author Curt Arnold
  11145. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317
  11146. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  11147. */
  11148. hc_nodeparentnodenull: function(test) {
  11149. var success;
  11150. var doc;
  11151. var createdNode;
  11152. var parentNode;
  11153. doc = hc_staff.hc_staff();
  11154. createdNode = doc.createElement("br");
  11155. parentNode = createdNode.parentNode;
  11156. test.equal(parentNode, null, 'parentNode');
  11157. test.done();
  11158. },
  11159. /**
  11160. *
  11161. The "removeChild(oldChild)" method removes the child node
  11162. indicated by "oldChild" from the list of children and
  11163. returns it.
  11164. Remove the first employee by invoking the
  11165. "removeChild(oldChild)" method an checking the
  11166. node returned by the "getParentNode()" method. It
  11167. should be set to null.
  11168. * @author Curt Arnold
  11169. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  11170. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  11171. */
  11172. hc_noderemovechild: function(test) {
  11173. var success;
  11174. var doc;
  11175. var rootNode;
  11176. var childList;
  11177. var childToRemove;
  11178. var removedChild;
  11179. var parentNode;
  11180. doc = hc_staff.hc_staff();
  11181. rootNode = doc.documentElement;
  11182. childList = rootNode.childNodes;
  11183. childToRemove = childList.item(1);
  11184. removedChild = rootNode.removeChild(childToRemove);
  11185. parentNode = removedChild.parentNode;
  11186. test.equal(parentNode, null, 'parentNodeNull');
  11187. test.done();
  11188. },
  11189. /**
  11190. *
  11191. The "removeChild(oldChild)" method returns
  11192. the node being removed.
  11193. Remove the first child of the second employee
  11194. and check the NodeName returned by the
  11195. "removeChild(oldChild)" method. The returned node
  11196. should have a NodeName equal to "#text".
  11197. * @author Curt Arnold
  11198. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  11199. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  11200. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  11201. */
  11202. hc_noderemovechildgetnodename: function(test) {
  11203. var success;
  11204. var doc;
  11205. var elementList;
  11206. var employeeNode;
  11207. var childList;
  11208. var oldChild;
  11209. var removedChild;
  11210. var childName;
  11211. var oldName;
  11212. doc = hc_staff.hc_staff();
  11213. elementList = doc.getElementsByTagName("p");
  11214. employeeNode = elementList.item(1);
  11215. childList = employeeNode.childNodes;
  11216. oldChild = childList.item(0);
  11217. oldName = oldChild.nodeName;
  11218. removedChild = employeeNode.removeChild(oldChild);
  11219. test.notEqual(removedChild, null, 'notnull');
  11220. childName = removedChild.nodeName;
  11221. test.equal(childName, oldName, 'nodeName');
  11222. test.done();
  11223. },
  11224. /**
  11225. *
  11226. The "removeChild(oldChild)" method removes the node
  11227. indicated by "oldChild".
  11228. Retrieve the second p element and remove its first child.
  11229. After the removal, the second p element should have 5 element
  11230. children and the first child should now be the child
  11231. that used to be at the second position in the list.
  11232. * @author Curt Arnold
  11233. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  11234. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  11235. */
  11236. hc_noderemovechildnode: function(test) {
  11237. var success;
  11238. var doc;
  11239. var elementList;
  11240. var emList;
  11241. var employeeNode;
  11242. var childList;
  11243. var oldChild;
  11244. var child;
  11245. var childName;
  11246. var length;
  11247. var removedChild;
  11248. var removedName;
  11249. var nodeType;
  11250. expected = new Array();
  11251. expected[0] = "strong";
  11252. expected[1] = "code";
  11253. expected[2] = "sup";
  11254. expected[3] = "var";
  11255. expected[4] = "acronym";
  11256. var actual = new Array();
  11257. doc = hc_staff.hc_staff();
  11258. elementList = doc.getElementsByTagName("p");
  11259. employeeNode = elementList.item(1);
  11260. childList = employeeNode.childNodes;
  11261. emList = employeeNode.getElementsByTagName("em");
  11262. oldChild = emList.item(0);
  11263. removedChild = employeeNode.removeChild(oldChild);
  11264. removedName = removedChild.nodeName;
  11265. test.equal(removedName, 'em', 'element removedName');
  11266. for(var indexN10098 = 0;indexN10098 < childList.length; indexN10098++) {
  11267. child = childList.item(indexN10098);
  11268. nodeType = child.nodeType;
  11269. childName = child.nodeName;
  11270. if(
  11271. (1 == nodeType)
  11272. ) {
  11273. actual[actual.length] = childName;
  11274. }
  11275. else {
  11276. test.equal(nodeType, 3, 'textNodeType');
  11277. test.equal(childName, '#text', 'textNodeName');
  11278. }
  11279. }
  11280. test.deepEqual(actual, expected, 'element childNames');
  11281. test.done();
  11282. },
  11283. /**
  11284. *
  11285. The "removeChild(oldChild)" method raises a
  11286. NOT_FOUND_ERR DOMException if the old child is
  11287. not a child of this node.
  11288. Retrieve the second employee and attempt to remove a
  11289. node that is not one of its children. An attempt to
  11290. remove such a node should raise the desired exception.
  11291. * @author Curt Arnold
  11292. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
  11293. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  11294. * @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'])
  11295. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  11296. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  11297. */
  11298. hc_noderemovechildoldchildnonexistent: function(test) {
  11299. var success;
  11300. var doc;
  11301. var oldChild;
  11302. var elementList;
  11303. var elementNode;
  11304. var removedChild;
  11305. doc = hc_staff.hc_staff();
  11306. oldChild = doc.createElement("br");
  11307. elementList = doc.getElementsByTagName("p");
  11308. elementNode = elementList.item(1);
  11309. {
  11310. success = false;
  11311. try {
  11312. removedChild = elementNode.removeChild(oldChild);
  11313. }
  11314. catch(ex) {
  11315. success = (typeof(ex.code) != 'undefined' && ex.code == 8);
  11316. }
  11317. test.ok(success, 'throw_NOT_FOUND_ERR');
  11318. }
  11319. test.done();
  11320. },
  11321. /**
  11322. *
  11323. The "replaceChild(newChild,oldChild)" method replaces
  11324. the node "oldChild" with the node "newChild".
  11325. Replace the first element of the second employee with
  11326. a newly created Element node. Check the first position
  11327. after the replacement operation is completed. The new
  11328. Element should be "newChild".
  11329. * @author Curt Arnold
  11330. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  11331. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  11332. */
  11333. hc_nodereplacechild: function(test) {
  11334. var success;
  11335. var doc;
  11336. var elementList;
  11337. var employeeNode;
  11338. var childList;
  11339. var oldChild;
  11340. var newChild;
  11341. var child;
  11342. var childName;
  11343. var replacedNode;
  11344. doc = hc_staff.hc_staff();
  11345. elementList = doc.getElementsByTagName("p");
  11346. employeeNode = elementList.item(1);
  11347. childList = employeeNode.childNodes;
  11348. oldChild = childList.item(0);
  11349. newChild = doc.createElement("br");
  11350. replacedNode = employeeNode.replaceChild(newChild,oldChild);
  11351. child = childList.item(0);
  11352. childName = child.nodeName;
  11353. test.equal(childName, 'br', 'element nodeName');
  11354. test.done();
  11355. },
  11356. /**
  11357. *
  11358. The "replaceChild(newChild,oldChild)" method raises a
  11359. HIERARCHY_REQUEST_ERR DOMException if this node is of
  11360. a type that does not allow children of the type "newChild"
  11361. to be inserted.
  11362. Retrieve the root node and attempt to replace
  11363. one of its children with a newly created Attr node.
  11364. An Element node cannot have children of the "Attr"
  11365. type, therefore the desired exception should be raised.
  11366. * @author Curt Arnold
  11367. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
  11368. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  11369. * @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'])
  11370. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  11371. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  11372. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  11373. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=406
  11374. */
  11375. hc_nodereplacechildinvalidnodetype: function(test) {
  11376. var success;
  11377. var doc;
  11378. var rootNode;
  11379. var newChild;
  11380. var elementList;
  11381. var oldChild;
  11382. var replacedChild;
  11383. doc = hc_staff.hc_staff();
  11384. newChild = doc.createAttribute("lang");
  11385. elementList = doc.getElementsByTagName("p");
  11386. oldChild = elementList.item(1);
  11387. rootNode = oldChild.parentNode;
  11388. {
  11389. success = false;
  11390. try {
  11391. replacedChild = rootNode.replaceChild(newChild,oldChild);
  11392. }
  11393. catch(ex) {
  11394. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  11395. }
  11396. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  11397. }
  11398. test.done();
  11399. },
  11400. /**
  11401. *
  11402. The "replaceChild(newChild,oldChild)" method raises a
  11403. WRONG_DOCUMENT_ERR DOMException if the "newChild" was
  11404. created from a different document than the one that
  11405. created this node.
  11406. Retrieve the second employee and attempt to replace one
  11407. of its children with a node created from a different
  11408. document. An attempt to make such a replacement
  11409. should raise the desired exception.
  11410. * @author Curt Arnold
  11411. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
  11412. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  11413. * @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'])
  11414. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  11415. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  11416. */
  11417. hc_nodereplacechildnewchilddiffdocument: function(test) {
  11418. var success;
  11419. var doc1;
  11420. var doc2;
  11421. var oldChild;
  11422. var newChild;
  11423. var elementList;
  11424. var elementNode;
  11425. var replacedChild;
  11426. var doc1Ref = null;
  11427. if (typeof(this.doc1) != 'undefined') {
  11428. doc1Ref = this.doc1;
  11429. }
  11430. doc1 = hc_staff.hc_staff();
  11431. var doc2Ref = null;
  11432. if (typeof(this.doc2) != 'undefined') {
  11433. doc2Ref = this.doc2;
  11434. }
  11435. doc2 = hc_staff.hc_staff();
  11436. newChild = doc1.createElement("br");
  11437. elementList = doc2.getElementsByTagName("p");
  11438. elementNode = elementList.item(1);
  11439. oldChild = elementNode.firstChild;
  11440. {
  11441. success = false;
  11442. try {
  11443. replacedChild = elementNode.replaceChild(newChild,oldChild);
  11444. }
  11445. catch(ex) {
  11446. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  11447. }
  11448. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  11449. }
  11450. test.done();
  11451. },
  11452. /**
  11453. *
  11454. If the "newChild" is already in the tree, it is first
  11455. removed before the new one is added.
  11456. Retrieve the second "p" and replace "acronym" with its "em".
  11457. * @author Curt Arnold
  11458. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  11459. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=246
  11460. */
  11461. hc_nodereplacechildnewchildexists: function(test) {
  11462. var success;
  11463. var doc;
  11464. var elementList;
  11465. var employeeNode;
  11466. var childList;
  11467. var oldChild = null;
  11468. var newChild = null;
  11469. var child;
  11470. var childName;
  11471. var childNode;
  11472. var actual = new Array();
  11473. expected = new Array();
  11474. expected[0] = "strong";
  11475. expected[1] = "code";
  11476. expected[2] = "sup";
  11477. expected[3] = "var";
  11478. expected[4] = "em";
  11479. var replacedChild;
  11480. var nodeType;
  11481. doc = hc_staff.hc_staff();
  11482. elementList = doc.getElementsByTagName("p");
  11483. employeeNode = elementList.item(1);
  11484. childList = employeeNode.getElementsByTagName("*");
  11485. newChild = childList.item(0);
  11486. oldChild = childList.item(5);
  11487. replacedChild = employeeNode.replaceChild(newChild,oldChild);
  11488. test.equal(replacedChild, oldChild, 'return_value_same');
  11489. for(var indexN10094 = 0;indexN10094 < childList.length; indexN10094++) {
  11490. childNode = childList.item(indexN10094);
  11491. childName = childNode.nodeName;
  11492. nodeType = childNode.nodeType;
  11493. if(
  11494. (1 == nodeType)
  11495. ) {
  11496. actual[actual.length] = childName;
  11497. }
  11498. else {
  11499. test.equal(nodeType, 3, 'textNodeType');
  11500. test.equal(childName, '#text', 'textNodeName');
  11501. }
  11502. }
  11503. test.deepEqual(actual, expected, 'element childNames');
  11504. test.done();
  11505. },
  11506. /**
  11507. *
  11508. The "replaceChild(newChild,oldChild)" method raises a
  11509. HIERARCHY_REQUEST_ERR DOMException if the node to put
  11510. in is one of this node's ancestors.
  11511. Retrieve the second employee and attempt to replace
  11512. one of its children with an ancestor node(root node).
  11513. An attempt to make such a replacement should raise the
  11514. desired exception.
  11515. * @author Curt Arnold
  11516. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
  11517. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  11518. * @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'])
  11519. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  11520. */
  11521. hc_nodereplacechildnodeancestor: function(test) {
  11522. var success;
  11523. var doc;
  11524. var newChild;
  11525. var elementList;
  11526. var employeeNode;
  11527. var childList;
  11528. var oldChild;
  11529. var replacedNode;
  11530. doc = hc_staff.hc_staff();
  11531. newChild = doc.documentElement;
  11532. elementList = doc.getElementsByTagName("p");
  11533. employeeNode = elementList.item(1);
  11534. childList = employeeNode.childNodes;
  11535. oldChild = childList.item(0);
  11536. {
  11537. success = false;
  11538. try {
  11539. replacedNode = employeeNode.replaceChild(newChild,oldChild);
  11540. }
  11541. catch(ex) {
  11542. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  11543. }
  11544. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  11545. }
  11546. test.done();
  11547. },
  11548. /**
  11549. *
  11550. The "replaceChild(newChild,oldChild)" method returns
  11551. the node being replaced.
  11552. Replace the second Element of the second employee with
  11553. a newly created node Element and check the NodeName
  11554. returned by the "replaceChild(newChild,oldChild)"
  11555. method. The returned node should have a NodeName equal
  11556. to "em".
  11557. * @author Curt Arnold
  11558. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  11559. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  11560. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  11561. */
  11562. hc_nodereplacechildnodename: function(test) {
  11563. var success;
  11564. var doc;
  11565. var elementList;
  11566. var employeeNode;
  11567. var childList;
  11568. var oldChild;
  11569. var newChild;
  11570. var replacedNode;
  11571. var childName;
  11572. doc = hc_staff.hc_staff();
  11573. elementList = doc.getElementsByTagName("p");
  11574. employeeNode = elementList.item(1);
  11575. childList = employeeNode.getElementsByTagName("em");
  11576. oldChild = childList.item(0);
  11577. newChild = doc.createElement("br");
  11578. replacedNode = employeeNode.replaceChild(newChild,oldChild);
  11579. childName = replacedNode.nodeName;
  11580. test.equal(childName, 'em', 'element replacedNodeName');
  11581. test.done();
  11582. },
  11583. /**
  11584. *
  11585. The "replaceChild(newChild,oldChild)" method raises a
  11586. NOT_FOUND_ERR DOMException if the old child is
  11587. not a child of this node.
  11588. Retrieve the second employee and attempt to replace a
  11589. node that is not one of its children. An attempt to
  11590. replace such a node should raise the desired exception.
  11591. * @author Curt Arnold
  11592. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
  11593. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  11594. * @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'])
  11595. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  11596. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=247
  11597. */
  11598. hc_nodereplacechildoldchildnonexistent: function(test) {
  11599. var success;
  11600. var doc;
  11601. var oldChild;
  11602. var newChild;
  11603. var elementList;
  11604. var elementNode;
  11605. var replacedNode;
  11606. doc = hc_staff.hc_staff();
  11607. newChild = doc.createElement("br");
  11608. oldChild = doc.createElement("b");
  11609. elementList = doc.getElementsByTagName("p");
  11610. elementNode = elementList.item(1);
  11611. {
  11612. success = false;
  11613. try {
  11614. replacedNode = elementNode.replaceChild(newChild,oldChild);
  11615. }
  11616. catch(ex) {
  11617. success = (typeof(ex.code) != 'undefined' && ex.code == 8);
  11618. }
  11619. test.ok(success, 'throw_NOT_FOUND_ERR');
  11620. }
  11621. test.done();
  11622. },
  11623. /**
  11624. *
  11625. The "getAttributes()" method invoked on a Text
  11626. Node returns null.
  11627. Retrieve the Text node from the last child of the
  11628. first employee and invoke the "getAttributes()" method
  11629. on the Text Node. It should return null.
  11630. * @author Curt Arnold
  11631. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  11632. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1312295772
  11633. */
  11634. hc_nodetextnodeattribute: function(test) {
  11635. var success;
  11636. var doc;
  11637. var elementList;
  11638. var testAddr;
  11639. var textNode;
  11640. var attrList;
  11641. doc = hc_staff.hc_staff();
  11642. elementList = doc.getElementsByTagName("acronym");
  11643. testAddr = elementList.item(0);
  11644. textNode = testAddr.firstChild;
  11645. attrList = textNode.attributes;
  11646. test.equal(attrList, null, 'text_attributes_is_null');
  11647. test.done();
  11648. },
  11649. /**
  11650. *
  11651. The string returned by the "getNodeName()" method for a
  11652. Text Node is "#text".
  11653. * @author Curt Arnold
  11654. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  11655. */
  11656. hc_nodetextnodename: function(test) {
  11657. var success;
  11658. var doc;
  11659. var elementList;
  11660. var testAddr;
  11661. var textNode;
  11662. var textName;
  11663. doc = hc_staff.hc_staff();
  11664. elementList = doc.getElementsByTagName("acronym");
  11665. testAddr = elementList.item(0);
  11666. textNode = testAddr.firstChild;
  11667. textName = textNode.nodeName;
  11668. test.equal(textName, '#text', 'textNodeName');
  11669. test.done();
  11670. },
  11671. /**
  11672. *
  11673. The "getNodeType()" method for a Text Node
  11674. returns the constant value 3.
  11675. Retrieve the Text node from the last child of
  11676. the first employee and invoke the "getNodeType()"
  11677. method. The method should return 3.
  11678. * @author Curt Arnold
  11679. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  11680. */
  11681. hc_nodetextnodetype: function(test) {
  11682. var success;
  11683. var doc;
  11684. var elementList;
  11685. var testAddr;
  11686. var textNode;
  11687. var nodeType;
  11688. doc = hc_staff.hc_staff();
  11689. elementList = doc.getElementsByTagName("acronym");
  11690. testAddr = elementList.item(0);
  11691. textNode = testAddr.firstChild;
  11692. nodeType = textNode.nodeType;
  11693. test.equal(nodeType, 3, 'nodeTextNodeType');
  11694. test.done();
  11695. },
  11696. /**
  11697. *
  11698. The string returned by the "getNodeValue()" method for a
  11699. Text Node is the content of the Text node.
  11700. Retrieve the Text node from the last child of the first
  11701. employee and check the string returned by the
  11702. "getNodeValue()" method. It should be equal to
  11703. "1230 North Ave. Dallas, Texas 98551".
  11704. * @author Curt Arnold
  11705. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  11706. */
  11707. hc_nodetextnodevalue: function(test) {
  11708. var success;
  11709. var doc;
  11710. var elementList;
  11711. var testAddr;
  11712. var textNode;
  11713. var textValue;
  11714. doc = hc_staff.hc_staff();
  11715. elementList = doc.getElementsByTagName("acronym");
  11716. testAddr = elementList.item(0);
  11717. textNode = testAddr.firstChild;
  11718. textValue = textNode.nodeValue;
  11719. test.equal(textValue, '1230 North Ave. Dallas, Texas 98551', 'textNodeValue');
  11720. test.done();
  11721. },
  11722. /**
  11723. *
  11724. An element is created, setNodeValue is called with a non-null argument, but getNodeValue
  11725. should still return null.
  11726. * @author Curt Arnold
  11727. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  11728. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
  11729. */
  11730. hc_nodevalue01: function(test) {
  11731. var success;
  11732. var doc;
  11733. var newNode;
  11734. var newValue;
  11735. doc = hc_staff.hc_staff();
  11736. newNode = doc.createElement("acronym");
  11737. newValue = newNode.nodeValue;
  11738. test.equal(newValue, null, 'initiallyNull');
  11739. newNode.nodeValue = "This should have no effect";
  11740. newValue = newNode.nodeValue;
  11741. test.equal(newValue, null, 'nullAfterAttemptedChange');
  11742. test.done();
  11743. },
  11744. /**
  11745. *
  11746. An comment is created, setNodeValue is called with a non-null argument, but getNodeValue
  11747. should still return null.
  11748. * @author Curt Arnold
  11749. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  11750. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
  11751. */
  11752. hc_nodevalue02: function(test) {
  11753. var success;
  11754. var doc;
  11755. var newNode;
  11756. var newValue;
  11757. doc = hc_staff.hc_staff();
  11758. newNode = doc.createComment("This is a new Comment node");
  11759. newValue = newNode.nodeValue;
  11760. test.equal(newValue, 'This is a new Comment node', 'initial');
  11761. newNode.nodeValue = "This should have an effect";
  11762. newValue = newNode.nodeValue;
  11763. test.equal(newValue, 'This should have an effect', 'afterChange');
  11764. test.done();
  11765. },
  11766. /**
  11767. *
  11768. An entity reference is created, setNodeValue is called with a non-null argument, but getNodeValue
  11769. should still return null.
  11770. * @author Curt Arnold
  11771. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  11772. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-11C98490
  11773. */
  11774. hc_nodevalue03: function(test) {
  11775. var success;
  11776. var doc;
  11777. var newNode;
  11778. var newValue;
  11779. doc = hc_staff.hc_staff();
  11780. // this code path is invalid... hc_staff is always html and doesn't
  11781. // include an entity=ent1
  11782. newNode = doc.createEntityReference("ent1");
  11783. test.notEqual(newNode, null, 'createdEntRefNotNull');
  11784. newValue = newNode.nodeValue;
  11785. test.equal(newValue, null, 'initiallyNull');
  11786. newNode.nodeValue = "This should have no effect";
  11787. newValue = newNode.nodeValue;
  11788. test.equal(newValue, null, 'nullAfterAttemptedChange');
  11789. test.done();
  11790. },
  11791. /**
  11792. *
  11793. An document type accessed, setNodeValue is called with a non-null argument, but getNodeValue
  11794. should still return null.
  11795. * @author Curt Arnold
  11796. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  11797. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31
  11798. */
  11799. hc_nodevalue04: function(test) {
  11800. var success;
  11801. var doc;
  11802. var newNode;
  11803. var newValue;
  11804. doc = hc_staff.hc_staff();
  11805. newNode = doc.doctype;
  11806. test.notEqual(newNode, null, 'docTypeNotNull');
  11807. newValue = newNode.nodeValue;
  11808. test.equal(newValue, null, 'initiallyNull');
  11809. newNode.nodeValue = "This should have no effect";
  11810. newValue = newNode.nodeValue;
  11811. test.equal(newValue, null, 'nullAfterAttemptedChange');
  11812. test.done();
  11813. },
  11814. /**
  11815. *
  11816. A document fragment is created, setNodeValue is called with a non-null argument, but getNodeValue
  11817. should still return null.
  11818. * @author Curt Arnold
  11819. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  11820. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
  11821. */
  11822. hc_nodevalue05: function(test) {
  11823. var success;
  11824. var doc;
  11825. var newNode;
  11826. var newValue;
  11827. doc = hc_staff.hc_staff();
  11828. newNode = doc.createDocumentFragment();
  11829. newValue = newNode.nodeValue;
  11830. test.equal(newValue, null, 'initiallyNull');
  11831. newNode.nodeValue = "This should have no effect";
  11832. newValue = newNode.nodeValue;
  11833. test.equal(newValue, null, 'nullAfterAttemptedChange');
  11834. test.done();
  11835. },
  11836. /**
  11837. *
  11838. An document is accessed, setNodeValue is called with a non-null argument, but getNodeValue
  11839. should still return null.
  11840. * @author Curt Arnold
  11841. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  11842. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
  11843. */
  11844. hc_nodevalue06: function(test) {
  11845. var success;
  11846. var newNode;
  11847. var newValue;
  11848. var newNodeRef = null;
  11849. if (typeof(this.newNode) != 'undefined') {
  11850. newNodeRef = this.newNode;
  11851. }
  11852. newNode = hc_staff.hc_staff();
  11853. newValue = newNode.nodeValue;
  11854. test.equal(newValue, null, 'initiallyNull');
  11855. newNode.nodeValue = "This should have no effect";
  11856. newValue = newNode.nodeValue;
  11857. test.equal(newValue, null, 'nullAfterAttemptedChange');
  11858. test.done();
  11859. },
  11860. /**
  11861. *
  11862. An Entity is accessed, setNodeValue is called with a non-null argument, but getNodeValue
  11863. should still return null.
  11864. * @author Curt Arnold
  11865. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  11866. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-527DCFF2
  11867. */
  11868. hc_nodevalue07: function(test) {
  11869. var success;
  11870. var doc;
  11871. var newNode;
  11872. var newValue;
  11873. var nodeMap;
  11874. var docType;
  11875. doc = hc_staff.hc_staff();
  11876. docType = doc.doctype;
  11877. test.notEqual(docType, null, 'docTypeNotNull');
  11878. nodeMap = docType.entities;
  11879. test.notEqual(nodeMap, null, 'entitiesNotNull');
  11880. newNode = nodeMap.getNamedItem("alpha");
  11881. test.notEqual(newNode, null, 'entityNotNull');
  11882. newValue = newNode.nodeValue;
  11883. test.equal(newValue, null, 'initiallyNull');
  11884. newNode.nodeValue = "This should have no effect";
  11885. newValue = newNode.nodeValue;
  11886. test.equal(newValue, null, 'nullAfterAttemptedChange');
  11887. test.done();
  11888. },
  11889. /**
  11890. *
  11891. An notation is accessed, setNodeValue is called with a non-null argument, but getNodeValue
  11892. should still return null.
  11893. * @author Curt Arnold
  11894. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  11895. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5431D1B9
  11896. */
  11897. hc_nodevalue08: function(test) {
  11898. var success;
  11899. var doc;
  11900. var docType;
  11901. var newNode;
  11902. var newValue;
  11903. var nodeMap;
  11904. doc = hc_staff.hc_staff();
  11905. docType = doc.doctype;
  11906. test.notEqual(docType, null, 'docTypeNotNull');
  11907. nodeMap = docType.notations;
  11908. test.notEqual(nodeMap, null, 'notationsNotNull');
  11909. newNode = nodeMap.getNamedItem("notation1");
  11910. test.notEqual(newNode, null, 'notationNotNull');
  11911. newValue = newNode.nodeValue;
  11912. test.equal(newValue, null, 'initiallyNull');
  11913. newNode.nodeValue = "This should have no effect";
  11914. newValue = newNode.nodeValue;
  11915. test.equal(newValue, null, 'nullAfterAttemptedChange');
  11916. test.done();
  11917. },
  11918. /**
  11919. *
  11920. An attempt to add remove an notation should result in a NO_MODIFICATION_ERR.
  11921. * @author Curt Arnold
  11922. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D46829EF
  11923. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193
  11924. */
  11925. hc_notationsremovenameditem1: function(test) {
  11926. var success;
  11927. var doc;
  11928. var notations;
  11929. var docType;
  11930. var retval;
  11931. doc = hc_staff.hc_staff();
  11932. docType = doc.doctype;
  11933. test.notEqual(docType, null, 'docTypeNotNull');
  11934. notations = docType.notations;
  11935. test.notEqual(notations, null, 'notationsNotNull');
  11936. success = false;
  11937. try {
  11938. retval = notations.removeNamedItem("notation1");
  11939. }
  11940. catch(ex) {
  11941. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  11942. }
  11943. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  11944. test.done();
  11945. },
  11946. /**
  11947. *
  11948. An attempt to add an element to the named node map returned by notations should
  11949. result in a NO_MODIFICATION_ERR or HIERARCHY_REQUEST_ERR.
  11950. * @author Curt Arnold
  11951. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D46829EF
  11952. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  11953. */
  11954. hc_notationssetnameditem1: function(test) {
  11955. var success;
  11956. var doc;
  11957. var notations;
  11958. var docType;
  11959. var retval;
  11960. var elem;
  11961. doc = hc_staff.hc_staff();
  11962. docType = doc.doctype;
  11963. test.notEqual(docType, null, 'docTypeNotNull');
  11964. notations = docType.notations;
  11965. test.notEqual(notations, null, 'notationsNotNull');
  11966. elem = doc.createElement("br");
  11967. try {
  11968. retval = notations.setNamedItem(elem);
  11969. fail("throw_HIER_OR_NO_MOD_ERR");
  11970. } catch (ex) {
  11971. if (typeof(ex.code) != 'undefined') {
  11972. switch(ex.code) {
  11973. case /* HIERARCHY_REQUEST_ERR */ 3 :
  11974. break;
  11975. case /* NO_MODIFICATION_ALLOWED_ERR */ 7 :
  11976. break;
  11977. default:
  11978. throw ex;
  11979. }
  11980. } else {
  11981. throw ex;
  11982. }
  11983. }
  11984. test.done();
  11985. },
  11986. /**
  11987. *
  11988. The "splitText(offset)" method raises an
  11989. INDEX_SIZE_ERR DOMException if the specified offset is
  11990. negative.
  11991. Retrieve the textual data from the second child of the
  11992. third employee and invoke the "splitText(offset)" method.
  11993. The desired exception should be raised since the offset
  11994. is a negative number.
  11995. * @author Curt Arnold
  11996. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  11997. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  11998. * @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'])
  11999. */
  12000. hc_textindexsizeerrnegativeoffset: function(test) {
  12001. var success;
  12002. var doc;
  12003. var elementList;
  12004. var nameNode;
  12005. var textNode;
  12006. var splitNode;
  12007. doc = hc_staff.hc_staff();
  12008. elementList = doc.getElementsByTagName("strong");
  12009. nameNode = elementList.item(2);
  12010. textNode = nameNode.firstChild;
  12011. {
  12012. success = false;
  12013. try {
  12014. splitNode = textNode.splitText(-69);
  12015. }
  12016. catch(ex) {
  12017. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  12018. }
  12019. test.ok(success, 'throws_INDEX_SIZE_ERR');
  12020. }
  12021. test.done();
  12022. },
  12023. /**
  12024. *
  12025. The "splitText(offset)" method raises an
  12026. INDEX_SIZE_ERR DOMException if the specified offset is
  12027. greater than the number of characters in the Text node.
  12028. Retrieve the textual data from the second child of the
  12029. third employee and invoke the "splitText(offset)" method.
  12030. The desired exception should be raised since the offset
  12031. is a greater than the number of characters in the Text
  12032. node.
  12033. * @author Curt Arnold
  12034. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  12035. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  12036. * @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'])
  12037. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  12038. */
  12039. hc_textindexsizeerroffsetoutofbounds: function(test) {
  12040. var success;
  12041. var doc;
  12042. var elementList;
  12043. var nameNode;
  12044. var textNode;
  12045. var splitNode;
  12046. doc = hc_staff.hc_staff();
  12047. elementList = doc.getElementsByTagName("strong");
  12048. nameNode = elementList.item(2);
  12049. textNode = nameNode.firstChild;
  12050. {
  12051. success = false;
  12052. try {
  12053. splitNode = textNode.splitText(300);
  12054. }
  12055. catch(ex) {
  12056. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  12057. }
  12058. test.ok(success, 'throw_INDEX_SIZE_ERR');
  12059. }
  12060. test.done();
  12061. },
  12062. /**
  12063. *
  12064. Retrieve the textual data from the last child of the
  12065. second employee. That node is composed of two
  12066. EntityReference nodes and two Text nodes. After
  12067. the content node is parsed, the "acronym" Element
  12068. should contain four children with each one of the
  12069. EntityReferences containing one child.
  12070. * @author Curt Arnold
  12071. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  12072. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-11C98490
  12073. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-745549614
  12074. */
  12075. hc_textparseintolistofelements: function(test) {
  12076. var success;
  12077. var doc;
  12078. var elementList;
  12079. var addressNode;
  12080. var childList;
  12081. var child;
  12082. var value;
  12083. var grandChild;
  12084. var length;
  12085. var result = new Array();
  12086. expectedNormal = new Array();
  12087. expectedNormal[0] = "β";
  12088. expectedNormal[1] = " Dallas, ";
  12089. expectedNormal[2] = "γ";
  12090. expectedNormal[3] = "\n 98554";
  12091. expectedExpanded = new Array();
  12092. expectedExpanded[0] = "β Dallas, γ\n 98554";
  12093. doc = hc_staff.hc_staff();
  12094. elementList = doc.getElementsByTagName("acronym");
  12095. addressNode = elementList.item(1);
  12096. childList = addressNode.childNodes;
  12097. length = childList.length;
  12098. for(var indexN1007C = 0;indexN1007C < childList.length; indexN1007C++) {
  12099. child = childList.item(indexN1007C);
  12100. value = child.nodeValue;
  12101. if(
  12102. (value == null)
  12103. ) {
  12104. grandChild = child.firstChild;
  12105. test.notEqual(grandChild, null, 'grandChildNotNull');
  12106. value = grandChild.nodeValue;
  12107. result[result.length] = value;
  12108. }
  12109. else {
  12110. result[result.length] = value;
  12111. }
  12112. }
  12113. if(
  12114. (1 == length)
  12115. ) {
  12116. test.deepEqual(result, expectedExpanded, 'assertEqCoalescing');
  12117. }
  12118. else {
  12119. test.deepEqual(result, expectedNormal, 'assertEqNormal');
  12120. }
  12121. test.done();
  12122. },
  12123. /**
  12124. *
  12125. The "splitText(offset)" method returns the new Text node.
  12126. Retrieve the textual data from the last child of the
  12127. first employee and invoke the "splitText(offset)" method.
  12128. The method should return the new Text node. The offset
  12129. value used for this test is 30. The "getNodeValue()"
  12130. method is called to check that the new node now contains
  12131. the characters at and after position 30.
  12132. (Starting count at 0)
  12133. * @author Curt Arnold
  12134. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  12135. */
  12136. hc_textsplittextfour: function(test) {
  12137. var success;
  12138. var doc;
  12139. var elementList;
  12140. var addressNode;
  12141. var textNode;
  12142. var splitNode;
  12143. var value;
  12144. doc = hc_staff.hc_staff();
  12145. elementList = doc.getElementsByTagName("acronym");
  12146. addressNode = elementList.item(0);
  12147. textNode = addressNode.firstChild;
  12148. splitNode = textNode.splitText(30);
  12149. value = splitNode.nodeValue;
  12150. test.equal(value, '98551', 'textSplitTextFourAssert');
  12151. test.done();
  12152. },
  12153. /**
  12154. *
  12155. The "splitText(offset)" method breaks the Text node into
  12156. two Text nodes at the specified offset keeping each node
  12157. as siblings in the tree.
  12158. Retrieve the textual data from the second child of the
  12159. third employee and invoke the "splitText(offset)" method.
  12160. The method splits the Text node into two new sibling
  12161. Text nodes keeping both of them in the tree. This test
  12162. checks the "nextSibling()" method of the original node
  12163. to ensure that the two nodes are indeed siblings.
  12164. * @author Curt Arnold
  12165. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  12166. */
  12167. hc_textsplittextone: function(test) {
  12168. var success;
  12169. var doc;
  12170. var elementList;
  12171. var nameNode;
  12172. var textNode;
  12173. var splitNode;
  12174. var secondPart;
  12175. var value;
  12176. doc = hc_staff.hc_staff();
  12177. elementList = doc.getElementsByTagName("strong");
  12178. nameNode = elementList.item(2);
  12179. textNode = nameNode.firstChild;
  12180. splitNode = textNode.splitText(7);
  12181. secondPart = textNode.nextSibling;
  12182. value = secondPart.nodeValue;
  12183. test.equal(value, 'Jones', 'textSplitTextOneAssert');
  12184. test.done();
  12185. },
  12186. /**
  12187. *
  12188. After the "splitText(offset)" method breaks the Text node
  12189. into two Text nodes, the new Text node contains all the
  12190. content at and after the offset point.
  12191. Retrieve the textual data from the second child of the
  12192. third employee and invoke the "splitText(offset)" method.
  12193. The new Text node should contain all the content
  12194. at and after the offset point. The "getNodeValue()"
  12195. method is called to check that the new node now contains
  12196. the characters at and after position seven.
  12197. (Starting count at 0)
  12198. * @author Curt Arnold
  12199. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  12200. */
  12201. hc_textsplittextthree: function(test) {
  12202. var success;
  12203. var doc;
  12204. var elementList;
  12205. var nameNode;
  12206. var textNode;
  12207. var splitNode;
  12208. var value;
  12209. doc = hc_staff.hc_staff();
  12210. elementList = doc.getElementsByTagName("strong");
  12211. nameNode = elementList.item(2);
  12212. textNode = nameNode.firstChild;
  12213. splitNode = textNode.splitText(6);
  12214. value = splitNode.nodeValue;
  12215. test.equal(value, ' Jones', 'textSplitTextThreeAssert');
  12216. test.done();
  12217. },
  12218. /**
  12219. *
  12220. After the "splitText(offset)" method breaks the Text node
  12221. into two Text nodes, the original node contains all the
  12222. content up to the offset point.
  12223. Retrieve the textual data from the second child of the
  12224. third employee and invoke the "splitText(offset)" method.
  12225. The original Text node should contain all the content
  12226. up to the offset point. The "getNodeValue()" method
  12227. is called to check that the original node now contains
  12228. the first five characters.
  12229. * @author Curt Arnold
  12230. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  12231. */
  12232. hc_textsplittexttwo: function(test) {
  12233. var success;
  12234. var doc;
  12235. var elementList;
  12236. var nameNode;
  12237. var textNode;
  12238. var splitNode;
  12239. var value;
  12240. doc = hc_staff.hc_staff();
  12241. elementList = doc.getElementsByTagName("strong");
  12242. nameNode = elementList.item(2);
  12243. textNode = nameNode.firstChild;
  12244. splitNode = textNode.splitText(5);
  12245. value = textNode.nodeValue;
  12246. test.equal(value, 'Roger', 'textSplitTextTwoAssert');
  12247. test.done();
  12248. },
  12249. /**
  12250. *
  12251. If there is not any markup inside an Element or Attr node
  12252. content, then the text is contained in a single object
  12253. implementing the Text interface that is the only child
  12254. of the element.
  12255. Retrieve the textual data from the second child of the
  12256. third employee. That Text node contains a block of
  12257. multiple text lines without markup, so they should be
  12258. treated as a single Text node. The "getNodeValue()"
  12259. method should contain the combination of the two lines.
  12260. * @author Curt Arnold
  12261. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1312295772
  12262. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  12263. */
  12264. hc_textwithnomarkup: function(test) {
  12265. var success;
  12266. var doc;
  12267. var elementList;
  12268. var nameNode;
  12269. var nodeV;
  12270. var value;
  12271. doc = hc_staff.hc_staff();
  12272. elementList = doc.getElementsByTagName("strong");
  12273. nameNode = elementList.item(2);
  12274. nodeV = nameNode.firstChild;
  12275. value = nodeV.nodeValue;
  12276. test.equal(value, 'Roger\n Jones', 'textWithNoMarkupAssert');
  12277. test.done();
  12278. },
  12279. /**
  12280. *
  12281. The range of valid child node indices is 0 to Length -1.
  12282. Create a NamedNodeMap object from the attributes of the
  12283. last child of the third employee and traverse the
  12284. list from index 0 thru length -1. All indices should
  12285. be valid.
  12286. * @author NIST
  12287. * @author Mary Brady
  12288. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  12289. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  12290. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D0FB19E
  12291. */
  12292. namednodemapchildnoderange: function(test) {
  12293. var success;
  12294. var doc;
  12295. var elementList;
  12296. var testEmployee;
  12297. var attributes;
  12298. var child;
  12299. var length;
  12300. doc = staff.staff();
  12301. elementList = doc.getElementsByTagName("address");
  12302. testEmployee = elementList.item(2);
  12303. attributes = testEmployee.attributes;
  12304. length = attributes.length;
  12305. test.equal(length, 2, 'length');
  12306. child = attributes.item(0);
  12307. child = attributes.item(1);
  12308. test.done();
  12309. },
  12310. /**
  12311. *
  12312. The "getNamedItem(name)" method retrieves a node
  12313. specified by name.
  12314. Retrieve the second employee and create a NamedNodeMap
  12315. listing of the attributes of the last child. Once the
  12316. list is created an invocation of the "getNamedItem(name)"
  12317. method is done with name="domestic". This should result
  12318. in the domestic Attr node being returned.
  12319. * @author NIST
  12320. * @author Mary Brady
  12321. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
  12322. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  12323. */
  12324. namednodemapgetnameditem: function(test) {
  12325. var success;
  12326. var doc;
  12327. var elementList;
  12328. var testEmployee;
  12329. var attributes;
  12330. var domesticAttr;
  12331. var attrName;
  12332. doc = staff.staff();
  12333. elementList = doc.getElementsByTagName("address");
  12334. testEmployee = elementList.item(1);
  12335. attributes = testEmployee.attributes;
  12336. domesticAttr = attributes.getNamedItem("domestic");
  12337. attrName = domesticAttr.nodeName;
  12338. test.equal(attrName, 'domestic', 'namednodemapGetNamedItemAssert');
  12339. test.done();
  12340. },
  12341. /**
  12342. *
  12343. The "setNamedItem(arg)" method raises a
  12344. INUSE_ATTRIBUTE_ERR DOMException if "arg" is an
  12345. Attr that is already in an attribute of another Element.
  12346. Create a NamedNodeMap object from the attributes of the
  12347. last child of the third employee and attempt to add
  12348. an attribute that is already being used by the first
  12349. employee. This should raise the desired exception.
  12350. * @author NIST
  12351. * @author Mary Brady
  12352. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])
  12353. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  12354. * @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'])
  12355. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  12356. */
  12357. namednodemapinuseattributeerr: function(test) {
  12358. var success;
  12359. var doc;
  12360. var elementList;
  12361. var firstNode;
  12362. var testNode;
  12363. var attributes;
  12364. var domesticAttr;
  12365. var setAttr;
  12366. var setNode;
  12367. doc = staff.staff();
  12368. elementList = doc.getElementsByTagName("address");
  12369. firstNode = elementList.item(0);
  12370. domesticAttr = doc.createAttribute("domestic");
  12371. domesticAttr.value = "Yes";
  12372. setAttr = firstNode.setAttributeNode(domesticAttr);
  12373. elementList = doc.getElementsByTagName("address");
  12374. testNode = elementList.item(2);
  12375. attributes = testNode.attributes;
  12376. {
  12377. success = false;
  12378. try {
  12379. setNode = attributes.setNamedItem(domesticAttr);
  12380. }
  12381. catch(ex) {
  12382. success = (typeof(ex.code) != 'undefined' && ex.code == 10);
  12383. }
  12384. test.ok(success, 'throw_INUSE_ATTRIBUTE_ERR');
  12385. }
  12386. test.done();
  12387. },
  12388. /**
  12389. *
  12390. The "removeNamedItem(name)" method raises a
  12391. NOT_FOUND_ERR DOMException if there is not a node
  12392. named "name" in the map.
  12393. Create a NamedNodeMap object from the attributes of the
  12394. last child of the third employee and attempt to remove
  12395. the "district" attribute. There is not a node named
  12396. "district" in the list and therefore the desired
  12397. exception should be raised.
  12398. * @author NIST
  12399. * @author Mary Brady
  12400. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INUSE_ATTRIBUTE_ERR'])
  12401. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193
  12402. * @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'])
  12403. */
  12404. namednodemapnotfounderr: function(test) {
  12405. var success;
  12406. var doc;
  12407. var elementList;
  12408. var testEmployee;
  12409. var attributes;
  12410. var removedNode;
  12411. doc = staff.staff();
  12412. elementList = doc.getElementsByTagName("address");
  12413. testEmployee = elementList.item(2);
  12414. attributes = testEmployee.attributes;
  12415. {
  12416. success = false;
  12417. try {
  12418. removedNode = attributes.removeNamedItem("district");
  12419. }
  12420. catch(ex) {
  12421. success = (typeof(ex.code) != 'undefined' && ex.code == 8);
  12422. }
  12423. test.ok(success, 'throw_NOT_FOUND_ERR');
  12424. }
  12425. test.done();
  12426. },
  12427. /**
  12428. *
  12429. The "getLength()" method returns the number of nodes
  12430. in the map.
  12431. Retrieve the second employee and create a NamedNodeMap
  12432. listing of the attributes of the last child. Once the
  12433. list is created an invocation of the "getLength()"
  12434. method is executed. The number of nodes should be 2.
  12435. * @author NIST
  12436. * @author Mary Brady
  12437. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  12438. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6D0FB19E
  12439. */
  12440. namednodemapnumberofnodes: function(test) {
  12441. var success;
  12442. var doc;
  12443. var elementList;
  12444. var testEmployee;
  12445. var attributes;
  12446. var length;
  12447. doc = staff.staff();
  12448. elementList = doc.getElementsByTagName("address");
  12449. testEmployee = elementList.item(2);
  12450. attributes = testEmployee.attributes;
  12451. length = attributes.length;
  12452. test.equal(length, 2, 'length');
  12453. test.done();
  12454. },
  12455. /**
  12456. *
  12457. The "removeNamedItem(name)" method removes a node
  12458. specified by name.
  12459. Retrieve the third employee and create a NamedNodeMap
  12460. object of the attributes of the last child. Once the
  12461. list is created invoke the "removeNamedItem(name)"
  12462. method with name="street". This should result
  12463. in the removal of the specified attribute and
  12464. the "getSpecified()" method should return false.
  12465. * @author NIST
  12466. * @author Mary Brady
  12467. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193
  12468. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  12469. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html
  12470. */
  12471. namednodemapremovenameditem: function(test) {
  12472. var success;
  12473. var doc;
  12474. var elementList;
  12475. var testAddress;
  12476. var attributes;
  12477. var streetAttr;
  12478. var specified;
  12479. var removedNode;
  12480. doc = staff.staff();
  12481. elementList = doc.getElementsByTagName("address");
  12482. testAddress = elementList.item(2);
  12483. attributes = testAddress.attributes;
  12484. test.notEqual(attributes, null, 'attributesNotNull');
  12485. removedNode = attributes.removeNamedItem("street");
  12486. streetAttr = attributes.getNamedItem("street");
  12487. test.notEqual(streetAttr, null, 'streetAttrNotNull');
  12488. specified = streetAttr.specified;
  12489. test.equal(specified, false, 'attrNotSpecified');
  12490. test.done();
  12491. },
  12492. /**
  12493. *
  12494. If the node removed by the "removeNamedItem(name)" method
  12495. is an Attr node with a default value it is immediately
  12496. replaced.
  12497. Retrieve the third employee and create a NamedNodeMap
  12498. object of the attributes of the last child. Once the
  12499. list is created invoke the "removeNamedItem(name)"
  12500. method with name="street". The "removeNamedItem(name)"
  12501. method should remove the "street" attribute and since
  12502. it has a default value of "Yes", that value should
  12503. immediately be the attributes value.
  12504. * @author NIST
  12505. * @author Mary Brady
  12506. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193
  12507. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  12508. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Mar/0002.html
  12509. */
  12510. namednodemapremovenameditemgetvalue: function(test) {
  12511. var success;
  12512. var doc;
  12513. var elementList;
  12514. var testEmployee;
  12515. var attributes;
  12516. var streetAttr;
  12517. var value;
  12518. var removedNode;
  12519. doc = staff.staff();
  12520. elementList = doc.getElementsByTagName("address");
  12521. testEmployee = elementList.item(2);
  12522. attributes = testEmployee.attributes;
  12523. test.notEqual(attributes, null, 'attributesNotNull');
  12524. removedNode = attributes.removeNamedItem("street");
  12525. streetAttr = attributes.getNamedItem("street");
  12526. test.notEqual(streetAttr, null, 'streetAttrNotNull');
  12527. value = streetAttr.value;
  12528. test.equal(value, 'Yes', 'namednodemapRemoveNamedItemGetValueAssert');
  12529. test.done();
  12530. },
  12531. /**
  12532. *
  12533. The "removeNamedItem(name)" method returns the node
  12534. removed from the map.
  12535. Retrieve the third employee and create a NamedNodeMap
  12536. object of the attributes of the last child. Once the
  12537. list is created invoke the "removeNamedItem(name)"
  12538. method with name="street". The "removeNamedItem(name)"
  12539. method should remove the existing "street" attribute
  12540. and return it.
  12541. * @author NIST
  12542. * @author Mary Brady
  12543. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-D58B193
  12544. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  12545. */
  12546. namednodemapremovenameditemreturnnodevalue: function(test) {
  12547. var success;
  12548. var doc;
  12549. var elementList;
  12550. var testAddress;
  12551. var attributes;
  12552. var removedNode;
  12553. var value;
  12554. doc = staff.staff();
  12555. elementList = doc.getElementsByTagName("address");
  12556. testAddress = elementList.item(2);
  12557. attributes = testAddress.attributes;
  12558. removedNode = attributes.removeNamedItem("street");
  12559. value = removedNode.nodeValue;
  12560. test.equal(value, 'No', 'namednodemapRemoveNamedItemReturnNodeValueAssert');
  12561. test.done();
  12562. },
  12563. /**
  12564. *
  12565. The "getNamedItem(name)" method returns a node of any
  12566. type specified by name.
  12567. Retrieve the second employee and create a NamedNodeMap
  12568. listing of the attributes of the last child. Once the
  12569. list is created an invocation of the "getNamedItem(name)"
  12570. method is done with name="street". This should result
  12571. in the method returning an Attr node.
  12572. * @author NIST
  12573. * @author Mary Brady
  12574. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
  12575. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  12576. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  12577. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1112119403
  12578. */
  12579. namednodemapreturnattrnode: function(test) {
  12580. var doc = staff.staff();
  12581. var streetAttr = doc.getElementsByTagName("address").item(1).attributes.getNamedItem("street");
  12582. test.equal(streetAttr.nodeType, 2, 'typeAssert');
  12583. test.equal(streetAttr.nodeName, 'street', 'nodeName');
  12584. test.equal(streetAttr.name, 'street', 'attrName');
  12585. test.done();
  12586. },
  12587. /**
  12588. *
  12589. The "item(index)" method returns the indexth item in
  12590. the map(test for first item).
  12591. Retrieve the second employee and create a NamedNodeMap
  12592. listing of the attributes of the last child. Since the
  12593. DOM does not specify an order of these nodes the contents
  12594. of the FIRST node can contain either "domestic" or "street".
  12595. The test should return "true" if the FIRST node is either
  12596. of these values.
  12597. * @author NIST
  12598. * @author Mary Brady
  12599. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  12600. */
  12601. namednodemapreturnfirstitem: function(test) {
  12602. var doc = staff.staff();
  12603. var child = doc.getElementsByTagName("address").item(1).attributes.item(0);
  12604. var name = child.nodeName;
  12605. test.ok((("domestic" == name) || ("street" == name)), 'namednodemapReturnFirstItemAssert')
  12606. test.done();
  12607. },
  12608. /**
  12609. *
  12610. The "item(index)" method returns the indexth item in
  12611. the map(test for last item).
  12612. Retrieve the second employee and create a NamedNodeMap
  12613. listing of the attributes of the last child. Since the
  12614. DOM does not specify an order of these nodes the contents
  12615. of the LAST node can contain either "domestic" or "street".
  12616. The test should return "true" if the LAST node is either
  12617. of these values.
  12618. * @author NIST
  12619. * @author Mary Brady
  12620. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  12621. */
  12622. namednodemapreturnlastitem: function(test) {
  12623. var doc = staff.staff();
  12624. var child = doc.getElementsByTagName("address").item(1).attributes.item(1);
  12625. var name = child.nodeName;
  12626. test.ok((("domestic" == name) || ("street" == name)), 'namednodemapReturnLastItemAssert')
  12627. test.done();
  12628. },
  12629. /**
  12630. *
  12631. The "getNamedItem(name)" method returns null of the
  12632. specified name did not identify any node in the map.
  12633. Retrieve the second employee and create a NamedNodeMap
  12634. listing of the attributes of the last child. Once the
  12635. list is created an invocation of the "getNamedItem(name)"
  12636. method is done with name="district". This name does not
  12637. match any names in the list therefore the method should
  12638. return null.
  12639. * @author NIST
  12640. * @author Mary Brady
  12641. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1074577549
  12642. */
  12643. namednodemapreturnnull: function(test) {
  12644. var success;
  12645. var doc;
  12646. var elementList;
  12647. var testEmployee;
  12648. var attributes;
  12649. var districtNode;
  12650. doc = staff.staff();
  12651. elementList = doc.getElementsByTagName("address");
  12652. testEmployee = elementList.item(1);
  12653. attributes = testEmployee.attributes;
  12654. districtNode = attributes.getNamedItem("district");
  12655. test.equal(districtNode, null, 'namednodemapReturnNullAssert');
  12656. test.done();
  12657. },
  12658. /**
  12659. *
  12660. The "setNamedItem(arg)" method adds a node using its
  12661. nodeName attribute.
  12662. Retrieve the second employee and create a NamedNodeMap
  12663. object from the attributes of the last child by
  12664. invoking the "getAttributes()" method. Once the
  12665. list is created an invocation of the "setNamedItem(arg)"
  12666. method is done with arg=newAttr, where newAttr is a
  12667. new Attr Node previously created. The "setNamedItem(arg)"
  12668. method should add then new node to the NamedNodeItem
  12669. object by using its "nodeName" attribute("district').
  12670. This node is then retrieved using the "getNamedItem(name)"
  12671. method. This test uses the "createAttribute(name)"
  12672. method from the document interface.
  12673. * @author NIST
  12674. * @author Mary Brady
  12675. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  12676. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  12677. */
  12678. namednodemapsetnameditem: function(test) {
  12679. var success;
  12680. var doc;
  12681. var elementList;
  12682. var newAttribute;
  12683. var testAddress;
  12684. var attributes;
  12685. var districtNode;
  12686. var attrName;
  12687. var setNode;
  12688. doc = staff.staff();
  12689. elementList = doc.getElementsByTagName("address");
  12690. testAddress = elementList.item(1);
  12691. newAttribute = doc.createAttribute("district");
  12692. attributes = testAddress.attributes;
  12693. setNode = attributes.setNamedItem(newAttribute);
  12694. districtNode = attributes.getNamedItem("district");
  12695. attrName = districtNode.nodeName;
  12696. test.equal(attrName, 'district', 'namednodemapSetNamedItemAssert');
  12697. test.done();
  12698. },
  12699. /**
  12700. *
  12701. If the "setNamedItem(arg)" method replaces an already
  12702. existing node with the same name then the already
  12703. existing node is returned.
  12704. Retrieve the third employee and create a NamedNodeMap
  12705. object from the attributes of the last child by
  12706. invoking the "getAttributes()" method. Once the
  12707. list is created an invocation of the "setNamedItem(arg)"
  12708. method is done with arg=newAttr, where newAttr is a
  12709. new Attr Node previously created and whose node name
  12710. already exists in the map. The "setNamedItem(arg)"
  12711. method should replace the already existing node with
  12712. the new one and return the existing node.
  12713. This test uses the "createAttribute(name)" method from
  12714. the document interface.
  12715. * @author NIST
  12716. * @author Mary Brady
  12717. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  12718. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  12719. */
  12720. namednodemapsetnameditemreturnvalue: function(test) {
  12721. var success;
  12722. var doc;
  12723. var elementList;
  12724. var newAttribute;
  12725. var testAddress;
  12726. var attributes;
  12727. var newNode;
  12728. var attrValue;
  12729. doc = staff.staff();
  12730. elementList = doc.getElementsByTagName("address");
  12731. testAddress = elementList.item(2);
  12732. newAttribute = doc.createAttribute("street");
  12733. attributes = testAddress.attributes;
  12734. newNode = attributes.setNamedItem(newAttribute);
  12735. attrValue = newNode.nodeValue;
  12736. test.equal(attrValue, 'No', 'returnedNodeValue');
  12737. test.done();
  12738. },
  12739. /**
  12740. *
  12741. If the node to be added by the "setNamedItem(arg)" method
  12742. already exists in the NamedNodeMap, it is replaced by
  12743. the new one.
  12744. Retrieve the second employee and create a NamedNodeMap
  12745. object from the attributes of the last child by
  12746. invoking the "getAttributes()" method. Once the
  12747. list is created an invocation of the "setNamedItem(arg)"
  12748. method is done with arg=newAttr, where newAttr is a
  12749. new Attr Node previously created and whose node name
  12750. already exists in the map. The "setNamedItem(arg)"
  12751. method should replace the already existing node with
  12752. the new one.
  12753. This node is then retrieved using the "getNamedItem(name)"
  12754. method. This test uses the "createAttribute(name)"
  12755. method from the document interface
  12756. * @author NIST
  12757. * @author Mary Brady
  12758. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  12759. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  12760. */
  12761. namednodemapsetnameditemthatexists: function(test) {
  12762. var success;
  12763. var doc;
  12764. var elementList;
  12765. var newAttribute;
  12766. var testAddress;
  12767. var attributes;
  12768. var districtNode;
  12769. var attrValue;
  12770. var setNode;
  12771. doc = staff.staff();
  12772. elementList = doc.getElementsByTagName("address");
  12773. testAddress = elementList.item(1);
  12774. newAttribute = doc.createAttribute("street");
  12775. attributes = testAddress.attributes;
  12776. setNode = attributes.setNamedItem(newAttribute);
  12777. districtNode = attributes.getNamedItem("street");
  12778. attrValue = districtNode.nodeValue;
  12779. test.equal(attrValue, '', 'streetValue');
  12780. test.done();
  12781. },
  12782. /**
  12783. *
  12784. If the "setNamedItem(arg)" method does not replace an
  12785. existing node with the same name then it returns null.
  12786. Retrieve the third employee and create a NamedNodeMap
  12787. object from the attributes of the last child.
  12788. Once the list is created the "setNamedItem(arg)" method
  12789. is invoked with arg=newAttr, where newAttr is a
  12790. newly created Attr Node and whose node name
  12791. already exists in the map. The "setNamedItem(arg)"
  12792. method should add the new node and return null.
  12793. This test uses the "createAttribute(name)" method from
  12794. the document interface.
  12795. * @author NIST
  12796. * @author Mary Brady
  12797. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  12798. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-349467F9
  12799. */
  12800. namednodemapsetnameditemwithnewvalue: function(test) {
  12801. var success;
  12802. var doc;
  12803. var elementList;
  12804. var newAttribute;
  12805. var testAddress;
  12806. var attributes;
  12807. var newNode;
  12808. doc = staff.staff();
  12809. elementList = doc.getElementsByTagName("address");
  12810. testAddress = elementList.item(2);
  12811. newAttribute = doc.createAttribute("district");
  12812. attributes = testAddress.attributes;
  12813. newNode = attributes.setNamedItem(newAttribute);
  12814. test.equal(newNode, null, 'returnedNodeNull');
  12815. test.done();
  12816. },
  12817. /**
  12818. *
  12819. The "setNamedItem(arg)" method raises a
  12820. WRONG_DOCUMENT_ERR DOMException if "arg" was created
  12821. from a different document than the one that created
  12822. the NamedNodeMap.
  12823. Create a NamedNodeMap object from the attributes of the
  12824. last child of the third employee and attempt to add
  12825. another Attr node to it that was created from a
  12826. different DOM document. This should raise the desired
  12827. exception. This method uses the "createAttribute(name)"
  12828. method from the Document interface.
  12829. * @author NIST
  12830. * @author Mary Brady
  12831. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])
  12832. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1025163788
  12833. * @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'])
  12834. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  12835. */
  12836. namednodemapwrongdocumenterr: function(test) {
  12837. var success;
  12838. var doc1;
  12839. var doc2;
  12840. var elementList;
  12841. var testAddress;
  12842. var attributes;
  12843. var newAttribute;
  12844. var setNode;
  12845. var doc1Ref = null;
  12846. if (typeof(this.doc1) != 'undefined') {
  12847. doc1Ref = this.doc1;
  12848. }
  12849. doc1 = staff.staff();
  12850. var doc2Ref = null;
  12851. if (typeof(this.doc2) != 'undefined') {
  12852. doc2Ref = this.doc2;
  12853. }
  12854. doc2 = staff.staff();
  12855. elementList = doc1.getElementsByTagName("address");
  12856. testAddress = elementList.item(2);
  12857. newAttribute = doc2.createAttribute("newAttribute");
  12858. attributes = testAddress.attributes;
  12859. {
  12860. success = false;
  12861. try {
  12862. setNode = attributes.setNamedItem(newAttribute);
  12863. }
  12864. catch(ex) {
  12865. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  12866. }
  12867. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  12868. }
  12869. test.done();
  12870. },
  12871. /**
  12872. *
  12873. The "appendChild(newChild)" method adds the node
  12874. "newChild" to the end of the list of children of the
  12875. node.
  12876. Retrieve the second employee and append a new Element
  12877. node to the list of children. The last node in the list
  12878. is then retrieved and its NodeName examined. The
  12879. "getNodeName()" method should return "newChild".
  12880. * @author NIST
  12881. * @author Mary Brady
  12882. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  12883. */
  12884. nodeappendchild: function(test) {
  12885. var success;
  12886. var doc;
  12887. var elementList;
  12888. var employeeNode;
  12889. var childList;
  12890. var createdNode;
  12891. var lchild;
  12892. var childName;
  12893. var appendedChild;
  12894. doc = staff.staff();
  12895. elementList = doc.getElementsByTagName("employee");
  12896. employeeNode = elementList.item(1);
  12897. childList = employeeNode.childNodes;
  12898. createdNode = doc.createElement("newChild");
  12899. appendedChild = employeeNode.appendChild(createdNode);
  12900. lchild = employeeNode.lastChild;
  12901. childName = lchild.nodeName;
  12902. test.equal(childName, 'newChild', 'nodeAppendChild');
  12903. test.done();
  12904. },
  12905. /**
  12906. *
  12907. If the "newChild" is already in the tree, it is first
  12908. removed before the new one is appended.
  12909. Retrieve the first child of the second employee and
  12910. append the first child to the end of the list. After
  12911. the "appendChild(newChild)" method is invoked the first
  12912. child should be the one that was second and the last
  12913. child should be the one that was first.
  12914. * @author NIST
  12915. * @author Mary Brady
  12916. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  12917. */
  12918. nodeappendchildchildexists: function(test) {
  12919. var success;
  12920. var doc;
  12921. var elementList;
  12922. var childNode;
  12923. var newChild;
  12924. var lchild;
  12925. var fchild;
  12926. var lchildName;
  12927. var fchildName;
  12928. var appendedChild;
  12929. var initialName;
  12930. doc = staff.staff();
  12931. elementList = doc.getElementsByTagName("employee");
  12932. childNode = elementList.item(1);
  12933. newChild = childNode.firstChild;
  12934. initialName = newChild.nodeName;
  12935. appendedChild = childNode.appendChild(newChild);
  12936. fchild = childNode.firstChild;
  12937. fchildName = fchild.nodeName;
  12938. lchild = childNode.lastChild;
  12939. lchildName = lchild.nodeName;
  12940. if("employeeId" == initialName) {
  12941. test.equal(fchildName, 'name', 'nowhitespace');
  12942. test.equal(lchildName, 'employeeId', 'nowhitespace');
  12943. } else {
  12944. test.equal(fchildName, 'employeeId');
  12945. test.equal(lchildName, '#text');
  12946. }
  12947. test.done();
  12948. },
  12949. /**
  12950. *
  12951. Create and populate a new DocumentFragment object and
  12952. append it to the second employee. After the
  12953. "appendChild(newChild)" method is invoked retrieve the
  12954. new nodes at the end of the list, they should be the
  12955. two Element nodes from the DocumentFragment.
  12956. * @author NIST
  12957. * @author Mary Brady
  12958. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  12959. */
  12960. nodeappendchilddocfragment: function(test) {
  12961. var success;
  12962. var doc;
  12963. var elementList;
  12964. var employeeNode;
  12965. var childList;
  12966. var newdocFragment;
  12967. var newChild1;
  12968. var newChild2;
  12969. var child;
  12970. var childName;
  12971. var result = new Array();
  12972. var nodeType;
  12973. var appendedChild;
  12974. expected = new Array();
  12975. expected[0] = "employeeId";
  12976. expected[1] = "name";
  12977. expected[2] = "position";
  12978. expected[3] = "salary";
  12979. expected[4] = "gender";
  12980. expected[5] = "address";
  12981. expected[6] = "newChild1";
  12982. expected[7] = "newChild2";
  12983. doc = staff.staff();
  12984. elementList = doc.getElementsByTagName("employee");
  12985. employeeNode = elementList.item(1);
  12986. childList = employeeNode.childNodes;
  12987. newdocFragment = doc.createDocumentFragment();
  12988. newChild1 = doc.createElement("newChild1");
  12989. newChild2 = doc.createElement("newChild2");
  12990. appendedChild = newdocFragment.appendChild(newChild1);
  12991. appendedChild = newdocFragment.appendChild(newChild2);
  12992. appendedChild = employeeNode.appendChild(newdocFragment);
  12993. for(var indexN1009F = 0;indexN1009F < childList.length; indexN1009F++) {
  12994. child = childList.item(indexN1009F);
  12995. nodeType = child.nodeType;
  12996. if(
  12997. (1 == nodeType)
  12998. ) {
  12999. childName = child.nodeName;
  13000. result[result.length] = childName;
  13001. }
  13002. }
  13003. test.deepEqual(result, expected, 'elementNames');
  13004. test.done();
  13005. },
  13006. /**
  13007. *
  13008. The "appendChild(newChild)" method returns the node
  13009. added.
  13010. Append a newly created node to the child list of the
  13011. second employee and check the NodeName returned. The
  13012. "getNodeName()" method should return "newChild".
  13013. * @author NIST
  13014. * @author Mary Brady
  13015. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  13016. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  13017. */
  13018. nodeappendchildgetnodename: function(test) {
  13019. var success;
  13020. var doc;
  13021. var elementList;
  13022. var employeeNode;
  13023. var childList;
  13024. var newChild;
  13025. var appendNode;
  13026. var childName;
  13027. doc = staff.staff();
  13028. elementList = doc.getElementsByTagName("employee");
  13029. employeeNode = elementList.item(1);
  13030. childList = employeeNode.childNodes;
  13031. newChild = doc.createElement("newChild");
  13032. appendNode = employeeNode.appendChild(newChild);
  13033. childName = appendNode.nodeName;
  13034. test.equal(childName, 'newChild', 'nodeAppendChildGetNodeName');
  13035. test.done();
  13036. },
  13037. /**
  13038. *
  13039. The "appendChild(newChild)" method raises a
  13040. HIERARCHY_REQUEST_ERR DOMException if this node is of
  13041. a type that does not allow children of the type "newChild"
  13042. to be inserted.
  13043. Retrieve the root node and attempt to append a newly
  13044. created Attr node. An Element node cannot have children
  13045. of the "Attr" type, therefore the desired exception
  13046. should be raised.
  13047. * @author NIST
  13048. * @author Mary Brady
  13049. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
  13050. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  13051. * @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'])
  13052. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  13053. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  13054. */
  13055. nodeappendchildinvalidnodetype: function(test) {
  13056. var success;
  13057. var doc;
  13058. var rootNode;
  13059. var newChild;
  13060. var appendedChild;
  13061. doc = staff.staff();
  13062. rootNode = doc.documentElement;
  13063. newChild = doc.createAttribute("newAttribute");
  13064. {
  13065. success = false;
  13066. try {
  13067. appendedChild = rootNode.appendChild(newChild);
  13068. }
  13069. catch(ex) {
  13070. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  13071. }
  13072. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  13073. }
  13074. test.done();
  13075. },
  13076. /**
  13077. *
  13078. The "appendChild(newChild)" method raises a
  13079. WRONG_DOCUMENT_ERR DOMException if the "newChild" was
  13080. created from a different document than the one that
  13081. created this node.
  13082. Retrieve the second employee and attempt to append
  13083. a node created from a different document. An attempt
  13084. to make such a replacement should raise the desired
  13085. exception.
  13086. * @author NIST
  13087. * @author Mary Brady
  13088. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
  13089. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  13090. * @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'])
  13091. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  13092. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  13093. */
  13094. nodeappendchildnewchilddiffdocument: function(test) {
  13095. var success;
  13096. var doc1;
  13097. var doc2;
  13098. var newChild;
  13099. var elementList;
  13100. var elementNode;
  13101. var appendedChild;
  13102. var doc1Ref = null;
  13103. if (typeof(this.doc1) != 'undefined') {
  13104. doc1Ref = this.doc1;
  13105. }
  13106. doc1 = staff.staff();
  13107. var doc2Ref = null;
  13108. if (typeof(this.doc2) != 'undefined') {
  13109. doc2Ref = this.doc2;
  13110. }
  13111. doc2 = staff.staff();
  13112. newChild = doc1.createElement("newChild");
  13113. elementList = doc2.getElementsByTagName("employee");
  13114. elementNode = elementList.item(1);
  13115. {
  13116. success = false;
  13117. try {
  13118. appendedChild = elementNode.appendChild(newChild);
  13119. }
  13120. catch(ex) {
  13121. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  13122. }
  13123. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  13124. }
  13125. test.done();
  13126. },
  13127. /**
  13128. *
  13129. The "appendChild(newChild)" method raises a
  13130. HIERARCHY_REQUEST_ERR DOMException if the node to
  13131. append is one of this node's ancestors.
  13132. Retrieve the second employee and attempt to append
  13133. an ancestor node(root node) to it.
  13134. An attempt to make such an addition should raise the
  13135. desired exception.
  13136. * @author NIST
  13137. * @author Mary Brady
  13138. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
  13139. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  13140. * @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'])
  13141. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  13142. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  13143. */
  13144. nodeappendchildnodeancestor: function(test) {
  13145. var success;
  13146. var doc;
  13147. var newChild;
  13148. var elementList;
  13149. var employeeNode;
  13150. var appendedChild;
  13151. doc = staff.staff();
  13152. newChild = doc.documentElement;
  13153. elementList = doc.getElementsByTagName("employee");
  13154. employeeNode = elementList.item(1);
  13155. {
  13156. success = false;
  13157. try {
  13158. appendedChild = employeeNode.appendChild(newChild);
  13159. }
  13160. catch(ex) {
  13161. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  13162. }
  13163. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  13164. }
  13165. test.done();
  13166. },
  13167. /**
  13168. *
  13169. The "appendChild(newChild)" method causes the
  13170. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  13171. if the node is readonly.
  13172. Obtain the children of the THIRD "gender" element. The elements
  13173. content is an entity reference. Get the FIRST item
  13174. from the entity reference and execute the "appendChild(newChild)" method.
  13175. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  13176. * @author NIST
  13177. * @author Mary Brady
  13178. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  13179. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  13180. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  13181. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  13182. */
  13183. nodeappendchildnomodificationallowederr: function(test) {
  13184. var success;
  13185. var doc;
  13186. var genderList;
  13187. var genderNode;
  13188. var entRef;
  13189. var entElement;
  13190. var createdNode;
  13191. var appendedNode;
  13192. var nodeType;
  13193. doc = staff.staff();
  13194. genderList = doc.getElementsByTagName("gender");
  13195. genderNode = genderList.item(2);
  13196. entRef = genderNode.firstChild;
  13197. test.notEqual(entRef, null, 'entRefNotNull');
  13198. nodeType = entRef.nodeType;
  13199. if(
  13200. (1 == nodeType)
  13201. ) {
  13202. entRef = doc.createEntityReference("ent4");
  13203. test.notEqual(entRef, null, 'createdEntRefNotNull');
  13204. }
  13205. entElement = entRef.firstChild;
  13206. test.notEqual(entElement, null, 'entElementNotNull');
  13207. createdNode = doc.createElement("text3");
  13208. {
  13209. success = false;
  13210. try {
  13211. appendedNode = entElement.appendChild(createdNode);
  13212. }
  13213. catch(ex) {
  13214. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  13215. }
  13216. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  13217. }
  13218. test.done();
  13219. },
  13220. /**
  13221. *
  13222. The "appendChild(newChild)" method causes the
  13223. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  13224. if the node is readonly.
  13225. Create an ent4 entity reference and the "appendChild(newChild)" method.
  13226. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  13227. * @author Curt Arnold
  13228. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  13229. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  13230. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  13231. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  13232. * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchildnomodificationallowederr.xml
  13233. */
  13234. nodeappendchildnomodificationallowederrEE: function(test) {
  13235. var success;
  13236. var doc;
  13237. var entRef;
  13238. var createdNode;
  13239. var appendedNode;
  13240. doc = staff.staff();
  13241. entRef = doc.createEntityReference("ent4");
  13242. test.notEqual(entRef, null, 'createdEntRefNotNull');
  13243. createdNode = doc.createElement("text3");
  13244. {
  13245. success = false;
  13246. try {
  13247. appendedNode = entRef.appendChild(createdNode);
  13248. }
  13249. catch(ex) {
  13250. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  13251. }
  13252. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  13253. }
  13254. test.done();
  13255. },
  13256. /**
  13257. *
  13258. The "getAttributes()" method invoked on an Attribute
  13259. Node returns null.
  13260. Retrieve the first attribute from the last child of the
  13261. first employee and invoke the "getAttributes()" method
  13262. on the Attribute Node. It should return null.
  13263. * @author NIST
  13264. * @author Mary Brady
  13265. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  13266. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-637646024
  13267. */
  13268. nodeattributenodeattribute: function(test) {
  13269. var success;
  13270. var doc;
  13271. var elementList;
  13272. var testAddr;
  13273. var addrAttr;
  13274. var attrNode;
  13275. var attrList;
  13276. doc = staff.staff();
  13277. elementList = doc.getElementsByTagName("address");
  13278. testAddr = elementList.item(0);
  13279. addrAttr = testAddr.attributes;
  13280. attrNode = addrAttr.item(0);
  13281. attrList = attrNode.attributes;
  13282. test.equal(attrList, null, 'nodeAttributeNodeAttribute');
  13283. test.done();
  13284. },
  13285. /**
  13286. *
  13287. The string returned by the "getNodeName()" method for an
  13288. Attribute Node is the name of the Attribute.
  13289. Retrieve the Attribute named "domestic" from the last
  13290. child of the first employee and check the string returned
  13291. by the "getNodeName()" method. It should be equal to
  13292. "domestic".
  13293. * @author NIST
  13294. * @author Mary Brady
  13295. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  13296. */
  13297. nodeattributenodename: function(test) {
  13298. var success;
  13299. var doc;
  13300. var elementList;
  13301. var testAddr;
  13302. var addrAttr;
  13303. var attrName;
  13304. doc = staff.staff();
  13305. elementList = doc.getElementsByTagName("address");
  13306. testAddr = elementList.item(0);
  13307. addrAttr = testAddr.getAttributeNode("domestic");
  13308. attrName = addrAttr.nodeName;
  13309. test.equal(attrName, 'domestic', 'nodeAttributeNodeName');
  13310. test.done();
  13311. },
  13312. /**
  13313. *
  13314. The "getNodeType()" method for an Attribute Node
  13315. returns the constant value 2.
  13316. Retrieve the first attribute from the last child of
  13317. the first employee and invoke the "getNodeType()"
  13318. method. The method should return 2.
  13319. * @author NIST
  13320. * @author Mary Brady
  13321. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  13322. */
  13323. nodeattributenodetype: function(test) {
  13324. var success;
  13325. var doc;
  13326. var elementList;
  13327. var testAddr;
  13328. var addrAttr;
  13329. var nodeType;
  13330. doc = staff.staff();
  13331. elementList = doc.getElementsByTagName("address");
  13332. testAddr = elementList.item(0);
  13333. addrAttr = testAddr.getAttributeNode("domestic");
  13334. nodeType = addrAttr.nodeType;
  13335. test.equal(nodeType, 2, 'nodeAttrNodeType');
  13336. test.done();
  13337. },
  13338. /**
  13339. *
  13340. The string returned by the "getNodeValue()" method for an
  13341. Attribute Node is the value of the Attribute.
  13342. Retrieve the Attribute named "domestic" from the last
  13343. child of the first employee and check the string returned
  13344. by the "getNodeValue()" method. It should be equal to
  13345. "Yes".
  13346. * @author NIST
  13347. * @author Mary Brady
  13348. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  13349. */
  13350. nodeattributenodevalue: function(test) {
  13351. var success;
  13352. var doc;
  13353. var elementList;
  13354. var testAddr;
  13355. var addrAttr;
  13356. var attrValue;
  13357. doc = staff.staff();
  13358. elementList = doc.getElementsByTagName("address");
  13359. testAddr = elementList.item(0);
  13360. addrAttr = testAddr.getAttributeNode("domestic");
  13361. attrValue = addrAttr.nodeValue;
  13362. test.equal(attrValue, 'Yes', 'nodeAttributeNodeValue');
  13363. test.done();
  13364. },
  13365. /**
  13366. *
  13367. The "getAttributes()" method invoked on a CDATASection
  13368. Node returns null.
  13369. Retrieve the CDATASection node contained inside the
  13370. second child of the second employee and invoke the
  13371. "getAttributes()" method on the CDATASection node.
  13372. It should return null.
  13373. * @author NIST
  13374. * @author Mary Brady
  13375. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  13376. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-667469212
  13377. */
  13378. nodecdatasectionnodeattribute: function(test) {
  13379. var success;
  13380. var doc;
  13381. var elementList;
  13382. var cdataName;
  13383. var cdataNode;
  13384. var attrList;
  13385. var nodeType;
  13386. doc = staff.staff();
  13387. elementList = doc.getElementsByTagName("name");
  13388. cdataName = elementList.item(1);
  13389. cdataNode = cdataName.lastChild;
  13390. nodeType = cdataNode.nodeType;
  13391. if(
  13392. !(4 == nodeType)
  13393. ) {
  13394. cdataNode = doc.createCDATASection("");
  13395. }
  13396. attrList = cdataNode.attributes;
  13397. test.equal(attrList, null, 'cdataSection');
  13398. test.done();
  13399. },
  13400. /**
  13401. *
  13402. The string returned by the "getNodeName()" method for a
  13403. CDATASection Node is #cdata-section".
  13404. Retrieve the CDATASection node inside the second child
  13405. of the second employee and check the string returned
  13406. by the "getNodeName()" method. It should be equal to
  13407. "#cdata-section".
  13408. * @author NIST
  13409. * @author Mary Brady
  13410. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  13411. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-667469212
  13412. */
  13413. nodecdatasectionnodename: function(test) {
  13414. var success;
  13415. var doc;
  13416. var elementList;
  13417. var cdataName;
  13418. var cdataNode;
  13419. var nodeType;
  13420. var cdataNodeName;
  13421. doc = staff.staff();
  13422. elementList = doc.getElementsByTagName("name");
  13423. cdataName = elementList.item(1);
  13424. cdataNode = cdataName.lastChild;
  13425. nodeType = cdataNode.nodeType;
  13426. if(
  13427. !(4 == nodeType)
  13428. ) {
  13429. cdataNode = doc.createCDATASection("");
  13430. }
  13431. cdataNodeName = cdataNode.nodeName;
  13432. test.equal(cdataNodeName, '#cdata-section', 'cdataNodeName');
  13433. test.done();
  13434. },
  13435. /**
  13436. *
  13437. The "getNodeType()" method for a CDATASection Node
  13438. returns the constant value 4.
  13439. Retrieve the CDATASection node contained inside the
  13440. second child of the second employee and invoke the
  13441. "getNodeType()" method. The method should return 4.
  13442. * @author NIST
  13443. * @author Mary Brady
  13444. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  13445. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-667469212
  13446. */
  13447. nodecdatasectionnodetype: function(test) {
  13448. var success;
  13449. var doc;
  13450. var elementList;
  13451. var testName;
  13452. var cdataNode;
  13453. var nodeType;
  13454. doc = staff.staff();
  13455. elementList = doc.getElementsByTagName("name");
  13456. testName = elementList.item(1);
  13457. cdataNode = testName.lastChild;
  13458. nodeType = cdataNode.nodeType;
  13459. if(
  13460. (3 == nodeType)
  13461. ) {
  13462. cdataNode = doc.createCDATASection("");
  13463. nodeType = cdataNode.nodeType;
  13464. }
  13465. test.equal(nodeType, 4, 'nodeTypeCDATA');
  13466. test.done();
  13467. },
  13468. /**
  13469. *
  13470. The string returned by the "getNodeValue()" method for a
  13471. CDATASection Node is the content of the CDATASection.
  13472. Retrieve the CDATASection node inside the second child
  13473. of the second employee and check the string returned
  13474. by the "getNodeValue()" method. It should be equal to
  13475. "This is a CDATA Section with EntityReference number 2
  13476. &ent2;".
  13477. * @author NIST
  13478. * @author Mary Brady
  13479. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  13480. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-667469212
  13481. */
  13482. nodecdatasectionnodevalue: function(test) {
  13483. var success;
  13484. var doc;
  13485. var elementList;
  13486. var cdataName;
  13487. var childList;
  13488. var child;
  13489. var cdataNodeValue;
  13490. doc = staff.staff();
  13491. elementList = doc.getElementsByTagName("name");
  13492. cdataName = elementList.item(1);
  13493. childList = cdataName.childNodes;
  13494. child = childList.item(1);
  13495. if(
  13496. (child == null)
  13497. ) {
  13498. child = doc.createCDATASection("This is a CDATASection with EntityReference number 2 &ent2;");
  13499. }
  13500. cdataNodeValue = child.nodeValue;
  13501. test.equal(cdataNodeValue, 'This is a CDATASection with EntityReference number 2 &ent2;', 'value');
  13502. test.done();
  13503. },
  13504. /**
  13505. *
  13506. Collect the element names from Node.childNodes and check against expectations.
  13507. * @author NIST
  13508. * @author Mary Brady
  13509. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  13510. */
  13511. nodechildnodes: function(test) {
  13512. var success;
  13513. var doc;
  13514. var elementList;
  13515. var employeeNode;
  13516. var childNodes;
  13517. var childNode;
  13518. var childType;
  13519. var childName;
  13520. var elementNames = new Array();
  13521. expectedElementNames = new Array();
  13522. expectedElementNames[0] = "employeeId";
  13523. expectedElementNames[1] = "name";
  13524. expectedElementNames[2] = "position";
  13525. expectedElementNames[3] = "salary";
  13526. expectedElementNames[4] = "gender";
  13527. expectedElementNames[5] = "address";
  13528. doc = staff.staff();
  13529. elementList = doc.getElementsByTagName("employee");
  13530. employeeNode = elementList.item(1);
  13531. childNodes = employeeNode.childNodes;
  13532. for(var indexN1006C = 0;indexN1006C < childNodes.length; indexN1006C++) {
  13533. childNode = childNodes.item(indexN1006C);
  13534. childType = childNode.nodeType;
  13535. if(
  13536. (1 == childType)
  13537. ) {
  13538. childName = childNode.nodeName;
  13539. elementNames[elementNames.length] = childName;
  13540. }
  13541. }
  13542. test.deepEqual(elementNames, expectedElementNames, 'elementNames');
  13543. test.done();
  13544. },
  13545. /**
  13546. *
  13547. Add an element and check that the previously retrieved childNodes NodeList
  13548. is live.
  13549. * @author NIST
  13550. * @author Mary Brady
  13551. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  13552. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-184E7107
  13553. */
  13554. nodechildnodesappendchild: function(test) {
  13555. var success;
  13556. var doc;
  13557. var elementList;
  13558. var employeeNode;
  13559. var childList;
  13560. var createdNode;
  13561. var expectedLength;
  13562. var length;
  13563. doc = staff.staff();
  13564. elementList = doc.getElementsByTagName("employee");
  13565. employeeNode = elementList.item(1);
  13566. childList = employeeNode.childNodes;
  13567. expectedLength = childList.length;
  13568. expectedLength += 1;
  13569. createdNode = doc.createElement("text3");
  13570. employeeNode = employeeNode.appendChild(createdNode);
  13571. length = childList.length;
  13572. test.equal(length, expectedLength, 'childNodeLength');
  13573. test.done();
  13574. },
  13575. /**
  13576. *
  13577. The "getChildNodes()" method returns a NodeList
  13578. that contains all children of this node. If there
  13579. are not any children, this is a NodeList that does not
  13580. contain any nodes.
  13581. Retrieve the Text node from the second child of the second
  13582. employee and invoke the "getChildNodes()" method. The
  13583. NodeList returned should not have any nodes.
  13584. * @author NIST
  13585. * @author Mary Brady
  13586. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  13587. */
  13588. nodechildnodesempty: function(test) {
  13589. var success;
  13590. var doc;
  13591. var elementList;
  13592. var employeeNode;
  13593. var childList;
  13594. var secondCNode;
  13595. var textNode;
  13596. var childNodesList;
  13597. doc = staff.staff();
  13598. elementList = doc.getElementsByTagName("employee");
  13599. employeeNode = elementList.item(1);
  13600. childList = employeeNode.childNodes;
  13601. secondCNode = childList.item(1);
  13602. textNode = secondCNode.firstChild;
  13603. childNodesList = textNode.childNodes;
  13604. test.equal(childNodesList.length, 0, 'nodeChildNodesEmpty');
  13605. test.done();
  13606. },
  13607. /**
  13608. *
  13609. If the cloneNode method is used to clone an
  13610. Element node, all the attributes of the Element are
  13611. copied along with their values.
  13612. Retrieve the last child of the second employee and invoke
  13613. the cloneNode method. The
  13614. duplicate node returned by the method should copy the
  13615. attributes associated with this node.
  13616. * @author NIST
  13617. * @author Mary Brady
  13618. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  13619. */
  13620. nodecloneattributescopied: function(test) {
  13621. var success;
  13622. var doc;
  13623. var elementList;
  13624. var addressNode;
  13625. var clonedNode;
  13626. var attributes;
  13627. var attributeNode;
  13628. var attributeName;
  13629. var result = new Array();
  13630. expectedResult = new Array();
  13631. expectedResult[0] = "domestic";
  13632. expectedResult[1] = "street";
  13633. doc = staff.staff();
  13634. elementList = doc.getElementsByTagName("address");
  13635. addressNode = elementList.item(1);
  13636. clonedNode = addressNode.cloneNode(false);
  13637. attributes = clonedNode.attributes;
  13638. for(var indexN10065 = 0;indexN10065 < attributes.length; indexN10065++) {
  13639. attributeNode = attributes.item(indexN10065);
  13640. attributeName = attributeNode.nodeName;
  13641. result[result.length] = attributeName;
  13642. }
  13643. domTestHelper.assertEqualsCollection(test, result, expectedResult, 'nodeCloneAttributesCopied');
  13644. test.done();
  13645. },
  13646. /**
  13647. *
  13648. The "cloneNode(deep)" method does not copy text unless it
  13649. is deep cloned.(Test for deep=false)
  13650. Retrieve the fourth child of the second employee and
  13651. the "cloneNode(deep)" method with deep=false. The
  13652. duplicate node returned by the method should not copy
  13653. any text data contained in this node.
  13654. * @author NIST
  13655. * @author Mary Brady
  13656. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
  13657. */
  13658. nodeclonefalsenocopytext: function(test) {
  13659. var success;
  13660. var doc;
  13661. var elementList;
  13662. var employeeNode;
  13663. var childList;
  13664. var childNode;
  13665. var clonedNode;
  13666. var lastChildNode;
  13667. doc = staff.staff();
  13668. elementList = doc.getElementsByTagName("employee");
  13669. employeeNode = elementList.item(1);
  13670. childList = employeeNode.childNodes;
  13671. childNode = childList.item(3);
  13672. clonedNode = childNode.cloneNode(false);
  13673. lastChildNode = clonedNode.lastChild;
  13674. test.equal(lastChildNode, null, 'noTextNodes');
  13675. test.done();
  13676. },
  13677. /**
  13678. *
  13679. The duplicate node returned by the "cloneNode(deep)"
  13680. method does not have a ParentNode.
  13681. Retrieve the second employee and invoke the
  13682. "cloneNode(deep)" method with deep=false. The
  13683. duplicate node returned should return null when the
  13684. "getParentNode()" is invoked.
  13685. * @author NIST
  13686. * @author Mary Brady
  13687. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
  13688. */
  13689. nodeclonegetparentnull: function(test) {
  13690. var success;
  13691. var doc;
  13692. var elementList;
  13693. var employeeNode;
  13694. var clonedNode;
  13695. var parentNode;
  13696. doc = staff.staff();
  13697. elementList = doc.getElementsByTagName("employee");
  13698. employeeNode = elementList.item(1);
  13699. clonedNode = employeeNode.cloneNode(false);
  13700. parentNode = clonedNode.parentNode;
  13701. test.equal(parentNode, null, 'nodeCloneGetParentNull');
  13702. test.done();
  13703. },
  13704. /**
  13705. *
  13706. The "cloneNode(deep)" method returns a copy of the node
  13707. only if deep=false.
  13708. Retrieve the second employee and invoke the
  13709. "cloneNode(deep)" method with deep=false. The
  13710. method should only clone this node. The NodeName and
  13711. length of the NodeList are checked. The "getNodeName()"
  13712. method should return "employee" and the "getLength()"
  13713. method should return 0.
  13714. * @author NIST
  13715. * @author Mary Brady
  13716. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
  13717. */
  13718. nodeclonenodefalse: function(test) {
  13719. var success;
  13720. var doc;
  13721. var elementList;
  13722. var employeeNode;
  13723. var clonedNode;
  13724. var cloneName;
  13725. var cloneChildren;
  13726. var length;
  13727. doc = staff.staff();
  13728. elementList = doc.getElementsByTagName("employee");
  13729. employeeNode = elementList.item(1);
  13730. clonedNode = employeeNode.cloneNode(false);
  13731. cloneName = clonedNode.nodeName;
  13732. test.equal(cloneName, 'employee', 'name');
  13733. cloneChildren = clonedNode.childNodes;
  13734. length = cloneChildren.length;
  13735. test.equal(length, 0, 'length');
  13736. test.done();
  13737. },
  13738. /**
  13739. *
  13740. The "cloneNode(deep)" method returns a copy of the node
  13741. and the subtree under it if deep=true.
  13742. Retrieve the second employee and invoke the
  13743. "cloneNode(deep)" method with deep=true. The
  13744. method should clone this node and the subtree under it.
  13745. The NodeName of each child in the returned node is
  13746. checked to insure the entire subtree under the second
  13747. employee was cloned.
  13748. * @author NIST
  13749. * @author Mary Brady
  13750. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
  13751. */
  13752. nodeclonenodetrue: function(test) {
  13753. var success;
  13754. var doc;
  13755. var elementList;
  13756. var employeeNode;
  13757. var childList;
  13758. var clonedNode;
  13759. var clonedList;
  13760. var clonedChild;
  13761. var clonedChildName;
  13762. var length;
  13763. var result = new Array();
  13764. expectedWhitespace = new Array();
  13765. expectedWhitespace[0] = "#text";
  13766. expectedWhitespace[1] = "employeeId";
  13767. expectedWhitespace[2] = "#text";
  13768. expectedWhitespace[3] = "name";
  13769. expectedWhitespace[4] = "#text";
  13770. expectedWhitespace[5] = "position";
  13771. expectedWhitespace[6] = "#text";
  13772. expectedWhitespace[7] = "salary";
  13773. expectedWhitespace[8] = "#text";
  13774. expectedWhitespace[9] = "gender";
  13775. expectedWhitespace[10] = "#text";
  13776. expectedWhitespace[11] = "address";
  13777. expectedWhitespace[12] = "#text";
  13778. expectedNoWhitespace = new Array();
  13779. expectedNoWhitespace[0] = "employeeId";
  13780. expectedNoWhitespace[1] = "name";
  13781. expectedNoWhitespace[2] = "position";
  13782. expectedNoWhitespace[3] = "salary";
  13783. expectedNoWhitespace[4] = "gender";
  13784. expectedNoWhitespace[5] = "address";
  13785. doc = staff.staff();
  13786. elementList = doc.getElementsByTagName("employee");
  13787. employeeNode = elementList.item(1);
  13788. childList = employeeNode.childNodes;
  13789. length = childList.length;
  13790. clonedNode = employeeNode.cloneNode(true);
  13791. clonedList = clonedNode.childNodes;
  13792. for(var indexN100AE = 0;indexN100AE < clonedList.length; indexN100AE++) {
  13793. clonedChild = clonedList.item(indexN100AE);
  13794. clonedChildName = clonedChild.nodeName;
  13795. result[result.length] = clonedChildName;
  13796. }
  13797. if(
  13798. (6 == length)
  13799. ) {
  13800. test.deepEqual(result, expectedNoWhitespace, 'nowhitespace');
  13801. }
  13802. else {
  13803. test.deepEqual(result, expectedWhitespace, 'whitespace');
  13804. }
  13805. test.done();
  13806. },
  13807. /**
  13808. *
  13809. Retrieve the second salary and
  13810. the "cloneNode(deep)" method with deep=true. The
  13811. duplicate node returned by the method should copy
  13812. any text data contained in this node.
  13813. * @author NIST
  13814. * @author Mary Brady
  13815. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-3A0ED0A4
  13816. */
  13817. nodeclonetruecopytext: function(test) {
  13818. var success;
  13819. var doc;
  13820. var elementList;
  13821. var childList;
  13822. var childNode;
  13823. var clonedNode;
  13824. var lastChildNode;
  13825. var childValue;
  13826. doc = staff.staff();
  13827. elementList = doc.getElementsByTagName("salary");
  13828. childNode = elementList.item(1);
  13829. clonedNode = childNode.cloneNode(true);
  13830. lastChildNode = clonedNode.lastChild;
  13831. childValue = lastChildNode.nodeValue;
  13832. test.equal(childValue, '35,000', 'nodeCloneTrueCopyText');
  13833. test.done();
  13834. },
  13835. /**
  13836. *
  13837. The "getAttributes()" method invoked on a Comment
  13838. Node returns null.
  13839. Find any comment that is an immediate child of the root
  13840. and assert that Node.attributes is null. Then create
  13841. a new comment node (in case they had been omitted) and
  13842. make the assertion.
  13843. * @author NIST
  13844. * @author Mary Brady
  13845. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  13846. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
  13847. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=248
  13848. */
  13849. nodecommentnodeattributes: function(test) {
  13850. var success;
  13851. var doc;
  13852. var childList;
  13853. var childNode;
  13854. var attrList;
  13855. var nodeType;
  13856. doc = staff.staff();
  13857. childList = doc.childNodes;
  13858. for(var indexN10043 = 0;indexN10043 < childList.length; indexN10043++) {
  13859. childNode = childList.item(indexN10043);
  13860. nodeType = childNode.nodeType;
  13861. if(
  13862. (8 == nodeType)
  13863. ) {
  13864. attrList = childNode.attributes;
  13865. test.equal(attrList, null, 'attributesNull');
  13866. }
  13867. }
  13868. childNode = doc.createComment("This is a comment");
  13869. attrList = childNode.attributes;
  13870. test.equal(attrList, null, 'createdAttributesNull');
  13871. test.done();
  13872. },
  13873. /**
  13874. *
  13875. The string returned by the "getNodeName()" method for a
  13876. Comment Node is "#comment".
  13877. Retrieve the Comment node in the XML file
  13878. and check the string returned by the "getNodeName()"
  13879. method. It should be equal to "#comment".
  13880. * @author NIST
  13881. * @author Mary Brady
  13882. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  13883. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
  13884. */
  13885. nodecommentnodename: function(test) {
  13886. var success;
  13887. var doc;
  13888. var elementList;
  13889. var commentNode;
  13890. var nodeType;
  13891. var commentNodeName;
  13892. doc = staff.staff();
  13893. elementList = doc.childNodes;
  13894. for(var indexN10040 = 0;indexN10040 < elementList.length; indexN10040++) {
  13895. commentNode = elementList.item(indexN10040);
  13896. nodeType = commentNode.nodeType;
  13897. if(
  13898. (8 == nodeType)
  13899. ) {
  13900. commentNodeName = commentNode.nodeName;
  13901. test.equal(commentNodeName, '#comment', 'commentNodeName');
  13902. }
  13903. }
  13904. test.done();
  13905. },
  13906. /**
  13907. *
  13908. The "getNodeType()" method for a Comment Node
  13909. returns the constant value 8.
  13910. Retrieve the nodes from the document and check for
  13911. a comment node and invoke the "getNodeType()" method. This should
  13912. return 8.
  13913. * @author NIST
  13914. * @author Mary Brady
  13915. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  13916. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
  13917. */
  13918. nodecommentnodetype: function(test) {
  13919. var success;
  13920. var doc;
  13921. var testList;
  13922. var commentNode;
  13923. var commentNodeName;
  13924. var nodeType;
  13925. doc = staff.staff();
  13926. testList = doc.childNodes;
  13927. for(var indexN10040 = 0;indexN10040 < testList.length; indexN10040++) {
  13928. commentNode = testList.item(indexN10040);
  13929. commentNodeName = commentNode.nodeName;
  13930. if(
  13931. ("#comment" == commentNodeName)
  13932. ) {
  13933. nodeType = commentNode.nodeType;
  13934. test.equal(nodeType, 8, 'nodeCommentNodeType');
  13935. }
  13936. }
  13937. test.done();
  13938. },
  13939. /**
  13940. *
  13941. The string returned by the "getNodeValue()" method for a
  13942. Comment Node is the content of the comment.
  13943. Retrieve the comment in the XML file and
  13944. check the string returned by the "getNodeValue()" method.
  13945. It should be equal to "This is comment number 1".
  13946. * @author NIST
  13947. * @author Mary Brady
  13948. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  13949. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
  13950. */
  13951. nodecommentnodevalue: function(test) {
  13952. var success;
  13953. var doc;
  13954. var elementList;
  13955. var commentNode;
  13956. var commentName;
  13957. var commentValue;
  13958. doc = staff.staff();
  13959. elementList = doc.childNodes;
  13960. for(var indexN10040 = 0;indexN10040 < elementList.length; indexN10040++) {
  13961. commentNode = elementList.item(indexN10040);
  13962. commentName = commentNode.nodeName;
  13963. if(
  13964. ("#comment" == commentName)
  13965. ) {
  13966. commentValue = commentNode.nodeValue;
  13967. test.equal(commentValue, ' This is comment number 1.', 'value');
  13968. }
  13969. }
  13970. test.done();
  13971. },
  13972. /**
  13973. *
  13974. The string returned by the "getNodeName()" method for a
  13975. DocumentFragment Node is "#document-frament".
  13976. Retrieve the DOM document and invoke the
  13977. "createDocumentFragment()" method and check the string
  13978. returned by the "getNodeName()" method. It should be
  13979. equal to "#document-fragment".
  13980. * @author NIST
  13981. * @author Mary Brady
  13982. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  13983. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
  13984. */
  13985. nodedocumentfragmentnodename: function(test) {
  13986. var success;
  13987. var doc;
  13988. var docFragment;
  13989. var documentFragmentName;
  13990. doc = staff.staff();
  13991. docFragment = doc.createDocumentFragment();
  13992. documentFragmentName = docFragment.nodeName;
  13993. test.equal(documentFragmentName, '#document-fragment', 'nodeDocumentFragmentNodeName');
  13994. test.done();
  13995. },
  13996. /**
  13997. *
  13998. The "getNodeType()" method for a DocumentFragment Node
  13999. returns the constant value 11.
  14000. Invoke the "createDocumentFragment()" method and
  14001. examine the NodeType of the document fragment
  14002. returned by the "getNodeType()" method. The method
  14003. should return 11.
  14004. * @author NIST
  14005. * @author Mary Brady
  14006. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  14007. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
  14008. */
  14009. nodedocumentfragmentnodetype: function(test) {
  14010. var success;
  14011. var doc;
  14012. var documentFragmentNode;
  14013. var nodeType;
  14014. doc = staff.staff();
  14015. documentFragmentNode = doc.createDocumentFragment();
  14016. nodeType = documentFragmentNode.nodeType;
  14017. test.equal(nodeType, 11, 'nodeDocumentFragmentNodeType');
  14018. test.done();
  14019. },
  14020. /**
  14021. *
  14022. The string returned by the "getNodeValue()" method for a
  14023. DocumentFragment Node is null.
  14024. Retrieve the DOM document and invoke the
  14025. "createDocumentFragment()" method and check the string
  14026. returned by the "getNodeValue()" method. It should be
  14027. equal to null.
  14028. * @author NIST
  14029. * @author Mary Brady
  14030. * @author Curt Arnold
  14031. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
  14032. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  14033. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  14034. */
  14035. nodedocumentfragmentnodevalue: function(test) {
  14036. var success;
  14037. var doc;
  14038. var docFragment;
  14039. var attrList;
  14040. var value;
  14041. doc = staff.staff();
  14042. docFragment = doc.createDocumentFragment();
  14043. attrList = docFragment.attributes;
  14044. test.equal(attrList, null, 'attributesNull');
  14045. value = docFragment.nodeValue;
  14046. test.equal(value, null, 'initiallyNull');
  14047. test.done();
  14048. },
  14049. /**
  14050. *
  14051. The "getAttributes()" method invoked on a Document
  14052. Node returns null.
  14053. * @author NIST
  14054. * @author Mary Brady
  14055. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  14056. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
  14057. */
  14058. nodedocumentnodeattribute: function(test) {
  14059. var success;
  14060. var doc;
  14061. var attrList;
  14062. doc = staff.staff();
  14063. attrList = doc.attributes;
  14064. test.equal(attrList, null, 'documentAttributesNull');
  14065. test.done();
  14066. },
  14067. /**
  14068. *
  14069. The string returned by the "getNodeName()" method for a
  14070. Document Node is "#document".
  14071. Retrieve the DOM document and check the string returned
  14072. by the "getNodeName()" method. It should be equal to
  14073. "#document".
  14074. * @author NIST
  14075. * @author Mary Brady
  14076. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
  14077. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  14078. */
  14079. nodedocumentnodename: function(test) {
  14080. var success;
  14081. var doc;
  14082. var documentName;
  14083. doc = staff.staff();
  14084. documentName = doc.nodeName;
  14085. test.equal(documentName, '#document', 'documentNodeName');
  14086. test.done();
  14087. },
  14088. /**
  14089. *
  14090. The "getNodeType()" method for a Document Node
  14091. returns the constant value 9.
  14092. Retrieve the document and invoke the "getNodeType()"
  14093. method. The method should return 9.
  14094. * @author NIST
  14095. * @author Mary Brady
  14096. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
  14097. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  14098. */
  14099. nodedocumentnodetype: function(test) {
  14100. var success;
  14101. var doc;
  14102. var nodeType;
  14103. doc = staff.staff();
  14104. nodeType = doc.nodeType;
  14105. test.equal(nodeType, 9, 'nodeDocumentNodeType');
  14106. test.done();
  14107. },
  14108. /**
  14109. *
  14110. The string returned by the "getNodeValue()" method for a
  14111. Document Node is null.
  14112. Retrieve the DOM Document and check the string returned
  14113. by the "getNodeValue()" method. It should be equal to
  14114. null.
  14115. * @author NIST
  14116. * @author Mary Brady
  14117. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
  14118. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  14119. */
  14120. nodedocumentnodevalue: function(test) {
  14121. var success;
  14122. var doc;
  14123. var documentValue;
  14124. doc = staff.staff();
  14125. documentValue = doc.nodeValue;
  14126. test.equal(documentValue, null, 'documentNodeValueNull');
  14127. test.done();
  14128. },
  14129. /**
  14130. *
  14131. Retrieve the DOCTYPE declaration from the XML file and
  14132. check the string returned by the "getNodeName()"
  14133. method. It should be equal to "staff" or "svg".
  14134. * @author NIST
  14135. * @author Mary Brady
  14136. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  14137. */
  14138. nodedocumenttypenodename: function(test) {
  14139. var success;
  14140. var doc;
  14141. var docType;
  14142. var documentTypeName;
  14143. doc = staff.staff();
  14144. docType = doc.doctype;
  14145. test.notEqual(docType, null, 'docTypeNotNull');
  14146. documentTypeName = docType.nodeName;
  14147. test.equal(documentTypeName, 'svg', 'doctypeNameSVG');
  14148. test.done();
  14149. },
  14150. /**
  14151. *
  14152. The "getNodeType()" method for a DocumentType Node
  14153. returns the constant value 10.
  14154. * @author NIST
  14155. * @author Mary Brady
  14156. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  14157. */
  14158. nodedocumenttypenodetype: function(test) {
  14159. var success;
  14160. var doc;
  14161. var documentTypeNode;
  14162. var nodeType;
  14163. doc = staff.staff();
  14164. documentTypeNode = doc.doctype;
  14165. test.notEqual(documentTypeNode, null, 'doctypeNotNull');
  14166. nodeType = documentTypeNode.nodeType;
  14167. test.equal(nodeType, 10, 'nodeType');
  14168. test.done();
  14169. },
  14170. /**
  14171. *
  14172. The string returned by the "getNodeValue()" method for a
  14173. DocumentType Node is null.
  14174. * @author NIST
  14175. * @author Mary Brady
  14176. */
  14177. nodedocumenttypenodevalue: function(test) {
  14178. var success;
  14179. var doc;
  14180. var docType;
  14181. var attrList;
  14182. doc = staff.staff();
  14183. docType = doc.doctype;
  14184. test.notEqual(docType, null, 'docTypeNotNull');
  14185. attrList = docType.attributes;
  14186. test.equal(attrList, null, 'doctypeAttributesNull');
  14187. test.done();
  14188. },
  14189. /**
  14190. *
  14191. The "getAttributes()" method invoked on an Element
  14192. Node returns a NamedNodeMap containing the attributes
  14193. of this node.
  14194. Retrieve the last child of the third employee and
  14195. invoke the "getAttributes()" method. It should return
  14196. a NamedNodeMap containing the attributes of the Element
  14197. node.
  14198. * @author NIST
  14199. * @author Mary Brady
  14200. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  14201. */
  14202. nodeelementnodeattributes: function(test) {
  14203. var success;
  14204. var doc;
  14205. var elementList;
  14206. var testAddr;
  14207. var addrAttr;
  14208. var attrNode;
  14209. var attrName;
  14210. var attrList = new Array();
  14211. expected = new Array();
  14212. expected[0] = "domestic";
  14213. expected[1] = "street";
  14214. doc = staff.staff();
  14215. elementList = doc.getElementsByTagName("address");
  14216. testAddr = elementList.item(2);
  14217. addrAttr = testAddr.attributes;
  14218. for(var indexN1005C = 0;indexN1005C < addrAttr.length; indexN1005C++) {
  14219. attrNode = addrAttr.item(indexN1005C);
  14220. attrName = attrNode.nodeName;
  14221. attrList[attrList.length] = attrName;
  14222. }
  14223. domTestHelper.assertEqualsCollection(test, attrList, expectedResult, 'nodeElementNodeValue');
  14224. test.done();
  14225. },
  14226. /**
  14227. *
  14228. The string returned by the "getNodeName()" method for an
  14229. Element Node is its tagName.
  14230. Retrieve the first Element Node(Root Node) of the
  14231. DOM object and check the string returned by the
  14232. "getNodeName()" method. It should be equal to its
  14233. tagName.
  14234. * @author NIST
  14235. * @author Mary Brady
  14236. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  14237. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
  14238. */
  14239. nodeelementnodename: function(test) {
  14240. var success;
  14241. var doc;
  14242. var elementNode;
  14243. var elementName;
  14244. doc = staff.staff();
  14245. elementNode = doc.documentElement;
  14246. elementName = elementNode.nodeName;
  14247. test.equal(elementName, 'svg', 'svgNodeName');
  14248. test.done();
  14249. },
  14250. /**
  14251. *
  14252. The "getNodeType()" method for an Element Node
  14253. returns the constant value 1.
  14254. Retrieve the root node and invoke the "getNodeType()"
  14255. method. The method should return 1.
  14256. * @author NIST
  14257. * @author Mary Brady
  14258. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  14259. */
  14260. nodeelementnodetype: function(test) {
  14261. var success;
  14262. var doc;
  14263. var rootNode;
  14264. var nodeType;
  14265. doc = staff.staff();
  14266. rootNode = doc.documentElement;
  14267. nodeType = rootNode.nodeType;
  14268. test.equal(nodeType, 1, 'nodeElementNodeType');
  14269. test.done();
  14270. },
  14271. /**
  14272. *
  14273. The string returned by the "getNodeValue()" method for an
  14274. Element Node is null.
  14275. * @author NIST
  14276. * @author Mary Brady
  14277. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  14278. */
  14279. nodeelementnodevalue: function(test) {
  14280. var success;
  14281. var doc;
  14282. var elementNode;
  14283. var elementValue;
  14284. doc = staff.staff();
  14285. elementNode = doc.documentElement;
  14286. elementValue = elementNode.nodeValue;
  14287. test.equal(elementValue, null, 'elementNodeValueNull');
  14288. test.done();
  14289. },
  14290. /**
  14291. *
  14292. The "getAttributes()" method invoked on an Entity
  14293. Node returns null.
  14294. * @author NIST
  14295. * @author Mary Brady
  14296. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  14297. */
  14298. nodeentitynodeattributes: function(test) {
  14299. var success;
  14300. var doc;
  14301. var docType;
  14302. var entities;
  14303. var entityNode;
  14304. var attrList;
  14305. doc = staff.staff();
  14306. docType = doc.doctype;
  14307. test.notEqual(docType, null, 'docTypeNotNull');
  14308. entities = docType.entities;
  14309. test.notEqual(entities, null, 'entitiesNotNull');
  14310. entityNode = entities.getNamedItem("ent1");
  14311. test.notEqual(entityNode, null, 'ent1NotNull');
  14312. attrList = entityNode.attributes;
  14313. test.equal(attrList, null, 'entityAttributesNull');
  14314. test.done();
  14315. },
  14316. /**
  14317. *
  14318. Check the nodeName of the entity returned by DocumentType.entities.getNamedItem("ent1").
  14319. * @author NIST
  14320. * @author Mary Brady
  14321. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  14322. */
  14323. nodeentitynodename: function(test) {
  14324. var success;
  14325. var doc;
  14326. var docType;
  14327. var entities;
  14328. var entityNode;
  14329. var entityName;
  14330. doc = staff.staff();
  14331. docType = doc.doctype;
  14332. test.notEqual(docType, null, 'docTypeNotNull');
  14333. entities = docType.entities;
  14334. test.notEqual(entities, null, 'entitiesNotNull');
  14335. entityNode = entities.getNamedItem("ent1");
  14336. test.notEqual(entityNode, null, 'entityNodeNotNull');
  14337. entityName = entityNode.nodeName;
  14338. test.equal(entityName, 'ent1', 'entityNodeName');
  14339. test.done();
  14340. },
  14341. /**
  14342. *
  14343. The "getNodeType()" method for an Entity Node
  14344. returns the constant value 6.
  14345. * @author NIST
  14346. * @author Mary Brady
  14347. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  14348. */
  14349. nodeentitynodetype: function(test) {
  14350. var success;
  14351. var doc;
  14352. var docType;
  14353. var entities;
  14354. var entityNode;
  14355. var nodeType;
  14356. doc = staff.staff();
  14357. docType = doc.doctype;
  14358. test.notEqual(docType, null, 'docTypeNotNull');
  14359. entities = docType.entities;
  14360. test.notEqual(entities, null, 'entitiesNotNull');
  14361. entityNode = entities.getNamedItem("ent1");
  14362. test.notEqual(entityNode, null, 'ent1NotNull');
  14363. nodeType = entityNode.nodeType;
  14364. test.equal(nodeType, 6, 'entityNodeType');
  14365. test.done();
  14366. },
  14367. /**
  14368. *
  14369. The string returned by the "getNodeValue()" method for an
  14370. Entity Node is null.
  14371. * @author NIST
  14372. * @author Mary Brady
  14373. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  14374. */
  14375. nodeentitynodevalue: function(test) {
  14376. var success;
  14377. var doc;
  14378. var docType;
  14379. var entities;
  14380. var entityNode;
  14381. var entityValue;
  14382. doc = staff.staff();
  14383. docType = doc.doctype;
  14384. test.notEqual(docType, null, 'docTypeNotNull');
  14385. entities = docType.entities;
  14386. test.notEqual(entities, null, 'entitiesNotNull');
  14387. entityNode = entities.getNamedItem("ent1");
  14388. test.notEqual(entityNode, null, 'ent1NotNull');
  14389. entityValue = entityNode.nodeValue;
  14390. test.equal(entityValue, null, 'entityNodeValue');
  14391. test.done();
  14392. },
  14393. /**
  14394. *
  14395. The "getAttributes()" method invoked on an EntityReference
  14396. Node returns null.
  14397. * @author NIST
  14398. * @author Mary Brady
  14399. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  14400. */
  14401. nodeentityreferencenodeattributes: function(test) {
  14402. var success;
  14403. var doc;
  14404. var elementList;
  14405. var entRefAddr;
  14406. var entRefNode;
  14407. var attrList;
  14408. var nodeType;
  14409. doc = staff.staff();
  14410. elementList = doc.getElementsByTagName("address");
  14411. entRefAddr = elementList.item(1);
  14412. entRefNode = entRefAddr.firstChild;
  14413. nodeType = entRefNode.nodeType;
  14414. if(
  14415. !(5 == nodeType)
  14416. ) {
  14417. entRefNode = doc.createEntityReference("ent2");
  14418. test.notEqual(entRefNode, null, 'createdEntRefNotNull');
  14419. }
  14420. attrList = entRefNode.attributes;
  14421. test.equal(attrList, null, 'attrList');
  14422. test.done();
  14423. },
  14424. /**
  14425. *
  14426. The string returned by the "getNodeName()" method for an
  14427. EntityReference Node is the name of the entity referenced.
  14428. Retrieve the first Entity Reference node from the last
  14429. child of the second employee and check the string
  14430. returned by the "getNodeName()" method. It should be
  14431. equal to "ent2".
  14432. * @author NIST
  14433. * @author Mary Brady
  14434. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  14435. */
  14436. nodeentityreferencenodename: function(test) {
  14437. var success;
  14438. var doc;
  14439. var elementList;
  14440. var entRefAddr;
  14441. var entRefNode;
  14442. var entRefName;
  14443. var nodeType;
  14444. doc = staff.staff();
  14445. elementList = doc.getElementsByTagName("address");
  14446. entRefAddr = elementList.item(1);
  14447. entRefNode = entRefAddr.firstChild;
  14448. nodeType = entRefNode.nodeType;
  14449. if(
  14450. !(5 == nodeType)
  14451. ) {
  14452. entRefNode = doc.createEntityReference("ent2");
  14453. test.notEqual(entRefNode, null, 'createdEntRefNotNull');
  14454. }
  14455. entRefName = entRefNode.nodeName;
  14456. test.equal(entRefName, 'ent2', 'nodeEntityReferenceNodeName');
  14457. test.done();
  14458. },
  14459. /**
  14460. *
  14461. The "getNodeType()" method for an EntityReference Node
  14462. returns the constant value 5.
  14463. Retrieve the EntityReference node from the last child
  14464. of the second employee and invoke the "getNodeType()"
  14465. method. The method should return 5.
  14466. * @author NIST
  14467. * @author Mary Brady
  14468. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  14469. */
  14470. nodeentityreferencenodetype: function(test) {
  14471. var success;
  14472. var doc;
  14473. var elementList;
  14474. var entRefAddr;
  14475. var entRefNode;
  14476. var nodeType;
  14477. doc = staff.staff();
  14478. elementList = doc.getElementsByTagName("address");
  14479. entRefAddr = elementList.item(1);
  14480. entRefNode = entRefAddr.firstChild;
  14481. nodeType = entRefNode.nodeType;
  14482. if(
  14483. (3 == nodeType)
  14484. ) {
  14485. entRefNode = doc.createEntityReference("ent2");
  14486. test.notEqual(entRefNode, null, 'createdEntRefNotNull');
  14487. nodeType = entRefNode.nodeType;
  14488. }
  14489. test.equal(nodeType, 5, 'entityNodeType');
  14490. test.done();
  14491. },
  14492. /**
  14493. *
  14494. The string returned by the "getNodeValue()" method for an
  14495. EntityReference Node is null.
  14496. Retrieve the first Entity Reference node from the last
  14497. child of the second employee and check the string
  14498. returned by the "getNodeValue()" method. It should be
  14499. equal to null.
  14500. * @author NIST
  14501. * @author Mary Brady
  14502. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  14503. */
  14504. nodeentityreferencenodevalue: function(test) {
  14505. var success;
  14506. var doc;
  14507. var elementList;
  14508. var entRefAddr;
  14509. var entRefNode;
  14510. var entRefValue;
  14511. var nodeType;
  14512. doc = staff.staff();
  14513. elementList = doc.getElementsByTagName("address");
  14514. entRefAddr = elementList.item(1);
  14515. entRefNode = entRefAddr.firstChild;
  14516. nodeType = entRefNode.nodeType;
  14517. if(
  14518. (3 == nodeType)
  14519. ) {
  14520. entRefNode = doc.createEntityReference("ent2");
  14521. test.notEqual(entRefNode, null, 'createdEntRefNotNull');
  14522. }
  14523. entRefValue = entRefNode.nodeValue;
  14524. test.equal(entRefValue, null, 'entRefNodeValue');
  14525. test.done();
  14526. },
  14527. /**
  14528. *
  14529. The string returned by the "getNodeValue()" method for an
  14530. Entity Node is always null and "setNodeValue" should have no effect.
  14531. * @author Curt Arnold
  14532. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  14533. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-527DCFF2
  14534. */
  14535. nodeentitysetnodevalue: function(test) {
  14536. var success;
  14537. var doc;
  14538. var docType;
  14539. var entities;
  14540. var entityNode;
  14541. var entityValue;
  14542. doc = staff.staff();
  14543. docType = doc.doctype;
  14544. test.notEqual(docType, null, 'docTypeNotNull');
  14545. entities = docType.entities;
  14546. test.notEqual(entities, null, 'entitiesNotNull');
  14547. entityNode = entities.getNamedItem("ent1");
  14548. test.notEqual(entityNode, null, 'ent1NotNull');
  14549. entityNode.nodeValue = "This should have no effect";
  14550. entityValue = entityNode.nodeValue;
  14551. test.equal(entityValue, null, 'nodeValueNull');
  14552. test.done();
  14553. },
  14554. /**
  14555. *
  14556. The "getFirstChild()" method returns the first child
  14557. of this node.
  14558. * @author NIST
  14559. * @author Mary Brady
  14560. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-169727388
  14561. */
  14562. nodegetfirstchild: function(test) {
  14563. var success;
  14564. var doc;
  14565. var elementList;
  14566. var employeeNode;
  14567. var fchildNode;
  14568. var childName;
  14569. doc = staff.staff();
  14570. elementList = doc.getElementsByTagName("employee");
  14571. employeeNode = elementList.item(1);
  14572. fchildNode = employeeNode.firstChild;
  14573. childName = fchildNode.nodeName;
  14574. if(
  14575. ("#text" == childName)
  14576. ) {
  14577. fchildNode = fchildNode.nextSibling;
  14578. childName = fchildNode.nodeName;
  14579. }
  14580. test.equal(childName, 'employeeId', 'nodeName');
  14581. test.done();
  14582. },
  14583. /**
  14584. *
  14585. If there is not a first child then the "getFirstChild()"
  14586. method returns null.
  14587. Retrieve the Text node form the second child of the first
  14588. employee and invoke the "getFirstChild()" method. It
  14589. should return null.
  14590. * @author NIST
  14591. * @author Mary Brady
  14592. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-169727388
  14593. */
  14594. nodegetfirstchildnull: function(test) {
  14595. var success;
  14596. var doc;
  14597. var elementList;
  14598. var employeeNode;
  14599. var employeeList;
  14600. var secondChildNode;
  14601. var textNode;
  14602. var noChildNode;
  14603. doc = staff.staff();
  14604. elementList = doc.getElementsByTagName("employee");
  14605. employeeNode = elementList.item(0);
  14606. employeeList = employeeNode.childNodes;
  14607. secondChildNode = employeeList.item(1);
  14608. textNode = secondChildNode.firstChild;
  14609. noChildNode = textNode.firstChild;
  14610. test.equal(noChildNode, null, 'nodeGetFirstChildNull');
  14611. test.done();
  14612. },
  14613. /**
  14614. *
  14615. The "getLastChild()" method returns the last child
  14616. of this node.
  14617. * @author NIST
  14618. * @author Mary Brady
  14619. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-61AD09FB
  14620. */
  14621. nodegetlastchild: function(test) {
  14622. var success;
  14623. var doc;
  14624. var elementList;
  14625. var employeeNode;
  14626. var lchildNode;
  14627. var childName;
  14628. doc = staff.staff();
  14629. elementList = doc.getElementsByTagName("employee");
  14630. employeeNode = elementList.item(1);
  14631. lchildNode = employeeNode.lastChild;
  14632. childName = lchildNode.nodeName;
  14633. if(
  14634. ("#text" == childName)
  14635. ) {
  14636. lchildNode = lchildNode.previousSibling;
  14637. childName = lchildNode.nodeName;
  14638. }
  14639. test.equal(childName, 'address', 'nodeName');
  14640. test.done();
  14641. },
  14642. /**
  14643. *
  14644. If there is not a last child then the "getLastChild()"
  14645. method returns null.
  14646. Retrieve the Text node from the second child of the first
  14647. employee and invoke the "getLastChild()" method. It
  14648. should return null.
  14649. * @author NIST
  14650. * @author Mary Brady
  14651. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-61AD09FB
  14652. */
  14653. nodegetlastchildnull: function(test) {
  14654. var success;
  14655. var doc;
  14656. var elementList;
  14657. var employeeNode;
  14658. var employeeList;
  14659. var secondChildNode;
  14660. var textNode;
  14661. var noChildNode;
  14662. doc = staff.staff();
  14663. elementList = doc.getElementsByTagName("employee");
  14664. employeeNode = elementList.item(0);
  14665. employeeList = employeeNode.childNodes;
  14666. secondChildNode = employeeList.item(1);
  14667. textNode = secondChildNode.firstChild;
  14668. noChildNode = textNode.lastChild;
  14669. test.equal(noChildNode, null, 'nodeGetLastChildNull');
  14670. test.done();
  14671. },
  14672. /**
  14673. *
  14674. The "getNextSibling()" method returns the node immediately
  14675. following this node.
  14676. * @author NIST
  14677. * @author Mary Brady
  14678. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F
  14679. */
  14680. nodegetnextsibling: function(test) {
  14681. var success;
  14682. var doc;
  14683. var elementList;
  14684. var employeeIdNode;
  14685. var nsNode;
  14686. var nsName;
  14687. doc = staff.staff();
  14688. elementList = doc.getElementsByTagName("employeeId");
  14689. employeeIdNode = elementList.item(1);
  14690. nsNode = employeeIdNode.nextSibling;
  14691. nsName = nsNode.nodeName;
  14692. if(
  14693. ("#text" == nsName)
  14694. ) {
  14695. nsNode = nsNode.nextSibling;
  14696. nsName = nsNode.nodeName;
  14697. }
  14698. test.equal(nsName, 'name', 'nodeName');
  14699. test.done();
  14700. },
  14701. /**
  14702. *
  14703. If there is not a node immediately following this node the
  14704. "getNextSibling()" method returns null.
  14705. Retrieve the first child of the second employee and
  14706. invoke the "getNextSibling()" method. It should
  14707. be set to null.
  14708. * @author NIST
  14709. * @author Mary Brady
  14710. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-6AC54C2F
  14711. */
  14712. nodegetnextsiblingnull: function(test) {
  14713. var success;
  14714. var doc;
  14715. var elementList;
  14716. var employeeNode;
  14717. var lcNode;
  14718. var nsNode;
  14719. doc = staff.staff();
  14720. elementList = doc.getElementsByTagName("employee");
  14721. employeeNode = elementList.item(1);
  14722. lcNode = employeeNode.lastChild;
  14723. nsNode = lcNode.nextSibling;
  14724. test.equal(nsNode, null, 'nodeGetNextSiblingNull');
  14725. test.done();
  14726. },
  14727. /**
  14728. *
  14729. The "getOwnerDocument()" method returns the Document
  14730. object associated with this node.
  14731. Retrieve the second employee and examine Document
  14732. returned by the "getOwnerDocument()" method. Invoke
  14733. the "getDocumentElement()" on the Document which will
  14734. return an Element that is equal to "staff".
  14735. * @author NIST
  14736. * @author Mary Brady
  14737. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#node-ownerDoc
  14738. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
  14739. */
  14740. nodegetownerdocument: function(test) {
  14741. var success;
  14742. var doc;
  14743. var elementList;
  14744. var docNode;
  14745. var ownerDocument;
  14746. var docElement;
  14747. var elementName;
  14748. doc = staff.staff();
  14749. elementList = doc.getElementsByTagName("employee");
  14750. docNode = elementList.item(1);
  14751. ownerDocument = docNode.ownerDocument;
  14752. docElement = ownerDocument.documentElement;
  14753. elementName = docElement.nodeName;
  14754. test.equal(elementName, 'svg', 'svgTagName');
  14755. test.done();
  14756. },
  14757. /**
  14758. *
  14759. The "getOwnerDocument()" method returns null if the target
  14760. node itself is a document.
  14761. * @author NIST
  14762. * @author Mary Brady
  14763. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#node-ownerDoc
  14764. */
  14765. nodegetownerdocumentnull: function(test) {
  14766. var success;
  14767. var doc;
  14768. var ownerDocument;
  14769. doc = staff.staff();
  14770. ownerDocument = doc.ownerDocument;
  14771. test.equal(ownerDocument, null, 'documentOwnerDocumentNull');
  14772. test.done();
  14773. },
  14774. /**
  14775. *
  14776. The "getPreviousSibling()" method returns the node
  14777. immediately preceding this node.
  14778. * @author NIST
  14779. * @author Mary Brady
  14780. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8
  14781. */
  14782. nodegetprevioussibling: function(test) {
  14783. var success;
  14784. var doc;
  14785. var elementList;
  14786. var nameNode;
  14787. var psNode;
  14788. var psName;
  14789. doc = staff.staff();
  14790. elementList = doc.getElementsByTagName("name");
  14791. nameNode = elementList.item(1);
  14792. psNode = nameNode.previousSibling;
  14793. psName = psNode.nodeName;
  14794. if(
  14795. ("#text" == psName)
  14796. ) {
  14797. psNode = psNode.previousSibling;
  14798. psName = psNode.nodeName;
  14799. }
  14800. test.equal(psName, 'employeeId', 'nodeName');
  14801. test.done();
  14802. },
  14803. /**
  14804. *
  14805. If there is not a node immediately preceding this node the
  14806. "getPreviousSibling()" method returns null.
  14807. Retrieve the first child of the second employee and
  14808. invoke the "getPreviousSibling()" method. It should
  14809. be set to null.
  14810. * @author NIST
  14811. * @author Mary Brady
  14812. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-640FB3C8
  14813. */
  14814. nodegetprevioussiblingnull: function(test) {
  14815. var success;
  14816. var doc;
  14817. var elementList;
  14818. var employeeNode;
  14819. var fcNode;
  14820. var psNode;
  14821. doc = staff.staff();
  14822. elementList = doc.getElementsByTagName("employee");
  14823. employeeNode = elementList.item(2);
  14824. fcNode = employeeNode.firstChild;
  14825. psNode = fcNode.previousSibling;
  14826. test.equal(psNode, null, 'nodeGetPreviousSiblingNull');
  14827. test.done();
  14828. },
  14829. /**
  14830. *
  14831. The "hasChildNodes()" method returns true if the node
  14832. has children.
  14833. Retrieve the root node("staff") and invoke the
  14834. "hasChildNodes()" method. It should return the boolean
  14835. value "true".
  14836. * @author NIST
  14837. * @author Mary Brady
  14838. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-810594187
  14839. */
  14840. nodehaschildnodes: function(test) {
  14841. var success;
  14842. var doc;
  14843. var elementList;
  14844. var employeeNode;
  14845. var state;
  14846. doc = staff.staff();
  14847. elementList = doc.getElementsByTagName("employee");
  14848. employeeNode = elementList.item(1);
  14849. state = employeeNode.hasChildNodes();
  14850. test.ok(state, 'nodeHasChild');
  14851. test.done();
  14852. },
  14853. /**
  14854. *
  14855. The "hasChildNodes()" method returns false if the node
  14856. does not have any children.
  14857. Retrieve the Text node inside the first child of the
  14858. second employee and invoke the "hasChildNodes()" method.
  14859. It should return the boolean value "false".
  14860. * @author NIST
  14861. * @author Mary Brady
  14862. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  14863. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-810594187
  14864. */
  14865. nodehaschildnodesfalse: function(test) {
  14866. var success;
  14867. var doc;
  14868. var elementList;
  14869. var child;
  14870. var employeeIdList;
  14871. var employeeNode;
  14872. var textNode;
  14873. var state;
  14874. doc = staff.staff();
  14875. elementList = doc.getElementsByTagName("employee");
  14876. child = elementList.item(1);
  14877. employeeIdList = child.childNodes;
  14878. employeeNode = employeeIdList.item(1);
  14879. textNode = employeeNode.firstChild;
  14880. state = textNode.hasChildNodes();
  14881. test.equal(state, false, 'nodeHasChildFalse');
  14882. test.done();
  14883. },
  14884. /**
  14885. *
  14886. The "insertBefore(newChild,refChild)" method inserts the
  14887. node "newChild" before the node "refChild".
  14888. Insert a newly created Element node before the eigth
  14889. child of the second employee and check the "newChild"
  14890. and "refChild" after insertion for correct placement.
  14891. * @author NIST
  14892. * @author Mary Brady
  14893. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  14894. */
  14895. nodeinsertbefore: function(test) {
  14896. var success;
  14897. var doc;
  14898. var elementList;
  14899. var employeeNode;
  14900. var childList;
  14901. var refChild;
  14902. var newChild;
  14903. var child;
  14904. var childName;
  14905. var length;
  14906. var insertedNode;
  14907. var actual = new Array();
  14908. expectedWithWhitespace = new Array();
  14909. expectedWithWhitespace[0] = "#text";
  14910. expectedWithWhitespace[1] = "employeeId";
  14911. expectedWithWhitespace[2] = "#text";
  14912. expectedWithWhitespace[3] = "name";
  14913. expectedWithWhitespace[4] = "#text";
  14914. expectedWithWhitespace[5] = "position";
  14915. expectedWithWhitespace[6] = "#text";
  14916. expectedWithWhitespace[7] = "newChild";
  14917. expectedWithWhitespace[8] = "salary";
  14918. expectedWithWhitespace[9] = "#text";
  14919. expectedWithWhitespace[10] = "gender";
  14920. expectedWithWhitespace[11] = "#text";
  14921. expectedWithWhitespace[12] = "address";
  14922. expectedWithWhitespace[13] = "#text";
  14923. expectedWithoutWhitespace = new Array();
  14924. expectedWithoutWhitespace[0] = "employeeId";
  14925. expectedWithoutWhitespace[1] = "name";
  14926. expectedWithoutWhitespace[2] = "position";
  14927. expectedWithoutWhitespace[3] = "newChild";
  14928. expectedWithoutWhitespace[4] = "salary";
  14929. expectedWithoutWhitespace[5] = "gender";
  14930. expectedWithoutWhitespace[6] = "address";
  14931. var expected = new Array();
  14932. doc = staff.staff();
  14933. elementList = doc.getElementsByTagName("employee");
  14934. employeeNode = elementList.item(1);
  14935. childList = employeeNode.childNodes;
  14936. length = childList.length;
  14937. if(
  14938. (6 == length)
  14939. ) {
  14940. refChild = childList.item(3);
  14941. expected = expectedWithoutWhitespace;
  14942. }
  14943. else {
  14944. refChild = childList.item(7);
  14945. expected = expectedWithWhitespace;
  14946. }
  14947. newChild = doc.createElement("newChild");
  14948. insertedNode = employeeNode.insertBefore(newChild,refChild);
  14949. for(var indexN100DC = 0;indexN100DC < childList.length; indexN100DC++) {
  14950. child = childList.item(indexN100DC);
  14951. childName = child.nodeName;
  14952. actual[actual.length] = childName;
  14953. }
  14954. test.deepEqual(actual, expected, 'nodeNames');
  14955. test.done();
  14956. },
  14957. /**
  14958. *
  14959. If the "newChild" is a DocumentFragment object then all
  14960. its children are inserted in the same order before the
  14961. the "refChild".
  14962. Create a DocumentFragment object and populate it with
  14963. two Element nodes. Retrieve the second employee and
  14964. insert the newly created DocumentFragment before its
  14965. fourth child. The second employee should now have two
  14966. extra children("newChild1" and "newChild2") at
  14967. positions fourth and fifth respectively.
  14968. * @author NIST
  14969. * @author Mary Brady
  14970. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  14971. */
  14972. nodeinsertbeforedocfragment: function(test) {
  14973. var success;
  14974. var doc;
  14975. var elementList;
  14976. var employeeNode;
  14977. var childList;
  14978. var refChild;
  14979. var newdocFragment;
  14980. var newChild1;
  14981. var newChild2;
  14982. var child;
  14983. var childName;
  14984. var appendedChild;
  14985. var insertedNode;
  14986. doc = staff.staff();
  14987. elementList = doc.getElementsByTagName("employee");
  14988. employeeNode = elementList.item(1);
  14989. childList = employeeNode.childNodes;
  14990. refChild = childList.item(3);
  14991. newdocFragment = doc.createDocumentFragment();
  14992. newChild1 = doc.createElement("newChild1");
  14993. newChild2 = doc.createElement("newChild2");
  14994. appendedChild = newdocFragment.appendChild(newChild1);
  14995. appendedChild = newdocFragment.appendChild(newChild2);
  14996. insertedNode = employeeNode.insertBefore(newdocFragment,refChild);
  14997. child = childList.item(3);
  14998. childName = child.nodeName;
  14999. test.equal(childName, 'newChild1', 'childName3');
  15000. child = childList.item(4);
  15001. childName = child.nodeName;
  15002. test.equal(childName, 'newChild2', 'childName4');
  15003. test.done();
  15004. },
  15005. /**
  15006. *
  15007. The "insertBefore(newChild,refChild)" method raises a
  15008. HIERARCHY_REQUEST_ERR DOMException if this node is of
  15009. a type that does not allow children of the type "newChild"
  15010. to be inserted.
  15011. Retrieve the root node and attempt to insert a newly
  15012. created Attr node. An Element node cannot have children
  15013. of the "Attr" type, therefore the desired exception
  15014. should be raised.
  15015. * @author NIST
  15016. * @author Mary Brady
  15017. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
  15018. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  15019. * @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'])
  15020. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  15021. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  15022. */
  15023. nodeinsertbeforeinvalidnodetype: function(test) {
  15024. var success;
  15025. var doc;
  15026. var rootNode;
  15027. var newChild;
  15028. var elementList;
  15029. var refChild;
  15030. var insertedNode;
  15031. doc = staff.staff();
  15032. rootNode = doc.documentElement;
  15033. newChild = doc.createAttribute("newAttribute");
  15034. elementList = doc.getElementsByTagName("employee");
  15035. refChild = elementList.item(1);
  15036. {
  15037. success = false;
  15038. try {
  15039. insertedNode = rootNode.insertBefore(newChild,refChild);
  15040. }
  15041. catch(ex) {
  15042. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  15043. }
  15044. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  15045. }
  15046. test.done();
  15047. },
  15048. /**
  15049. *
  15050. The "insertBefore(newChild,refChild)" method raises a
  15051. WRONG_DOCUMENT_ERR DOMException if the "newChild" was
  15052. created from a different document than the one that
  15053. created this node.
  15054. Retrieve the second employee and attempt to insert a new
  15055. child that was created from a different document than the
  15056. one that created the second employee. An attempt to
  15057. insert such a child should raise the desired exception.
  15058. * @author NIST
  15059. * @author Mary Brady
  15060. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='WRONG_DOCUMENT_ERR'])
  15061. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  15062. * @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'])
  15063. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  15064. */
  15065. nodeinsertbeforenewchilddiffdocument: function(test) {
  15066. var success;
  15067. var doc1;
  15068. var doc2;
  15069. var refChild;
  15070. var newChild;
  15071. var elementList;
  15072. var elementNode;
  15073. var insertedNode;
  15074. var doc1Ref = null;
  15075. if (typeof(this.doc1) != 'undefined') {
  15076. doc1Ref = this.doc1;
  15077. }
  15078. doc1 = staff.staff();
  15079. var doc2Ref = null;
  15080. if (typeof(this.doc2) != 'undefined') {
  15081. doc2Ref = this.doc2;
  15082. }
  15083. doc2 = staff.staff();
  15084. newChild = doc1.createElement("newChild");
  15085. elementList = doc2.getElementsByTagName("employee");
  15086. elementNode = elementList.item(1);
  15087. refChild = elementNode.firstChild;
  15088. {
  15089. success = false;
  15090. try {
  15091. insertedNode = elementNode.insertBefore(newChild,refChild);
  15092. }
  15093. catch(ex) {
  15094. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  15095. }
  15096. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  15097. }
  15098. test.done();
  15099. },
  15100. /**
  15101. *
  15102. If the "newChild" is already in the tree, the
  15103. "insertBefore(newChild,refChild)" method must first
  15104. remove it before the insertion takes place.
  15105. Insert a node Element ("employeeId") that is already
  15106. present in the tree. The existing node should be
  15107. removed first and the new one inserted. The node is
  15108. inserted at a different position in the tree to assure
  15109. that it was indeed inserted.
  15110. * @author NIST
  15111. * @author Mary Brady
  15112. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  15113. */
  15114. nodeinsertbeforenewchildexists: function(test) {
  15115. var success;
  15116. var doc;
  15117. var elementList;
  15118. var employeeNode;
  15119. var childList;
  15120. var refChild;
  15121. var newChild;
  15122. var child;
  15123. var length;
  15124. var childName;
  15125. var insertedNode;
  15126. expectedWhitespace = new Array();
  15127. expectedWhitespace[0] = "#text";
  15128. expectedWhitespace[1] = "#text";
  15129. expectedWhitespace[2] = "name";
  15130. expectedWhitespace[3] = "#text";
  15131. expectedWhitespace[4] = "position";
  15132. expectedWhitespace[5] = "#text";
  15133. expectedWhitespace[6] = "salary";
  15134. expectedWhitespace[7] = "#text";
  15135. expectedWhitespace[8] = "gender";
  15136. expectedWhitespace[9] = "#text";
  15137. expectedWhitespace[10] = "employeeId";
  15138. expectedWhitespace[11] = "address";
  15139. expectedWhitespace[12] = "#text";
  15140. expectedNoWhitespace = new Array();
  15141. expectedNoWhitespace[0] = "name";
  15142. expectedNoWhitespace[1] = "position";
  15143. expectedNoWhitespace[2] = "salary";
  15144. expectedNoWhitespace[3] = "gender";
  15145. expectedNoWhitespace[4] = "employeeId";
  15146. expectedNoWhitespace[5] = "address";
  15147. var expected = new Array();
  15148. var result = new Array();
  15149. doc = staff.staff();
  15150. elementList = doc.getElementsByTagName("employee");
  15151. employeeNode = elementList.item(1);
  15152. childList = employeeNode.childNodes;
  15153. length = childList.length;
  15154. if(
  15155. (6 == length)
  15156. ) {
  15157. expected = expectedNoWhitespace;
  15158. refChild = childList.item(5);
  15159. newChild = childList.item(0);
  15160. }
  15161. else {
  15162. expected = expectedWhitespace;
  15163. refChild = childList.item(11);
  15164. newChild = childList.item(1);
  15165. }
  15166. insertedNode = employeeNode.insertBefore(newChild,refChild);
  15167. for(var indexN100DD = 0;indexN100DD < childList.length; indexN100DD++) {
  15168. child = childList.item(indexN100DD);
  15169. childName = child.nodeName;
  15170. result[result.length] = childName;
  15171. }
  15172. test.deepEqual(result, expected, 'childNames');
  15173. test.done();
  15174. },
  15175. /**
  15176. *
  15177. The "insertBefore(newChild,refChild)" method raises a
  15178. HIERARCHY_REQUEST_ERR DOMException if the node to be
  15179. inserted is one of this nodes ancestors.
  15180. Retrieve the second employee and attempt to insert a
  15181. node that is one of its ancestors(root node). An
  15182. attempt to insert such a node should raise the
  15183. desired exception.
  15184. * @author NIST
  15185. * @author Mary Brady
  15186. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
  15187. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  15188. * @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'])
  15189. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  15190. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  15191. */
  15192. nodeinsertbeforenodeancestor: function(test) {
  15193. var success;
  15194. var doc;
  15195. var newChild;
  15196. var elementList;
  15197. var employeeNode;
  15198. var childList;
  15199. var refChild;
  15200. var insertedNode;
  15201. doc = staff.staff();
  15202. newChild = doc.documentElement;
  15203. elementList = doc.getElementsByTagName("employee");
  15204. employeeNode = elementList.item(1);
  15205. childList = employeeNode.childNodes;
  15206. refChild = childList.item(0);
  15207. {
  15208. success = false;
  15209. try {
  15210. insertedNode = employeeNode.insertBefore(newChild,refChild);
  15211. }
  15212. catch(ex) {
  15213. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  15214. }
  15215. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  15216. }
  15217. test.done();
  15218. },
  15219. /**
  15220. *
  15221. The "insertBefore(newChild,refchild)" method returns
  15222. the node being inserted.
  15223. Insert an Element node before the fourth
  15224. child of the second employee and check the node
  15225. returned from the "insertBefore(newChild,refChild)"
  15226. method. The node returned should be "newChild".
  15227. * @author NIST
  15228. * @author Mary Brady
  15229. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  15230. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  15231. */
  15232. nodeinsertbeforenodename: function(test) {
  15233. var success;
  15234. var doc;
  15235. var elementList;
  15236. var employeeNode;
  15237. var childList;
  15238. var refChild;
  15239. var newChild;
  15240. var insertedNode;
  15241. var childName;
  15242. doc = staff.staff();
  15243. elementList = doc.getElementsByTagName("employee");
  15244. employeeNode = elementList.item(1);
  15245. childList = employeeNode.childNodes;
  15246. refChild = childList.item(3);
  15247. newChild = doc.createElement("newChild");
  15248. insertedNode = employeeNode.insertBefore(newChild,refChild);
  15249. childName = insertedNode.nodeName;
  15250. test.equal(childName, 'newChild', 'nodeInsertBeforeNodeName');
  15251. test.done();
  15252. },
  15253. /**
  15254. *
  15255. The "insertBefore(newChild,refChild)" method causes the
  15256. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  15257. if the node is readonly.
  15258. Obtain the children of the THIRD "gender" element. The elements
  15259. content is an entity reference. Get the FIRST item
  15260. from the entity reference and execute the "insertBefore(newChild,refChild)" method.
  15261. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  15262. * @author NIST
  15263. * @author Mary Brady
  15264. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  15265. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  15266. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  15267. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  15268. */
  15269. nodeinsertbeforenomodificationallowederr: function(test) {
  15270. var success;
  15271. var doc;
  15272. var genderList;
  15273. var genderNode;
  15274. var entRef;
  15275. var entElement;
  15276. var createdNode;
  15277. var insertedNode;
  15278. var refChild = null;
  15279. var nodeType;
  15280. doc = staff.staff();
  15281. genderList = doc.getElementsByTagName("gender");
  15282. genderNode = genderList.item(2);
  15283. entRef = genderNode.firstChild;
  15284. test.notEqual(entRef, null, 'entRefNotNull');
  15285. nodeType = entRef.nodeType;
  15286. if(
  15287. (1 == nodeType)
  15288. ) {
  15289. entRef = doc.createEntityReference("ent4");
  15290. test.notEqual(entRef, null, 'createdEntRefNotNull');
  15291. }
  15292. entElement = entRef.firstChild;
  15293. test.notEqual(entElement, null, 'entElementNotNull');
  15294. createdNode = doc.createElement("text3");
  15295. {
  15296. success = false;
  15297. try {
  15298. insertedNode = entElement.insertBefore(createdNode,refChild);
  15299. }
  15300. catch(ex) {
  15301. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  15302. }
  15303. test.ok(success, 'throw_NOT_MODIFICATION_ALLOWED_ERR');
  15304. }
  15305. test.done();
  15306. },
  15307. /**
  15308. *
  15309. The "insertBefore(newChild,refChild)" method causes the
  15310. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  15311. if the node is readonly.
  15312. Create an ent4 entity reference and and execute the "insertBefore(newChild,refChild)" method.
  15313. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  15314. * @author Curt Arnold
  15315. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  15316. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  15317. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  15318. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  15319. * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeinsertbeforenomodificationallowederr.xml
  15320. */
  15321. nodeinsertbeforenomodificationallowederrEE: function(test) {
  15322. var success;
  15323. var doc;
  15324. var entRef;
  15325. var createdNode;
  15326. var insertedNode;
  15327. var refChild = null;
  15328. doc = staff.staff();
  15329. entRef = doc.createEntityReference("ent4");
  15330. test.notEqual(entRef, null, 'createdEntRefNotNull');
  15331. createdNode = doc.createElement("text3");
  15332. {
  15333. success = false;
  15334. try {
  15335. insertedNode = entRef.insertBefore(createdNode,refChild);
  15336. }
  15337. catch(ex) {
  15338. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  15339. }
  15340. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  15341. }
  15342. test.done();
  15343. },
  15344. /**
  15345. *
  15346. The "insertBefore(newChild,refChild)" method raises a
  15347. NOT_FOUND_ERR DOMException if the reference child is
  15348. not a child of this node.
  15349. Retrieve the second employee and attempt to insert a
  15350. new node before a reference node that is not a child
  15351. of this node. An attempt to insert before a non child
  15352. node should raise the desired exception.
  15353. * @author NIST
  15354. * @author Mary Brady
  15355. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
  15356. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  15357. * @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'])
  15358. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  15359. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  15360. */
  15361. nodeinsertbeforerefchildnonexistent: function(test) {
  15362. var success;
  15363. var doc;
  15364. var refChild;
  15365. var newChild;
  15366. var elementList;
  15367. var elementNode;
  15368. var insertedNode;
  15369. doc = staff.staff();
  15370. newChild = doc.createElement("newChild");
  15371. refChild = doc.createElement("refChild");
  15372. elementList = doc.getElementsByTagName("employee");
  15373. elementNode = elementList.item(1);
  15374. {
  15375. success = false;
  15376. try {
  15377. insertedNode = elementNode.insertBefore(newChild,refChild);
  15378. }
  15379. catch(ex) {
  15380. success = (typeof(ex.code) != 'undefined' && ex.code == 8);
  15381. }
  15382. test.ok(success, 'throw_NOT_FOUND_ERR');
  15383. }
  15384. test.done();
  15385. },
  15386. /**
  15387. *
  15388. If the "refChild" is null then the
  15389. "insertBefore(newChild,refChild)" method inserts the
  15390. node "newChild" at the end of the list of children.
  15391. Retrieve the second employee and invoke the
  15392. "insertBefore(newChild,refChild)" method with
  15393. refChild=null. Since "refChild" is null the "newChild"
  15394. should be added to the end of the list. The last item
  15395. in the list is checked after insertion. The last Element
  15396. node of the list should be "newChild".
  15397. * @author NIST
  15398. * @author Mary Brady
  15399. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-952280727
  15400. */
  15401. nodeinsertbeforerefchildnull: function(test) {
  15402. var success;
  15403. var doc;
  15404. var elementList;
  15405. var employeeNode;
  15406. var childList;
  15407. var refChild = null;
  15408. var newChild;
  15409. var child;
  15410. var childName;
  15411. var insertedNode;
  15412. doc = staff.staff();
  15413. elementList = doc.getElementsByTagName("employee");
  15414. employeeNode = elementList.item(1);
  15415. childList = employeeNode.childNodes;
  15416. newChild = doc.createElement("newChild");
  15417. insertedNode = employeeNode.insertBefore(newChild,refChild);
  15418. child = employeeNode.lastChild;
  15419. childName = child.nodeName;
  15420. test.equal(childName, 'newChild', 'nodeInsertBeforeRefChildNull');
  15421. test.done();
  15422. },
  15423. /**
  15424. *
  15425. Create a list of all the children elements of the third
  15426. employee and access its first child by using an index
  15427. of 0.
  15428. * @author NIST
  15429. * @author Mary Brady
  15430. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
  15431. */
  15432. nodelistindexequalzero: function(test) {
  15433. var success;
  15434. var doc;
  15435. var elementList;
  15436. var employeeNode;
  15437. var employeeList;
  15438. var child;
  15439. var childName;
  15440. doc = staff.staff();
  15441. elementList = doc.getElementsByTagName("employee");
  15442. employeeNode = elementList.item(2);
  15443. employeeList = employeeNode.childNodes;
  15444. child = employeeList.item(0);
  15445. childName = child.nodeName;
  15446. if(
  15447. !("#text" == childName)
  15448. ) {
  15449. test.equal(childName, 'employeeId', 'childName');
  15450. }
  15451. test.done();
  15452. },
  15453. /**
  15454. *
  15455. The "getLength()" method returns the number of nodes
  15456. in the list should be 6 (no whitespace) or 13.
  15457. * @author NIST
  15458. * @author Mary Brady
  15459. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337
  15460. */
  15461. nodelistindexgetlength: function(test) {
  15462. var doc = staff.staff();
  15463. var employeeList = doc.getElementsByTagName("employee").item(2).childNodes;
  15464. test.equal(employeeList.length, 6)
  15465. test.done();
  15466. },
  15467. /**
  15468. *
  15469. The "getLength()" method returns the number of nodes
  15470. in the list.(Test for EMPTY list)
  15471. Create a list of all the children of the Text node
  15472. inside the first child of the third employee and
  15473. invoke the "getLength()" method. It should contain
  15474. the value 0.
  15475. * @author NIST
  15476. * @author Mary Brady
  15477. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337
  15478. */
  15479. nodelistindexgetlengthofemptylist: function(test) {
  15480. var success;
  15481. var doc;
  15482. var elementList;
  15483. var employeeNode;
  15484. var employeeList;
  15485. var childNode;
  15486. var textNode;
  15487. var textList;
  15488. doc = staff.staff();
  15489. elementList = doc.getElementsByTagName("employee");
  15490. employeeNode = elementList.item(2);
  15491. employeeList = employeeNode.childNodes;
  15492. childNode = employeeList.item(1);
  15493. textNode = childNode.firstChild;
  15494. textList = textNode.childNodes;
  15495. test.equal(textList.length, 0, 'nodelistIndexGetLengthOfEmptyListAssert');
  15496. test.done();
  15497. },
  15498. /**
  15499. *
  15500. Create a list of all the children elements of the third
  15501. employee and access its fourth child by using an index
  15502. of 3. This should result in "name" being
  15503. selected. Further we evaluate its content(by using
  15504. the "getNodeName()" method) to ensure the proper
  15505. element was accessed.
  15506. * @author NIST
  15507. * @author Mary Brady
  15508. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
  15509. */
  15510. nodelistindexnotzero: function(test) {
  15511. var success;
  15512. var doc;
  15513. var elementList;
  15514. var employeeNode;
  15515. var employeeList;
  15516. var child;
  15517. var length;
  15518. var childName;
  15519. doc = staff.staff();
  15520. elementList = doc.getElementsByTagName("employee");
  15521. employeeNode = elementList.item(2);
  15522. employeeList = employeeNode.childNodes;
  15523. length = employeeList.length;
  15524. if(
  15525. (6 == length)
  15526. ) {
  15527. child = employeeList.item(1);
  15528. }
  15529. else {
  15530. child = employeeList.item(3);
  15531. }
  15532. childName = child.nodeName;
  15533. test.equal(childName, 'name', 'nodeName');
  15534. test.done();
  15535. },
  15536. /**
  15537. *
  15538. Get the first child of the third employee using NodeList.item(0)
  15539. which will either be a Text node (whitespace) or employeeId element.
  15540. * @author NIST
  15541. * @author Mary Brady
  15542. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
  15543. */
  15544. nodelistreturnfirstitem: function(test) {
  15545. var success;
  15546. var doc;
  15547. var elementList;
  15548. var employeeNode;
  15549. var employeeList;
  15550. var child;
  15551. var childName;
  15552. var length;
  15553. doc = staff.staff();
  15554. elementList = doc.getElementsByTagName("employee");
  15555. employeeNode = elementList.item(2);
  15556. employeeList = employeeNode.childNodes;
  15557. child = employeeList.item(0);
  15558. childName = child.nodeName;
  15559. length = employeeList.length;
  15560. test.equal(childName, "employeeId", 'firstChildNoWhitespace');
  15561. test.done();
  15562. },
  15563. /**
  15564. *
  15565. Get this last child of the third employee using NodeList.item(NodeList.length - 1)
  15566. and check that it is either a Text element (with whitespace) or an address element.
  15567. * @author NIST
  15568. * @author Mary Brady
  15569. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
  15570. */
  15571. nodelistreturnlastitem: function(test) {
  15572. var success;
  15573. var doc;
  15574. var elementList;
  15575. var employeeNode;
  15576. var employeeList;
  15577. var child;
  15578. var childName;
  15579. var length;
  15580. doc = staff.staff();
  15581. elementList = doc.getElementsByTagName("employee");
  15582. employeeNode = elementList.item(2);
  15583. employeeList = employeeNode.childNodes;
  15584. length = employeeList.length;
  15585. if(
  15586. (6 == length)
  15587. ) {
  15588. child = employeeList.item(5);
  15589. childName = child.nodeName;
  15590. test.equal(childName, 'address', 'nodeName1');
  15591. }
  15592. else {
  15593. child = employeeList.item(12);
  15594. childName = child.nodeName;
  15595. test.equal(childName, '#text', 'nodeName2');
  15596. }
  15597. test.done();
  15598. },
  15599. /**
  15600. *
  15601. The range of valid child node indices is 0 thru length -1
  15602. Create a list of all the children elements of the third
  15603. employee and traverse the list from index=0 thru
  15604. length -1.
  15605. * @author NIST
  15606. * @author Mary Brady
  15607. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-203510337
  15608. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-844377136
  15609. */
  15610. nodelisttraverselist: function(test) {
  15611. var success;
  15612. var doc;
  15613. var elementList;
  15614. var employeeNode;
  15615. var employeeList;
  15616. var child;
  15617. var childName;
  15618. var result = new Array();
  15619. var length;
  15620. expectedWhitespace = new Array();
  15621. expectedWhitespace[0] = "#text";
  15622. expectedWhitespace[1] = "employeeId";
  15623. expectedWhitespace[2] = "#text";
  15624. expectedWhitespace[3] = "name";
  15625. expectedWhitespace[4] = "#text";
  15626. expectedWhitespace[5] = "position";
  15627. expectedWhitespace[6] = "#text";
  15628. expectedWhitespace[7] = "salary";
  15629. expectedWhitespace[8] = "#text";
  15630. expectedWhitespace[9] = "gender";
  15631. expectedWhitespace[10] = "#text";
  15632. expectedWhitespace[11] = "address";
  15633. expectedWhitespace[12] = "#text";
  15634. expectedNoWhitespace = new Array();
  15635. expectedNoWhitespace[0] = "employeeId";
  15636. expectedNoWhitespace[1] = "name";
  15637. expectedNoWhitespace[2] = "position";
  15638. expectedNoWhitespace[3] = "salary";
  15639. expectedNoWhitespace[4] = "gender";
  15640. expectedNoWhitespace[5] = "address";
  15641. doc = staff.staff();
  15642. elementList = doc.getElementsByTagName("employee");
  15643. employeeNode = elementList.item(2);
  15644. employeeList = employeeNode.childNodes;
  15645. length = employeeList.length;
  15646. for(var indexN100A4 = 0;indexN100A4 < employeeList.length; indexN100A4++) {
  15647. child = employeeList.item(indexN100A4);
  15648. childName = child.nodeName;
  15649. result[result.length] = childName;
  15650. }
  15651. if(
  15652. (6 == length)
  15653. ) {
  15654. test.deepEqual(result, expectedNoWhitespace, 'nowhitespace');
  15655. }
  15656. else {
  15657. test.deepEqual(result, expectedWhitespace, 'whitespace');
  15658. }
  15659. test.done();
  15660. },
  15661. /**
  15662. *
  15663. The "getAttributes()" method invoked on a Notation
  15664. Node returns null.
  15665. Retrieve the Notation declaration inside the DocumentType
  15666. node and invoke the "getAttributes()" method on the
  15667. Notation Node. It should return null.
  15668. * @author NIST
  15669. * @author Mary Brady
  15670. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  15671. */
  15672. nodenotationnodeattributes: function(test) {
  15673. var success;
  15674. var doc;
  15675. var docType;
  15676. var notations;
  15677. var notationNode;
  15678. var attrList;
  15679. doc = staff.staff();
  15680. docType = doc.doctype;
  15681. test.notEqual(docType, null, 'docTypeNotNull');
  15682. notations = docType.notations;
  15683. test.notEqual(notations, null, 'notationsNotNull');
  15684. notationNode = notations.getNamedItem("notation1");
  15685. test.notEqual(notationNode, null, 'notationNotNull');
  15686. attrList = notationNode.attributes;
  15687. test.equal(attrList, null, 'nodeNotationNodeAttributes');
  15688. test.done();
  15689. },
  15690. /**
  15691. *
  15692. The string returned by the "getNodeName()" method for a
  15693. Notation Node is the name of the notation.
  15694. Retrieve the Notation declaration inside the
  15695. DocumentType node and check the string returned
  15696. by the "getNodeName()" method. It should be equal to
  15697. "notation1".
  15698. * @author NIST
  15699. * @author Mary Brady
  15700. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  15701. */
  15702. nodenotationnodename: function(test) {
  15703. var success;
  15704. var doc;
  15705. var docType;
  15706. var notations;
  15707. var notationNode;
  15708. var notationName;
  15709. doc = staff.staff();
  15710. docType = doc.doctype;
  15711. test.notEqual(docType, null, 'docTypeNotNull');
  15712. notations = docType.notations;
  15713. test.notEqual(notations, null, 'notationsNotNull');
  15714. notationNode = notations.getNamedItem("notation1");
  15715. test.notEqual(notationNode, null, 'notationNotNull');
  15716. notationName = notationNode.nodeName;
  15717. test.equal(notationName, 'notation1', 'nodeName');
  15718. test.done();
  15719. },
  15720. /**
  15721. *
  15722. The "getNodeType()" method for an Notation Node
  15723. returns the constant value 12.
  15724. Retrieve the Notation declaration in the DocumentType
  15725. node and invoke the "getNodeType()" method. The method
  15726. should return 12.
  15727. * @author NIST
  15728. * @author Mary Brady
  15729. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  15730. */
  15731. nodenotationnodetype: function(test) {
  15732. var success;
  15733. var doc;
  15734. var docType;
  15735. var notations;
  15736. var notationNode;
  15737. var nodeType;
  15738. doc = staff.staff();
  15739. docType = doc.doctype;
  15740. test.notEqual(docType, null, 'docTypeNotNull');
  15741. notations = docType.notations;
  15742. test.notEqual(notations, null, 'notationsNotNull');
  15743. notationNode = notations.getNamedItem("notation1");
  15744. test.notEqual(notationNode, null, 'notationNotNull');
  15745. nodeType = notationNode.nodeType;
  15746. test.equal(nodeType, 12, 'nodeNotationNodeType');
  15747. test.done();
  15748. },
  15749. /**
  15750. *
  15751. The string returned by the "getNodeValue()" method for a
  15752. Notation Node is null.
  15753. Retrieve the Notation declaration inside the
  15754. DocumentType node and check the string returned
  15755. by the "getNodeValue()" method. It should be equal to
  15756. null.
  15757. * @author NIST
  15758. * @author Mary Brady
  15759. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  15760. */
  15761. nodenotationnodevalue: function(test) {
  15762. var success;
  15763. var doc;
  15764. var docType;
  15765. var notations;
  15766. var notationNode;
  15767. var notationValue;
  15768. doc = staff.staff();
  15769. docType = doc.doctype;
  15770. test.notEqual(docType, null, 'docTypeNotNull');
  15771. notations = docType.notations;
  15772. test.notEqual(notations, null, 'notationsNotNull');
  15773. notationNode = notations.getNamedItem("notation1");
  15774. test.notEqual(notationNode, null, 'notationNotNull');
  15775. notationValue = notationNode.nodeValue;
  15776. test.equal(notationValue, null, 'nodeValue');
  15777. test.done();
  15778. },
  15779. /**
  15780. *
  15781. The "getParentNode()" method returns the parent
  15782. of this node.
  15783. Retrieve the second employee and invoke the
  15784. "getParentNode()" method on this node. It should
  15785. be set to "staff".
  15786. * @author NIST
  15787. * @author Mary Brady
  15788. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317
  15789. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=251
  15790. */
  15791. nodeparentnode: function(test) {
  15792. var success;
  15793. var doc;
  15794. var elementList;
  15795. var employeeNode;
  15796. var parentNode;
  15797. var parentName;
  15798. doc = staff.staff();
  15799. elementList = doc.getElementsByTagName("employee");
  15800. employeeNode = elementList.item(1);
  15801. parentNode = employeeNode.parentNode;
  15802. parentName = parentNode.nodeName;
  15803. test.equal(parentName, 'svg', 'svgTagName');
  15804. test.done();
  15805. },
  15806. /**
  15807. *
  15808. The "getParentNode()" method invoked on a node that has
  15809. just been created and not yet added to the tree is null.
  15810. Create a new "employee" Element node using the
  15811. "createElement(name)" method from the Document interface.
  15812. Since this new node has not yet been added to the tree,
  15813. the "getParentNode()" method will return null.
  15814. * @author NIST
  15815. * @author Mary Brady
  15816. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1060184317
  15817. */
  15818. nodeparentnodenull: function(test) {
  15819. var success;
  15820. var doc;
  15821. var createdNode;
  15822. var parentNode;
  15823. doc = staff.staff();
  15824. createdNode = doc.createElement("employee");
  15825. parentNode = createdNode.parentNode;
  15826. test.equal(parentNode, null, 'parentNode');
  15827. test.done();
  15828. },
  15829. /**
  15830. *
  15831. The "getAttributes()" method invoked on a Processing
  15832. Instruction Node returns null.
  15833. Retrieve the Processing Instruction node and invoke
  15834. the "getAttributes()" method. It should return null.
  15835. * @author NIST
  15836. * @author Mary Brady
  15837. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  15838. */
  15839. nodeprocessinginstructionnodeattributes: function(test) {
  15840. var success;
  15841. var doc;
  15842. var testList;
  15843. var piNode;
  15844. var attrList;
  15845. doc = staff.staff();
  15846. testList = doc.childNodes;
  15847. piNode = testList.item(0);
  15848. attrList = piNode.attributes;
  15849. test.equal(attrList, null, 'nodeProcessingInstructionNodeAttr');
  15850. test.done();
  15851. },
  15852. /**
  15853. *
  15854. The string returned by the "getNodeName()" method for a
  15855. Processing Instruction Node is the target.
  15856. Retrieve the Processing Instruction Node in the XML file
  15857. and check the string returned by the "getNodeName()"
  15858. method. It should be equal to "XML-STYLE".
  15859. * @author NIST
  15860. * @author Mary Brady
  15861. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  15862. */
  15863. nodeprocessinginstructionnodename: function(test) {
  15864. var success;
  15865. var doc;
  15866. var testList;
  15867. var piNode;
  15868. var piName;
  15869. doc = staff.staff();
  15870. testList = doc.childNodes;
  15871. piNode = testList.item(0);
  15872. piName = piNode.nodeName;
  15873. test.equal(piName, 'TEST-STYLE', 'nodeProcessingInstructionNodeName');
  15874. test.done();
  15875. },
  15876. /**
  15877. *
  15878. The "getNodeType()" method for a Processing Instruction
  15879. node returns the constant value 7.
  15880. Retrieve a NodeList of child elements from the document.
  15881. Retrieve the first child and invoke the "getNodeType()"
  15882. method. The method should return 7.
  15883. * @author NIST
  15884. * @author Mary Brady
  15885. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  15886. */
  15887. nodeprocessinginstructionnodetype: function(test) {
  15888. var success;
  15889. var doc;
  15890. var testList;
  15891. var piNode;
  15892. var nodeType;
  15893. doc = staff.staff();
  15894. testList = doc.childNodes;
  15895. piNode = testList.item(0);
  15896. nodeType = piNode.nodeType;
  15897. test.equal(nodeType, 7, 'nodeProcessingInstructionNodeType');
  15898. test.done();
  15899. },
  15900. /**
  15901. *
  15902. The string returned by the "getNodeValue()" method for a
  15903. Processing Instruction Node is the content of the
  15904. Processing Instruction(exclude the target).
  15905. Retrieve the Processing Instruction node in the XML file
  15906. and check the string returned by the "getNodeValue()"
  15907. method. It should be equal to "PIDATA".
  15908. * @author NIST
  15909. * @author Mary Brady
  15910. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  15911. */
  15912. nodeprocessinginstructionnodevalue: function(test) {
  15913. var success;
  15914. var doc;
  15915. var testList;
  15916. var piNode;
  15917. var piValue;
  15918. doc = staff.staff();
  15919. testList = doc.childNodes;
  15920. piNode = testList.item(0);
  15921. piValue = piNode.nodeValue;
  15922. test.equal(piValue, 'PIDATA', 'value');
  15923. test.done();
  15924. },
  15925. /**
  15926. *
  15927. Setting the nodeValue should change the value returned by
  15928. nodeValue and ProcessingInstruction.getData.
  15929. * @author Curt Arnold
  15930. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  15931. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1004215813
  15932. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-837822393
  15933. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=181
  15934. */
  15935. nodeprocessinginstructionsetnodevalue: function(test) {
  15936. var success;
  15937. var doc;
  15938. var testList;
  15939. var piNode;
  15940. var piValue;
  15941. doc = staff.staff();
  15942. testList = doc.childNodes;
  15943. piNode = testList.item(0);
  15944. piNode.nodeValue = "Something different";
  15945. piValue = piNode.nodeValue;
  15946. test.equal(piValue, 'Something different', 'nodeValue');
  15947. piValue = piNode.data;
  15948. test.equal(piValue, 'Something different', 'data');
  15949. test.done();
  15950. },
  15951. /**
  15952. *
  15953. The "removeChild(oldChild)" method removes the child node
  15954. indicated by "oldChild" from the list of children and
  15955. returns it.
  15956. Remove the first employee by invoking the
  15957. "removeChild(oldChild)" method an checking the
  15958. node returned by the "getParentNode()" method. It
  15959. should be set to null.
  15960. * @author NIST
  15961. * @author Mary Brady
  15962. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  15963. */
  15964. noderemovechild: function(test) {
  15965. var success;
  15966. var doc;
  15967. var rootNode;
  15968. var childList;
  15969. var childToRemove;
  15970. var removedChild;
  15971. var parentNode;
  15972. doc = staff.staff();
  15973. rootNode = doc.documentElement;
  15974. childList = rootNode.childNodes;
  15975. childToRemove = childList.item(1);
  15976. removedChild = rootNode.removeChild(childToRemove);
  15977. parentNode = removedChild.parentNode;
  15978. test.equal(parentNode, null, 'nodeRemoveChild');
  15979. test.done();
  15980. },
  15981. /**
  15982. *
  15983. Remove the first child of the second employee
  15984. and check the NodeName returned by the
  15985. "removeChild(oldChild)" method. The returned node
  15986. should have a NodeName equal to "#text" or employeeId depending on whitespace.
  15987. * @author NIST
  15988. * @author Mary Brady
  15989. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  15990. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  15991. */
  15992. noderemovechildgetnodename: function(test) {
  15993. var success;
  15994. var doc;
  15995. var elementList;
  15996. var employeeNode;
  15997. var childList;
  15998. var oldChild;
  15999. var removedChild;
  16000. var childName;
  16001. var length;
  16002. doc = staff.staff();
  16003. elementList = doc.getElementsByTagName("employee");
  16004. employeeNode = elementList.item(1);
  16005. childList = employeeNode.childNodes;
  16006. length = childList.length;
  16007. oldChild = childList.item(0);
  16008. removedChild = employeeNode.removeChild(oldChild);
  16009. childName = removedChild.nodeName;
  16010. if(
  16011. (6 == length)
  16012. ) {
  16013. test.equal(childName, 'employeeId', 'nowhitespace');
  16014. }
  16015. else {
  16016. test.equal(childName, '#text', 'whitespace');
  16017. }
  16018. test.done();
  16019. },
  16020. /**
  16021. *
  16022. Retrieve the second employee and remove its first child.
  16023. After the removal, the second employee should have five or twelve
  16024. children and the first child should now be the child
  16025. that used to be at the second position in the list.
  16026. * @author NIST
  16027. * @author Mary Brady
  16028. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  16029. */
  16030. noderemovechildnode: function(test) {
  16031. var success;
  16032. var doc;
  16033. var elementList;
  16034. var employeeNode;
  16035. var childList;
  16036. var oldChild;
  16037. var child;
  16038. var childName;
  16039. var length;
  16040. var removedChild;
  16041. var removedName;
  16042. doc = staff.staff();
  16043. elementList = doc.getElementsByTagName("employee");
  16044. employeeNode = elementList.item(1);
  16045. childList = employeeNode.childNodes;
  16046. oldChild = childList.item(0);
  16047. removedChild = employeeNode.removeChild(oldChild);
  16048. removedName = removedChild.nodeName;
  16049. child = childList.item(0);
  16050. childName = child.nodeName;
  16051. length = childList.length;
  16052. if(
  16053. (5 == length)
  16054. ) {
  16055. test.equal(removedName, 'employeeId', 'removedNameNoWhitespace');
  16056. test.equal(childName, 'name', 'childNameNoWhitespace');
  16057. }
  16058. else {
  16059. test.equal(removedName, '#text', 'removedName');
  16060. test.equal(childName, 'employeeId', 'childName');
  16061. test.equal(length, 12, 'length');
  16062. }
  16063. test.done();
  16064. },
  16065. /**
  16066. *
  16067. The "removeChild(oldChild)" method causes the
  16068. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  16069. if the node is readonly.
  16070. Obtain the children of the THIRD "gender" element. The elements
  16071. content is an entity reference. Get the FIRST item
  16072. from the entity reference and execute the "removeChild(oldChild)" method.
  16073. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  16074. * @author NIST
  16075. * @author Mary Brady
  16076. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  16077. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  16078. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  16079. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  16080. */
  16081. noderemovechildnomodificationallowederr: function(test) {
  16082. var success;
  16083. var doc;
  16084. var genderList;
  16085. var genderNode;
  16086. var entRef;
  16087. var entElement;
  16088. var removedNode;
  16089. var nodeType;
  16090. doc = staff.staff();
  16091. genderList = doc.getElementsByTagName("gender");
  16092. genderNode = genderList.item(2);
  16093. entRef = genderNode.firstChild;
  16094. test.notEqual(entRef, null, 'entRefNotNull');
  16095. nodeType = entRef.nodeType;
  16096. if(
  16097. (1 == nodeType)
  16098. ) {
  16099. entRef = doc.createEntityReference("ent4");
  16100. test.notEqual(entRef, null, 'createdEntRefNotNull');
  16101. }
  16102. entElement = entRef.firstChild;
  16103. test.notEqual(entElement, null, 'entElementNotNull');
  16104. {
  16105. success = false;
  16106. try {
  16107. removedNode = entRef.removeChild(entElement);
  16108. }
  16109. catch(ex) {
  16110. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  16111. }
  16112. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  16113. }
  16114. test.done();
  16115. },
  16116. /**
  16117. *
  16118. The "removeChild(oldChild)" method causes the
  16119. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  16120. if the node is readonly.
  16121. Create an entity reference and execute the "removeChild(oldChild)" method.
  16122. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  16123. * @author Curt Arnold
  16124. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  16125. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  16126. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  16127. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  16128. * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/noderemovechildnomodificationallowederr.xml
  16129. */
  16130. noderemovechildnomodificationallowederrEE: function(test) {
  16131. var success;
  16132. var doc;
  16133. var entRef;
  16134. var entText;
  16135. var removedNode;
  16136. doc = staff.staff();
  16137. entRef = doc.createEntityReference("ent4");
  16138. test.notEqual(entRef, null, 'createdEntRefNotNull');
  16139. entText = entRef.firstChild;
  16140. test.notEqual(entText, null, 'entTextNotNull');
  16141. {
  16142. success = false;
  16143. try {
  16144. removedNode = entRef.removeChild(entText);
  16145. }
  16146. catch(ex) {
  16147. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  16148. }
  16149. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  16150. }
  16151. test.done();
  16152. },
  16153. /**
  16154. *
  16155. The "removeChild(oldChild)" method raises a
  16156. NOT_FOUND_ERR DOMException if the old child is
  16157. not a child of this node.
  16158. Retrieve the second employee and attempt to remove a
  16159. node that is not one of its children. An attempt to
  16160. remove such a node should raise the desired exception.
  16161. * @author NIST
  16162. * @author Mary Brady
  16163. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
  16164. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  16165. * @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'])
  16166. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1734834066
  16167. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  16168. */
  16169. noderemovechildoldchildnonexistent: function(test) {
  16170. var success;
  16171. var doc;
  16172. var oldChild;
  16173. var elementList;
  16174. var elementNode;
  16175. var removedChild;
  16176. doc = staff.staff();
  16177. oldChild = doc.createElement("oldChild");
  16178. elementList = doc.getElementsByTagName("employee");
  16179. elementNode = elementList.item(1);
  16180. {
  16181. success = false;
  16182. try {
  16183. removedChild = elementNode.removeChild(oldChild);
  16184. }
  16185. catch(ex) {
  16186. success = (typeof(ex.code) != 'undefined' && ex.code == 8);
  16187. }
  16188. test.ok(success, 'throw_NOT_FOUND_ERR');
  16189. }
  16190. test.done();
  16191. },
  16192. /**
  16193. *
  16194. The "replaceChild(newChild,oldChild)" method replaces
  16195. the node "oldChild" with the node "newChild".
  16196. Replace the first element of the second employee with
  16197. a newly created Element node. Check the first position
  16198. after the replacement operation is completed. The new
  16199. Element should be "newChild".
  16200. * @author NIST
  16201. * @author Mary Brady
  16202. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  16203. */
  16204. nodereplacechild: function(test) {
  16205. var success;
  16206. var doc;
  16207. var elementList;
  16208. var employeeNode;
  16209. var childList;
  16210. var oldChild;
  16211. var newChild;
  16212. var child;
  16213. var childName;
  16214. var replacedNode;
  16215. doc = staff.staff();
  16216. elementList = doc.getElementsByTagName("employee");
  16217. employeeNode = elementList.item(1);
  16218. childList = employeeNode.childNodes;
  16219. oldChild = childList.item(0);
  16220. newChild = doc.createElement("newChild");
  16221. replacedNode = employeeNode.replaceChild(newChild,oldChild);
  16222. child = childList.item(0);
  16223. childName = child.nodeName;
  16224. test.equal(childName, 'newChild', 'nodeReplaceChild');
  16225. test.done();
  16226. },
  16227. /**
  16228. *
  16229. The "replaceChild(newChild,oldChild)" method raises a
  16230. HIERARCHY_REQUEST_ERR DOMException if this node is of
  16231. a type that does not allow children of the type "newChild"
  16232. to be inserted.
  16233. Retrieve the root node and attempt to replace
  16234. one of its children with a newly created Attr node.
  16235. An Element node cannot have children of the "Attr"
  16236. type, therefore the desired exception should be raised.
  16237. * @author NIST
  16238. * @author Mary Brady
  16239. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
  16240. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  16241. * @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'])
  16242. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  16243. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  16244. */
  16245. nodereplacechildinvalidnodetype: function(test) {
  16246. var success;
  16247. var doc;
  16248. var rootNode;
  16249. var newChild;
  16250. var elementList;
  16251. var oldChild;
  16252. var replacedChild;
  16253. doc = staff.staff();
  16254. rootNode = doc.documentElement;
  16255. newChild = doc.createAttribute("newAttribute");
  16256. elementList = doc.getElementsByTagName("employee");
  16257. oldChild = elementList.item(1);
  16258. {
  16259. success = false;
  16260. try {
  16261. replacedChild = rootNode.replaceChild(newChild,oldChild);
  16262. }
  16263. catch(ex) {
  16264. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  16265. }
  16266. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  16267. }
  16268. test.done();
  16269. },
  16270. /**
  16271. *
  16272. The "replaceChild(newChild,oldChild)" method raises a
  16273. WRONG_DOCUMENT_ERR DOMException if the "newChild" was
  16274. created from a different document than the one that
  16275. created this node.
  16276. Retrieve the second employee and attempt to replace one
  16277. of its children with a node created from a different
  16278. document. An attempt to make such a replacement
  16279. should raise the desired exception.
  16280. * @author NIST
  16281. * @author Mary Brady
  16282. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
  16283. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  16284. * @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'])
  16285. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  16286. */
  16287. nodereplacechildnewchilddiffdocument: function(test) {
  16288. var success;
  16289. var doc1;
  16290. var doc2;
  16291. var oldChild;
  16292. var newChild;
  16293. var elementList;
  16294. var elementNode;
  16295. var replacedChild;
  16296. var doc1Ref = null;
  16297. if (typeof(this.doc1) != 'undefined') {
  16298. doc1Ref = this.doc1;
  16299. }
  16300. doc1 = staff.staff();
  16301. var doc2Ref = null;
  16302. if (typeof(this.doc2) != 'undefined') {
  16303. doc2Ref = this.doc2;
  16304. }
  16305. doc2 = staff.staff();
  16306. newChild = doc1.createElement("newChild");
  16307. elementList = doc2.getElementsByTagName("employee");
  16308. elementNode = elementList.item(1);
  16309. oldChild = elementNode.firstChild;
  16310. {
  16311. success = false;
  16312. try {
  16313. replacedChild = elementNode.replaceChild(newChild,oldChild);
  16314. }
  16315. catch(ex) {
  16316. success = (typeof(ex.code) != 'undefined' && ex.code == 4);
  16317. }
  16318. test.ok(success, 'throw_WRONG_DOCUMENT_ERR');
  16319. }
  16320. test.done();
  16321. },
  16322. /**
  16323. *
  16324. Retrieve the second employee and replace its TWELFTH
  16325. child(address) with its SECOND child(employeeId). After the
  16326. replacement the second child should now be the one that used
  16327. to be at the third position and the TWELFTH child should be the
  16328. one that used to be at the SECOND position.
  16329. * @author NIST
  16330. * @author Mary Brady
  16331. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  16332. */
  16333. nodereplacechildnewchildexists: function(test) {
  16334. var success;
  16335. var doc;
  16336. var elementList;
  16337. var employeeNode;
  16338. var childList;
  16339. var oldChild = null;
  16340. var newChild = null;
  16341. var childName;
  16342. var childNode;
  16343. var length;
  16344. var actual = new Array();
  16345. var expected = new Array();
  16346. expectedWithoutWhitespace = new Array();
  16347. expectedWithoutWhitespace[0] = "name";
  16348. expectedWithoutWhitespace[1] = "position";
  16349. expectedWithoutWhitespace[2] = "salary";
  16350. expectedWithoutWhitespace[3] = "gender";
  16351. expectedWithoutWhitespace[4] = "employeeId";
  16352. expectedWithWhitespace = new Array();
  16353. expectedWithWhitespace[0] = "#text";
  16354. expectedWithWhitespace[1] = "#text";
  16355. expectedWithWhitespace[2] = "name";
  16356. expectedWithWhitespace[3] = "#text";
  16357. expectedWithWhitespace[4] = "position";
  16358. expectedWithWhitespace[5] = "#text";
  16359. expectedWithWhitespace[6] = "salary";
  16360. expectedWithWhitespace[7] = "#text";
  16361. expectedWithWhitespace[8] = "gender";
  16362. expectedWithWhitespace[9] = "#text";
  16363. expectedWithWhitespace[10] = "employeeId";
  16364. expectedWithWhitespace[11] = "#text";
  16365. var replacedChild;
  16366. doc = staff.staff();
  16367. elementList = doc.getElementsByTagName("employee");
  16368. employeeNode = elementList.item(1);
  16369. childList = employeeNode.childNodes;
  16370. length = childList.length;
  16371. if(
  16372. (13 == length)
  16373. ) {
  16374. newChild = childList.item(1);
  16375. oldChild = childList.item(11);
  16376. expected = expectedWithWhitespace;
  16377. }
  16378. else {
  16379. newChild = childList.item(0);
  16380. oldChild = childList.item(5);
  16381. expected = expectedWithoutWhitespace;
  16382. }
  16383. replacedChild = employeeNode.replaceChild(newChild,oldChild);
  16384. test.equal(replacedChild, oldChild, 'return_value_same');
  16385. for(var indexN100DE = 0;indexN100DE < childList.length; indexN100DE++) {
  16386. childNode = childList.item(indexN100DE);
  16387. childName = childNode.nodeName;
  16388. actual[actual.length] = childName;
  16389. }
  16390. test.deepEqual(actual, expected, 'childNames');
  16391. test.done();
  16392. },
  16393. /**
  16394. *
  16395. The "replaceChild(newChild,oldChild)" method raises a
  16396. HIERARCHY_REQUEST_ERR DOMException if the node to put
  16397. in is one of this node's ancestors.
  16398. Retrieve the second employee and attempt to replace
  16399. one of its children with an ancestor node(root node).
  16400. An attempt to make such a replacement should raise the
  16401. desired exception.
  16402. * @author NIST
  16403. * @author Mary Brady
  16404. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='HIERARCHY_REQUEST_ERR'])
  16405. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  16406. * @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'])
  16407. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  16408. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  16409. */
  16410. nodereplacechildnodeancestor: function(test) {
  16411. var success;
  16412. var doc;
  16413. var newChild;
  16414. var elementList;
  16415. var employeeNode;
  16416. var childList;
  16417. var oldChild;
  16418. var replacedNode;
  16419. doc = staff.staff();
  16420. newChild = doc.documentElement;
  16421. elementList = doc.getElementsByTagName("employee");
  16422. employeeNode = elementList.item(1);
  16423. childList = employeeNode.childNodes;
  16424. oldChild = childList.item(0);
  16425. {
  16426. success = false;
  16427. try {
  16428. replacedNode = employeeNode.replaceChild(newChild,oldChild);
  16429. }
  16430. catch(ex) {
  16431. success = (typeof(ex.code) != 'undefined' && ex.code == 3);
  16432. }
  16433. test.ok(success, 'throw_HIERARCHY_REQUEST_ERR');
  16434. }
  16435. test.done();
  16436. },
  16437. /**
  16438. *
  16439. Replace the second Element of the second employee with
  16440. a newly created node Element and check the NodeName
  16441. returned by the "replaceChild(newChild,oldChild)"
  16442. method. The returned node should have a NodeName equal
  16443. to "employeeId".
  16444. * @author NIST
  16445. * @author Mary Brady
  16446. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  16447. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  16448. */
  16449. nodereplacechildnodename: function(test) {
  16450. var success;
  16451. var doc;
  16452. var elementList;
  16453. var employeeNode;
  16454. var childList;
  16455. var oldChild;
  16456. var newChild;
  16457. var replacedNode;
  16458. var length;
  16459. var childName;
  16460. doc = staff.staff();
  16461. elementList = doc.getElementsByTagName("employee");
  16462. employeeNode = elementList.item(1);
  16463. childList = employeeNode.childNodes;
  16464. length = childList.length;
  16465. oldChild = childList.item(1);
  16466. newChild = doc.createElement("newChild");
  16467. replacedNode = employeeNode.replaceChild(newChild,oldChild);
  16468. childName = replacedNode.nodeName;
  16469. if(
  16470. (6 == length)
  16471. ) {
  16472. test.equal(childName, 'name', 'nowhitespace');
  16473. }
  16474. else {
  16475. test.equal(childName, 'employeeId', 'whitespace');
  16476. }
  16477. test.done();
  16478. },
  16479. /**
  16480. *
  16481. The "replaceChild(newChild,oldChild)" method causes the
  16482. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  16483. if the node is readonly.
  16484. Obtain the children of the THIRD "gender" element. The elements
  16485. content is an entity reference. Get the FIRST item
  16486. from the entity reference and execute the "replaceChild(newChild,oldChild)" method.
  16487. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  16488. * @author NIST
  16489. * @author Mary Brady
  16490. * @author Curt Arnold
  16491. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  16492. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  16493. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  16494. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  16495. */
  16496. nodereplacechildnomodificationallowederr: function(test) {
  16497. var success;
  16498. var doc;
  16499. var genderList;
  16500. var genderNode;
  16501. var entRef;
  16502. var entElement;
  16503. var createdNode;
  16504. var replacedChild;
  16505. var nodeType;
  16506. doc = staff.staff();
  16507. genderList = doc.getElementsByTagName("gender");
  16508. genderNode = genderList.item(2);
  16509. entRef = genderNode.firstChild;
  16510. nodeType = entRef.nodeType;
  16511. if(
  16512. (1 == nodeType)
  16513. ) {
  16514. entRef = doc.createEntityReference("ent4");
  16515. test.notEqual(entRef, null, 'createdEntRefNotNull');
  16516. }
  16517. entElement = entRef.firstChild;
  16518. createdNode = doc.createElement("newChild");
  16519. {
  16520. success = false;
  16521. try {
  16522. replacedChild = entRef.replaceChild(createdNode,entElement);
  16523. }
  16524. catch(ex) {
  16525. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  16526. }
  16527. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  16528. }
  16529. test.done();
  16530. },
  16531. /**
  16532. *
  16533. The "replaceChild(newChild,oldChild)" method causes the
  16534. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  16535. if the node is readonly.
  16536. Create an entity reference execute the "replaceChild(newChild,oldChild)" method.
  16537. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  16538. * @author Curt Arnold
  16539. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  16540. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  16541. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  16542. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  16543. * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodereplacechildnomodificationallowederr.xml
  16544. */
  16545. nodereplacechildnomodificationallowederrEE: function(test) {
  16546. var success;
  16547. var doc;
  16548. var entRef;
  16549. var entText;
  16550. var createdNode;
  16551. var replacedChild;
  16552. doc = staff.staff();
  16553. entRef = doc.createEntityReference("ent4");
  16554. test.notEqual(entRef, null, 'createdEntRefNotNull');
  16555. entText = entRef.firstChild;
  16556. createdNode = doc.createElement("newChild");
  16557. {
  16558. success = false;
  16559. try {
  16560. replacedChild = entRef.replaceChild(createdNode,entText);
  16561. }
  16562. catch(ex) {
  16563. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  16564. }
  16565. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  16566. }
  16567. test.done();
  16568. },
  16569. /**
  16570. *
  16571. The "replaceChild(newChild,oldChild)" method raises a
  16572. NOT_FOUND_ERR DOMException if the old child is
  16573. not a child of this node.
  16574. Retrieve the second employee and attempt to replace a
  16575. node that is not one of its children. An attempt to
  16576. replace such a node should raise the desired exception.
  16577. * @author NIST
  16578. * @author Mary Brady
  16579. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NOT_FOUND_ERR'])
  16580. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  16581. * @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'])
  16582. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-785887307
  16583. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  16584. */
  16585. nodereplacechildoldchildnonexistent: function(test) {
  16586. var success;
  16587. var doc;
  16588. var oldChild;
  16589. var newChild;
  16590. var elementList;
  16591. var elementNode;
  16592. var replacedNode;
  16593. doc = staff.staff();
  16594. newChild = doc.createElement("newChild");
  16595. oldChild = doc.createElement("oldChild");
  16596. elementList = doc.getElementsByTagName("employee");
  16597. elementNode = elementList.item(1);
  16598. {
  16599. success = false;
  16600. try {
  16601. replacedNode = elementNode.replaceChild(newChild,oldChild);
  16602. }
  16603. catch(ex) {
  16604. success = (typeof(ex.code) != 'undefined' && ex.code == 8);
  16605. }
  16606. test.ok(success, 'throw_NOT_FOUND_ERR');
  16607. }
  16608. test.done();
  16609. },
  16610. /**
  16611. *
  16612. The "setNodeValue(nodeValue)" method causes the
  16613. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  16614. if the node is readonly.
  16615. Obtain the children of the THIRD "gender" element. The elements
  16616. content is an entity reference. Get the SECOND item
  16617. from the entity reference and execute the "setNodeValue(nodeValue)" method.
  16618. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  16619. * @author NIST
  16620. * @author Mary Brady
  16621. * @author Curt Arnold
  16622. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  16623. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  16624. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-F68D080')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  16625. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  16626. */
  16627. nodesetnodevaluenomodificationallowederr: function(test) {
  16628. var success;
  16629. var doc;
  16630. var genderList;
  16631. var genderNode;
  16632. var entRef;
  16633. var entElement;
  16634. var entElementText;
  16635. var nodeType;
  16636. doc = staff.staff();
  16637. genderList = doc.getElementsByTagName("gender");
  16638. genderNode = genderList.item(2);
  16639. entRef = genderNode.firstChild;
  16640. test.notEqual(entRef, null, 'entRefNotNull');
  16641. nodeType = entRef.nodeType;
  16642. if(
  16643. (1 == nodeType)
  16644. ) {
  16645. entRef = doc.createEntityReference("ent4");
  16646. test.notEqual(entRef, null, 'createdEntRefNotNull');
  16647. }
  16648. entElement = entRef.firstChild;
  16649. test.notEqual(entElement, null, 'entElementNotNull');
  16650. entElementText = entElement.firstChild;
  16651. test.notEqual(entElementText, null, 'entElementTextNotNull');
  16652. {
  16653. success = false;
  16654. try {
  16655. entElementText.nodeValue = "newValue";
  16656. }
  16657. catch(ex) {
  16658. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  16659. }
  16660. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  16661. }
  16662. test.done();
  16663. },
  16664. /**
  16665. *
  16666. Create an entity reference and execute the "setNodeValue(nodeValue)" method.
  16667. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  16668. * @author Curt Arnold
  16669. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  16670. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  16671. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-F68D080')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  16672. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  16673. * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodesetnodevaluenomodificationallowederr.xml
  16674. */
  16675. nodesetnodevaluenomodificationallowederrEE: function(test) {
  16676. var success;
  16677. var doc;
  16678. var entRef;
  16679. var entText;
  16680. doc = staff.staff();
  16681. entRef = doc.createEntityReference("ent3");
  16682. test.notEqual(entRef, null, 'createdEntRefNotNull');
  16683. entText = entRef.firstChild;
  16684. test.notEqual(entText, null, 'entTextNotNull');
  16685. {
  16686. success = false;
  16687. try {
  16688. entText.nodeValue = "newValue";
  16689. }
  16690. catch(ex) {
  16691. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  16692. }
  16693. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  16694. }
  16695. test.done();
  16696. },
  16697. /**
  16698. *
  16699. The "getAttributes()" method invoked on a Text
  16700. Node returns null.
  16701. Retrieve the Text node from the last child of the
  16702. first employee and invoke the "getAttributes()" method
  16703. on the Text Node. It should return null.
  16704. * @author NIST
  16705. * @author Mary Brady
  16706. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-84CF096
  16707. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1312295772
  16708. */
  16709. nodetextnodeattribute: function(test) {
  16710. var success;
  16711. var doc;
  16712. var elementList;
  16713. var testAddr;
  16714. var textNode;
  16715. var attrList;
  16716. doc = staff.staff();
  16717. elementList = doc.getElementsByTagName("address");
  16718. testAddr = elementList.item(0);
  16719. textNode = testAddr.firstChild;
  16720. attrList = textNode.attributes;
  16721. test.equal(attrList, null, 'nodeTextNodeAttributes');
  16722. test.done();
  16723. },
  16724. /**
  16725. *
  16726. The string returned by the "getNodeName()" method for a
  16727. Text Node is "#text".
  16728. Retrieve the Text Node from the last child of the
  16729. first employee and check the string returned
  16730. by the "getNodeName()" method. It should be equal to
  16731. "#text".
  16732. * @author NIST
  16733. * @author Mary Brady
  16734. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  16735. */
  16736. nodetextnodename: function(test) {
  16737. var success;
  16738. var doc;
  16739. var elementList;
  16740. var testAddr;
  16741. var textNode;
  16742. var textName;
  16743. doc = staff.staff();
  16744. elementList = doc.getElementsByTagName("address");
  16745. testAddr = elementList.item(0);
  16746. textNode = testAddr.firstChild;
  16747. textName = textNode.nodeName;
  16748. test.equal(textName, '#text', 'nodeTextNodeName');
  16749. test.done();
  16750. },
  16751. /**
  16752. *
  16753. The "getNodeType()" method for a Text Node
  16754. returns the constant value 3.
  16755. Retrieve the Text node from the last child of
  16756. the first employee and invoke the "getNodeType()"
  16757. method. The method should return 3.
  16758. * @author NIST
  16759. * @author Mary Brady
  16760. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-111237558
  16761. */
  16762. nodetextnodetype: function(test) {
  16763. var success;
  16764. var doc;
  16765. var elementList;
  16766. var testAddr;
  16767. var textNode;
  16768. var nodeType;
  16769. doc = staff.staff();
  16770. elementList = doc.getElementsByTagName("address");
  16771. testAddr = elementList.item(0);
  16772. textNode = testAddr.firstChild;
  16773. nodeType = textNode.nodeType;
  16774. test.equal(nodeType, 3, 'nodeTextNodeType');
  16775. test.done();
  16776. },
  16777. /**
  16778. *
  16779. The string returned by the "getNodeValue()" method for a
  16780. Text Node is the content of the Text node.
  16781. Retrieve the Text node from the last child of the first
  16782. employee and check the string returned by the
  16783. "getNodeValue()" method. It should be equal to
  16784. "1230 North Ave. Dallas, Texas 98551".
  16785. * @author NIST
  16786. * @author Mary Brady
  16787. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  16788. */
  16789. nodetextnodevalue: function(test) {
  16790. var success;
  16791. var doc;
  16792. var elementList;
  16793. var testAddr;
  16794. var textNode;
  16795. var textValue;
  16796. doc = staff.staff();
  16797. elementList = doc.getElementsByTagName("address");
  16798. testAddr = elementList.item(0);
  16799. textNode = testAddr.firstChild;
  16800. textValue = textNode.nodeValue;
  16801. test.equal(textValue, '1230 North Ave. Dallas, Texas 98551', 'nodeTextNodeValue');
  16802. test.done();
  16803. },
  16804. /**
  16805. *
  16806. An element is created, setNodeValue is called with a non-null argument, but getNodeValue
  16807. should still return null.
  16808. * @author Curt Arnold
  16809. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  16810. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
  16811. */
  16812. nodevalue01: function(test) {
  16813. var success;
  16814. var doc;
  16815. var newNode;
  16816. var newValue;
  16817. doc = staff.staff();
  16818. newNode = doc.createElement("address");
  16819. newValue = newNode.nodeValue;
  16820. test.equal(newValue, null, 'initiallyNull');
  16821. newNode.nodeValue = "This should have no effect";
  16822. newValue = newNode.nodeValue;
  16823. test.equal(newValue, null, 'nullAfterAttemptedChange');
  16824. test.done();
  16825. },
  16826. /**
  16827. *
  16828. An comment is created, setNodeValue is called with a non-null argument, but getNodeValue
  16829. should still return null.
  16830. * @author Curt Arnold
  16831. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  16832. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1728279322
  16833. */
  16834. nodevalue02: function(test) {
  16835. var success;
  16836. var doc;
  16837. var newNode;
  16838. var newValue;
  16839. doc = staff.staff();
  16840. newNode = doc.createComment("This is a new Comment node");
  16841. newValue = newNode.nodeValue;
  16842. test.equal(newValue, 'This is a new Comment node', 'initial');
  16843. newNode.nodeValue = "This should have an effect";
  16844. newValue = newNode.nodeValue;
  16845. test.equal(newValue, 'This should have an effect', 'afterChange');
  16846. test.done();
  16847. },
  16848. /**
  16849. *
  16850. An entity reference is created, setNodeValue is called with a non-null argument, but getNodeValue
  16851. should still return null.
  16852. * @author Curt Arnold
  16853. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  16854. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-11C98490
  16855. */
  16856. nodevalue03: function(test) {
  16857. var success;
  16858. var doc;
  16859. var newNode;
  16860. var newValue;
  16861. doc = staff.staff();
  16862. newNode = doc.createEntityReference("ent1");
  16863. test.notEqual(newNode, null, 'createdEntRefNotNull');
  16864. newValue = newNode.nodeValue;
  16865. test.equal(newValue, null, 'initiallyNull');
  16866. newNode.nodeValue = "This should have no effect";
  16867. newValue = newNode.nodeValue;
  16868. test.equal(newValue, null, 'nullAfterAttemptedChange');
  16869. test.done();
  16870. },
  16871. /**
  16872. *
  16873. An document type accessed, setNodeValue is called with a non-null argument, but getNodeValue
  16874. should still return null.
  16875. * @author Curt Arnold
  16876. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  16877. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A31
  16878. */
  16879. nodevalue04: function(test) {
  16880. var success;
  16881. var doc;
  16882. var newNode;
  16883. var newValue;
  16884. doc = staff.staff();
  16885. newNode = doc.doctype;
  16886. test.notEqual(newNode, null, 'docTypeNotNull');
  16887. newValue = newNode.nodeValue;
  16888. test.equal(newValue, null, 'initiallyNull');
  16889. newNode.nodeValue = "This should have no effect";
  16890. newValue = newNode.nodeValue;
  16891. test.equal(newValue, null, 'nullAfterAttemptedChange');
  16892. test.done();
  16893. },
  16894. /**
  16895. *
  16896. A document fragment is created, setNodeValue is called with a non-null argument, but getNodeValue
  16897. should still return null.
  16898. * @author Curt Arnold
  16899. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  16900. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-B63ED1A3
  16901. */
  16902. nodevalue05: function(test) {
  16903. var success;
  16904. var doc;
  16905. var newNode;
  16906. var newValue;
  16907. doc = staff.staff();
  16908. newNode = doc.createDocumentFragment();
  16909. newValue = newNode.nodeValue;
  16910. test.equal(newValue, null, 'initiallyNull');
  16911. newNode.nodeValue = "This should have no effect";
  16912. newValue = newNode.nodeValue;
  16913. test.equal(newValue, null, 'nullAfterAttemptedChange');
  16914. test.done();
  16915. },
  16916. /**
  16917. *
  16918. An document is accessed, setNodeValue is called with a non-null argument, but getNodeValue
  16919. should still return null.
  16920. * @author Curt Arnold
  16921. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  16922. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#i-Document
  16923. */
  16924. nodevalue06: function(test) {
  16925. var success;
  16926. var newNode;
  16927. var newValue;
  16928. var newNodeRef = null;
  16929. if (typeof(this.newNode) != 'undefined') {
  16930. newNodeRef = this.newNode;
  16931. }
  16932. newNode = staff.staff();
  16933. newValue = newNode.nodeValue;
  16934. test.equal(newValue, null, 'initiallyNull');
  16935. newNode.nodeValue = "This should have no effect";
  16936. newValue = newNode.nodeValue;
  16937. test.equal(newValue, null, 'nullAfterAttemptedChange');
  16938. test.done();
  16939. },
  16940. /**
  16941. *
  16942. An Entity is accessed, setNodeValue is called with a non-null argument, but getNodeValue
  16943. should still return null.
  16944. * @author Curt Arnold
  16945. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  16946. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-527DCFF2
  16947. */
  16948. nodevalue07: function(test) {
  16949. var success;
  16950. var doc;
  16951. var newNode;
  16952. var newValue;
  16953. var nodeMap;
  16954. var docType;
  16955. doc = staff.staff();
  16956. docType = doc.doctype;
  16957. test.notEqual(docType, null, 'docTypeNotNull');
  16958. nodeMap = docType.entities;
  16959. test.notEqual(nodeMap, null, 'entitiesNotNull');
  16960. newNode = nodeMap.getNamedItem("ent1");
  16961. test.notEqual(newNode, null, 'entityNotNull');
  16962. newValue = newNode.nodeValue;
  16963. test.equal(newValue, null, 'initiallyNull');
  16964. newNode.nodeValue = "This should have no effect";
  16965. newValue = newNode.nodeValue;
  16966. test.equal(newValue, null, 'nullAfterAttemptedChange');
  16967. test.done();
  16968. },
  16969. /**
  16970. *
  16971. An notation is accessed, setNodeValue is called with a non-null argument, but getNodeValue
  16972. should still return null.
  16973. * @author Curt Arnold
  16974. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  16975. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5431D1B9
  16976. */
  16977. nodevalue08: function(test) {
  16978. var success;
  16979. var doc;
  16980. var docType;
  16981. var newNode;
  16982. var newValue;
  16983. var nodeMap;
  16984. doc = staff.staff();
  16985. docType = doc.doctype;
  16986. test.notEqual(docType, null, 'docTypeNotNull');
  16987. nodeMap = docType.notations;
  16988. test.notEqual(nodeMap, null, 'notationsNotNull');
  16989. newNode = nodeMap.getNamedItem("notation1");
  16990. test.notEqual(newNode, null, 'notationNotNull');
  16991. newValue = newNode.nodeValue;
  16992. test.equal(newValue, null, 'initiallyNull');
  16993. newNode.nodeValue = "This should have no effect";
  16994. newValue = newNode.nodeValue;
  16995. test.equal(newValue, null, 'nullAfterAttemptedChange');
  16996. test.done();
  16997. },
  16998. /**
  16999. *
  17000. An processing instruction is created, setNodeValue is called with a non-null argument, but getNodeValue
  17001. should still return null.
  17002. * @author Curt Arnold
  17003. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  17004. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1004215813
  17005. */
  17006. nodevalue09: function(test) {
  17007. var success;
  17008. var doc;
  17009. var newNode;
  17010. var newValue;
  17011. doc = staff.staff();
  17012. newNode = doc.createProcessingInstruction("TARGET","DATA");
  17013. newValue = newNode.nodeValue;
  17014. test.equal(newValue, 'DATA', 'initial');
  17015. newNode.nodeValue = "This should have an effect";
  17016. newValue = newNode.nodeValue;
  17017. test.equal(newValue, 'This should have an effect', 'after');
  17018. test.done();
  17019. },
  17020. /**
  17021. *
  17022. Retrieve the notation named "notation1" and access its
  17023. name by invoking the "getNodeName()" method inherited
  17024. from the Node interface.
  17025. * @author NIST
  17026. * @author Mary Brady
  17027. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D095
  17028. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5431D1B9
  17029. */
  17030. notationgetnotationname: function(test) {
  17031. var success;
  17032. var doc;
  17033. var docType;
  17034. var notations;
  17035. var notationNode;
  17036. var notationName;
  17037. doc = staff.staff();
  17038. docType = doc.doctype;
  17039. test.notEqual(docType, null, 'docTypeNotNull');
  17040. notations = docType.notations;
  17041. test.notEqual(notations, null, 'notationsNotNull');
  17042. notationNode = notations.getNamedItem("notation1");
  17043. notationName = notationNode.nodeName;
  17044. test.equal(notationName, 'notation1', 'notationGetNotationNameAssert');
  17045. test.done();
  17046. },
  17047. /**
  17048. *
  17049. Retrieve the notation named "notation1" and access its
  17050. public identifier. The string "notation1File" should be
  17051. returned.
  17052. * @author NIST
  17053. * @author Mary Brady
  17054. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-54F2B4D0
  17055. */
  17056. notationgetpublicid: function(test) {
  17057. var success;
  17058. var doc;
  17059. var docType;
  17060. var notations;
  17061. var notationNode;
  17062. var publicId;
  17063. doc = staff.staff();
  17064. docType = doc.doctype;
  17065. test.notEqual(docType, null, 'docTypeNotNull');
  17066. notations = docType.notations;
  17067. test.notEqual(notations, null, 'notationsNotNull');
  17068. notationNode = notations.getNamedItem("notation1");
  17069. publicId = notationNode.publicId;
  17070. test.equal(publicId, 'notation1File', 'publicId');
  17071. test.done();
  17072. },
  17073. /**
  17074. *
  17075. The "getPublicId()" method of a Notation node contains
  17076. the public identifier associated with the notation, if
  17077. one was not specified a null value should be returned.
  17078. Retrieve the notation named "notation2" and access its
  17079. public identifier. Since a public identifier was not
  17080. specified for this notation, the "getPublicId()" method
  17081. should return null.
  17082. * @author NIST
  17083. * @author Mary Brady
  17084. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-54F2B4D0
  17085. */
  17086. notationgetpublicidnull: function(test) {
  17087. var success;
  17088. var doc;
  17089. var docType;
  17090. var notations;
  17091. var notationNode;
  17092. var publicId;
  17093. doc = staff.staff();
  17094. docType = doc.doctype;
  17095. test.notEqual(docType, null, 'docTypeNotNull');
  17096. notations = docType.notations;
  17097. test.notEqual(notations, null, 'notationsNotNull');
  17098. notationNode = notations.getNamedItem("notation2");
  17099. publicId = notationNode.publicId;
  17100. test.equal(publicId, null, 'publicId');
  17101. test.done();
  17102. },
  17103. /**
  17104. *
  17105. The "getSystemId()" method of a Notation node contains
  17106. the system identifier associated with the notation, if
  17107. one was specified.
  17108. Retrieve the notation named "notation2" and access its
  17109. system identifier. The string "notation2File" should be
  17110. returned.
  17111. * @author NIST
  17112. * @author Mary Brady
  17113. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E8AAB1D0
  17114. */
  17115. notationgetsystemid: function(test) {
  17116. var doc = staff.staff();
  17117. test.notEqual(doc.doctype, null, 'docTypeNotNull');
  17118. test.notEqual(doc.doctype.notations, null, 'notationsNotNull');
  17119. var notationNode = doc.doctype.notations.getNamedItem("notation2");
  17120. test.equal(notationNode.systemId, 'notation2File')
  17121. test.done();
  17122. },
  17123. /**
  17124. *
  17125. Retrieve the notation named "notation1" and access its
  17126. system identifier. Since a system identifier was not
  17127. specified for this notation, the "getSystemId()" method
  17128. should return null.
  17129. * @author NIST
  17130. * @author Mary Brady
  17131. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-E8AAB1D0
  17132. */
  17133. notationgetsystemidnull: function(test) {
  17134. var success;
  17135. var doc;
  17136. var docType;
  17137. var notations;
  17138. var notationNode;
  17139. var systemId;
  17140. doc = staff.staff();
  17141. docType = doc.doctype;
  17142. test.notEqual(docType, null, 'docTypeNotNull');
  17143. notations = docType.notations;
  17144. test.notEqual(notations, null, 'notationsNotNull');
  17145. notationNode = notations.getNamedItem("notation1");
  17146. systemId = notationNode.systemId;
  17147. test.equal(systemId, null, 'systemId');
  17148. test.done();
  17149. },
  17150. /**
  17151. *
  17152. The "getData()" method returns the content of the
  17153. processing instruction. It starts at the first non
  17154. white character following the target and ends at the
  17155. character immediately preceding the "?>".
  17156. Retrieve the ProcessingInstruction node located
  17157. immediately after the prolog. Create a nodelist of the
  17158. child nodes of this document. Invoke the "getData()"
  17159. method on the first child in the list. This should
  17160. return the content of the ProcessingInstruction.
  17161. * @author NIST
  17162. * @author Mary Brady
  17163. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-837822393
  17164. */
  17165. processinginstructiongetdata: function(test) {
  17166. var success;
  17167. var doc;
  17168. var childNodes;
  17169. var piNode;
  17170. var data;
  17171. doc = staff.staff();
  17172. childNodes = doc.childNodes;
  17173. piNode = childNodes.item(0);
  17174. data = piNode.data;
  17175. test.equal(data, 'PIDATA', 'processinginstructionGetTargetAssert');
  17176. test.done();
  17177. },
  17178. /**
  17179. *
  17180. The "getTarget()" method returns the target of the
  17181. processing instruction. It is the first token following
  17182. the markup that begins the processing instruction.
  17183. Retrieve the ProcessingInstruction node located
  17184. immediately after the prolog. Create a nodelist of the
  17185. child nodes of this document. Invoke the "getTarget()"
  17186. method on the first child in the list. This should
  17187. return the target of the ProcessingInstruction.
  17188. * @author NIST
  17189. * @author Mary Brady
  17190. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1478689192
  17191. */
  17192. processinginstructiongettarget: function(test) {
  17193. var success;
  17194. var doc;
  17195. var childNodes;
  17196. var piNode;
  17197. var target;
  17198. doc = staff.staff();
  17199. childNodes = doc.childNodes;
  17200. piNode = childNodes.item(0);
  17201. target = piNode.target;
  17202. test.equal(target, 'TEST-STYLE', 'processinginstructionGetTargetAssert');
  17203. test.done();
  17204. },
  17205. /**
  17206. *
  17207. The "setData(data)" method for a processing instruction causes the
  17208. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  17209. if the node is readonly.
  17210. Obtain the children of the THIRD "gender" element. The elements
  17211. content is an entity reference. Try to remove the "domestic" attribute
  17212. from the entity reference by executing the "setData(data)" method.
  17213. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  17214. * @author NIST
  17215. * @author Mary Brady
  17216. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  17217. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-837822393
  17218. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-837822393')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  17219. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-837822393
  17220. */
  17221. processinginstructionsetdatanomodificationallowederr: function(test) {
  17222. var success;
  17223. var doc;
  17224. var genderList;
  17225. var gender;
  17226. var entRef;
  17227. var piNode;
  17228. doc = staff.staff();
  17229. genderList = doc.getElementsByTagName("gender");
  17230. gender = genderList.item(2);
  17231. entRef = gender.firstChild;
  17232. test.notEqual(entRef, null, 'entRefNotNull');
  17233. piNode = entRef.lastChild;
  17234. test.notEqual(piNode, null, 'piNodeNotNull');
  17235. {
  17236. success = false;
  17237. try {
  17238. piNode.data = "newData";
  17239. }
  17240. catch(ex) {
  17241. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  17242. }
  17243. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  17244. }
  17245. test.done();
  17246. },
  17247. /**
  17248. *
  17249. The "setData(data)" method for a processing instruction causes the
  17250. DOMException NO_MODIFICATION_ALLOWED_ERR to be raised
  17251. if the node is readonly.
  17252. Create an ent4 entity reference and add to document of the THIRD "gender" element. The elements
  17253. content is an entity reference. Try to remove the "domestic" attribute
  17254. from the entity reference by executing the "setData(data)" method.
  17255. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  17256. * @author Curt Arnold
  17257. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  17258. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-837822393
  17259. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-837822393')/setraises/exception[@name='DOMException']/descr/p[substring-before(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  17260. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-837822393
  17261. * @see http://lists.w3.org/Archives/Public/www-dom-ts/2002Apr/0053.html
  17262. * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/processinginstructionsetdatanomodificationallowederr.xml
  17263. */
  17264. processinginstructionsetdatanomodificationallowederrEE: function(test) {
  17265. var success;
  17266. var doc;
  17267. var genderList;
  17268. var gender;
  17269. var entRef;
  17270. var piNode;
  17271. var appendedChild;
  17272. doc = staff.staff();
  17273. genderList = doc.getElementsByTagName("gender");
  17274. gender = genderList.item(2);
  17275. entRef = doc.createEntityReference("ent4");
  17276. appendedChild = gender.appendChild(entRef);
  17277. entRef = gender.lastChild;
  17278. test.notEqual(entRef, null, 'entRefNotNull');
  17279. piNode = entRef.lastChild;
  17280. test.notEqual(piNode, null, 'piNodeNotNull');
  17281. {
  17282. success = false;
  17283. try {
  17284. piNode.data = "newData";
  17285. }
  17286. catch(ex) {
  17287. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  17288. }
  17289. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  17290. }
  17291. test.done();
  17292. },
  17293. /**
  17294. *
  17295. The "splitText(offset)" method raises an
  17296. INDEX_SIZE_ERR DOMException if the specified offset is
  17297. negative.
  17298. Retrieve the textual data from the second child of the
  17299. third employee and invoke the "splitText(offset)" method.
  17300. The desired exception should be raised since the offset
  17301. is a negative number.
  17302. * @author NIST
  17303. * @author Mary Brady
  17304. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  17305. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  17306. * @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'])
  17307. */
  17308. textindexsizeerrnegativeoffset: function(test) {
  17309. var success;
  17310. var doc;
  17311. var elementList;
  17312. var nameNode;
  17313. var textNode;
  17314. var splitNode;
  17315. doc = staff.staff();
  17316. elementList = doc.getElementsByTagName("name");
  17317. nameNode = elementList.item(2);
  17318. textNode = nameNode.firstChild;
  17319. {
  17320. success = false;
  17321. try {
  17322. splitNode = textNode.splitText(-69);
  17323. }
  17324. catch(ex) {
  17325. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  17326. }
  17327. test.ok(success, 'throws_INDEX_SIZE_ERR');
  17328. }
  17329. test.done();
  17330. },
  17331. /**
  17332. *
  17333. The "splitText(offset)" method raises an
  17334. INDEX_SIZE_ERR DOMException if the specified offset is
  17335. greater than the number of characters in the Text node.
  17336. Retrieve the textual data from the second child of the
  17337. third employee and invoke the "splitText(offset)" method.
  17338. The desired exception should be raised since the offset
  17339. is a greater than the number of characters in the Text
  17340. node.
  17341. * @author NIST
  17342. * @author Mary Brady
  17343. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='INDEX_SIZE_ERR'])
  17344. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  17345. * @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'])
  17346. * @see http://www.w3.org/Bugs/Public/show_bug.cgi?id=249
  17347. */
  17348. textindexsizeerroffsetoutofbounds: function(test) {
  17349. var success;
  17350. var doc;
  17351. var elementList;
  17352. var nameNode;
  17353. var textNode;
  17354. var splitNode;
  17355. doc = staff.staff();
  17356. elementList = doc.getElementsByTagName("name");
  17357. nameNode = elementList.item(2);
  17358. textNode = nameNode.firstChild;
  17359. {
  17360. success = false;
  17361. try {
  17362. splitNode = textNode.splitText(300);
  17363. }
  17364. catch(ex) {
  17365. success = (typeof(ex.code) != 'undefined' && ex.code == 1);
  17366. }
  17367. test.ok(success, 'throw_INDEX_SIZE_ERR');
  17368. }
  17369. test.done();
  17370. },
  17371. /**
  17372. *
  17373. Retrieve the textual data from the last child of the
  17374. second employee. That node is composed of two
  17375. EntityReference nodes and two Text nodes. After
  17376. the content node is parsed, the "address" Element
  17377. should contain four children with each one of the
  17378. EntityReferences containing one child.
  17379. * @author NIST
  17380. * @author Mary Brady
  17381. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
  17382. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-11C98490
  17383. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-745549614
  17384. */
  17385. textparseintolistofelements: function(test) {
  17386. var success;
  17387. var doc;
  17388. var elementList;
  17389. var addressNode;
  17390. var childList;
  17391. var child;
  17392. var length;
  17393. var value;
  17394. var grandChild;
  17395. var result = new Array();
  17396. expectedNormal = new Array();
  17397. expectedNormal[0] = "1900 Dallas Road";
  17398. expectedNormal[1] = " Dallas, ";
  17399. expectedNormal[2] = "Texas";
  17400. expectedNormal[3] = "\n 98554";
  17401. expectedExpanded = new Array();
  17402. expectedExpanded[0] = "1900 Dallas Road Dallas, Texas\n 98554";
  17403. doc = staff.staff();
  17404. elementList = doc.getElementsByTagName("address");
  17405. addressNode = elementList.item(1);
  17406. childList = addressNode.childNodes;
  17407. length = childList.length;
  17408. for(var indexN1007F = 0;indexN1007F < childList.length; indexN1007F++) {
  17409. child = childList.item(indexN1007F);
  17410. value = child.nodeValue;
  17411. if(
  17412. (value == null)
  17413. ) {
  17414. grandChild = child.firstChild;
  17415. test.notEqual(grandChild, null, 'grandChildNotNull');
  17416. value = grandChild.nodeValue;
  17417. result[result.length] = value;
  17418. }
  17419. else {
  17420. result[result.length] = value;
  17421. }
  17422. }
  17423. if(
  17424. (4 == length)
  17425. ) {
  17426. test.deepEqual(result, expectedNormal, 'assertEqNormal');
  17427. }
  17428. else {
  17429. test.deepEqual(result, expectedExpanded, 'assertEqCoalescing');
  17430. }
  17431. test.done();
  17432. },
  17433. /**
  17434. *
  17435. The "splitText(offset)" method returns the new Text node.
  17436. Retrieve the textual data from the last child of the
  17437. first employee and invoke the "splitText(offset)" method.
  17438. The method should return the new Text node. The offset
  17439. value used for this test is 30. The "getNodeValue()"
  17440. method is called to check that the new node now contains
  17441. the characters at and after position 30.
  17442. (Starting count at 0)
  17443. * @author NIST
  17444. * @author Mary Brady
  17445. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  17446. */
  17447. textsplittextfour: function(test) {
  17448. var success;
  17449. var doc;
  17450. var elementList;
  17451. var addressNode;
  17452. var textNode;
  17453. var splitNode;
  17454. var value;
  17455. doc = staff.staff();
  17456. elementList = doc.getElementsByTagName("address");
  17457. addressNode = elementList.item(0);
  17458. textNode = addressNode.firstChild;
  17459. splitNode = textNode.splitText(30);
  17460. value = splitNode.nodeValue;
  17461. test.equal(value, '98551', 'textSplitTextFourAssert');
  17462. test.done();
  17463. },
  17464. /**
  17465. *
  17466. The "splitText(offset)" method raises a
  17467. NO_MODIFICATION_ALLOWED_ERR DOMException if the
  17468. node is readonly.
  17469. Obtain the children of the THIRD "gender" element. The elements
  17470. content is an entity reference. Get the element content of the FIRST
  17471. Text Node of the entity reference and execute the "splitText(offset)" method.
  17472. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  17473. * @author NIST
  17474. * @author Mary Brady
  17475. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  17476. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  17477. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  17478. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  17479. */
  17480. textsplittextnomodificationallowederr: function(test) {
  17481. var success;
  17482. var doc;
  17483. var genderList;
  17484. var gender;
  17485. var entRef;
  17486. var entElement;
  17487. var entElementText;
  17488. var splitNode;
  17489. var nodeType;
  17490. doc = staff.staff();
  17491. genderList = doc.getElementsByTagName("gender");
  17492. gender = genderList.item(2);
  17493. entRef = gender.firstChild;
  17494. test.notEqual(entRef, null, 'entRefNotNull');
  17495. nodeType = entRef.nodeType;
  17496. if(
  17497. (1 == nodeType)
  17498. ) {
  17499. entRef = doc.createEntityReference("ent4");
  17500. test.notEqual(entRef, null, 'createdEntRefNotNull');
  17501. }
  17502. entElement = entRef.firstChild;
  17503. test.notEqual(entElement, null, 'entElementNotNull');
  17504. entElementText = entElement.firstChild;
  17505. test.notEqual(entElementText, null, 'entElementTextNotNull');
  17506. {
  17507. success = false;
  17508. try {
  17509. splitNode = entElementText.splitText(2);
  17510. }
  17511. catch(ex) {
  17512. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  17513. }
  17514. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  17515. }
  17516. test.done();
  17517. },
  17518. /**
  17519. *
  17520. Create an ent3 reference and execute the "splitText(offset)" method.
  17521. This causes a NO_MODIFICATION_ALLOWED_ERR DOMException to be thrown.
  17522. * @author Curt Arnold
  17523. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#xpointer(id('ID-258A00AF')/constant[@name='NO_MODIFICATION_ALLOWED_ERR'])
  17524. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  17525. * @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(.,':')='NO_MODIFICATION_ALLOWED_ERR'])
  17526. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  17527. * @see http://www.w3.org/2001/DOM-Test-Suite/level1/core/textsplittextnomodificationallowederr.xml
  17528. */
  17529. textsplittextnomodificationallowederrEE: function(test) {
  17530. var success;
  17531. var doc;
  17532. var entRef;
  17533. var entText;
  17534. var splitNode;
  17535. doc = staff.staff();
  17536. entRef = doc.createEntityReference("ent3");
  17537. test.notEqual(entRef, null, 'createdEntRefNotNull');
  17538. entText = entRef.firstChild;
  17539. test.notEqual(entText, null, 'entTextNotNull');
  17540. success = false;
  17541. try {
  17542. splitNode = entText.splitText(2);
  17543. }
  17544. catch(ex) {
  17545. success = (typeof(ex.code) != 'undefined' && ex.code == 7);
  17546. }
  17547. test.ok(success, 'throw_NO_MODIFICATION_ALLOWED_ERR');
  17548. test.done();
  17549. },
  17550. /**
  17551. *
  17552. The "splitText(offset)" method breaks the Text node into
  17553. two Text nodes at the specified offset keeping each node
  17554. as siblings in the tree.
  17555. Retrieve the textual data from the second child of the
  17556. third employee and invoke the "splitText(offset)" method.
  17557. The method splits the Text node into two new sibling
  17558. Text nodes keeping both of them in the tree. This test
  17559. checks the "nextSibling()" method of the original node
  17560. to ensure that the two nodes are indeed siblings.
  17561. * @author NIST
  17562. * @author Mary Brady
  17563. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  17564. */
  17565. textsplittextone: function(test) {
  17566. var success;
  17567. var doc;
  17568. var elementList;
  17569. var nameNode;
  17570. var textNode;
  17571. var splitNode;
  17572. var secondPart;
  17573. var value;
  17574. doc = staff.staff();
  17575. elementList = doc.getElementsByTagName("name");
  17576. nameNode = elementList.item(2);
  17577. textNode = nameNode.firstChild;
  17578. splitNode = textNode.splitText(7);
  17579. secondPart = textNode.nextSibling;
  17580. value = secondPart.nodeValue;
  17581. test.equal(value, 'Jones', 'textSplitTextOneAssert');
  17582. test.done();
  17583. },
  17584. /**
  17585. *
  17586. After the "splitText(offset)" method breaks the Text node
  17587. into two Text nodes, the new Text node contains all the
  17588. content at and after the offset point.
  17589. Retrieve the textual data from the second child of the
  17590. third employee and invoke the "splitText(offset)" method.
  17591. The new Text node should contain all the content
  17592. at and after the offset point. The "getNodeValue()"
  17593. method is called to check that the new node now contains
  17594. the characters at and after position seven.
  17595. (Starting count at 0)
  17596. * @author NIST
  17597. * @author Mary Brady
  17598. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  17599. */
  17600. textsplittextthree: function(test) {
  17601. var success;
  17602. var doc;
  17603. var elementList;
  17604. var nameNode;
  17605. var textNode;
  17606. var splitNode;
  17607. var value;
  17608. doc = staff.staff();
  17609. elementList = doc.getElementsByTagName("name");
  17610. nameNode = elementList.item(2);
  17611. textNode = nameNode.firstChild;
  17612. splitNode = textNode.splitText(6);
  17613. value = splitNode.nodeValue;
  17614. test.equal(value, ' Jones', 'textSplitTextThreeAssert');
  17615. test.done();
  17616. },
  17617. /**
  17618. *
  17619. After the "splitText(offset)" method breaks the Text node
  17620. into two Text nodes, the original node contains all the
  17621. content up to the offset point.
  17622. Retrieve the textual data from the second child of the
  17623. third employee and invoke the "splitText(offset)" method.
  17624. The original Text node should contain all the content
  17625. up to the offset point. The "getNodeValue()" method
  17626. is called to check that the original node now contains
  17627. the first five characters.
  17628. * @author NIST
  17629. * @author Mary Brady
  17630. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-38853C1D
  17631. */
  17632. textsplittexttwo: function(test) {
  17633. var success;
  17634. var doc;
  17635. var elementList;
  17636. var nameNode;
  17637. var textNode;
  17638. var splitNode;
  17639. var value;
  17640. doc = staff.staff();
  17641. elementList = doc.getElementsByTagName("name");
  17642. nameNode = elementList.item(2);
  17643. textNode = nameNode.firstChild;
  17644. splitNode = textNode.splitText(5);
  17645. value = textNode.nodeValue;
  17646. test.equal(value, 'Roger', 'textSplitTextTwoAssert');
  17647. test.done();
  17648. },
  17649. /**
  17650. *
  17651. If there is not any markup inside an Element or Attr node
  17652. content, then the text is contained in a single object
  17653. implementing the Text interface that is the only child
  17654. of the element.
  17655. Retrieve the textual data from the second child of the
  17656. third employee. That Text node contains a block of
  17657. multiple text lines without markup, so they should be
  17658. treated as a single Text node. The "getNodeValue()"
  17659. method should contain the combination of the two lines.
  17660. * @author NIST
  17661. * @author Mary Brady
  17662. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1312295772
  17663. * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
  17664. */
  17665. textwithnomarkup: function(test) {
  17666. var success;
  17667. var doc;
  17668. var elementList;
  17669. var nameNode;
  17670. var nodeV;
  17671. var value;
  17672. doc = staff.staff();
  17673. elementList = doc.getElementsByTagName("name");
  17674. nameNode = elementList.item(2);
  17675. nodeV = nameNode.firstChild;
  17676. value = nodeV.nodeValue;
  17677. test.equal(value, 'Roger\n Jones', 'textNodeValue');
  17678. test.done();
  17679. }
  17680. };