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.
1 <!DOCTYPE html>
2 <head>
3 <!--
4 Copyright (C) 2007 Apple Inc. All rights reserved.
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9 1. Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 2. Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution.
15 THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
16 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
19 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 -->
28 <title>SunSpider string-validate-input</title>
30 </head>
32 <body>
33 <h3>string-validate-input</h3>
34 <div id="console">
35 </div>
37 <script>
39 var _sunSpiderStartDate = new Date();
41 letters = new Array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
42 numbers = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26);
43 colors = new Array("FF","CC","99","66","33","00");
45 var endResult;
47 function doTest()
48 {
49 endResult = "";
51 // make up email address
52 for (var k=0;k<4000;k++)
53 {
54 name = makeName(6);
55 (k%2)?email=name+"@mac.com":email=name+"(at)mac.com";
57 // validate the email address
58 var pattern = /^[a-zA-Z0-9\-\._]+@[a-zA-Z0-9\-_]+(\.?[a-zA-Z0-9\-_]*)\.[a-zA-Z]{2,3}$/;
60 if(pattern.test(email))
61 {
62 var r = email + " appears to be a valid email address.";
63 addResult(r);
64 }
65 else
66 {
67 r = email + " does NOT appear to be a valid email address.";
68 addResult(r);
69 }
70 }
72 // make up ZIP codes
73 for (var s=0;s<4000;s++)
74 {
75 var zipGood = true;
76 var zip = makeNumber(4);
77 (s%2)?zip=zip+"xyz":zip=zip.concat("7");
79 // validate the zip code
80 for (var i = 0; i < zip.length; i++) {
81 var ch = zip.charAt(i);
82 if (ch < "0" || ch > "9") {
83 zipGood = false;
84 r = zip + " contains letters.";
85 addResult(r);
86 }
87 }
88 if (zipGood && zip.length>5)
89 {
90 zipGood = false;
91 r = zip + " is longer than five characters.";
92 addResult(r);
93 }
94 if (zipGood)
95 {
96 r = zip + " appears to be a valid ZIP code.";
97 addResult(r);
98 }
99 }
100 }
102 function makeName(n)
103 {
104 var tmp = "";
105 for (var i=0;i<n;i++)
106 {
107 var l = Math.floor(26*Math.random());
108 tmp += letters[l];
109 }
110 return tmp;
111 }
113 function makeNumber(n)
114 {
115 var tmp = "";
116 for (var i=0;i<n;i++)
117 {
118 var l = Math.floor(9*Math.random());
119 tmp = tmp.concat(l);
120 }
121 return tmp;
122 }
124 function addResult(r)
125 {
126 endResult += "\n" + r;
127 }
129 doTest();
132 var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
134 document.getElementById("console").innerHTML = _sunSpiderInterval;
135 </script>
138 </body>
139 </html>