~ubuntu-branches/ubuntu/quantal/enigmail/quantal-security

« back to all changes in this revision

Viewing changes to build/pgo/js-input/string-validate-input.html

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2013-09-13 16:02:15 UTC
  • mfrom: (0.12.16)
  • Revision ID: package-import@ubuntu.com-20130913160215-u3g8nmwa0pdwagwc
Tags: 2:1.5.2-0ubuntu0.12.10.1
* New upstream release v1.5.2 for Thunderbird 24

* Build enigmail using a stripped down Thunderbird 17 build system, as it's
  now quite difficult to build the way we were doing previously, with the
  latest Firefox build system
* Add debian/patches/no_libxpcom.patch - Don't link against libxpcom, as it
  doesn't exist anymore (but exists in the build system)
* Add debian/patches/use_sdk.patch - Use the SDK version of xpt.py and
  friends
* Drop debian/patches/ipc-pipe_rename.diff (not needed anymore)
* Drop debian/patches/makefile_depth.diff (not needed anymore)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html>
2
 
<head>
3
 
<!--
4
 
 Copyright (C) 2007 Apple Inc.  All rights reserved.
5
 
 
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.
14
 
 
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
 
-->
27
 
 
28
 
<title>SunSpider string-validate-input</title>
29
 
 
30
 
</head>
31
 
 
32
 
<body>
33
 
<h3>string-validate-input</h3>
34
 
<div id="console">
35
 
</div>
36
 
 
37
 
<script>
38
 
 
39
 
var _sunSpiderStartDate = new Date();
40
 
 
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");
44
 
 
45
 
var endResult;
46
 
 
47
 
function doTest()
48
 
{
49
 
   endResult = "";
50
 
 
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";
56
 
 
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}$/;
59
 
 
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
 
   }
71
 
 
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");
78
 
 
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
 
}
101
 
 
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
 
}
112
 
 
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
 
}
123
 
 
124
 
function addResult(r)
125
 
{
126
 
   endResult += "\n" + r;
127
 
}
128
 
 
129
 
doTest();
130
 
 
131
 
 
132
 
var _sunSpiderInterval = new Date() - _sunSpiderStartDate;
133
 
 
134
 
document.getElementById("console").innerHTML = _sunSpiderInterval;
135
 
</script>
136
 
 
137
 
 
138
 
</body>
139
 
</html>