js/src/tests/ecma_2/RegExp/properties-002.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-002.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 //-----------------------------------------------------------------------------
michael@0 16 var SECTION = "RegExp/properties-002.js";
michael@0 17 var VERSION = "ECMA_2";
michael@0 18 var TITLE = "Properties of RegExp Instances";
michael@0 19 var BUGNUMBER ="124339";
michael@0 20
michael@0 21 startTest();
michael@0 22
michael@0 23 re_1 = /\cA?/g;
michael@0 24 re_1.lastIndex = Math.pow(2,31);
michael@0 25 AddRegExpCases( re_1, "\\cA?", true, false, false, Math.pow(2,31) );
michael@0 26
michael@0 27 re_2 = /\w*/i;
michael@0 28 re_2.lastIndex = Math.pow(2,32) -1;
michael@0 29 AddRegExpCases( re_2, "\\w*", false, true, false, Math.pow(2,32)-1 );
michael@0 30
michael@0 31 re_3 = /\*{0,80}/m;
michael@0 32 re_3.lastIndex = Math.pow(2,31) -1;
michael@0 33 AddRegExpCases( re_3, "\\*{0,80}", false, false, true, Math.pow(2,31) -1 );
michael@0 34
michael@0 35 re_4 = /^./gim;
michael@0 36 re_4.lastIndex = Math.pow(2,30) -1;
michael@0 37 AddRegExpCases( re_4, "^.", true, true, true, Math.pow(2,30) -1 );
michael@0 38
michael@0 39 re_5 = /\B/;
michael@0 40 re_5.lastIndex = Math.pow(2,30);
michael@0 41 AddRegExpCases( re_5, "\\B", false, false, false, Math.pow(2,30) );
michael@0 42
michael@0 43 /*
michael@0 44 * Brendan: "need to test cases Math.pow(2,32) and greater to see
michael@0 45 * whether they round-trip." Reason: thanks to the work done in
michael@0 46 * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, lastIndex
michael@0 47 * is now stored as a double instead of a uint32_t (unsigned integer).
michael@0 48 *
michael@0 49 * Note 2^32 -1 is the upper bound for uint32's, but doubles can go
michael@0 50 * all the way up to Number.MAX_VALUE. So that's why we need cases
michael@0 51 * between those two numbers.
michael@0 52 *
michael@0 53 */
michael@0 54 re_6 = /\B/;
michael@0 55 re_6.lastIndex = Math.pow(2,32);
michael@0 56 AddRegExpCases( re_6, "\\B", false, false, false, Math.pow(2,32) );
michael@0 57
michael@0 58 re_7 = /\B/;
michael@0 59 re_7.lastIndex = Math.pow(2,32) + 1;
michael@0 60 AddRegExpCases( re_7, "\\B", false, false, false, Math.pow(2,32) + 1 );
michael@0 61
michael@0 62 re_8 = /\B/;
michael@0 63 re_8.lastIndex = Math.pow(2,32) * 2;
michael@0 64 AddRegExpCases( re_8, "\\B", false, false, false, Math.pow(2,32) * 2 );
michael@0 65
michael@0 66 re_9 = /\B/;
michael@0 67 re_9.lastIndex = Math.pow(2,40);
michael@0 68 AddRegExpCases( re_9, "\\B", false, false, false, Math.pow(2,40) );
michael@0 69
michael@0 70 re_10 = /\B/;
michael@0 71 re_10.lastIndex = Number.MAX_VALUE;
michael@0 72 AddRegExpCases( re_10, "\\B", false, false, false, Number.MAX_VALUE );
michael@0 73
michael@0 74
michael@0 75
michael@0 76 //-----------------------------------------------------------------------------
michael@0 77 test();
michael@0 78 //-----------------------------------------------------------------------------
michael@0 79
michael@0 80
michael@0 81
michael@0 82 function AddRegExpCases( re, s, g, i, m, l ){
michael@0 83
michael@0 84 AddTestCase( re + ".test == RegExp.prototype.test",
michael@0 85 true,
michael@0 86 re.test == RegExp.prototype.test );
michael@0 87
michael@0 88 AddTestCase( re + ".toString == RegExp.prototype.toString",
michael@0 89 true,
michael@0 90 re.toString == RegExp.prototype.toString );
michael@0 91
michael@0 92 AddTestCase( re + ".contructor == RegExp.prototype.constructor",
michael@0 93 true,
michael@0 94 re.constructor == RegExp.prototype.constructor );
michael@0 95
michael@0 96 AddTestCase( re + ".compile == RegExp.prototype.compile",
michael@0 97 true,
michael@0 98 re.compile == RegExp.prototype.compile );
michael@0 99
michael@0 100 AddTestCase( re + ".exec == RegExp.prototype.exec",
michael@0 101 true,
michael@0 102 re.exec == RegExp.prototype.exec );
michael@0 103
michael@0 104 // properties
michael@0 105
michael@0 106 AddTestCase( re + ".source",
michael@0 107 s,
michael@0 108 re.source );
michael@0 109
michael@0 110 AddTestCase( re + ".toString()",
michael@0 111 "/" + s +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""),
michael@0 112 re.toString() );
michael@0 113
michael@0 114 AddTestCase( re + ".global",
michael@0 115 g,
michael@0 116 re.global );
michael@0 117
michael@0 118 AddTestCase( re + ".ignoreCase",
michael@0 119 i,
michael@0 120 re.ignoreCase );
michael@0 121
michael@0 122 AddTestCase( re + ".multiline",
michael@0 123 m,
michael@0 124 re.multiline);
michael@0 125
michael@0 126 AddTestCase( re + ".lastIndex",
michael@0 127 l,
michael@0 128 re.lastIndex );
michael@0 129 }

mercurial