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 = 371932; |
michael@0 | 8 | var summary = 'ES4 Regular Expression /y flag'; |
michael@0 | 9 | var actual = ''; |
michael@0 | 10 | var expect = ''; |
michael@0 | 11 | |
michael@0 | 12 | print('See http://developer.mozilla.org/es4/proposals/extend_regexps.html#y_flag'); |
michael@0 | 13 | |
michael@0 | 14 | //----------------------------------------------------------------------------- |
michael@0 | 15 | test(); |
michael@0 | 16 | //----------------------------------------------------------------------------- |
michael@0 | 17 | |
michael@0 | 18 | function test() |
michael@0 | 19 | { |
michael@0 | 20 | enterFunc ('test'); |
michael@0 | 21 | printBugNumber(BUGNUMBER); |
michael@0 | 22 | printStatus (summary); |
michael@0 | 23 | |
michael@0 | 24 | var c; |
michael@0 | 25 | var s = '123456'; |
michael@0 | 26 | |
michael@0 | 27 | print('Test global flag.'); |
michael@0 | 28 | |
michael@0 | 29 | var g = /(1)/g; |
michael@0 | 30 | expect = 'captures: 1,1; RegExp.leftContext: ""; RegExp.rightContext: "234561"'; |
michael@0 | 31 | actual = 'captures: ' + g.exec('1234561') + |
michael@0 | 32 | '; RegExp.leftContext: "' + RegExp.leftContext + |
michael@0 | 33 | '"; RegExp.rightContext: "' + RegExp.rightContext + '"'; |
michael@0 | 34 | reportCompare(expect, actual, summary + ' - /(1)/g.exec("1234561") first call'); |
michael@0 | 35 | |
michael@0 | 36 | expect = 'captures: 1,1; RegExp.leftContext: "123456"; RegExp.rightContext: ""'; |
michael@0 | 37 | actual = 'captures: ' + g.exec('1234561') + |
michael@0 | 38 | '; RegExp.leftContext: "' + RegExp.leftContext + |
michael@0 | 39 | '"; RegExp.rightContext: "' + RegExp.rightContext + '"'; |
michael@0 | 40 | reportCompare(expect, actual, summary + ' - /(1)/g.exec("1234561") second call'); |
michael@0 | 41 | var y = /(1)/y; |
michael@0 | 42 | |
michael@0 | 43 | print('Test sticky flag.'); |
michael@0 | 44 | |
michael@0 | 45 | /* |
michael@0 | 46 | * calls to reportCompare invoke regular expression matches which interfere |
michael@0 | 47 | * with the test of the sticky flag. Collect expect and actual values prior |
michael@0 | 48 | * to calling reportCompare. Note setting y = /(1)/y resets the lastIndex etc. |
michael@0 | 49 | */ |
michael@0 | 50 | |
michael@0 | 51 | var y = /(1)/y; |
michael@0 | 52 | var expect4 = 'captures: 1,1; RegExp.leftContext: ""; RegExp.rightContext: "234561"'; |
michael@0 | 53 | var actual4 = 'captures: ' + y.exec('1234561') + |
michael@0 | 54 | '; RegExp.leftContext: "' + RegExp.leftContext + |
michael@0 | 55 | '"; RegExp.rightContext: "' + RegExp.rightContext + '"'; |
michael@0 | 56 | |
michael@0 | 57 | var expect5 = 'captures: null; RegExp.leftContext: ""; RegExp.rightContext: "234561"'; |
michael@0 | 58 | var actual5 = 'captures: ' + y.exec('1234561') + |
michael@0 | 59 | '; RegExp.leftContext: "' + RegExp.leftContext + |
michael@0 | 60 | '"; RegExp.rightContext: "' + RegExp.rightContext + '"'; |
michael@0 | 61 | |
michael@0 | 62 | reportCompare(expect4, actual4, summary + ' - /(1)/y.exec("1234561") first call'); |
michael@0 | 63 | reportCompare(expect5, actual5, summary + ' - /(1)/y.exec("1234561") second call'); |
michael@0 | 64 | |
michael@0 | 65 | var y = /(1)/y; |
michael@0 | 66 | |
michael@0 | 67 | reportCompare(expect5, actual5, summary); |
michael@0 | 68 | |
michael@0 | 69 | y = /(1)/y; |
michael@0 | 70 | var expect6 = 'captures: 1,1; RegExp.leftContext: ""; RegExp.rightContext: "123456"'; |
michael@0 | 71 | var actual6 = 'captures: ' + y.exec('1123456') + |
michael@0 | 72 | '; RegExp.leftContext: "' + RegExp.leftContext + |
michael@0 | 73 | '"; RegExp.rightContext: "' + RegExp.rightContext + '"'; |
michael@0 | 74 | |
michael@0 | 75 | var expect7 = 'captures: 1,1; RegExp.leftContext: "1"; RegExp.rightContext: "23456"'; |
michael@0 | 76 | var actual7 = 'captures: ' + y.exec('1123456') + |
michael@0 | 77 | '; RegExp.leftContext: "' + RegExp.leftContext + |
michael@0 | 78 | '"; RegExp.rightContext: "' + RegExp.rightContext + '"'; |
michael@0 | 79 | |
michael@0 | 80 | reportCompare(expect6, actual6, summary + ' - /(1)/y.exec("1123456") first call'); |
michael@0 | 81 | reportCompare(expect7, actual7, summary + ' - /(1)/y.exec("1123456") second call'); |
michael@0 | 82 | |
michael@0 | 83 | var y = /(1)/y; |
michael@0 | 84 | |
michael@0 | 85 | reportCompare(expect, actual, summary); |
michael@0 | 86 | |
michael@0 | 87 | exitFunc ('test'); |
michael@0 | 88 | } |