1818/**
1919 Data returned from server:
2020
21+ response.testURI;
22+ response.resultsURI;
23+ response.detailsURI;
24+ response.rewriteURIs;
2125 response.clientEngineName;
26+ response.engines[];
2227 response.sections[];
2328
2429 section.anchorName;
30+ section.section;
2531 section.testCount;
26- section.needCount; // (bool) results needed from client engine
27- section.testURI;
2832 section.engines[];
2933
30- engine.title; // human readable title
31- engine.name; // string key for harness
34+ engineInfo.title; // human readable title
35+ engineInfo.name; // string key for harness
36+
37+ engine.index;
3238 engine.passCount;
3339 engine.failCount;
34- engine.detailsURI;
3540
3641**/
3742
@@ -44,6 +49,18 @@ var annotator = {
4449 mResponse : null ,
4550 mClosed : false ,
4651
52+ buildURI : function ( base , section ) {
53+ if ( section ) {
54+ if ( this . mResponse . rewriteURIs ) {
55+ return base + 'section/' + section + '/' ;
56+ }
57+ else {
58+ return base + '&sec=' + section ;
59+ }
60+ }
61+ return base ;
62+ } ,
63+
4764 removeAnnotation : function ( anchorName ) {
4865 try {
4966 var annotation = document . getElementById ( 'annotation_' + ( ( 0 < anchorName . length ) ? anchorName : 'root_' ) ) ;
@@ -84,21 +101,30 @@ var annotator = {
84101 targetElement = targetElement . parentNode ;
85102 }
86103 if ( targetElement && ( Node . ELEMENT_NODE == targetElement . nodeType ) ) {
104+ var needCount = section . testCount ;
105+ for ( index in section . engines ) {
106+ var engine = section . engines [ index ] ;
107+ if ( this . mResponse . engines [ engine . index ] . name == this . mResponse . clientEngineName ) {
108+ needCount = section . testCount - ( engine . passCount + engine . failCount ) ;
109+ break ;
110+ }
111+ }
112+
87113 var annotation = document . createElement ( 'div' ) ;
88114 annotation . setAttribute ( 'id' , 'annotation_' + ( ( 0 == section . anchorName . length ) ? 'root_' : section . anchorName ) ) ;
89115 var annotationClass = 'annotation' ;
90116 if ( first ) {
91117 annotationClass += ' first' ;
92118 }
93- if ( 0 < section . needCount ) {
119+ if ( 0 < needCount ) {
94120 annotationClass += ' need' ;
95121 }
96122 if ( this . mClosed ) {
97123 annotationClass += ' closed' ;
98124 }
99125 annotation . setAttribute ( 'class' , annotationClass ) ;
100126 annotation . setAttribute ( 'testCount' , section . testCount ) ;
101- annotation . setAttribute ( 'needCount' , section . needCount ) ;
127+ annotation . setAttribute ( 'needCount' , needCount ) ;
102128
103129 if ( first ) {
104130 var disclosure = document . createElement ( 'div' ) ;
@@ -121,28 +147,28 @@ var annotator = {
121147 heading . setAttribute ( 'class' , 'heading' ) ;
122148
123149 var testLink = document . createElement ( 'a' ) ;
124- testLink . setAttribute ( 'href' , section . testURI ) ;
150+ testLink . setAttribute ( 'href' , this . buildURI ( this . mResponse . testURI , section . section ) ) ;
125151
126152 if ( 1 == section . testCount ) {
127153 testLink . appendChild ( document . createTextNode ( '1 Test' ) ) ;
128154 }
129155 else {
130156 testLink . appendChild ( document . createTextNode ( section . testCount + ' Tests' ) ) ;
131157 }
132- if ( ( ! this . mClosed ) && ( 0 < section . needCount ) ) {
158+ if ( ( ! this . mClosed ) && ( 0 < needCount ) ) {
133159 var image = document . createElement ( 'img' ) ;
134160 image . setAttribute ( 'src' , this . NEED_TEST_ICON_URI ) ;
135161 image . setAttribute ( 'class' , 'need' ) ;
136162 testLink . appendChild ( image ) ;
137163
138- if ( 1 == section . needCount ) {
164+ if ( 1 == needCount ) {
139165 testLink . setAttribute ( 'title' , '1 test needs results from your client, please click here to run test' ) ;
140166 }
141167 else {
142- testLink . setAttribute ( 'title' , section . needCount + ' tests need results from your client, please click here to run tests' ) ;
168+ testLink . setAttribute ( 'title' , needCount + ' tests need results from your client, please click here to run tests' ) ;
143169 }
144170 var untested = document . createElement ( 'span' ) ;
145- untested . appendChild ( document . createTextNode ( ' ' + section . needCount + '\u00A0untested, please\u00A0test' ) ) ;
171+ untested . appendChild ( document . createTextNode ( ' ' + needCount + '\u00A0untested, please\u00A0test' ) ) ;
146172 testLink . appendChild ( untested ) ;
147173 }
148174 heading . appendChild ( testLink ) ;
@@ -200,23 +226,23 @@ var annotator = {
200226 if ( 0 < resultCount ) {
201227 var engineNode = document . createElement ( 'span' ) ;
202228 engineNode . setAttribute ( 'title' , toolTip ) ;
203- if ( engine . name == this . mResponse . clientEngineName ) {
229+ if ( this . mResponse . engines [ engine . index ] . name == this . mResponse . clientEngineName ) {
204230 engineClass += ' active' ;
205231 }
206- engineNode . setAttribute ( 'class' , engine . name + ' ' + engineClass ) ;
232+ engineNode . setAttribute ( 'class' , this . mResponse . engines [ engine . index ] . name + ' ' + engineClass ) ;
207233 engineNode . setAttribute ( 'passCount' , engine . passCount ) ;
208234 engineNode . setAttribute ( 'failCount' , engine . failCount ) ;
209235 engineNode . setAttribute ( 'needCount' , section . testCount - resultCount ) ;
210236
211237 if ( 0 < resultCount ) {
212238 var detailsLink = document . createElement ( 'a' ) ;
213- detailsLink . setAttribute ( 'href' , engine . detailsURI ) ;
239+ detailsLink . setAttribute ( 'href' , this . buildURI ( this . mResponse . resultsURI , section . section ) ) ;
214240
215- detailsLink . appendChild ( document . createTextNode ( engine . title ) ) ;
241+ detailsLink . appendChild ( document . createTextNode ( this . mResponse . engines [ engine . index ] . title ) ) ;
216242 engineNode . appendChild ( detailsLink ) ;
217243 }
218244 else {
219- engineNode . appendChild ( document . createTextNode ( engine . title ) ) ;
245+ engineNode . appendChild ( document . createTextNode ( this . mResponse . engines [ engine . index ] . title ) ) ;
220246 }
221247
222248 engines . appendChild ( engineNode ) ;
@@ -329,8 +355,7 @@ var annotator = {
329355 styleSheet . setAttribute ( 'href' , this . STYLESHEET_URI ) ;
330356 document . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( styleSheet )
331357
332- // var statusURI = this.QUERY_URI + '?s=' + encodeURIComponent(testSuiteName) + '&x=' + encodeURIComponent(document.URL);
333- var statusURI = this . QUERY_URI + '?s=' + encodeURIComponent ( testSuiteName ) + '&x=' + encodeURIComponent ( document . baseURI ) ;
358+ var statusURI = this . QUERY_URI + '?s=' + encodeURIComponent ( testSuiteName ) + '&x=' + encodeURIComponent ( document . URL ) ;
334359
335360 if ( window . XDomainRequest ) { // The IE way...
336361 var xdr = new XDomainRequest ( ) ;
0 commit comments