diff options
author | xue <> | 2006-06-02 18:27:02 +0000 |
---|---|---|
committer | xue <> | 2006-06-02 18:27:02 +0000 |
commit | 0f3a577bed4d828472469675e90fcab032e33f44 (patch) | |
tree | 3ca817247b8006563900d5fb8995d6a6f0627a2b /tests/FunctionalTests/selenium/core/domviewer | |
parent | 067ab51fbd9b2f18f63fc80895476e5b0e2f9bfb (diff) |
merge from 3.0 branch till 1133.
Diffstat (limited to 'tests/FunctionalTests/selenium/core/domviewer')
-rwxr-xr-x | tests/FunctionalTests/selenium/core/domviewer/butmin.gif | bin | 0 -> 843 bytes | |||
-rwxr-xr-x | tests/FunctionalTests/selenium/core/domviewer/butplus.gif | bin | 0 -> 848 bytes | |||
-rwxr-xr-x | tests/FunctionalTests/selenium/core/domviewer/domviewer.css | 298 | ||||
-rwxr-xr-x | tests/FunctionalTests/selenium/core/domviewer/domviewer.html | 16 | ||||
-rwxr-xr-x | tests/FunctionalTests/selenium/core/domviewer/selenium-domviewer.js | 205 |
5 files changed, 519 insertions, 0 deletions
diff --git a/tests/FunctionalTests/selenium/core/domviewer/butmin.gif b/tests/FunctionalTests/selenium/core/domviewer/butmin.gif Binary files differnew file mode 100755 index 00000000..7b7cefd5 --- /dev/null +++ b/tests/FunctionalTests/selenium/core/domviewer/butmin.gif diff --git a/tests/FunctionalTests/selenium/core/domviewer/butplus.gif b/tests/FunctionalTests/selenium/core/domviewer/butplus.gif Binary files differnew file mode 100755 index 00000000..6d68cfa9 --- /dev/null +++ b/tests/FunctionalTests/selenium/core/domviewer/butplus.gif diff --git a/tests/FunctionalTests/selenium/core/domviewer/domviewer.css b/tests/FunctionalTests/selenium/core/domviewer/domviewer.css new file mode 100755 index 00000000..b64b2435 --- /dev/null +++ b/tests/FunctionalTests/selenium/core/domviewer/domviewer.css @@ -0,0 +1,298 @@ +/******************************************************************************
+* Defines default styles for site pages. *
+******************************************************************************/
+.hidden {
+ display: none;
+}
+
+img{
+ display: inline;
+ border: none;
+}
+
+.box{
+ background: #fcfcfc;
+ border: 1px solid #000;
+ border-color: blue;
+ color: #000000;
+ margin: 10px auto;
+ padding: 3px;
+ vertical-align: bottom;
+}
+a {
+ text-decoration: none;
+}
+
+body {
+ background-color: #ffffff;
+ color: #000000;
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 10pt;
+}
+
+h2 {
+ font-size: 140%;
+}
+
+h3 {
+ font-size: 120%;
+}
+
+h4 {
+ font-size: 100%;
+}
+
+pre {
+ font-family: Courier New, Courier, monospace;
+ font-size: 80%;
+}
+
+td, th {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 10pt;
+ text-align: left;
+ vertical-align: top;
+}
+
+th {
+ font-weight: bold;
+ vertical-align: bottom;
+}
+
+ul {
+ list-style-type: square;
+}
+
+#demoBox {
+ border-color: #000000;
+ border-style: solid;
+ border-width: 1px;
+ padding: 8px;
+ width: 24em;
+}
+
+.footer {
+ margin-bottom: 0px;
+ text-align: center;
+}
+
+/* Boxed table styles */
+
+table.boxed {
+ border-spacing: 2px;
+ empty-cells: hide;
+}
+
+td.boxed, th.boxed, th.boxedHeader {
+ background-color: #ffffff;
+ border-color: #000000;
+ border-style: solid;
+ border-width: 1px;
+ color: #000000;
+ padding: 2px;
+ padding-left: 8px;
+ padding-right: 8px;
+}
+
+th.boxed {
+ background-color: #c0c0c0;
+}
+
+th.boxedHeader {
+ background-color: #808080;
+ color: #ffffff;
+}
+
+a.object {
+ color: #0000ff;
+}
+
+li {
+ white-space: nowrap;
+}
+
+ul {
+ list-style-type: square;
+ margin-left: 0px;
+ padding-left: 1em;
+}
+
+.boxlevel1{
+ background: #FFD700;
+}
+
+.boxlevel2{
+ background: #D2691E;
+}
+
+.boxlevel3{
+ background: #DCDCDC;
+}
+
+.boxlevel4{
+ background: #F5F5F5;
+}
+
+.boxlevel5{
+ background: #BEBEBE;
+}
+
+.boxlevel6{
+ background: #D3D3D3;
+}
+
+.boxlevel7{
+ background: #A9A9A9;
+}
+
+.boxlevel8{
+ background: #191970;
+}
+
+.boxlevel9{
+ background: #000080;
+}
+
+.boxlevel10{
+ background: #6495ED;
+}
+
+.boxlevel11{
+ background: #483D8B;
+}
+
+.boxlevel12{
+ background: #6A5ACD;
+}
+
+.boxlevel13{
+ background: #7B68EE;
+}
+
+.boxlevel14{
+ background: #8470FF;
+}
+
+.boxlevel15{
+ background: #0000CD;
+}
+
+.boxlevel16{
+ background: #4169E1;
+}
+
+.boxlevel17{
+ background: #0000FF;
+}
+
+.boxlevel18{
+ background: #1E90FF;
+}
+
+.boxlevel19{
+ background: #00BFFF;
+}
+
+.boxlevel20{
+ background: #87CEEB;
+}
+
+.boxlevel21{
+ background: #B0C4DE;
+}
+
+.boxlevel22{
+ background: #ADD8E6;
+}
+
+.boxlevel23{
+ background: #00CED1;
+}
+
+.boxlevel24{
+ background: #48D1CC;
+}
+
+.boxlevel25{
+ background: #40E0D0;
+}
+
+.boxlevel26{
+ background: #008B8B;
+}
+
+.boxlevel27{
+ background: #00FFFF;
+}
+
+.boxlevel28{
+ background: #E0FFFF;
+}
+
+.boxlevel29{
+ background: #5F9EA0;
+}
+
+.boxlevel30{
+ background: #66CDAA;
+}
+
+.boxlevel31{
+ background: #7FFFD4;
+}
+
+.boxlevel32{
+ background: #006400;
+}
+
+.boxlevel33{
+ background: #556B2F;
+}
+
+.boxlevel34{
+ background: #8FBC8F;
+}
+
+.boxlevel35{
+ background: #2E8B57;
+}
+
+.boxlevel36{
+ background: #3CB371;
+}
+
+.boxlevel37{
+ background: #20B2AA;
+}
+
+.boxlevel38{
+ background: #00FF7F;
+}
+
+.boxlevel39{
+ background: #7CFC00;
+}
+
+.boxlevel40{
+ background: #90EE90;
+}
+
+.boxlevel41{
+ background: #00FF00;
+}
+
+.boxlevel41{
+ background: #7FFF00;
+}
+
+.boxlevel42{
+ background: #00FA9A;
+}
+
+.boxlevel43{
+ background: #ADFF2F;
+}
+
+.boxlevel44{
+ background: #32CD32;
+}
\ No newline at end of file diff --git a/tests/FunctionalTests/selenium/core/domviewer/domviewer.html b/tests/FunctionalTests/selenium/core/domviewer/domviewer.html new file mode 100755 index 00000000..9158a50f --- /dev/null +++ b/tests/FunctionalTests/selenium/core/domviewer/domviewer.html @@ -0,0 +1,16 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <head> + <title>DOM Viewer</title> + <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> + <link rel="stylesheet" type="text/css" href="domviewer.css"/> + <script type="text/javascript" src="selenium-domviewer.js"></script> + </head> + <body onload="loadDomViewer();"> + <h3>DOM Viewer</h3> + <p> This page is generated using JavaScript. If you see this text, your + browser doesn't support JavaScript.</p> + </body> + +</html> diff --git a/tests/FunctionalTests/selenium/core/domviewer/selenium-domviewer.js b/tests/FunctionalTests/selenium/core/domviewer/selenium-domviewer.js new file mode 100755 index 00000000..941aab16 --- /dev/null +++ b/tests/FunctionalTests/selenium/core/domviewer/selenium-domviewer.js @@ -0,0 +1,205 @@ +var HIDDEN="hidden"; +var LEVEL = "level"; +var PLUS_SRC="butplus.gif"; +var MIN_SRC="butmin.gif"; +var newRoot; +var maxColumns=1; + +function loadDomViewer() { + // See if the rootDocument variable has been set on this window. + var rootDocument = window.rootDocument; + + // If not look to the opener for an explicity rootDocument variable, otherwise, use the opener document + if (!rootDocument && window.opener) { + rootDocument = window.opener.rootDocument || window.opener.document; + } + + if (rootDocument) { + document.body.innerHTML = displayDOM(rootDocument); + } + else { + document.body.innerHTML = "<b>Must specify rootDocument for window. This can be done by setting the rootDocument variable on this window, or on the opener window for a popup window.</b>"; + } +} + + +function displayDOM(root){ + var str = ""; + str+="<table>"; + str += treeTraversal(root,0); + // to make table columns work well. + str += "<tr>"; + for (var i=0; i < maxColumns; i++) { + str+= "<td> </td>"; + } + str += "</tr>"; + str += "</table>"; + return str; +} + +function checkForChildren(element){ + if(!element.hasChildNodes()) + return false; + + var nodes = element.childNodes; + var size = nodes.length; + var count=0; + + for(var i=0; i< size; i++){ + var node = nodes.item(i); + //if(node.toString()=="[object Text]"){ + //this is equalent to the above + //but will work with more browsers + if(node.nodeType!=1){ + count++; + } + } + + if(count == size) + return false; + else + return true; +} + +function treeTraversal(root, level){ + var str = ""; + var nodes= null; + var size = null; + //it is supposed to show the last node, + //but the last node is always nodeText type + //and we don't show it + if(!root.hasChildNodes()) + return "";//displayNode(root,level,false); + + nodes = root.childNodes; + size = nodes.length; + + for(var i=0; i< size; i++){ + var element = nodes.item(i); + //if the node is textNode, don't display + if(element.nodeType==1){ + str+= displayNode(element,level,checkForChildren(element)); + str+=treeTraversal(element, level+1); + } + } + return str; +} + +function displayNode(element, level, isLink){ + nodeContent = getNodeContent(element); + columns = Math.round((nodeContent.length / 12) + 0.5); + if (columns + level > maxColumns) { + maxColumns = columns + level; + } + var str ="<tr class='"+LEVEL+level+"'>"; + for (var i=0; i < level; i++) + str+= "<td> </td>"; + str+="<td colspan='"+ columns +"' class='box"+" boxlevel"+level+"' >"; + if(isLink){ + str+='<a onclick="hide(this);return false;" href="javascript:void();">'; + str+='<img src="'+MIN_SRC+'" />'; + } + str += nodeContent; + if(isLink) + str+="</a></td></tr>"; + return str; +} + +function getNodeContent(element) { + + str = ""; + id =""; + if (element.id != null && element.id != "") { + id = " ID(" + element.id +")"; + } + name =""; + if (element.name != null && element.name != "") { + name = " NAME(" + element.name + ")"; + } + value =""; + if (element.value != null && element.value != "") { + value = " VALUE(" + element.value + ")"; + } + href =""; + if (element.href != null && element.href != "") { + href = " HREF(" + element.href + ")"; + } + clazz = ""; + if (element.className != null && element.className != "") { + clazz = " CLASS(" + element.className + ")"; + } + src = ""; + if (element.src != null && element.src != "") { + src = " SRC(" + element.src + ")"; + } + alt = ""; + if (element.alt != null && element.alt != "") { + alt = " ALT(" + element.alt + ")"; + } + type = ""; + if (element.type != null && element.type != "") { + type = " TYPE(" + element.type + ")"; + } + text =""; + if (element.text != null && element.text != "" && element.text != "undefined") { + text = " #TEXT(" + trim(element.text) +")"; + } + str+=" <b>"+ element.nodeName + id + alt + type + clazz + name + value + href + src + text + "</b>"; + return str; + +} + +function trim(val) { + val2 = val.substring(0,40) + " "; + var spaceChr = String.fromCharCode(32); + var length = val2.length; + var retVal = ""; + var ix = length -1; + + while(ix > -1){ + if(val2.charAt(ix) == spaceChr) { + } else { + retVal = val2.substring(0, ix +1); + break; + } + ix = ix-1; + } + if (val.length > 40) { + retVal += "..."; + } + return retVal; +} + +function hide(hlink){ + var isHidden = false; + var image = hlink.firstChild; + if(image.src.toString().indexOf(MIN_SRC)!=-1){ + image.src=PLUS_SRC; + isHidden=true; + }else{ + image.src=MIN_SRC; + } + var rowObj= hlink.parentNode.parentNode; + var rowLevel = parseInt(rowObj.className.substring(LEVEL.length)); + + var sibling = rowObj.nextSibling; + var siblingLevel = sibling.className.substring(LEVEL.length); + if(siblingLevel.indexOf(HIDDEN)!=-1){ + siblingLevel = siblingLevel.substring(0,siblingLevel.length - HIDDEN.length-1); + } + siblingLevel=parseInt(siblingLevel); + while(sibling!=null && rowLevel<siblingLevel){ + if(isHidden){ + sibling.className += " "+ HIDDEN; + }else if(!isHidden && sibling.className.indexOf(HIDDEN)!=-1){ + var str = sibling.className; + sibling.className=str.substring(0, str.length - HIDDEN.length-1); + } + sibling = sibling.nextSibling; + siblingLevel = parseInt(sibling.className.substring(LEVEL.length)); + } +} + +function LOG(message) { + window.opener.LOG.warn(message); +} |