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 = 459389; |
michael@0 | 8 | var summary = 'Do not crash with JIT'; |
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 | print('mmmm, food!'); |
michael@0 | 16 | |
michael@0 | 17 | jit(true); |
michael@0 | 18 | |
michael@0 | 19 | var SNI = {}; |
michael@0 | 20 | SNI.MetaData={}; |
michael@0 | 21 | SNI.MetaData.Parameter=function() |
michael@0 | 22 | { |
michael@0 | 23 | var parameters={}; |
michael@0 | 24 | this.addParameter=function(key,value) |
michael@0 | 25 | { |
michael@0 | 26 | parameters[key]=[]; |
michael@0 | 27 | parameters[key].push(value); |
michael@0 | 28 | }; |
michael@0 | 29 | this.getParameter=function(key,separator){ |
michael@0 | 30 | if(!parameters[key]) |
michael@0 | 31 | { |
michael@0 | 32 | return; |
michael@0 | 33 | } |
michael@0 | 34 | return parameters[key].join(separator); |
michael@0 | 35 | }; |
michael@0 | 36 | this.getKeys=function() |
michael@0 | 37 | { |
michael@0 | 38 | return parameters; |
michael@0 | 39 | }; |
michael@0 | 40 | }; |
michael@0 | 41 | SNI.MetaData.Manager=function(){ |
michael@0 | 42 | var m=new SNI.MetaData.Parameter(); |
michael@0 | 43 | this.getParameter=m.getParameter; |
michael@0 | 44 | }; |
michael@0 | 45 | var MetaDataManager=SNI.MetaData.Manager; |
michael@0 | 46 | SNI.Ads={ }; |
michael@0 | 47 | SNI.Ads.Url=function(){ |
michael@0 | 48 | var p=new SNI.MetaData.Parameter(); |
michael@0 | 49 | this.addParameter=p.addParameter; |
michael@0 | 50 | this.getParameter=p.getParameter; |
michael@0 | 51 | }; |
michael@0 | 52 | function Ad() { |
michael@0 | 53 | var url=new SNI.Ads.Url(); |
michael@0 | 54 | this.addParameter=url.addParameter; |
michael@0 | 55 | this.getParameter=url.getParameter; |
michael@0 | 56 | } |
michael@0 | 57 | function DartAd() |
michael@0 | 58 | AdUrl.prototype=new Ad(); |
michael@0 | 59 | function AdUrl() { } |
michael@0 | 60 | function AdRestriction() { |
michael@0 | 61 | var p=new SNI.MetaData.Parameter(); |
michael@0 | 62 | this.addParameter=p.addParameter; |
michael@0 | 63 | this.getParameter=p.getParameter; |
michael@0 | 64 | this.getKeys=p.getKeys; |
michael@0 | 65 | } |
michael@0 | 66 | function AdRestrictionManager(){ |
michael@0 | 67 | this.restriction=[]; |
michael@0 | 68 | this.isActive=isActive; |
michael@0 | 69 | this.isMatch=isMatch; |
michael@0 | 70 | this.startMatch=startMatch; |
michael@0 | 71 | function isActive(ad,mdm){ |
michael@0 | 72 | var value=false; |
michael@0 | 73 | for(var i=0;i<this.restriction.length;i++) |
michael@0 | 74 | { |
michael@0 | 75 | adRestriction=this.restriction[i]; |
michael@0 | 76 | value=this.startMatch(ad,mdm,adRestriction); |
michael@0 | 77 | } |
michael@0 | 78 | } |
michael@0 | 79 | function startMatch(ad,mdm,adRestriction){ |
michael@0 | 80 | for(var key in adRestriction.getKeys()){ |
michael@0 | 81 | var restrictions=adRestriction.getParameter(key,','); |
michael@0 | 82 | var value=mdm.getParameter(key,''); |
michael@0 | 83 | match=this.isMatch(value,restrictions); |
michael@0 | 84 | if(!match){ |
michael@0 | 85 | value=ad.getParameter(key,'') |
michael@0 | 86 | match=this.isMatch(value,restrictions); |
michael@0 | 87 | } |
michael@0 | 88 | } |
michael@0 | 89 | } |
michael@0 | 90 | function isMatch(value,restrictions){ |
michael@0 | 91 | var match=false; |
michael@0 | 92 | if(value) |
michael@0 | 93 | { |
michael@0 | 94 | splitValue=value.split(''); |
michael@0 | 95 | for(var x=0;x<splitValue.length;x++){ |
michael@0 | 96 | for(var a;a<restrictions.length;a++){ } |
michael@0 | 97 | } |
michael@0 | 98 | } |
michael@0 | 99 | return match; |
michael@0 | 100 | } |
michael@0 | 101 | } |
michael@0 | 102 | var adRestrictionManager = new AdRestrictionManager(); |
michael@0 | 103 | var restrictionLeader6 = new AdRestriction(); |
michael@0 | 104 | restrictionLeader6.addParameter("", ""); |
michael@0 | 105 | adRestrictionManager.restriction.push(restrictionLeader6); |
michael@0 | 106 | var restrictionLeader7 = new AdRestriction(); |
michael@0 | 107 | restrictionLeader7.addParameter("", ""); |
michael@0 | 108 | adRestrictionManager.restriction.push(restrictionLeader7); |
michael@0 | 109 | function FoodAd(adtype) |
michael@0 | 110 | { |
michael@0 | 111 | ad=new DartAd() |
michael@0 | 112 | ad.addParameter("",adtype) |
michael@0 | 113 | adRestrictionManager.isActive(ad, mdManager) |
michael@0 | 114 | } |
michael@0 | 115 | var mdManager = new MetaDataManager() ; |
michael@0 | 116 | FoodAd('P') |
michael@0 | 117 | |
michael@0 | 118 | jit(false); |
michael@0 | 119 | |
michael@0 | 120 | reportCompare(expect, actual, summary); |