Sat, 03 Jan 2015 20:18:00 +0100
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: String/split-001.js |
michael@0 | 9 | * ECMA Section: 15.6.4.9 |
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 | /* |
michael@0 | 17 | * Since regular expressions have been part of JavaScript since 1.2, there |
michael@0 | 18 | * are already tests for regular expressions in the js1_2/regexp folder. |
michael@0 | 19 | * |
michael@0 | 20 | * These new tests try to supplement the existing tests, and verify that |
michael@0 | 21 | * our implementation of RegExp conforms to the ECMA specification, but |
michael@0 | 22 | * does not try to be as exhaustive as in previous tests. |
michael@0 | 23 | * |
michael@0 | 24 | * The [,limit] argument to String.split is new, and not covered in any |
michael@0 | 25 | * existing tests. |
michael@0 | 26 | * |
michael@0 | 27 | * String.split cases are covered in ecma/String/15.5.4.8-*.js. |
michael@0 | 28 | * String.split where separator is a RegExp are in |
michael@0 | 29 | * js1_2/regexp/string_split.js |
michael@0 | 30 | * |
michael@0 | 31 | */ |
michael@0 | 32 | |
michael@0 | 33 | var SECTION = "ecma_2/String/split-001.js"; |
michael@0 | 34 | var VERSION = "ECMA_2"; |
michael@0 | 35 | var TITLE = "String.prototype.split( regexp, [,limit] )"; |
michael@0 | 36 | |
michael@0 | 37 | startTest(); |
michael@0 | 38 | |
michael@0 | 39 | // the separator is not supplied |
michael@0 | 40 | // separator is undefined |
michael@0 | 41 | // separator is an empty string |
michael@0 | 42 | |
michael@0 | 43 | AddSplitCases( "splitme", "", "''", ["s", "p", "l", "i", "t", "m", "e"] ); |
michael@0 | 44 | AddSplitCases( "splitme", new RegExp(), "new RegExp()", ["s", "p", "l", "i", "t", "m", "e"] ); |
michael@0 | 45 | |
michael@0 | 46 | // separartor is a regexp |
michael@0 | 47 | // separator regexp value global setting is set |
michael@0 | 48 | // string is an empty string |
michael@0 | 49 | // if separator is an empty string, split each by character |
michael@0 | 50 | |
michael@0 | 51 | // this is not a String object |
michael@0 | 52 | |
michael@0 | 53 | // limit is not a number |
michael@0 | 54 | // limit is undefined |
michael@0 | 55 | // limit is larger than 2^32-1 |
michael@0 | 56 | // limit is a negative number |
michael@0 | 57 | |
michael@0 | 58 | test(); |
michael@0 | 59 | |
michael@0 | 60 | function AddSplitCases( string, separator, str_sep, split_array ) { |
michael@0 | 61 | |
michael@0 | 62 | // verify that the result of split is an object of type Array |
michael@0 | 63 | AddTestCase( |
michael@0 | 64 | "( " + string + " ).split(" + str_sep +").constructor == Array", |
michael@0 | 65 | true, |
michael@0 | 66 | string.split(separator).constructor == Array ); |
michael@0 | 67 | |
michael@0 | 68 | // check the number of items in the array |
michael@0 | 69 | AddTestCase( |
michael@0 | 70 | "( " + string + " ).split(" + str_sep +").length", |
michael@0 | 71 | split_array.length, |
michael@0 | 72 | string.split(separator).length ); |
michael@0 | 73 | |
michael@0 | 74 | // check the value of each array item |
michael@0 | 75 | var limit = (split_array.length > string.split(separator).length ) |
michael@0 | 76 | ? split_array.length : string.split(separator).length; |
michael@0 | 77 | |
michael@0 | 78 | for ( var matches = 0; matches < split_array.length; matches++ ) { |
michael@0 | 79 | AddTestCase( |
michael@0 | 80 | "( " + string + " ).split(" + str_sep +")[" + matches +"]", |
michael@0 | 81 | split_array[matches], |
michael@0 | 82 | string.split( separator )[matches] ); |
michael@0 | 83 | } |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | function AddLimitedSplitCases( |
michael@0 | 87 | string, separator, str_sep, limit, str_limit, split_array ) { |
michael@0 | 88 | |
michael@0 | 89 | // verify that the result of split is an object of type Array |
michael@0 | 90 | |
michael@0 | 91 | AddTestCase( |
michael@0 | 92 | "( " + string + " ).split(" + str_sep +", " + str_limit + |
michael@0 | 93 | " ).constructor == Array", |
michael@0 | 94 | true, |
michael@0 | 95 | string.split(separator, limit).constructor == Array ); |
michael@0 | 96 | |
michael@0 | 97 | // check the length of the array |
michael@0 | 98 | |
michael@0 | 99 | AddTestCase( |
michael@0 | 100 | "( " + string + " ).split(" + str_sep +", " + str_limit + " ).length", |
michael@0 | 101 | length, |
michael@0 | 102 | string.split(separator).length ); |
michael@0 | 103 | |
michael@0 | 104 | // check the value of each array item |
michael@0 | 105 | |
michael@0 | 106 | for ( var matches = 0; matches < split_array.length; matches++ ) { |
michael@0 | 107 | AddTestCase( |
michael@0 | 108 | "( " + string + " ).split(" + str_sep +", " + str_limit + " )[" + matches +"]", |
michael@0 | 109 | split_array[matches], |
michael@0 | 110 | string.split( separator )[matches] ); |
michael@0 | 111 | } |
michael@0 | 112 | } |