tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

S15.10.2_A1_T1.js (3719B)


      1 // Copyright 2009 the Sputnik authors.  All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 info: XML Shallow Parsing with Regular Expressions
      6 es5id: 15.10.2_A1_T1
      7 description: "See bug http://bugzilla.mozilla.org/show_bug.cgi?id=103087"
      8 ---*/
      9 
     10 // REX/Javascript 1.0 
     11 // Robert D. Cameron "REX: XML Shallow Parsing with Regular Expressions",
     12 // Technical Report TR 1998-17, School of Computing Science, Simon Fraser 
     13 // University, November, 1998.
     14 // Copyright (c) 1998, Robert D. Cameron. 
     15 // The following code may be freely used and distributed provided that
     16 // this copyright and citation notice remains intact and that modifications
     17 // or additions are clearly identified.
     18 
     19 var TextSE = "[^<]+";
     20 var UntilHyphen = "[^-]*-";
     21 var Until2Hyphens = UntilHyphen + "([^-]" + UntilHyphen + ")*-";
     22 var CommentCE = Until2Hyphens + ">?";
     23 var UntilRSBs = "[^\\]]*\\]([^\\]]+\\])*\\]+";
     24 var CDATA_CE = UntilRSBs + "([^\\]>]" + UntilRSBs + ")*>";
     25 var S = "[ \\n\\t\\r]+";
     26 var NameStrt = "[A-Za-z_:]|[^\\x00-\\x7F]";
     27 var NameChar = "[A-Za-z0-9_:.-]|[^\\x00-\\x7F]";
     28 var Name = "(" + NameStrt + ")(" + NameChar + ")*";
     29 var QuoteSE = '"[^"]' + "*" + '"' + "|'[^']*'";
     30 var DT_IdentSE = S + Name + "(" + S + "(" + Name + "|" + QuoteSE + "))*";
     31 var MarkupDeclCE = "([^\\]\"'><]+|" + QuoteSE + ")*>";
     32 var S1 = "[\\n\\r\\t ]";
     33 var UntilQMs = "[^?]*\\?+";
     34 var PI_Tail = "\\?>|" + S1 + UntilQMs + "([^>?]" + UntilQMs + ")*>";
     35 var DT_ItemSE = "<(!(--" + Until2Hyphens + ">|[^-]" + MarkupDeclCE + ")|\\?" + Name + "(" + PI_Tail + "))|%" + Name + ";|" + S;
     36 var DocTypeCE = DT_IdentSE + "(" + S + ")?(\\[(" + DT_ItemSE + ")*\\](" + S + ")?)?>?";
     37 var DeclCE = "--(" + CommentCE + ")?|\\[CDATA\\[(" + CDATA_CE + ")?|DOCTYPE(" + DocTypeCE + ")?";
     38 var PI_CE = Name + "(" + PI_Tail + ")?";
     39 var EndTagCE = Name + "(" + S + ")?>?";
     40 var AttValSE = '"[^<"]' + "*" + '"' + "|'[^<']*'";
     41 var ElemTagCE = Name + "(" + S + Name + "(" + S + ")?=(" + S + ")?(" + AttValSE + "))*(" + S + ")?/?>?";
     42 var MarkupSPE = "<(!(" + DeclCE + ")?|\\?(" + PI_CE + ")?|/(" + EndTagCE + ")?|(" + ElemTagCE + ")?)";
     43 var XML_SPE = TextSE + "|" + MarkupSPE;
     44 
     45 ///
     46 ////
     47 /////
     48 
     49 var __patterns = [TextSE,UntilHyphen,Until2Hyphens,CommentCE,UntilRSBs,CDATA_CE,S,NameStrt, NameChar, 
     50 Name, QuoteSE, DT_IdentSE, MarkupDeclCE, S1,UntilQMs, PI_Tail, DT_ItemSE, DocTypeCE, DeclCE, 
     51 PI_CE, EndTagCE, AttValSE, ElemTagCE, MarkupSPE, XML_SPE];
     52 
     53 var __html=""+
     54 '<html xmlns="http://www.w3.org/1999/xhtml"\n' +
     55 '      xmlns:xlink="http://www.w3.org/XML/XLink/0.9">\n' +
     56 '  <head><title>Three Namespaces</title></head>\n' +
     57 '  <body>\n' +
     58 '    <h1 align="center">An Ellipse and a Rectangle</h1>\n' +
     59 '    <svg xmlns="http://www.w3.org/Graphics/SVG/SVG-19991203.dtd"\n' +
     60 '         width="12cm" height="10cm">\n' +
     61 '      <ellipse rx="110" ry="130" />\n' +
     62 '      <rect x="4cm" y="1cm" width="3cm" height="6cm" />\n' +
     63 '    </svg>\n' +
     64 '    <p xlink:type="simple" xlink:href="ellipses.html">\n' +
     65 '      More about ellipses\n' +
     66 '    </p>\n' +
     67 '    <p xlink:type="simple" xlink:href="rectangles.html">\n' +
     68 '      More about rectangles\n' +
     69 '    </p>\n' +
     70 '    <hr/>\n' +
     71 '    <p>Last Modified February 13, 2000</p>\n' +
     72 '  </body>\n' +
     73 '</html>';
     74 
     75 //////////////////////////////////////////////////////////////////////////////
     76 try {
     77    for(var index=0; index<__patterns.length; index++) {
     78        var __re = new RegExp(__patterns[index]);
     79        __re.test(__html);
     80    }
     81 } catch (e) {
     82    throw new Test262Error('#'+index+": XML Shallow Parsing with Regular Expression: "+__patterns[index]);
     83 }
     84 //
     85 //////////////////////////////////////////////////////////////////////////////
     86 
     87 // TODO: Convert to assert.throws() format.
     88 
     89 reportCompare(0, 0);