[webkit-changes] cvs commit: WebCore/layout-tests/fast/js/global encode-URI-test-expected.checksum encode-URI-test-expected.png encode-URI-test-expected.txt encode-URI-test.html

Maciej mjs at opensource.apple.com
Mon Aug 29 20:46:42 PDT 2005


mjs         05/08/29 20:46:42

  Modified:    .        ChangeLog
               layout-tests/fast/js date-parse-test-expected.txt
                        date-parse-test.html
                        declaration-in-block-expected.txt
                        declaration-in-block.html
                        has-own-property-expected.txt has-own-property.html
                        slash-lineterminator-parse-expected.txt
                        slash-lineterminator-parse.html
                        string-from-char-code-expected.txt
                        string-from-char-code.html
                        window-object-cross-frame-calls-expected.txt
                        window-object-cross-frame-calls.html
  Added:       layout-tests/fast/js encode-URI-test-expected.txt
                        encode-URI-test.html
  Removed:     layout-tests/fast/js date-parse-test-expected.checksum
                        date-parse-test-expected.png
                        declaration-in-block-expected.checksum
                        declaration-in-block-expected.png
                        has-own-property-expected.checksum
                        has-own-property-expected.png
                        slash-lineterminator-parse-expected.checksum
                        slash-lineterminator-parse-expected.png
                        string-from-char-code-expected.checksum
                        string-from-char-code-expected.png
                        window-object-cross-frame-calls-expected.checksum
                        window-object-cross-frame-calls-expected.png
               layout-tests/fast/js/global
                        encode-URI-test-expected.checksum
                        encode-URI-test-expected.png
                        encode-URI-test-expected.txt encode-URI-test.html
  Log:
          - make the JS tests that weren't already doing so dump as text, and remove
  	their image results.
  
          * layout-tests/fast/js/date-parse-test-expected.checksum: Removed.
          * layout-tests/fast/js/date-parse-test-expected.png: Removed.
          * layout-tests/fast/js/date-parse-test-expected.txt:
          * layout-tests/fast/js/date-parse-test.html:
          * layout-tests/fast/js/declaration-in-block-expected.checksum: Removed.
          * layout-tests/fast/js/declaration-in-block-expected.png: Removed.
          * layout-tests/fast/js/declaration-in-block-expected.txt:
          * layout-tests/fast/js/declaration-in-block.html:
          * layout-tests/fast/js/encode-URI-test-expected.txt: Added.
          * layout-tests/fast/js/encode-URI-test.html: Added.
          * layout-tests/fast/js/global/encode-URI-test-expected.checksum: Removed.
          * layout-tests/fast/js/global/encode-URI-test-expected.png: Removed.
          * layout-tests/fast/js/global/encode-URI-test-expected.txt: Removed.
          * layout-tests/fast/js/global/encode-URI-test.html: Removed.
          * layout-tests/fast/js/has-own-property-expected.checksum: Removed.
          * layout-tests/fast/js/has-own-property-expected.png: Removed.
          * layout-tests/fast/js/has-own-property-expected.txt:
          * layout-tests/fast/js/has-own-property.html:
          * layout-tests/fast/js/slash-lineterminator-parse-expected.checksum: Removed.
          * layout-tests/fast/js/slash-lineterminator-parse-expected.png: Removed.
          * layout-tests/fast/js/slash-lineterminator-parse-expected.txt:
          * layout-tests/fast/js/slash-lineterminator-parse.html:
          * layout-tests/fast/js/string-from-char-code-expected.checksum: Removed.
          * layout-tests/fast/js/string-from-char-code-expected.png: Removed.
          * layout-tests/fast/js/string-from-char-code-expected.txt:
          * layout-tests/fast/js/string-from-char-code.html:
          * layout-tests/fast/js/window-object-cross-frame-calls-expected.checksum: Removed.
          * layout-tests/fast/js/window-object-cross-frame-calls-expected.png: Removed.
          * layout-tests/fast/js/window-object-cross-frame-calls-expected.txt:
          * layout-tests/fast/js/window-object-cross-frame-calls.html:
  
  Revision  Changes    Path
  1.38      +36 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- ChangeLog	29 Aug 2005 23:39:17 -0000	1.37
  +++ ChangeLog	30 Aug 2005 03:46:36 -0000	1.38
  @@ -1,3 +1,39 @@
  +2005-08-29  Maciej Stachowiak  <mjs at apple.com>
  +
  +        - make the JS tests that weren't already doing so dump as text, and remove
  +	their image results.
  +
  +        * layout-tests/fast/js/date-parse-test-expected.checksum: Removed.
  +        * layout-tests/fast/js/date-parse-test-expected.png: Removed.
  +        * layout-tests/fast/js/date-parse-test-expected.txt:
  +        * layout-tests/fast/js/date-parse-test.html:
  +        * layout-tests/fast/js/declaration-in-block-expected.checksum: Removed.
  +        * layout-tests/fast/js/declaration-in-block-expected.png: Removed.
  +        * layout-tests/fast/js/declaration-in-block-expected.txt:
  +        * layout-tests/fast/js/declaration-in-block.html:
  +        * layout-tests/fast/js/encode-URI-test-expected.txt: Added.
  +        * layout-tests/fast/js/encode-URI-test.html: Added.
  +        * layout-tests/fast/js/global/encode-URI-test-expected.checksum: Removed.
  +        * layout-tests/fast/js/global/encode-URI-test-expected.png: Removed.
  +        * layout-tests/fast/js/global/encode-URI-test-expected.txt: Removed.
  +        * layout-tests/fast/js/global/encode-URI-test.html: Removed.
  +        * layout-tests/fast/js/has-own-property-expected.checksum: Removed.
  +        * layout-tests/fast/js/has-own-property-expected.png: Removed.
  +        * layout-tests/fast/js/has-own-property-expected.txt:
  +        * layout-tests/fast/js/has-own-property.html:
  +        * layout-tests/fast/js/slash-lineterminator-parse-expected.checksum: Removed.
  +        * layout-tests/fast/js/slash-lineterminator-parse-expected.png: Removed.
  +        * layout-tests/fast/js/slash-lineterminator-parse-expected.txt:
  +        * layout-tests/fast/js/slash-lineterminator-parse.html:
  +        * layout-tests/fast/js/string-from-char-code-expected.checksum: Removed.
  +        * layout-tests/fast/js/string-from-char-code-expected.png: Removed.
  +        * layout-tests/fast/js/string-from-char-code-expected.txt:
  +        * layout-tests/fast/js/string-from-char-code.html:
  +        * layout-tests/fast/js/window-object-cross-frame-calls-expected.checksum: Removed.
  +        * layout-tests/fast/js/window-object-cross-frame-calls-expected.png: Removed.
  +        * layout-tests/fast/js/window-object-cross-frame-calls-expected.txt:
  +        * layout-tests/fast/js/window-object-cross-frame-calls.html:
  +
   2005-08-29  John Sullivan  <sullivan at apple.com>
   
           Written by Justin Garcia
  
  
  
  1.3       +3 -8      WebCore/layout-tests/fast/js/date-parse-test-expected.txt
  
  Index: date-parse-test-expected.txt
  ===================================================================
  RCS file: /cvs/root/WebCore/layout-tests/fast/js/date-parse-test-expected.txt,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- date-parse-test-expected.txt	24 Oct 2003 21:20:30 -0000	1.2
  +++ date-parse-test-expected.txt	30 Aug 2005 03:46:37 -0000	1.3
  @@ -1,8 +1,3 @@
  -layer at (0,0) size 800x600
  -  RenderCanvas at (0,0) size 800x600
  -layer at (0,0) size 800x50
  -  RenderBlock {HTML} at (0,0) size 800x50
  -    RenderBody {BODY} at (8,16) size 784x18
  -      RenderBlock {P} at (0,0) size 784x18
  -        RenderText {TEXT} at (0,0) size 190x18
  -          text run at (0,0) width 190: "Testing complete. No failures."
  +Testing complete. No failures.
  +
  +
  
  
  
  1.5       +3 -0      WebCore/layout-tests/fast/js/date-parse-test.html
  
  Index: date-parse-test.html
  ===================================================================
  RCS file: /cvs/root/WebCore/layout-tests/fast/js/date-parse-test.html,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- date-parse-test.html	1 Jul 2005 18:45:13 -0000	1.4
  +++ date-parse-test.html	30 Aug 2005 03:46:37 -0000	1.5
  @@ -11,6 +11,9 @@
   
   <script type="text/javascript">
   
  +if (window.layoutTestController)
  +    layoutTestController.dumpAsText();
  +
   // --------
   
   // Helper functions.
  
  
  
  1.2       +1 -7      WebCore/layout-tests/fast/js/declaration-in-block-expected.txt
  
  Index: declaration-in-block-expected.txt
  ===================================================================
  RCS file: /cvs/root/WebCore/layout-tests/fast/js/declaration-in-block-expected.txt,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- declaration-in-block-expected.txt	27 Sep 2004 02:07:37 -0000	1.1
  +++ declaration-in-block-expected.txt	30 Aug 2005 03:46:37 -0000	1.2
  @@ -1,7 +1 @@
  -layer at (0,0) size 800x600
  -  RenderCanvas at (0,0) size 800x600
  -layer at (0,0) size 800x34
  -  RenderBlock {HTML} at (0,0) size 800x34
  -    RenderBody {BODY} at (8,8) size 784x18
  -      RenderText {TEXT} at (0,0) size 60x18
  -        text run at (0,0) width 60: "all is well"
  +all is well
  
  
  
  1.2       +2 -0      WebCore/layout-tests/fast/js/declaration-in-block.html
  
  Index: declaration-in-block.html
  ===================================================================
  RCS file: /cvs/root/WebCore/layout-tests/fast/js/declaration-in-block.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- declaration-in-block.html	27 Sep 2004 02:07:37 -0000	1.1
  +++ declaration-in-block.html	30 Aug 2005 03:46:37 -0000	1.2
  @@ -1,4 +1,6 @@
   <script>
  +if (window.layoutTestController)
  +    layoutTestController.dumpAsText();
   if (0) { var b; }
   var a = b;
   document.write("all is well");
  
  
  
  1.2       +10 -35    WebCore/layout-tests/fast/js/has-own-property-expected.txt
  
  Index: has-own-property-expected.txt
  ===================================================================
  RCS file: /cvs/root/WebCore/layout-tests/fast/js/has-own-property-expected.txt,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- has-own-property-expected.txt	4 Jul 2005 13:11:25 -0000	1.1
  +++ has-own-property-expected.txt	30 Aug 2005 03:46:38 -0000	1.2
  @@ -1,35 +1,10 @@
  -layer at (0,0) size 800x600
  -  RenderCanvas at (0,0) size 800x600
  -layer at (0,0) size 800x600
  -  RenderBlock {HTML} at (0,0) size 800x600
  -    RenderBody {BODY} at (8,8) size 784x576
  -      RenderBlock {P} at (0,0) size 784x18
  -        RenderText {TEXT} at (0,0) size 769x18
  -          text run at (0,0) width 769: "This test verifies the behaviour of Object.prototype.hasOwnProperty, as documented in ECMA-262 rev3 section 15.2.4.5."
  -      RenderBlock {P} at (0,34) size 784x18
  -        RenderText {TEXT} at (0,0) size 524x18
  -          text run at (0,0) width 524: "If the test passes, you should see two 'true' outputs followed by three 'false' outputs."
  -      RenderBlock {HR} at (0,68) size 784x2 [border: (1px inset #000000)]
  -      RenderBlock {P} at (0,86) size 784x0
  -      RenderBlock {OL} at (0,86) size 784x90
  -        RenderListItem {LI} at (40,0) size 744x18
  -          RenderListMarker at (0,0) size 0x14
  -          RenderText {TEXT} at (0,0) size 234x18
  -            text run at (0,0) width 234: "anObject has own property 'foo': true"
  -        RenderListItem {LI} at (40,18) size 744x18
  -          RenderListMarker at (0,0) size 0x14
  -          RenderText {TEXT} at (0,0) size 240x18
  -            text run at (0,0) width 240: "aString has own property 'length': true"
  -        RenderListItem {LI} at (40,36) size 744x18
  -          RenderListMarker at (0,0) size 0x14
  -          RenderText {TEXT} at (0,0) size 238x18
  -            text run at (0,0) width 238: "anObject has own property 'bar': false"
  -        RenderListItem {LI} at (40,54) size 744x18
  -          RenderListMarker at (0,0) size 0x14
  -          RenderText {TEXT} at (0,0) size 268x18
  -            text run at (0,0) width 268: "anObject has own property 'toString': false"
  -        RenderListItem {LI} at (40,72) size 744x18
  -          RenderListMarker at (0,0) size 0x14
  -          RenderText {TEXT} at (0,0) size 256x18
  -            text run at (0,0) width 256: "aString has own property 'toString': false"
  -      RenderBlock {P} at (0,192) size 784x0
  +This test verifies the behaviour of Object.prototype.hasOwnProperty, as documented in ECMA-262 rev3 section 15.2.4.5.
  +
  +If the test passes, you should see two 'true' outputs followed by three 'false' outputs.
  +
  +anObject has own property 'foo': true
  +aString has own property 'length': true
  +anObject has own property 'bar': false
  +anObject has own property 'toString': false
  +aString has own property 'toString': false
  +
  
  
  
  1.2       +5 -1      WebCore/layout-tests/fast/js/has-own-property.html
  
  Index: has-own-property.html
  ===================================================================
  RCS file: /cvs/root/WebCore/layout-tests/fast/js/has-own-property.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- has-own-property.html	3 Jul 2005 10:47:58 -0000	1.1
  +++ has-own-property.html	30 Aug 2005 03:46:38 -0000	1.2
  @@ -2,6 +2,10 @@
       <head>
           <title>Test of hasOwnProperty</title>
           <script type="text/javascript">
  +	    if (window.layoutTestController) {
  +	        layoutTestController.dumpAsText();
  +	    }
  +
               function print(message)
               {
                   var paragraph = document.createElement("li");
  @@ -36,4 +40,4 @@
           <hr>
           <p><ol id=console></ol></p>
       </body>
  -</html>
  \ No newline at end of file
  +</html>
  
  
  
  1.2       +1 -8      WebCore/layout-tests/fast/js/slash-lineterminator-parse-expected.txt
  
  Index: slash-lineterminator-parse-expected.txt
  ===================================================================
  RCS file: /cvs/root/WebCore/layout-tests/fast/js/slash-lineterminator-parse-expected.txt,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- slash-lineterminator-parse-expected.txt	5 Aug 2004 00:18:08 -0000	1.1
  +++ slash-lineterminator-parse-expected.txt	30 Aug 2005 03:46:39 -0000	1.2
  @@ -1,8 +1 @@
  -layer at (0,0) size 800x600
  -  RenderCanvas at (0,0) size 800x600
  -layer at (0,0) size 800x600
  -  RenderBlock {HTML} at (0,0) size 800x600
  -    RenderBody {BODY} at (8,8) size 784x584
  -      RenderText {TEXT} at (0,0) size 564x18
  -        text run at (0,0) width 564: "hellothere You should see \"hellothere\", with no space between the two words (3649789)."
  -      RenderText {TEXT} at (0,0) size 0x0
  +hellothere You should see "hellothere", with no space between the two words (3649789).
  
  
  
  1.2       +3 -0      WebCore/layout-tests/fast/js/slash-lineterminator-parse.html
  
  Index: slash-lineterminator-parse.html
  ===================================================================
  RCS file: /cvs/root/WebCore/layout-tests/fast/js/slash-lineterminator-parse.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- slash-lineterminator-parse.html	5 Aug 2004 00:18:08 -0000	1.1
  +++ slash-lineterminator-parse.html	30 Aug 2005 03:46:39 -0000	1.2
  @@ -1,6 +1,9 @@
   <html>
   <body>
   <script type="text/javascript">
  +if (window.layoutTestController)
  +    layoutTestController.dumpAsText();
  +
   mystring = 'hello\
   there';  
   document.write(mystring);
  
  
  
  1.2       +3 -11     WebCore/layout-tests/fast/js/string-from-char-code-expected.txt
  
  Index: string-from-char-code-expected.txt
  ===================================================================
  RCS file: /cvs/root/WebCore/layout-tests/fast/js/string-from-char-code-expected.txt,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- string-from-char-code-expected.txt	27 Apr 2005 00:18:14 -0000	1.1
  +++ string-from-char-code-expected.txt	30 Aug 2005 03:46:39 -0000	1.2
  @@ -1,11 +1,3 @@
  -layer at (0,0) size 800x600
  -  RenderCanvas at (0,0) size 800x600
  -layer at (0,0) size 800x600
  -  RenderBlock {HTML} at (0,0) size 800x600
  -    RenderBody {BODY} at (8,8) size 784x584
  -      RenderText {TEXT} at (0,0) size 422x18
  -        text run at (0,0) width 422: "This test should not crash and should display an X on the next line:"
  -      RenderBR {BR} at (0,0) size 0x0
  -      RenderText {TEXT} at (0,18) size 12x18
  -        text run at (0,18) width 12: "X"
  -      RenderBR {BR} at (0,0) size 0x0
  +This test should not crash and should display an X on the next line:
  +X
  +
  
  
  
  1.2       +2 -0      WebCore/layout-tests/fast/js/string-from-char-code.html
  
  Index: string-from-char-code.html
  ===================================================================
  RCS file: /cvs/root/WebCore/layout-tests/fast/js/string-from-char-code.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- string-from-char-code.html	27 Apr 2005 00:18:14 -0000	1.1
  +++ string-from-char-code.html	30 Aug 2005 03:46:39 -0000	1.2
  @@ -2,6 +2,8 @@
   <body>
   This test should not crash and should display an X on the next line:<br>
   <script>
  +if (window.layoutTestController)
  +    layoutTestController.dumpAsText();
   document.write(String.fromCharCode(88));
   document.write('<br>');
   </script>
  
  
  
  1.4       +5 -20     WebCore/layout-tests/fast/js/window-object-cross-frame-calls-expected.txt
  
  Index: window-object-cross-frame-calls-expected.txt
  ===================================================================
  RCS file: /cvs/root/WebCore/layout-tests/fast/js/window-object-cross-frame-calls-expected.txt,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- window-object-cross-frame-calls-expected.txt	18 Aug 2005 04:23:08 -0000	1.3
  +++ window-object-cross-frame-calls-expected.txt	30 Aug 2005 03:46:39 -0000	1.4
  @@ -1,20 +1,5 @@
  -layer at (0,0) size 800x600
  -  RenderCanvas at (0,0) size 800x600
  -layer at (0,0) size 800x600
  -  RenderBlock {HTML} at (0,0) size 800x600
  -    RenderBody {BODY} at (8,8) size 784x584
  -      RenderBlock {P} at (0,0) size 784x18
  -        RenderText {TEXT} at (0,0) size 566x18
  -          text run at (0,0) width 566: "The following line should say \"parent\", meaning that the proper window object was used."
  -      RenderBlock {P} at (0,34) size 784x18
  -        RenderText {TEXT} at (0,0) size 39x18
  -          text run at (0,0) width 39: "parent"
  -      RenderBlock (anonymous) at (0,68) size 784x150
  -        RenderPartObject {IFRAME} at (0,0) size 300x150
  -          layer at (0,0) size 300x150
  -            RenderCanvas at (0,0) size 300x150
  -          layer at (0,0) size 300x150
  -            RenderBlock {HTML} at (0,0) size 300x150
  -              RenderBody {BODY} at (8,8) size 284x134
  -        RenderText {TEXT} at (0,0) size 0x0
  -        RenderText {TEXT} at (0,0) size 0x0
  +The following line should say "parent", meaning that the proper window object was used.
  +
  +parent
  +
  +
  
  
  
  1.2       +3 -0      WebCore/layout-tests/fast/js/window-object-cross-frame-calls.html
  
  Index: window-object-cross-frame-calls.html
  ===================================================================
  RCS file: /cvs/root/WebCore/layout-tests/fast/js/window-object-cross-frame-calls.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- window-object-cross-frame-calls.html	9 Oct 2004 21:39:51 -0000	1.1
  +++ window-object-cross-frame-calls.html	30 Aug 2005 03:46:39 -0000	1.2
  @@ -1,6 +1,9 @@
   <html>
    <head>
     <script>
  +  if (window.layoutTestController)
  +    layoutTestController.dumpAsText();
  +
      function bar() { which = "parent"; document.getElementById("result").innerHTML = which; }
     </script>
    </head>
  
  
  
  1.1                  WebCore/layout-tests/fast/js/encode-URI-test-expected.txt
  
  Index: encode-URI-test-expected.txt
  ===================================================================
  Testing complete. No failures.
  
  
  
  
  
  1.1                  WebCore/layout-tests/fast/js/encode-URI-test.html
  
  Index: encode-URI-test.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  
  <html>
  
  <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>test of JavaScript URI encoding and decoding methods</title>
  </head>
  
  <body>
  
  <script type="text/javascript">
  
  if (window.layoutTestController)  layoutTestController.dumpAsText();
  
  // --------
  
  // Helper functions.
  
  function hexDigit(number)
  {
      if (number >= 10)
          return String.fromCharCode(number + 55);
      return number;
  }
  
  function printable(s)
  {
      if (s == "")
          return "empty string";
      var p = "";
      for (var i = 0; i < s.length; i++) {
          var c = s.charAt(i);
          var cc = s.charCodeAt(i);
          if (c == "\\") {
              p += "\\\\";
          } else if (c == "\"") {
              p += "\\\"";
          } else if (c == "\n") {
              p += "\\n";
          } else if (c == "\r") {
              p += "\\r";
          } else if (c == "\t") {
              p += "\\t";
          } else if (cc >= 20 && cc < 0x7F) {
              p += c;
          } else if (cc <= 0xFF) {
              p += "\\x" + hexDigit(cc >> 4) + hexDigit(cc & 0xF);
          } else if (cc <= 0xFFFF) {
              p += "\\u" + hexDigit((cc >> 12) & 0xF) + hexDigit((cc >> 8) & 0xF) + hexDigit((cc >> 4) & 0xF) + hexDigit(cc & 0xF);
          } else {
              p += "\\U" + hexDigit((cc >> 28) & 0xF) + hexDigit((cc >> 24) & 0xF) + hexDigit((cc >> 20) & 0xF) + hexDigit((cc >> 16) & 0xF)
                         + hexDigit((cc >> 12) & 0xF) + hexDigit((cc >> 8) & 0xF) + hexDigit((cc >> 4) & 0xF) + hexDigit(cc & 0xF);
          }
      }
      return "\"" + p + "\"";
  }
  
  function encodedCharacter(c)
  {
      // UTF-8 is what Gecko does, but not what WinIE 6 does.
      // It makes much more sense, though, to produce encodings that actually work in URLs.
      // So for JavaScriptCore, we want to match Gecko on this, WinIE on most other things.
  
      // Instead of writing a JavaScript implementation of UTF-8 escaping, just do some specific cases here.
      switch (c) {
          case    0x80: return "%C2%80";
          case   0x7FF: return "%DF%BF";
          case   0x800: return "%E0%A0%80";
          case  0x2022: return "%E2%80%A2";
          case  0xD7FF: return "%ED%9F%BF";
          case  0xD800: return "%ED%A0%80";
          case  0xE000: return "%EE%80%80";
          case  0xFFFC: return "%EF%BF%BC";
          case  0xFFFD: return "%EF%BF%BD";
      }
  
      if (c < 0 || c > 0x7F) {
          window.alert("encodedCharacter doesn't know how to escape character code " + c);
          return "?";
      }
      
      return "%" + hexDigit(c >> 4) + hexDigit(c - (c >> 4 << 4));
  }
  
  function escapedCharacter(c)
  {
      // UTF-8 is what Gecko does, but we do what Win IE does instead. We use Latin1 for
      // unicode characters less than or equal to 255, and %u encoding for everything else.
      switch (c) {
          case    0x80: return "%80";
          case   0x7FF: return "%u07FF";
          case   0x800: return "%u0800";
          case  0x2022: return "%u2022";
          case  0xD7FF: return "%uD7FF";
          case  0xD800: return "%uD800";
          case  0xE000: return "%uE000";
          case  0xFFFC: return "%uFFFC";
          case  0xFFFD: return "%uFFFD";
      }
  
      if (c < 0 || c > 0x7F) {
          window.alert("escapedCharacter doesn't know how to escape character code " + c);
          return "?";
      }
      
      return "%" + hexDigit(c >> 4) + hexDigit(c - (c >> 4 << 4));
  }
  
  function forEachCharacterCode(f, s)
  {
      for (var i = 0; i < s.length; i++) {
          f(s.charCodeAt(i));
      }
  }
  
  function call(functionName, parameter)
  {
      try {
          result = eval(functionName + "(parameter)");
      } catch (e) {
          result = "exception";
      }
      return result;
  }
  
  // --------
  
  // Build up tables with expected results.
  
  var expectedResult = new Object;
  
  function addExpectedNonEscaped(f, c)
  {
      expectedResult[f + "(" + String.fromCharCode(c) + ")"] = String.fromCharCode(c);
  }
  
  function addNoEscape(c)
  {
      addExpectedNonEscaped("escape", c);
      addExpectedNonEscaped("encodeURI", c);
      addExpectedNonEscaped("encodeURIComponent", c);
  }
  
  function addEscapeNoEscape(c)
  {
      addExpectedNonEscaped("escape", c);
  }
  
  function addURIComponentNoEscape(c)
  {
      addExpectedNonEscaped("encodeURI", c);
      addExpectedNonEscaped("encodeURIComponent", c);
  }
  
  function addURINoEscape(c)
  {
      addExpectedNonEscaped("encodeURI", c);
      expectedResult["decodeURI(" + escapedCharacter(c) + ")"] = encodedCharacter(c);
      expectedResult["decodeURI(" + escapedCharacter(c).toLowerCase() + ")"] = encodedCharacter(c).toLowerCase();
  }
  
  forEachCharacterCode(addNoEscape, "*0123456789-.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_");
  forEachCharacterCode(addEscapeNoEscape, "+/");
  forEachCharacterCode(addURINoEscape, "@#$&+,/:;=?");
  forEachCharacterCode(addURIComponentNoEscape, "!'()~");
  
  // WinIE 6's escape function does not escape @, although Gecko's does.
  expectedResult["escape(@)"] = "@";
  
  // --------
  
  // Run tests.
  
  var failureCount = 0;
  
  function test(functionName, parameter, desiredResult)
  {
      var alternateResult = expectedResult[functionName + "(" + parameter + ")"];
      if (alternateResult)
          desiredResult = alternateResult;
      var result = call(functionName, parameter);
      if (result != desiredResult) {
          var s = "called " + functionName + " on " + printable(parameter) + " and got " + printable(result) + " instead of " + printable(desiredResult);
          document.writeln("<p>" + s + "</p>");
          failureCount += 1;
      }
  }
  
  function testEscapeAndEncode(parameter, escapeExpected, encodeExpected)
  {
      test("escape", parameter, escapeExpected);
      test("encodeURI", parameter, encodeExpected);
      test("encodeURIComponent", parameter, encodeExpected);
  }
  
  function testUnescape(parameter, expected)
  {
      test("unescape", parameter, expected);
  }
  
  function testDecode(parameter, expected)
  {
      if (expected == "\uFFFE" || expected == "\uFFFF")
          expected = "\uFFFD";
  
      test("decodeURI", parameter, expected);
      test("decodeURIComponent", parameter, expected);
  }
  
  function testUnescapeAndDecode(parameter, expectedUnescape, expectedDecode)
  {
      testUnescape(parameter, expectedUnescape);
      testDecode(parameter, expectedDecode);
  }
  
  function testCharacter(c)
  {
      var s = String.fromCharCode(c);
      var escaped = escapedCharacter(c);
      var encoded = encodedCharacter(c);
  
      testEscapeAndEncode(s, escaped, encoded);
      testUnescape(escaped, s);
      testUnescape(escaped.toLowerCase(), s);
      testDecode(encoded, s);
      testDecode(encoded.toLowerCase(), s);
  }
  
  for (var c = 0; c <= 128; c++) {
      testCharacter(c);
  }
  testCharacter(0x7FF);
  testCharacter(0x800);
  testCharacter(0x2022);
  testCharacter(0xD7FF);
  testCharacter(0xE000);
  testCharacter(0xFFFC);
  testCharacter(0xFFFD);
  
  // These tests are currently turned off because it's not yet entirely clear what correct behavior
  // is for these cases. Gecko seems to reject values in the surrogate range entirely, yet turns
  // U+FFFE and U+FFFF into U+FFFD, even though Unicode documentation says to treat both the same.
  // And all the JavaScript engines seem to use UTF-16 in a way that prevents characters greater
  // than U+FFFF (outside the BMP) from working properly.
  
  //testCharacter(0xD800);
  //testCharacter(0xDBFF);
  //testCharacter(0xDC00);
  //testCharacter(0xDFFF);
  //testCharacter(0xFFFE);
  //testCharacter(0xFFFF);
  //testCharacter(0x10000);
  
  testUnescapeAndDecode("%", "%", "exception");
  testUnescapeAndDecode("%0", "%0", "exception");
  testUnescapeAndDecode("%a", "%a", "exception");
  testUnescapeAndDecode("%u", "%u", "exception");
  testUnescapeAndDecode("%xx", "%xx", "exception");
  testUnescapeAndDecode("%u004", "%u004", "exception");
  testUnescapeAndDecode("%u0041", "A", "exception");
  testUnescapeAndDecode("%uxxxx", "%uxxxx", "exception");
  
  testUnescapeAndDecode(String.fromCharCode(0x80), String.fromCharCode(0x80), String.fromCharCode(0x80));
  testUnescapeAndDecode(String.fromCharCode(0xD800), String.fromCharCode(0xD800), String.fromCharCode(0xD800));
  
  testUnescapeAndDecode("%C2%80", String.fromCharCode(0xC2) + String.fromCharCode(0x80), String.fromCharCode(0x80));
  testUnescapeAndDecode("%C2", String.fromCharCode(0xC2), "exception");
  testUnescapeAndDecode("%C2" + String.fromCharCode(0x80), String.fromCharCode(0xC2) + String.fromCharCode(0x80), "exception");
  
  // The characters below hav to be literal because String.fromCharCode will make a single character
  // and the \u syntax won't allow us to specify characters with Unicode values higher than U+FFFF.
  // For most JavaScript engines, this will turn into two characters because they use UTF-16
  // instead of Unicode; it's not clear to me at the moment if the standard asks for this UTF-16
  // behavior, forbids it, or doesn't say either way.
  testEscapeAndEncode("𐀀", "%uD800%uDC00", "%F0%90%80%80");
  testUnescapeAndDecode("%F0%90%80%80", "\xF0\x90\x80\x80", "𐀀");
  testEscapeAndEncode("𦏵", "%uD858%uDFF5", "%F0%A6%8F%B5");
  testUnescapeAndDecode("%F0%A6%8F%B5", "\xF0\xA6\x8F\xB5", "𦏵");
  testEscapeAndEncode("𯿿", "%uD87F%uDFFF", "%F0%AF%BF%BF");
  testUnescapeAndDecode("%F0%AF%BF%BF", "\xF0\xAF\xBF\xBF", "𯿿");
  
  // --------
  
  // Summarize.
  
  var failuresMessage;
  if (failureCount) {
      failuresMessage = failureCount + " tests failed.";
  } else {
      failuresMessage = "No failures.";
  }
  document.writeln("<p>Testing complete. " + failuresMessage + "</p>");
  
  // --------
  
  </script>
  
  </body>
  
  </html>
  
  
  



More information about the webkit-changes mailing list