| 1 |
/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ |
| 2 |
/* This Source Code Form is subject to the terms of the Mozilla Public |
| 3 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 4 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 5 |
|
| 6 |
//----------------------------------------------------------------------------- |
| 7 |
var BUGNUMBER = 459389; |
| 8 |
var summary = 'Do not crash with JIT'; |
| 9 |
var actual = ''; |
| 10 |
var expect = ''; |
| 11 |
|
| 12 |
printBugNumber(BUGNUMBER); |
| 13 |
printStatus (summary); |
| 14 |
|
| 15 |
print('mmmm, food!'); |
| 16 |
|
| 17 |
|
| 18 |
var SNI = {}; |
| 19 |
SNI.MetaData={}; |
| 20 |
SNI.MetaData.Parameter=function() |
| 21 |
{ |
| 22 |
var parameters={}; |
| 23 |
this.addParameter=function(key,value) |
| 24 |
{ |
| 25 |
parameters[key]=[]; |
| 26 |
parameters[key].push(value); |
| 27 |
}; |
| 28 |
this.getParameter=function(key,separator){ |
| 29 |
if(!parameters[key]) |
| 30 |
{ |
| 31 |
return; |
| 32 |
} |
| 33 |
return parameters[key].join(separator); |
| 34 |
}; |
| 35 |
this.getKeys=function() |
| 36 |
{ |
| 37 |
return parameters; |
| 38 |
}; |
| 39 |
}; |
| 40 |
SNI.MetaData.Manager=function(){ |
| 41 |
var m=new SNI.MetaData.Parameter(); |
| 42 |
this.getParameter=m.getParameter; |
| 43 |
}; |
| 44 |
var MetaDataManager=SNI.MetaData.Manager; |
| 45 |
SNI.Ads={ }; |
| 46 |
SNI.Ads.Url=function(){ |
| 47 |
var p=new SNI.MetaData.Parameter(); |
| 48 |
this.addParameter=p.addParameter; |
| 49 |
this.getParameter=p.getParameter; |
| 50 |
}; |
| 51 |
function Ad() { |
| 52 |
var url=new SNI.Ads.Url(); |
| 53 |
this.addParameter=url.addParameter; |
| 54 |
this.getParameter=url.getParameter; |
| 55 |
} |
| 56 |
function DartAd() { |
| 57 |
return AdUrl.prototype=new Ad(); |
| 58 |
} |
| 59 |
function AdUrl() { } |
| 60 |
function AdRestriction() { |
| 61 |
var p=new SNI.MetaData.Parameter(); |
| 62 |
this.addParameter=p.addParameter; |
| 63 |
this.getParameter=p.getParameter; |
| 64 |
this.getKeys=p.getKeys; |
| 65 |
} |
| 66 |
function AdRestrictionManager(){ |
| 67 |
this.restriction=[]; |
| 68 |
this.isActive=isActive; |
| 69 |
this.isMatch=isMatch; |
| 70 |
this.startMatch=startMatch; |
| 71 |
function isActive(ad,mdm){ |
| 72 |
var value=false; |
| 73 |
for(var i=0;i<this.restriction.length;i++) |
| 74 |
{ |
| 75 |
adRestriction=this.restriction[i]; |
| 76 |
value=this.startMatch(ad,mdm,adRestriction); |
| 77 |
} |
| 78 |
} |
| 79 |
function startMatch(ad,mdm,adRestriction){ |
| 80 |
for(var key in adRestriction.getKeys()){ |
| 81 |
var restrictions=adRestriction.getParameter(key,','); |
| 82 |
var value=mdm.getParameter(key,''); |
| 83 |
match=this.isMatch(value,restrictions); |
| 84 |
if(!match){ |
| 85 |
value=ad.getParameter(key,'') |
| 86 |
match=this.isMatch(value,restrictions); |
| 87 |
} |
| 88 |
} |
| 89 |
} |
| 90 |
function isMatch(value,restrictions){ |
| 91 |
var match=false; |
| 92 |
if(value) |
| 93 |
{ |
| 94 |
splitValue=value.split(''); |
| 95 |
for(var x=0;x<splitValue.length;x++){ |
| 96 |
for(var a;a<restrictions.length;a++){ } |
| 97 |
} |
| 98 |
} |
| 99 |
return match; |
| 100 |
} |
| 101 |
} |
| 102 |
var adRestrictionManager = new AdRestrictionManager(); |
| 103 |
var restrictionLeader6 = new AdRestriction(); |
| 104 |
restrictionLeader6.addParameter("", ""); |
| 105 |
adRestrictionManager.restriction.push(restrictionLeader6); |
| 106 |
var restrictionLeader7 = new AdRestriction(); |
| 107 |
restrictionLeader7.addParameter("", ""); |
| 108 |
adRestrictionManager.restriction.push(restrictionLeader7); |
| 109 |
function FoodAd(adtype) |
| 110 |
{ |
| 111 |
ad=new DartAd() |
| 112 |
ad.addParameter("",adtype) |
| 113 |
adRestrictionManager.isActive(ad, mdManager) |
| 114 |
} |
| 115 |
var mdManager = new MetaDataManager() ; |
| 116 |
FoodAd('P') |
| 117 |
|
| 118 |
|
| 119 |
reportCompare(expect, actual, summary); |