js/src/tests/ecma_3/Statements/regress-121744.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 // |reftest| skip -- obsolete test
michael@0 2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 /*
michael@0 8 *
michael@0 9 * Date: 30 Jan 2002
michael@0 10 * Revised: 10 Apr 2002
michael@0 11 * Revised: 14 July 2002
michael@0 12 *
michael@0 13 * SUMMARY: JS should error on |for(i in undefined)|, |for(i in null)|
michael@0 14 * See http://bugzilla.mozilla.org/show_bug.cgi?id=121744
michael@0 15 *
michael@0 16 * ECMA-262 3rd Edition Final spec says such statements should error. See:
michael@0 17 *
michael@0 18 * Section 12.6.4 The for-in Statement
michael@0 19 * Section 9.9 ToObject
michael@0 20 *
michael@0 21 *
michael@0 22 * BUT: SpiderMonkey has decided NOT to follow this; it's a bug in the spec.
michael@0 23 * See http://bugzilla.mozilla.org/show_bug.cgi?id=131348
michael@0 24 *
michael@0 25 * UPDATE: Rhino has also decided not to follow the spec on this.
michael@0 26 * See http://bugzilla.mozilla.org/show_bug.cgi?id=136893
michael@0 27 *
michael@0 28
michael@0 29 |--------------------------------------------------------------------|
michael@0 30 | |
michael@0 31 | So for now, adding an early return for this test so it won't run. |
michael@0 32 | |
michael@0 33 |--------------------------------------------------------------------|
michael@0 34
michael@0 35 *
michael@0 36 */
michael@0 37 //-----------------------------------------------------------------------------
michael@0 38 var UBound = 0;
michael@0 39 var BUGNUMBER = 121744;
michael@0 40 var summary = 'JS should error on |for(i in undefined)|, |for(i in null)|';
michael@0 41 var TEST_PASSED = 'TypeError';
michael@0 42 var TEST_FAILED = 'Generated an error, but NOT a TypeError!';
michael@0 43 var TEST_FAILED_BADLY = 'Did not generate ANY error!!!';
michael@0 44 var status = '';
michael@0 45 var statusitems = [];
michael@0 46 var actual = '';
michael@0 47 var actualvalues = [];
michael@0 48 var expect= '';
michael@0 49 var expectedvalues = [];
michael@0 50
michael@0 51 /*
michael@0 52 * AS OF 14 JULY 2002, DON'T RUN THIS TEST IN EITHER RHINO OR SPIDERMONKEY -
michael@0 53 */
michael@0 54 quit();
michael@0 55
michael@0 56
michael@0 57 status = inSection(1);
michael@0 58 expect = TEST_PASSED;
michael@0 59 actual = TEST_FAILED_BADLY;
michael@0 60 /*
michael@0 61 * OK, this should generate a TypeError
michael@0 62 */
michael@0 63 try
michael@0 64 {
michael@0 65 for (var i in undefined)
michael@0 66 {
michael@0 67 print(i);
michael@0 68 }
michael@0 69 }
michael@0 70 catch(e)
michael@0 71 {
michael@0 72 if (e instanceof TypeError)
michael@0 73 actual = TEST_PASSED;
michael@0 74 else
michael@0 75 actual = TEST_FAILED;
michael@0 76 }
michael@0 77 addThis();
michael@0 78
michael@0 79
michael@0 80
michael@0 81 status = inSection(2);
michael@0 82 expect = TEST_PASSED;
michael@0 83 actual = TEST_FAILED_BADLY;
michael@0 84 /*
michael@0 85 * OK, this should generate a TypeError
michael@0 86 */
michael@0 87 try
michael@0 88 {
michael@0 89 for (var i in null)
michael@0 90 {
michael@0 91 print(i);
michael@0 92 }
michael@0 93 }
michael@0 94 catch(e)
michael@0 95 {
michael@0 96 if (e instanceof TypeError)
michael@0 97 actual = TEST_PASSED;
michael@0 98 else
michael@0 99 actual = TEST_FAILED;
michael@0 100 }
michael@0 101 addThis();
michael@0 102
michael@0 103
michael@0 104
michael@0 105 status = inSection(3);
michael@0 106 expect = TEST_PASSED;
michael@0 107 actual = TEST_FAILED_BADLY;
michael@0 108 /*
michael@0 109 * Variable names that cannot be looked up generate ReferenceErrors; however,
michael@0 110 * property names like obj.ZZZ that cannot be looked up are set to |undefined|
michael@0 111 *
michael@0 112 * Therefore, this should indirectly test | for (var i in undefined) |
michael@0 113 */
michael@0 114 try
michael@0 115 {
michael@0 116 for (var i in this.ZZZ)
michael@0 117 {
michael@0 118 print(i);
michael@0 119 }
michael@0 120 }
michael@0 121 catch(e)
michael@0 122 {
michael@0 123 if(e instanceof TypeError)
michael@0 124 actual = TEST_PASSED;
michael@0 125 else
michael@0 126 actual = TEST_FAILED;
michael@0 127 }
michael@0 128 addThis();
michael@0 129
michael@0 130
michael@0 131
michael@0 132 status = inSection(4);
michael@0 133 expect = TEST_PASSED;
michael@0 134 actual = TEST_FAILED_BADLY;
michael@0 135 /*
michael@0 136 * The result of an unsuccessful regexp match is the null value
michael@0 137 * Therefore, this should indirectly test | for (var i in null) |
michael@0 138 */
michael@0 139 try
michael@0 140 {
michael@0 141 for (var i in 'bbb'.match(/aaa/))
michael@0 142 {
michael@0 143 print(i);
michael@0 144 }
michael@0 145 }
michael@0 146 catch(e)
michael@0 147 {
michael@0 148 if(e instanceof TypeError)
michael@0 149 actual = TEST_PASSED;
michael@0 150 else
michael@0 151 actual = TEST_FAILED;
michael@0 152 }
michael@0 153 addThis();
michael@0 154
michael@0 155
michael@0 156
michael@0 157 //-----------------------------------------------------------------------------
michael@0 158 test();
michael@0 159 //-----------------------------------------------------------------------------
michael@0 160
michael@0 161
michael@0 162
michael@0 163 function addThis()
michael@0 164 {
michael@0 165 statusitems[UBound] = status;
michael@0 166 actualvalues[UBound] = actual;
michael@0 167 expectedvalues[UBound] = expect;
michael@0 168 UBound++;
michael@0 169 }
michael@0 170
michael@0 171
michael@0 172 function test()
michael@0 173 {
michael@0 174 enterFunc('test');
michael@0 175 printBugNumber(BUGNUMBER);
michael@0 176 printStatus(summary);
michael@0 177
michael@0 178 for (var i=0; i<UBound; i++)
michael@0 179 {
michael@0 180 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
michael@0 181 }
michael@0 182
michael@0 183 exitFunc ('test');
michael@0 184 }

mercurial