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>&lt;!DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01 
Transitional//EN"
+       "http://www.w3.org/TR/html4/loose.dtd";>
+&lt;html lang="en">
+
+    &lt;head>
+        &lt;base href="http://localhost:8080/coreWeb/idmap/nesting/index.jsp";>
+    &lt;/head>
+    &lt;body>
+        &lt;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.
+        &lt;/p>
+       &lt;div netui:scopeId="n0" >
+           &lt;div netui:scopeId="scope" >
+               &lt;span id="scopeOneSpan" />
+                  &lt;input type="text" name="{pageFlow.textOne}" 
id="n0.scope.textBox">
+                 &lt;span id="n0.scope.span" spanId="[1]">span[1] inside 
scopeOneSpan&lt;/span>
+               &lt;/span>
+           &lt;/div>
+
+&lt;script language="JavaScript" type="text/JavaScript">
+&lt;!--
+
+// **** 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 &amp;&amp; tag.getAttribute != null) {
+      var attrVal = tag.getAttribute("netui:scopeId");
+      if (attrVal != null)
+         val = attrVal + sep + val;
+      tag = tag.parentNode;
+   }
+   return val;
+}
+-->
+&lt;/script>
+
+
+       &lt;/div>
+       &lt;div netui:scopeId="n1" >
+           &lt;div netui:scopeId="scope" >
+              &lt;span id="scopeTwoSpan" />
+                  &lt;input type="text" name="{pageFlow.textTwo}" 
id="n1.scope.textBox">
+                &lt;span id="n1.scope.span" spanId="[1]">span[2] inside 
scopeTwoSpan&lt;/span>
+              &lt;/span>
+           &lt;/div>
+
+&lt;script language="JavaScript" type="text/JavaScript">
+&lt;!--
+
+// **** 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}"
+
+-->
+&lt;/script>
+
+
+       &lt;/div>
+        &lt;hr>
+        &lt;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.
+        &lt;/p>
+        &lt;p id="javaOut">&lt;/p>
+    &lt;/body>
+&lt;script language="JavaScript" type="text/JavaScript">
+
+    var p = document.getElementById("javaOut");
+    var s1 = document.getElementById("scopeOneSpan");
+    var s2 = document.getElementById("scopeTwoSpan");
+
+    var val = "&lt;b>Document Access&lt;/b>&lt;br>";
+
+    val = val + "Span[1] by id is null: &lt;b>" +
+        (document.getElementById(lookupIdByTagId("span",s1)) == null) + 
"&lt;/b>&lt;br>";
+    val = val + "Span[2] by id is null: &lt;b>" +
+        (document.getElementById(lookupIdByTagId("span",s2)) == null) + 
"&lt;/b>&lt;br>";
+    val = val + "TextBox[1] by id is null: &lt;b>" +
+        (document.getElementById(lookupIdByTagId("textBox",s1)) == null) + 
"&lt;/b>&lt;br>";
+    val = val + "TextBox[2] by id is null: &lt;b>" +
+        (document.getElementById(lookupIdByTagId("textBox",s2)) == null) + 
"&lt;/b>&lt;br>";
+    var tmp = document.getElementsByName(lookupNameByTagId("textBox",s1));
+    val = val + "&lt;br>TextBox[1] by name is == 0: &lt;b>" +
+        (tmp.length == 0) +
+       "&lt;/b>&lt;br>";
+    if (tmp.length > 0) {
+       val = val + "TextBox[1] id: &lt;b>" + tmp[0].id + "&lt;/b>&lt;br>";
+    }
+    else {
+       val = val + "TextBox[1] &lt;b>not found&lt;/b>&lt;br>";
+    }
+
+    tmp = document.getElementsByName(lookupNameByTagId("textBox",s2));
+    val = val + "&lt;br>TextBox[2] by name is == 0: &lt;b>" +
+        (tmp.length == 0) +
+       "&lt;/b>&lt;br>";
+    if (tmp.length > 0) {
+       val = val + "TextBox[2] id: &lt;b>" + tmp[0].id + "&lt;/b>&lt;br>";
+    }
+    else {
+       val = val + "TextBox[2] &lt;b>not found&lt;/b>&lt;br>";
+    }
+
+    val = val + "&lt;br>";
+    if (typeof(netui_tagIdNameMap) != "undefined") {
+       val = val + "&lt;b>tagIdNameMap:&lt;/b>&lt;br>";
+       for (var x in netui_tagIdNameMap) {
+           val = val + "Name '" + x + "' value '" + netui_tagIdNameMap[x] + 
"'&lt;br>";
+       }
+       val = val + "&lt;br>";
+    }
+    else {
+       val = val + "tagIdNameMap is &lt;b>undefined&lt;/b>&lt;br>&lt;br>";
+    }
+
+    if (typeof(netui_names) != "undefined") {
+       val = val + "&lt;b>netui_names (Legacy):&lt;/b>&lt;br>";
+       for (var x in netui_names) {
+           val = val + "Name '" + x + "' value '" + netui_names[x] + 
"'&lt;br>";
+       }
+       val = val + "&lt;br>";
+    }
+    else {
+       val = val + "netui_name (Legacy) is &lt;b>undefined&lt;/b>&lt;br>";
+    }
+
+    p.innerHTML = val;
+
+&lt;/script>
+
+&lt;/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

Reply via email to