[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/tests/test_tools/selenium/core/scripts/ -> js2html.js (source)

   1  /*
   2  
   3  This is an experiment in using the Narcissus JavaScript engine 
   4  to allow Selenium scripts to be written in plain JavaScript.
   5  
   6  The 'jsparse' function will compile each high level block into a Selenium table script.
   7  
   8  
   9  TODO: 
  10  1) Test! (More browsers, more sample scripts)
  11  2) Stepping and walking lower levels of the parse tree
  12  3) Calling Selenium commands directly from JavaScript
  13  4) Do we want comments to appear in the TestRunner?
  14  5) Fix context so variables don't have to be global
  15     For now, variables defined with "var" won't be found
  16     if used later on in a script.
  17  6) Fix formatting   
  18  */
  19  
  20  
  21  function jsparse() {
  22      var script = document.getElementById('sejs')
  23      var fname = 'javascript script';
  24      parse_result = parse(script.text, fname, 0);       
  25  
  26      var x2 = new ExecutionContext(GLOBAL_CODE);
  27      ExecutionContext.current = x2;
  28  
  29  
  30      var new_test_source = '';    
  31      var new_line        = '';
  32      
  33      for (i=0;i<parse_result.$length;i++){ 
  34          var the_start = parse_result[i].start;
  35          var the_end;
  36          if ( i == (parse_result.$length-1)) {
  37              the_end = parse_result.tokenizer.source.length;
  38          } else {
  39              the_end = parse_result[i+1].start;
  40          }
  41          
  42          var script_fragment = parse_result.tokenizer.source.slice(the_start,the_end)
  43          
  44          new_line = '<tr><td style="display:none;" class="js">getEval</td>' +
  45                     '<td style="display:none;">currentTest.doNextCommand()</td>' +
  46                     '<td style="white-space: pre;">' + script_fragment + '</td>' + 
  47                     '<td></td></tr>\n';
  48          new_test_source += new_line;
  49          //eval(script_fragment);
  50          
  51                
  52      };
  53      
  54      
  55      
  56      execute(parse_result,x2)
  57  
  58      // Create HTML Table        
  59      body = document.body      
  60      body.innerHTML += "<table class='selenium' id='se-js-table'>"+
  61                        "<tbody>" +
  62                        "<tr><td>// " + document.title + "</td></tr>" +
  63                        new_test_source +
  64                        "</tbody" +
  65                        "</table>";          
  66     
  67      //body.innerHTML = "<pre>" + parse_result + "</pre>"
  68  }
  69  
  70  


Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7