Author: dolander Date: Thu Jan 13 13:27:33 2005 New Revision: 125104 URL: http://svn.apache.org/viewcvs?view=rev&rev=125104 Log: Add a test of nesting ScriptContainers with duplicate TagIds and ScopeIds
Added: incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapNesting.xml Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nesting/index.jsp incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nesting/index.jsp Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nesting/index.jsp?view=diff&rev=125104&p1=incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nesting/index.jsp&r1=125103&p2=incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nesting/index.jsp&r2=125104 ============================================================================== --- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nesting/index.jsp (original) +++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/nesting/index.jsp Thu Jan 13 13:27:33 2005 @@ -7,8 +7,8 @@ </head> <netui:body> <p style="color: green">This test will generate multiple nested ScriptContainers - which requires fully qualifying the lookup to find the proper span. There - are two spans with the same tagId inside a ScriptContainer with the same + which requires fully qualifying the lookup to find the proper span or textbox. There + are two spans and textboxes with the same tagId inside a ScriptContainer with the same scopeId. These are then found in a outer ScriptContainer that has generateScopeId = 'true' so that we create a unique id. This will not work in the legacy lookups. Modified: incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml?view=diff&rev=125104&p1=incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml&r1=125103&p2=incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml&r2=125104 ============================================================================== --- incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml (original) +++ incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml Thu Jan 13 13:27:33 2005 @@ -3164,6 +3164,19 @@ </features> </test> <test> + <name>IdMapNesting</name> + <description>Verify tagId lookups in a nested situation with duplicate scope ids</description> + <webapp>coreWeb</webapp> + <categories> + <category>bvt</category> + <category>tags</category> + </categories> + <features> + <feature>JavaScript</feature> + <feature>tagid</feature> + </features> + </test> + <test> <name>IdMapNonCtrls</name> <description>Verify the non-HTML controls produce tagId lookup</description> <webapp>coreWeb</webapp> Added: incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapNesting.xml Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapNesting.xml?view=auto&rev=125104 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/IdMapNesting.xml Thu Jan 13 13:27:33 2005 @@ -0,0 +1,282 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ses:recorderSession xmlns:ses="http://beehive.apache.org/netui/tools/testrecorder/2004/session"> + <ses:sessionName>IdMapNesting</ses:sessionName> + <ses:tester>Daryl</ses:tester> + <ses:startDate>13 Jan 2005, 02:03:57.739 PM MST</ses:startDate> + <ses:description>Test of multiple levels of nesting with matching tagId and scope Id values.</ses:description> + <ses:tests> + <ses:test> + <ses:testNumber>1</ses:testNumber> + <ses:request> + <ses:protocol>HTTP</ses:protocol> + <ses:protocolVersion>1.1</ses:protocolVersion> + <ses:host>localhost</ses:host> + <ses:port>8080</ses:port> + <ses:uri>/coreWeb/idmap/nesting/Controller.jpf</ses:uri> + <ses:method>GET</ses:method> + <ses:parameters/> + <ses:cookies> + <ses:cookie> + <ses:name>JSESSIONID</ses:name> + <ses:value>FD220D00F97EF9842E38205385D3192F</ses:value> + </ses:cookie> + </ses:cookies> + <ses:headers> + <ses:header> + <ses:name>accept</ses:name> + <ses:value>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</ses:value> + </ses:header> + <ses:header> + <ses:name>accept-charset</ses:name> + <ses:value>ISO-8859-1,utf-8;q=0.7,*;q=0.7</ses:value> + </ses:header> + <ses:header> + <ses:name>accept-encoding</ses:name> + <ses:value>gzip,deflate</ses:value> + </ses:header> + <ses:header> + <ses:name>accept-language</ses:name> + <ses:value>en-us,en;q=0.5</ses:value> + </ses:header> + <ses:header> + <ses:name>connection</ses:name> + <ses:value>keep-alive</ses:value> + </ses:header> + <ses:header> + <ses:name>cookie</ses:name> + <ses:value>JSESSIONID=FD220D00F97EF9842E38205385D3192F</ses:value> + </ses:header> + <ses:header> + <ses:name>host</ses:name> + <ses:value>localhost:8080</ses:value> + </ses:header> + <ses:header> + <ses:name>keep-alive</ses:name> + <ses:value>300</ses:value> + </ses:header> + <ses:header> + <ses:name>user-agent</ses:name> + <ses:value>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0</ses:value> + </ses:header> + </ses:headers> + </ses:request> + <ses:response> + <ses:statusCode>200</ses:statusCode> + <ses:reason/> + <ses:responseBody><!DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01 Transitional//EN" + "http://www.w3.org/TR/html4/loose.dtd"> +<html lang="en"> + + <head> + <base href="http://localhost:8080/coreWeb/idmap/nesting/index.jsp"> + </head> + <body> + <p style="color: green">This test will generate multiple nested ScriptContainers + which requires fully qualifying the lookup to find the proper span or textbox. There + are two spans and textboxes with the same tagId inside a ScriptContainer with the same + scopeId. These are then found in a outer ScriptContainer that has + generateScopeId = 'true' so that we create a unique id. This will not + work in the legacy lookups. + </p> + <div netui:scopeId="n0" > + <div netui:scopeId="scope" > + <span id="scopeOneSpan" /> + <input type="text" name="{pageFlow.textOne}" id="n0.scope.textBox"> + <span id="n0.scope.span" spanId="[1]">span[1] inside scopeOneSpan</span> + </span> + </div> + +<script language="JavaScript" type="text/JavaScript"> +<!-- + +// **** This section contains code that will run when the page is loaded **** + + +// Build the netui_names table to map the tagId attributes +// to the real id written into the HTML +if (netui_names == null) + var netui_names = new Object(); +netui_names.scope__textBox="{pageFlow.textOne}" +netui_names.scope__span="n0.scope.span" + + +// Build the netui_names table to map the tagId attributes +// to the real id written into the HTML +if (netui_tagIdNameMap == null) + var netui_tagIdNameMap = new Object(); +netui_tagIdNameMap.n0_scope___textBox="{pageFlow.textOne}" + + +// **** This section contains functions typically run as events **** + + +// method which will return a real id for a tagId, +// the tag parameter will be used to find the scopeId for +// containers that may scope their ids +function getNetuiTagName(id, tag) +{ + var scopeId = getScopeId(tag); + if (scopeId == "") + return netui_names[id]; + else + return netui_names[scopeId + "__" + id]; +} + +// This method will walk the hierarchy from the pass element looking for a scopeId. +// The first scopeId found will be returned or the empty string if a scopeId is not found. +function getScopeId(tag) +{ + if (tag == null || tag.getAttribute == null) + return ""; + var attrVal = tag.getAttribute("netui:scopeId"); + if (attrVal != null) + return attrVal; + return getScopeId(tag.parentNode); +} + +// lookup by tagId to "real id" +function lookupIdByTagId(id, tag) +{ + var scopeId = lookupScopeId(tag,"."); + return (scopeId == "") ? id : scopeId + id; +} + +// lookup by tagId to "real name" +function lookupNameByTagId(id, tag) +{ + var scopeId = lookupScopeId(tag,"_"); + if (scopeId == "") + return netui_tagIdNameMap[id]; + else + return netui_tagIdNameMap[scopeId + "__" + id]; +} + +//Non-Legacy lookup method creating a fully qualified scope id +function lookupScopeId(tag,sep) +{ + var val = ""; + while (tag != null && tag.getAttribute != null) { + var attrVal = tag.getAttribute("netui:scopeId"); + if (attrVal != null) + val = attrVal + sep + val; + tag = tag.parentNode; + } + return val; +} +--> +</script> + + + </div> + <div netui:scopeId="n1" > + <div netui:scopeId="scope" > + <span id="scopeTwoSpan" /> + <input type="text" name="{pageFlow.textTwo}" id="n1.scope.textBox"> + <span id="n1.scope.span" spanId="[1]">span[2] inside scopeTwoSpan</span> + </span> + </div> + +<script language="JavaScript" type="text/JavaScript"> +<!-- + +// **** This section contains code that will run when the page is loaded **** + + +// Build the netui_names table to map the tagId attributes +// to the real id written into the HTML +if (netui_names == null) + var netui_names = new Object(); +netui_names.scope__textBox="{pageFlow.textTwo}" +netui_names.scope__span="n1.scope.span" + + +// Build the netui_names table to map the tagId attributes +// to the real id written into the HTML +if (netui_tagIdNameMap == null) + var netui_tagIdNameMap = new Object(); +netui_tagIdNameMap.n1_scope___textBox="{pageFlow.textTwo}" + +--> +</script> + + + </div> + <hr> + <p style="color: green">Below we search for each span by the tagId name. We + should find the individual spans. Below the search results there is a dump + of the lookup tables. + </p> + <p id="javaOut"></p> + </body> +<script language="JavaScript" type="text/JavaScript"> + + var p = document.getElementById("javaOut"); + var s1 = document.getElementById("scopeOneSpan"); + var s2 = document.getElementById("scopeTwoSpan"); + + var val = "<b>Document Access</b><br>"; + + val = val + "Span[1] by id is null: <b>" + + (document.getElementById(lookupIdByTagId("span",s1)) == null) + "</b><br>"; + val = val + "Span[2] by id is null: <b>" + + (document.getElementById(lookupIdByTagId("span",s2)) == null) + "</b><br>"; + val = val + "TextBox[1] by id is null: <b>" + + (document.getElementById(lookupIdByTagId("textBox",s1)) == null) + "</b><br>"; + val = val + "TextBox[2] by id is null: <b>" + + (document.getElementById(lookupIdByTagId("textBox",s2)) == null) + "</b><br>"; + var tmp = document.getElementsByName(lookupNameByTagId("textBox",s1)); + val = val + "<br>TextBox[1] by name is == 0: <b>" + + (tmp.length == 0) + + "</b><br>"; + if (tmp.length > 0) { + val = val + "TextBox[1] id: <b>" + tmp[0].id + "</b><br>"; + } + else { + val = val + "TextBox[1] <b>not found</b><br>"; + } + + tmp = document.getElementsByName(lookupNameByTagId("textBox",s2)); + val = val + "<br>TextBox[2] by name is == 0: <b>" + + (tmp.length == 0) + + "</b><br>"; + if (tmp.length > 0) { + val = val + "TextBox[2] id: <b>" + tmp[0].id + "</b><br>"; + } + else { + val = val + "TextBox[2] <b>not found</b><br>"; + } + + val = val + "<br>"; + if (typeof(netui_tagIdNameMap) != "undefined") { + val = val + "<b>tagIdNameMap:</b><br>"; + for (var x in netui_tagIdNameMap) { + val = val + "Name '" + x + "' value '" + netui_tagIdNameMap[x] + "'<br>"; + } + val = val + "<br>"; + } + else { + val = val + "tagIdNameMap is <b>undefined</b><br><br>"; + } + + if (typeof(netui_names) != "undefined") { + val = val + "<b>netui_names (Legacy):</b><br>"; + for (var x in netui_names) { + val = val + "Name '" + x + "' value '" + netui_names[x] + "'<br>"; + } + val = val + "<br>"; + } + else { + val = val + "netui_name (Legacy) is <b>undefined</b><br>"; + } + + p.innerHTML = val; + +</script> + +</html></ses:responseBody> + </ses:response> + </ses:test> + </ses:tests> + <ses:endDate>13 Jan 2005, 02:04:03.637 PM MST</ses:endDate> + <ses:testCount>1</ses:testCount> +</ses:recorderSession> \ No newline at end of file
