not part of build; adding a XUL interface to use the xalan conformance tests for transformiix

This commit is contained in:
axel%pike.org 2001-03-02 03:45:29 +00:00
Родитель 3f1333fffc
Коммит 9a75233afd
11 изменённых файлов: 558 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,67 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Axel Hecht.
* Portions created by Axel Hecht are Copyright (C) 2001 Axel Hecht.
* All Rights Reserved.
*
* Contributor(s):
* Axel Hecht <axel@pike.org> (Original Author)
*/
// ----------------------
// DiffDOM(node1,node2)
// ----------------------
function DiffDOM(node1,node2)
{
return DiffNodeAndChildren(node1, node2);
}
// This function does the work of DiffDOM by recursively calling
// itself to explore the tree
function DiffNodeAndChildren(node1, node2)
{
if (!node1 && !node2) return true;
if (!node1 || !node2) return false;
if (node1.type!=node2.type){
return false;
}
var attributes = node1.attributes;
if ( attributes && attributes.length ) {
var item, name, value;
for ( var index = 0; index < attributes.length; index++ ) {
item = attributes.item(index);
name = item.nodeName;
value = item.nodeValue;
if (node2.getAttribute(name)!=value){
return false;
}
}
}
if (node1.nodeName!=node2.nodeName) return false;
if (node1.nodeValue!=node2.nodeValue) return false;
if (node1.hasChildNodes() != node2.hasChildNodes()) return false;
if ( node1.childNodes ) {
if (node1.childNodes.length != node2.childNodes.length) return false;
for ( var child = 0; child < node1.childNodes.length; child++ )
if (!DiffNodeAndChildren(node1.childNodes[child], node2.childNodes[child])) {
return false;
}
}
return true;
}

Просмотреть файл

@ -0,0 +1,85 @@
// ----------------------
// DumpDOM(node)
//
// Call this function to dump the contents of the DOM starting at the specified node.
// Use node = document.documentElement to dump every element of the current document.
// Use node = top.window.document.documentElement to dump every element.
//
// 8-13-99 Updated to dump almost all attributes of every node. There are still some attributes
// that are purposely skipped to make it more readable.
// ----------------------
function DumpDOM(node)
{
dump("--------------------- DumpDOM ---------------------\n");
DumpNodeAndChildren(node, "");
dump("------------------- End DumpDOM -------------------\n");
}
// This function does the work of DumpDOM by recursively calling itself to explore the tree
function DumpNodeAndChildren(node, prefix)
{
dump(prefix + "<" + node.nodeName);
var attributes = node.attributes;
if ( attributes && attributes.length )
{
var item, name, value;
for ( var index = 0; index < attributes.length; index++ )
{
item = attributes.item(index);
name = item.nodeName;
value = item.nodeValue;
if ( (name == 'lazycontent' && value == 'true') ||
(name == 'xulcontentsgenerated' && value == 'true') ||
(name == 'id') ||
(name == 'instanceOf') )
{
// ignore these
}
else
{
dump(" " + name + "=\"" + value + "\"");
}
}
}
if ( node.nodeType == 1 )
{
// id
var text = node.getAttribute('id');
if ( text && text[0] != '$' )
dump(" id=\"" + text + "\"");
}
if ( node.nodeName == "#text" )
dump(" = \"" + node.data + "\"");
dump(">\n");
// dump IFRAME && FRAME DOM
if ( node.nodeName == "IFRAME" || node.nodeName == "FRAME" )
{
if ( node.name )
{
var wind = top.frames[node.name];
if ( wind && wind.document && wind.document.documentElement )
{
dump(prefix + "----------- " + node.nodeName + " -----------\n");
DumpNodeAndChildren(wind.document.documentElement, prefix + " ");
dump(prefix + "--------- End " + node.nodeName + " ---------\n");
}
}
}
// children of nodes (other than frames)
else if ( node.childNodes )
{
for ( var child = 0; child < node.childNodes.length; child++ )
DumpNodeAndChildren(node.childNodes[child], prefix + " ");
}
}

Просмотреть файл

@ -0,0 +1,24 @@
The buster is a XUL interface to the conformance tests shipped as part of
Xalan. For information about Xalan, please see http://xml.apache.org/.
For your convenience we provide a packed distribution of all needed files
in http://www.axel.pike.org/mozilla/xalan.tar.gz. Please see the included
LICENSE.txt or http://xml.apache.org/dist/LICENSE.txt for terms of
distributing those files.
To use the buster, open buster.xul with a XSLT enabled Mozilla. Warning,
it takes quite a while until that page is fully loaded, and due to bug
http://bugzilla.mozilla.org/show_bug.cgi?id=70324, we don't have scrolling.
You can use regular expressions to narrow the set of tests to run.
Once you have selected the tests you're interested in, press the button
"run checked tests", and all the tests will be run.
DiffDOM tries to find out, which tests failed, and will DumpDOM both the
result and the reference solution. Not all reference solutions load
properly, those need manual love.
All of the code was done sleeping, and is not intended as example of good
code. It's for debugging only!
Good luck and fun
Axel Hecht <axel@pike.org>

Просмотреть файл

@ -0,0 +1,79 @@
<?xml version="1.0"?>
<!--
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is mozilla.org.
The Initial Developer of the Original Code is Axel Hecht.
Portions created by Axel Hecht are Copyright (C) 2001 Axel Hecht.
All Rights Reserved.
Contributor(s):
Axel Hecht <axel@pike.org> (Original Author)
-->
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<?xml-stylesheet href="txTools.css" type="text/css"?>
<window id="XalanBuster"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="loaderstuff()"
align="vertical">
<script type="text/javascript" src="DiffDOM.js" />
<script type="text/javascript" src="txTools.js" />
<script type="text/javascript" src="xulTxTools.js" />
<script type="text/javascript" src="DumpDOM.js" />
<box align="horizontal">
<button value="refresh" oncommand="refresh_xalan()" />
<button value="check all" oncommand="check(true)" />
<button value="uncheck all" oncommand="check(false)" />
<button value="invert checks" oncommand="invert_check()" />
<button value="hide checked" oncommand="hide_checked(true)" />
<button value="hide unchecked" oncommand="hide_checked(false)" />
<button value="run checked tests" oncommand="dump_checked()" />
</box>
<box align="horizontal">
<text value="Xalan base directory: " class="head" />
<textfield id="xalan_base" persist="value"/>
<button value="browse..." oncommand="browse_base_dir()" />
</box>
<box align="horizontal">
<titledbox align="horizontal"><title value="search" />
<button value="Search for " oncommand="select()"/>
<textfield style="width: 10em;" id="search-name" /><text value=" in " />
<menulist id="search-field">
<menupopup>
<menuitem data="1" value="Name" />
<menuitem data="2" value="Purpose" />
<menuitem data="3" value="Comment" />
</menupopup>
</menulist>
</titledbox>
<spring flex="1" /></box>
<grid>
<columns>
<column/>
<column flex="1"/>
<column flex="1"/>
<column flex="1"/>
</columns>
<rows id="xalan_grid">
<row flex="1">
<text value=" " class="head"/>
<text value="Name" class="head"/>
<text value="Purpose" class="head"/>
<text value="Comment" class="head"/>
</row>
</rows>
</grid>
</window>

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,36 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Axel Hecht.
* Portions created by Axel Hecht are Copyright (C) 2001 Axel Hecht.
* All Rights Reserved.
*
* Contributor(s):
* Axel Hecht <axel@pike.org> (Original Author)
*/
text.head {
padding: 5px;
font-size: medium;
font-weight: bold;
}
column {
margin-left: 2px;
margin-right: 2px;
}
junkwindow {
overflow: auto;
}

Просмотреть файл

@ -0,0 +1,98 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Axel Hecht.
* Portions created by Axel Hecht are Copyright (C) 2001 Axel Hecht.
* All Rights Reserved.
*
* Contributor(s):
* Axel Hecht <axel@pike.org> (Original Author)
*/
var name_array,__docSet;
function do_transforms(new_name_array,verbose){
if (new_name_array) {
name_array=new_name_array;
dump("\n==============================\n");
dump("TransforMiiX regression buster\n");
dump("==============================\n");
}
if (name_array.length){
current=name_array.shift();
__docSet=new txDocSet(current);
setTimeout("do_transforms()",20);
}
}
function txDocSet(name,verbose){
this.mName = name;
this.mBase = document.getElementById('xalan_base').getAttribute('value');
if (verbose) this.mVerbose=verbose;
this.mSource = document.implementation.createDocument("","",null);
this.mStyle = document.implementation.createDocument("","",null);
this.mReference = document.implementation.createDocument("","",null);
this.mResult = document.implementation.createDocument("","",null);
this.mSource.addEventListener("load",this.docLoaded,false);
this.mStyle.addEventListener("load",this.styleLoaded,false);
this.mReference.addEventListener("load",this.refLoaded,false);
this.mSource.load(this.mBase+"conf/"+name+".xml");
this.mStyle.load(this.mBase+"conf/"+name+".xsl");
this.mReference.load(this.mBase+"conf-gold/"+name+".out");
}
txDocSet.prototype = {
mBase : null,
mName : null,
mSource : null,
mStyle : null,
mResult : null,
mReference : null,
mVerbose : false,
mLoaded : 0,
styleLoaded : function(e){
__docSet.stuffLoaded(1);
},
docLoaded : function(e){
__docSet.stuffLoaded(4);
},
refLoaded : function(e){
__docSet.stuffLoaded(2);
},
stuffLoaded : function(mask){
__docSet.mLoaded+=mask;
if (this.mLoaded==7){
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var txProc = new XSLTProcessor(),isGood;
dump("\nTrying "+this.mName+" ");
txProc.transformDocument(this.mSource,this.mStyle,this.mResult,null);
try{
isGood = DiffDOM(this.mResult.documentElement,this.mReference.documentElement);
} catch (e) {isGood = false;};
if (!isGood){
dump(" and failed\n\n");
this.mVerbose=true;
} else {
dump(" and succeeded\n\n");
}
if (this.mVerbose){
dump("Result:\n");
DumpDOM(this.mResult);
dump("Reference:\n");
DumpDOM(this.mReference);
}
}
}
};

Просмотреть файл

Просмотреть файл

@ -0,0 +1,169 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Axel Hecht.
* Portions created by Axel Hecht are Copyright (C) 2001 Axel Hecht.
* All Rights Reserved.
*
* Contributor(s):
* Axel Hecht <axel@pike.org> (Original Author)
*/
var pop_last=0, pop_chunk=25;
var isinited=false;
var xalan_base, xalan_xml, xalan_elems, xalan_length, content_row, target;
var pref;
function loaderstuff(eve) {
var ns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
content_row = document.createElementNS(ns,"row");
content_row.setAttribute("flex","1");
content_row.appendChild(document.createElementNS(ns,"checkbox"));
content_row.appendChild(document.createElementNS(ns,"text"));
content_row.appendChild(document.createElementNS(ns,"text"));
content_row.appendChild(document.createElementNS(ns,"text"));
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
target = document.getElementById("xalan_grid");
xalan_base = document.getElementById("xalan_base");
xalan_xml = document.implementation.createDocument("","",null);
xalan_xml.addEventListener("load", xalanIndexLoaded, false);
xalan_xml.load("complete-xalanindex.xml");
//xalan_xml.load("xalanindex.xml");
return true;
}
function xalanIndexLoaded(e) {
xalan_elems = xalan_xml.getElementsByTagName("test");
xalan_length = xalan_elems.length;
populate_xalan();
return true;
}
function refresh_xalan() {
while(target.hasChildNodes()) target.removeChild(target.lastChild);
xalan_elems = xalan_xml.getElementsByTagName("test");
xalan_length = xalan_elems.length;
populate_xalan();
return true;
}
function populate_xalan() {
var upper=pop_last+pop_chunk;
var current,test,i,j, re=/\/err\//;
for (i=pop_last;i<Math.min(upper,xalan_length);i++){
current = content_row.cloneNode(true);
test = xalan_elems.item(i);
if (!test.getAttribute("file").match(re)){
current.childNodes.item(1).setAttribute("value",
test.getAttribute("file"));
for (j=0;j<test.childNodes.length;j++){
if (test.childNodes.item(j).localName=="purpose")
current.childNodes.item(2).setAttribute("value",
test.childNodes.item(j).firstChild.nodeValue);
if (test.childNodes.item(j).localName=="comment")
current.childNodes.item(3).setAttribute("value",
test.childNodes.item(j).firstChild.nodeValue);
}
target.appendChild(current);
}
}
if (pop_last+pop_chunk<xalan_length){
pop_last+=pop_chunk;
window.status="Loaded "+Math.ceil(pop_last/xalan_length*100)+"% of xalanindex.xml";
setTimeout("populate_xalan()",10);
} else {
window.status="";
}
}
function dump_checked(){
var nds = target.childNodes;
var todo = new Array();
for (i=1;i<nds.length;i++){
node=nds.item(i).firstChild;
if(node.hasAttribute("checked"))
todo.push(node.nextSibling.getAttribute("value"));
}
do_transforms(todo);
}
function hide_checked(yes){
var checks = document.getElementsByTagName("checkbox");
for (i=0;i<checks.length;i++){
node=checks.item(i);
if (node.hasAttribute("checked")==yes)
node.parentNode.parentNode.removeChild(node.parentNode);
}
}
function select(){
var se = document.getElementById("search-name");
var searchField = document.getElementById("search-field");
searchField = searchField.getAttribute("data");
var re = new RegExp(se.value);
if (searchField<1 || searchField>3) return;
var nds = target.childNodes;
for (i=1;i<nds.length;i++){
node=nds.item(i).childNodes.item(searchField);
if (re.test(node.getAttribute("value")))
nds.item(i).firstChild.setAttribute("checked",true);
}
}
function check(yes){
var i, nds = target.childNodes;
for (i=1;i<nds.length;i++){
if (yes)
nds.item(i).firstChild.setAttribute("checked",true);
else
nds.item(i).firstChild.removeAttribute("checked");
}
}
function invert_check(){
var i, checker, nds = target.childNodes;
for (i=0;i<nds.length;i++){
checker = nds.item(i).firstChild;
if (checker.hasAttribute("checked"))
checker.removeAttribute("checked");
else
checker.setAttribute("checked",true);
}
}
function browse_base_dir(){
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
const nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(
nsIFilePicker);
fp.init(window,'Xalan Tests Base Dir',nsIFilePicker.modeGetFolder);
fp.appendFilters(nsIFilePicker.filterAll);
var res = fp.show();
if (res == nsIFilePicker.returnOK) {
var furl = fp.fileURL, fconf=fp.fileURL, fgold=fp.fileURL;
fconf.path = furl.path+'conf';
fgold.path = furl.path+'conf-gold';
if (!fconf.file.exists() || !fconf.file.isDirectory()){
alert("Xalan Tests not found!");
return;
}
if (!fgold.file.exists() || !fgold.file.isDirectory()){
alert("Xalan Tests Reference solutions not found!");
return;
}
xalan_base.setAttribute('value',fp.fileURL.path);
}
}