mirror of
https://github.com/rn10950/RetroZilla.git
synced 2024-11-10 18:00:15 +01:00
330 lines
13 KiB
HTML
330 lines
13 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<title></title>
|
|
<style>
|
|
.passed {background-color:lightgreen;}
|
|
.failed {background-color:red;}
|
|
|
|
td {
|
|
padding:3px;
|
|
}
|
|
</style>
|
|
<script>
|
|
var myValidator = null;
|
|
var counter;
|
|
var failCounter = 0;
|
|
var results;
|
|
var start;
|
|
var end;
|
|
var gXMLDoc;
|
|
|
|
function getValidator() {
|
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|
if (!myValidator)
|
|
myValidator = Components.classes["@mozilla.org/xmlextras/schemas/schemavalidator;1"]
|
|
.getService(Components.interfaces.nsISchemaValidator);
|
|
return myValidator;
|
|
}
|
|
|
|
function validateComplexType(aID, aType, aIsValid){
|
|
var rv = false;
|
|
|
|
if (!gXMLDoc) {
|
|
var xmlHTTP = new XMLHttpRequest();
|
|
xmlHTTP.open("GET", document.URL + "/../schema-complex-test.xml", false);
|
|
xmlHTTP.send(null);
|
|
gXMLDoc = xmlHTTP.responseXML;
|
|
}
|
|
|
|
var elm = gXMLDoc.getElementById(aID);
|
|
if (!elm) {
|
|
alert("No element found!");
|
|
} else {
|
|
//elm.removeAttribute("id");
|
|
rv = getValidator().validate(elm);
|
|
}
|
|
|
|
counter++;
|
|
results[results.length] = {type: aType, nodevalue: aID, rv: rv, isvalid: aIsValid};
|
|
}
|
|
|
|
function validateFile(aFile, aSchema, aIsValid) {
|
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|
|
|
try{
|
|
var myValidator = Components.classes["@mozilla.org/schemavalidator;1"].getService(Components.interfaces.nsISchemaValidator);
|
|
} catch(e){ alert(e) }
|
|
|
|
var schemaLoader = Components.classes["@mozilla.org/xmlextras/schemas/schemaloader;1"]
|
|
.getService(Components.interfaces.nsISchemaLoader);
|
|
try {
|
|
schema = schemaLoader.load(aSchema);
|
|
myValidator.loadSchema(schema);
|
|
} catch(e){alert(e)}
|
|
|
|
var rv = false;
|
|
|
|
var xmlHTTP = new XMLHttpRequest();
|
|
xmlHTTP.open("GET", aFile, false);
|
|
xmlHTTP.send(null);
|
|
xmlDoc = xmlHTTP.responseXML;
|
|
|
|
xmlDoc.documentElement.removeAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "schemaLocation");
|
|
rv = getValidator().validate(xmlDoc.documentElement);
|
|
|
|
counter++;
|
|
results[results.length] = {type: "file", nodevalue: "", rv: rv, isvalid: aIsValid};
|
|
}
|
|
|
|
function displayResults(){
|
|
var tbody = document.createElement("tbody");
|
|
var tr, td, textNode;
|
|
for (var run = 0; run < results.length; run++){
|
|
tr = document.createElement("tr");
|
|
|
|
td = document.createElement("td");
|
|
textNode = document.createTextNode(run + 1);
|
|
td.appendChild(textNode);
|
|
tr.appendChild(td);
|
|
|
|
td = document.createElement("td");
|
|
textNode = document.createTextNode(results[run].type);
|
|
td.appendChild(textNode);
|
|
tr.appendChild(td);
|
|
|
|
td = document.createElement("td");
|
|
textNode = document.createTextNode(results[run].nodevalue);
|
|
td.appendChild(textNode);
|
|
tr.appendChild(td);
|
|
|
|
td = document.createElement("td");
|
|
textNode = document.createTextNode(results[run].rv);
|
|
td.appendChild(textNode);
|
|
tr.appendChild(td);
|
|
|
|
td = document.createElement("td");
|
|
textNode = document.createTextNode(results[run].isvalid);
|
|
td.appendChild(textNode);
|
|
tr.appendChild(td);
|
|
|
|
td = document.createElement("td");
|
|
textNode = document.createTextNode((results[run].rv == results[run].isvalid) ? "Passed" : "Failed");
|
|
td.appendChild(textNode);
|
|
td.className = (results[run].rv == results[run].isvalid) ? "passed" : "failed";
|
|
tr.appendChild(td);
|
|
|
|
tbody.appendChild(tr);
|
|
|
|
if (results[run].rv!=results[run].isvalid)
|
|
failCounter++;
|
|
}
|
|
document.getElementById("resultTable").replaceChild(tbody, document.getElementById("results"));
|
|
}
|
|
|
|
var dp = new DOMParser();
|
|
var schema;
|
|
|
|
function test() {
|
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|
|
|
try{
|
|
myValidator = Components.classes["@mozilla.org/schemavalidator;1"].getService(Components.interfaces.nsISchemaValidator);
|
|
} catch(e){ alert(e) }
|
|
|
|
var schemaLoader = Components.classes["@mozilla.org/xmlextras/schemas/schemaloader;1"]
|
|
.getService(Components.interfaces.nsISchemaLoader);
|
|
try {
|
|
// SchemaLoader.Load() wants a URI
|
|
schema = schemaLoader.load(document.URL + "/../schema.xsd");
|
|
//alert(schema.attributeFormDefaultQualified)
|
|
myValidator.loadSchema(schema);
|
|
} catch(e){alert(e)}
|
|
|
|
//schema collection
|
|
var schemaCollection = schema.collection;
|
|
|
|
document.getElementById("results").innerHTML = "";
|
|
counter = 0;
|
|
failCounter = 0;
|
|
results = new Array();
|
|
|
|
start = new Date();
|
|
|
|
if (1) {
|
|
validateComplexType("balance-1", "balance-1", true);
|
|
validateComplexType("balance-2", "balance-2", false);
|
|
validateComplexType("balance-3", "balance-3", false);
|
|
validateComplexType("balance-4", "balance-4", false);
|
|
validateComplexType("balance-5", "balance-5", true);
|
|
|
|
validateComplexType("balance2-1", "balance2-1", true);
|
|
validateComplexType("balance2-2", "balance2-2", false);
|
|
validateComplexType("balance2-3", "balance2-3", false);
|
|
validateComplexType("balance2-4", "balance2-4", false);
|
|
|
|
validateComplexType("balance3-1", "balance3-1", true);
|
|
validateComplexType("balance3-2", "balance3-2", true);
|
|
validateComplexType("balance3-3", "balance3-3", false);
|
|
validateComplexType("balance3-4", "balance3-4", true);
|
|
validateComplexType("balance3-5", "balance3-5", false);
|
|
|
|
validateComplexType("balance4-1", "balance4-1", true);
|
|
validateComplexType("balance4-2", "balance4-2", true);
|
|
validateComplexType("balance4-3", "balance4-3", false);
|
|
validateComplexType("balance4-4", "balance4-4", false);
|
|
|
|
validateComplexType("balance5-1", "balance5-1", true);
|
|
validateComplexType("balance5-2", "balance5-2", false);
|
|
validateComplexType("balance5-3", "balance5-3", true);
|
|
validateComplexType("balance5-4", "balance5-4", true);
|
|
validateComplexType("balance5-5", "balance5-5", false);
|
|
validateComplexType("balance5-6", "balance5-6", false);
|
|
|
|
validateComplexType("balance6-1", "balance6-1", true);
|
|
validateComplexType("balance6-2", "balance6-2", true);
|
|
validateComplexType("balance6-3", "balance6-3", true);
|
|
validateComplexType("balance6-4", "balance6-4", true);
|
|
validateComplexType("balance6-5", "balance6-5", false);
|
|
validateComplexType("balance6-6", "balance6-6", true);
|
|
validateComplexType("balance6-7", "balance6-7", true);
|
|
validateComplexType("balance6-8", "balance6-8", true);
|
|
validateComplexType("balance6-9", "balance6-9", false);
|
|
|
|
validateComplexType("balance7-1", "balance7-1", false);
|
|
validateComplexType("balance7-2", "balance7-2", true);
|
|
validateComplexType("balance7-3", "balance7-3", false);
|
|
validateComplexType("balance7-4", "balance7-4", true);
|
|
validateComplexType("balance7-5", "balance7-5", false);
|
|
validateComplexType("balance7-6", "balance7-6", true);
|
|
validateComplexType("balance7-7", "balance7-7", true);
|
|
validateComplexType("balance7-8", "balance7-8", true);
|
|
validateComplexType("balance7-9", "balance7-9", false);
|
|
validateComplexType("balance7-10", "balance7-10", false);
|
|
validateComplexType("balance7-11", "balance7-11", false);
|
|
|
|
validateComplexType("balance8-1", "balance8-1", true);
|
|
validateComplexType("balance8-2", "balance8-2", true);
|
|
validateComplexType("balance8-3", "balance8-3", false);
|
|
validateComplexType("balance8-4", "balance8-4", true);
|
|
validateComplexType("balance8-5", "balance8-5", true);
|
|
validateComplexType("balance8-6", "balance8-6", false);
|
|
validateComplexType("balance8-7", "balance8-7", false);
|
|
|
|
validateComplexType("balance9-1", "balance9-1", true);
|
|
validateComplexType("balance9-2", "balance9-2", false);
|
|
validateComplexType("balance9-3", "balance9-3", false);
|
|
validateComplexType("balance9-4", "balance9-4", true);
|
|
validateComplexType("balance9-5", "balance9-5", false);
|
|
validateComplexType("balance9-6", "balance9-6", false);
|
|
|
|
validateComplexType("balance10-1", "balance10-1", false);
|
|
validateComplexType("balance10-2", "balance10-2", false);
|
|
validateComplexType("balance10-3", "balance10-3", false);
|
|
|
|
validateComplexType("balance11-1", "balance11-1", true);
|
|
validateComplexType("balance11-2", "balance11-2", false);
|
|
|
|
validateComplexType("balance12-1", "balance12-1", true);
|
|
validateComplexType("balance12-2", "balance12-2", true);
|
|
validateComplexType("balance12-3", "balance12-3", false);
|
|
validateComplexType("balance12-4", "balance12-4", false);
|
|
validateComplexType("balance12-5", "balance12-5", false);
|
|
|
|
validateComplexType("t1", "t1", true);
|
|
validateComplexType("t2", "t2", false);
|
|
validateComplexType("t3", "t3", true);
|
|
validateComplexType("t4", "t4", false);
|
|
validateComplexType("t5", "t5", false);
|
|
validateComplexType("t6", "t6", true);
|
|
validateComplexType("t7", "t7", false);
|
|
validateComplexType("t8", "t8", false);
|
|
validateComplexType("t9", "t9", false);
|
|
validateComplexType("t10", "t10", false);
|
|
validateComplexType("t11", "t11", true);
|
|
validateComplexType("t12", "t12", true);
|
|
validateComplexType("t13", "t13", false);
|
|
|
|
validateComplexType("author-1", "author-1", true);
|
|
validateComplexType("author-2", "author-2", false);
|
|
validateComplexType("author-3", "author-3", false);
|
|
validateComplexType("author-4", "author-4", false);
|
|
validateComplexType("author-5", "author-5", true);
|
|
validateComplexType("author-6", "author-6", false);
|
|
validateComplexType("author-7", "author-7", false);
|
|
validateComplexType("author-8", "author-8", false);
|
|
|
|
validateComplexType("author-2-1", "author-2-1", true);
|
|
validateComplexType("author-2-2", "author-2-2", false);
|
|
validateComplexType("author-2-3", "author-2-3", false);
|
|
|
|
validateComplexType("author-3-1", "author-3-1", true);
|
|
validateComplexType("author-3-2", "author-3-2", true);
|
|
|
|
validateComplexType("author-4-1", "author-4-1", true);
|
|
|
|
validateComplexType("balance-attrgroup-1-1", "balance-attrgroup-1-1", true);
|
|
validateComplexType("balance-attrgroup-1-2", "balance-attrgroup-1-2", true);
|
|
validateComplexType("balance-attrgroup-1-3", "balance-attrgroup-1-3", false);
|
|
validateComplexType("balance-attrgroup-1-4", "balance-attrgroup-1-4", false);
|
|
|
|
validateComplexType("group-1", "group-1", true);
|
|
validateComplexType("group-2", "group-2", true);
|
|
validateComplexType("group-3", "group-3", false);
|
|
validateComplexType("group-4", "group-4", false);
|
|
|
|
validateComplexType("deriv-ext-1-1", "deriv-ext-1-1", true);
|
|
validateComplexType("deriv-ext-1-2", "deriv-ext-1-2", false);
|
|
validateComplexType("deriv-ext-1-3", "deriv-ext-1-3", false);
|
|
|
|
validateComplexType("deriv-res-1-1", "deriv-res-1-1", true);
|
|
validateComplexType("deriv-res-1-2", "deriv-res-1-2", false);
|
|
|
|
validateComplexType("deriv-res-2-1", "deriv-res-2-1", true);
|
|
validateComplexType("deriv-res-2-2", "deriv-res-2-2", false);
|
|
|
|
validateComplexType("deriv-ext-complex-1-1", "deriv-ext-complex-1-1", true);
|
|
validateComplexType("deriv-ext-complex-1-2", "deriv-ext-complex-1-2", false);
|
|
|
|
validateComplexType("deriv-ext-restriction-1-1", "deriv-ext-restriction-1-1", true);
|
|
validateComplexType("deriv-ext-restriction-1-2", "deriv-ext-restriction-1-2", false);
|
|
validateComplexType("deriv-ext-restriction-1-3", "deriv-ext-restriction-1-3", true);
|
|
|
|
validateComplexType("empty-complex-1-1", "empty-complex-1-1", true);
|
|
validateComplexType("empty-complex-1-2", "empty-complex-1-2", true);
|
|
validateComplexType("empty-complex-1-3", "empty-complex-1-3", false);
|
|
validateComplexType("empty-complex-1-4", "empty-complex-1-4", false);
|
|
|
|
validateComplexType("empty-complex-2-1", "empty-complex-2-1", true);
|
|
validateComplexType("empty-complex-2-2", "empty-complex-2-2", true);
|
|
}
|
|
|
|
end = new Date();
|
|
|
|
// final result
|
|
displayResults();
|
|
document.getElementById("finalResults").innerHTML = counter + " Tests Completed, with " + failCounter + " Failures" +
|
|
". Seconds: " + ((end-start) / 1000);
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
|
|
<button onclick="test()">Do</button>
|
|
|
|
<div id="finalResults"></div>
|
|
|
|
<table border=1 cellpadding=0 cellspacing=0 width="100%" id="resultTable" style="font-size:0.8em;">
|
|
<thead>
|
|
<td>#</td>
|
|
<td>Type</td>
|
|
<td>Value</td>
|
|
<td>Is Valid?</td>
|
|
<td>Should be Valid?</td>
|
|
<td>Result</td>
|
|
</thead>
|
|
<tbody id="results" />
|
|
</table>
|
|
</body>
|
|
</html>
|