|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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 jit(true); |
|
18 |
|
19 var SNI = {}; |
|
20 SNI.MetaData={}; |
|
21 SNI.MetaData.Parameter=function() |
|
22 { |
|
23 var parameters={}; |
|
24 this.addParameter=function(key,value) |
|
25 { |
|
26 parameters[key]=[]; |
|
27 parameters[key].push(value); |
|
28 }; |
|
29 this.getParameter=function(key,separator){ |
|
30 if(!parameters[key]) |
|
31 { |
|
32 return; |
|
33 } |
|
34 return parameters[key].join(separator); |
|
35 }; |
|
36 this.getKeys=function() |
|
37 { |
|
38 return parameters; |
|
39 }; |
|
40 }; |
|
41 SNI.MetaData.Manager=function(){ |
|
42 var m=new SNI.MetaData.Parameter(); |
|
43 this.getParameter=m.getParameter; |
|
44 }; |
|
45 var MetaDataManager=SNI.MetaData.Manager; |
|
46 SNI.Ads={ }; |
|
47 SNI.Ads.Url=function(){ |
|
48 var p=new SNI.MetaData.Parameter(); |
|
49 this.addParameter=p.addParameter; |
|
50 this.getParameter=p.getParameter; |
|
51 }; |
|
52 function Ad() { |
|
53 var url=new SNI.Ads.Url(); |
|
54 this.addParameter=url.addParameter; |
|
55 this.getParameter=url.getParameter; |
|
56 } |
|
57 function DartAd() |
|
58 AdUrl.prototype=new Ad(); |
|
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 jit(false); |
|
119 |
|
120 reportCompare(expect, actual, summary); |