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 | var BUGNUMBER = 418641; |
michael@0 | 8 | var summary = '++ and -- correctness'; |
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 | |
michael@0 | 15 | function get_pre_check(operand, op) |
michael@0 | 16 | { |
michael@0 | 17 | return "{\n"+ |
michael@0 | 18 | " "+operand+" = I;\n"+ |
michael@0 | 19 | " let tmp = "+op+op+operand+";\n"+ |
michael@0 | 20 | " if ("+operand+" !== Number(I) "+op+" 1)\n"+ |
michael@0 | 21 | " throw Error('"+op+op+operand+" case 1 for '+uneval(I));\n"+ |
michael@0 | 22 | " if (tmp !== "+operand+")\n"+ |
michael@0 | 23 | " throw Error('"+op+op+operand+" case 2 for '+uneval(I));\n"+ |
michael@0 | 24 | "}\n"; |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | function get_post_check(operand, op) |
michael@0 | 28 | { |
michael@0 | 29 | return "{\n"+ |
michael@0 | 30 | " "+operand+" = I;\n"+ |
michael@0 | 31 | " let tmp = "+operand+op+op+";\n"+ |
michael@0 | 32 | " if ("+operand+" !== Number(I) "+op+" 1)\n"+ |
michael@0 | 33 | " throw Error('"+operand+op+op+" case 1 for '+uneval(I));\n"+ |
michael@0 | 34 | " if (tmp !== Number(I))\n"+ |
michael@0 | 35 | " throw Error('"+op+op+operand+" case 2 for '+uneval(I));\n"+ |
michael@0 | 36 | "}\n"; |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | function get_check_source(operand) |
michael@0 | 40 | { |
michael@0 | 41 | return get_pre_check(operand, '+')+ |
michael@0 | 42 | get_pre_check(operand, '-')+ |
michael@0 | 43 | get_post_check(operand, '+')+ |
michael@0 | 44 | get_post_check(operand, '-'); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | var arg_check = Function('I', 'a', get_check_source('a')); |
michael@0 | 48 | var let_check = Function('I', 'let a;'+get_check_source('a')); |
michael@0 | 49 | var var_check = Function('I', 'var a;'+get_check_source('a')); |
michael@0 | 50 | |
michael@0 | 51 | var my_name; |
michael@0 | 52 | var my_obj = {}; |
michael@0 | 53 | var my_index = 0; |
michael@0 | 54 | var name_check = Function('I', get_check_source('my_name')); |
michael@0 | 55 | var prop_check = Function('I', get_check_source('my_obj.x')); |
michael@0 | 56 | var elem_check = Function('I', get_check_source('my_obj[my_index]')); |
michael@0 | 57 | |
michael@0 | 58 | var test_values = [0 , 0.5, -0.0, (1 << 30) - 1, 1 - (1 << 30)]; |
michael@0 | 59 | |
michael@0 | 60 | for (let i = 0; i != test_values.length; i = i + 1) { |
michael@0 | 61 | let x = [test_values[i], String(test_values[i])]; |
michael@0 | 62 | for (let j = 0; j != x.length; j = j + 1) { |
michael@0 | 63 | try |
michael@0 | 64 | { |
michael@0 | 65 | expect = actual = 'No Error'; |
michael@0 | 66 | let test_value = x[j]; |
michael@0 | 67 | arg_check(test_value, 0); |
michael@0 | 68 | let_check(test_value); |
michael@0 | 69 | var_check(test_value); |
michael@0 | 70 | name_check(test_value); |
michael@0 | 71 | prop_check(test_value); |
michael@0 | 72 | elem_check(test_value); |
michael@0 | 73 | } |
michael@0 | 74 | catch(ex) |
michael@0 | 75 | { |
michael@0 | 76 | actual = ex + ''; |
michael@0 | 77 | } |
michael@0 | 78 | reportCompare(expect, actual, summary + ': ' + i + ', ' + j); |
michael@0 | 79 | } |
michael@0 | 80 | } |