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 | * Date: 09 November 2002 |
michael@0 | 9 | * SUMMARY: Test that interpreter can handle string literals exceeding 64K |
michael@0 | 10 | * See http://bugzilla.mozilla.org/show_bug.cgi?id=179068 |
michael@0 | 11 | * |
michael@0 | 12 | * Test that the interpreter can handle string literals exceeding 64K limit. |
michael@0 | 13 | * For that the script passes to eval() "str ='LONG_STRING_LITERAL';" where |
michael@0 | 14 | * LONG_STRING_LITERAL is a string with 200K chars. |
michael@0 | 15 | * |
michael@0 | 16 | * Igor Bukanov explains the technique used below: |
michael@0 | 17 | * |
michael@0 | 18 | * > Philip Schwartau wrote: |
michael@0 | 19 | * >... |
michael@0 | 20 | * > Here is the heart of the testcase: |
michael@0 | 21 | * > |
michael@0 | 22 | * > // Generate 200K long string |
michael@0 | 23 | * > var long_str = duplicate(LONG_STR_SEED, N); |
michael@0 | 24 | * > var str = ""; |
michael@0 | 25 | * > eval("str='".concat(long_str, "';")); |
michael@0 | 26 | * > var test_is_ok = (str.length == LONG_STR_SEED.length * N); |
michael@0 | 27 | * > |
michael@0 | 28 | * > |
michael@0 | 29 | * > The testcase creates two identical strings, |long_str| and |str|. It |
michael@0 | 30 | * > uses eval() simply to assign the value of |long_str| to |str|. Why is |
michael@0 | 31 | * > it necessary to have the variable |str|, then? Why not just create |
michael@0 | 32 | * > |long_str| and test it? Wouldn't this be enough: |
michael@0 | 33 | * > |
michael@0 | 34 | * > // Generate 200K long string |
michael@0 | 35 | * > var long_str = duplicate(LONG_STR_SEED, N); |
michael@0 | 36 | * > var test_is_ok = (long_str.length == LONG_STR_SEED.length * N); |
michael@0 | 37 | * > |
michael@0 | 38 | * > Or do we specifically need to test eval() to exercise the interpreter? |
michael@0 | 39 | * |
michael@0 | 40 | * The reason for eval is to test string literals like in 'a string literal |
michael@0 | 41 | * with 100 000 characters...', Rhino deals fine with strings generated at |
michael@0 | 42 | * run time where lengths > 64K. Without eval it would be necessary to have |
michael@0 | 43 | * a test file excedding 64K which is not that polite for CVS and then a |
michael@0 | 44 | * special treatment for the compiled mode in Rhino should be added. |
michael@0 | 45 | * |
michael@0 | 46 | * |
michael@0 | 47 | * > |
michael@0 | 48 | * > If so, is it important to use the concat() method in the assignment, as |
michael@0 | 49 | * > you have done: |eval("str='".concat(long_str, "';"))|, or can we simply |
michael@0 | 50 | * > do |eval("str = long_str;")| ? |
michael@0 | 51 | * |
michael@0 | 52 | * The concat is a replacement for eval("str='"+long_str+"';"), but as |
michael@0 | 53 | * long_str is huge, this leads to constructing first a new string via |
michael@0 | 54 | * "str='"+long_str and then another one via ("str='"+long_str) + "';" |
michael@0 | 55 | * which takes time under JDK 1.1 on a something like StrongArm 200MHz. |
michael@0 | 56 | * Calling concat makes less copies, that is why it is used in the |
michael@0 | 57 | * duplicate function and this is faster then doing recursion like in the |
michael@0 | 58 | * test case to test that 64K different string literals can be handled. |
michael@0 | 59 | * |
michael@0 | 60 | */ |
michael@0 | 61 | //----------------------------------------------------------------------------- |
michael@0 | 62 | var UBound = 0; |
michael@0 | 63 | var BUGNUMBER = 179068; |
michael@0 | 64 | var summary = 'Test that interpreter can handle string literals exceeding 64K'; |
michael@0 | 65 | var status = ''; |
michael@0 | 66 | var statusitems = []; |
michael@0 | 67 | var actual = ''; |
michael@0 | 68 | var actualvalues = []; |
michael@0 | 69 | var expect= ''; |
michael@0 | 70 | var expectedvalues = []; |
michael@0 | 71 | var LONG_STR_SEED = "0123456789"; |
michael@0 | 72 | var N = 20 * 1024; |
michael@0 | 73 | var str = ""; |
michael@0 | 74 | |
michael@0 | 75 | |
michael@0 | 76 | // Generate 200K long string and assign it to |str| via eval() |
michael@0 | 77 | var long_str = duplicate(LONG_STR_SEED, N); |
michael@0 | 78 | eval("str='".concat(long_str, "';")); |
michael@0 | 79 | |
michael@0 | 80 | status = inSection(1); |
michael@0 | 81 | actual = str.length == LONG_STR_SEED.length * N |
michael@0 | 82 | expect = true; |
michael@0 | 83 | addThis(); |
michael@0 | 84 | |
michael@0 | 85 | |
michael@0 | 86 | |
michael@0 | 87 | //----------------------------------------------------------------------------- |
michael@0 | 88 | test(); |
michael@0 | 89 | //----------------------------------------------------------------------------- |
michael@0 | 90 | |
michael@0 | 91 | |
michael@0 | 92 | |
michael@0 | 93 | function duplicate(str, count) |
michael@0 | 94 | { |
michael@0 | 95 | var tmp = new Array(count); |
michael@0 | 96 | |
michael@0 | 97 | while (count != 0) |
michael@0 | 98 | tmp[--count] = str; |
michael@0 | 99 | |
michael@0 | 100 | return String.prototype.concat.apply("", tmp); |
michael@0 | 101 | } |
michael@0 | 102 | |
michael@0 | 103 | |
michael@0 | 104 | function addThis() |
michael@0 | 105 | { |
michael@0 | 106 | statusitems[UBound] = status; |
michael@0 | 107 | actualvalues[UBound] = actual; |
michael@0 | 108 | expectedvalues[UBound] = expect; |
michael@0 | 109 | UBound++; |
michael@0 | 110 | } |
michael@0 | 111 | |
michael@0 | 112 | |
michael@0 | 113 | function test() |
michael@0 | 114 | { |
michael@0 | 115 | enterFunc('test'); |
michael@0 | 116 | printBugNumber(BUGNUMBER); |
michael@0 | 117 | printStatus(summary); |
michael@0 | 118 | |
michael@0 | 119 | for (var i=0; i<UBound; i++) |
michael@0 | 120 | { |
michael@0 | 121 | reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
michael@0 | 122 | } |
michael@0 | 123 | |
michael@0 | 124 | exitFunc ('test'); |
michael@0 | 125 | } |