js/src/tests/ecma_3/Statements/regress-131348.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: 10 Apr 2002
michael@0 9 * Revised: 14 July 2002
michael@0 10 *
michael@0 11 * SUMMARY: JS should NOT error on |for(i in undefined)|, |for(i in null)|
michael@0 12 *
michael@0 13 * ECMA-262 3rd Edition Final spec says such statements SHOULD error. See:
michael@0 14 *
michael@0 15 * Section 12.6.4 The for-in Statement
michael@0 16 * Section 9.9 ToObject
michael@0 17 *
michael@0 18 *
michael@0 19 * But SpiderMonkey has decided NOT to follow this; it's a bug in the spec.
michael@0 20 * See http://bugzilla.mozilla.org/show_bug.cgi?id=131348
michael@0 21 *
michael@0 22 * Update: Rhino has also decided not to follow the spec on this
michael@0 23 * See http://bugzilla.mozilla.org/show_bug.cgi?id=136893
michael@0 24 */
michael@0 25 //-----------------------------------------------------------------------------
michael@0 26 var UBound = 0;
michael@0 27 var BUGNUMBER = 131348;
michael@0 28 var summary = 'JS should not error on |for(i in undefined)|, |for(i in null)|';
michael@0 29 var TEST_PASSED = 'No error';
michael@0 30 var TEST_FAILED = 'An error was generated!!!';
michael@0 31 var status = '';
michael@0 32 var statusitems = [];
michael@0 33 var actual = '';
michael@0 34 var actualvalues = [];
michael@0 35 var expect= '';
michael@0 36 var expectedvalues = [];
michael@0 37
michael@0 38
michael@0 39
michael@0 40 status = inSection(1);
michael@0 41 expect = TEST_PASSED;
michael@0 42 actual = TEST_PASSED;
michael@0 43 try
michael@0 44 {
michael@0 45 for (var i in undefined)
michael@0 46 {
michael@0 47 print(i);
michael@0 48 }
michael@0 49 }
michael@0 50 catch(e)
michael@0 51 {
michael@0 52 actual = TEST_FAILED;
michael@0 53 }
michael@0 54 addThis();
michael@0 55
michael@0 56
michael@0 57
michael@0 58 status = inSection(2);
michael@0 59 expect = TEST_PASSED;
michael@0 60 actual = TEST_PASSED;
michael@0 61 try
michael@0 62 {
michael@0 63 for (var i in null)
michael@0 64 {
michael@0 65 print(i);
michael@0 66 }
michael@0 67 }
michael@0 68 catch(e)
michael@0 69 {
michael@0 70 actual = TEST_FAILED;
michael@0 71 }
michael@0 72 addThis();
michael@0 73
michael@0 74
michael@0 75
michael@0 76 status = inSection(3);
michael@0 77 expect = TEST_PASSED;
michael@0 78 actual = TEST_PASSED;
michael@0 79 /*
michael@0 80 * Variable names that cannot be looked up generate ReferenceErrors; however,
michael@0 81 * property names like obj.ZZZ that cannot be looked up are set to |undefined|
michael@0 82 *
michael@0 83 * Therefore, this should indirectly test | for (var i in undefined) |
michael@0 84 */
michael@0 85 try
michael@0 86 {
michael@0 87 for (var i in this.ZZZ)
michael@0 88 {
michael@0 89 print(i);
michael@0 90 }
michael@0 91 }
michael@0 92 catch(e)
michael@0 93 {
michael@0 94 actual = TEST_FAILED;
michael@0 95 }
michael@0 96 addThis();
michael@0 97
michael@0 98
michael@0 99
michael@0 100 status = inSection(4);
michael@0 101 expect = TEST_PASSED;
michael@0 102 actual = TEST_PASSED;
michael@0 103 /*
michael@0 104 * The result of an unsuccessful regexp match is the null value
michael@0 105 * Therefore, this should indirectly test | for (var i in null) |
michael@0 106 */
michael@0 107 try
michael@0 108 {
michael@0 109 for (var i in 'bbb'.match(/aaa/))
michael@0 110 {
michael@0 111 print(i);
michael@0 112 }
michael@0 113 }
michael@0 114 catch(e)
michael@0 115 {
michael@0 116 actual = TEST_FAILED;
michael@0 117 }
michael@0 118 addThis();
michael@0 119
michael@0 120
michael@0 121
michael@0 122
michael@0 123 //-----------------------------------------------------------------------------
michael@0 124 test();
michael@0 125 //-----------------------------------------------------------------------------
michael@0 126
michael@0 127
michael@0 128
michael@0 129 function addThis()
michael@0 130 {
michael@0 131 statusitems[UBound] = status;
michael@0 132 actualvalues[UBound] = actual;
michael@0 133 expectedvalues[UBound] = expect;
michael@0 134 UBound++;
michael@0 135 }
michael@0 136
michael@0 137
michael@0 138 function test()
michael@0 139 {
michael@0 140 enterFunc('test');
michael@0 141 printBugNumber(BUGNUMBER);
michael@0 142 printStatus(summary);
michael@0 143
michael@0 144 for (var i=0; i<UBound; i++)
michael@0 145 {
michael@0 146 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
michael@0 147 }
michael@0 148
michael@0 149 exitFunc ('test');
michael@0 150 }

mercurial