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 | // Check that withSourceHook passes URLs, propagates exceptions, and |
michael@0 | 2 | // properly restores the original source hooks. |
michael@0 | 3 | |
michael@0 | 4 | load(libdir + 'asserts.js'); |
michael@0 | 5 | |
michael@0 | 6 | // withSourceHook isn't defined if you pass the shell the --fuzzing-safe |
michael@0 | 7 | // option. Skip this test silently, to avoid spurious failures. |
michael@0 | 8 | if (typeof withSourceHook != 'function') |
michael@0 | 9 | quit(0); |
michael@0 | 10 | |
michael@0 | 11 | var log = ''; |
michael@0 | 12 | |
michael@0 | 13 | // Establish an outermost source hook. |
michael@0 | 14 | withSourceHook(function (url) { |
michael@0 | 15 | log += 'o'; |
michael@0 | 16 | assertEq(url, 'outer'); |
michael@0 | 17 | return '(function outer() { 3; })'; |
michael@0 | 18 | }, function () { |
michael@0 | 19 | log += 'O'; |
michael@0 | 20 | // Verify that withSourceHook propagates exceptions thrown by source hooks. |
michael@0 | 21 | assertThrowsValue(function () { |
michael@0 | 22 | // Establish a source hook that throws. |
michael@0 | 23 | withSourceHook(function (url) { |
michael@0 | 24 | log += 'm'; |
michael@0 | 25 | assertEq(url, 'middle'); |
michael@0 | 26 | throw 'borborygmus'; // middle |
michael@0 | 27 | }, function () { |
michael@0 | 28 | log += 'M'; |
michael@0 | 29 | // Establish an innermost source hook that does not throw, |
michael@0 | 30 | // and verify that it is in force. |
michael@0 | 31 | assertEq(withSourceHook(function (url) { |
michael@0 | 32 | log += 'i'; |
michael@0 | 33 | assertEq(url, 'inner'); |
michael@0 | 34 | return '(function inner() { 1; })'; |
michael@0 | 35 | }, function () { |
michael@0 | 36 | log += 'I'; |
michael@0 | 37 | return evaluate('(function inner() { 2; })', |
michael@0 | 38 | { fileName: 'inner', sourceIsLazy: true }) |
michael@0 | 39 | .toSource(); |
michael@0 | 40 | }), |
michael@0 | 41 | '(function inner() { 1; })'); |
michael@0 | 42 | // Verify that the source hook that throws has been reinstated. |
michael@0 | 43 | evaluate('(function middle() { })', |
michael@0 | 44 | { fileName: 'middle', sourceIsLazy: true }) |
michael@0 | 45 | .toSource(); |
michael@0 | 46 | }); |
michael@0 | 47 | }, 'borborygmus'); |
michael@0 | 48 | |
michael@0 | 49 | // Verify that the outermost source hook has been restored. |
michael@0 | 50 | assertEq(evaluate('(function outer() { 4; })', |
michael@0 | 51 | { fileName: 'outer', sourceIsLazy: true }) |
michael@0 | 52 | .toSource(), |
michael@0 | 53 | '(function outer() { 3; })'); |
michael@0 | 54 | }); |
michael@0 | 55 | |
michael@0 | 56 | assertEq(log, 'OMIimo'); |