js/src/tests/js1_5/extensions/regress-96284-002.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 /*
     7  * Date: 03 September 2001
     8  *
     9  * SUMMARY: Double quotes should be escaped in uneval(new Error('""'))
    10  * See http://bugzilla.mozilla.org/show_bug.cgi?id=96284
    11  *
    12  * The real point here is this: we should be able to reconstruct an object
    13  * obj from uneval(obj). We'll test this on various types of objects.
    14  *
    15  * Method: define obj2 = eval(uneval(obj1)) and verify that
    16  * obj2.toSource() == obj1.toSource().
    17  */
    18 //-----------------------------------------------------------------------------
    19 var UBound = 0;
    20 var BUGNUMBER = 96284;
    21 var summary = 'Double quotes should be escaped in Error.prototype.toSource()';
    22 var status = '';
    23 var statusitems = [];
    24 var actual = '';
    25 var actualvalues = [];
    26 var expect= '';
    27 var expectedvalues = [];
    28 var obj1 = {};
    29 var obj2 = {};
    30 var cnTestString = '"This is a \" STUPID \" test string!!!"\\';
    33 // various NativeError objects -
    34 status = inSection(1);
    35 obj1 = Error(cnTestString);
    36 obj2 = eval(uneval(obj1));
    37 actual = obj2.toSource();
    38 expect = obj1.toSource();
    39 addThis();
    41 status = inSection(2);
    42 obj1 = EvalError(cnTestString);
    43 obj2 = eval(uneval(obj1));
    44 actual = obj2.toSource();
    45 expect = obj1.toSource();
    46 addThis();
    48 status = inSection(3);
    49 obj1 = RangeError(cnTestString);
    50 obj2 = eval(uneval(obj1));
    51 actual = obj2.toSource();
    52 expect = obj1.toSource();
    53 addThis();
    55 status = inSection(4);
    56 obj1 = ReferenceError(cnTestString);
    57 obj2 = eval(uneval(obj1));
    58 actual = obj2.toSource();
    59 expect = obj1.toSource();
    60 addThis();
    62 status = inSection(5);
    63 obj1 = SyntaxError(cnTestString);
    64 obj2 = eval(uneval(obj1));
    65 actual = obj2.toSource();
    66 expect = obj1.toSource();
    67 addThis();
    69 status = inSection(6);
    70 obj1 = TypeError(cnTestString);
    71 obj2 = eval(uneval(obj1));
    72 actual = obj2.toSource();
    73 expect = obj1.toSource();
    74 addThis();
    76 status = inSection(7);
    77 obj1 = URIError(cnTestString);
    78 obj2 = eval(uneval(obj1));
    79 actual = obj2.toSource();
    80 expect = obj1.toSource();
    81 addThis();
    84 // other types of objects -
    85 status = inSection(8);
    86 obj1 = new String(cnTestString);
    87 obj2 = eval(uneval(obj1));
    88 actual = obj2.toSource();
    89 expect = obj1.toSource();
    90 addThis();
    92 status = inSection(9);
    93 obj1 = {color:'red', texture:cnTestString, hasOwnProperty:42};
    94 obj2 = eval(uneval(obj1));
    95 actual = obj2.toSource();
    96 expect = obj1.toSource();
    97 addThis();
    99 status = inSection(10);
   100 obj1 = function(x) {function g(y){return y+1;} return g(x);};
   101 obj2 = eval(uneval(obj1));
   102 actual = obj2.toSource();
   103 expect = obj1.toSource();
   104 addThis();
   106 status = inSection(11);
   107 obj1 = new Number(eval('6'));
   108 obj2 = eval(uneval(obj1));
   109 actual = obj2.toSource();
   110 expect = obj1.toSource();
   111 addThis();
   113 status = inSection(12);
   114 obj1 = /ad;(lf)kj(2309\/\/)\/\//;
   115 obj2 = eval(uneval(obj1));
   116 actual = obj2.toSource();
   117 expect = obj1.toSource();
   118 addThis();
   122 //-----------------------------------------------------------------------------
   123 test();
   124 //-----------------------------------------------------------------------------
   127 function addThis()
   128 {
   129   statusitems[UBound] = status;
   130   actualvalues[UBound] = actual;
   131   expectedvalues[UBound] = expect;
   132   UBound++;
   133 }
   136 function test()
   137 {
   138   enterFunc ('test');
   139   printBugNumber(BUGNUMBER);
   140   printStatus (summary);
   142   for (var i = 0; i < UBound; i++)
   143   {
   144     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
   145   }
   147   exitFunc ('test');
   148 }

mercurial