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 | // |reftest| skip -- obsolete test |
michael@0 | 2 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | |
michael@0 | 8 | /** |
michael@0 | 9 | File Name: toString_1.js |
michael@0 | 10 | ECMA Section: Object.toString() |
michael@0 | 11 | Description: |
michael@0 | 12 | |
michael@0 | 13 | This checks the ToString value of Object objects under JavaScript 1.2. |
michael@0 | 14 | |
michael@0 | 15 | In JavaScript 1.2, Object.toString() |
michael@0 | 16 | |
michael@0 | 17 | Author: christine@netscape.com |
michael@0 | 18 | Date: 12 november 1997 |
michael@0 | 19 | */ |
michael@0 | 20 | |
michael@0 | 21 | var SECTION = "JS1_2"; |
michael@0 | 22 | var VERSION = "JS1_2"; |
michael@0 | 23 | startTest(); |
michael@0 | 24 | var TITLE = "Object.toString()"; |
michael@0 | 25 | |
michael@0 | 26 | writeHeaderToLog( SECTION + " "+ TITLE); |
michael@0 | 27 | |
michael@0 | 28 | var o = new Object(); |
michael@0 | 29 | |
michael@0 | 30 | new TestCase( SECTION, |
michael@0 | 31 | "var o = new Object(); o.toString()", |
michael@0 | 32 | "{}", |
michael@0 | 33 | o.toString() ); |
michael@0 | 34 | |
michael@0 | 35 | o = {}; |
michael@0 | 36 | |
michael@0 | 37 | new TestCase( SECTION, |
michael@0 | 38 | "o = {}; o.toString()", |
michael@0 | 39 | "{}", |
michael@0 | 40 | o.toString() ); |
michael@0 | 41 | |
michael@0 | 42 | o = { name:"object", length:0, value:"hello" } |
michael@0 | 43 | |
michael@0 | 44 | new TestCase( SECTION, |
michael@0 | 45 | "o = { name:\"object\", length:0, value:\"hello\" }; o.toString()", |
michael@0 | 46 | true, |
michael@0 | 47 | checkObjectToString(o.toString(), ['name:"object"', 'length:0', |
michael@0 | 48 | 'value:"hello"'])); |
michael@0 | 49 | |
michael@0 | 50 | o = { name:"object", length:0, value:"hello", |
michael@0 | 51 | toString:new Function( "return this.value+''" ) } |
michael@0 | 52 | |
michael@0 | 53 | new TestCase( SECTION, |
michael@0 | 54 | "o = { name:\"object\", length:0, value:\"hello\", "+ |
michael@0 | 55 | "toString:new Function( \"return this.value+''\" ) }; o.toString()", |
michael@0 | 56 | "hello", |
michael@0 | 57 | o.toString() ); |
michael@0 | 58 | |
michael@0 | 59 | |
michael@0 | 60 | |
michael@0 | 61 | test(); |
michael@0 | 62 | |
michael@0 | 63 | /** |
michael@0 | 64 | * checkObjectToString |
michael@0 | 65 | * |
michael@0 | 66 | * In JS1.2, Object.prototype.toString returns a representation of the |
michael@0 | 67 | * object's properties as a string. However, the order of the properties |
michael@0 | 68 | * in the resulting string is not specified. This function compares the |
michael@0 | 69 | * resulting string with an array of strings to make sure that the |
michael@0 | 70 | * resulting string is some permutation of the strings in the array. |
michael@0 | 71 | */ |
michael@0 | 72 | function checkObjectToString(s, a) { |
michael@0 | 73 | var m = /^\{(.*)\}$/(s); |
michael@0 | 74 | if (!m) |
michael@0 | 75 | return false; // should begin and end with curly brackets |
michael@0 | 76 | var a2 = m[1].split(", "); |
michael@0 | 77 | if (a.length != a2.length) |
michael@0 | 78 | return false; // should be same length |
michael@0 | 79 | a.sort(); |
michael@0 | 80 | a2.sort(); |
michael@0 | 81 | for (var i=0; i < a.length; i++) { |
michael@0 | 82 | if (a[i] != a2[i]) |
michael@0 | 83 | return false; // should have identical elements |
michael@0 | 84 | } |
michael@0 | 85 | return true; |
michael@0 | 86 | } |
michael@0 | 87 |