Home | History | Annotate | Download | only in harness
      1 <!--
      2 /*
      3  * Copyright (C) 2010 Apple Inc. All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  * 1. Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  * 2. Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in the
     12  *    documentation and/or other materials provided with the distribution.
     13  *
     14  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
     15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     16  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
     18  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     19  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     20  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     21  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     22  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     23  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     24  * THE POSSIBILITY OF SUCH DAMAGE.
     25  */
     26 -->
     27 
     28 <!DOCTYPE html>
     29 <html>
     30   <head>
     31   <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
     32   <title>CSS 2.1 Test Harness</title>
     33   <link rel="stylesheet" href="harness.css" type="text/css" media="screen" charset="utf-8">
     34 
     35   <script src="http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript" charset="utf-8"></script>
     36   <script src="harness.js" type="text/javascript" charset="utf-8"></script>
     37   
     38   <script type="text/javascript" charset="utf-8">
     39     var gTestSuite;
     40     function setupTests()
     41     {
     42       gTestSuite = new TestSuite();
     43     }
     44     
     45     window.addEventListener('load', setupTests, false);
     46     
     47     function skipTest()
     48     {
     49       gTestSuite.skipTest(document.getElementById('skip-reason').value);
     50     }
     51     
     52     function invalidTest()
     53     {
     54       gTestSuite.invalidTest();
     55     }
     56 
     57     function failTest()
     58     {
     59       gTestSuite.failTest();
     60     }
     61 
     62     function passTest()
     63     {
     64       gTestSuite.passTest();
     65     }
     66     
     67     function goToNextUntested()
     68     {
     69       gTestSuite.goToNextIncompleteTest();
     70     }
     71 
     72     function goToTest()
     73     {
     74       var testName = prompt('Go to test:', '');
     75       
     76       // This accepts any of the following:
     77       // at-charset-010
     78       // at-charset-010.xht
     79       // xhtml1/at-charset-010
     80       // xhtml1/at-charset-010.xht
     81       // and will choose the format if specified.
     82       if (!gTestSuite.goToTestByName(testName))
     83         alert('Failed to find test ' + testName);
     84     }
     85     
     86     function formatChanged()
     87     {
     88       var newFormat;
     89       if (document.harness.format.html4.checked)
     90         newFormat = 'html4';
     91       else
     92         newFormat = 'xhtml1';
     93       gTestSuite.formatChanged(newFormat);
     94     }
     95     
     96     function testSelected()
     97     {
     98       var list = document.getElementById('test-list')
     99       if (list.selectedIndex >= 0)
    100         gTestSuite.goToTestIndex(list.selectedIndex);
    101       else
    102         gTestSuite.clearTest();
    103     }
    104 
    105     function resultsPopupChanged(popup)
    106     {
    107       gTestSuite.resultsPopupChanged(popup.selectedIndex);
    108     }
    109     
    110     function doExport()
    111     {
    112       gTestSuite.exportResults(document.getElementById('results-popup').selectedIndex);
    113     }
    114     
    115     function printTestIframe()
    116     {
    117       var testFrame = document.getElementById('test-frame');
    118       testFrame.contentWindow.print();
    119     }
    120 
    121     var gOverlayConfirmCallback;
    122     function showOverlay(overlayConfirmCallback)
    123     {
    124       document.getElementById('overlay-data').value = '';
    125       gOverlayConfirmCallback = overlayConfirmCallback;
    126       $('#overlay').addClass('visible');
    127     }
    128 
    129     function overlayCancel()
    130     {
    131       $('#overlay').removeClass('visible');
    132     }
    133     
    134     function overlayConfirm()
    135     {
    136       var data = document.getElementById('overlay-data').value;
    137       gOverlayConfirmCallback(data);
    138       $('#overlay').removeClass('visible');
    139     }
    140     
    141     function doImport()
    142     {
    143       document.getElementById('overlay-action').innerText = 'Enter results to import (in the same format as the exported results):';
    144       showOverlay(function(data) {
    145         gTestSuite.importResults(data);
    146       });
    147     }
    148     
    149     function doClear()
    150     {
    151       document.getElementById('overlay-action').innerText = 'Enter list of tests for which to clear results (so they can be re-tested):';
    152       showOverlay(function(data) {
    153         gTestSuite.clearResults(data);
    154       });
    155     }
    156   </script>
    157 
    158 </head>
    159 <body>
    160 
    161   <div class="controls">
    162     <form name="harness" onsubmit="return false;">
    163     <select id="chapters">
    164       <option>Test category</option>
    165     </select>
    166     <div class="progress">
    167       <div><span id="test-index">1</span> of <span id="chapter-test-count">200</span> unique tests</div>
    168     </div>
    169     <div class="details">
    170       <div class="name">
    171         <div class="test-type">
    172           <input type="radio" name="format" id="html4" onchange="formatChanged()" checked><label for="html4">HTML4</label><br>
    173           <input type="radio" name="format" id="xhtml1" onchange="formatChanged()"><label for="xhtml1">XHTML1</label>
    174         </div>
    175         <button onclick="goToNextUntested()" accesskey="n"><strong>N</strong>ext Untested</button>
    176         <button onclick="goToTest()" accesskey="g">Go to Test...</button>
    177       </div>
    178     </div>
    179     
    180     <div>
    181       <select id="test-list" size="40" onchange="testSelected()"></select>
    182     </div>
    183     </form>
    184   </div>
    185   
    186   <div class="actions">
    187     <span>Skip reason:</span> <input type="text" id="skip-reason" size="50">
    188     <button onclick="skipTest()" accesskey="s"><strong>S</strong>kip</button>
    189     <div class="note">Use <i>Control-Option-letter</i> to<br> trigger buttons via the keyboard.</div>
    190     <div class="action-buttons">
    191       <button onclick="invalidTest()" accesskey="i">Invalid</button>
    192       <button onclick="failTest()" accesskey="f"><strong>F</strong>ail</button>
    193       <button onclick="passTest()" accesskey="p"><strong>P</strong>ass</button>
    194     </div>
    195   </div>
    196   <div id="test-content">
    197     <div class="info">
    198       <div class="title">Title: <span id="test-title"></span></div>
    199       <div class="url">URL: <span id="test-url"></span></div>
    200       <div class="assertion">Assertion: <span id="test-assertion"></span></div>
    201       <div class="flags">Flags: <span id="test-flags"></span>
    202         <span id="warning">This test must be run over HTTP.</span>
    203         <button id="print-button" onclick="printTestIframe()">Print Preview</button>
    204       </div>
    205     </div>
    206     
    207     <div id="test-wrapper" class="frame-wrapper">
    208       <h2>Test</h2>
    209       <iframe id="test-frame"></iframe>
    210     </div>
    211     <div id="ref-wrapper" class="frame-wrapper">
    212       <h2>Reference</h2>
    213       <iframe id="ref-frame"></iframe>
    214     </div>
    215   </div>
    216 
    217   <div class="results">
    218 
    219     <div class="output-options">
    220       <p>Show results for:</p>
    221       <select id="results-popup" onchange="resultsPopupChanged(this)">
    222       </select>
    223       <div>
    224         <button id="export-button" onclick="doExport()">Export...</button>
    225       </div>
    226 
    227       <div class="custom">
    228         <button id="import-button" onclick="doImport()">Import...</button>
    229         <button id="import-button" onclick="doClear()">Clear Results...</button>
    230       </div>
    231     </div>
    232 
    233     <div id="output"></div>
    234     <div class="summary">
    235       <table>
    236         <tr>
    237           <th></th><th>Passed</th><th>Failed</th><th>Skipped</th><th>Invalid</th><th>Tested</th><th>Total</th><th>% done</th>
    238         </tr>
    239         <tr>
    240           <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>
    241         </tr>
    242         <tr>
    243           <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>
    244         </tr>
    245       </table>
    246     </div>
    247   </div>
    248 
    249   <div id="overlay">
    250     
    251     <div class="overlay-contents">
    252       <p id="overlay-action"></p>
    253       <textarea id="overlay-data"></textarea>
    254       <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>
    255       <div class="buttons">
    256         <button onclick="overlayCancel()">Cancel</button><button onclick="overlayConfirm()">OK</button>
    257       </div>
    258     </div>
    259     
    260   </div>
    261 </body>
    262 </html>