js/src/tests/js1_5/Regress/regress-118849.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.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /*
michael@0 7 *
michael@0 8 * Date: 08 Jan 2002
michael@0 9 * SUMMARY: Just testing that we don't crash on this code
michael@0 10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=118849
michael@0 11 *
michael@0 12 * http://developer.netscape.com:80/docs/manuals/js/core/jsref/function.htm
michael@0 13 * The Function constructor:
michael@0 14 * Function ([arg1[, arg2[, ... argN]],] functionBody)
michael@0 15 *
michael@0 16 * Parameters
michael@0 17 * arg1, arg2, ... argN
michael@0 18 * (Optional) Names to be used by the function as formal argument names.
michael@0 19 * Each must be a string that corresponds to a valid JavaScript identifier.
michael@0 20 *
michael@0 21 * functionBody
michael@0 22 * A string containing JS statements comprising the function definition.
michael@0 23 */
michael@0 24 //-----------------------------------------------------------------------------
michael@0 25 var UBound = 0;
michael@0 26 var BUGNUMBER = 118849;
michael@0 27 var summary = 'Should not crash if we provide Function() with bad arguments'
michael@0 28 var status = '';
michael@0 29 var statusitems = [];
michael@0 30 var actual = '';
michael@0 31 var actualvalues = [];
michael@0 32 var expect= '';
michael@0 33 var expectedvalues = [];
michael@0 34 var cnFAIL_1 = 'LEGAL call to Function() caused an ERROR!!!';
michael@0 35 var cnFAIL_2 = 'ILLEGAL call to Function() FAILED to cause an error';
michael@0 36 var cnSTRING = 'ASDF';
michael@0 37 var cnNUMBER = 123;
michael@0 38
michael@0 39
michael@0 40 /***********************************************************/
michael@0 41 /**** THESE ARE LEGITMATE CALLS AND SHOULD ALL SUCCEED ***/
michael@0 42 /***********************************************************/
michael@0 43 status = inSection(1);
michael@0 44 actual = cnFAIL_1; // initialize to failure
michael@0 45 try
michael@0 46 {
michael@0 47 Function(cnSTRING);
michael@0 48 Function(cnNUMBER); // cnNUMBER is a valid functionBody
michael@0 49 Function(cnSTRING,cnSTRING);
michael@0 50 Function(cnSTRING,cnNUMBER);
michael@0 51 Function(cnSTRING,cnSTRING,cnNUMBER);
michael@0 52
michael@0 53 new Function(cnSTRING);
michael@0 54 new Function(cnNUMBER);
michael@0 55 new Function(cnSTRING,cnSTRING);
michael@0 56 new Function(cnSTRING,cnNUMBER);
michael@0 57 new Function(cnSTRING,cnSTRING,cnNUMBER);
michael@0 58
michael@0 59 actual = expect;
michael@0 60 }
michael@0 61 catch(e)
michael@0 62 {
michael@0 63 }
michael@0 64 addThis();
michael@0 65
michael@0 66
michael@0 67
michael@0 68 /**********************************************************/
michael@0 69 /*** EACH CASE THAT FOLLOWS SHOULD TRIGGER AN ERROR ***/
michael@0 70 /*** (BUT NOT A CRASH) ***/
michael@0 71 /*** NOTE WE NOW USE cnFAIL_2 INSTEAD OF cnFAIL_1 ***/
michael@0 72 /**********************************************************/
michael@0 73 status = inSection(2);
michael@0 74 actual = cnFAIL_2;
michael@0 75 try
michael@0 76 {
michael@0 77 Function(cnNUMBER,cnNUMBER); // cnNUMBER is an invalid JS identifier name
michael@0 78 }
michael@0 79 catch(e)
michael@0 80 {
michael@0 81 actual = expect;
michael@0 82 }
michael@0 83 addThis();
michael@0 84
michael@0 85
michael@0 86 status = inSection(3);
michael@0 87 actual = cnFAIL_2;
michael@0 88 try
michael@0 89 {
michael@0 90 Function(cnNUMBER,cnSTRING,cnSTRING);
michael@0 91 }
michael@0 92 catch(e)
michael@0 93 {
michael@0 94 actual = expect;
michael@0 95 }
michael@0 96 addThis();
michael@0 97
michael@0 98
michael@0 99 status = inSection(4);
michael@0 100 actual = cnFAIL_2;
michael@0 101 try
michael@0 102 {
michael@0 103 new Function(cnNUMBER,cnNUMBER);
michael@0 104 }
michael@0 105 catch(e)
michael@0 106 {
michael@0 107 actual = expect;
michael@0 108 }
michael@0 109 addThis();
michael@0 110
michael@0 111
michael@0 112 status = inSection(5);
michael@0 113 actual = cnFAIL_2;
michael@0 114 try
michael@0 115 {
michael@0 116 new Function(cnNUMBER,cnSTRING,cnSTRING);
michael@0 117 }
michael@0 118 catch(e)
michael@0 119 {
michael@0 120 actual = expect;
michael@0 121 }
michael@0 122 addThis();
michael@0 123
michael@0 124
michael@0 125
michael@0 126 //-----------------------------------------------------------------------------
michael@0 127 test();
michael@0 128 //-----------------------------------------------------------------------------
michael@0 129
michael@0 130
michael@0 131 function addThis()
michael@0 132 {
michael@0 133 statusitems[UBound] = status;
michael@0 134 actualvalues[UBound] = actual;
michael@0 135 expectedvalues[UBound] = expect;
michael@0 136 UBound++;
michael@0 137 }
michael@0 138
michael@0 139
michael@0 140 function test()
michael@0 141 {
michael@0 142 enterFunc ('test');
michael@0 143 printBugNumber(BUGNUMBER);
michael@0 144 printStatus (summary);
michael@0 145
michael@0 146 for (var i = 0; i < UBound; i++)
michael@0 147 {
michael@0 148 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
michael@0 149 }
michael@0 150
michael@0 151 exitFunc ('test');
michael@0 152 }

mercurial