js/src/tests/js1_6/String/regress-306591.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 var BUGNUMBER = 306591;
michael@0 8 var summary = 'String static methods';
michael@0 9 var actual = '';
michael@0 10 var expect = '';
michael@0 11
michael@0 12 printBugNumber(BUGNUMBER);
michael@0 13 printStatus (summary);
michael@0 14 printStatus ('See https://bugzilla.mozilla.org/show_bug.cgi?id=304828');
michael@0 15
michael@0 16 expect = ['a', 'b', 'c'].toString();
michael@0 17 actual = String.split(new String('abc'), '').toString();
michael@0 18 reportCompare(expect, actual, summary +
michael@0 19 " String.split(new String('abc'), '')");
michael@0 20
michael@0 21 expect = '2';
michael@0 22 actual = String.substring(new Number(123), 1, 2);
michael@0 23 reportCompare(expect, actual, summary +
michael@0 24 " String.substring(new Number(123), 1, 2)");
michael@0 25
michael@0 26 expect = 'TRUE';
michael@0 27 actual = String.toUpperCase(new Boolean(true));
michael@0 28 reportCompare(expect, actual, summary +
michael@0 29 " String.toUpperCase(new Boolean(true))");
michael@0 30
michael@0 31 try
michael@0 32 {
michael@0 33 String.indexOf(null, 'l');
michael@0 34 throw new Error("should have thrown a TypeError");
michael@0 35 }
michael@0 36 catch (e)
michael@0 37 {
michael@0 38 assertEq(e instanceof TypeError, true,
michael@0 39 "String.indexOf(null [, ...]) didn't work correctly");
michael@0 40 }
michael@0 41
michael@0 42 expect = 2;
michael@0 43 actual = String.indexOf(String(null), 'l');
michael@0 44 reportCompare(expect, actual, summary +
michael@0 45 " String.indexOf(String(null), 'l')");
michael@0 46
michael@0 47 expect = ['a', 'b', 'c'].toString();
michael@0 48 actual = String.split('abc', '').toString();
michael@0 49 reportCompare(expect, actual, summary +
michael@0 50 " String.split('abc', '')");
michael@0 51
michael@0 52 expect = '2';
michael@0 53 actual = String.substring(123, 1, 2);
michael@0 54 reportCompare(expect, actual, summary +
michael@0 55 " String.substring(123, 1, 2)");
michael@0 56
michael@0 57 expect = 'TRUE';
michael@0 58 actual = String.toUpperCase(true);
michael@0 59 reportCompare(expect, actual, summary +
michael@0 60 " String.toUpperCase(true)");
michael@0 61
michael@0 62 try
michael@0 63 {
michael@0 64 String.indexOf(undefined, 'd');
michael@0 65 throw new Error("should have thrown a TypeError");
michael@0 66 }
michael@0 67 catch (e)
michael@0 68 {
michael@0 69 assertEq(e instanceof TypeError, true,
michael@0 70 "String.indexOf(undefined [, ...]) didn't work correctly");
michael@0 71 }
michael@0 72
michael@0 73 expect = 2;
michael@0 74 actual = String.indexOf(String(undefined), 'd');
michael@0 75 reportCompare(expect, actual, summary +
michael@0 76 " String.indexOf(String(undefined), 'd')");

mercurial