js/src/tests/ecma_2/RegExp/regexp-enumerate-001.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 File Name: regexp-enumerate-001.js
michael@0 9 ECMA V2 Section:
michael@0 10 Description: Regression Test.
michael@0 11
michael@0 12 If instance Native Object have properties that are enumerable,
michael@0 13 JavaScript enumerated through the properties twice. This only
michael@0 14 happened if objects had been instantiated, but their properties
michael@0 15 had not been enumerated. ie, the object inherited properties
michael@0 16 from its prototype that are enumerated.
michael@0 17
michael@0 18 In the core JavaScript, this is only a problem with RegExp
michael@0 19 objects, since the inherited properties of most core JavaScript
michael@0 20 objects are not enumerated.
michael@0 21
michael@0 22 Author: christine@netscape.com, pschwartau@netscape.com
michael@0 23 Date: 12 November 1997
michael@0 24 Modified: 14 July 2002
michael@0 25 Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155291
michael@0 26 ECMA-262 Ed.3 Sections 15.10.7.1 through 15.10.7.5
michael@0 27 RegExp properties should be DontEnum
michael@0 28 *
michael@0 29 */
michael@0 30 // onerror = err;
michael@0 31
michael@0 32 var SECTION = "regexp-enumerate-001";
michael@0 33 var VERSION = "ECMA_2";
michael@0 34 var TITLE = "Regression Test for Enumerating Properties";
michael@0 35
michael@0 36 var BUGNUMBER="339403";
michael@0 37
michael@0 38 startTest();
michael@0 39 writeHeaderToLog( SECTION + " "+ TITLE);
michael@0 40
michael@0 41 /*
michael@0 42 * This test expects RegExp instances to have four enumerated properties:
michael@0 43 * source, global, ignoreCase, and lastIndex
michael@0 44 *
michael@0 45 * 99.01.25: now they also have a multiLine instance property.
michael@0 46 *
michael@0 47 */
michael@0 48
michael@0 49
michael@0 50 var r = new RegExp();
michael@0 51
michael@0 52 var e = new Array();
michael@0 53
michael@0 54 var t = new TestRegExp();
michael@0 55
michael@0 56 for ( p in r ) { e[e.length] = { property:p, value:r[p] }; t.addProperty( p, r[p]) };
michael@0 57
michael@0 58 new TestCase( SECTION,
michael@0 59 "r = new RegExp(); e = new Array(); "+
michael@0 60 "for ( p in r ) { e[e.length] = { property:p, value:r[p] }; e.length",
michael@0 61 0,
michael@0 62 e.length );
michael@0 63
michael@0 64 test();
michael@0 65
michael@0 66 function TestRegExp() {
michael@0 67 this.addProperty = addProperty;
michael@0 68 }
michael@0 69 function addProperty(name, value) {
michael@0 70 var pass = false;
michael@0 71
michael@0 72 if ( eval("this."+name) != void 0 ) {
michael@0 73 pass = true;
michael@0 74 } else {
michael@0 75 eval( "this."+ name+" = "+ false );
michael@0 76 }
michael@0 77
michael@0 78 new TestCase( SECTION,
michael@0 79 "Property: " + name +" already enumerated?",
michael@0 80 false,
michael@0 81 pass );
michael@0 82
michael@0 83 if ( gTestcases[ gTestcases.length-1].passed == false ) {
michael@0 84 gTestcases[gTestcases.length-1].reason = "property already enumerated";
michael@0 85
michael@0 86 }
michael@0 87
michael@0 88 }

mercurial