js/src/tests/ecma_2/RegExp/properties-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/properties-001.js
michael@0 9 * ECMA Section: 15.7.6.js
michael@0 10 * Description: Based on ECMA 2 Draft 7 February 1999
michael@0 11 *
michael@0 12 * Author: christine@netscape.com
michael@0 13 * Date: 19 February 1999
michael@0 14 */
michael@0 15 var SECTION = "RegExp/properties-001.js";
michael@0 16 var VERSION = "ECMA_2";
michael@0 17 var TITLE = "Properties of RegExp Instances";
michael@0 18 var BUGNUMBER ="";
michael@0 19
michael@0 20 startTest();
michael@0 21
michael@0 22 AddRegExpCases( new RegExp, "", false, false, false, 0 );
michael@0 23 AddRegExpCases( /.*/, ".*", false, false, false, 0 );
michael@0 24 AddRegExpCases( /[\d]{5}/g, "[\\d]{5}", true, false, false, 0 );
michael@0 25 AddRegExpCases( /[\S]?$/i, "[\\S]?$", false, true, false, 0 );
michael@0 26 AddRegExpCases( /^([a-z]*)[^\w\s\f\n\r]+/m, "^([a-z]*)[^\\w\\s\\f\\n\\r]+", false, false, true, 0 );
michael@0 27 AddRegExpCases( /[\D]{1,5}[\ -][\d]/gi, "[\\D]{1,5}[\\ -][\\d]", true, true, false, 0 );
michael@0 28 AddRegExpCases( /[a-zA-Z0-9]*/gm, "[a-zA-Z0-9]*", true, false, true, 0 );
michael@0 29 AddRegExpCases( /x|y|z/gim, "x|y|z", true, true, true, 0 );
michael@0 30
michael@0 31 AddRegExpCases( /\u0051/im, "\\u0051", false, true, true, 0 );
michael@0 32 AddRegExpCases( /\x45/gm, "\\x45", true, false, true, 0 );
michael@0 33 AddRegExpCases( /\097/gi, "\\097", true, true, false, 0 );
michael@0 34
michael@0 35 test();
michael@0 36
michael@0 37 function AddRegExpCases( re, s, g, i, m, l ) {
michael@0 38
michael@0 39 AddTestCase( re + ".test == RegExp.prototype.test",
michael@0 40 true,
michael@0 41 re.test == RegExp.prototype.test );
michael@0 42
michael@0 43 AddTestCase( re + ".toString == RegExp.prototype.toString",
michael@0 44 true,
michael@0 45 re.toString == RegExp.prototype.toString );
michael@0 46
michael@0 47 AddTestCase( re + ".contructor == RegExp.prototype.constructor",
michael@0 48 true,
michael@0 49 re.constructor == RegExp.prototype.constructor );
michael@0 50
michael@0 51 AddTestCase( re + ".compile == RegExp.prototype.compile",
michael@0 52 true,
michael@0 53 re.compile == RegExp.prototype.compile );
michael@0 54
michael@0 55 AddTestCase( re + ".exec == RegExp.prototype.exec",
michael@0 56 true,
michael@0 57 re.exec == RegExp.prototype.exec );
michael@0 58
michael@0 59 // properties
michael@0 60
michael@0 61 AddTestCase( re + ".source",
michael@0 62 s,
michael@0 63 re.source );
michael@0 64
michael@0 65 /*
michael@0 66 * http://bugzilla.mozilla.org/show_bug.cgi?id=225550 changed
michael@0 67 * the behavior of toString() and toSource() on empty regexps.
michael@0 68 * So branch if |s| is the empty string -
michael@0 69 */
michael@0 70 var S = s? s : '(?:)';
michael@0 71
michael@0 72 AddTestCase( re + ".toString()",
michael@0 73 "/" + S +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""),
michael@0 74 re.toString() );
michael@0 75
michael@0 76 AddTestCase( re + ".global",
michael@0 77 g,
michael@0 78 re.global );
michael@0 79
michael@0 80 AddTestCase( re + ".ignoreCase",
michael@0 81 i,
michael@0 82 re.ignoreCase );
michael@0 83
michael@0 84 AddTestCase( re + ".multiline",
michael@0 85 m,
michael@0 86 re.multiline);
michael@0 87
michael@0 88 AddTestCase( re + ".lastIndex",
michael@0 89 l,
michael@0 90 re.lastIndex );
michael@0 91 }

mercurial