summaryrefslogtreecommitdiffstats
path: root/Tools/CSSTestSuiteHarness/harness/harness.html
blob: 3877f497bee81efb40a8ce85523978748ca97154 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<!--
/*
 * Copyright (C) 2010 Apple Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */
-->

<!DOCTYPE html>
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  <title>CSS 2.1 Test Harness</title>
  <link rel="stylesheet" href="harness.css" type="text/css" media="screen" charset="utf-8">

  <script src="http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript" charset="utf-8"></script>
  <script src="harness.js" type="text/javascript" charset="utf-8"></script>
  
  <script type="text/javascript" charset="utf-8">
    var gTestSuite;
    function setupTests()
    {
      gTestSuite = new TestSuite();
    }
    
    window.addEventListener('load', setupTests, false);
    
    function skipTest()
    {
      gTestSuite.skipTest(document.getElementById('skip-reason').value);
    }
    
    function invalidTest()
    {
      gTestSuite.invalidTest();
    }

    function failTest()
    {
      gTestSuite.failTest();
    }

    function passTest()
    {
      gTestSuite.passTest();
    }
    
    function goToNextUntested()
    {
      gTestSuite.goToNextIncompleteTest();
    }

    function goToTest()
    {
      var testName = prompt('Go to test:', '');
      
      // This accepts any of the following:
      // at-charset-010
      // at-charset-010.xht
      // xhtml1/at-charset-010
      // xhtml1/at-charset-010.xht
      // and will choose the format if specified.
      if (!gTestSuite.goToTestByName(testName))
        alert('Failed to find test ' + testName);
    }
    
    function formatChanged()
    {
      var newFormat;
      if (document.harness.format.html4.checked)
        newFormat = 'html4';
      else
        newFormat = 'xhtml1';
      gTestSuite.formatChanged(newFormat);
    }
    
    function testSelected()
    {
      var list = document.getElementById('test-list')
      if (list.selectedIndex >= 0)
        gTestSuite.goToTestIndex(list.selectedIndex);
      else
        gTestSuite.clearTest();
    }

    function resultsPopupChanged(popup)
    {
      gTestSuite.resultsPopupChanged(popup.selectedIndex);
    }
    
    function doExport()
    {
      gTestSuite.exportResults(document.getElementById('results-popup').selectedIndex);
    }
    
    function printTestIframe()
    {
      var testFrame = document.getElementById('test-frame');
      testFrame.contentWindow.print();
    }

    var gOverlayConfirmCallback;
    function showOverlay(overlayConfirmCallback)
    {
      document.getElementById('overlay-data').value = '';
      gOverlayConfirmCallback = overlayConfirmCallback;
      $('#overlay').addClass('visible');
    }

    function overlayCancel()
    {
      $('#overlay').removeClass('visible');
    }
    
    function overlayConfirm()
    {
      var data = document.getElementById('overlay-data').value;
      gOverlayConfirmCallback(data);
      $('#overlay').removeClass('visible');
    }
    
    function doImport()
    {
      document.getElementById('overlay-action').innerText = 'Enter results to import (in the same format as the exported results):';
      showOverlay(function(data) {
        gTestSuite.importResults(data);
      });
    }
    
    function doClear()
    {
      document.getElementById('overlay-action').innerText = 'Enter list of tests for which to clear results (so they can be re-tested):';
      showOverlay(function(data) {
        gTestSuite.clearResults(data);
      });
    }
  </script>

</head>
<body>

  <div class="controls">
    <form name="harness" onsubmit="return false;">
    <select id="chapters">
      <option>Test category</option>
    </select>
    <div class="progress">
      <div><span id="test-index">1</span> of <span id="chapter-test-count">200</span> unique tests</div>
    </div>
    <div class="details">
      <div class="name">
        <div class="test-type">
          <input type="radio" name="format" id="html4" onchange="formatChanged()" checked><label for="html4">HTML4</label><br>
          <input type="radio" name="format" id="xhtml1" onchange="formatChanged()"><label for="xhtml1">XHTML1</label>
        </div>
        <button onclick="goToNextUntested()" accesskey="n"><strong>N</strong>ext Untested</button>
        <button onclick="goToTest()" accesskey="g">Go to Test...</button>
      </div>
    </div>
    
    <div>
      <select id="test-list" size="40" onchange="testSelected()"></select>
    </div>
    </form>
  </div>
  
  <div class="actions">
    <span>Skip reason:</span> <input type="text" id="skip-reason" size="50">
    <button onclick="skipTest()" accesskey="s"><strong>S</strong>kip</button>
    <div class="note">Use <i>Control-Option-letter</i> to<br> trigger buttons via the keyboard.</div>
    <div class="action-buttons">
      <button onclick="invalidTest()" accesskey="i">Invalid</button>
      <button onclick="failTest()" accesskey="f"><strong>F</strong>ail</button>
      <button onclick="passTest()" accesskey="p"><strong>P</strong>ass</button>
    </div>
  </div>
  <div id="test-content">
    <div class="info">
      <div class="title">Title: <span id="test-title"></span></div>
      <div class="url">URL: <span id="test-url"></span></div>
      <div class="assertion">Assertion: <span id="test-assertion"></span></div>
      <div class="flags">Flags: <span id="test-flags"></span>
        <span id="warning">This test must be run over HTTP.</span>
        <button id="print-button" onclick="printTestIframe()">Print Preview</button>
      </div>
    </div>
    
    <div id="test-wrapper" class="frame-wrapper">
      <h2>Test</h2>
      <iframe id="test-frame"></iframe>
    </div>
    <div id="ref-wrapper" class="frame-wrapper">
      <h2>Reference</h2>
      <iframe id="ref-frame"></iframe>
    </div>
  </div>

  <div class="results">

    <div class="output-options">
      <p>Show results for:</p>
      <select id="results-popup" onchange="resultsPopupChanged(this)">
      </select>
      <div>
        <button id="export-button" onclick="doExport()">Export...</button>
      </div>

      <div class="custom">
        <button id="import-button" onclick="doImport()">Import...</button>
        <button id="import-button" onclick="doClear()">Clear Results...</button>
      </div>
    </div>

    <div id="output"></div>
    <div class="summary">
      <table>
        <tr>
          <th></th><th>Passed</th><th>Failed</th><th>Skipped</th><th>Invalid</th><th>Tested</th><th>Total</th><th>% done</th>
        </tr>
        <tr>
          <td class="label">HTML4:</td><td id="h-passed"></td><td id="h-failed"></td><td id="h-skipped"></td><td id="h-invalid"></td><td id="h-tested"></td><td id="h-total"></td><td id="h-percent"></td>
        </tr>
        <tr>
          <td class="label">XHTML1:</td><td id="x-passed"></td><td id="x-failed"></td><td id="x-skipped"></td><td id="x-invalid"></td><td id="x-tested"></td><td id="x-total"></td><td id="x-percent"></td>
        </tr>
      </table>
    </div>
  </div>

  <div id="overlay">
    
    <div class="overlay-contents">
      <p id="overlay-action"></p>
      <textarea id="overlay-data"></textarea>
      <p class="note">Pasting many lines of text here can be very slow in Safari 5. You can quit Safari and use a <a href="http://nightly.webkit.org/" title="WebKit Nightly Builds">WebKit nightly build</a> for importing or clearing.</p>
      <div class="buttons">
        <button onclick="overlayCancel()">Cancel</button><button onclick="overlayConfirm()">OK</button>
      </div>
    </div>
    
  </div>
</body>
</html>