!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is TransforMiiX XSLT processor code.
16 *
17 * The Initial Developer of the Original Code is
18 * Axel Hecht.
19 * Portions created by the Initial Developer are Copyright (C) 2002
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Axel Hecht <axel@pike.org>
24 * Peter Van der Beken <peterv@propagandism.org>
25 *
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
37 *
38 * ***** END LICENSE BLOCK ***** */
39
40 var view =
41 {
onRun
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
42 onRun : function()
43 {
44 runQueue.mArray = new Array();
45 var sels = this.boxObject.view.selection,a=new Object(),b=new Object(),k;
46 var rowResource, name, path;
47 for (k=0;k<sels.getRangeCount();k++){
48 sels.getRangeAt(k,a,b);
49 for (var l=a.value;l<=b.value;l++) {
50 rowResource = this.builder.getResourceAtIndex(l);
51 itemCache.getItem(rowResource);
52 }
53 }
54 runQueue.run();
55 },
displayTest
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
56 displayTest : function()
57 {
58 var current = this.boxObject.view.selection.currentIndex;
59 var rowResource = this.builder.getResourceAtIndex(current);
60 var item = itemCache.getItem(rowResource);
61 },
browseForRDF
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
62 browseForRDF : function()
63 {
64 var fp = doCreateRDFFP('Xalan Description File',
65 nsIFilePicker.modeOpen);
66 var res = fp.show();
67
68 if (res == nsIFilePicker.returnOK) {
69 var furl = fp.fileURL;
70 this.setDataSource(fp.fileURL.spec);
71 }
72 },
dump_Good
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
73 dump_Good : function()
74 {
75 var enumi = this.mResultDS.GetSources(krTypeSucc, kGood, true);
76 var k = 0;
77 while (enumi.hasMoreElements()) {
78 k += 1;
79 dump(enumi.getNext().QueryInterface(nsIRDFResource).Value+"\n");
80 }
81 dump("found "+k+" good tests\n");
82 },
prune_ds
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
83 prune_ds : function()
84 {
85 if (this.mResultDS) {
86 this.mResultDS.QueryInterface(nsIRDFPurgeableDataSource).Sweep();
87 }
88 regressionStats.init()
89 itemCache.mArray = new Array();
90 },
setDataSource
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
91 setDataSource : function(aSpec)
92 {
93 var baseSpec;
94 if (aSpec) {
95 baseSpec = aSpec;
96 }
97 else {
98 baseSpec = document.getElementById("xalan_rdf").value;
99 }
100 if (this.mXalanDS && this.mXalanDS.URI == baseSpec) {
101 this.mXalanDS.QueryInterface(nsIRDFRemoteDataSource);
102 this.mXalanDS.Refresh(true);
103 }
104 else {
105 if (this.mXalanDS) {
106 this.database.RemoveDataSource(view.mXalanDS);
107 }
108 this.mXalanDS = kRDFSvc.GetDataSourceBlocking(baseSpec);
109 if (!this.mXalanDS) {
110 alert("Unable do load DataSource: "+baseSpec);
111 return;
112 }
113 this.database.AddDataSource(this.mXalanDS);
114 }
115 regressionStats.init();
116 if (!this.mResultDS) {
117 this.mResultDS = doCreate(kRDFInMemContractID,
118 nsIRDFDataSource);
119 this.database.AddDataSource(view.mResultDS);
120 if (!this.mResultDS) {
121 alert("Unable to create result InMemDatasource");
122 return;
123 }
124 }
125
126 this.builder.rebuild();
127 document.getElementById("xalan_rdf").value = baseSpec;
128 runItem.prototype.kXalan.init(runItem.prototype.kXalan.URLTYPE_STANDARD,
129 0, baseSpec, null, null);
130 },
loadHtml
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
131 loadHtml : function(aUrl, aListener)
132 {
133 const nsIIRequestor = Components.interfaces.nsIInterfaceRequestor;
134 const nsIWebProgress = Components.interfaces.nsIWebProgress;
135 var req = this.mIframe.webNavigation.QueryInterface(nsIIRequestor);
136 var prog = req.getInterface(nsIWebProgress);
137 prog.addProgressListener(aListener, nsIWebProgress.NOTIFY_ALL);
138 this.mIframe.webNavigation.loadURI(aUrl, 0,null,null,null);
139 },
fillItemContext
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
140 fillItemContext : function()
141 {
142 var index = view.boxObject.view.selection.currentIndex;
143 var res = view.builder.getResourceAtIndex(index);
144 var purp = view.mXalanDS.GetTarget(res, krTypePurp, true);
145 return (purp != null);
146 }
147 }
148
149 regressionStats =
150 {
observe
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
151 observe: function(aSubject, aTopic, aData)
152 {
153 if (aTopic != 'success') {
154 return;
155 }
156 var arc = (aData == "true") ? krTypeSuccCount : krTypeFailCount;
157 this.assertNewCount(aSubject, arc, 1);
158 },
init
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
159 init: function()
160 {
161 if (this.mRegressionDS) {
162 this.mRegressionDS.QueryInterface(nsIRDFPurgeableDataSource).Sweep();
163 }
164 else {
165 this.mRegressionDS =
166 doCreate(kRDFInMemContractID, nsIRDFDataSource);
167 view.database.AddDataSource(this.mRegressionDS);
168 }
169 },
getParent
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
170 getParent: function(aDS, aSource)
171 {
172 // parent chached?
173 var parent = this.mRegressionDS.GetTarget(aSource, krTypeParent, true);
174 if (!parent) {
175 var labels = view.mXalanDS.ArcLabelsIn(aSource);
176 while (labels.hasMoreElements()) {
177 var arc = labels.getNext().QueryInterface(nsIRDFResource);
178 if (arc.Value.match(this.mChildRE)) {
179 parent = view.mXalanDS.GetSource(arc, aSource, true);
180 // cache the parent
181 this.mRegressionDS.Assert(aSource, krTypeParent,
182 parent, true);
183 }
184 }
185 }
186 return parent;
187 },
assertNewCount
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
188 assertNewCount: function(aSource, aArc, aIncrement)
189 {
190 var root = kRDFSvc.GetResource('urn:root');
191 var count = 0;
192 // parent chached?
193 var parent = this.getParent(view.XalanDS, aSource);
194 while (parent && !parent.EqualsNode(root)) {
195 var countRes = view.mResultDS.GetTarget(parent, aArc, true);
196 if (countRes) {
197 count = countRes.QueryInterface(nsIRDFInt).Value;
198 }
199 var newCountRes = kRDFSvc.GetIntLiteral(count + aIncrement);
200 if (!newCountRes) {
201 return;
202 }
203
204 if (countRes) {
205 view.mResultDS.Change(parent, aArc, countRes, newCountRes);
206 }
207 else {
208 view.mResultDS.Assert(parent, aArc, newCountRes, true);
209 }
210 parent = this.getParent(view.XalanDS, parent);
211 }
212 },
213 mRegressionDS: 0,
214 mChildRE: /http:\/\/www\.w3\.org\/1999\/02\/22-rdf-syntax-ns#_/
215 }
216
rdfObserve
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
217 function rdfObserve(aSubject, aTopic, aData)
218 {
219 if (aTopic == "success") {
220 var target = (aData == "true") ? kGood : kBad;
221 view.mResultDS.Assert(aSubject, krTypeSucc, target, true);
222
223 regressionStats.observe(aSubject, aTopic, aData);
224 }
225 }
226
227 runItem.prototype.kObservers.push(rdfObserve);