[webkit-changes] cvs commit: LayoutTests/fast/js cyclic-ref-toString-expected.txt cyclic-ref-toString.html

Darin darin at opensource.apple.com
Sat Dec 10 11:05:22 PST 2005


darin       05/12/10 11:05:22

  Modified:    .        ChangeLog
               kjs      array_object.cpp
               .        ChangeLog
  Added:       fast/js  cyclic-ref-toString-expected.txt
                        cyclic-ref-toString.html
  Log:
  JavaScriptCore:
  
          Reviewed by Maciej, landed by Darin.
  
          - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=3539
            Array join and toString methods do not support circular references
  
          * kjs/array_object.cpp: (ArrayProtoFuncImp::callAsFunction):
          Added set of visited objects -- don't recurse if item is already in the set.
  
  LayoutTests:
  
          New layout test for http://bugzilla.opendarwin.org/show_bug.cgi?id=3539
  
          * fast/js/cyclic-ref-toString-expected.txt: Added.
          * fast/js/cyclic-ref-toString.html: Added.
  
  Revision  Changes    Path
  1.896     +10 -0     JavaScriptCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/ChangeLog,v
  retrieving revision 1.895
  retrieving revision 1.896
  diff -u -r1.895 -r1.896
  --- ChangeLog	8 Dec 2005 18:19:26 -0000	1.895
  +++ ChangeLog	10 Dec 2005 19:05:19 -0000	1.896
  @@ -1,3 +1,13 @@
  +2005-12-10  Oliver Hunt  <ojh16 at student.canterbury.ac.nz>
  +
  +        Reviewed by Maciej, landed by Darin.
  +
  +        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=3539
  +          Array join and toString methods do not support circular references
  +
  +        * kjs/array_object.cpp: (ArrayProtoFuncImp::callAsFunction):
  +        Added set of visited objects -- don't recurse if item is already in the set.
  +
   2005-12-08  Maciej Stachowiak  <mjs at apple.com>
   
           Reviewed by John.
  
  
  
  1.55      +6 -0      JavaScriptCore/kjs/array_object.cpp
  
  Index: array_object.cpp
  ===================================================================
  RCS file: /cvs/root/JavaScriptCore/kjs/array_object.cpp,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- array_object.cpp	16 Oct 2005 00:46:21 -0000	1.54
  +++ array_object.cpp	10 Dec 2005 19:05:21 -0000	1.55
  @@ -31,6 +31,7 @@
   #include "reference_list.h"
   #include "types.h"
   #include "value.h"
  +#include "HashSet.h"
   
   #include "array_object.lut.h"
   
  @@ -446,9 +447,13 @@
   
       // fall through
     case Join: {
  +    static HashSet< ObjectImp*, PointerHash<ObjectImp*> > visitedElems;
  +    if (visitedElems.contains(thisObj))
  +      return jsString("");
       UString separator = ",";
       UString str = "";
   
  +    visitedElems.insert(thisObj);
       if (!args[0]->isUndefined())
         separator = args[0]->toString(exec);
       for (unsigned int k = 0; k < length; k++) {
  @@ -488,6 +493,7 @@
         if ( exec->hadException() )
           break;
       }
  +    visitedElems.remove(thisObj);
       result = String(str);
       break;
     }
  
  
  
  1.134     +7 -0      LayoutTests/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/LayoutTests/ChangeLog,v
  retrieving revision 1.133
  retrieving revision 1.134
  diff -u -r1.133 -r1.134
  --- ChangeLog	10 Dec 2005 18:55:55 -0000	1.133
  +++ ChangeLog	10 Dec 2005 19:05:21 -0000	1.134
  @@ -1,3 +1,10 @@
  +2005-12-10  Oliver Hunt  <ojh16 at student.canterbury.ac.nz>
  +
  +        New layout test for http://bugzilla.opendarwin.org/show_bug.cgi?id=3539
  +
  +        * fast/js/cyclic-ref-toString-expected.txt: Added.
  +        * fast/js/cyclic-ref-toString.html: Added.
  +
   2005-12-10  Darin Adler  <darin at apple.com>
   
           New layout test for http://bugzilla.opendarwin.org/show_bug.cgi?id=5784
  
  
  
  1.1                  LayoutTests/fast/js/cyclic-ref-toString-expected.txt
  
  Index: cyclic-ref-toString-expected.txt
  ===================================================================
  This will test Array.toString with circular references. If an element contains a reference to itself or one of its children (at any depth) contains a reference to it, it will be skipped. This can result in either a trailing ',' (if the self reference is at the end of the array) or ',,' if the self reference is contained at some mid point in the array.
  Array Contents	Expected Output	Actual Output
  [1, 2, self]	1,2,	1,2,
  [1, 2, [3, 4, parent]]	1,2,3,4,	1,2,3,4,
  [1, 2, [3, 4, parent], 5]	1,2,3,4,,5	1,2,3,4,,5
  
  
  
  
  1.1                  LayoutTests/fast/js/cyclic-ref-toString.html
  
  Index: cyclic-ref-toString.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  <html>
  <head>
  <title>test cyclic references and Array.toString</title>
  <script language="javascript">
  function init(){
    if (window.layoutTestController) {
        layoutTestController.dumpAsText();
    }
    var ary1=[1,2];
    ary1.push(ary1);
    document.getElementById("r0c1").firstChild.nodeValue = ary1;
    ary1=[1,2];
    var ary2=[3,4];
    ary1.push(ary2);
    ary2.push(ary1);
    document.getElementById("r1c1").firstChild.nodeValue = ary1;
    ary1.push(5);
    document.getElementById("r2c1").firstChild.nodeValue = ary1;
  }
  </script>
  </head>
  <body onload="init()">
      This will test Array.toString with circular references.  If an element contains a reference to 
      itself or one of its children (at any depth) contains a reference to it, it will be skipped.
      This can result in either a trailing ',' (if the self reference is at the end of the array) or ',,' 
      if the self reference is contained at some mid point in the array.
      <table cellpadding="2" cellspacing="2" border="1">
  		<tbody>
  			<tr>
  				<td>Array Contents</td><td>Expected Output</td><td>Actual Output</td>
  			</tr>
  			<tr>
  				<td>[1, 2, self]</td><td id="r0c0">1,2,</td><td id="r0c1">&nbsp;</td>
  			</tr>
  			<tr>
  				<td>[1, 2, [3, 4, parent]]</td><td id="r1c0">1,2,3,4,</td><td id="r1c1">&nbsp;</td>
  			</tr>
  			<tr>
  				<td>[1, 2, [3, 4, parent], 5]</td><td id="r2c0">1,2,3,4,,5</td><td id="r2c1">&nbsp;</td>
  			</tr>
  		</tbody>
  	</table>
  <div id='console'/>
  </body>
  </html>
  
  



More information about the webkit-changes mailing list