You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/05/27 21:22:54 UTC
[01/10] [#4122] rename AlluraTesting dir to AlluraTest,
to match the module name below
Updated Branches:
refs/heads/db/6277 [created] 1b9cdc232
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/jslint/rhino.js
----------------------------------------------------------------------
diff --git a/AlluraTesting/jslint/rhino.js b/AlluraTesting/jslint/rhino.js
deleted file mode 100644
index 04be512..0000000
--- a/AlluraTesting/jslint/rhino.js
+++ /dev/null
@@ -1,41 +0,0 @@
-// rhino.js
-// 2009-09-11
-/*
-Copyright (c) 2002 Douglas Crockford (www.JSLint.com) Rhino Edition
-*/
-
-// This is the Rhino companion to fulljslint.js.
-
-/*global JSLINT */
-/*jslint rhino: true, strict: false */
-
-(function (a) {
- var e, i, input;
- if (!a[0]) {
- print("Usage: jslint.js file.js");
- quit(1);
- }
- input = readFile(a[0]);
- if (!input) {
- print("jslint: Couldn't open file '" + a[0] + "'.");
- quit(1);
- }
- if (!JSLINT(input, {bitwise: true, eqeqeq: true, immed: true,
- newcap: true, nomen: true, onevar: true, plusplus: true,
- regexp: true, rhino: true, undef: true, white: true})) {
- for (i = 0; i < JSLINT.errors.length; i += 1) {
- e = JSLINT.errors[i];
- if (e) {
- print('Lint at line ' + e.line + ' character ' +
- e.character + ': ' + e.reason);
- print((e.evidence || '').
- replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"));
- print('');
- }
- }
- quit(2);
- } else {
- print("jslint: No problems found in " + a[0]);
- quit();
- }
-}(arguments));
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/setup.py
----------------------------------------------------------------------
diff --git a/AlluraTesting/setup.py b/AlluraTesting/setup.py
deleted file mode 100644
index a449b84..0000000
--- a/AlluraTesting/setup.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-from setuptools import setup, find_packages
-import sys, os
-
-setup(name='AlluraTesting',
- version='0.1',
- description="Allura testing support",
- long_description="""\
-""",
- classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
- keywords='',
- author='',
- author_email='',
- url='',
- license='',
- packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
- include_package_data=True,
- zip_safe=False,
- install_requires=[
- "poster",
- # -*- Extra requirements: -*-
- ]
- )
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/twill-tests/README
----------------------------------------------------------------------
diff --git a/AlluraTesting/twill-tests/README b/AlluraTesting/twill-tests/README
deleted file mode 100644
index 59e490e..0000000
--- a/AlluraTesting/twill-tests/README
+++ /dev/null
@@ -1,19 +0,0 @@
-Twill Tests
-
-First, you'll need twill-sh:
-
- sudo easy_install twill
-
-
-Files in this directory ending with '.twill' are tests to be run by twill-sh
-
- twill-sh --url=http://url.of.forge.to.test/ twill-tests/*.twill
-
-e.g.,
-
- twill-sh --url=http://re.sourceforge.net/ twill-tests/*.twill
-
-
-If you just want to run the quick "smoke tests":
-
- twill-sh --url=... twill-tests/smoke*.twill
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/twill-tests/create_repo.twill
----------------------------------------------------------------------
diff --git a/AlluraTesting/twill-tests/create_repo.twill b/AlluraTesting/twill-tests/create_repo.twill
deleted file mode 100644
index 17b9a3a..0000000
--- a/AlluraTesting/twill-tests/create_repo.twill
+++ /dev/null
@@ -1,47 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-setlocal username test_admin
-setlocal password foo
-
-clear_extra_headers
-go ./auth/
-formvalue 1 username $username
-formvalue 1 password $password
-submit
-
-code 200
-
-go ./p/test/admin/tools
-
-code 200
-
-formvalue 2 "new.ep_name" "Git"
-formvalue 2 "new.mount_point" "deleteme"
-submit
-
-code 200
-
-go ../deleteme/
-
-code 200
-
-find ready
-
-go ../admin/tools
-
-# Delete the repo :-(
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/twill-tests/edit_wiki_page.twill
----------------------------------------------------------------------
diff --git a/AlluraTesting/twill-tests/edit_wiki_page.twill b/AlluraTesting/twill-tests/edit_wiki_page.twill
deleted file mode 100644
index 2b659ec..0000000
--- a/AlluraTesting/twill-tests/edit_wiki_page.twill
+++ /dev/null
@@ -1,36 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-setlocal username test_admin
-setlocal password foo
-
-clear_extra_headers
-go ./auth/
-formvalue 1 username $username
-formvalue 1 password $password
-submit
-
-code 200
-
-go ./p/test/wiki/TestWikiWord/edit
-
-code 200
-
-formvalue 3 text "This is just a test."
-submit
-
-code 200
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/twill-tests/login.twill
----------------------------------------------------------------------
diff --git a/AlluraTesting/twill-tests/login.twill b/AlluraTesting/twill-tests/login.twill
deleted file mode 100644
index fbe6f67..0000000
--- a/AlluraTesting/twill-tests/login.twill
+++ /dev/null
@@ -1,27 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-setlocal username test_admin
-setlocal password foo
-
-clear_extra_headers
-go ./auth/
-formvalue 1 username $username
-formvalue 1 password $password
-submit
-
-code 200
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/twill-tests/new_issue.twill
----------------------------------------------------------------------
diff --git a/AlluraTesting/twill-tests/new_issue.twill b/AlluraTesting/twill-tests/new_issue.twill
deleted file mode 100644
index 7b05168..0000000
--- a/AlluraTesting/twill-tests/new_issue.twill
+++ /dev/null
@@ -1,36 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-setlocal username test_admin
-setlocal password foo
-
-clear_extra_headers
-go ./auth/
-formvalue 1 username $username
-formvalue 1 password $password
-submit
-
-code 200
-
-go ./p/test/bugs/new/
-
-code 200
-
-formvalue 2 "ticket_form.summary" "test create ticket"
-submit
-
-code 200
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/twill-tests/smoke-front-page.twill
----------------------------------------------------------------------
diff --git a/AlluraTesting/twill-tests/smoke-front-page.twill b/AlluraTesting/twill-tests/smoke-front-page.twill
deleted file mode 100644
index a0f4852..0000000
--- a/AlluraTesting/twill-tests/smoke-front-page.twill
+++ /dev/null
@@ -1,20 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-clear_extra_headers
-go .
-code 200
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/twill-tests/smoke-project-home.twill
----------------------------------------------------------------------
diff --git a/AlluraTesting/twill-tests/smoke-project-home.twill b/AlluraTesting/twill-tests/smoke-project-home.twill
deleted file mode 100644
index 3d1e8bf..0000000
--- a/AlluraTesting/twill-tests/smoke-project-home.twill
+++ /dev/null
@@ -1,20 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-clear_extra_headers
-go ./p/test/home/
-code 200
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/twill-tests/smoke-tracker-search.twill
----------------------------------------------------------------------
diff --git a/AlluraTesting/twill-tests/smoke-tracker-search.twill b/AlluraTesting/twill-tests/smoke-tracker-search.twill
deleted file mode 100644
index d8d03a3..0000000
--- a/AlluraTesting/twill-tests/smoke-tracker-search.twill
+++ /dev/null
@@ -1,20 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-clear_extra_headers
-go ./p/test/bugs/search/
-code 200
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/twill-tests/smoke-tracker.twill
----------------------------------------------------------------------
diff --git a/AlluraTesting/twill-tests/smoke-tracker.twill b/AlluraTesting/twill-tests/smoke-tracker.twill
deleted file mode 100644
index 1e9e0f7..0000000
--- a/AlluraTesting/twill-tests/smoke-tracker.twill
+++ /dev/null
@@ -1,20 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-clear_extra_headers
-go ./p/test/bugs/
-code 200
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/twill-tests/smoke-user-profile.twill
----------------------------------------------------------------------
diff --git a/AlluraTesting/twill-tests/smoke-user-profile.twill b/AlluraTesting/twill-tests/smoke-user-profile.twill
deleted file mode 100644
index 907f17d..0000000
--- a/AlluraTesting/twill-tests/smoke-user-profile.twill
+++ /dev/null
@@ -1,20 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-clear_extra_headers
-go ./u/test_admin/profile/
-code 200
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/twill-tests/smoke-wiki.twill
----------------------------------------------------------------------
diff --git a/AlluraTesting/twill-tests/smoke-wiki.twill b/AlluraTesting/twill-tests/smoke-wiki.twill
deleted file mode 100644
index 03e2c56..0000000
--- a/AlluraTesting/twill-tests/smoke-wiki.twill
+++ /dev/null
@@ -1,20 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-clear_extra_headers
-go ./p/test/wiki/Home/
-code 200
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/rat-excludes.txt
----------------------------------------------------------------------
diff --git a/rat-excludes.txt b/rat-excludes.txt
index 49e640b..cb8aea3 100644
--- a/rat-excludes.txt
+++ b/rat-excludes.txt
@@ -32,7 +32,7 @@ Allura/allura/public/nf/js/sylvester.js
Allura/allura/tests/data/genshi_hello_tmpl
Allura/allura/tests/data/test_mime/text_file.txt
Allura/run/dummy.txt
-AlluraTesting/jslint/
+AlluraTest/jslint/
ForgeGit/forgegit/data/post-receive_tmpl
ForgeSVN/forgesvn/tests/data/testsvn/
solr_config/core0/conf/spellings.txt
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/run_clonedigger
----------------------------------------------------------------------
diff --git a/run_clonedigger b/run_clonedigger
index cda4b67..d7f1a1f 100755
--- a/run_clonedigger
+++ b/run_clonedigger
@@ -27,7 +27,7 @@ fi
if [ "$TEST_MODULES" == "" ]; then
TEST_MODULES="\
- AlluraTesting \
+ AlluraTest \
Allura \
ForgeBlog \
ForgeLink \
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/run_tests
----------------------------------------------------------------------
diff --git a/run_tests b/run_tests
index fa39230..59e1825 100755
--- a/run_tests
+++ b/run_tests
@@ -27,7 +27,7 @@ fi
if [ "$TEST_MODULES" == "" ]; then
TEST_MODULES="\
- AlluraTesting \
+ AlluraTest \
Allura \
ForgeBlog \
ForgeLink \
[08/10] git commit: fix indentation
Posted by br...@apache.org.
fix indentation
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/941d83b4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/941d83b4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/941d83b4
Branch: refs/heads/db/6277
Commit: 941d83b482daa6e5421d2782e44f9ca9d275c666
Parents: aa22243
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Sat May 25 13:28:20 2013 -0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon May 27 15:21:29 2013 -0400
----------------------------------------------------------------------
AlluraTest/alluratest/validation.py | 175 ++++++++++++++++--------------
1 files changed, 91 insertions(+), 84 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/941d83b4/AlluraTest/alluratest/validation.py
----------------------------------------------------------------------
diff --git a/AlluraTest/alluratest/validation.py b/AlluraTest/alluratest/validation.py
index 235d7c0..7a5fd0b 100644
--- a/AlluraTest/alluratest/validation.py
+++ b/AlluraTest/alluratest/validation.py
@@ -115,112 +115,118 @@ def report_validation_error(val_name, filename, message):
else:
sys.stderr.write('=' * 40 + '\n' + message)
+
def dump_to_file(prefix, html):
f = tempfile.NamedTemporaryFile(prefix=prefix, delete=False)
f.write(html)
f.close()
return f.name
+
def validate_html(html_or_response):
- if hasattr(html_or_response, 'body'):
- html = html_or_response.body
- else:
- html = html_or_response
+ if hasattr(html_or_response, 'body'):
+ html = html_or_response.body
+ else:
+ html = html_or_response
- html = html.lstrip()
+ html = html.lstrip()
+
+ if html.startswith('<!DOCTYPE html>'):
+ return validate_html5(html)
+ else:
+ assert False, 'Non-valid HTML: ' + html[:100] + '...'
- if html.startswith('<!DOCTYPE html>'):
- return validate_html5(html)
- else:
- assert False, 'Non-valid HTML: ' + html[:100] + '...'
def validate_json(json_or_response):
- if hasattr(json_or_response, 'body'):
- j = json_or_response.body
- else:
- j = json_or_response
+ if hasattr(json_or_response, 'body'):
+ j = json_or_response.body
+ else:
+ j = json_or_response
- try:
- obj = json.loads(j)
- except Exception, e:
- ok_(False, "Couldn't validate JSON: " + str(e) + ':' + j[:100] + '...')
+ try:
+ obj = json.loads(j)
+ except Exception, e:
+ ok_(False, "Couldn't validate JSON: " + str(e) + ':' + j[:100] + '...')
+
+ return obj
- return obj
def validate_html5(html_or_response):
- if hasattr(html_or_response, 'body'):
- html = html_or_response.body
- else:
- html = html_or_response
- register_openers()
- params = [("out","text"),("content",html)]
- datagen, headers = multipart_encode(params)
- request = urllib2.Request("http://html5.validator.nu/", datagen, headers)
- count = 3
- while True:
- try:
- resp = urllib2.urlopen(request, timeout=3).read()
+ if hasattr(html_or_response, 'body'):
+ html = html_or_response.body
+ else:
+ html = html_or_response
+ register_openers()
+ params = [("out","text"),("content",html)]
+ datagen, headers = multipart_encode(params)
+ request = urllib2.Request("http://html5.validator.nu/", datagen, headers)
+ count = 3
+ while True:
+ try:
+ resp = urllib2.urlopen(request, timeout=3).read()
+ break
+ except:
+ resp = "Couldn't connect to validation service to check the HTML"
+ count -= 1
+ if count == 0:
+ sys.stderr.write('WARNING: ' + resp + '\n')
break
- except:
- resp = "Couldn't connect to validation service to check the HTML"
- count -= 1
- if count == 0:
- sys.stderr.write('WARNING: ' + resp + '\n')
- break
-
- resp = resp.replace('“','"').replace('”','"').replace('–','-')
-
- ignored_errors = [
- 'Required attributes missing on element "object"',
- 'Stray end tag "embed".',
- 'Stray end tag "param".',
- r'Bad value .+? for attribute "onclick" on element "input": invalid return',
- ]
- for ignore in ignored_errors:
- resp = re.sub('Error: ' + ignore, 'Ignoring: ' + ignore, resp)
-
- if 'Error:' in resp:
- fname = dump_to_file('html5-', html)
- message = resp.decode('ascii','ignore')
- report_validation_error('html5', fname, message)
+
+ resp = resp.replace('“','"').replace('”','"').replace('–','-')
+
+ ignored_errors = [
+ 'Required attributes missing on element "object"',
+ 'Stray end tag "embed".',
+ 'Stray end tag "param".',
+ r'Bad value .+? for attribute "onclick" on element "input": invalid return',
+ ]
+ for ignore in ignored_errors:
+ resp = re.sub('Error: ' + ignore, 'Ignoring: ' + ignore, resp)
+
+ if 'Error:' in resp:
+ fname = dump_to_file('html5-', html)
+ message = resp.decode('ascii','ignore')
+ report_validation_error('html5', fname, message)
def validate_html5_chunk(html):
- """ When you don't have a html & body tags - this adds it"""
- # WebTest doesn't like HTML fragments without doctype,
- # so we output them sometimes for fragments, which is hack.
- # Unhack it here.
- doctype = '<!DOCTYPE html>'
- if html.startswith(doctype):
- html = html[len(doctype):]
-
- html = '''<!DOCTYPE html>
- <html>
- <head><title></title></head>
- <body>
- %s
- </body></html>''' % html
- return validate_html5(html)
+ """ When you don't have a html & body tags - this adds it"""
+ # WebTest doesn't like HTML fragments without doctype,
+ # so we output them sometimes for fragments, which is hack.
+ # Unhack it here.
+ doctype = '<!DOCTYPE html>'
+ if html.startswith(doctype):
+ html = html[len(doctype):]
+
+ html = '''<!DOCTYPE html>
+ <html>
+ <head><title></title></head>
+ <body>
+ %s
+ </body></html>''' % html
+ return validate_html5(html)
+
def validate_js(html_or_response):
- if hasattr(html_or_response, 'body'):
- if html_or_response.status_int != 200:
- return
- html = html_or_response.body
- else:
- html = html_or_response
- basedir = path.dirname(path.abspath(__file__))
- jslint_dir = basedir + '/../jslint'
- fname = dump_to_file('jslint-', html)
- cmd = 'java -jar ' + jslint_dir + '/js.jar '+ jslint_dir +'/jslint.js ' + fname
- p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- stdout, stderr = p.communicate(html)
- if stdout.startswith('jslint: No problems found'):
- os.unlink(fname)
+ if hasattr(html_or_response, 'body'):
+ if html_or_response.status_int != 200:
return
- stdout = stdout.decode('UTF-8', 'replace')
- msg = '\n'.join(repr(s) for s in stdout.split('\n') if s)
- report_validation_error('js', fname, msg)
+ html = html_or_response.body
+ else:
+ html = html_or_response
+ basedir = path.dirname(path.abspath(__file__))
+ jslint_dir = basedir + '/../jslint'
+ fname = dump_to_file('jslint-', html)
+ cmd = 'java -jar ' + jslint_dir + '/js.jar '+ jslint_dir +'/jslint.js ' + fname
+ p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ stdout, stderr = p.communicate(html)
+ if stdout.startswith('jslint: No problems found'):
+ os.unlink(fname)
+ return
+ stdout = stdout.decode('UTF-8', 'replace')
+ msg = '\n'.join(repr(s) for s in stdout.split('\n') if s)
+ report_validation_error('js', fname, msg)
+
def validate_page(html_or_response):
if Config.instance().validation_enabled('html5'):
@@ -228,6 +234,7 @@ def validate_page(html_or_response):
if Config.instance().validation_enabled('inlinejs'):
validate_js(html_or_response)
+
class AntiSpamTestApp(TestApp):
def post(self, *args, **kwargs):
[09/10] git commit: remove hardcoded hostname
Posted by br...@apache.org.
remove hardcoded hostname
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/12170190
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/12170190
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/12170190
Branch: refs/heads/db/6277
Commit: 121701902421aa39585532f0970e9ffb53b9089a
Parents: 941d83b
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Sat May 25 13:29:05 2013 -0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon May 27 15:21:29 2013 -0400
----------------------------------------------------------------------
AlluraTest/alluratest/validation.py | 12 +-----------
1 files changed, 1 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/12170190/AlluraTest/alluratest/validation.py
----------------------------------------------------------------------
diff --git a/AlluraTest/alluratest/validation.py b/AlluraTest/alluratest/validation.py
index 7a5fd0b..39f73c3 100644
--- a/AlluraTest/alluratest/validation.py
+++ b/AlluraTest/alluratest/validation.py
@@ -47,11 +47,6 @@ from ming.utils import LazyProperty
from allura.lib import utils
-ENABLE_CONTENT_VALIDATION = False
-# By default we want to run only validations which are fast,
-# but on special test hosts - all.
-COMPLETE_TESTS_HOST = 'sb-forge-4039'
-
log = logging.getLogger(__name__)
class Config(object):
@@ -93,9 +88,6 @@ class Config(object):
elif env_var is not None:
return val_type in env_var.split(',')
- if self.hostname == COMPLETE_TESTS_HOST:
- return True
-
enabled = self.test_ini.getboolean('validation', 'validate_' + val_type)
return enabled
@@ -103,9 +95,7 @@ class Config(object):
env_var = os.getenv('ALLURA_VALIDATION')
if env_var == 'all':
return True
- if self.hostname == COMPLETE_TESTS_HOST:
- return True
- return ENABLE_CONTENT_VALIDATION
+ return False
def report_validation_error(val_name, filename, message):
[06/10] [#4122] rename AlluraTesting dir to AlluraTest,
to match the module name below
Posted by br...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/jslint/fulljslint.js
----------------------------------------------------------------------
diff --git a/AlluraTest/jslint/fulljslint.js b/AlluraTest/jslint/fulljslint.js
new file mode 100644
index 0000000..0bf59bb
--- /dev/null
+++ b/AlluraTest/jslint/fulljslint.js
@@ -0,0 +1,5688 @@
+// jslint.js
+// 2010-08-05
+
+/*
+Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+/*
+ JSLINT is a global function. It takes two parameters.
+
+ var myResult = JSLINT(source, option);
+
+ The first parameter is either a string or an array of strings. If it is a
+ string, it will be split on '\n' or '\r'. If it is an array of strings, it
+ is assumed that each string represents one line. The source can be a
+ JavaScript text, or HTML text, or a Konfabulator text.
+
+ The second parameter is an optional object of options which control the
+ operation of JSLINT. Most of the options are booleans: They are all are
+ optional and have a default value of false.
+
+ If it checks out, JSLINT returns true. Otherwise, it returns false.
+
+ If false, you can inspect JSLINT.errors to find out the problems.
+ JSLINT.errors is an array of objects containing these members:
+
+ {
+ line : The line (relative to 0) at which the lint was found
+ character : The character (relative to 0) at which the lint was found
+ reason : The problem
+ evidence : The text line in which the problem occurred
+ raw : The raw message before the details were inserted
+ a : The first detail
+ b : The second detail
+ c : The third detail
+ d : The fourth detail
+ }
+
+ If a fatal error was found, a null will be the last element of the
+ JSLINT.errors array.
+
+ You can request a Function Report, which shows all of the functions
+ and the parameters and vars that they use. This can be used to find
+ implied global variables and other problems. The report is in HTML and
+ can be inserted in an HTML <body>.
+
+ var myReport = JSLINT.report(limited);
+
+ If limited is true, then the report will be limited to only errors.
+
+ You can request a data structure which contains JSLint's results.
+
+ var myData = JSLINT.data();
+
+ It returns a structure with this form:
+
+ {
+ errors: [
+ {
+ line: NUMBER,
+ character: NUMBER,
+ reason: STRING,
+ evidence: STRING
+ }
+ ],
+ functions: [
+ name: STRING,
+ line: NUMBER,
+ last: NUMBER,
+ param: [
+ STRING
+ ],
+ closure: [
+ STRING
+ ],
+ var: [
+ STRING
+ ],
+ exception: [
+ STRING
+ ],
+ outer: [
+ STRING
+ ],
+ unused: [
+ STRING
+ ],
+ global: [
+ STRING
+ ],
+ label: [
+ STRING
+ ]
+ ],
+ globals: [
+ STRING
+ ],
+ member: {
+ STRING: NUMBER
+ },
+ unuseds: [
+ {
+ name: STRING,
+ line: NUMBER
+ }
+ ],
+ implieds: [
+ {
+ name: STRING,
+ line: NUMBER
+ }
+ ],
+ urls: [
+ STRING
+ ],
+ json: BOOLEAN
+ }
+
+ Empty arrays will not be included.
+
+*/
+
+/*jslint
+ evil: true, nomen: false, onevar: false, regexp: false, strict: true
+*/
+
+/*members "\b", "\t", "\n", "\f", "\r", "!=", "!==", "\"", "%",
+ "(begin)", "(breakage)", "(context)", "(error)", "(global)",
+ "(identifier)", "(last)", "(line)", "(loopage)", "(name)", "(onevar)",
+ "(params)", "(scope)", "(verb)", "*", "+", "++", "-", "--", "\/",
+ "<", "<=", "==", "===", ">", ">=", ADSAFE, ActiveXObject,
+ Array, Boolean, COM, CScript, Canvas, CustomAnimation, Date, Debug, E,
+ Enumerator, Error, EvalError, FadeAnimation, Flash, FormField, Frame,
+ Function, HotKey, Image, JSON, LN10, LN2, LOG10E, LOG2E, MAX_VALUE,
+ MIN_VALUE, Math, MenuItem, MoveAnimation, NEGATIVE_INFINITY, Number,
+ Object, Option, PI, POSITIVE_INFINITY, Point, RangeError, Rectangle,
+ ReferenceError, RegExp, ResizeAnimation, RotateAnimation, SQRT1_2,
+ SQRT2, ScrollBar, String, Style, SyntaxError, System, Text, TextArea,
+ Timer, TypeError, URIError, URL, VBArray, WScript, Web, Window, XMLDOM,
+ XMLHttpRequest, "\\", a, abbr, acronym, addEventListener, address,
+ adsafe, alert, aliceblue, animator, antiquewhite, appleScript, applet,
+ apply, approved, aqua, aquamarine, area, arguments, arity, article,
+ aside, audio, autocomplete, azure, b, background,
+ "background-attachment", "background-color", "background-image",
+ "background-position", "background-repeat", base, bdo, beep, beige, big,
+ bisque, bitwise, black, blanchedalmond, block, blockquote, blue,
+ blueviolet, blur, body, border, "border-bottom", "border-bottom-color",
+ "border-bottom-style", "border-bottom-width", "border-collapse",
+ "border-color", "border-left", "border-left-color", "border-left-style",
+ "border-left-width", "border-right", "border-right-color",
+ "border-right-style", "border-right-width", "border-spacing",
+ "border-style", "border-top", "border-top-color", "border-top-style",
+ "border-top-width", "border-width", bottom, br, brown, browser,
+ burlywood, button, bytesToUIString, c, cadetblue, call, callee, caller,
+ canvas, cap, caption, "caption-side", cases, center, charAt, charCodeAt,
+ character, chartreuse, chocolate, chooseColor, chooseFile, chooseFolder,
+ cite, clear, clearInterval, clearTimeout, clip, close, closeWidget,
+ closed, closure, cm, code, col, colgroup, color, command, comment,
+ condition, confirm, console, constructor, content, convertPathToHFS,
+ convertPathToPlatform, coral, cornflowerblue, cornsilk,
+ "counter-increment", "counter-reset", create, crimson, css, cursor,
+ cyan, d, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen,
+ darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred,
+ darksalmon, darkseagreen, darkslateblue, darkslategray, darkturquoise,
+ darkviolet, data, datalist, dd, debug, decodeURI, decodeURIComponent,
+ deeppink, deepskyblue, defaultStatus, defineClass, del, deserialize,
+ details, devel, dfn, dialog, dimension, dimgray, dir, direction,
+ display, div, dl, document, dodgerblue, dt, edition, else, em, embed,
+ empty, "empty-cells", encodeURI, encodeURIComponent, entityify, eqeqeq,
+ errors, es5, escape, eval, event, evidence, evil, ex, exception, exec, exps,
+ fieldset, figure, filesystem, firebrick, first, float, floor,
+ floralwhite, focus, focusWidget, font, "font-face", "font-family",
+ "font-size", "font-size-adjust", "font-stretch", "font-style",
+ "font-variant", "font-weight", footer, forestgreen, forin, form,
+ fragment, frame, frames, frameset, from, fromCharCode, fuchsia, fud,
+ funct, function, functions, g, gainsboro, gc, getComputedStyle,
+ ghostwhite, global, globals, gold, goldenrod, gray, green, greenyellow,
+ h1, h2, h3, h4, h5, h6, hasOwnProperty, head, header, height, help,
+ hgroup, history, honeydew, hotpink, hr, 'hta:application', html,
+ i, iTunes, id, identifier,
+ iframe, img, immed, implieds, in, include, indent, indexOf, indianred,
+ indigo, init, input, ins, isAlpha, isApplicationRunning, isDigit,
+ isFinite, isNaN, ivory, join, jslint, json, kbd, keygen, khaki,
+ konfabulatorVersion, label, labelled, lang, last, lavender,
+ lavenderblush, lawngreen, laxbreak, lbp, led, left, legend,
+ lemonchiffon, length, "letter-spacing", li, lib, lightblue, lightcoral,
+ lightcyan, lightgoldenrodyellow, lightgreen, lightpink, lightsalmon,
+ lightseagreen, lightskyblue, lightslategray, lightsteelblue,
+ lightyellow, lime, limegreen, line, "line-height", linen, link,
+ "list-style", "list-style-image", "list-style-position",
+ "list-style-type", load, loadClass, location, log, m, magenta, map,
+ margin, "margin-bottom", "margin-left", "margin-right", "margin-top",
+ mark, "marker-offset", maroon, match, "max-height", "max-width", maxerr,
+ maxlen, md5, media, mediumaquamarine, mediumblue, mediumorchid,
+ mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen,
+ mediumturquoise, mediumvioletred, member, menu, message, meta, meter,
+ midnightblue, "min-height", "min-width", mintcream, mistyrose, mm,
+ moccasin, moveBy, moveTo, name, nav, navajowhite, navigator, navy, new,
+ newcap, noframes, nomen, noscript, nud, object, ol, oldlace, olive,
+ olivedrab, on, onbeforeunload, onblur, onerror, onevar, onfocus, onload,
+ onresize, onunload, opacity, open, openURL, opener, opera, optgroup,
+ option, orange, orangered, orchid, outer, outline, "outline-color",
+ "outline-style", "outline-width", output, overflow, "overflow-x",
+ "overflow-y", p, padding, "padding-bottom", "padding-left",
+ "padding-right", "padding-top", page, "page-break-after",
+ "page-break-before", palegoldenrod, palegreen, paleturquoise,
+ palevioletred, papayawhip, param, parent, parseFloat, parseInt,
+ passfail, pc, peachpuff, peru, pink, play, plum, plusplus, pop,
+ popupMenu, position, powderblue, pre, predef, preferenceGroups,
+ preferences, print, progress, prompt, prototype, pt, purple, push, px,
+ q, quit, quotes, random, range, raw, reach, readFile, readUrl, reason,
+ red, regexp, reloadWidget, removeEventListener, replace, report,
+ reserved, resizeBy, resizeTo, resolvePath, resumeUpdates, rhino, right,
+ rosybrown, royalblue, rp, rt, ruby, runCommand, runCommandInBg,
+ saddlebrown, safe, salmon, samp, sandybrown, saveAs, savePreferences,
+ screen, script, scroll, scrollBy, scrollTo, seagreen, seal, search,
+ seashell, section, select, serialize, setInterval, setTimeout, shift,
+ showWidgetPreferences, sienna, silver, skyblue, slateblue, slategray,
+ sleep, slice, small, snow, sort, source, span, spawn, speak, split,
+ springgreen, src, stack, status, steelblue, strict, strong, style,
+ styleproperty, sub, substr, sup, supplant, suppressUpdates, sync,
+ system, table, "table-layout", tan, tbody, td, teal, tellWidget, test,
+ "text-align", "text-decoration", "text-indent", "text-shadow",
+ "text-transform", textarea, tfoot, th, thead, thistle, time, title,
+ toLowerCase, toString, toUpperCase, toint32, token, tomato, top, tr, tt,
+ turquoise, type, u, ul, undef, unescape, "unicode-bidi", unused,
+ unwatch, updateNow, urls, value, valueOf, var, version,
+ "vertical-align", video, violet, visibility, watch, wheat, white,
+ "white-space", whitesmoke, widget, width, windows, "word-spacing",
+ "word-wrap", yahooCheckLogin, yahooLogin, yahooLogout, yellow,
+ yellowgreen, "z-index"
+*/
+
+// We build the application inside a function so that we produce only a single
+// global variable. The function will be invoked, its return value is the JSLINT
+// application itself.
+
+"use strict";
+
+var JSLINT = (function () {
+ var adsafe_id, // The widget's ADsafe id.
+ adsafe_may, // The widget may load approved scripts.
+ adsafe_went, // ADSAFE.go has been called.
+ anonname, // The guessed name for anonymous functions.
+ approved, // ADsafe approved urls.
+
+ atrule = {
+ media : true,
+ 'font-face': true,
+ page : true
+ },
+
+// These are operators that should not be used with the ! operator.
+
+ bang = {
+ '<': true,
+ '<=': true,
+ '==': true,
+ '===': true,
+ '!==': true,
+ '!=': true,
+ '>': true,
+ '>=': true,
+ '+': true,
+ '-': true,
+ '*': true,
+ '/': true,
+ '%': true
+ },
+
+// These are members that should not be permitted in the safe subset.
+
+ banned = { // the member names that ADsafe prohibits.
+ 'arguments' : true,
+ callee : true,
+ caller : true,
+ constructor : true,
+ 'eval' : true,
+ prototype : true,
+ stack : true,
+ unwatch : true,
+ valueOf : true,
+ watch : true
+ },
+
+
+// These are the JSLint boolean options.
+
+ boolOptions = {
+ adsafe : true, // if ADsafe should be enforced
+ bitwise : true, // if bitwise operators should not be allowed
+ browser : true, // if the standard browser globals should be predefined
+ cap : true, // if upper case HTML should be allowed
+ css : true, // if CSS workarounds should be tolerated
+ debug : true, // if debugger statements should be allowed
+ devel : true, // if logging should be allowed (console, alert, etc.)
+ eqeqeq : true, // if === should be required
+ es5 : true, // if ES5 syntax should be allowed
+ evil : true, // if eval should be allowed
+ forin : true, // if for in statements must filter
+ fragment : true, // if HTML fragments should be allowed
+ immed : true, // if immediate invocations must be wrapped in parens
+ laxbreak : true, // if line breaks should not be checked
+ newcap : true, // if constructor names must be capitalized
+ nomen : true, // if names should be checked
+ on : true, // if HTML event handlers should be allowed
+ onevar : true, // if only one var statement per function should be allowed
+ passfail : true, // if the scan should stop on first error
+ plusplus : true, // if increment/decrement should not be allowed
+ regexp : true, // if the . should not be allowed in regexp literals
+ rhino : true, // if the Rhino environment globals should be predefined
+ undef : true, // if variables should be declared before used
+ safe : true, // if use of some browser features should be restricted
+ windows : true, // if MS Windows-specigic globals should be predefined
+ strict : true, // require the "use strict"; pragma
+ sub : true, // if all forms of subscript notation are tolerated
+ white : true, // if strict whitespace rules apply
+ widget : true // if the Yahoo Widgets globals should be predefined
+ },
+
+// browser contains a set of global names which are commonly provided by a
+// web browser environment.
+
+ browser = {
+ addEventListener: false,
+ blur : false,
+ clearInterval : false,
+ clearTimeout : false,
+ close : false,
+ closed : false,
+ defaultStatus : false,
+ document : false,
+ event : false,
+ focus : false,
+ frames : false,
+ getComputedStyle: false,
+ history : false,
+ Image : false,
+ length : false,
+ location : false,
+ moveBy : false,
+ moveTo : false,
+ name : false,
+ navigator : false,
+ onbeforeunload : true,
+ onblur : true,
+ onerror : true,
+ onfocus : true,
+ onload : true,
+ onresize : true,
+ onunload : true,
+ open : false,
+ opener : false,
+ Option : false,
+ parent : false,
+ print : false,
+ removeEventListener: false,
+ resizeBy : false,
+ resizeTo : false,
+ screen : false,
+ scroll : false,
+ scrollBy : false,
+ scrollTo : false,
+ setInterval : false,
+ setTimeout : false,
+ status : false,
+ top : false,
+ XMLHttpRequest : false
+ },
+
+ cssAttributeData,
+ cssAny,
+
+ cssColorData = {
+ "aliceblue" : true,
+ "antiquewhite" : true,
+ "aqua" : true,
+ "aquamarine" : true,
+ "azure" : true,
+ "beige" : true,
+ "bisque" : true,
+ "black" : true,
+ "blanchedalmond" : true,
+ "blue" : true,
+ "blueviolet" : true,
+ "brown" : true,
+ "burlywood" : true,
+ "cadetblue" : true,
+ "chartreuse" : true,
+ "chocolate" : true,
+ "coral" : true,
+ "cornflowerblue" : true,
+ "cornsilk" : true,
+ "crimson" : true,
+ "cyan" : true,
+ "darkblue" : true,
+ "darkcyan" : true,
+ "darkgoldenrod" : true,
+ "darkgray" : true,
+ "darkgreen" : true,
+ "darkkhaki" : true,
+ "darkmagenta" : true,
+ "darkolivegreen" : true,
+ "darkorange" : true,
+ "darkorchid" : true,
+ "darkred" : true,
+ "darksalmon" : true,
+ "darkseagreen" : true,
+ "darkslateblue" : true,
+ "darkslategray" : true,
+ "darkturquoise" : true,
+ "darkviolet" : true,
+ "deeppink" : true,
+ "deepskyblue" : true,
+ "dimgray" : true,
+ "dodgerblue" : true,
+ "firebrick" : true,
+ "floralwhite" : true,
+ "forestgreen" : true,
+ "fuchsia" : true,
+ "gainsboro" : true,
+ "ghostwhite" : true,
+ "gold" : true,
+ "goldenrod" : true,
+ "gray" : true,
+ "green" : true,
+ "greenyellow" : true,
+ "honeydew" : true,
+ "hotpink" : true,
+ "indianred" : true,
+ "indigo" : true,
+ "ivory" : true,
+ "khaki" : true,
+ "lavender" : true,
+ "lavenderblush" : true,
+ "lawngreen" : true,
+ "lemonchiffon" : true,
+ "lightblue" : true,
+ "lightcoral" : true,
+ "lightcyan" : true,
+ "lightgoldenrodyellow" : true,
+ "lightgreen" : true,
+ "lightpink" : true,
+ "lightsalmon" : true,
+ "lightseagreen" : true,
+ "lightskyblue" : true,
+ "lightslategray" : true,
+ "lightsteelblue" : true,
+ "lightyellow" : true,
+ "lime" : true,
+ "limegreen" : true,
+ "linen" : true,
+ "magenta" : true,
+ "maroon" : true,
+ "mediumaquamarine" : true,
+ "mediumblue" : true,
+ "mediumorchid" : true,
+ "mediumpurple" : true,
+ "mediumseagreen" : true,
+ "mediumslateblue" : true,
+ "mediumspringgreen" : true,
+ "mediumturquoise" : true,
+ "mediumvioletred" : true,
+ "midnightblue" : true,
+ "mintcream" : true,
+ "mistyrose" : true,
+ "moccasin" : true,
+ "navajowhite" : true,
+ "navy" : true,
+ "oldlace" : true,
+ "olive" : true,
+ "olivedrab" : true,
+ "orange" : true,
+ "orangered" : true,
+ "orchid" : true,
+ "palegoldenrod" : true,
+ "palegreen" : true,
+ "paleturquoise" : true,
+ "palevioletred" : true,
+ "papayawhip" : true,
+ "peachpuff" : true,
+ "peru" : true,
+ "pink" : true,
+ "plum" : true,
+ "powderblue" : true,
+ "purple" : true,
+ "red" : true,
+ "rosybrown" : true,
+ "royalblue" : true,
+ "saddlebrown" : true,
+ "salmon" : true,
+ "sandybrown" : true,
+ "seagreen" : true,
+ "seashell" : true,
+ "sienna" : true,
+ "silver" : true,
+ "skyblue" : true,
+ "slateblue" : true,
+ "slategray" : true,
+ "snow" : true,
+ "springgreen" : true,
+ "steelblue" : true,
+ "tan" : true,
+ "teal" : true,
+ "thistle" : true,
+ "tomato" : true,
+ "turquoise" : true,
+ "violet" : true,
+ "wheat" : true,
+ "white" : true,
+ "whitesmoke" : true,
+ "yellow" : true,
+ "yellowgreen" : true
+ },
+
+ cssBorderStyle,
+ cssBreak,
+
+ cssLengthData = {
+ '%': true,
+ 'cm': true,
+ 'em': true,
+ 'ex': true,
+ 'in': true,
+ 'mm': true,
+ 'pc': true,
+ 'pt': true,
+ 'px': true
+ },
+
+ cssOverflow,
+
+ devel = {
+ alert : false,
+ confirm : false,
+ console : false,
+ Debug : false,
+ opera : false,
+ prompt : false
+ },
+
+ escapes = {
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '/' : '\\/',
+ '\\': '\\\\'
+ },
+
+ funct, // The current function
+
+ functionicity = [
+ 'closure', 'exception', 'global', 'label',
+ 'outer', 'unused', 'var'
+ ],
+
+ functions, // All of the functions
+
+ global, // The global scope
+ htmltag = {
+ a: {},
+ abbr: {},
+ acronym: {},
+ address: {},
+ applet: {},
+ area: {empty: true, parent: ' map '},
+ article: {},
+ aside: {},
+ audio: {},
+ b: {},
+ base: {empty: true, parent: ' head '},
+ bdo: {},
+ big: {},
+ blockquote: {},
+ body: {parent: ' html noframes '},
+ br: {empty: true},
+ button: {},
+ canvas: {parent: ' body p div th td '},
+ caption: {parent: ' table '},
+ center: {},
+ cite: {},
+ code: {},
+ col: {empty: true, parent: ' table colgroup '},
+ colgroup: {parent: ' table '},
+ command: {parent: ' menu '},
+ datalist: {},
+ dd: {parent: ' dl '},
+ del: {},
+ details: {},
+ dialog: {},
+ dfn: {},
+ dir: {},
+ div: {},
+ dl: {},
+ dt: {parent: ' dl '},
+ em: {},
+ embed: {},
+ fieldset: {},
+ figure: {},
+ font: {},
+ footer: {},
+ form: {},
+ frame: {empty: true, parent: ' frameset '},
+ frameset: {parent: ' html frameset '},
+ h1: {},
+ h2: {},
+ h3: {},
+ h4: {},
+ h5: {},
+ h6: {},
+ head: {parent: ' html '},
+ header: {},
+ hgroup: {},
+ hr: {empty: true},
+ 'hta:application':
+ {empty: true, parent: ' head '},
+ html: {parent: '*'},
+ i: {},
+ iframe: {},
+ img: {empty: true},
+ input: {empty: true},
+ ins: {},
+ kbd: {},
+ keygen: {},
+ label: {},
+ legend: {parent: ' details fieldset figure '},
+ li: {parent: ' dir menu ol ul '},
+ link: {empty: true, parent: ' head '},
+ map: {},
+ mark: {},
+ menu: {},
+ meta: {empty: true, parent: ' head noframes noscript '},
+ meter: {},
+ nav: {},
+ noframes: {parent: ' html body '},
+ noscript: {},
+ object: {},
+ ol: {},
+ optgroup: {parent: ' select '},
+ option: {parent: ' optgroup select '},
+ output: {},
+ p: {},
+ param: {parent: ' applet object '},
+ pre: {},
+ progress: {},
+ q: {},
+ rp: {},
+ rt: {},
+ ruby: {},
+ s: {},
+ samp: {},
+ script: {empty: true, parent: ' body div frame head iframe p pre span '},
+ section: {},
+ select: {},
+ small: {},
+ span: {},
+ source: {},
+ strong: {},
+ style: {parent: ' head ', empty: true},
+ sub: {},
+ sup: {},
+ table: {},
+ tbody: {parent: ' table '},
+ td: {parent: ' tr '},
+ textarea: {},
+ tfoot: {parent: ' table '},
+ th: {parent: ' tr '},
+ thead: {parent: ' table '},
+ time: {},
+ title: {parent: ' head '},
+ tr: {parent: ' table tbody thead tfoot '},
+ tt: {},
+ u: {},
+ ul: {},
+ 'var': {},
+ video: {}
+ },
+
+ ids, // HTML ids
+ implied, // Implied globals
+ inblock,
+ indent,
+ jsonmode,
+ lines,
+ lookahead,
+ member,
+ membersOnly,
+ nexttoken,
+ noreach,
+ option,
+ predefined, // Global variables defined by option
+ prereg,
+ prevtoken,
+
+ rhino = {
+ defineClass : false,
+ deserialize : false,
+ gc : false,
+ help : false,
+ load : false,
+ loadClass : false,
+ print : false,
+ quit : false,
+ readFile : false,
+ readUrl : false,
+ runCommand : false,
+ seal : false,
+ serialize : false,
+ spawn : false,
+ sync : false,
+ toint32 : false,
+ version : false
+ },
+
+ scope, // The current scope
+
+ windows = {
+ ActiveXObject: false,
+ CScript : false,
+ Debug : false,
+ Enumerator : false,
+ System : false,
+ VBArray : false,
+ WScript : false
+ },
+
+ src,
+ stack,
+
+// standard contains the global names that are provided by the
+// ECMAScript standard.
+
+ standard = {
+ 'void' : false,
+ Array : false,
+ Boolean : false,
+ Date : false,
+ decodeURI : false,
+ decodeURIComponent : false,
+ encodeURI : false,
+ encodeURIComponent : false,
+ Error : false,
+ 'eval' : false,
+ EvalError : false,
+ Function : false,
+ hasOwnProperty : false,
+ isFinite : false,
+ isNaN : false,
+ JSON : false,
+ Math : false,
+ Number : false,
+ Object : false,
+ parseInt : false,
+ parseFloat : false,
+ RangeError : false,
+ ReferenceError : false,
+ RegExp : false,
+ String : false,
+ SyntaxError : false,
+ TypeError : false,
+ URIError : false
+ },
+
+ standard_member = {
+ E : true,
+ LN2 : true,
+ LN10 : true,
+ LOG2E : true,
+ LOG10E : true,
+ PI : true,
+ SQRT1_2 : true,
+ SQRT2 : true,
+ MAX_VALUE : true,
+ MIN_VALUE : true,
+ NEGATIVE_INFINITY : true,
+ POSITIVE_INFINITY : true
+ },
+
+ strict_mode,
+ syntax = {},
+ tab,
+ token,
+ urls,
+ warnings,
+
+// widget contains the global names which are provided to a Yahoo
+// (fna Konfabulator) widget.
+
+ widget = {
+ alert : true,
+ animator : true,
+ appleScript : true,
+ beep : true,
+ bytesToUIString : true,
+ Canvas : true,
+ chooseColor : true,
+ chooseFile : true,
+ chooseFolder : true,
+ closeWidget : true,
+ COM : true,
+ convertPathToHFS : true,
+ convertPathToPlatform : true,
+ CustomAnimation : true,
+ escape : true,
+ FadeAnimation : true,
+ filesystem : true,
+ Flash : true,
+ focusWidget : true,
+ form : true,
+ FormField : true,
+ Frame : true,
+ HotKey : true,
+ Image : true,
+ include : true,
+ isApplicationRunning : true,
+ iTunes : true,
+ konfabulatorVersion : true,
+ log : true,
+ md5 : true,
+ MenuItem : true,
+ MoveAnimation : true,
+ openURL : true,
+ play : true,
+ Point : true,
+ popupMenu : true,
+ preferenceGroups : true,
+ preferences : true,
+ print : true,
+ prompt : true,
+ random : true,
+ Rectangle : true,
+ reloadWidget : true,
+ ResizeAnimation : true,
+ resolvePath : true,
+ resumeUpdates : true,
+ RotateAnimation : true,
+ runCommand : true,
+ runCommandInBg : true,
+ saveAs : true,
+ savePreferences : true,
+ screen : true,
+ ScrollBar : true,
+ showWidgetPreferences : true,
+ sleep : true,
+ speak : true,
+ Style : true,
+ suppressUpdates : true,
+ system : true,
+ tellWidget : true,
+ Text : true,
+ TextArea : true,
+ Timer : true,
+ unescape : true,
+ updateNow : true,
+ URL : true,
+ Web : true,
+ widget : true,
+ Window : true,
+ XMLDOM : true,
+ XMLHttpRequest : true,
+ yahooCheckLogin : true,
+ yahooLogin : true,
+ yahooLogout : true
+ },
+
+// xmode is used to adapt to the exceptions in html parsing.
+// It can have these states:
+// false .js script file
+// html
+// outer
+// script
+// style
+// scriptstring
+// styleproperty
+
+ xmode,
+ xquote,
+
+// unsafe comment or string
+ ax = /@cc|<\/?|script|\]*s\]|<\s*!|</i,
+// unsafe characters that are silently deleted by one or more browsers
+// Whitelist Replacement Char, 0xfffd
+ cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\ufffc\ufffe-\uffff]/,
+// token
+ tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jslint|members?|global)?|=|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/,
+// html token
+ hx = /^\s*(['"=>\/&#]|<(?:\/|\!(?:--)?)?|[a-zA-Z][a-zA-Z0-9_\-:]*|[0-9]+|--)/,
+// characters in strings that need escapement
+ nx = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
+ nxg = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+// outer html token
+ ox = /[>&]|<[\/!]?|--/,
+// star slash
+ lx = /\*\/|\/\*/,
+// identifier
+ ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/,
+// javascript url
+ jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i,
+// url badness
+ ux = /&|\+|\u00AD|\.\.|\/\*|%[^;]|base64|url|expression|data|mailto/i,
+// style
+ sx = /^\s*([{:#%.=,>+\[\]@()"';]|\*=?|\$=|\|=|\^=|~=|[a-zA-Z_][a-zA-Z0-9_\-]*|[0-9]+|<\/|\/\*)/,
+ ssx = /^\s*(\.?\d+(?:\.\d+)?|[@#!"'};:\-%.=,+\[\]()*_]|[a-zA-Z][a-zA-Z0-9._\-]*|\/\*?|<\/)/,
+// attributes characters
+ //qx = /[^a-zA-Z0-9+\-_\/ ]/,
+ qx = /[^a-zA-Z0-9+\-_\/ .#]/, // We want dots in names, period; and hashes for templating
+// query characters for ids
+ //dx = /[\[\]\/\\"'*<>.&:(){}+=#]/,
+ // allow . and /
+ dx = /[\[\]\\"'*<>&:(){}+=#]/,
+
+ rx = {
+ outer: hx,
+ html: hx,
+ style: sx,
+ styleproperty: ssx
+ };
+
+ function F() {}
+
+ if (typeof Object.create !== 'function') {
+ Object.create = function (o) {
+ F.prototype = o;
+ return new F();
+ };
+ }
+
+
+ function is_own(object, name) {
+ return Object.prototype.hasOwnProperty.call(object, name);
+ }
+
+
+ function combine(t, o) {
+ var n;
+ for (n in o) {
+ if (is_own(o, n)) {
+ t[n] = o[n];
+ }
+ }
+ }
+
+ String.prototype.entityify = function () {
+ return this.
+ replace(/&/g, '&').
+ replace(/</g, '<').
+ replace(/>/g, '>');
+ };
+
+ String.prototype.isAlpha = function () {
+ return (this >= 'a' && this <= 'z\uffff') ||
+ (this >= 'A' && this <= 'Z\uffff');
+ };
+
+
+ String.prototype.isDigit = function () {
+ return (this >= '0' && this <= '9');
+ };
+
+
+ String.prototype.supplant = function (o) {
+ return this.replace(/\{([^{}]*)\}/g, function (a, b) {
+ var r = o[b];
+ return typeof r === 'string' || typeof r === 'number' ? r : a;
+ });
+ };
+
+ String.prototype.name = function () {
+
+// If the string looks like an identifier, then we can return it as is.
+// If the string contains no control characters, no quote characters, and no
+// backslash characters, then we can simply slap some quotes around it.
+// Otherwise we must also replace the offending characters with safe
+// sequences.
+
+ if (ix.test(this)) {
+ return this;
+ }
+ if (nx.test(this)) {
+ return '"' + this.replace(nxg, function (a) {
+ var c = escapes[a];
+ if (c) {
+ return c;
+ }
+ return '\\u' + ('0000' + a.charCodeAt().toString(16)).slice(-4);
+ }) + '"';
+ }
+ return '"' + this + '"';
+ };
+
+
+ function assume() {
+ if (!option.safe) {
+ if (option.rhino) {
+ combine(predefined, rhino);
+ }
+ if (option.devel) {
+ combine(predefined, devel);
+ }
+ if (option.browser) {
+ combine(predefined, browser);
+ }
+ if (option.windows) {
+ combine(predefined, windows);
+ }
+ if (option.widget) {
+ combine(predefined, widget);
+ }
+ }
+ }
+
+
+// Produce an error warning.
+
+ function quit(m, l, ch) {
+ throw {
+ name: 'JSLintError',
+ line: l,
+ character: ch,
+ message: m + " (" + Math.floor((l / lines.length) * 100) +
+ "% scanned)."
+ };
+ }
+
+ function warning(m, t, a, b, c, d) {
+ var ch, l, w;
+ t = t || nexttoken;
+ if (t.id === '(end)') { // `~
+ t = token;
+ }
+ l = t.line || 0;
+ ch = t.from || 0;
+ w = {
+ id: '(error)',
+ raw: m,
+ evidence: lines[l - 1] || '',
+ line: l,
+ character: ch,
+ a: a,
+ b: b,
+ c: c,
+ d: d
+ };
+ w.reason = m.supplant(w);
+ JSLINT.errors.push(w);
+ if (option.passfail) {
+ quit('Stopping. ', l, ch);
+ }
+ warnings += 1;
+ if (warnings >= option.maxerr) {
+ quit("Too many errors.", l, ch);
+ }
+ return w;
+ }
+
+ function warningAt(m, l, ch, a, b, c, d) {
+ return warning(m, {
+ line: l,
+ from: ch
+ }, a, b, c, d);
+ }
+
+ function error(m, t, a, b, c, d) {
+ var w = warning(m, t, a, b, c, d);
+ quit("Stopping, unable to continue.", w.line, w.character);
+ }
+
+ function errorAt(m, l, ch, a, b, c, d) {
+ return error(m, {
+ line: l,
+ from: ch
+ }, a, b, c, d);
+ }
+
+
+
+// lexical analysis
+
+ var lex = (function lex() {
+ var character, from, line, s;
+
+// Private lex methods
+
+ function nextLine() {
+ var at;
+ if (line >= lines.length) {
+ return false;
+ }
+ character = 1;
+ s = lines[line];
+ line += 1;
+ at = s.search(/ \t/);
+ if (at >= 0) {
+ warningAt("Mixed spaces and tabs.", line, at + 1);
+ }
+ s = s.replace(/\t/g, tab);
+ at = s.search(cx);
+ if (at >= 0) {
+ warningAt("Unsafe character.", line, at);
+ }
+ if (option.maxlen && option.maxlen < s.length) {
+ warningAt("Line too long.", line, s.length);
+ }
+ return true;
+ }
+
+// Produce a token object. The token inherits from a syntax symbol.
+
+ function it(type, value) {
+ var i, t;
+ if (type === '(color)') {
+ t = {type: type};
+ } else if (type === '(punctuator)' ||
+ (type === '(identifier)' && is_own(syntax, value))) {
+ t = syntax[value] || syntax['(error)'];
+ } else {
+ t = syntax[type];
+ }
+ t = Object.create(t);
+ if (type === '(string)' || type === '(range)') {
+ if (jx.test(value)) {
+ warningAt("Script URL.", line, from);
+ }
+ }
+ if (type === '(identifier)') {
+ t.identifier = true;
+ if (value === '__iterator__' || value === '__proto__') {
+ errorAt("Reserved name '{a}'.",
+ line, from, value);
+ } else if (option.nomen &&
+ (value.charAt(0) === '_' ||
+ value.charAt(value.length - 1) === '_')) {
+ warningAt("Unexpected {a} in '{b}'.", line, from,
+ "dangling '_'", value);
+ }
+ }
+ t.value = value;
+ t.line = line;
+ t.character = character;
+ t.from = from;
+ i = t.id;
+ if (i !== '(endline)') {
+ prereg = i &&
+ (('(,=:[!&|?{};'.indexOf(i.charAt(i.length - 1)) >= 0) ||
+ i === 'return');
+ }
+ return t;
+ }
+
+// Public lex methods
+
+ return {
+ init: function (source) {
+ if (typeof source === 'string') {
+ lines = source.
+ replace(/\r\n/g, '\n').
+ replace(/\r/g, '\n').
+ split('\n');
+ } else {
+ lines = source;
+ }
+ line = 0;
+ nextLine();
+ from = 1;
+ },
+
+ range: function (begin, end) {
+ var c, value = '';
+ from = character;
+ if (s.charAt(0) !== begin) {
+ errorAt("Expected '{a}' and instead saw '{b}'.",
+ line, character, begin, s.charAt(0));
+ }
+ for (;;) {
+ s = s.slice(1);
+ character += 1;
+ c = s.charAt(0);
+ switch (c) {
+ case '':
+ errorAt("Missing '{a}'.", line, character, c);
+ break;
+ case end:
+ s = s.slice(1);
+ character += 1;
+ return it('(range)', value);
+ case xquote:
+ case '\\':
+ warningAt("Unexpected '{a}'.", line, character, c);
+ }
+ value += c;
+ }
+
+ },
+
+// skip all content up to marker
+
+ skip_till: function (end) {
+ for (;;) {
+ i = s.indexOf(end);
+ if (i >= 0) {
+ break;
+ }
+ if (!nextLine()) {
+ errorAt("Unclosed {a} block.", line, character, end);
+ }
+ }
+ character += i;
+ s = s.substr(i);
+ },
+
+// token -- this is called by advance to get the next token.
+
+ token: function () {
+ var b, c, captures, d, depth, high, i, l, low, q, t;
+
+ function match(x) {
+ var r = x.exec(s), r1;
+ if (r) {
+ l = r[0].length;
+ r1 = r[1];
+ c = r1.charAt(0);
+ s = s.substr(l);
+ from = character + l - r1.length;
+ character += l;
+ return r1;
+ }
+ }
+
+ function string(x) {
+ var c, j, r = '';
+
+ if (jsonmode && x !== '"') {
+ warningAt("Strings must use doublequote.",
+ line, character);
+ }
+
+ if (xquote === x || (xmode === 'scriptstring' && !xquote)) {
+ return it('(punctuator)', x);
+ }
+
+ function esc(n) {
+ var i = parseInt(s.substr(j + 1, n), 16);
+ j += n;
+ if (i >= 32 && i <= 126 &&
+ i !== 34 && i !== 92 && i !== 39) {
+ warningAt("Unnecessary escapement.", line, character);
+ }
+ character += n;
+ c = String.fromCharCode(i);
+ }
+ j = 0;
+ for (;;) {
+ while (j >= s.length) {
+ j = 0;
+ if (xmode !== 'html' || !nextLine()) {
+ errorAt("Unclosed string.", line, from);
+ }
+ }
+ c = s.charAt(j);
+ if (c === x) {
+ character += 1;
+ s = s.substr(j + 1);
+ return it('(string)', r, x);
+ }
+ if (c < ' ') {
+ if (c === '\n' || c === '\r') {
+ break;
+ }
+ warningAt("Control character in string: {a}.",
+ line, character + j, s.slice(0, j));
+ } else if (c === xquote) {
+ warningAt("Bad HTML string", line, character + j);
+ } else if (c === '<') {
+ if (option.safe && xmode === 'html') {
+ warningAt("ADsafe string violation.",
+ line, character + j);
+ } else if (s.charAt(j + 1) === '/' && (xmode || option.safe) && s.substr(j + 2, 6) === 'script') {
+ warningAt("Expected '<\\/' and instead saw '</'.", line, character);
+ } else if (s.charAt(j + 1) === '!' && (xmode || option.safe)) {
+ warningAt("Unexpected '<!' in a string.", line, character);
+ }
+ } else if (c === '\\') {
+ if (xmode === 'html') {
+ if (option.safe) {
+ warningAt("ADsafe string violation.",
+ line, character + j);
+ }
+ } else if (xmode === 'styleproperty') {
+ j += 1;
+ character += 1;
+ c = s.charAt(j);
+ if (c !== x) {
+ warningAt("Escapement in style string.",
+ line, character + j);
+ }
+ } else {
+ j += 1;
+ character += 1;
+ c = s.charAt(j);
+ switch (c) {
+ case xquote:
+ warningAt("Bad HTML string", line,
+ character + j);
+ break;
+ case '\\':
+ case '\'':
+ case '"':
+ case '/':
+ break;
+ case 'b':
+ c = '\b';
+ break;
+ case 'f':
+ c = '\f';
+ break;
+ case 'n':
+ c = '\n';
+ break;
+ case 'r':
+ c = '\r';
+ break;
+ case 't':
+ c = '\t';
+ break;
+ case 'u':
+ esc(4);
+ break;
+ case 'v':
+ c = '\v';
+ break;
+ case 'x':
+ if (jsonmode) {
+ warningAt("Avoid \\x-.", line, character);
+ }
+ esc(2);
+ break;
+ default:
+ warningAt("Bad escapement.", line, character);
+ }
+ }
+ }
+ r += c;
+ character += 1;
+ j += 1;
+ }
+ }
+
+ for (;;) {
+ if (!s) {
+ return it(nextLine() ? '(endline)' : '(end)', '');
+ }
+ while (xmode === 'outer') {
+ i = s.search(ox);
+ if (i === 0) {
+ break;
+ } else if (i > 0) {
+ character += 1;
+ s = s.slice(i);
+ break;
+ } else {
+ if (!nextLine()) {
+ return it('(end)', '');
+ }
+ }
+ }
+// t = match(rx[xmode] || tx);
+// if (!t) {
+// if (xmode === 'html') {
+// return it('(error)', s.charAt(0));
+// } else {
+// t = '';
+// c = '';
+// while (s && s < '!') {
+// s = s.substr(1);
+// }
+// if (s) {
+// errorAt("Unexpected '{a}'.",
+// line, character, s.substr(0, 1));
+// }
+// }
+ t = match(rx[xmode] || tx);
+ if (!t) {
+ t = '';
+ c = '';
+ while (s && s < '!') {
+ s = s.substr(1);
+ }
+ if (s) {
+ if (xmode === 'html') {
+ return it('(error)', s.charAt(0));
+ } else {
+ errorAt("Unexpected '{a}'.",
+ line, character, s.substr(0, 1));
+ }
+ }
+ } else {
+
+ // identifier
+
+ if (c.isAlpha() || c === '_' || c === '$') {
+ return it('(identifier)', t);
+ }
+
+ // number
+
+ if (c.isDigit() || (c === '.' && t.substr(1, 1).isDigit())) {
+ if (c === '.') {
+ t = '0' + t;
+ c = '0';
+ }
+
+ if (xmode !== 'style' && !isFinite(Number(t))) {
+ warningAt("Bad number '{a}'.",
+ line, character, t);
+ }
+ if (xmode !== 'style' &&
+ xmode !== 'styleproperty' &&
+ s.substr(0, 1).isAlpha()) {
+ warningAt("Missing space after '{a}'.",
+ line, character, t);
+ }
+ if (c === '0') {
+ d = t.substr(1, 1);
+ if (d.isDigit()) {
+ if (token.id !== '.' && xmode !== 'styleproperty') {
+ warningAt("Don't use extra leading zeros '{a}'.",
+ line, character, t);
+ }
+ } else if (jsonmode && (d === 'x' || d === 'X')) {
+ warningAt("Avoid 0x-. '{a}'.",
+ line, character, t);
+ }
+ }
+ if (t.substr(t.length - 1) === '.') {
+ warningAt(
+ "A trailing decimal point can be confused with a dot '{a}'.",
+ line, character, t);
+ }
+ return it('(number)', t);
+ }
+ switch (t) {
+
+ // string
+
+ case '"':
+ case "'":
+ return string(t);
+
+ // // comment
+
+ case '//':
+ if (src || (xmode && xmode !== 'script')) {
+ warningAt("Unexpected comment.", line, character);
+ } else if (xmode === 'script' && /<\s*\//i.test(s)) {
+ warningAt("Unexpected <\/ in comment.", line, character);
+ } else if ((option.safe || xmode === 'script') && ax.test(s)) {
+ warningAt("Dangerous comment.", line, character);
+ }
+ s = '';
+ token.comment = true;
+ break;
+
+ // /* comment
+
+ case '/*':
+ if (src || (xmode && xmode !== 'script' && xmode !== 'style' && xmode !== 'styleproperty')) {
+ warningAt("Unexpected comment.", line, character);
+ }
+ if (option.safe && ax.test(s)) {
+ warningAt("ADsafe comment violation.", line, character);
+ }
+ for (;;) {
+ i = s.search(lx);
+ if (i >= 0) {
+ break;
+ }
+ if (!nextLine()) {
+ errorAt("Unclosed comment.", line, character);
+ } else {
+ if (option.safe && ax.test(s)) {
+ warningAt("ADsafe comment violation.",
+ line, character);
+ }
+ }
+ }
+ character += i + 2;
+ if (s.substr(i, 1) === '/') {
+ errorAt("Nested comment.", line, character);
+ }
+ s = s.substr(i + 2);
+ token.comment = true;
+ break;
+
+ // /*members /*jslint /*global
+
+ case '/*members':
+ case '/*member':
+ case '/*jslint':
+ case '/*global':
+ case '*/':
+ return {
+ value: t,
+ type: 'special',
+ line: line,
+ character: character,
+ from: from
+ };
+
+ case '':
+ break;
+ // /
+ case '/':
+ if (token.id === '/=') {
+ errorAt(
+"A regular expression literal can be confused with '/='.", line, from);
+ }
+ if (prereg) {
+ depth = 0;
+ captures = 0;
+ l = 0;
+ for (;;) {
+ b = true;
+ c = s.charAt(l);
+ l += 1;
+ switch (c) {
+ case '':
+ errorAt("Unclosed regular expression.",
+ line, from);
+ return;
+ case '/':
+ if (depth > 0) {
+ warningAt("Unescaped '{a}'.",
+ line, from + l, '/');
+ }
+ c = s.substr(0, l - 1);
+ q = {
+ g: true,
+ i: true,
+ m: true
+ };
+ while (q[s.charAt(l)] === true) {
+ q[s.charAt(l)] = false;
+ l += 1;
+ }
+ character += l;
+ s = s.substr(l);
+ q = s.charAt(0);
+ if (q === '/' || q === '*') {
+ errorAt("Confusing regular expression.",
+ line, from);
+ }
+ return it('(regexp)', c);
+ case '\\':
+ c = s.charAt(l);
+ if (c < ' ') {
+ warningAt(
+"Unexpected control character in regular expression.", line, from + l);
+ } else if (c === '<') {
+ warningAt(
+"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
+ }
+ l += 1;
+ break;
+ case '(':
+ depth += 1;
+ b = false;
+ if (s.charAt(l) === '?') {
+ l += 1;
+ switch (s.charAt(l)) {
+ case ':':
+ case '=':
+ case '!':
+ l += 1;
+ break;
+ default:
+ warningAt(
+"Expected '{a}' and instead saw '{b}'.", line, from + l, ':', s.charAt(l));
+ }
+ } else {
+ captures += 1;
+ }
+ break;
+ case '|':
+ b = false;
+ break;
+ case ')':
+ if (depth === 0) {
+ warningAt("Unescaped '{a}'.",
+ line, from + l, ')');
+ } else {
+ depth -= 1;
+ }
+ break;
+ case ' ':
+ q = 1;
+ while (s.charAt(l) === ' ') {
+ l += 1;
+ q += 1;
+ }
+ if (q > 1) {
+ warningAt(
+"Spaces are hard to count. Use {{a}}.", line, from + l, q);
+ }
+ break;
+ case '[':
+ c = s.charAt(l);
+ if (c === '^') {
+ l += 1;
+ if (option.regexp) {
+ warningAt("Insecure '{a}'.",
+ line, from + l, c);
+ }
+ }
+ q = false;
+ if (c === ']') {
+ warningAt("Empty class.", line,
+ from + l - 1);
+ q = true;
+ }
+klass: do {
+ c = s.charAt(l);
+ l += 1;
+ switch (c) {
+ case '[':
+ case '^':
+ warningAt("Unescaped '{a}'.",
+ line, from + l, c);
+ q = true;
+ break;
+ case '-':
+ if (q) {
+ q = false;
+ } else {
+ warningAt("Unescaped '{a}'.",
+ line, from + l, '-');
+ q = true;
+ }
+ break;
+ case ']':
+ if (!q) {
+ warningAt("Unescaped '{a}'.",
+ line, from + l - 1, '-');
+ }
+ break klass;
+ case '\\':
+ c = s.charAt(l);
+ if (c < ' ') {
+ warningAt(
+"Unexpected control character in regular expression.", line, from + l);
+ } else if (c === '<') {
+ warningAt(
+"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
+ }
+ l += 1;
+ q = true;
+ break;
+ case '/':
+ warningAt("Unescaped '{a}'.",
+ line, from + l - 1, '/');
+ q = true;
+ break;
+ case '<':
+ if (xmode === 'script') {
+ c = s.charAt(l);
+ if (c === '!' || c === '/') {
+ warningAt(
+"HTML confusion in regular expression '<{a}'.", line, from + l, c);
+ }
+ }
+ q = true;
+ break;
+ default:
+ q = true;
+ }
+ } while (c);
+ break;
+ case '.':
+ if (option.regexp) {
+ warningAt("Insecure '{a}'.", line,
+ from + l, c);
+ }
+ break;
+ case ']':
+ case '?':
+ case '{':
+ case '}':
+ case '+':
+ case '*':
+ warningAt("Unescaped '{a}'.", line,
+ from + l, c);
+ break;
+ case '<':
+ if (xmode === 'script') {
+ c = s.charAt(l);
+ if (c === '!' || c === '/') {
+ warningAt(
+"HTML confusion in regular expression '<{a}'.", line, from + l, c);
+ }
+ }
+ }
+ if (b) {
+ switch (s.charAt(l)) {
+ case '?':
+ case '+':
+ case '*':
+ l += 1;
+ if (s.charAt(l) === '?') {
+ l += 1;
+ }
+ break;
+ case '{':
+ l += 1;
+ c = s.charAt(l);
+ if (c < '0' || c > '9') {
+ warningAt(
+"Expected a number and instead saw '{a}'.", line, from + l, c);
+ }
+ l += 1;
+ low = +c;
+ for (;;) {
+ c = s.charAt(l);
+ if (c < '0' || c > '9') {
+ break;
+ }
+ l += 1;
+ low = +c + (low * 10);
+ }
+ high = low;
+ if (c === ',') {
+ l += 1;
+ high = Infinity;
+ c = s.charAt(l);
+ if (c >= '0' && c <= '9') {
+ l += 1;
+ high = +c;
+ for (;;) {
+ c = s.charAt(l);
+ if (c < '0' || c > '9') {
+ break;
+ }
+ l += 1;
+ high = +c + (high * 10);
+ }
+ }
+ }
+ if (s.charAt(l) !== '}') {
+ warningAt(
+"Expected '{a}' and instead saw '{b}'.", line, from + l, '}', c);
+ } else {
+ l += 1;
+ }
+ if (s.charAt(l) === '?') {
+ l += 1;
+ }
+ if (low > high) {
+ warningAt(
+"'{a}' should not be greater than '{b}'.", line, from + l, low, high);
+ }
+ }
+ }
+ }
+ c = s.substr(0, l - 1);
+ character += l;
+ s = s.substr(l);
+ return it('(regexp)', c);
+ }
+ return it('(punctuator)', t);
+
+ // punctuator
+
+ case '<!--':
+ l = line;
+ c = character;
+ for (;;) {
+ i = s.indexOf('--');
+ if (i >= 0) {
+ break;
+ }
+ i = s.indexOf('<!-');
+ if (i >= 0) {
+ errorAt("Nested HTML comment.",
+ line, character + i);
+ }
+ if (!nextLine()) {
+ errorAt("Unclosed HTML comment.", l, c);
+ }
+ }
+ l = s.indexOf('<!-');
+ if (l >= 0 && l < i) {
+ errorAt("Nested HTML comment.",
+ line, character + l);
+ }
+ character += i;
+ if (s[i + 2] !== '>') {
+ errorAt("Expected -->.", line, character);
+ }
+ character += 3;
+ s = s.slice(i + 3);
+ break;
+ case '#':
+ if (xmode === 'html' || xmode === 'styleproperty') {
+ for (;;) {
+ c = s.charAt(0);
+ if ((c < '0' || c > '9') &&
+ (c < 'a' || c > 'f') &&
+ (c < 'A' || c > 'F')) {
+ break;
+ }
+ character += 1;
+ s = s.substr(1);
+ t += c;
+ }
+ if (t.length !== 4 && t.length !== 7) {
+ warningAt("Bad hex color '{a}'.", line,
+ from + l, t);
+ }
+ return it('(color)', t);
+ }
+ return it('(punctuator)', t);
+ default:
+ if (xmode === 'outer' && c === '&') {
+ character += 1;
+ s = s.substr(1);
+ for (;;) {
+ c = s.charAt(0);
+ character += 1;
+ s = s.substr(1);
+ if (c === ';') {
+ break;
+ }
+ if (!((c >= '0' && c <= '9') ||
+ (c >= 'a' && c <= 'z') ||
+ c === '#')) {
+ errorAt("Bad entity", line, from + l,
+ character);
+ }
+ }
+ break;
+ }
+ return it('(punctuator)', t);
+ }
+ }
+ }
+ }
+ };
+ }());
+
+
+ function addlabel(t, type) {
+
+ if (option.safe && funct['(global)'] &&
+ typeof predefined[t] !== 'boolean') {
+ warning('ADsafe global: ' + t + '.', token);
+ } else if (t === 'hasOwnProperty') {
+ warning("'hasOwnProperty' is a really bad name.");
+ }
+
+// Define t in the current function in the current scope.
+
+ if (is_own(funct, t) && !funct['(global)']) {
+ warning(funct[t] === true ?
+ "'{a}' was used before it was defined." :
+ "'{a}' is already defined.",
+ nexttoken, t);
+ }
+ funct[t] = type;
+ if (funct['(global)']) {
+ global[t] = funct;
+ if (is_own(implied, t)) {
+ warning("'{a}' was used before it was defined.", nexttoken, t);
+ delete implied[t];
+ }
+ } else {
+ scope[t] = funct;
+ }
+ }
+
+
+ function doOption() {
+ var b, obj, filter, o = nexttoken.value, t, v;
+ switch (o) {
+ case '*/':
+ error("Unbegun comment.");
+ break;
+ case '/*members':
+ case '/*member':
+ o = '/*members';
+ if (!membersOnly) {
+ membersOnly = {};
+ }
+ obj = membersOnly;
+ break;
+ case '/*jslint':
+ if (option.safe) {
+ warning("ADsafe restriction.");
+ }
+ obj = option;
+ filter = boolOptions;
+ break;
+ case '/*global':
+ if (option.safe) {
+ warning("ADsafe restriction.");
+ }
+ obj = predefined;
+ break;
+ default:
+ }
+ t = lex.token();
+loop: for (;;) {
+ for (;;) {
+ if (t.type === 'special' && t.value === '*/') {
+ break loop;
+ }
+ if (t.id !== '(endline)' && t.id !== ',') {
+ break;
+ }
+ t = lex.token();
+ }
+ if (t.type !== '(string)' && t.type !== '(identifier)' &&
+ o !== '/*members') {
+ error("Bad option.", t);
+ }
+ v = lex.token();
+ if (v.id === ':') {
+ v = lex.token();
+ if (obj === membersOnly) {
+ error("Expected '{a}' and instead saw '{b}'.",
+ t, '*/', ':');
+ }
+ if (t.value === 'indent' && o === '/*jslint') {
+ b = +v.value;
+ if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
+ Math.floor(b) !== b) {
+ error("Expected a small integer and instead saw '{a}'.",
+ v, v.value);
+ }
+ obj.white = true;
+ obj.indent = b;
+ } else if (t.value === 'maxerr' && o === '/*jslint') {
+ b = +v.value;
+ if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
+ Math.floor(b) !== b) {
+ error("Expected a small integer and instead saw '{a}'.",
+ v, v.value);
+ }
+ obj.maxerr = b;
+ } else if (t.value === 'maxlen' && o === '/*jslint') {
+ b = +v.value;
+ if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
+ Math.floor(b) !== b) {
+ error("Expected a small integer and instead saw '{a}'.",
+ v, v.value);
+ }
+ obj.maxlen = b;
+ } else if (v.value === 'true') {
+ obj[t.value] = true;
+ } else if (v.value === 'false') {
+ obj[t.value] = false;
+ } else {
+ error("Bad option value.", v);
+ }
+ t = lex.token();
+ } else {
+ if (o === '/*jslint') {
+ error("Missing option value.", t);
+ }
+ obj[t.value] = false;
+ t = v;
+ }
+ }
+ if (filter) {
+ assume();
+ }
+ }
+
+
+// We need a peek function. If it has an argument, it peeks that much farther
+// ahead. It is used to distinguish
+// for ( var i in ...
+// from
+// for ( var i = ...
+
+ function peek(p) {
+ var i = p || 0, j = 0, t;
+
+ while (j <= i) {
+ t = lookahead[j];
+ if (!t) {
+ t = lookahead[j] = lex.token();
+ }
+ j += 1;
+ }
+ return t;
+ }
+
+
+
+// Produce the next token. It looks for programming errors.
+
+ function advance(id, t) {
+ switch (token.id) {
+ case '(number)':
+ if (nexttoken.id === '.') {
+ warning(
+"A dot following a number can be confused with a decimal point.", token);
+ }
+ break;
+ case '-':
+ if (nexttoken.id === '-' || nexttoken.id === '--') {
+ warning("Confusing minusses.");
+ }
+ break;
+ case '+':
+ if (nexttoken.id === '+' || nexttoken.id === '++') {
+ warning("Confusing plusses.");
+ }
+ break;
+ }
+ if (token.type === '(string)' || token.identifier) {
+ anonname = token.value;
+ }
+
+ if (id && nexttoken.id !== id) {
+ if (t) {
+ if (nexttoken.id === '(end)') {
+ warning("Unmatched '{a}'.", t, t.id);
+ } else {
+ warning(
+"Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
+ nexttoken, id, t.id, t.line, nexttoken.value);
+ }
+ } else if (nexttoken.type !== '(identifier)' ||
+ nexttoken.value !== id) {
+ warning("Expected '{a}' and instead saw '{b}'.",
+ nexttoken, id, nexttoken.value);
+ }
+ }
+ prevtoken = token;
+ token = nexttoken;
+ for (;;) {
+ nexttoken = lookahead.shift() || lex.token();
+ if (nexttoken.id === '(end)' || nexttoken.id === '(error)') {
+ return;
+ }
+ if (nexttoken.type === 'special') {
+ doOption();
+ } else {
+ if (nexttoken.id !== '(endline)') {
+ break;
+ }
+ }
+ }
+ }
+
+
+// This is the heart of JSLINT, the Pratt parser. In addition to parsing, it
+// is looking for ad hoc lint patterns. We add to Pratt's model .fud, which is
+// like nud except that it is only used on the first token of a statement.
+// Having .fud makes it much easier to define JavaScript. I retained Pratt's
+// nomenclature.
+
+// .nud Null denotation
+// .fud First null denotation
+// .led Left denotation
+// lbp Left binding power
+// rbp Right binding power
+
+// They are key to the parsing method called Top Down Operator Precedence.
+
+ function parse(rbp, initial) {
+ var left;
+ if (nexttoken.id === '(end)') {
+ error("Unexpected early end of program.", token);
+ }
+ advance();
+ if (option.safe && typeof predefined[token.value] === 'boolean' &&
+ (nexttoken.id !== '(' && nexttoken.id !== '.')) {
+ warning('ADsafe violation.', token);
+ }
+ if (initial) {
+ anonname = 'anonymous';
+ funct['(verb)'] = token.value;
+ }
+ if (initial === true && token.fud) {
+ left = token.fud();
+ } else {
+ if (token.nud) {
+ left = token.nud();
+ } else {
+ if (nexttoken.type === '(number)' && token.id === '.') {
+ warning(
+"A leading decimal point can be confused with a dot: '.{a}'.",
+ token, nexttoken.value);
+ advance();
+ return token;
+ } else {
+ error("Expected an identifier and instead saw '{a}'.",
+ token, token.id);
+ }
+ }
+ while (rbp < nexttoken.lbp) {
+ advance();
+ if (token.led) {
+ left = token.led(left);
+ } else {
+ error("Expected an operator and instead saw '{a}'.",
+ token, token.id);
+ }
+ }
+ }
+ return left;
+ }
+
+
+// Functions for conformance of style.
+
+ function adjacent(left, right) {
+ left = left || token;
+ right = right || nexttoken;
+ if (option.white || xmode === 'styleproperty' || xmode === 'style') {
+ if (left.character !== right.from && left.line === right.line) {
+ warning("Unexpected space after '{a}'.", right, left.value);
+ }
+ }
+ }
+
+ function nospace(left, right) {
+ left = left || token;
+ right = right || nexttoken;
+ if (option.white && !left.comment) {
+ if (left.line === right.line) {
+ adjacent(left, right);
+ }
+ }
+ }
+
+
+ function nonadjacent(left, right) {
+ if (option.white) {
+ left = left || token;
+ right = right || nexttoken;
+ if (left.line === right.line && left.character === right.from) {
+ warning("Missing space after '{a}'.",
+
<TRUNCATED>
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/jslint/js.jar
----------------------------------------------------------------------
diff --git a/AlluraTest/jslint/js.jar b/AlluraTest/jslint/js.jar
new file mode 100644
index 0000000..2369f99
Binary files /dev/null and b/AlluraTest/jslint/js.jar differ
[07/10] git commit: [#4122] rename AlluraTesting dir to AlluraTest,
to match the module name below
Posted by br...@apache.org.
[#4122] rename AlluraTesting dir to AlluraTest, to match the module name below
This makes the coverage output from ./run_tests better
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/aa222434
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/aa222434
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/aa222434
Branch: refs/heads/db/6277
Commit: aa222434bb5351b464e8f512dcea4b28019b8081
Parents: e375efb
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Mon May 6 18:24:09 2013 -0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri May 24 21:16:02 2013 -0400
----------------------------------------------------------------------
AlluraTest/LICENSE | 234 +
AlluraTest/alluratest/__init__.py | 16 +
AlluraTest/alluratest/controller.py | 171 +
AlluraTest/alluratest/test_syntax.py | 95 +
AlluraTest/alluratest/validation.py | 321 +
AlluraTest/jslint/Makefile | 7 +
AlluraTest/jslint/env-js.jar | Bin 0 -> 1110999 bytes
AlluraTest/jslint/fulljslint.js | 5688 ++++++++++++++
AlluraTest/jslint/js.jar | Bin 0 -> 871260 bytes
AlluraTest/jslint/jslint.js | 5729 +++++++++++++++
AlluraTest/jslint/rhino.js | 41 +
AlluraTest/setup.py | 39 +
AlluraTest/twill-tests/README | 19 +
AlluraTest/twill-tests/create_repo.twill | 47 +
AlluraTest/twill-tests/edit_wiki_page.twill | 36 +
AlluraTest/twill-tests/login.twill | 27 +
AlluraTest/twill-tests/new_issue.twill | 36 +
AlluraTest/twill-tests/smoke-front-page.twill | 20 +
AlluraTest/twill-tests/smoke-project-home.twill | 20 +
AlluraTest/twill-tests/smoke-tracker-search.twill | 20 +
AlluraTest/twill-tests/smoke-tracker.twill | 20 +
AlluraTest/twill-tests/smoke-user-profile.twill | 20 +
AlluraTest/twill-tests/smoke-wiki.twill | 20 +
AlluraTesting/LICENSE | 234 -
AlluraTesting/alluratest/__init__.py | 16 -
AlluraTesting/alluratest/controller.py | 171 -
AlluraTesting/alluratest/test_syntax.py | 95 -
AlluraTesting/alluratest/validation.py | 321 -
AlluraTesting/jslint/Makefile | 7 -
AlluraTesting/jslint/env-js.jar | Bin 1110999 -> 0 bytes
AlluraTesting/jslint/fulljslint.js | 5688 --------------
AlluraTesting/jslint/js.jar | Bin 871260 -> 0 bytes
AlluraTesting/jslint/jslint.js | 5729 ---------------
AlluraTesting/jslint/rhino.js | 41 -
AlluraTesting/setup.py | 39 -
AlluraTesting/twill-tests/README | 19 -
AlluraTesting/twill-tests/create_repo.twill | 47 -
AlluraTesting/twill-tests/edit_wiki_page.twill | 36 -
AlluraTesting/twill-tests/login.twill | 27 -
AlluraTesting/twill-tests/new_issue.twill | 36 -
AlluraTesting/twill-tests/smoke-front-page.twill | 20 -
AlluraTesting/twill-tests/smoke-project-home.twill | 20 -
.../twill-tests/smoke-tracker-search.twill | 20 -
AlluraTesting/twill-tests/smoke-tracker.twill | 20 -
AlluraTesting/twill-tests/smoke-user-profile.twill | 20 -
AlluraTesting/twill-tests/smoke-wiki.twill | 20 -
rat-excludes.txt | 2 +-
run_clonedigger | 2 +-
run_tests | 2 +-
49 files changed, 12629 insertions(+), 12629 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/LICENSE
----------------------------------------------------------------------
diff --git a/AlluraTest/LICENSE b/AlluraTest/LICENSE
new file mode 100644
index 0000000..15f71ee
--- /dev/null
+++ b/AlluraTest/LICENSE
@@ -0,0 +1,234 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+AlluraTest SUBCOMPONENTS:
+
+AlluraTest includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source code
+for the these subcomponents is subject to the terms and conditions of the
+following licenses.
+
+For jslint.js, in directory
+jslint/
+
+ Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
+ this software and associated documentation files (the "Software"), to deal in
+ the Software without restriction, including without limitation the rights to
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is furnished to do
+ so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ The Software shall be used for Good, not Evil.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/alluratest/__init__.py
----------------------------------------------------------------------
diff --git a/AlluraTest/alluratest/__init__.py b/AlluraTest/alluratest/__init__.py
new file mode 100644
index 0000000..144e298
--- /dev/null
+++ b/AlluraTest/alluratest/__init__.py
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/alluratest/controller.py
----------------------------------------------------------------------
diff --git a/AlluraTest/alluratest/controller.py b/AlluraTest/alluratest/controller.py
new file mode 100644
index 0000000..dd81b23
--- /dev/null
+++ b/AlluraTest/alluratest/controller.py
@@ -0,0 +1,171 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit and functional test suite for allura."""
+import os
+import urllib
+
+import mock
+import beaker.session
+from formencode import variabledecode
+from paste.deploy import loadapp
+from paste.deploy.converters import asbool
+from paste.script.appinstall import SetupCommand
+from pylons import tmpl_context as c, app_globals as g
+from pylons import url, request, response, session
+import tg
+from webtest import TestApp
+from webob import Request, Response
+import ew
+from ming.orm import ThreadLocalORMSession
+import ming.orm
+
+from allura import model as M
+import allura.lib.security
+from allura.lib.app_globals import Globals
+from allura.lib import helpers as h
+from allura.websetup.schema import REGISTRY
+#from allura.lib.custom_middleware import environ as ENV, MagicalC
+from .validation import ValidatingTestApp
+
+DFL_APP_NAME = 'main_without_authn'
+
+def get_config_file(config=None):
+ if not config:
+ config = 'test.ini'
+
+ try:
+ conf_dir = tg.config.here
+ except AttributeError:
+ conf_dir = os.getcwd()
+ return os.path.join(conf_dir, config)
+
+def setup_basic_test(config=None, app_name=DFL_APP_NAME):
+ '''Create clean environment for running tests'''
+ try:
+ conf_dir = tg.config.here
+ except AttributeError:
+ conf_dir = os.getcwd()
+ ew.TemplateEngine.initialize({})
+ test_file = os.path.join(conf_dir, get_config_file(config))
+ cmd = SetupCommand('setup-app')
+ cmd.run([test_file])
+
+ # run all tasks, e.g. indexing from bootstrap operations
+ while M.MonQTask.run_ready('setup'):
+ ThreadLocalORMSession.flush_all()
+
+def setup_functional_test(config=None, app_name=DFL_APP_NAME):
+ '''Create clean environment for running tests. Also return WSGI test app'''
+ config = get_config_file(config)
+ setup_basic_test(config, app_name)
+ conf_dir = tg.config.here
+ wsgiapp = loadapp('config:%s#%s' % (config, app_name),
+ relative_to=conf_dir)
+ return wsgiapp
+
+def setup_unit_test():
+ try:
+ while True:
+ REGISTRY.cleanup()
+ except:
+ pass
+ REGISTRY.prepare()
+ REGISTRY.register(ew.widget_context, ew.core.WidgetContext('http', ew.ResourceManager()))
+ REGISTRY.register(g, Globals())
+ REGISTRY.register(c, mock.Mock())
+ REGISTRY.register(url, lambda:None)
+ REGISTRY.register(request, Request.blank('/', remote_addr='1.1.1.1'))
+ REGISTRY.register(response, Response())
+ REGISTRY.register(session, beaker.session.SessionObject({}))
+ REGISTRY.register(allura.credentials, allura.lib.security.Credentials())
+ c.memoize_cache = {}
+ c.queued_messages = None
+ c.model_cache = None
+ ThreadLocalORMSession.close_all()
+
+def setup_global_objects():
+ setup_unit_test()
+ h.set_context('test', 'wiki', neighborhood='Projects')
+ c.user = M.User.query.get(username='test-admin')
+
+
+class TestController(object):
+
+ application_under_test = 'main'
+ validate_skip = False
+
+ def setUp(self):
+ """Method called by nose before running each test"""
+ self.app = ValidatingTestApp(setup_functional_test(app_name=self.application_under_test))
+ if self.validate_skip:
+ self.app.validate_skip = self.validate_skip
+ if asbool(tg.config.get('smtp.mock')):
+ self.smtp_mock = mock.patch('allura.lib.mail_util.smtplib.SMTP')
+ self.smtp_mock.start()
+
+ def tearDown(self):
+ """Method called by nose after running each test"""
+ if asbool(tg.config.get('smtp.mock')):
+ self.smtp_mock.stop()
+
+ def webflash(self, response):
+ "Extract webflash content from response."
+ return urllib.unquote(response.cookies_set.get('webflash', ''))
+
+
+class TestRestApiBase(TestController):
+
+ def setUp(self):
+ super(TestRestApiBase, self).setUp()
+ setup_global_objects()
+# h.set_context('test', 'home')
+ self.user = M.User.query.get(username='test-admin')
+ self.token = M.ApiToken(user_id=self.user._id)
+ ming.orm.session(self.token).flush()
+
+ def set_api_token(self, token):
+ self.token = token
+
+ def _api_getpost(self, method, path, api_key=None, api_timestamp=None, api_signature=None,
+ wrap_args=None, **params):
+ if wrap_args:
+ params = {wrap_args: params}
+ params = variabledecode.variable_encode(params, add_repetitions=False)
+ if api_key: params['api_key'] = api_key
+ if api_timestamp: params['api_timestamp'] = api_timestamp
+ if api_signature: params['api_signature'] = api_signature
+ params = self.token.sign_request(path, params)
+
+ fn = self.app.post if method=='POST' else self.app.get
+
+ response = fn(
+ str(path),
+ params=params,
+ status=[200, 302, 400, 403, 404])
+ if response.status_int == 302:
+ return response.follow()
+ else:
+ return response
+
+ def api_get(self, path, api_key=None, api_timestamp=None, api_signature=None,
+ wrap_args=None, **params):
+ return self._api_getpost('GET', path, api_key, api_timestamp, api_signature, wrap_args, **params)
+
+ def api_post(self, path, api_key=None, api_timestamp=None, api_signature=None,
+ wrap_args=None, **params):
+ return self._api_getpost('POST', path, api_key, api_timestamp, api_signature, wrap_args, **params)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/alluratest/test_syntax.py
----------------------------------------------------------------------
diff --git a/AlluraTest/alluratest/test_syntax.py b/AlluraTest/alluratest/test_syntax.py
new file mode 100644
index 0000000..b394798
--- /dev/null
+++ b/AlluraTest/alluratest/test_syntax.py
@@ -0,0 +1,95 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import os.path
+from glob import glob
+from subprocess import Popen, PIPE
+import sys
+
+toplevel_dir = os.path.abspath(os.path.dirname(__file__) + "/../..")
+
+def run(cmd):
+ proc = Popen(cmd, shell=True, cwd=toplevel_dir, stdout=PIPE, stderr=PIPE)
+ # must capture & reprint stdount, so that nosetests can capture it
+ (stdout, stderr) = proc.communicate()
+ sys.stdout.write(stdout)
+ sys.stderr.write(stderr)
+ return proc.returncode
+
+find_py = "find Allura Forge* -name '*.py'"
+
+# a recepe from itertools doc
+from itertools import izip_longest
+def grouper(n, iterable, fillvalue=None):
+ "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
+ args = [iter(iterable)] * n
+ return izip_longest(fillvalue=fillvalue, *args)
+
+def test_pyflakes():
+ # skip some that aren't critical errors
+ skips = [
+ 'imported but unused',
+ 'redefinition of unused',
+ 'assigned to but never used',
+ '__version__',
+ ]
+ proc = Popen(find_py, shell=True, cwd=toplevel_dir, stdout=PIPE, stderr=PIPE)
+ (find_stdout, stderr) = proc.communicate()
+ sys.stderr.write(stderr)
+ assert proc.returncode == 0, proc.returncode
+
+ # run pyflakes in batches, so it doesn't take tons of memory
+ error = False
+ all_files = [f for f in find_stdout.split('\n')
+ if '/migrations/' not in f and f.strip()]
+ for files in grouper(20, all_files, fillvalue=''):
+ cmd = "pyflakes " + ' '.join(files) + " | grep -v '" + "' | grep -v '".join(skips) + "'"
+ #print 'Command was: %s' % cmd
+ retval = run(cmd)
+ if retval != 1:
+ print
+ #print 'Command was: %s' % cmd
+ print 'Returned %s' % retval
+ error = True
+
+ if error:
+ raise Exception('pyflakes failure, see stdout')
+
+def test_no_now():
+ if run(find_py + " | xargs grep '\.now(' ") not in [1,123]:
+ raise Exception("These should use .utcnow()")
+ if run(find_py + " | xargs grep '\.fromtimestamp(' ") not in [1,123]:
+ raise Exception("These should use .utcfromtimestamp()")
+
+def test_no_prints():
+ skips = [
+ '/tests/',
+ 'Allura/allura/command/',
+ 'Allura/ldap-setup.py',
+ 'Allura/ldap-userconfig.py',
+ 'Allura/ez_setup/',
+ 'Allura/allura/lib/AsciiDammit.py',
+ '/scripts/',
+ 'Allura/allura/lib/import_api.py',
+ 'ForgeSVN/setup.py',
+ ]
+ if run(find_py + " | grep -v '" + "' | grep -v '".join(skips) + "' | xargs grep -v '^ *#' | grep 'print ' | grep -E -v '(pprint|#pragma: ?printok)' ") != 1:
+ raise Exception("These should use logging instead of print")
+
+def test_no_tabs():
+ if run(find_py + " | xargs grep ' ' ") not in [1,123]:
+ raise Exception('These should not use tab chars')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/alluratest/validation.py
----------------------------------------------------------------------
diff --git a/AlluraTest/alluratest/validation.py b/AlluraTest/alluratest/validation.py
new file mode 100644
index 0000000..235d7c0
--- /dev/null
+++ b/AlluraTest/alluratest/validation.py
@@ -0,0 +1,321 @@
+# -*- coding: utf-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Functions to syntax-validate output content
+"""
+from os import path, environ, getcwd
+import os
+import sys
+import logging
+import tempfile
+import subprocess
+import json
+import urllib2
+import re
+
+import tg
+import mock
+import beaker.session
+from paste.deploy import loadapp
+from paste.script.appinstall import SetupCommand
+from pylons import tmpl_context as c, app_globals as g
+from pylons import url, request, response, session
+import webtest
+from webtest import TestApp
+from webob import Request, Response
+from nose.tools import ok_, assert_true, assert_false
+from poster.encode import multipart_encode
+from poster.streaminghttp import register_openers
+from ming.utils import LazyProperty
+
+from allura.lib import utils
+
+ENABLE_CONTENT_VALIDATION = False
+# By default we want to run only validations which are fast,
+# but on special test hosts - all.
+COMPLETE_TESTS_HOST = 'sb-forge-4039'
+
+log = logging.getLogger(__name__)
+
+class Config(object):
+ "Config to encapsulate flexible/complex test enabled/disabled rules."
+ _instance = None
+
+ def __init__(self):
+ self.ini_config = None
+ pass
+
+ @classmethod
+ def instance(cls):
+ if not cls._instance:
+ cls._instance = cls()
+ return cls._instance
+
+ @LazyProperty
+ def test_ini(self):
+ if not self.ini_config:
+ from . import controller
+ import ConfigParser
+ conf = ConfigParser.ConfigParser({'validate_html5': 'false', 'validate_inlinejs': 'false'})
+ conf.read(controller.get_config_file())
+ self.ini_config = conf
+ return self.ini_config
+
+ @LazyProperty
+ def hostname(self):
+ if os.path.exists('/etc/soghost'):
+ with open('/etc/soghost') as fp:
+ return fp.read().strip()
+
+ def validation_enabled(self, val_type):
+ env_var = os.getenv('ALLURA_VALIDATION')
+ if env_var == 'all':
+ return True
+ elif env_var == 'none':
+ return False
+ elif env_var is not None:
+ return val_type in env_var.split(',')
+
+ if self.hostname == COMPLETE_TESTS_HOST:
+ return True
+
+ enabled = self.test_ini.getboolean('validation', 'validate_' + val_type)
+ return enabled
+
+ def fail_on_validation(self, val_type):
+ env_var = os.getenv('ALLURA_VALIDATION')
+ if env_var == 'all':
+ return True
+ if self.hostname == COMPLETE_TESTS_HOST:
+ return True
+ return ENABLE_CONTENT_VALIDATION
+
+
+def report_validation_error(val_name, filename, message):
+ message = '%s Validation errors (%s):\n%s\n' % (val_name, filename, message)
+ if Config.instance().fail_on_validation(val_name):
+ ok_(False, message)
+ else:
+ sys.stderr.write('=' * 40 + '\n' + message)
+
+def dump_to_file(prefix, html):
+ f = tempfile.NamedTemporaryFile(prefix=prefix, delete=False)
+ f.write(html)
+ f.close()
+ return f.name
+
+def validate_html(html_or_response):
+ if hasattr(html_or_response, 'body'):
+ html = html_or_response.body
+ else:
+ html = html_or_response
+
+ html = html.lstrip()
+
+ if html.startswith('<!DOCTYPE html>'):
+ return validate_html5(html)
+ else:
+ assert False, 'Non-valid HTML: ' + html[:100] + '...'
+
+def validate_json(json_or_response):
+ if hasattr(json_or_response, 'body'):
+ j = json_or_response.body
+ else:
+ j = json_or_response
+
+ try:
+ obj = json.loads(j)
+ except Exception, e:
+ ok_(False, "Couldn't validate JSON: " + str(e) + ':' + j[:100] + '...')
+
+ return obj
+
+def validate_html5(html_or_response):
+ if hasattr(html_or_response, 'body'):
+ html = html_or_response.body
+ else:
+ html = html_or_response
+ register_openers()
+ params = [("out","text"),("content",html)]
+ datagen, headers = multipart_encode(params)
+ request = urllib2.Request("http://html5.validator.nu/", datagen, headers)
+ count = 3
+ while True:
+ try:
+ resp = urllib2.urlopen(request, timeout=3).read()
+ break
+ except:
+ resp = "Couldn't connect to validation service to check the HTML"
+ count -= 1
+ if count == 0:
+ sys.stderr.write('WARNING: ' + resp + '\n')
+ break
+
+ resp = resp.replace('“','"').replace('”','"').replace('–','-')
+
+ ignored_errors = [
+ 'Required attributes missing on element "object"',
+ 'Stray end tag "embed".',
+ 'Stray end tag "param".',
+ r'Bad value .+? for attribute "onclick" on element "input": invalid return',
+ ]
+ for ignore in ignored_errors:
+ resp = re.sub('Error: ' + ignore, 'Ignoring: ' + ignore, resp)
+
+ if 'Error:' in resp:
+ fname = dump_to_file('html5-', html)
+ message = resp.decode('ascii','ignore')
+ report_validation_error('html5', fname, message)
+
+
+def validate_html5_chunk(html):
+ """ When you don't have a html & body tags - this adds it"""
+ # WebTest doesn't like HTML fragments without doctype,
+ # so we output them sometimes for fragments, which is hack.
+ # Unhack it here.
+ doctype = '<!DOCTYPE html>'
+ if html.startswith(doctype):
+ html = html[len(doctype):]
+
+ html = '''<!DOCTYPE html>
+ <html>
+ <head><title></title></head>
+ <body>
+ %s
+ </body></html>''' % html
+ return validate_html5(html)
+
+def validate_js(html_or_response):
+ if hasattr(html_or_response, 'body'):
+ if html_or_response.status_int != 200:
+ return
+ html = html_or_response.body
+ else:
+ html = html_or_response
+ basedir = path.dirname(path.abspath(__file__))
+ jslint_dir = basedir + '/../jslint'
+ fname = dump_to_file('jslint-', html)
+ cmd = 'java -jar ' + jslint_dir + '/js.jar '+ jslint_dir +'/jslint.js ' + fname
+ p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ stdout, stderr = p.communicate(html)
+ if stdout.startswith('jslint: No problems found'):
+ os.unlink(fname)
+ return
+ stdout = stdout.decode('UTF-8', 'replace')
+ msg = '\n'.join(repr(s) for s in stdout.split('\n') if s)
+ report_validation_error('js', fname, msg)
+
+def validate_page(html_or_response):
+ if Config.instance().validation_enabled('html5'):
+ validate_html(html_or_response)
+ if Config.instance().validation_enabled('inlinejs'):
+ validate_js(html_or_response)
+
+class AntiSpamTestApp(TestApp):
+
+ def post(self, *args, **kwargs):
+ if kwargs.pop('antispam', False):
+ antispam = utils.AntiSpam()
+ params = {
+ 'timestamp': antispam.timestamp_text,
+ 'spinner': antispam.spinner_text,
+ antispam.enc('honey0'): '',
+ antispam.enc('honey1'): '',
+ }
+ for k, v in kwargs['params'].iteritems():
+ params[antispam.enc(k)] = v
+ kwargs['params'] = params
+ return super(AntiSpamTestApp, self).post(*args, **kwargs)
+
+class PostParamCheckingTestApp(AntiSpamTestApp):
+
+ def _validate_params(self, params, method):
+ if not params:
+ return
+ # params can be a list or a dict
+ if hasattr(params, 'items'):
+ params = params.items()
+ for k, v in params:
+ if not isinstance(k, basestring):
+ raise TypeError('%s key %s is %s, not str' % (method, k, type(k)))
+ if not isinstance(v, (basestring, webtest.app.File)):
+ raise TypeError('%s key %s has value %s of type %s, not str. ' % (method, k, v, type(v)))
+
+ def get(self, *args, **kwargs):
+ self._validate_params(kwargs.get('params'), 'get')
+ return super(PostParamCheckingTestApp, self).get(*args, **kwargs)
+
+ def post(self, *args, **kwargs):
+ self._validate_params(kwargs.get('params'), 'post')
+ return super(PostParamCheckingTestApp, self).post(*args, **kwargs)
+
+class ValidatingTestApp(PostParamCheckingTestApp):
+
+ # Subclasses may set this to True to skip validation altogether
+ validate_skip = False
+
+ def _validate(self, resp, method, val_params):
+ """Perform validation on webapp response. This handles responses of
+ various types and forms."""
+ if resp.status_int != 200:
+ return
+
+ content = resp.body
+ content_type = resp.headers['Content-Type']
+ if content_type.startswith('text/html'):
+ if val_params['validate_chunk']:
+ validate_html5_chunk(content)
+ else:
+ validate_page(resp)
+ elif content_type.split(';', 1)[0] in ('text/plain', 'text/x-python', 'application/octet-stream'):
+ pass
+ elif content_type.startswith('application/json'):
+ validate_json(content)
+ elif content_type.startswith(('application/x-javascript','application/javascript', 'text/javascript')):
+ validate_js(content)
+ elif content_type.startswith('application/xml'):
+ import feedparser
+ d = feedparser.parse(content)
+ assert d.bozo == 0, 'Non-wellformed feed'
+ elif content_type.startswith('image/'):
+ pass
+ else:
+ assert False, 'Unexpected output content type: ' + content_type
+
+ def _get_validation_params(self, kw):
+ "Separate validation params from normal TestApp methods params."
+ params = {}
+ for k in ('validate_skip', 'validate_chunk'):
+ params[k] = kw.pop(k, False)
+ return params, kw
+
+ def get(self, *args, **kw):
+ val_params, kw = self._get_validation_params(kw)
+ resp = super(ValidatingTestApp, self).get(*args, **kw)
+ if not self.validate_skip and not val_params['validate_skip']:
+ self._validate(resp, 'get', val_params)
+ return resp
+
+ def post(self, *args, **kw):
+ val_params, kw = self._get_validation_params(kw)
+ resp = super(ValidatingTestApp, self).post(*args, **kw)
+ if not self.validate_skip and not val_params['validate_skip']:
+ self._validate(resp, 'post', val_params)
+ return resp
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/jslint/Makefile
----------------------------------------------------------------------
diff --git a/AlluraTest/jslint/Makefile b/AlluraTest/jslint/Makefile
new file mode 100644
index 0000000..7efd72e
--- /dev/null
+++ b/AlluraTest/jslint/Makefile
@@ -0,0 +1,7 @@
+# Make single-file jslint script out of main script (from jslint.com,
+# patched by us to tweak its behavior, as it configurability leaves much
+# to be desired) and Rhino support module. Needed because Rhino accepts
+# only single file as script.
+
+jslint.js: fulljslint.js rhino.js
+ cat $^ >$@
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/jslint/env-js.jar
----------------------------------------------------------------------
diff --git a/AlluraTest/jslint/env-js.jar b/AlluraTest/jslint/env-js.jar
new file mode 100644
index 0000000..072891a
Binary files /dev/null and b/AlluraTest/jslint/env-js.jar differ
[05/10] [#4122] rename AlluraTesting dir to AlluraTest,
to match the module name below
Posted by br...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/jslint/jslint.js
----------------------------------------------------------------------
diff --git a/AlluraTest/jslint/jslint.js b/AlluraTest/jslint/jslint.js
new file mode 100644
index 0000000..4b2ddcc
--- /dev/null
+++ b/AlluraTest/jslint/jslint.js
@@ -0,0 +1,5729 @@
+// jslint.js
+// 2010-08-05
+
+/*
+Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+/*
+ JSLINT is a global function. It takes two parameters.
+
+ var myResult = JSLINT(source, option);
+
+ The first parameter is either a string or an array of strings. If it is a
+ string, it will be split on '\n' or '\r'. If it is an array of strings, it
+ is assumed that each string represents one line. The source can be a
+ JavaScript text, or HTML text, or a Konfabulator text.
+
+ The second parameter is an optional object of options which control the
+ operation of JSLINT. Most of the options are booleans: They are all are
+ optional and have a default value of false.
+
+ If it checks out, JSLINT returns true. Otherwise, it returns false.
+
+ If false, you can inspect JSLINT.errors to find out the problems.
+ JSLINT.errors is an array of objects containing these members:
+
+ {
+ line : The line (relative to 0) at which the lint was found
+ character : The character (relative to 0) at which the lint was found
+ reason : The problem
+ evidence : The text line in which the problem occurred
+ raw : The raw message before the details were inserted
+ a : The first detail
+ b : The second detail
+ c : The third detail
+ d : The fourth detail
+ }
+
+ If a fatal error was found, a null will be the last element of the
+ JSLINT.errors array.
+
+ You can request a Function Report, which shows all of the functions
+ and the parameters and vars that they use. This can be used to find
+ implied global variables and other problems. The report is in HTML and
+ can be inserted in an HTML <body>.
+
+ var myReport = JSLINT.report(limited);
+
+ If limited is true, then the report will be limited to only errors.
+
+ You can request a data structure which contains JSLint's results.
+
+ var myData = JSLINT.data();
+
+ It returns a structure with this form:
+
+ {
+ errors: [
+ {
+ line: NUMBER,
+ character: NUMBER,
+ reason: STRING,
+ evidence: STRING
+ }
+ ],
+ functions: [
+ name: STRING,
+ line: NUMBER,
+ last: NUMBER,
+ param: [
+ STRING
+ ],
+ closure: [
+ STRING
+ ],
+ var: [
+ STRING
+ ],
+ exception: [
+ STRING
+ ],
+ outer: [
+ STRING
+ ],
+ unused: [
+ STRING
+ ],
+ global: [
+ STRING
+ ],
+ label: [
+ STRING
+ ]
+ ],
+ globals: [
+ STRING
+ ],
+ member: {
+ STRING: NUMBER
+ },
+ unuseds: [
+ {
+ name: STRING,
+ line: NUMBER
+ }
+ ],
+ implieds: [
+ {
+ name: STRING,
+ line: NUMBER
+ }
+ ],
+ urls: [
+ STRING
+ ],
+ json: BOOLEAN
+ }
+
+ Empty arrays will not be included.
+
+*/
+
+/*jslint
+ evil: true, nomen: false, onevar: false, regexp: false, strict: true
+*/
+
+/*members "\b", "\t", "\n", "\f", "\r", "!=", "!==", "\"", "%",
+ "(begin)", "(breakage)", "(context)", "(error)", "(global)",
+ "(identifier)", "(last)", "(line)", "(loopage)", "(name)", "(onevar)",
+ "(params)", "(scope)", "(verb)", "*", "+", "++", "-", "--", "\/",
+ "<", "<=", "==", "===", ">", ">=", ADSAFE, ActiveXObject,
+ Array, Boolean, COM, CScript, Canvas, CustomAnimation, Date, Debug, E,
+ Enumerator, Error, EvalError, FadeAnimation, Flash, FormField, Frame,
+ Function, HotKey, Image, JSON, LN10, LN2, LOG10E, LOG2E, MAX_VALUE,
+ MIN_VALUE, Math, MenuItem, MoveAnimation, NEGATIVE_INFINITY, Number,
+ Object, Option, PI, POSITIVE_INFINITY, Point, RangeError, Rectangle,
+ ReferenceError, RegExp, ResizeAnimation, RotateAnimation, SQRT1_2,
+ SQRT2, ScrollBar, String, Style, SyntaxError, System, Text, TextArea,
+ Timer, TypeError, URIError, URL, VBArray, WScript, Web, Window, XMLDOM,
+ XMLHttpRequest, "\\", a, abbr, acronym, addEventListener, address,
+ adsafe, alert, aliceblue, animator, antiquewhite, appleScript, applet,
+ apply, approved, aqua, aquamarine, area, arguments, arity, article,
+ aside, audio, autocomplete, azure, b, background,
+ "background-attachment", "background-color", "background-image",
+ "background-position", "background-repeat", base, bdo, beep, beige, big,
+ bisque, bitwise, black, blanchedalmond, block, blockquote, blue,
+ blueviolet, blur, body, border, "border-bottom", "border-bottom-color",
+ "border-bottom-style", "border-bottom-width", "border-collapse",
+ "border-color", "border-left", "border-left-color", "border-left-style",
+ "border-left-width", "border-right", "border-right-color",
+ "border-right-style", "border-right-width", "border-spacing",
+ "border-style", "border-top", "border-top-color", "border-top-style",
+ "border-top-width", "border-width", bottom, br, brown, browser,
+ burlywood, button, bytesToUIString, c, cadetblue, call, callee, caller,
+ canvas, cap, caption, "caption-side", cases, center, charAt, charCodeAt,
+ character, chartreuse, chocolate, chooseColor, chooseFile, chooseFolder,
+ cite, clear, clearInterval, clearTimeout, clip, close, closeWidget,
+ closed, closure, cm, code, col, colgroup, color, command, comment,
+ condition, confirm, console, constructor, content, convertPathToHFS,
+ convertPathToPlatform, coral, cornflowerblue, cornsilk,
+ "counter-increment", "counter-reset", create, crimson, css, cursor,
+ cyan, d, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen,
+ darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred,
+ darksalmon, darkseagreen, darkslateblue, darkslategray, darkturquoise,
+ darkviolet, data, datalist, dd, debug, decodeURI, decodeURIComponent,
+ deeppink, deepskyblue, defaultStatus, defineClass, del, deserialize,
+ details, devel, dfn, dialog, dimension, dimgray, dir, direction,
+ display, div, dl, document, dodgerblue, dt, edition, else, em, embed,
+ empty, "empty-cells", encodeURI, encodeURIComponent, entityify, eqeqeq,
+ errors, es5, escape, eval, event, evidence, evil, ex, exception, exec, exps,
+ fieldset, figure, filesystem, firebrick, first, float, floor,
+ floralwhite, focus, focusWidget, font, "font-face", "font-family",
+ "font-size", "font-size-adjust", "font-stretch", "font-style",
+ "font-variant", "font-weight", footer, forestgreen, forin, form,
+ fragment, frame, frames, frameset, from, fromCharCode, fuchsia, fud,
+ funct, function, functions, g, gainsboro, gc, getComputedStyle,
+ ghostwhite, global, globals, gold, goldenrod, gray, green, greenyellow,
+ h1, h2, h3, h4, h5, h6, hasOwnProperty, head, header, height, help,
+ hgroup, history, honeydew, hotpink, hr, 'hta:application', html,
+ i, iTunes, id, identifier,
+ iframe, img, immed, implieds, in, include, indent, indexOf, indianred,
+ indigo, init, input, ins, isAlpha, isApplicationRunning, isDigit,
+ isFinite, isNaN, ivory, join, jslint, json, kbd, keygen, khaki,
+ konfabulatorVersion, label, labelled, lang, last, lavender,
+ lavenderblush, lawngreen, laxbreak, lbp, led, left, legend,
+ lemonchiffon, length, "letter-spacing", li, lib, lightblue, lightcoral,
+ lightcyan, lightgoldenrodyellow, lightgreen, lightpink, lightsalmon,
+ lightseagreen, lightskyblue, lightslategray, lightsteelblue,
+ lightyellow, lime, limegreen, line, "line-height", linen, link,
+ "list-style", "list-style-image", "list-style-position",
+ "list-style-type", load, loadClass, location, log, m, magenta, map,
+ margin, "margin-bottom", "margin-left", "margin-right", "margin-top",
+ mark, "marker-offset", maroon, match, "max-height", "max-width", maxerr,
+ maxlen, md5, media, mediumaquamarine, mediumblue, mediumorchid,
+ mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen,
+ mediumturquoise, mediumvioletred, member, menu, message, meta, meter,
+ midnightblue, "min-height", "min-width", mintcream, mistyrose, mm,
+ moccasin, moveBy, moveTo, name, nav, navajowhite, navigator, navy, new,
+ newcap, noframes, nomen, noscript, nud, object, ol, oldlace, olive,
+ olivedrab, on, onbeforeunload, onblur, onerror, onevar, onfocus, onload,
+ onresize, onunload, opacity, open, openURL, opener, opera, optgroup,
+ option, orange, orangered, orchid, outer, outline, "outline-color",
+ "outline-style", "outline-width", output, overflow, "overflow-x",
+ "overflow-y", p, padding, "padding-bottom", "padding-left",
+ "padding-right", "padding-top", page, "page-break-after",
+ "page-break-before", palegoldenrod, palegreen, paleturquoise,
+ palevioletred, papayawhip, param, parent, parseFloat, parseInt,
+ passfail, pc, peachpuff, peru, pink, play, plum, plusplus, pop,
+ popupMenu, position, powderblue, pre, predef, preferenceGroups,
+ preferences, print, progress, prompt, prototype, pt, purple, push, px,
+ q, quit, quotes, random, range, raw, reach, readFile, readUrl, reason,
+ red, regexp, reloadWidget, removeEventListener, replace, report,
+ reserved, resizeBy, resizeTo, resolvePath, resumeUpdates, rhino, right,
+ rosybrown, royalblue, rp, rt, ruby, runCommand, runCommandInBg,
+ saddlebrown, safe, salmon, samp, sandybrown, saveAs, savePreferences,
+ screen, script, scroll, scrollBy, scrollTo, seagreen, seal, search,
+ seashell, section, select, serialize, setInterval, setTimeout, shift,
+ showWidgetPreferences, sienna, silver, skyblue, slateblue, slategray,
+ sleep, slice, small, snow, sort, source, span, spawn, speak, split,
+ springgreen, src, stack, status, steelblue, strict, strong, style,
+ styleproperty, sub, substr, sup, supplant, suppressUpdates, sync,
+ system, table, "table-layout", tan, tbody, td, teal, tellWidget, test,
+ "text-align", "text-decoration", "text-indent", "text-shadow",
+ "text-transform", textarea, tfoot, th, thead, thistle, time, title,
+ toLowerCase, toString, toUpperCase, toint32, token, tomato, top, tr, tt,
+ turquoise, type, u, ul, undef, unescape, "unicode-bidi", unused,
+ unwatch, updateNow, urls, value, valueOf, var, version,
+ "vertical-align", video, violet, visibility, watch, wheat, white,
+ "white-space", whitesmoke, widget, width, windows, "word-spacing",
+ "word-wrap", yahooCheckLogin, yahooLogin, yahooLogout, yellow,
+ yellowgreen, "z-index"
+*/
+
+// We build the application inside a function so that we produce only a single
+// global variable. The function will be invoked, its return value is the JSLINT
+// application itself.
+
+"use strict";
+
+var JSLINT = (function () {
+ var adsafe_id, // The widget's ADsafe id.
+ adsafe_may, // The widget may load approved scripts.
+ adsafe_went, // ADSAFE.go has been called.
+ anonname, // The guessed name for anonymous functions.
+ approved, // ADsafe approved urls.
+
+ atrule = {
+ media : true,
+ 'font-face': true,
+ page : true
+ },
+
+// These are operators that should not be used with the ! operator.
+
+ bang = {
+ '<': true,
+ '<=': true,
+ '==': true,
+ '===': true,
+ '!==': true,
+ '!=': true,
+ '>': true,
+ '>=': true,
+ '+': true,
+ '-': true,
+ '*': true,
+ '/': true,
+ '%': true
+ },
+
+// These are members that should not be permitted in the safe subset.
+
+ banned = { // the member names that ADsafe prohibits.
+ 'arguments' : true,
+ callee : true,
+ caller : true,
+ constructor : true,
+ 'eval' : true,
+ prototype : true,
+ stack : true,
+ unwatch : true,
+ valueOf : true,
+ watch : true
+ },
+
+
+// These are the JSLint boolean options.
+
+ boolOptions = {
+ adsafe : true, // if ADsafe should be enforced
+ bitwise : true, // if bitwise operators should not be allowed
+ browser : true, // if the standard browser globals should be predefined
+ cap : true, // if upper case HTML should be allowed
+ css : true, // if CSS workarounds should be tolerated
+ debug : true, // if debugger statements should be allowed
+ devel : true, // if logging should be allowed (console, alert, etc.)
+ eqeqeq : true, // if === should be required
+ es5 : true, // if ES5 syntax should be allowed
+ evil : true, // if eval should be allowed
+ forin : true, // if for in statements must filter
+ fragment : true, // if HTML fragments should be allowed
+ immed : true, // if immediate invocations must be wrapped in parens
+ laxbreak : true, // if line breaks should not be checked
+ newcap : true, // if constructor names must be capitalized
+ nomen : true, // if names should be checked
+ on : true, // if HTML event handlers should be allowed
+ onevar : true, // if only one var statement per function should be allowed
+ passfail : true, // if the scan should stop on first error
+ plusplus : true, // if increment/decrement should not be allowed
+ regexp : true, // if the . should not be allowed in regexp literals
+ rhino : true, // if the Rhino environment globals should be predefined
+ undef : true, // if variables should be declared before used
+ safe : true, // if use of some browser features should be restricted
+ windows : true, // if MS Windows-specigic globals should be predefined
+ strict : true, // require the "use strict"; pragma
+ sub : true, // if all forms of subscript notation are tolerated
+ white : true, // if strict whitespace rules apply
+ widget : true // if the Yahoo Widgets globals should be predefined
+ },
+
+// browser contains a set of global names which are commonly provided by a
+// web browser environment.
+
+ browser = {
+ addEventListener: false,
+ blur : false,
+ clearInterval : false,
+ clearTimeout : false,
+ close : false,
+ closed : false,
+ defaultStatus : false,
+ document : false,
+ event : false,
+ focus : false,
+ frames : false,
+ getComputedStyle: false,
+ history : false,
+ Image : false,
+ length : false,
+ location : false,
+ moveBy : false,
+ moveTo : false,
+ name : false,
+ navigator : false,
+ onbeforeunload : true,
+ onblur : true,
+ onerror : true,
+ onfocus : true,
+ onload : true,
+ onresize : true,
+ onunload : true,
+ open : false,
+ opener : false,
+ Option : false,
+ parent : false,
+ print : false,
+ removeEventListener: false,
+ resizeBy : false,
+ resizeTo : false,
+ screen : false,
+ scroll : false,
+ scrollBy : false,
+ scrollTo : false,
+ setInterval : false,
+ setTimeout : false,
+ status : false,
+ top : false,
+ XMLHttpRequest : false
+ },
+
+ cssAttributeData,
+ cssAny,
+
+ cssColorData = {
+ "aliceblue" : true,
+ "antiquewhite" : true,
+ "aqua" : true,
+ "aquamarine" : true,
+ "azure" : true,
+ "beige" : true,
+ "bisque" : true,
+ "black" : true,
+ "blanchedalmond" : true,
+ "blue" : true,
+ "blueviolet" : true,
+ "brown" : true,
+ "burlywood" : true,
+ "cadetblue" : true,
+ "chartreuse" : true,
+ "chocolate" : true,
+ "coral" : true,
+ "cornflowerblue" : true,
+ "cornsilk" : true,
+ "crimson" : true,
+ "cyan" : true,
+ "darkblue" : true,
+ "darkcyan" : true,
+ "darkgoldenrod" : true,
+ "darkgray" : true,
+ "darkgreen" : true,
+ "darkkhaki" : true,
+ "darkmagenta" : true,
+ "darkolivegreen" : true,
+ "darkorange" : true,
+ "darkorchid" : true,
+ "darkred" : true,
+ "darksalmon" : true,
+ "darkseagreen" : true,
+ "darkslateblue" : true,
+ "darkslategray" : true,
+ "darkturquoise" : true,
+ "darkviolet" : true,
+ "deeppink" : true,
+ "deepskyblue" : true,
+ "dimgray" : true,
+ "dodgerblue" : true,
+ "firebrick" : true,
+ "floralwhite" : true,
+ "forestgreen" : true,
+ "fuchsia" : true,
+ "gainsboro" : true,
+ "ghostwhite" : true,
+ "gold" : true,
+ "goldenrod" : true,
+ "gray" : true,
+ "green" : true,
+ "greenyellow" : true,
+ "honeydew" : true,
+ "hotpink" : true,
+ "indianred" : true,
+ "indigo" : true,
+ "ivory" : true,
+ "khaki" : true,
+ "lavender" : true,
+ "lavenderblush" : true,
+ "lawngreen" : true,
+ "lemonchiffon" : true,
+ "lightblue" : true,
+ "lightcoral" : true,
+ "lightcyan" : true,
+ "lightgoldenrodyellow" : true,
+ "lightgreen" : true,
+ "lightpink" : true,
+ "lightsalmon" : true,
+ "lightseagreen" : true,
+ "lightskyblue" : true,
+ "lightslategray" : true,
+ "lightsteelblue" : true,
+ "lightyellow" : true,
+ "lime" : true,
+ "limegreen" : true,
+ "linen" : true,
+ "magenta" : true,
+ "maroon" : true,
+ "mediumaquamarine" : true,
+ "mediumblue" : true,
+ "mediumorchid" : true,
+ "mediumpurple" : true,
+ "mediumseagreen" : true,
+ "mediumslateblue" : true,
+ "mediumspringgreen" : true,
+ "mediumturquoise" : true,
+ "mediumvioletred" : true,
+ "midnightblue" : true,
+ "mintcream" : true,
+ "mistyrose" : true,
+ "moccasin" : true,
+ "navajowhite" : true,
+ "navy" : true,
+ "oldlace" : true,
+ "olive" : true,
+ "olivedrab" : true,
+ "orange" : true,
+ "orangered" : true,
+ "orchid" : true,
+ "palegoldenrod" : true,
+ "palegreen" : true,
+ "paleturquoise" : true,
+ "palevioletred" : true,
+ "papayawhip" : true,
+ "peachpuff" : true,
+ "peru" : true,
+ "pink" : true,
+ "plum" : true,
+ "powderblue" : true,
+ "purple" : true,
+ "red" : true,
+ "rosybrown" : true,
+ "royalblue" : true,
+ "saddlebrown" : true,
+ "salmon" : true,
+ "sandybrown" : true,
+ "seagreen" : true,
+ "seashell" : true,
+ "sienna" : true,
+ "silver" : true,
+ "skyblue" : true,
+ "slateblue" : true,
+ "slategray" : true,
+ "snow" : true,
+ "springgreen" : true,
+ "steelblue" : true,
+ "tan" : true,
+ "teal" : true,
+ "thistle" : true,
+ "tomato" : true,
+ "turquoise" : true,
+ "violet" : true,
+ "wheat" : true,
+ "white" : true,
+ "whitesmoke" : true,
+ "yellow" : true,
+ "yellowgreen" : true
+ },
+
+ cssBorderStyle,
+ cssBreak,
+
+ cssLengthData = {
+ '%': true,
+ 'cm': true,
+ 'em': true,
+ 'ex': true,
+ 'in': true,
+ 'mm': true,
+ 'pc': true,
+ 'pt': true,
+ 'px': true
+ },
+
+ cssOverflow,
+
+ devel = {
+ alert : false,
+ confirm : false,
+ console : false,
+ Debug : false,
+ opera : false,
+ prompt : false
+ },
+
+ escapes = {
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '/' : '\\/',
+ '\\': '\\\\'
+ },
+
+ funct, // The current function
+
+ functionicity = [
+ 'closure', 'exception', 'global', 'label',
+ 'outer', 'unused', 'var'
+ ],
+
+ functions, // All of the functions
+
+ global, // The global scope
+ htmltag = {
+ a: {},
+ abbr: {},
+ acronym: {},
+ address: {},
+ applet: {},
+ area: {empty: true, parent: ' map '},
+ article: {},
+ aside: {},
+ audio: {},
+ b: {},
+ base: {empty: true, parent: ' head '},
+ bdo: {},
+ big: {},
+ blockquote: {},
+ body: {parent: ' html noframes '},
+ br: {empty: true},
+ button: {},
+ canvas: {parent: ' body p div th td '},
+ caption: {parent: ' table '},
+ center: {},
+ cite: {},
+ code: {},
+ col: {empty: true, parent: ' table colgroup '},
+ colgroup: {parent: ' table '},
+ command: {parent: ' menu '},
+ datalist: {},
+ dd: {parent: ' dl '},
+ del: {},
+ details: {},
+ dialog: {},
+ dfn: {},
+ dir: {},
+ div: {},
+ dl: {},
+ dt: {parent: ' dl '},
+ em: {},
+ embed: {},
+ fieldset: {},
+ figure: {},
+ font: {},
+ footer: {},
+ form: {},
+ frame: {empty: true, parent: ' frameset '},
+ frameset: {parent: ' html frameset '},
+ h1: {},
+ h2: {},
+ h3: {},
+ h4: {},
+ h5: {},
+ h6: {},
+ head: {parent: ' html '},
+ header: {},
+ hgroup: {},
+ hr: {empty: true},
+ 'hta:application':
+ {empty: true, parent: ' head '},
+ html: {parent: '*'},
+ i: {},
+ iframe: {},
+ img: {empty: true},
+ input: {empty: true},
+ ins: {},
+ kbd: {},
+ keygen: {},
+ label: {},
+ legend: {parent: ' details fieldset figure '},
+ li: {parent: ' dir menu ol ul '},
+ link: {empty: true, parent: ' head '},
+ map: {},
+ mark: {},
+ menu: {},
+ meta: {empty: true, parent: ' head noframes noscript '},
+ meter: {},
+ nav: {},
+ noframes: {parent: ' html body '},
+ noscript: {},
+ object: {},
+ ol: {},
+ optgroup: {parent: ' select '},
+ option: {parent: ' optgroup select '},
+ output: {},
+ p: {},
+ param: {parent: ' applet object '},
+ pre: {},
+ progress: {},
+ q: {},
+ rp: {},
+ rt: {},
+ ruby: {},
+ s: {},
+ samp: {},
+ script: {empty: true, parent: ' body div frame head iframe p pre span '},
+ section: {},
+ select: {},
+ small: {},
+ span: {},
+ source: {},
+ strong: {},
+ style: {parent: ' head ', empty: true},
+ sub: {},
+ sup: {},
+ table: {},
+ tbody: {parent: ' table '},
+ td: {parent: ' tr '},
+ textarea: {},
+ tfoot: {parent: ' table '},
+ th: {parent: ' tr '},
+ thead: {parent: ' table '},
+ time: {},
+ title: {parent: ' head '},
+ tr: {parent: ' table tbody thead tfoot '},
+ tt: {},
+ u: {},
+ ul: {},
+ 'var': {},
+ video: {}
+ },
+
+ ids, // HTML ids
+ implied, // Implied globals
+ inblock,
+ indent,
+ jsonmode,
+ lines,
+ lookahead,
+ member,
+ membersOnly,
+ nexttoken,
+ noreach,
+ option,
+ predefined, // Global variables defined by option
+ prereg,
+ prevtoken,
+
+ rhino = {
+ defineClass : false,
+ deserialize : false,
+ gc : false,
+ help : false,
+ load : false,
+ loadClass : false,
+ print : false,
+ quit : false,
+ readFile : false,
+ readUrl : false,
+ runCommand : false,
+ seal : false,
+ serialize : false,
+ spawn : false,
+ sync : false,
+ toint32 : false,
+ version : false
+ },
+
+ scope, // The current scope
+
+ windows = {
+ ActiveXObject: false,
+ CScript : false,
+ Debug : false,
+ Enumerator : false,
+ System : false,
+ VBArray : false,
+ WScript : false
+ },
+
+ src,
+ stack,
+
+// standard contains the global names that are provided by the
+// ECMAScript standard.
+
+ standard = {
+ 'void' : false,
+ Array : false,
+ Boolean : false,
+ Date : false,
+ decodeURI : false,
+ decodeURIComponent : false,
+ encodeURI : false,
+ encodeURIComponent : false,
+ Error : false,
+ 'eval' : false,
+ EvalError : false,
+ Function : false,
+ hasOwnProperty : false,
+ isFinite : false,
+ isNaN : false,
+ JSON : false,
+ Math : false,
+ Number : false,
+ Object : false,
+ parseInt : false,
+ parseFloat : false,
+ RangeError : false,
+ ReferenceError : false,
+ RegExp : false,
+ String : false,
+ SyntaxError : false,
+ TypeError : false,
+ URIError : false
+ },
+
+ standard_member = {
+ E : true,
+ LN2 : true,
+ LN10 : true,
+ LOG2E : true,
+ LOG10E : true,
+ PI : true,
+ SQRT1_2 : true,
+ SQRT2 : true,
+ MAX_VALUE : true,
+ MIN_VALUE : true,
+ NEGATIVE_INFINITY : true,
+ POSITIVE_INFINITY : true
+ },
+
+ strict_mode,
+ syntax = {},
+ tab,
+ token,
+ urls,
+ warnings,
+
+// widget contains the global names which are provided to a Yahoo
+// (fna Konfabulator) widget.
+
+ widget = {
+ alert : true,
+ animator : true,
+ appleScript : true,
+ beep : true,
+ bytesToUIString : true,
+ Canvas : true,
+ chooseColor : true,
+ chooseFile : true,
+ chooseFolder : true,
+ closeWidget : true,
+ COM : true,
+ convertPathToHFS : true,
+ convertPathToPlatform : true,
+ CustomAnimation : true,
+ escape : true,
+ FadeAnimation : true,
+ filesystem : true,
+ Flash : true,
+ focusWidget : true,
+ form : true,
+ FormField : true,
+ Frame : true,
+ HotKey : true,
+ Image : true,
+ include : true,
+ isApplicationRunning : true,
+ iTunes : true,
+ konfabulatorVersion : true,
+ log : true,
+ md5 : true,
+ MenuItem : true,
+ MoveAnimation : true,
+ openURL : true,
+ play : true,
+ Point : true,
+ popupMenu : true,
+ preferenceGroups : true,
+ preferences : true,
+ print : true,
+ prompt : true,
+ random : true,
+ Rectangle : true,
+ reloadWidget : true,
+ ResizeAnimation : true,
+ resolvePath : true,
+ resumeUpdates : true,
+ RotateAnimation : true,
+ runCommand : true,
+ runCommandInBg : true,
+ saveAs : true,
+ savePreferences : true,
+ screen : true,
+ ScrollBar : true,
+ showWidgetPreferences : true,
+ sleep : true,
+ speak : true,
+ Style : true,
+ suppressUpdates : true,
+ system : true,
+ tellWidget : true,
+ Text : true,
+ TextArea : true,
+ Timer : true,
+ unescape : true,
+ updateNow : true,
+ URL : true,
+ Web : true,
+ widget : true,
+ Window : true,
+ XMLDOM : true,
+ XMLHttpRequest : true,
+ yahooCheckLogin : true,
+ yahooLogin : true,
+ yahooLogout : true
+ },
+
+// xmode is used to adapt to the exceptions in html parsing.
+// It can have these states:
+// false .js script file
+// html
+// outer
+// script
+// style
+// scriptstring
+// styleproperty
+
+ xmode,
+ xquote,
+
+// unsafe comment or string
+ ax = /@cc|<\/?|script|\]*s\]|<\s*!|</i,
+// unsafe characters that are silently deleted by one or more browsers
+// Whitelist Replacement Char, 0xfffd
+ cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\ufffc\ufffe-\uffff]/,
+// token
+ tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jslint|members?|global)?|=|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/,
+// html token
+ hx = /^\s*(['"=>\/&#]|<(?:\/|\!(?:--)?)?|[a-zA-Z][a-zA-Z0-9_\-:]*|[0-9]+|--)/,
+// characters in strings that need escapement
+ nx = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
+ nxg = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+// outer html token
+ ox = /[>&]|<[\/!]?|--/,
+// star slash
+ lx = /\*\/|\/\*/,
+// identifier
+ ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/,
+// javascript url
+ jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i,
+// url badness
+ ux = /&|\+|\u00AD|\.\.|\/\*|%[^;]|base64|url|expression|data|mailto/i,
+// style
+ sx = /^\s*([{:#%.=,>+\[\]@()"';]|\*=?|\$=|\|=|\^=|~=|[a-zA-Z_][a-zA-Z0-9_\-]*|[0-9]+|<\/|\/\*)/,
+ ssx = /^\s*(\.?\d+(?:\.\d+)?|[@#!"'};:\-%.=,+\[\]()*_]|[a-zA-Z][a-zA-Z0-9._\-]*|\/\*?|<\/)/,
+// attributes characters
+ //qx = /[^a-zA-Z0-9+\-_\/ ]/,
+ qx = /[^a-zA-Z0-9+\-_\/ .#]/, // We want dots in names, period; and hashes for templating
+// query characters for ids
+ //dx = /[\[\]\/\\"'*<>.&:(){}+=#]/,
+ // allow . and /
+ dx = /[\[\]\\"'*<>&:(){}+=#]/,
+
+ rx = {
+ outer: hx,
+ html: hx,
+ style: sx,
+ styleproperty: ssx
+ };
+
+ function F() {}
+
+ if (typeof Object.create !== 'function') {
+ Object.create = function (o) {
+ F.prototype = o;
+ return new F();
+ };
+ }
+
+
+ function is_own(object, name) {
+ return Object.prototype.hasOwnProperty.call(object, name);
+ }
+
+
+ function combine(t, o) {
+ var n;
+ for (n in o) {
+ if (is_own(o, n)) {
+ t[n] = o[n];
+ }
+ }
+ }
+
+ String.prototype.entityify = function () {
+ return this.
+ replace(/&/g, '&').
+ replace(/</g, '<').
+ replace(/>/g, '>');
+ };
+
+ String.prototype.isAlpha = function () {
+ return (this >= 'a' && this <= 'z\uffff') ||
+ (this >= 'A' && this <= 'Z\uffff');
+ };
+
+
+ String.prototype.isDigit = function () {
+ return (this >= '0' && this <= '9');
+ };
+
+
+ String.prototype.supplant = function (o) {
+ return this.replace(/\{([^{}]*)\}/g, function (a, b) {
+ var r = o[b];
+ return typeof r === 'string' || typeof r === 'number' ? r : a;
+ });
+ };
+
+ String.prototype.name = function () {
+
+// If the string looks like an identifier, then we can return it as is.
+// If the string contains no control characters, no quote characters, and no
+// backslash characters, then we can simply slap some quotes around it.
+// Otherwise we must also replace the offending characters with safe
+// sequences.
+
+ if (ix.test(this)) {
+ return this;
+ }
+ if (nx.test(this)) {
+ return '"' + this.replace(nxg, function (a) {
+ var c = escapes[a];
+ if (c) {
+ return c;
+ }
+ return '\\u' + ('0000' + a.charCodeAt().toString(16)).slice(-4);
+ }) + '"';
+ }
+ return '"' + this + '"';
+ };
+
+
+ function assume() {
+ if (!option.safe) {
+ if (option.rhino) {
+ combine(predefined, rhino);
+ }
+ if (option.devel) {
+ combine(predefined, devel);
+ }
+ if (option.browser) {
+ combine(predefined, browser);
+ }
+ if (option.windows) {
+ combine(predefined, windows);
+ }
+ if (option.widget) {
+ combine(predefined, widget);
+ }
+ }
+ }
+
+
+// Produce an error warning.
+
+ function quit(m, l, ch) {
+ throw {
+ name: 'JSLintError',
+ line: l,
+ character: ch,
+ message: m + " (" + Math.floor((l / lines.length) * 100) +
+ "% scanned)."
+ };
+ }
+
+ function warning(m, t, a, b, c, d) {
+ var ch, l, w;
+ t = t || nexttoken;
+ if (t.id === '(end)') { // `~
+ t = token;
+ }
+ l = t.line || 0;
+ ch = t.from || 0;
+ w = {
+ id: '(error)',
+ raw: m,
+ evidence: lines[l - 1] || '',
+ line: l,
+ character: ch,
+ a: a,
+ b: b,
+ c: c,
+ d: d
+ };
+ w.reason = m.supplant(w);
+ JSLINT.errors.push(w);
+ if (option.passfail) {
+ quit('Stopping. ', l, ch);
+ }
+ warnings += 1;
+ if (warnings >= option.maxerr) {
+ quit("Too many errors.", l, ch);
+ }
+ return w;
+ }
+
+ function warningAt(m, l, ch, a, b, c, d) {
+ return warning(m, {
+ line: l,
+ from: ch
+ }, a, b, c, d);
+ }
+
+ function error(m, t, a, b, c, d) {
+ var w = warning(m, t, a, b, c, d);
+ quit("Stopping, unable to continue.", w.line, w.character);
+ }
+
+ function errorAt(m, l, ch, a, b, c, d) {
+ return error(m, {
+ line: l,
+ from: ch
+ }, a, b, c, d);
+ }
+
+
+
+// lexical analysis
+
+ var lex = (function lex() {
+ var character, from, line, s;
+
+// Private lex methods
+
+ function nextLine() {
+ var at;
+ if (line >= lines.length) {
+ return false;
+ }
+ character = 1;
+ s = lines[line];
+ line += 1;
+ at = s.search(/ \t/);
+ if (at >= 0) {
+ warningAt("Mixed spaces and tabs.", line, at + 1);
+ }
+ s = s.replace(/\t/g, tab);
+ at = s.search(cx);
+ if (at >= 0) {
+ warningAt("Unsafe character.", line, at);
+ }
+ if (option.maxlen && option.maxlen < s.length) {
+ warningAt("Line too long.", line, s.length);
+ }
+ return true;
+ }
+
+// Produce a token object. The token inherits from a syntax symbol.
+
+ function it(type, value) {
+ var i, t;
+ if (type === '(color)') {
+ t = {type: type};
+ } else if (type === '(punctuator)' ||
+ (type === '(identifier)' && is_own(syntax, value))) {
+ t = syntax[value] || syntax['(error)'];
+ } else {
+ t = syntax[type];
+ }
+ t = Object.create(t);
+ if (type === '(string)' || type === '(range)') {
+ if (jx.test(value)) {
+ warningAt("Script URL.", line, from);
+ }
+ }
+ if (type === '(identifier)') {
+ t.identifier = true;
+ if (value === '__iterator__' || value === '__proto__') {
+ errorAt("Reserved name '{a}'.",
+ line, from, value);
+ } else if (option.nomen &&
+ (value.charAt(0) === '_' ||
+ value.charAt(value.length - 1) === '_')) {
+ warningAt("Unexpected {a} in '{b}'.", line, from,
+ "dangling '_'", value);
+ }
+ }
+ t.value = value;
+ t.line = line;
+ t.character = character;
+ t.from = from;
+ i = t.id;
+ if (i !== '(endline)') {
+ prereg = i &&
+ (('(,=:[!&|?{};'.indexOf(i.charAt(i.length - 1)) >= 0) ||
+ i === 'return');
+ }
+ return t;
+ }
+
+// Public lex methods
+
+ return {
+ init: function (source) {
+ if (typeof source === 'string') {
+ lines = source.
+ replace(/\r\n/g, '\n').
+ replace(/\r/g, '\n').
+ split('\n');
+ } else {
+ lines = source;
+ }
+ line = 0;
+ nextLine();
+ from = 1;
+ },
+
+ range: function (begin, end) {
+ var c, value = '';
+ from = character;
+ if (s.charAt(0) !== begin) {
+ errorAt("Expected '{a}' and instead saw '{b}'.",
+ line, character, begin, s.charAt(0));
+ }
+ for (;;) {
+ s = s.slice(1);
+ character += 1;
+ c = s.charAt(0);
+ switch (c) {
+ case '':
+ errorAt("Missing '{a}'.", line, character, c);
+ break;
+ case end:
+ s = s.slice(1);
+ character += 1;
+ return it('(range)', value);
+ case xquote:
+ case '\\':
+ warningAt("Unexpected '{a}'.", line, character, c);
+ }
+ value += c;
+ }
+
+ },
+
+// skip all content up to marker
+
+ skip_till: function (end) {
+ for (;;) {
+ i = s.indexOf(end);
+ if (i >= 0) {
+ break;
+ }
+ if (!nextLine()) {
+ errorAt("Unclosed {a} block.", line, character, end);
+ }
+ }
+ character += i;
+ s = s.substr(i);
+ },
+
+// token -- this is called by advance to get the next token.
+
+ token: function () {
+ var b, c, captures, d, depth, high, i, l, low, q, t;
+
+ function match(x) {
+ var r = x.exec(s), r1;
+ if (r) {
+ l = r[0].length;
+ r1 = r[1];
+ c = r1.charAt(0);
+ s = s.substr(l);
+ from = character + l - r1.length;
+ character += l;
+ return r1;
+ }
+ }
+
+ function string(x) {
+ var c, j, r = '';
+
+ if (jsonmode && x !== '"') {
+ warningAt("Strings must use doublequote.",
+ line, character);
+ }
+
+ if (xquote === x || (xmode === 'scriptstring' && !xquote)) {
+ return it('(punctuator)', x);
+ }
+
+ function esc(n) {
+ var i = parseInt(s.substr(j + 1, n), 16);
+ j += n;
+ if (i >= 32 && i <= 126 &&
+ i !== 34 && i !== 92 && i !== 39) {
+ warningAt("Unnecessary escapement.", line, character);
+ }
+ character += n;
+ c = String.fromCharCode(i);
+ }
+ j = 0;
+ for (;;) {
+ while (j >= s.length) {
+ j = 0;
+ if (xmode !== 'html' || !nextLine()) {
+ errorAt("Unclosed string.", line, from);
+ }
+ }
+ c = s.charAt(j);
+ if (c === x) {
+ character += 1;
+ s = s.substr(j + 1);
+ return it('(string)', r, x);
+ }
+ if (c < ' ') {
+ if (c === '\n' || c === '\r') {
+ break;
+ }
+ warningAt("Control character in string: {a}.",
+ line, character + j, s.slice(0, j));
+ } else if (c === xquote) {
+ warningAt("Bad HTML string", line, character + j);
+ } else if (c === '<') {
+ if (option.safe && xmode === 'html') {
+ warningAt("ADsafe string violation.",
+ line, character + j);
+ } else if (s.charAt(j + 1) === '/' && (xmode || option.safe) && s.substr(j + 2, 6) === 'script') {
+ warningAt("Expected '<\\/' and instead saw '</'.", line, character);
+ } else if (s.charAt(j + 1) === '!' && (xmode || option.safe)) {
+ warningAt("Unexpected '<!' in a string.", line, character);
+ }
+ } else if (c === '\\') {
+ if (xmode === 'html') {
+ if (option.safe) {
+ warningAt("ADsafe string violation.",
+ line, character + j);
+ }
+ } else if (xmode === 'styleproperty') {
+ j += 1;
+ character += 1;
+ c = s.charAt(j);
+ if (c !== x) {
+ warningAt("Escapement in style string.",
+ line, character + j);
+ }
+ } else {
+ j += 1;
+ character += 1;
+ c = s.charAt(j);
+ switch (c) {
+ case xquote:
+ warningAt("Bad HTML string", line,
+ character + j);
+ break;
+ case '\\':
+ case '\'':
+ case '"':
+ case '/':
+ break;
+ case 'b':
+ c = '\b';
+ break;
+ case 'f':
+ c = '\f';
+ break;
+ case 'n':
+ c = '\n';
+ break;
+ case 'r':
+ c = '\r';
+ break;
+ case 't':
+ c = '\t';
+ break;
+ case 'u':
+ esc(4);
+ break;
+ case 'v':
+ c = '\v';
+ break;
+ case 'x':
+ if (jsonmode) {
+ warningAt("Avoid \\x-.", line, character);
+ }
+ esc(2);
+ break;
+ default:
+ warningAt("Bad escapement.", line, character);
+ }
+ }
+ }
+ r += c;
+ character += 1;
+ j += 1;
+ }
+ }
+
+ for (;;) {
+ if (!s) {
+ return it(nextLine() ? '(endline)' : '(end)', '');
+ }
+ while (xmode === 'outer') {
+ i = s.search(ox);
+ if (i === 0) {
+ break;
+ } else if (i > 0) {
+ character += 1;
+ s = s.slice(i);
+ break;
+ } else {
+ if (!nextLine()) {
+ return it('(end)', '');
+ }
+ }
+ }
+// t = match(rx[xmode] || tx);
+// if (!t) {
+// if (xmode === 'html') {
+// return it('(error)', s.charAt(0));
+// } else {
+// t = '';
+// c = '';
+// while (s && s < '!') {
+// s = s.substr(1);
+// }
+// if (s) {
+// errorAt("Unexpected '{a}'.",
+// line, character, s.substr(0, 1));
+// }
+// }
+ t = match(rx[xmode] || tx);
+ if (!t) {
+ t = '';
+ c = '';
+ while (s && s < '!') {
+ s = s.substr(1);
+ }
+ if (s) {
+ if (xmode === 'html') {
+ return it('(error)', s.charAt(0));
+ } else {
+ errorAt("Unexpected '{a}'.",
+ line, character, s.substr(0, 1));
+ }
+ }
+ } else {
+
+ // identifier
+
+ if (c.isAlpha() || c === '_' || c === '$') {
+ return it('(identifier)', t);
+ }
+
+ // number
+
+ if (c.isDigit() || (c === '.' && t.substr(1, 1).isDigit())) {
+ if (c === '.') {
+ t = '0' + t;
+ c = '0';
+ }
+
+ if (xmode !== 'style' && !isFinite(Number(t))) {
+ warningAt("Bad number '{a}'.",
+ line, character, t);
+ }
+ if (xmode !== 'style' &&
+ xmode !== 'styleproperty' &&
+ s.substr(0, 1).isAlpha()) {
+ warningAt("Missing space after '{a}'.",
+ line, character, t);
+ }
+ if (c === '0') {
+ d = t.substr(1, 1);
+ if (d.isDigit()) {
+ if (token.id !== '.' && xmode !== 'styleproperty') {
+ warningAt("Don't use extra leading zeros '{a}'.",
+ line, character, t);
+ }
+ } else if (jsonmode && (d === 'x' || d === 'X')) {
+ warningAt("Avoid 0x-. '{a}'.",
+ line, character, t);
+ }
+ }
+ if (t.substr(t.length - 1) === '.') {
+ warningAt(
+ "A trailing decimal point can be confused with a dot '{a}'.",
+ line, character, t);
+ }
+ return it('(number)', t);
+ }
+ switch (t) {
+
+ // string
+
+ case '"':
+ case "'":
+ return string(t);
+
+ // // comment
+
+ case '//':
+ if (src || (xmode && xmode !== 'script')) {
+ warningAt("Unexpected comment.", line, character);
+ } else if (xmode === 'script' && /<\s*\//i.test(s)) {
+ warningAt("Unexpected <\/ in comment.", line, character);
+ } else if ((option.safe || xmode === 'script') && ax.test(s)) {
+ warningAt("Dangerous comment.", line, character);
+ }
+ s = '';
+ token.comment = true;
+ break;
+
+ // /* comment
+
+ case '/*':
+ if (src || (xmode && xmode !== 'script' && xmode !== 'style' && xmode !== 'styleproperty')) {
+ warningAt("Unexpected comment.", line, character);
+ }
+ if (option.safe && ax.test(s)) {
+ warningAt("ADsafe comment violation.", line, character);
+ }
+ for (;;) {
+ i = s.search(lx);
+ if (i >= 0) {
+ break;
+ }
+ if (!nextLine()) {
+ errorAt("Unclosed comment.", line, character);
+ } else {
+ if (option.safe && ax.test(s)) {
+ warningAt("ADsafe comment violation.",
+ line, character);
+ }
+ }
+ }
+ character += i + 2;
+ if (s.substr(i, 1) === '/') {
+ errorAt("Nested comment.", line, character);
+ }
+ s = s.substr(i + 2);
+ token.comment = true;
+ break;
+
+ // /*members /*jslint /*global
+
+ case '/*members':
+ case '/*member':
+ case '/*jslint':
+ case '/*global':
+ case '*/':
+ return {
+ value: t,
+ type: 'special',
+ line: line,
+ character: character,
+ from: from
+ };
+
+ case '':
+ break;
+ // /
+ case '/':
+ if (token.id === '/=') {
+ errorAt(
+"A regular expression literal can be confused with '/='.", line, from);
+ }
+ if (prereg) {
+ depth = 0;
+ captures = 0;
+ l = 0;
+ for (;;) {
+ b = true;
+ c = s.charAt(l);
+ l += 1;
+ switch (c) {
+ case '':
+ errorAt("Unclosed regular expression.",
+ line, from);
+ return;
+ case '/':
+ if (depth > 0) {
+ warningAt("Unescaped '{a}'.",
+ line, from + l, '/');
+ }
+ c = s.substr(0, l - 1);
+ q = {
+ g: true,
+ i: true,
+ m: true
+ };
+ while (q[s.charAt(l)] === true) {
+ q[s.charAt(l)] = false;
+ l += 1;
+ }
+ character += l;
+ s = s.substr(l);
+ q = s.charAt(0);
+ if (q === '/' || q === '*') {
+ errorAt("Confusing regular expression.",
+ line, from);
+ }
+ return it('(regexp)', c);
+ case '\\':
+ c = s.charAt(l);
+ if (c < ' ') {
+ warningAt(
+"Unexpected control character in regular expression.", line, from + l);
+ } else if (c === '<') {
+ warningAt(
+"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
+ }
+ l += 1;
+ break;
+ case '(':
+ depth += 1;
+ b = false;
+ if (s.charAt(l) === '?') {
+ l += 1;
+ switch (s.charAt(l)) {
+ case ':':
+ case '=':
+ case '!':
+ l += 1;
+ break;
+ default:
+ warningAt(
+"Expected '{a}' and instead saw '{b}'.", line, from + l, ':', s.charAt(l));
+ }
+ } else {
+ captures += 1;
+ }
+ break;
+ case '|':
+ b = false;
+ break;
+ case ')':
+ if (depth === 0) {
+ warningAt("Unescaped '{a}'.",
+ line, from + l, ')');
+ } else {
+ depth -= 1;
+ }
+ break;
+ case ' ':
+ q = 1;
+ while (s.charAt(l) === ' ') {
+ l += 1;
+ q += 1;
+ }
+ if (q > 1) {
+ warningAt(
+"Spaces are hard to count. Use {{a}}.", line, from + l, q);
+ }
+ break;
+ case '[':
+ c = s.charAt(l);
+ if (c === '^') {
+ l += 1;
+ if (option.regexp) {
+ warningAt("Insecure '{a}'.",
+ line, from + l, c);
+ }
+ }
+ q = false;
+ if (c === ']') {
+ warningAt("Empty class.", line,
+ from + l - 1);
+ q = true;
+ }
+klass: do {
+ c = s.charAt(l);
+ l += 1;
+ switch (c) {
+ case '[':
+ case '^':
+ warningAt("Unescaped '{a}'.",
+ line, from + l, c);
+ q = true;
+ break;
+ case '-':
+ if (q) {
+ q = false;
+ } else {
+ warningAt("Unescaped '{a}'.",
+ line, from + l, '-');
+ q = true;
+ }
+ break;
+ case ']':
+ if (!q) {
+ warningAt("Unescaped '{a}'.",
+ line, from + l - 1, '-');
+ }
+ break klass;
+ case '\\':
+ c = s.charAt(l);
+ if (c < ' ') {
+ warningAt(
+"Unexpected control character in regular expression.", line, from + l);
+ } else if (c === '<') {
+ warningAt(
+"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
+ }
+ l += 1;
+ q = true;
+ break;
+ case '/':
+ warningAt("Unescaped '{a}'.",
+ line, from + l - 1, '/');
+ q = true;
+ break;
+ case '<':
+ if (xmode === 'script') {
+ c = s.charAt(l);
+ if (c === '!' || c === '/') {
+ warningAt(
+"HTML confusion in regular expression '<{a}'.", line, from + l, c);
+ }
+ }
+ q = true;
+ break;
+ default:
+ q = true;
+ }
+ } while (c);
+ break;
+ case '.':
+ if (option.regexp) {
+ warningAt("Insecure '{a}'.", line,
+ from + l, c);
+ }
+ break;
+ case ']':
+ case '?':
+ case '{':
+ case '}':
+ case '+':
+ case '*':
+ warningAt("Unescaped '{a}'.", line,
+ from + l, c);
+ break;
+ case '<':
+ if (xmode === 'script') {
+ c = s.charAt(l);
+ if (c === '!' || c === '/') {
+ warningAt(
+"HTML confusion in regular expression '<{a}'.", line, from + l, c);
+ }
+ }
+ }
+ if (b) {
+ switch (s.charAt(l)) {
+ case '?':
+ case '+':
+ case '*':
+ l += 1;
+ if (s.charAt(l) === '?') {
+ l += 1;
+ }
+ break;
+ case '{':
+ l += 1;
+ c = s.charAt(l);
+ if (c < '0' || c > '9') {
+ warningAt(
+"Expected a number and instead saw '{a}'.", line, from + l, c);
+ }
+ l += 1;
+ low = +c;
+ for (;;) {
+ c = s.charAt(l);
+ if (c < '0' || c > '9') {
+ break;
+ }
+ l += 1;
+ low = +c + (low * 10);
+ }
+ high = low;
+ if (c === ',') {
+ l += 1;
+ high = Infinity;
+ c = s.charAt(l);
+ if (c >= '0' && c <= '9') {
+ l += 1;
+ high = +c;
+ for (;;) {
+ c = s.charAt(l);
+ if (c < '0' || c > '9') {
+ break;
+ }
+ l += 1;
+ high = +c + (high * 10);
+ }
+ }
+ }
+ if (s.charAt(l) !== '}') {
+ warningAt(
+"Expected '{a}' and instead saw '{b}'.", line, from + l, '}', c);
+ } else {
+ l += 1;
+ }
+ if (s.charAt(l) === '?') {
+ l += 1;
+ }
+ if (low > high) {
+ warningAt(
+"'{a}' should not be greater than '{b}'.", line, from + l, low, high);
+ }
+ }
+ }
+ }
+ c = s.substr(0, l - 1);
+ character += l;
+ s = s.substr(l);
+ return it('(regexp)', c);
+ }
+ return it('(punctuator)', t);
+
+ // punctuator
+
+ case '<!--':
+ l = line;
+ c = character;
+ for (;;) {
+ i = s.indexOf('--');
+ if (i >= 0) {
+ break;
+ }
+ i = s.indexOf('<!-');
+ if (i >= 0) {
+ errorAt("Nested HTML comment.",
+ line, character + i);
+ }
+ if (!nextLine()) {
+ errorAt("Unclosed HTML comment.", l, c);
+ }
+ }
+ l = s.indexOf('<!-');
+ if (l >= 0 && l < i) {
+ errorAt("Nested HTML comment.",
+ line, character + l);
+ }
+ character += i;
+ if (s[i + 2] !== '>') {
+ errorAt("Expected -->.", line, character);
+ }
+ character += 3;
+ s = s.slice(i + 3);
+ break;
+ case '#':
+ if (xmode === 'html' || xmode === 'styleproperty') {
+ for (;;) {
+ c = s.charAt(0);
+ if ((c < '0' || c > '9') &&
+ (c < 'a' || c > 'f') &&
+ (c < 'A' || c > 'F')) {
+ break;
+ }
+ character += 1;
+ s = s.substr(1);
+ t += c;
+ }
+ if (t.length !== 4 && t.length !== 7) {
+ warningAt("Bad hex color '{a}'.", line,
+ from + l, t);
+ }
+ return it('(color)', t);
+ }
+ return it('(punctuator)', t);
+ default:
+ if (xmode === 'outer' && c === '&') {
+ character += 1;
+ s = s.substr(1);
+ for (;;) {
+ c = s.charAt(0);
+ character += 1;
+ s = s.substr(1);
+ if (c === ';') {
+ break;
+ }
+ if (!((c >= '0' && c <= '9') ||
+ (c >= 'a' && c <= 'z') ||
+ c === '#')) {
+ errorAt("Bad entity", line, from + l,
+ character);
+ }
+ }
+ break;
+ }
+ return it('(punctuator)', t);
+ }
+ }
+ }
+ }
+ };
+ }());
+
+
+ function addlabel(t, type) {
+
+ if (option.safe && funct['(global)'] &&
+ typeof predefined[t] !== 'boolean') {
+ warning('ADsafe global: ' + t + '.', token);
+ } else if (t === 'hasOwnProperty') {
+ warning("'hasOwnProperty' is a really bad name.");
+ }
+
+// Define t in the current function in the current scope.
+
+ if (is_own(funct, t) && !funct['(global)']) {
+ warning(funct[t] === true ?
+ "'{a}' was used before it was defined." :
+ "'{a}' is already defined.",
+ nexttoken, t);
+ }
+ funct[t] = type;
+ if (funct['(global)']) {
+ global[t] = funct;
+ if (is_own(implied, t)) {
+ warning("'{a}' was used before it was defined.", nexttoken, t);
+ delete implied[t];
+ }
+ } else {
+ scope[t] = funct;
+ }
+ }
+
+
+ function doOption() {
+ var b, obj, filter, o = nexttoken.value, t, v;
+ switch (o) {
+ case '*/':
+ error("Unbegun comment.");
+ break;
+ case '/*members':
+ case '/*member':
+ o = '/*members';
+ if (!membersOnly) {
+ membersOnly = {};
+ }
+ obj = membersOnly;
+ break;
+ case '/*jslint':
+ if (option.safe) {
+ warning("ADsafe restriction.");
+ }
+ obj = option;
+ filter = boolOptions;
+ break;
+ case '/*global':
+ if (option.safe) {
+ warning("ADsafe restriction.");
+ }
+ obj = predefined;
+ break;
+ default:
+ }
+ t = lex.token();
+loop: for (;;) {
+ for (;;) {
+ if (t.type === 'special' && t.value === '*/') {
+ break loop;
+ }
+ if (t.id !== '(endline)' && t.id !== ',') {
+ break;
+ }
+ t = lex.token();
+ }
+ if (t.type !== '(string)' && t.type !== '(identifier)' &&
+ o !== '/*members') {
+ error("Bad option.", t);
+ }
+ v = lex.token();
+ if (v.id === ':') {
+ v = lex.token();
+ if (obj === membersOnly) {
+ error("Expected '{a}' and instead saw '{b}'.",
+ t, '*/', ':');
+ }
+ if (t.value === 'indent' && o === '/*jslint') {
+ b = +v.value;
+ if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
+ Math.floor(b) !== b) {
+ error("Expected a small integer and instead saw '{a}'.",
+ v, v.value);
+ }
+ obj.white = true;
+ obj.indent = b;
+ } else if (t.value === 'maxerr' && o === '/*jslint') {
+ b = +v.value;
+ if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
+ Math.floor(b) !== b) {
+ error("Expected a small integer and instead saw '{a}'.",
+ v, v.value);
+ }
+ obj.maxerr = b;
+ } else if (t.value === 'maxlen' && o === '/*jslint') {
+ b = +v.value;
+ if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
+ Math.floor(b) !== b) {
+ error("Expected a small integer and instead saw '{a}'.",
+ v, v.value);
+ }
+ obj.maxlen = b;
+ } else if (v.value === 'true') {
+ obj[t.value] = true;
+ } else if (v.value === 'false') {
+ obj[t.value] = false;
+ } else {
+ error("Bad option value.", v);
+ }
+ t = lex.token();
+ } else {
+ if (o === '/*jslint') {
+ error("Missing option value.", t);
+ }
+ obj[t.value] = false;
+ t = v;
+ }
+ }
+ if (filter) {
+ assume();
+ }
+ }
+
+
+// We need a peek function. If it has an argument, it peeks that much farther
+// ahead. It is used to distinguish
+// for ( var i in ...
+// from
+// for ( var i = ...
+
+ function peek(p) {
+ var i = p || 0, j = 0, t;
+
+ while (j <= i) {
+ t = lookahead[j];
+ if (!t) {
+ t = lookahead[j] = lex.token();
+ }
+ j += 1;
+ }
+ return t;
+ }
+
+
+
+// Produce the next token. It looks for programming errors.
+
+ function advance(id, t) {
+ switch (token.id) {
+ case '(number)':
+ if (nexttoken.id === '.') {
+ warning(
+"A dot following a number can be confused with a decimal point.", token);
+ }
+ break;
+ case '-':
+ if (nexttoken.id === '-' || nexttoken.id === '--') {
+ warning("Confusing minusses.");
+ }
+ break;
+ case '+':
+ if (nexttoken.id === '+' || nexttoken.id === '++') {
+ warning("Confusing plusses.");
+ }
+ break;
+ }
+ if (token.type === '(string)' || token.identifier) {
+ anonname = token.value;
+ }
+
+ if (id && nexttoken.id !== id) {
+ if (t) {
+ if (nexttoken.id === '(end)') {
+ warning("Unmatched '{a}'.", t, t.id);
+ } else {
+ warning(
+"Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
+ nexttoken, id, t.id, t.line, nexttoken.value);
+ }
+ } else if (nexttoken.type !== '(identifier)' ||
+ nexttoken.value !== id) {
+ warning("Expected '{a}' and instead saw '{b}'.",
+ nexttoken, id, nexttoken.value);
+ }
+ }
+ prevtoken = token;
+ token = nexttoken;
+ for (;;) {
+ nexttoken = lookahead.shift() || lex.token();
+ if (nexttoken.id === '(end)' || nexttoken.id === '(error)') {
+ return;
+ }
+ if (nexttoken.type === 'special') {
+ doOption();
+ } else {
+ if (nexttoken.id !== '(endline)') {
+ break;
+ }
+ }
+ }
+ }
+
+
+// This is the heart of JSLINT, the Pratt parser. In addition to parsing, it
+// is looking for ad hoc lint patterns. We add to Pratt's model .fud, which is
+// like nud except that it is only used on the first token of a statement.
+// Having .fud makes it much easier to define JavaScript. I retained Pratt's
+// nomenclature.
+
+// .nud Null denotation
+// .fud First null denotation
+// .led Left denotation
+// lbp Left binding power
+// rbp Right binding power
+
+// They are key to the parsing method called Top Down Operator Precedence.
+
+ function parse(rbp, initial) {
+ var left;
+ if (nexttoken.id === '(end)') {
+ error("Unexpected early end of program.", token);
+ }
+ advance();
+ if (option.safe && typeof predefined[token.value] === 'boolean' &&
+ (nexttoken.id !== '(' && nexttoken.id !== '.')) {
+ warning('ADsafe violation.', token);
+ }
+ if (initial) {
+ anonname = 'anonymous';
+ funct['(verb)'] = token.value;
+ }
+ if (initial === true && token.fud) {
+ left = token.fud();
+ } else {
+ if (token.nud) {
+ left = token.nud();
+ } else {
+ if (nexttoken.type === '(number)' && token.id === '.') {
+ warning(
+"A leading decimal point can be confused with a dot: '.{a}'.",
+ token, nexttoken.value);
+ advance();
+ return token;
+ } else {
+ error("Expected an identifier and instead saw '{a}'.",
+ token, token.id);
+ }
+ }
+ while (rbp < nexttoken.lbp) {
+ advance();
+ if (token.led) {
+ left = token.led(left);
+ } else {
+ error("Expected an operator and instead saw '{a}'.",
+ token, token.id);
+ }
+ }
+ }
+ return left;
+ }
+
+
+// Functions for conformance of style.
+
+ function adjacent(left, right) {
+ left = left || token;
+ right = right || nexttoken;
+ if (option.white || xmode === 'styleproperty' || xmode === 'style') {
+ if (left.character !== right.from && left.line === right.line) {
+ warning("Unexpected space after '{a}'.", right, left.value);
+ }
+ }
+ }
+
+ function nospace(left, right) {
+ left = left || token;
+ right = right || nexttoken;
+ if (option.white && !left.comment) {
+ if (left.line === right.line) {
+ adjacent(left, right);
+ }
+ }
+ }
+
+
+ function nonadjacent(left, right) {
+ if (option.white) {
+ left = left || token;
+ right = right || nexttoken;
+ if (left.line === right.line && left.character === right.from) {
+ warning("Missing space after '{a}'.",
+ nexttoke
<TRUNCATED>
[10/10] git commit: [#4122] change ./run_tests to python,
run suites in parallel
Posted by br...@apache.org.
[#4122] change ./run_tests to python, run suites in parallel
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/1b9cdc23
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/1b9cdc23
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/1b9cdc23
Branch: refs/heads/db/6277
Commit: 1b9cdc232dc135a271a0688789bbff3030638a11
Parents: 1217019
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Mon May 6 18:30:30 2013 -0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon May 27 15:22:45 2013 -0400
----------------------------------------------------------------------
run_tests | 138 +++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 102 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1b9cdc23/run_tests
----------------------------------------------------------------------
diff --git a/run_tests b/run_tests
index 59e1825..5a958d9 100755
--- a/run_tests
+++ b/run_tests
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env python
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -17,38 +17,104 @@
# specific language governing permissions and limitations
# under the License.
-if [ -n "$SF_SYSTEM_FUNC" ]; then
- if [ -z "$VIRTUAL_ENV" ]; then
- source /var/local/env-allura/bin/activate
- fi
-fi
-
-# main
-
-if [ "$TEST_MODULES" == "" ]; then
- TEST_MODULES="\
- AlluraTest \
- Allura \
- ForgeBlog \
- ForgeLink \
- ForgeChat \
- ForgeDiscussion \
- ForgeGit \
- ForgeSVN \
- ForgeTracker \
- ForgeWiki \
- ForgeActivity \
- ForgeShortUrl \
- ForgeUserStats \
- "
-fi
-
-# Run with --with-coverage for coverage (add --cover-html for html report)
-for module in $TEST_MODULES; do
- (
- echo "Running tests in module $module"
- cd $module
- cover_package=$(echo $module | tr "[:upper:]" "[:lower:]")
- nosetests --cover-package=$cover_package --cover-html-dir=report.coverage --cover-erase $* || exit
- ) || exit
-done
+import argparse
+from glob import glob
+from multiprocessing.pool import ThreadPool
+import subprocess
+import sys
+import threading
+import textwrap
+
+
+def run_one(cmd, **popen_kwargs):
+ print '{} running {} {}'.format(threading.current_thread(), cmd, popen_kwargs)
+ all_popen_kwargs = dict(shell=True, stderr=subprocess.STDOUT,
+ stdout=subprocess.PIPE,
+ bufsize=1, # 1 == line-buffered
+ close_fds='posix' in sys.builtin_module_names)
+ all_popen_kwargs.update(popen_kwargs)
+ proc = subprocess.Popen(cmd, **all_popen_kwargs)
+ while proc.poll() is None:
+ line = proc.stdout.readline()
+ sys.stdout.write(line)
+ sys.stdout.flush()
+ # wait for completion and get remainder of output
+ out_remainder, _ = proc.communicate()
+ sys.stdout.write(out_remainder)
+ sys.stdout.flush()
+ return proc
+
+
+def run_many(cmds, processes=None):
+ """
+ cmds: list of shell commands, or list of (shell cmds, popen_kwargs)
+ processes: number of processes, or None for # of CPU cores
+ """
+ thread_pool = ThreadPool(processes=processes)
+
+ async_results = []
+ for cmd_kwds in cmds:
+ if type(cmd_kwds) == ():
+ cmd = cmd_kwds
+ kwds = {}
+ else:
+ cmd = cmd_kwds[0]
+ kwds = cmd_kwds[1]
+ result = thread_pool.apply_async(run_one, args=(cmd,), kwds=kwds)
+ async_results.append(result)
+
+ thread_pool.close()
+ thread_pool.join()
+
+ procs = [async_result.get() for async_result in async_results]
+ return [p.returncode for p in procs]
+
+
+def get_packages():
+ packages = [p.split('/')[0] for p in glob("*/setup.py")]
+
+ # make it first, to catch syntax errors
+ packages.remove('AlluraTest')
+ packages.insert(0, 'AlluraTest')
+ return packages
+
+
+def check_packages(packages):
+ for pkg in packages:
+ try:
+ __import__(pkg.lower())
+ except ImportError:
+ print "Not running tests for {}, since it isn't set up".format(pkg)
+ else:
+ yield pkg
+
+
+def run_tests_in_parallel(options, nosetests_args):
+ cmds = []
+ for package in check_packages(options.packages):
+ cover_package = package.lower()
+ cmd = "nosetests {nosetests_args} --cover-package={cover_package}".format(
+ cover_package=cover_package,
+ nosetests_args=' '.join(nosetests_args),
+ )
+ cmds.append((cmd, dict(cwd=package)))
+ return run_many(cmds, processes=options.num_processes)
+
+
+def parse_args():
+ parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,
+ epilog=textwrap.dedent('''
+ All additional arguments are passed along to nosetests
+ (e.g. -v --with-coverage)
+ Note: --cover-package will be set automatically to the appropriate value'''))
+ parser.add_argument('-n', help='Number of processes to use at once. Default: # CPUs',
+ dest='num_processes', type=int, default=None)
+ parser.add_argument('-p', help='List of packages to run tests on. Default: all',
+ dest='packages', choices=get_packages(), default=get_packages(),
+ nargs='+')
+ return parser.parse_known_args()
+
+
+if __name__ == "__main__":
+ ret_codes = run_tests_in_parallel(*parse_args())
+ sys.exit(any(ret_codes))
[04/10] [#4122] rename AlluraTesting dir to AlluraTest,
to match the module name below
Posted by br...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/jslint/rhino.js
----------------------------------------------------------------------
diff --git a/AlluraTest/jslint/rhino.js b/AlluraTest/jslint/rhino.js
new file mode 100644
index 0000000..04be512
--- /dev/null
+++ b/AlluraTest/jslint/rhino.js
@@ -0,0 +1,41 @@
+// rhino.js
+// 2009-09-11
+/*
+Copyright (c) 2002 Douglas Crockford (www.JSLint.com) Rhino Edition
+*/
+
+// This is the Rhino companion to fulljslint.js.
+
+/*global JSLINT */
+/*jslint rhino: true, strict: false */
+
+(function (a) {
+ var e, i, input;
+ if (!a[0]) {
+ print("Usage: jslint.js file.js");
+ quit(1);
+ }
+ input = readFile(a[0]);
+ if (!input) {
+ print("jslint: Couldn't open file '" + a[0] + "'.");
+ quit(1);
+ }
+ if (!JSLINT(input, {bitwise: true, eqeqeq: true, immed: true,
+ newcap: true, nomen: true, onevar: true, plusplus: true,
+ regexp: true, rhino: true, undef: true, white: true})) {
+ for (i = 0; i < JSLINT.errors.length; i += 1) {
+ e = JSLINT.errors[i];
+ if (e) {
+ print('Lint at line ' + e.line + ' character ' +
+ e.character + ': ' + e.reason);
+ print((e.evidence || '').
+ replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"));
+ print('');
+ }
+ }
+ quit(2);
+ } else {
+ print("jslint: No problems found in " + a[0]);
+ quit();
+ }
+}(arguments));
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/setup.py
----------------------------------------------------------------------
diff --git a/AlluraTest/setup.py b/AlluraTest/setup.py
new file mode 100644
index 0000000..421cd39
--- /dev/null
+++ b/AlluraTest/setup.py
@@ -0,0 +1,39 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from setuptools import setup, find_packages
+import sys, os
+
+setup(name='AlluraTest',
+ version='0.1',
+ description="Allura testing support",
+ long_description="""\
+""",
+ classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
+ keywords='',
+ author='',
+ author_email='',
+ url='',
+ license='',
+ packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
+ include_package_data=True,
+ zip_safe=False,
+ install_requires=[
+ "poster",
+ # -*- Extra requirements: -*-
+ ]
+ )
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/twill-tests/README
----------------------------------------------------------------------
diff --git a/AlluraTest/twill-tests/README b/AlluraTest/twill-tests/README
new file mode 100644
index 0000000..59e490e
--- /dev/null
+++ b/AlluraTest/twill-tests/README
@@ -0,0 +1,19 @@
+Twill Tests
+
+First, you'll need twill-sh:
+
+ sudo easy_install twill
+
+
+Files in this directory ending with '.twill' are tests to be run by twill-sh
+
+ twill-sh --url=http://url.of.forge.to.test/ twill-tests/*.twill
+
+e.g.,
+
+ twill-sh --url=http://re.sourceforge.net/ twill-tests/*.twill
+
+
+If you just want to run the quick "smoke tests":
+
+ twill-sh --url=... twill-tests/smoke*.twill
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/twill-tests/create_repo.twill
----------------------------------------------------------------------
diff --git a/AlluraTest/twill-tests/create_repo.twill b/AlluraTest/twill-tests/create_repo.twill
new file mode 100644
index 0000000..17b9a3a
--- /dev/null
+++ b/AlluraTest/twill-tests/create_repo.twill
@@ -0,0 +1,47 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+setlocal username test_admin
+setlocal password foo
+
+clear_extra_headers
+go ./auth/
+formvalue 1 username $username
+formvalue 1 password $password
+submit
+
+code 200
+
+go ./p/test/admin/tools
+
+code 200
+
+formvalue 2 "new.ep_name" "Git"
+formvalue 2 "new.mount_point" "deleteme"
+submit
+
+code 200
+
+go ../deleteme/
+
+code 200
+
+find ready
+
+go ../admin/tools
+
+# Delete the repo :-(
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/twill-tests/edit_wiki_page.twill
----------------------------------------------------------------------
diff --git a/AlluraTest/twill-tests/edit_wiki_page.twill b/AlluraTest/twill-tests/edit_wiki_page.twill
new file mode 100644
index 0000000..2b659ec
--- /dev/null
+++ b/AlluraTest/twill-tests/edit_wiki_page.twill
@@ -0,0 +1,36 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+setlocal username test_admin
+setlocal password foo
+
+clear_extra_headers
+go ./auth/
+formvalue 1 username $username
+formvalue 1 password $password
+submit
+
+code 200
+
+go ./p/test/wiki/TestWikiWord/edit
+
+code 200
+
+formvalue 3 text "This is just a test."
+submit
+
+code 200
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/twill-tests/login.twill
----------------------------------------------------------------------
diff --git a/AlluraTest/twill-tests/login.twill b/AlluraTest/twill-tests/login.twill
new file mode 100644
index 0000000..fbe6f67
--- /dev/null
+++ b/AlluraTest/twill-tests/login.twill
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+setlocal username test_admin
+setlocal password foo
+
+clear_extra_headers
+go ./auth/
+formvalue 1 username $username
+formvalue 1 password $password
+submit
+
+code 200
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/twill-tests/new_issue.twill
----------------------------------------------------------------------
diff --git a/AlluraTest/twill-tests/new_issue.twill b/AlluraTest/twill-tests/new_issue.twill
new file mode 100644
index 0000000..7b05168
--- /dev/null
+++ b/AlluraTest/twill-tests/new_issue.twill
@@ -0,0 +1,36 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+setlocal username test_admin
+setlocal password foo
+
+clear_extra_headers
+go ./auth/
+formvalue 1 username $username
+formvalue 1 password $password
+submit
+
+code 200
+
+go ./p/test/bugs/new/
+
+code 200
+
+formvalue 2 "ticket_form.summary" "test create ticket"
+submit
+
+code 200
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/twill-tests/smoke-front-page.twill
----------------------------------------------------------------------
diff --git a/AlluraTest/twill-tests/smoke-front-page.twill b/AlluraTest/twill-tests/smoke-front-page.twill
new file mode 100644
index 0000000..a0f4852
--- /dev/null
+++ b/AlluraTest/twill-tests/smoke-front-page.twill
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+clear_extra_headers
+go .
+code 200
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/twill-tests/smoke-project-home.twill
----------------------------------------------------------------------
diff --git a/AlluraTest/twill-tests/smoke-project-home.twill b/AlluraTest/twill-tests/smoke-project-home.twill
new file mode 100644
index 0000000..3d1e8bf
--- /dev/null
+++ b/AlluraTest/twill-tests/smoke-project-home.twill
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+clear_extra_headers
+go ./p/test/home/
+code 200
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/twill-tests/smoke-tracker-search.twill
----------------------------------------------------------------------
diff --git a/AlluraTest/twill-tests/smoke-tracker-search.twill b/AlluraTest/twill-tests/smoke-tracker-search.twill
new file mode 100644
index 0000000..d8d03a3
--- /dev/null
+++ b/AlluraTest/twill-tests/smoke-tracker-search.twill
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+clear_extra_headers
+go ./p/test/bugs/search/
+code 200
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/twill-tests/smoke-tracker.twill
----------------------------------------------------------------------
diff --git a/AlluraTest/twill-tests/smoke-tracker.twill b/AlluraTest/twill-tests/smoke-tracker.twill
new file mode 100644
index 0000000..1e9e0f7
--- /dev/null
+++ b/AlluraTest/twill-tests/smoke-tracker.twill
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+clear_extra_headers
+go ./p/test/bugs/
+code 200
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/twill-tests/smoke-user-profile.twill
----------------------------------------------------------------------
diff --git a/AlluraTest/twill-tests/smoke-user-profile.twill b/AlluraTest/twill-tests/smoke-user-profile.twill
new file mode 100644
index 0000000..907f17d
--- /dev/null
+++ b/AlluraTest/twill-tests/smoke-user-profile.twill
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+clear_extra_headers
+go ./u/test_admin/profile/
+code 200
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTest/twill-tests/smoke-wiki.twill
----------------------------------------------------------------------
diff --git a/AlluraTest/twill-tests/smoke-wiki.twill b/AlluraTest/twill-tests/smoke-wiki.twill
new file mode 100644
index 0000000..03e2c56
--- /dev/null
+++ b/AlluraTest/twill-tests/smoke-wiki.twill
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+clear_extra_headers
+go ./p/test/wiki/Home/
+code 200
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/LICENSE
----------------------------------------------------------------------
diff --git a/AlluraTesting/LICENSE b/AlluraTesting/LICENSE
deleted file mode 100644
index 196ac43..0000000
--- a/AlluraTesting/LICENSE
+++ /dev/null
@@ -1,234 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-AlluraTesting SUBCOMPONENTS:
-
-AlluraTesting includes a number of subcomponents with
-separate copyright notices and license terms. Your use of the source code
-for the these subcomponents is subject to the terms and conditions of the
-following licenses.
-
-For jslint.js, in directory
-jslint/
-
- Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of
- this software and associated documentation files (the "Software"), to deal in
- the Software without restriction, including without limitation the rights to
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
- of the Software, and to permit persons to whom the Software is furnished to do
- so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
-
- The Software shall be used for Good, not Evil.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/alluratest/__init__.py
----------------------------------------------------------------------
diff --git a/AlluraTesting/alluratest/__init__.py b/AlluraTesting/alluratest/__init__.py
deleted file mode 100644
index 144e298..0000000
--- a/AlluraTesting/alluratest/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/alluratest/controller.py
----------------------------------------------------------------------
diff --git a/AlluraTesting/alluratest/controller.py b/AlluraTesting/alluratest/controller.py
deleted file mode 100644
index dd81b23..0000000
--- a/AlluraTesting/alluratest/controller.py
+++ /dev/null
@@ -1,171 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-"""Unit and functional test suite for allura."""
-import os
-import urllib
-
-import mock
-import beaker.session
-from formencode import variabledecode
-from paste.deploy import loadapp
-from paste.deploy.converters import asbool
-from paste.script.appinstall import SetupCommand
-from pylons import tmpl_context as c, app_globals as g
-from pylons import url, request, response, session
-import tg
-from webtest import TestApp
-from webob import Request, Response
-import ew
-from ming.orm import ThreadLocalORMSession
-import ming.orm
-
-from allura import model as M
-import allura.lib.security
-from allura.lib.app_globals import Globals
-from allura.lib import helpers as h
-from allura.websetup.schema import REGISTRY
-#from allura.lib.custom_middleware import environ as ENV, MagicalC
-from .validation import ValidatingTestApp
-
-DFL_APP_NAME = 'main_without_authn'
-
-def get_config_file(config=None):
- if not config:
- config = 'test.ini'
-
- try:
- conf_dir = tg.config.here
- except AttributeError:
- conf_dir = os.getcwd()
- return os.path.join(conf_dir, config)
-
-def setup_basic_test(config=None, app_name=DFL_APP_NAME):
- '''Create clean environment for running tests'''
- try:
- conf_dir = tg.config.here
- except AttributeError:
- conf_dir = os.getcwd()
- ew.TemplateEngine.initialize({})
- test_file = os.path.join(conf_dir, get_config_file(config))
- cmd = SetupCommand('setup-app')
- cmd.run([test_file])
-
- # run all tasks, e.g. indexing from bootstrap operations
- while M.MonQTask.run_ready('setup'):
- ThreadLocalORMSession.flush_all()
-
-def setup_functional_test(config=None, app_name=DFL_APP_NAME):
- '''Create clean environment for running tests. Also return WSGI test app'''
- config = get_config_file(config)
- setup_basic_test(config, app_name)
- conf_dir = tg.config.here
- wsgiapp = loadapp('config:%s#%s' % (config, app_name),
- relative_to=conf_dir)
- return wsgiapp
-
-def setup_unit_test():
- try:
- while True:
- REGISTRY.cleanup()
- except:
- pass
- REGISTRY.prepare()
- REGISTRY.register(ew.widget_context, ew.core.WidgetContext('http', ew.ResourceManager()))
- REGISTRY.register(g, Globals())
- REGISTRY.register(c, mock.Mock())
- REGISTRY.register(url, lambda:None)
- REGISTRY.register(request, Request.blank('/', remote_addr='1.1.1.1'))
- REGISTRY.register(response, Response())
- REGISTRY.register(session, beaker.session.SessionObject({}))
- REGISTRY.register(allura.credentials, allura.lib.security.Credentials())
- c.memoize_cache = {}
- c.queued_messages = None
- c.model_cache = None
- ThreadLocalORMSession.close_all()
-
-def setup_global_objects():
- setup_unit_test()
- h.set_context('test', 'wiki', neighborhood='Projects')
- c.user = M.User.query.get(username='test-admin')
-
-
-class TestController(object):
-
- application_under_test = 'main'
- validate_skip = False
-
- def setUp(self):
- """Method called by nose before running each test"""
- self.app = ValidatingTestApp(setup_functional_test(app_name=self.application_under_test))
- if self.validate_skip:
- self.app.validate_skip = self.validate_skip
- if asbool(tg.config.get('smtp.mock')):
- self.smtp_mock = mock.patch('allura.lib.mail_util.smtplib.SMTP')
- self.smtp_mock.start()
-
- def tearDown(self):
- """Method called by nose after running each test"""
- if asbool(tg.config.get('smtp.mock')):
- self.smtp_mock.stop()
-
- def webflash(self, response):
- "Extract webflash content from response."
- return urllib.unquote(response.cookies_set.get('webflash', ''))
-
-
-class TestRestApiBase(TestController):
-
- def setUp(self):
- super(TestRestApiBase, self).setUp()
- setup_global_objects()
-# h.set_context('test', 'home')
- self.user = M.User.query.get(username='test-admin')
- self.token = M.ApiToken(user_id=self.user._id)
- ming.orm.session(self.token).flush()
-
- def set_api_token(self, token):
- self.token = token
-
- def _api_getpost(self, method, path, api_key=None, api_timestamp=None, api_signature=None,
- wrap_args=None, **params):
- if wrap_args:
- params = {wrap_args: params}
- params = variabledecode.variable_encode(params, add_repetitions=False)
- if api_key: params['api_key'] = api_key
- if api_timestamp: params['api_timestamp'] = api_timestamp
- if api_signature: params['api_signature'] = api_signature
- params = self.token.sign_request(path, params)
-
- fn = self.app.post if method=='POST' else self.app.get
-
- response = fn(
- str(path),
- params=params,
- status=[200, 302, 400, 403, 404])
- if response.status_int == 302:
- return response.follow()
- else:
- return response
-
- def api_get(self, path, api_key=None, api_timestamp=None, api_signature=None,
- wrap_args=None, **params):
- return self._api_getpost('GET', path, api_key, api_timestamp, api_signature, wrap_args, **params)
-
- def api_post(self, path, api_key=None, api_timestamp=None, api_signature=None,
- wrap_args=None, **params):
- return self._api_getpost('POST', path, api_key, api_timestamp, api_signature, wrap_args, **params)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/alluratest/test_syntax.py
----------------------------------------------------------------------
diff --git a/AlluraTesting/alluratest/test_syntax.py b/AlluraTesting/alluratest/test_syntax.py
deleted file mode 100644
index b394798..0000000
--- a/AlluraTesting/alluratest/test_syntax.py
+++ /dev/null
@@ -1,95 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-import os.path
-from glob import glob
-from subprocess import Popen, PIPE
-import sys
-
-toplevel_dir = os.path.abspath(os.path.dirname(__file__) + "/../..")
-
-def run(cmd):
- proc = Popen(cmd, shell=True, cwd=toplevel_dir, stdout=PIPE, stderr=PIPE)
- # must capture & reprint stdount, so that nosetests can capture it
- (stdout, stderr) = proc.communicate()
- sys.stdout.write(stdout)
- sys.stderr.write(stderr)
- return proc.returncode
-
-find_py = "find Allura Forge* -name '*.py'"
-
-# a recepe from itertools doc
-from itertools import izip_longest
-def grouper(n, iterable, fillvalue=None):
- "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
- args = [iter(iterable)] * n
- return izip_longest(fillvalue=fillvalue, *args)
-
-def test_pyflakes():
- # skip some that aren't critical errors
- skips = [
- 'imported but unused',
- 'redefinition of unused',
- 'assigned to but never used',
- '__version__',
- ]
- proc = Popen(find_py, shell=True, cwd=toplevel_dir, stdout=PIPE, stderr=PIPE)
- (find_stdout, stderr) = proc.communicate()
- sys.stderr.write(stderr)
- assert proc.returncode == 0, proc.returncode
-
- # run pyflakes in batches, so it doesn't take tons of memory
- error = False
- all_files = [f for f in find_stdout.split('\n')
- if '/migrations/' not in f and f.strip()]
- for files in grouper(20, all_files, fillvalue=''):
- cmd = "pyflakes " + ' '.join(files) + " | grep -v '" + "' | grep -v '".join(skips) + "'"
- #print 'Command was: %s' % cmd
- retval = run(cmd)
- if retval != 1:
- print
- #print 'Command was: %s' % cmd
- print 'Returned %s' % retval
- error = True
-
- if error:
- raise Exception('pyflakes failure, see stdout')
-
-def test_no_now():
- if run(find_py + " | xargs grep '\.now(' ") not in [1,123]:
- raise Exception("These should use .utcnow()")
- if run(find_py + " | xargs grep '\.fromtimestamp(' ") not in [1,123]:
- raise Exception("These should use .utcfromtimestamp()")
-
-def test_no_prints():
- skips = [
- '/tests/',
- 'Allura/allura/command/',
- 'Allura/ldap-setup.py',
- 'Allura/ldap-userconfig.py',
- 'Allura/ez_setup/',
- 'Allura/allura/lib/AsciiDammit.py',
- '/scripts/',
- 'Allura/allura/lib/import_api.py',
- 'ForgeSVN/setup.py',
- ]
- if run(find_py + " | grep -v '" + "' | grep -v '".join(skips) + "' | xargs grep -v '^ *#' | grep 'print ' | grep -E -v '(pprint|#pragma: ?printok)' ") != 1:
- raise Exception("These should use logging instead of print")
-
-def test_no_tabs():
- if run(find_py + " | xargs grep ' ' ") not in [1,123]:
- raise Exception('These should not use tab chars')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/alluratest/validation.py
----------------------------------------------------------------------
diff --git a/AlluraTesting/alluratest/validation.py b/AlluraTesting/alluratest/validation.py
deleted file mode 100644
index 235d7c0..0000000
--- a/AlluraTesting/alluratest/validation.py
+++ /dev/null
@@ -1,321 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-"""
-Functions to syntax-validate output content
-"""
-from os import path, environ, getcwd
-import os
-import sys
-import logging
-import tempfile
-import subprocess
-import json
-import urllib2
-import re
-
-import tg
-import mock
-import beaker.session
-from paste.deploy import loadapp
-from paste.script.appinstall import SetupCommand
-from pylons import tmpl_context as c, app_globals as g
-from pylons import url, request, response, session
-import webtest
-from webtest import TestApp
-from webob import Request, Response
-from nose.tools import ok_, assert_true, assert_false
-from poster.encode import multipart_encode
-from poster.streaminghttp import register_openers
-from ming.utils import LazyProperty
-
-from allura.lib import utils
-
-ENABLE_CONTENT_VALIDATION = False
-# By default we want to run only validations which are fast,
-# but on special test hosts - all.
-COMPLETE_TESTS_HOST = 'sb-forge-4039'
-
-log = logging.getLogger(__name__)
-
-class Config(object):
- "Config to encapsulate flexible/complex test enabled/disabled rules."
- _instance = None
-
- def __init__(self):
- self.ini_config = None
- pass
-
- @classmethod
- def instance(cls):
- if not cls._instance:
- cls._instance = cls()
- return cls._instance
-
- @LazyProperty
- def test_ini(self):
- if not self.ini_config:
- from . import controller
- import ConfigParser
- conf = ConfigParser.ConfigParser({'validate_html5': 'false', 'validate_inlinejs': 'false'})
- conf.read(controller.get_config_file())
- self.ini_config = conf
- return self.ini_config
-
- @LazyProperty
- def hostname(self):
- if os.path.exists('/etc/soghost'):
- with open('/etc/soghost') as fp:
- return fp.read().strip()
-
- def validation_enabled(self, val_type):
- env_var = os.getenv('ALLURA_VALIDATION')
- if env_var == 'all':
- return True
- elif env_var == 'none':
- return False
- elif env_var is not None:
- return val_type in env_var.split(',')
-
- if self.hostname == COMPLETE_TESTS_HOST:
- return True
-
- enabled = self.test_ini.getboolean('validation', 'validate_' + val_type)
- return enabled
-
- def fail_on_validation(self, val_type):
- env_var = os.getenv('ALLURA_VALIDATION')
- if env_var == 'all':
- return True
- if self.hostname == COMPLETE_TESTS_HOST:
- return True
- return ENABLE_CONTENT_VALIDATION
-
-
-def report_validation_error(val_name, filename, message):
- message = '%s Validation errors (%s):\n%s\n' % (val_name, filename, message)
- if Config.instance().fail_on_validation(val_name):
- ok_(False, message)
- else:
- sys.stderr.write('=' * 40 + '\n' + message)
-
-def dump_to_file(prefix, html):
- f = tempfile.NamedTemporaryFile(prefix=prefix, delete=False)
- f.write(html)
- f.close()
- return f.name
-
-def validate_html(html_or_response):
- if hasattr(html_or_response, 'body'):
- html = html_or_response.body
- else:
- html = html_or_response
-
- html = html.lstrip()
-
- if html.startswith('<!DOCTYPE html>'):
- return validate_html5(html)
- else:
- assert False, 'Non-valid HTML: ' + html[:100] + '...'
-
-def validate_json(json_or_response):
- if hasattr(json_or_response, 'body'):
- j = json_or_response.body
- else:
- j = json_or_response
-
- try:
- obj = json.loads(j)
- except Exception, e:
- ok_(False, "Couldn't validate JSON: " + str(e) + ':' + j[:100] + '...')
-
- return obj
-
-def validate_html5(html_or_response):
- if hasattr(html_or_response, 'body'):
- html = html_or_response.body
- else:
- html = html_or_response
- register_openers()
- params = [("out","text"),("content",html)]
- datagen, headers = multipart_encode(params)
- request = urllib2.Request("http://html5.validator.nu/", datagen, headers)
- count = 3
- while True:
- try:
- resp = urllib2.urlopen(request, timeout=3).read()
- break
- except:
- resp = "Couldn't connect to validation service to check the HTML"
- count -= 1
- if count == 0:
- sys.stderr.write('WARNING: ' + resp + '\n')
- break
-
- resp = resp.replace('“','"').replace('”','"').replace('–','-')
-
- ignored_errors = [
- 'Required attributes missing on element "object"',
- 'Stray end tag "embed".',
- 'Stray end tag "param".',
- r'Bad value .+? for attribute "onclick" on element "input": invalid return',
- ]
- for ignore in ignored_errors:
- resp = re.sub('Error: ' + ignore, 'Ignoring: ' + ignore, resp)
-
- if 'Error:' in resp:
- fname = dump_to_file('html5-', html)
- message = resp.decode('ascii','ignore')
- report_validation_error('html5', fname, message)
-
-
-def validate_html5_chunk(html):
- """ When you don't have a html & body tags - this adds it"""
- # WebTest doesn't like HTML fragments without doctype,
- # so we output them sometimes for fragments, which is hack.
- # Unhack it here.
- doctype = '<!DOCTYPE html>'
- if html.startswith(doctype):
- html = html[len(doctype):]
-
- html = '''<!DOCTYPE html>
- <html>
- <head><title></title></head>
- <body>
- %s
- </body></html>''' % html
- return validate_html5(html)
-
-def validate_js(html_or_response):
- if hasattr(html_or_response, 'body'):
- if html_or_response.status_int != 200:
- return
- html = html_or_response.body
- else:
- html = html_or_response
- basedir = path.dirname(path.abspath(__file__))
- jslint_dir = basedir + '/../jslint'
- fname = dump_to_file('jslint-', html)
- cmd = 'java -jar ' + jslint_dir + '/js.jar '+ jslint_dir +'/jslint.js ' + fname
- p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- stdout, stderr = p.communicate(html)
- if stdout.startswith('jslint: No problems found'):
- os.unlink(fname)
- return
- stdout = stdout.decode('UTF-8', 'replace')
- msg = '\n'.join(repr(s) for s in stdout.split('\n') if s)
- report_validation_error('js', fname, msg)
-
-def validate_page(html_or_response):
- if Config.instance().validation_enabled('html5'):
- validate_html(html_or_response)
- if Config.instance().validation_enabled('inlinejs'):
- validate_js(html_or_response)
-
-class AntiSpamTestApp(TestApp):
-
- def post(self, *args, **kwargs):
- if kwargs.pop('antispam', False):
- antispam = utils.AntiSpam()
- params = {
- 'timestamp': antispam.timestamp_text,
- 'spinner': antispam.spinner_text,
- antispam.enc('honey0'): '',
- antispam.enc('honey1'): '',
- }
- for k, v in kwargs['params'].iteritems():
- params[antispam.enc(k)] = v
- kwargs['params'] = params
- return super(AntiSpamTestApp, self).post(*args, **kwargs)
-
-class PostParamCheckingTestApp(AntiSpamTestApp):
-
- def _validate_params(self, params, method):
- if not params:
- return
- # params can be a list or a dict
- if hasattr(params, 'items'):
- params = params.items()
- for k, v in params:
- if not isinstance(k, basestring):
- raise TypeError('%s key %s is %s, not str' % (method, k, type(k)))
- if not isinstance(v, (basestring, webtest.app.File)):
- raise TypeError('%s key %s has value %s of type %s, not str. ' % (method, k, v, type(v)))
-
- def get(self, *args, **kwargs):
- self._validate_params(kwargs.get('params'), 'get')
- return super(PostParamCheckingTestApp, self).get(*args, **kwargs)
-
- def post(self, *args, **kwargs):
- self._validate_params(kwargs.get('params'), 'post')
- return super(PostParamCheckingTestApp, self).post(*args, **kwargs)
-
-class ValidatingTestApp(PostParamCheckingTestApp):
-
- # Subclasses may set this to True to skip validation altogether
- validate_skip = False
-
- def _validate(self, resp, method, val_params):
- """Perform validation on webapp response. This handles responses of
- various types and forms."""
- if resp.status_int != 200:
- return
-
- content = resp.body
- content_type = resp.headers['Content-Type']
- if content_type.startswith('text/html'):
- if val_params['validate_chunk']:
- validate_html5_chunk(content)
- else:
- validate_page(resp)
- elif content_type.split(';', 1)[0] in ('text/plain', 'text/x-python', 'application/octet-stream'):
- pass
- elif content_type.startswith('application/json'):
- validate_json(content)
- elif content_type.startswith(('application/x-javascript','application/javascript', 'text/javascript')):
- validate_js(content)
- elif content_type.startswith('application/xml'):
- import feedparser
- d = feedparser.parse(content)
- assert d.bozo == 0, 'Non-wellformed feed'
- elif content_type.startswith('image/'):
- pass
- else:
- assert False, 'Unexpected output content type: ' + content_type
-
- def _get_validation_params(self, kw):
- "Separate validation params from normal TestApp methods params."
- params = {}
- for k in ('validate_skip', 'validate_chunk'):
- params[k] = kw.pop(k, False)
- return params, kw
-
- def get(self, *args, **kw):
- val_params, kw = self._get_validation_params(kw)
- resp = super(ValidatingTestApp, self).get(*args, **kw)
- if not self.validate_skip and not val_params['validate_skip']:
- self._validate(resp, 'get', val_params)
- return resp
-
- def post(self, *args, **kw):
- val_params, kw = self._get_validation_params(kw)
- resp = super(ValidatingTestApp, self).post(*args, **kw)
- if not self.validate_skip and not val_params['validate_skip']:
- self._validate(resp, 'post', val_params)
- return resp
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/jslint/Makefile
----------------------------------------------------------------------
diff --git a/AlluraTesting/jslint/Makefile b/AlluraTesting/jslint/Makefile
deleted file mode 100644
index 7efd72e..0000000
--- a/AlluraTesting/jslint/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# Make single-file jslint script out of main script (from jslint.com,
-# patched by us to tweak its behavior, as it configurability leaves much
-# to be desired) and Rhino support module. Needed because Rhino accepts
-# only single file as script.
-
-jslint.js: fulljslint.js rhino.js
- cat $^ >$@
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/jslint/env-js.jar
----------------------------------------------------------------------
diff --git a/AlluraTesting/jslint/env-js.jar b/AlluraTesting/jslint/env-js.jar
deleted file mode 100644
index 072891a..0000000
Binary files a/AlluraTesting/jslint/env-js.jar and /dev/null differ
[02/10] [#4122] rename AlluraTesting dir to AlluraTest,
to match the module name below
Posted by br...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/jslint/jslint.js
----------------------------------------------------------------------
diff --git a/AlluraTesting/jslint/jslint.js b/AlluraTesting/jslint/jslint.js
deleted file mode 100644
index 4b2ddcc..0000000
--- a/AlluraTesting/jslint/jslint.js
+++ /dev/null
@@ -1,5729 +0,0 @@
-// jslint.js
-// 2010-08-05
-
-/*
-Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-/*
- JSLINT is a global function. It takes two parameters.
-
- var myResult = JSLINT(source, option);
-
- The first parameter is either a string or an array of strings. If it is a
- string, it will be split on '\n' or '\r'. If it is an array of strings, it
- is assumed that each string represents one line. The source can be a
- JavaScript text, or HTML text, or a Konfabulator text.
-
- The second parameter is an optional object of options which control the
- operation of JSLINT. Most of the options are booleans: They are all are
- optional and have a default value of false.
-
- If it checks out, JSLINT returns true. Otherwise, it returns false.
-
- If false, you can inspect JSLINT.errors to find out the problems.
- JSLINT.errors is an array of objects containing these members:
-
- {
- line : The line (relative to 0) at which the lint was found
- character : The character (relative to 0) at which the lint was found
- reason : The problem
- evidence : The text line in which the problem occurred
- raw : The raw message before the details were inserted
- a : The first detail
- b : The second detail
- c : The third detail
- d : The fourth detail
- }
-
- If a fatal error was found, a null will be the last element of the
- JSLINT.errors array.
-
- You can request a Function Report, which shows all of the functions
- and the parameters and vars that they use. This can be used to find
- implied global variables and other problems. The report is in HTML and
- can be inserted in an HTML <body>.
-
- var myReport = JSLINT.report(limited);
-
- If limited is true, then the report will be limited to only errors.
-
- You can request a data structure which contains JSLint's results.
-
- var myData = JSLINT.data();
-
- It returns a structure with this form:
-
- {
- errors: [
- {
- line: NUMBER,
- character: NUMBER,
- reason: STRING,
- evidence: STRING
- }
- ],
- functions: [
- name: STRING,
- line: NUMBER,
- last: NUMBER,
- param: [
- STRING
- ],
- closure: [
- STRING
- ],
- var: [
- STRING
- ],
- exception: [
- STRING
- ],
- outer: [
- STRING
- ],
- unused: [
- STRING
- ],
- global: [
- STRING
- ],
- label: [
- STRING
- ]
- ],
- globals: [
- STRING
- ],
- member: {
- STRING: NUMBER
- },
- unuseds: [
- {
- name: STRING,
- line: NUMBER
- }
- ],
- implieds: [
- {
- name: STRING,
- line: NUMBER
- }
- ],
- urls: [
- STRING
- ],
- json: BOOLEAN
- }
-
- Empty arrays will not be included.
-
-*/
-
-/*jslint
- evil: true, nomen: false, onevar: false, regexp: false, strict: true
-*/
-
-/*members "\b", "\t", "\n", "\f", "\r", "!=", "!==", "\"", "%",
- "(begin)", "(breakage)", "(context)", "(error)", "(global)",
- "(identifier)", "(last)", "(line)", "(loopage)", "(name)", "(onevar)",
- "(params)", "(scope)", "(verb)", "*", "+", "++", "-", "--", "\/",
- "<", "<=", "==", "===", ">", ">=", ADSAFE, ActiveXObject,
- Array, Boolean, COM, CScript, Canvas, CustomAnimation, Date, Debug, E,
- Enumerator, Error, EvalError, FadeAnimation, Flash, FormField, Frame,
- Function, HotKey, Image, JSON, LN10, LN2, LOG10E, LOG2E, MAX_VALUE,
- MIN_VALUE, Math, MenuItem, MoveAnimation, NEGATIVE_INFINITY, Number,
- Object, Option, PI, POSITIVE_INFINITY, Point, RangeError, Rectangle,
- ReferenceError, RegExp, ResizeAnimation, RotateAnimation, SQRT1_2,
- SQRT2, ScrollBar, String, Style, SyntaxError, System, Text, TextArea,
- Timer, TypeError, URIError, URL, VBArray, WScript, Web, Window, XMLDOM,
- XMLHttpRequest, "\\", a, abbr, acronym, addEventListener, address,
- adsafe, alert, aliceblue, animator, antiquewhite, appleScript, applet,
- apply, approved, aqua, aquamarine, area, arguments, arity, article,
- aside, audio, autocomplete, azure, b, background,
- "background-attachment", "background-color", "background-image",
- "background-position", "background-repeat", base, bdo, beep, beige, big,
- bisque, bitwise, black, blanchedalmond, block, blockquote, blue,
- blueviolet, blur, body, border, "border-bottom", "border-bottom-color",
- "border-bottom-style", "border-bottom-width", "border-collapse",
- "border-color", "border-left", "border-left-color", "border-left-style",
- "border-left-width", "border-right", "border-right-color",
- "border-right-style", "border-right-width", "border-spacing",
- "border-style", "border-top", "border-top-color", "border-top-style",
- "border-top-width", "border-width", bottom, br, brown, browser,
- burlywood, button, bytesToUIString, c, cadetblue, call, callee, caller,
- canvas, cap, caption, "caption-side", cases, center, charAt, charCodeAt,
- character, chartreuse, chocolate, chooseColor, chooseFile, chooseFolder,
- cite, clear, clearInterval, clearTimeout, clip, close, closeWidget,
- closed, closure, cm, code, col, colgroup, color, command, comment,
- condition, confirm, console, constructor, content, convertPathToHFS,
- convertPathToPlatform, coral, cornflowerblue, cornsilk,
- "counter-increment", "counter-reset", create, crimson, css, cursor,
- cyan, d, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen,
- darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred,
- darksalmon, darkseagreen, darkslateblue, darkslategray, darkturquoise,
- darkviolet, data, datalist, dd, debug, decodeURI, decodeURIComponent,
- deeppink, deepskyblue, defaultStatus, defineClass, del, deserialize,
- details, devel, dfn, dialog, dimension, dimgray, dir, direction,
- display, div, dl, document, dodgerblue, dt, edition, else, em, embed,
- empty, "empty-cells", encodeURI, encodeURIComponent, entityify, eqeqeq,
- errors, es5, escape, eval, event, evidence, evil, ex, exception, exec, exps,
- fieldset, figure, filesystem, firebrick, first, float, floor,
- floralwhite, focus, focusWidget, font, "font-face", "font-family",
- "font-size", "font-size-adjust", "font-stretch", "font-style",
- "font-variant", "font-weight", footer, forestgreen, forin, form,
- fragment, frame, frames, frameset, from, fromCharCode, fuchsia, fud,
- funct, function, functions, g, gainsboro, gc, getComputedStyle,
- ghostwhite, global, globals, gold, goldenrod, gray, green, greenyellow,
- h1, h2, h3, h4, h5, h6, hasOwnProperty, head, header, height, help,
- hgroup, history, honeydew, hotpink, hr, 'hta:application', html,
- i, iTunes, id, identifier,
- iframe, img, immed, implieds, in, include, indent, indexOf, indianred,
- indigo, init, input, ins, isAlpha, isApplicationRunning, isDigit,
- isFinite, isNaN, ivory, join, jslint, json, kbd, keygen, khaki,
- konfabulatorVersion, label, labelled, lang, last, lavender,
- lavenderblush, lawngreen, laxbreak, lbp, led, left, legend,
- lemonchiffon, length, "letter-spacing", li, lib, lightblue, lightcoral,
- lightcyan, lightgoldenrodyellow, lightgreen, lightpink, lightsalmon,
- lightseagreen, lightskyblue, lightslategray, lightsteelblue,
- lightyellow, lime, limegreen, line, "line-height", linen, link,
- "list-style", "list-style-image", "list-style-position",
- "list-style-type", load, loadClass, location, log, m, magenta, map,
- margin, "margin-bottom", "margin-left", "margin-right", "margin-top",
- mark, "marker-offset", maroon, match, "max-height", "max-width", maxerr,
- maxlen, md5, media, mediumaquamarine, mediumblue, mediumorchid,
- mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen,
- mediumturquoise, mediumvioletred, member, menu, message, meta, meter,
- midnightblue, "min-height", "min-width", mintcream, mistyrose, mm,
- moccasin, moveBy, moveTo, name, nav, navajowhite, navigator, navy, new,
- newcap, noframes, nomen, noscript, nud, object, ol, oldlace, olive,
- olivedrab, on, onbeforeunload, onblur, onerror, onevar, onfocus, onload,
- onresize, onunload, opacity, open, openURL, opener, opera, optgroup,
- option, orange, orangered, orchid, outer, outline, "outline-color",
- "outline-style", "outline-width", output, overflow, "overflow-x",
- "overflow-y", p, padding, "padding-bottom", "padding-left",
- "padding-right", "padding-top", page, "page-break-after",
- "page-break-before", palegoldenrod, palegreen, paleturquoise,
- palevioletred, papayawhip, param, parent, parseFloat, parseInt,
- passfail, pc, peachpuff, peru, pink, play, plum, plusplus, pop,
- popupMenu, position, powderblue, pre, predef, preferenceGroups,
- preferences, print, progress, prompt, prototype, pt, purple, push, px,
- q, quit, quotes, random, range, raw, reach, readFile, readUrl, reason,
- red, regexp, reloadWidget, removeEventListener, replace, report,
- reserved, resizeBy, resizeTo, resolvePath, resumeUpdates, rhino, right,
- rosybrown, royalblue, rp, rt, ruby, runCommand, runCommandInBg,
- saddlebrown, safe, salmon, samp, sandybrown, saveAs, savePreferences,
- screen, script, scroll, scrollBy, scrollTo, seagreen, seal, search,
- seashell, section, select, serialize, setInterval, setTimeout, shift,
- showWidgetPreferences, sienna, silver, skyblue, slateblue, slategray,
- sleep, slice, small, snow, sort, source, span, spawn, speak, split,
- springgreen, src, stack, status, steelblue, strict, strong, style,
- styleproperty, sub, substr, sup, supplant, suppressUpdates, sync,
- system, table, "table-layout", tan, tbody, td, teal, tellWidget, test,
- "text-align", "text-decoration", "text-indent", "text-shadow",
- "text-transform", textarea, tfoot, th, thead, thistle, time, title,
- toLowerCase, toString, toUpperCase, toint32, token, tomato, top, tr, tt,
- turquoise, type, u, ul, undef, unescape, "unicode-bidi", unused,
- unwatch, updateNow, urls, value, valueOf, var, version,
- "vertical-align", video, violet, visibility, watch, wheat, white,
- "white-space", whitesmoke, widget, width, windows, "word-spacing",
- "word-wrap", yahooCheckLogin, yahooLogin, yahooLogout, yellow,
- yellowgreen, "z-index"
-*/
-
-// We build the application inside a function so that we produce only a single
-// global variable. The function will be invoked, its return value is the JSLINT
-// application itself.
-
-"use strict";
-
-var JSLINT = (function () {
- var adsafe_id, // The widget's ADsafe id.
- adsafe_may, // The widget may load approved scripts.
- adsafe_went, // ADSAFE.go has been called.
- anonname, // The guessed name for anonymous functions.
- approved, // ADsafe approved urls.
-
- atrule = {
- media : true,
- 'font-face': true,
- page : true
- },
-
-// These are operators that should not be used with the ! operator.
-
- bang = {
- '<': true,
- '<=': true,
- '==': true,
- '===': true,
- '!==': true,
- '!=': true,
- '>': true,
- '>=': true,
- '+': true,
- '-': true,
- '*': true,
- '/': true,
- '%': true
- },
-
-// These are members that should not be permitted in the safe subset.
-
- banned = { // the member names that ADsafe prohibits.
- 'arguments' : true,
- callee : true,
- caller : true,
- constructor : true,
- 'eval' : true,
- prototype : true,
- stack : true,
- unwatch : true,
- valueOf : true,
- watch : true
- },
-
-
-// These are the JSLint boolean options.
-
- boolOptions = {
- adsafe : true, // if ADsafe should be enforced
- bitwise : true, // if bitwise operators should not be allowed
- browser : true, // if the standard browser globals should be predefined
- cap : true, // if upper case HTML should be allowed
- css : true, // if CSS workarounds should be tolerated
- debug : true, // if debugger statements should be allowed
- devel : true, // if logging should be allowed (console, alert, etc.)
- eqeqeq : true, // if === should be required
- es5 : true, // if ES5 syntax should be allowed
- evil : true, // if eval should be allowed
- forin : true, // if for in statements must filter
- fragment : true, // if HTML fragments should be allowed
- immed : true, // if immediate invocations must be wrapped in parens
- laxbreak : true, // if line breaks should not be checked
- newcap : true, // if constructor names must be capitalized
- nomen : true, // if names should be checked
- on : true, // if HTML event handlers should be allowed
- onevar : true, // if only one var statement per function should be allowed
- passfail : true, // if the scan should stop on first error
- plusplus : true, // if increment/decrement should not be allowed
- regexp : true, // if the . should not be allowed in regexp literals
- rhino : true, // if the Rhino environment globals should be predefined
- undef : true, // if variables should be declared before used
- safe : true, // if use of some browser features should be restricted
- windows : true, // if MS Windows-specigic globals should be predefined
- strict : true, // require the "use strict"; pragma
- sub : true, // if all forms of subscript notation are tolerated
- white : true, // if strict whitespace rules apply
- widget : true // if the Yahoo Widgets globals should be predefined
- },
-
-// browser contains a set of global names which are commonly provided by a
-// web browser environment.
-
- browser = {
- addEventListener: false,
- blur : false,
- clearInterval : false,
- clearTimeout : false,
- close : false,
- closed : false,
- defaultStatus : false,
- document : false,
- event : false,
- focus : false,
- frames : false,
- getComputedStyle: false,
- history : false,
- Image : false,
- length : false,
- location : false,
- moveBy : false,
- moveTo : false,
- name : false,
- navigator : false,
- onbeforeunload : true,
- onblur : true,
- onerror : true,
- onfocus : true,
- onload : true,
- onresize : true,
- onunload : true,
- open : false,
- opener : false,
- Option : false,
- parent : false,
- print : false,
- removeEventListener: false,
- resizeBy : false,
- resizeTo : false,
- screen : false,
- scroll : false,
- scrollBy : false,
- scrollTo : false,
- setInterval : false,
- setTimeout : false,
- status : false,
- top : false,
- XMLHttpRequest : false
- },
-
- cssAttributeData,
- cssAny,
-
- cssColorData = {
- "aliceblue" : true,
- "antiquewhite" : true,
- "aqua" : true,
- "aquamarine" : true,
- "azure" : true,
- "beige" : true,
- "bisque" : true,
- "black" : true,
- "blanchedalmond" : true,
- "blue" : true,
- "blueviolet" : true,
- "brown" : true,
- "burlywood" : true,
- "cadetblue" : true,
- "chartreuse" : true,
- "chocolate" : true,
- "coral" : true,
- "cornflowerblue" : true,
- "cornsilk" : true,
- "crimson" : true,
- "cyan" : true,
- "darkblue" : true,
- "darkcyan" : true,
- "darkgoldenrod" : true,
- "darkgray" : true,
- "darkgreen" : true,
- "darkkhaki" : true,
- "darkmagenta" : true,
- "darkolivegreen" : true,
- "darkorange" : true,
- "darkorchid" : true,
- "darkred" : true,
- "darksalmon" : true,
- "darkseagreen" : true,
- "darkslateblue" : true,
- "darkslategray" : true,
- "darkturquoise" : true,
- "darkviolet" : true,
- "deeppink" : true,
- "deepskyblue" : true,
- "dimgray" : true,
- "dodgerblue" : true,
- "firebrick" : true,
- "floralwhite" : true,
- "forestgreen" : true,
- "fuchsia" : true,
- "gainsboro" : true,
- "ghostwhite" : true,
- "gold" : true,
- "goldenrod" : true,
- "gray" : true,
- "green" : true,
- "greenyellow" : true,
- "honeydew" : true,
- "hotpink" : true,
- "indianred" : true,
- "indigo" : true,
- "ivory" : true,
- "khaki" : true,
- "lavender" : true,
- "lavenderblush" : true,
- "lawngreen" : true,
- "lemonchiffon" : true,
- "lightblue" : true,
- "lightcoral" : true,
- "lightcyan" : true,
- "lightgoldenrodyellow" : true,
- "lightgreen" : true,
- "lightpink" : true,
- "lightsalmon" : true,
- "lightseagreen" : true,
- "lightskyblue" : true,
- "lightslategray" : true,
- "lightsteelblue" : true,
- "lightyellow" : true,
- "lime" : true,
- "limegreen" : true,
- "linen" : true,
- "magenta" : true,
- "maroon" : true,
- "mediumaquamarine" : true,
- "mediumblue" : true,
- "mediumorchid" : true,
- "mediumpurple" : true,
- "mediumseagreen" : true,
- "mediumslateblue" : true,
- "mediumspringgreen" : true,
- "mediumturquoise" : true,
- "mediumvioletred" : true,
- "midnightblue" : true,
- "mintcream" : true,
- "mistyrose" : true,
- "moccasin" : true,
- "navajowhite" : true,
- "navy" : true,
- "oldlace" : true,
- "olive" : true,
- "olivedrab" : true,
- "orange" : true,
- "orangered" : true,
- "orchid" : true,
- "palegoldenrod" : true,
- "palegreen" : true,
- "paleturquoise" : true,
- "palevioletred" : true,
- "papayawhip" : true,
- "peachpuff" : true,
- "peru" : true,
- "pink" : true,
- "plum" : true,
- "powderblue" : true,
- "purple" : true,
- "red" : true,
- "rosybrown" : true,
- "royalblue" : true,
- "saddlebrown" : true,
- "salmon" : true,
- "sandybrown" : true,
- "seagreen" : true,
- "seashell" : true,
- "sienna" : true,
- "silver" : true,
- "skyblue" : true,
- "slateblue" : true,
- "slategray" : true,
- "snow" : true,
- "springgreen" : true,
- "steelblue" : true,
- "tan" : true,
- "teal" : true,
- "thistle" : true,
- "tomato" : true,
- "turquoise" : true,
- "violet" : true,
- "wheat" : true,
- "white" : true,
- "whitesmoke" : true,
- "yellow" : true,
- "yellowgreen" : true
- },
-
- cssBorderStyle,
- cssBreak,
-
- cssLengthData = {
- '%': true,
- 'cm': true,
- 'em': true,
- 'ex': true,
- 'in': true,
- 'mm': true,
- 'pc': true,
- 'pt': true,
- 'px': true
- },
-
- cssOverflow,
-
- devel = {
- alert : false,
- confirm : false,
- console : false,
- Debug : false,
- opera : false,
- prompt : false
- },
-
- escapes = {
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '"' : '\\"',
- '/' : '\\/',
- '\\': '\\\\'
- },
-
- funct, // The current function
-
- functionicity = [
- 'closure', 'exception', 'global', 'label',
- 'outer', 'unused', 'var'
- ],
-
- functions, // All of the functions
-
- global, // The global scope
- htmltag = {
- a: {},
- abbr: {},
- acronym: {},
- address: {},
- applet: {},
- area: {empty: true, parent: ' map '},
- article: {},
- aside: {},
- audio: {},
- b: {},
- base: {empty: true, parent: ' head '},
- bdo: {},
- big: {},
- blockquote: {},
- body: {parent: ' html noframes '},
- br: {empty: true},
- button: {},
- canvas: {parent: ' body p div th td '},
- caption: {parent: ' table '},
- center: {},
- cite: {},
- code: {},
- col: {empty: true, parent: ' table colgroup '},
- colgroup: {parent: ' table '},
- command: {parent: ' menu '},
- datalist: {},
- dd: {parent: ' dl '},
- del: {},
- details: {},
- dialog: {},
- dfn: {},
- dir: {},
- div: {},
- dl: {},
- dt: {parent: ' dl '},
- em: {},
- embed: {},
- fieldset: {},
- figure: {},
- font: {},
- footer: {},
- form: {},
- frame: {empty: true, parent: ' frameset '},
- frameset: {parent: ' html frameset '},
- h1: {},
- h2: {},
- h3: {},
- h4: {},
- h5: {},
- h6: {},
- head: {parent: ' html '},
- header: {},
- hgroup: {},
- hr: {empty: true},
- 'hta:application':
- {empty: true, parent: ' head '},
- html: {parent: '*'},
- i: {},
- iframe: {},
- img: {empty: true},
- input: {empty: true},
- ins: {},
- kbd: {},
- keygen: {},
- label: {},
- legend: {parent: ' details fieldset figure '},
- li: {parent: ' dir menu ol ul '},
- link: {empty: true, parent: ' head '},
- map: {},
- mark: {},
- menu: {},
- meta: {empty: true, parent: ' head noframes noscript '},
- meter: {},
- nav: {},
- noframes: {parent: ' html body '},
- noscript: {},
- object: {},
- ol: {},
- optgroup: {parent: ' select '},
- option: {parent: ' optgroup select '},
- output: {},
- p: {},
- param: {parent: ' applet object '},
- pre: {},
- progress: {},
- q: {},
- rp: {},
- rt: {},
- ruby: {},
- s: {},
- samp: {},
- script: {empty: true, parent: ' body div frame head iframe p pre span '},
- section: {},
- select: {},
- small: {},
- span: {},
- source: {},
- strong: {},
- style: {parent: ' head ', empty: true},
- sub: {},
- sup: {},
- table: {},
- tbody: {parent: ' table '},
- td: {parent: ' tr '},
- textarea: {},
- tfoot: {parent: ' table '},
- th: {parent: ' tr '},
- thead: {parent: ' table '},
- time: {},
- title: {parent: ' head '},
- tr: {parent: ' table tbody thead tfoot '},
- tt: {},
- u: {},
- ul: {},
- 'var': {},
- video: {}
- },
-
- ids, // HTML ids
- implied, // Implied globals
- inblock,
- indent,
- jsonmode,
- lines,
- lookahead,
- member,
- membersOnly,
- nexttoken,
- noreach,
- option,
- predefined, // Global variables defined by option
- prereg,
- prevtoken,
-
- rhino = {
- defineClass : false,
- deserialize : false,
- gc : false,
- help : false,
- load : false,
- loadClass : false,
- print : false,
- quit : false,
- readFile : false,
- readUrl : false,
- runCommand : false,
- seal : false,
- serialize : false,
- spawn : false,
- sync : false,
- toint32 : false,
- version : false
- },
-
- scope, // The current scope
-
- windows = {
- ActiveXObject: false,
- CScript : false,
- Debug : false,
- Enumerator : false,
- System : false,
- VBArray : false,
- WScript : false
- },
-
- src,
- stack,
-
-// standard contains the global names that are provided by the
-// ECMAScript standard.
-
- standard = {
- 'void' : false,
- Array : false,
- Boolean : false,
- Date : false,
- decodeURI : false,
- decodeURIComponent : false,
- encodeURI : false,
- encodeURIComponent : false,
- Error : false,
- 'eval' : false,
- EvalError : false,
- Function : false,
- hasOwnProperty : false,
- isFinite : false,
- isNaN : false,
- JSON : false,
- Math : false,
- Number : false,
- Object : false,
- parseInt : false,
- parseFloat : false,
- RangeError : false,
- ReferenceError : false,
- RegExp : false,
- String : false,
- SyntaxError : false,
- TypeError : false,
- URIError : false
- },
-
- standard_member = {
- E : true,
- LN2 : true,
- LN10 : true,
- LOG2E : true,
- LOG10E : true,
- PI : true,
- SQRT1_2 : true,
- SQRT2 : true,
- MAX_VALUE : true,
- MIN_VALUE : true,
- NEGATIVE_INFINITY : true,
- POSITIVE_INFINITY : true
- },
-
- strict_mode,
- syntax = {},
- tab,
- token,
- urls,
- warnings,
-
-// widget contains the global names which are provided to a Yahoo
-// (fna Konfabulator) widget.
-
- widget = {
- alert : true,
- animator : true,
- appleScript : true,
- beep : true,
- bytesToUIString : true,
- Canvas : true,
- chooseColor : true,
- chooseFile : true,
- chooseFolder : true,
- closeWidget : true,
- COM : true,
- convertPathToHFS : true,
- convertPathToPlatform : true,
- CustomAnimation : true,
- escape : true,
- FadeAnimation : true,
- filesystem : true,
- Flash : true,
- focusWidget : true,
- form : true,
- FormField : true,
- Frame : true,
- HotKey : true,
- Image : true,
- include : true,
- isApplicationRunning : true,
- iTunes : true,
- konfabulatorVersion : true,
- log : true,
- md5 : true,
- MenuItem : true,
- MoveAnimation : true,
- openURL : true,
- play : true,
- Point : true,
- popupMenu : true,
- preferenceGroups : true,
- preferences : true,
- print : true,
- prompt : true,
- random : true,
- Rectangle : true,
- reloadWidget : true,
- ResizeAnimation : true,
- resolvePath : true,
- resumeUpdates : true,
- RotateAnimation : true,
- runCommand : true,
- runCommandInBg : true,
- saveAs : true,
- savePreferences : true,
- screen : true,
- ScrollBar : true,
- showWidgetPreferences : true,
- sleep : true,
- speak : true,
- Style : true,
- suppressUpdates : true,
- system : true,
- tellWidget : true,
- Text : true,
- TextArea : true,
- Timer : true,
- unescape : true,
- updateNow : true,
- URL : true,
- Web : true,
- widget : true,
- Window : true,
- XMLDOM : true,
- XMLHttpRequest : true,
- yahooCheckLogin : true,
- yahooLogin : true,
- yahooLogout : true
- },
-
-// xmode is used to adapt to the exceptions in html parsing.
-// It can have these states:
-// false .js script file
-// html
-// outer
-// script
-// style
-// scriptstring
-// styleproperty
-
- xmode,
- xquote,
-
-// unsafe comment or string
- ax = /@cc|<\/?|script|\]*s\]|<\s*!|</i,
-// unsafe characters that are silently deleted by one or more browsers
-// Whitelist Replacement Char, 0xfffd
- cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\ufffc\ufffe-\uffff]/,
-// token
- tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jslint|members?|global)?|=|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/,
-// html token
- hx = /^\s*(['"=>\/&#]|<(?:\/|\!(?:--)?)?|[a-zA-Z][a-zA-Z0-9_\-:]*|[0-9]+|--)/,
-// characters in strings that need escapement
- nx = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
- nxg = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
-// outer html token
- ox = /[>&]|<[\/!]?|--/,
-// star slash
- lx = /\*\/|\/\*/,
-// identifier
- ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/,
-// javascript url
- jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i,
-// url badness
- ux = /&|\+|\u00AD|\.\.|\/\*|%[^;]|base64|url|expression|data|mailto/i,
-// style
- sx = /^\s*([{:#%.=,>+\[\]@()"';]|\*=?|\$=|\|=|\^=|~=|[a-zA-Z_][a-zA-Z0-9_\-]*|[0-9]+|<\/|\/\*)/,
- ssx = /^\s*(\.?\d+(?:\.\d+)?|[@#!"'};:\-%.=,+\[\]()*_]|[a-zA-Z][a-zA-Z0-9._\-]*|\/\*?|<\/)/,
-// attributes characters
- //qx = /[^a-zA-Z0-9+\-_\/ ]/,
- qx = /[^a-zA-Z0-9+\-_\/ .#]/, // We want dots in names, period; and hashes for templating
-// query characters for ids
- //dx = /[\[\]\/\\"'*<>.&:(){}+=#]/,
- // allow . and /
- dx = /[\[\]\\"'*<>&:(){}+=#]/,
-
- rx = {
- outer: hx,
- html: hx,
- style: sx,
- styleproperty: ssx
- };
-
- function F() {}
-
- if (typeof Object.create !== 'function') {
- Object.create = function (o) {
- F.prototype = o;
- return new F();
- };
- }
-
-
- function is_own(object, name) {
- return Object.prototype.hasOwnProperty.call(object, name);
- }
-
-
- function combine(t, o) {
- var n;
- for (n in o) {
- if (is_own(o, n)) {
- t[n] = o[n];
- }
- }
- }
-
- String.prototype.entityify = function () {
- return this.
- replace(/&/g, '&').
- replace(/</g, '<').
- replace(/>/g, '>');
- };
-
- String.prototype.isAlpha = function () {
- return (this >= 'a' && this <= 'z\uffff') ||
- (this >= 'A' && this <= 'Z\uffff');
- };
-
-
- String.prototype.isDigit = function () {
- return (this >= '0' && this <= '9');
- };
-
-
- String.prototype.supplant = function (o) {
- return this.replace(/\{([^{}]*)\}/g, function (a, b) {
- var r = o[b];
- return typeof r === 'string' || typeof r === 'number' ? r : a;
- });
- };
-
- String.prototype.name = function () {
-
-// If the string looks like an identifier, then we can return it as is.
-// If the string contains no control characters, no quote characters, and no
-// backslash characters, then we can simply slap some quotes around it.
-// Otherwise we must also replace the offending characters with safe
-// sequences.
-
- if (ix.test(this)) {
- return this;
- }
- if (nx.test(this)) {
- return '"' + this.replace(nxg, function (a) {
- var c = escapes[a];
- if (c) {
- return c;
- }
- return '\\u' + ('0000' + a.charCodeAt().toString(16)).slice(-4);
- }) + '"';
- }
- return '"' + this + '"';
- };
-
-
- function assume() {
- if (!option.safe) {
- if (option.rhino) {
- combine(predefined, rhino);
- }
- if (option.devel) {
- combine(predefined, devel);
- }
- if (option.browser) {
- combine(predefined, browser);
- }
- if (option.windows) {
- combine(predefined, windows);
- }
- if (option.widget) {
- combine(predefined, widget);
- }
- }
- }
-
-
-// Produce an error warning.
-
- function quit(m, l, ch) {
- throw {
- name: 'JSLintError',
- line: l,
- character: ch,
- message: m + " (" + Math.floor((l / lines.length) * 100) +
- "% scanned)."
- };
- }
-
- function warning(m, t, a, b, c, d) {
- var ch, l, w;
- t = t || nexttoken;
- if (t.id === '(end)') { // `~
- t = token;
- }
- l = t.line || 0;
- ch = t.from || 0;
- w = {
- id: '(error)',
- raw: m,
- evidence: lines[l - 1] || '',
- line: l,
- character: ch,
- a: a,
- b: b,
- c: c,
- d: d
- };
- w.reason = m.supplant(w);
- JSLINT.errors.push(w);
- if (option.passfail) {
- quit('Stopping. ', l, ch);
- }
- warnings += 1;
- if (warnings >= option.maxerr) {
- quit("Too many errors.", l, ch);
- }
- return w;
- }
-
- function warningAt(m, l, ch, a, b, c, d) {
- return warning(m, {
- line: l,
- from: ch
- }, a, b, c, d);
- }
-
- function error(m, t, a, b, c, d) {
- var w = warning(m, t, a, b, c, d);
- quit("Stopping, unable to continue.", w.line, w.character);
- }
-
- function errorAt(m, l, ch, a, b, c, d) {
- return error(m, {
- line: l,
- from: ch
- }, a, b, c, d);
- }
-
-
-
-// lexical analysis
-
- var lex = (function lex() {
- var character, from, line, s;
-
-// Private lex methods
-
- function nextLine() {
- var at;
- if (line >= lines.length) {
- return false;
- }
- character = 1;
- s = lines[line];
- line += 1;
- at = s.search(/ \t/);
- if (at >= 0) {
- warningAt("Mixed spaces and tabs.", line, at + 1);
- }
- s = s.replace(/\t/g, tab);
- at = s.search(cx);
- if (at >= 0) {
- warningAt("Unsafe character.", line, at);
- }
- if (option.maxlen && option.maxlen < s.length) {
- warningAt("Line too long.", line, s.length);
- }
- return true;
- }
-
-// Produce a token object. The token inherits from a syntax symbol.
-
- function it(type, value) {
- var i, t;
- if (type === '(color)') {
- t = {type: type};
- } else if (type === '(punctuator)' ||
- (type === '(identifier)' && is_own(syntax, value))) {
- t = syntax[value] || syntax['(error)'];
- } else {
- t = syntax[type];
- }
- t = Object.create(t);
- if (type === '(string)' || type === '(range)') {
- if (jx.test(value)) {
- warningAt("Script URL.", line, from);
- }
- }
- if (type === '(identifier)') {
- t.identifier = true;
- if (value === '__iterator__' || value === '__proto__') {
- errorAt("Reserved name '{a}'.",
- line, from, value);
- } else if (option.nomen &&
- (value.charAt(0) === '_' ||
- value.charAt(value.length - 1) === '_')) {
- warningAt("Unexpected {a} in '{b}'.", line, from,
- "dangling '_'", value);
- }
- }
- t.value = value;
- t.line = line;
- t.character = character;
- t.from = from;
- i = t.id;
- if (i !== '(endline)') {
- prereg = i &&
- (('(,=:[!&|?{};'.indexOf(i.charAt(i.length - 1)) >= 0) ||
- i === 'return');
- }
- return t;
- }
-
-// Public lex methods
-
- return {
- init: function (source) {
- if (typeof source === 'string') {
- lines = source.
- replace(/\r\n/g, '\n').
- replace(/\r/g, '\n').
- split('\n');
- } else {
- lines = source;
- }
- line = 0;
- nextLine();
- from = 1;
- },
-
- range: function (begin, end) {
- var c, value = '';
- from = character;
- if (s.charAt(0) !== begin) {
- errorAt("Expected '{a}' and instead saw '{b}'.",
- line, character, begin, s.charAt(0));
- }
- for (;;) {
- s = s.slice(1);
- character += 1;
- c = s.charAt(0);
- switch (c) {
- case '':
- errorAt("Missing '{a}'.", line, character, c);
- break;
- case end:
- s = s.slice(1);
- character += 1;
- return it('(range)', value);
- case xquote:
- case '\\':
- warningAt("Unexpected '{a}'.", line, character, c);
- }
- value += c;
- }
-
- },
-
-// skip all content up to marker
-
- skip_till: function (end) {
- for (;;) {
- i = s.indexOf(end);
- if (i >= 0) {
- break;
- }
- if (!nextLine()) {
- errorAt("Unclosed {a} block.", line, character, end);
- }
- }
- character += i;
- s = s.substr(i);
- },
-
-// token -- this is called by advance to get the next token.
-
- token: function () {
- var b, c, captures, d, depth, high, i, l, low, q, t;
-
- function match(x) {
- var r = x.exec(s), r1;
- if (r) {
- l = r[0].length;
- r1 = r[1];
- c = r1.charAt(0);
- s = s.substr(l);
- from = character + l - r1.length;
- character += l;
- return r1;
- }
- }
-
- function string(x) {
- var c, j, r = '';
-
- if (jsonmode && x !== '"') {
- warningAt("Strings must use doublequote.",
- line, character);
- }
-
- if (xquote === x || (xmode === 'scriptstring' && !xquote)) {
- return it('(punctuator)', x);
- }
-
- function esc(n) {
- var i = parseInt(s.substr(j + 1, n), 16);
- j += n;
- if (i >= 32 && i <= 126 &&
- i !== 34 && i !== 92 && i !== 39) {
- warningAt("Unnecessary escapement.", line, character);
- }
- character += n;
- c = String.fromCharCode(i);
- }
- j = 0;
- for (;;) {
- while (j >= s.length) {
- j = 0;
- if (xmode !== 'html' || !nextLine()) {
- errorAt("Unclosed string.", line, from);
- }
- }
- c = s.charAt(j);
- if (c === x) {
- character += 1;
- s = s.substr(j + 1);
- return it('(string)', r, x);
- }
- if (c < ' ') {
- if (c === '\n' || c === '\r') {
- break;
- }
- warningAt("Control character in string: {a}.",
- line, character + j, s.slice(0, j));
- } else if (c === xquote) {
- warningAt("Bad HTML string", line, character + j);
- } else if (c === '<') {
- if (option.safe && xmode === 'html') {
- warningAt("ADsafe string violation.",
- line, character + j);
- } else if (s.charAt(j + 1) === '/' && (xmode || option.safe) && s.substr(j + 2, 6) === 'script') {
- warningAt("Expected '<\\/' and instead saw '</'.", line, character);
- } else if (s.charAt(j + 1) === '!' && (xmode || option.safe)) {
- warningAt("Unexpected '<!' in a string.", line, character);
- }
- } else if (c === '\\') {
- if (xmode === 'html') {
- if (option.safe) {
- warningAt("ADsafe string violation.",
- line, character + j);
- }
- } else if (xmode === 'styleproperty') {
- j += 1;
- character += 1;
- c = s.charAt(j);
- if (c !== x) {
- warningAt("Escapement in style string.",
- line, character + j);
- }
- } else {
- j += 1;
- character += 1;
- c = s.charAt(j);
- switch (c) {
- case xquote:
- warningAt("Bad HTML string", line,
- character + j);
- break;
- case '\\':
- case '\'':
- case '"':
- case '/':
- break;
- case 'b':
- c = '\b';
- break;
- case 'f':
- c = '\f';
- break;
- case 'n':
- c = '\n';
- break;
- case 'r':
- c = '\r';
- break;
- case 't':
- c = '\t';
- break;
- case 'u':
- esc(4);
- break;
- case 'v':
- c = '\v';
- break;
- case 'x':
- if (jsonmode) {
- warningAt("Avoid \\x-.", line, character);
- }
- esc(2);
- break;
- default:
- warningAt("Bad escapement.", line, character);
- }
- }
- }
- r += c;
- character += 1;
- j += 1;
- }
- }
-
- for (;;) {
- if (!s) {
- return it(nextLine() ? '(endline)' : '(end)', '');
- }
- while (xmode === 'outer') {
- i = s.search(ox);
- if (i === 0) {
- break;
- } else if (i > 0) {
- character += 1;
- s = s.slice(i);
- break;
- } else {
- if (!nextLine()) {
- return it('(end)', '');
- }
- }
- }
-// t = match(rx[xmode] || tx);
-// if (!t) {
-// if (xmode === 'html') {
-// return it('(error)', s.charAt(0));
-// } else {
-// t = '';
-// c = '';
-// while (s && s < '!') {
-// s = s.substr(1);
-// }
-// if (s) {
-// errorAt("Unexpected '{a}'.",
-// line, character, s.substr(0, 1));
-// }
-// }
- t = match(rx[xmode] || tx);
- if (!t) {
- t = '';
- c = '';
- while (s && s < '!') {
- s = s.substr(1);
- }
- if (s) {
- if (xmode === 'html') {
- return it('(error)', s.charAt(0));
- } else {
- errorAt("Unexpected '{a}'.",
- line, character, s.substr(0, 1));
- }
- }
- } else {
-
- // identifier
-
- if (c.isAlpha() || c === '_' || c === '$') {
- return it('(identifier)', t);
- }
-
- // number
-
- if (c.isDigit() || (c === '.' && t.substr(1, 1).isDigit())) {
- if (c === '.') {
- t = '0' + t;
- c = '0';
- }
-
- if (xmode !== 'style' && !isFinite(Number(t))) {
- warningAt("Bad number '{a}'.",
- line, character, t);
- }
- if (xmode !== 'style' &&
- xmode !== 'styleproperty' &&
- s.substr(0, 1).isAlpha()) {
- warningAt("Missing space after '{a}'.",
- line, character, t);
- }
- if (c === '0') {
- d = t.substr(1, 1);
- if (d.isDigit()) {
- if (token.id !== '.' && xmode !== 'styleproperty') {
- warningAt("Don't use extra leading zeros '{a}'.",
- line, character, t);
- }
- } else if (jsonmode && (d === 'x' || d === 'X')) {
- warningAt("Avoid 0x-. '{a}'.",
- line, character, t);
- }
- }
- if (t.substr(t.length - 1) === '.') {
- warningAt(
- "A trailing decimal point can be confused with a dot '{a}'.",
- line, character, t);
- }
- return it('(number)', t);
- }
- switch (t) {
-
- // string
-
- case '"':
- case "'":
- return string(t);
-
- // // comment
-
- case '//':
- if (src || (xmode && xmode !== 'script')) {
- warningAt("Unexpected comment.", line, character);
- } else if (xmode === 'script' && /<\s*\//i.test(s)) {
- warningAt("Unexpected <\/ in comment.", line, character);
- } else if ((option.safe || xmode === 'script') && ax.test(s)) {
- warningAt("Dangerous comment.", line, character);
- }
- s = '';
- token.comment = true;
- break;
-
- // /* comment
-
- case '/*':
- if (src || (xmode && xmode !== 'script' && xmode !== 'style' && xmode !== 'styleproperty')) {
- warningAt("Unexpected comment.", line, character);
- }
- if (option.safe && ax.test(s)) {
- warningAt("ADsafe comment violation.", line, character);
- }
- for (;;) {
- i = s.search(lx);
- if (i >= 0) {
- break;
- }
- if (!nextLine()) {
- errorAt("Unclosed comment.", line, character);
- } else {
- if (option.safe && ax.test(s)) {
- warningAt("ADsafe comment violation.",
- line, character);
- }
- }
- }
- character += i + 2;
- if (s.substr(i, 1) === '/') {
- errorAt("Nested comment.", line, character);
- }
- s = s.substr(i + 2);
- token.comment = true;
- break;
-
- // /*members /*jslint /*global
-
- case '/*members':
- case '/*member':
- case '/*jslint':
- case '/*global':
- case '*/':
- return {
- value: t,
- type: 'special',
- line: line,
- character: character,
- from: from
- };
-
- case '':
- break;
- // /
- case '/':
- if (token.id === '/=') {
- errorAt(
-"A regular expression literal can be confused with '/='.", line, from);
- }
- if (prereg) {
- depth = 0;
- captures = 0;
- l = 0;
- for (;;) {
- b = true;
- c = s.charAt(l);
- l += 1;
- switch (c) {
- case '':
- errorAt("Unclosed regular expression.",
- line, from);
- return;
- case '/':
- if (depth > 0) {
- warningAt("Unescaped '{a}'.",
- line, from + l, '/');
- }
- c = s.substr(0, l - 1);
- q = {
- g: true,
- i: true,
- m: true
- };
- while (q[s.charAt(l)] === true) {
- q[s.charAt(l)] = false;
- l += 1;
- }
- character += l;
- s = s.substr(l);
- q = s.charAt(0);
- if (q === '/' || q === '*') {
- errorAt("Confusing regular expression.",
- line, from);
- }
- return it('(regexp)', c);
- case '\\':
- c = s.charAt(l);
- if (c < ' ') {
- warningAt(
-"Unexpected control character in regular expression.", line, from + l);
- } else if (c === '<') {
- warningAt(
-"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
- }
- l += 1;
- break;
- case '(':
- depth += 1;
- b = false;
- if (s.charAt(l) === '?') {
- l += 1;
- switch (s.charAt(l)) {
- case ':':
- case '=':
- case '!':
- l += 1;
- break;
- default:
- warningAt(
-"Expected '{a}' and instead saw '{b}'.", line, from + l, ':', s.charAt(l));
- }
- } else {
- captures += 1;
- }
- break;
- case '|':
- b = false;
- break;
- case ')':
- if (depth === 0) {
- warningAt("Unescaped '{a}'.",
- line, from + l, ')');
- } else {
- depth -= 1;
- }
- break;
- case ' ':
- q = 1;
- while (s.charAt(l) === ' ') {
- l += 1;
- q += 1;
- }
- if (q > 1) {
- warningAt(
-"Spaces are hard to count. Use {{a}}.", line, from + l, q);
- }
- break;
- case '[':
- c = s.charAt(l);
- if (c === '^') {
- l += 1;
- if (option.regexp) {
- warningAt("Insecure '{a}'.",
- line, from + l, c);
- }
- }
- q = false;
- if (c === ']') {
- warningAt("Empty class.", line,
- from + l - 1);
- q = true;
- }
-klass: do {
- c = s.charAt(l);
- l += 1;
- switch (c) {
- case '[':
- case '^':
- warningAt("Unescaped '{a}'.",
- line, from + l, c);
- q = true;
- break;
- case '-':
- if (q) {
- q = false;
- } else {
- warningAt("Unescaped '{a}'.",
- line, from + l, '-');
- q = true;
- }
- break;
- case ']':
- if (!q) {
- warningAt("Unescaped '{a}'.",
- line, from + l - 1, '-');
- }
- break klass;
- case '\\':
- c = s.charAt(l);
- if (c < ' ') {
- warningAt(
-"Unexpected control character in regular expression.", line, from + l);
- } else if (c === '<') {
- warningAt(
-"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
- }
- l += 1;
- q = true;
- break;
- case '/':
- warningAt("Unescaped '{a}'.",
- line, from + l - 1, '/');
- q = true;
- break;
- case '<':
- if (xmode === 'script') {
- c = s.charAt(l);
- if (c === '!' || c === '/') {
- warningAt(
-"HTML confusion in regular expression '<{a}'.", line, from + l, c);
- }
- }
- q = true;
- break;
- default:
- q = true;
- }
- } while (c);
- break;
- case '.':
- if (option.regexp) {
- warningAt("Insecure '{a}'.", line,
- from + l, c);
- }
- break;
- case ']':
- case '?':
- case '{':
- case '}':
- case '+':
- case '*':
- warningAt("Unescaped '{a}'.", line,
- from + l, c);
- break;
- case '<':
- if (xmode === 'script') {
- c = s.charAt(l);
- if (c === '!' || c === '/') {
- warningAt(
-"HTML confusion in regular expression '<{a}'.", line, from + l, c);
- }
- }
- }
- if (b) {
- switch (s.charAt(l)) {
- case '?':
- case '+':
- case '*':
- l += 1;
- if (s.charAt(l) === '?') {
- l += 1;
- }
- break;
- case '{':
- l += 1;
- c = s.charAt(l);
- if (c < '0' || c > '9') {
- warningAt(
-"Expected a number and instead saw '{a}'.", line, from + l, c);
- }
- l += 1;
- low = +c;
- for (;;) {
- c = s.charAt(l);
- if (c < '0' || c > '9') {
- break;
- }
- l += 1;
- low = +c + (low * 10);
- }
- high = low;
- if (c === ',') {
- l += 1;
- high = Infinity;
- c = s.charAt(l);
- if (c >= '0' && c <= '9') {
- l += 1;
- high = +c;
- for (;;) {
- c = s.charAt(l);
- if (c < '0' || c > '9') {
- break;
- }
- l += 1;
- high = +c + (high * 10);
- }
- }
- }
- if (s.charAt(l) !== '}') {
- warningAt(
-"Expected '{a}' and instead saw '{b}'.", line, from + l, '}', c);
- } else {
- l += 1;
- }
- if (s.charAt(l) === '?') {
- l += 1;
- }
- if (low > high) {
- warningAt(
-"'{a}' should not be greater than '{b}'.", line, from + l, low, high);
- }
- }
- }
- }
- c = s.substr(0, l - 1);
- character += l;
- s = s.substr(l);
- return it('(regexp)', c);
- }
- return it('(punctuator)', t);
-
- // punctuator
-
- case '<!--':
- l = line;
- c = character;
- for (;;) {
- i = s.indexOf('--');
- if (i >= 0) {
- break;
- }
- i = s.indexOf('<!-');
- if (i >= 0) {
- errorAt("Nested HTML comment.",
- line, character + i);
- }
- if (!nextLine()) {
- errorAt("Unclosed HTML comment.", l, c);
- }
- }
- l = s.indexOf('<!-');
- if (l >= 0 && l < i) {
- errorAt("Nested HTML comment.",
- line, character + l);
- }
- character += i;
- if (s[i + 2] !== '>') {
- errorAt("Expected -->.", line, character);
- }
- character += 3;
- s = s.slice(i + 3);
- break;
- case '#':
- if (xmode === 'html' || xmode === 'styleproperty') {
- for (;;) {
- c = s.charAt(0);
- if ((c < '0' || c > '9') &&
- (c < 'a' || c > 'f') &&
- (c < 'A' || c > 'F')) {
- break;
- }
- character += 1;
- s = s.substr(1);
- t += c;
- }
- if (t.length !== 4 && t.length !== 7) {
- warningAt("Bad hex color '{a}'.", line,
- from + l, t);
- }
- return it('(color)', t);
- }
- return it('(punctuator)', t);
- default:
- if (xmode === 'outer' && c === '&') {
- character += 1;
- s = s.substr(1);
- for (;;) {
- c = s.charAt(0);
- character += 1;
- s = s.substr(1);
- if (c === ';') {
- break;
- }
- if (!((c >= '0' && c <= '9') ||
- (c >= 'a' && c <= 'z') ||
- c === '#')) {
- errorAt("Bad entity", line, from + l,
- character);
- }
- }
- break;
- }
- return it('(punctuator)', t);
- }
- }
- }
- }
- };
- }());
-
-
- function addlabel(t, type) {
-
- if (option.safe && funct['(global)'] &&
- typeof predefined[t] !== 'boolean') {
- warning('ADsafe global: ' + t + '.', token);
- } else if (t === 'hasOwnProperty') {
- warning("'hasOwnProperty' is a really bad name.");
- }
-
-// Define t in the current function in the current scope.
-
- if (is_own(funct, t) && !funct['(global)']) {
- warning(funct[t] === true ?
- "'{a}' was used before it was defined." :
- "'{a}' is already defined.",
- nexttoken, t);
- }
- funct[t] = type;
- if (funct['(global)']) {
- global[t] = funct;
- if (is_own(implied, t)) {
- warning("'{a}' was used before it was defined.", nexttoken, t);
- delete implied[t];
- }
- } else {
- scope[t] = funct;
- }
- }
-
-
- function doOption() {
- var b, obj, filter, o = nexttoken.value, t, v;
- switch (o) {
- case '*/':
- error("Unbegun comment.");
- break;
- case '/*members':
- case '/*member':
- o = '/*members';
- if (!membersOnly) {
- membersOnly = {};
- }
- obj = membersOnly;
- break;
- case '/*jslint':
- if (option.safe) {
- warning("ADsafe restriction.");
- }
- obj = option;
- filter = boolOptions;
- break;
- case '/*global':
- if (option.safe) {
- warning("ADsafe restriction.");
- }
- obj = predefined;
- break;
- default:
- }
- t = lex.token();
-loop: for (;;) {
- for (;;) {
- if (t.type === 'special' && t.value === '*/') {
- break loop;
- }
- if (t.id !== '(endline)' && t.id !== ',') {
- break;
- }
- t = lex.token();
- }
- if (t.type !== '(string)' && t.type !== '(identifier)' &&
- o !== '/*members') {
- error("Bad option.", t);
- }
- v = lex.token();
- if (v.id === ':') {
- v = lex.token();
- if (obj === membersOnly) {
- error("Expected '{a}' and instead saw '{b}'.",
- t, '*/', ':');
- }
- if (t.value === 'indent' && o === '/*jslint') {
- b = +v.value;
- if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.white = true;
- obj.indent = b;
- } else if (t.value === 'maxerr' && o === '/*jslint') {
- b = +v.value;
- if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.maxerr = b;
- } else if (t.value === 'maxlen' && o === '/*jslint') {
- b = +v.value;
- if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.maxlen = b;
- } else if (v.value === 'true') {
- obj[t.value] = true;
- } else if (v.value === 'false') {
- obj[t.value] = false;
- } else {
- error("Bad option value.", v);
- }
- t = lex.token();
- } else {
- if (o === '/*jslint') {
- error("Missing option value.", t);
- }
- obj[t.value] = false;
- t = v;
- }
- }
- if (filter) {
- assume();
- }
- }
-
-
-// We need a peek function. If it has an argument, it peeks that much farther
-// ahead. It is used to distinguish
-// for ( var i in ...
-// from
-// for ( var i = ...
-
- function peek(p) {
- var i = p || 0, j = 0, t;
-
- while (j <= i) {
- t = lookahead[j];
- if (!t) {
- t = lookahead[j] = lex.token();
- }
- j += 1;
- }
- return t;
- }
-
-
-
-// Produce the next token. It looks for programming errors.
-
- function advance(id, t) {
- switch (token.id) {
- case '(number)':
- if (nexttoken.id === '.') {
- warning(
-"A dot following a number can be confused with a decimal point.", token);
- }
- break;
- case '-':
- if (nexttoken.id === '-' || nexttoken.id === '--') {
- warning("Confusing minusses.");
- }
- break;
- case '+':
- if (nexttoken.id === '+' || nexttoken.id === '++') {
- warning("Confusing plusses.");
- }
- break;
- }
- if (token.type === '(string)' || token.identifier) {
- anonname = token.value;
- }
-
- if (id && nexttoken.id !== id) {
- if (t) {
- if (nexttoken.id === '(end)') {
- warning("Unmatched '{a}'.", t, t.id);
- } else {
- warning(
-"Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
- nexttoken, id, t.id, t.line, nexttoken.value);
- }
- } else if (nexttoken.type !== '(identifier)' ||
- nexttoken.value !== id) {
- warning("Expected '{a}' and instead saw '{b}'.",
- nexttoken, id, nexttoken.value);
- }
- }
- prevtoken = token;
- token = nexttoken;
- for (;;) {
- nexttoken = lookahead.shift() || lex.token();
- if (nexttoken.id === '(end)' || nexttoken.id === '(error)') {
- return;
- }
- if (nexttoken.type === 'special') {
- doOption();
- } else {
- if (nexttoken.id !== '(endline)') {
- break;
- }
- }
- }
- }
-
-
-// This is the heart of JSLINT, the Pratt parser. In addition to parsing, it
-// is looking for ad hoc lint patterns. We add to Pratt's model .fud, which is
-// like nud except that it is only used on the first token of a statement.
-// Having .fud makes it much easier to define JavaScript. I retained Pratt's
-// nomenclature.
-
-// .nud Null denotation
-// .fud First null denotation
-// .led Left denotation
-// lbp Left binding power
-// rbp Right binding power
-
-// They are key to the parsing method called Top Down Operator Precedence.
-
- function parse(rbp, initial) {
- var left;
- if (nexttoken.id === '(end)') {
- error("Unexpected early end of program.", token);
- }
- advance();
- if (option.safe && typeof predefined[token.value] === 'boolean' &&
- (nexttoken.id !== '(' && nexttoken.id !== '.')) {
- warning('ADsafe violation.', token);
- }
- if (initial) {
- anonname = 'anonymous';
- funct['(verb)'] = token.value;
- }
- if (initial === true && token.fud) {
- left = token.fud();
- } else {
- if (token.nud) {
- left = token.nud();
- } else {
- if (nexttoken.type === '(number)' && token.id === '.') {
- warning(
-"A leading decimal point can be confused with a dot: '.{a}'.",
- token, nexttoken.value);
- advance();
- return token;
- } else {
- error("Expected an identifier and instead saw '{a}'.",
- token, token.id);
- }
- }
- while (rbp < nexttoken.lbp) {
- advance();
- if (token.led) {
- left = token.led(left);
- } else {
- error("Expected an operator and instead saw '{a}'.",
- token, token.id);
- }
- }
- }
- return left;
- }
-
-
-// Functions for conformance of style.
-
- function adjacent(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (option.white || xmode === 'styleproperty' || xmode === 'style') {
- if (left.character !== right.from && left.line === right.line) {
- warning("Unexpected space after '{a}'.", right, left.value);
- }
- }
- }
-
- function nospace(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (option.white && !left.comment) {
- if (left.line === right.line) {
- adjacent(left, right);
- }
- }
- }
-
-
- function nonadjacent(left, right) {
- if (option.white) {
- left = left || token;
- right = right || nexttoken;
- if (left.line === right.line && left.character === right.from) {
- warning("Missing space after '{a}'.",
-
<TRUNCATED>
[03/10] [#4122] rename AlluraTesting dir to AlluraTest,
to match the module name below
Posted by br...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/jslint/fulljslint.js
----------------------------------------------------------------------
diff --git a/AlluraTesting/jslint/fulljslint.js b/AlluraTesting/jslint/fulljslint.js
deleted file mode 100644
index 0bf59bb..0000000
--- a/AlluraTesting/jslint/fulljslint.js
+++ /dev/null
@@ -1,5688 +0,0 @@
-// jslint.js
-// 2010-08-05
-
-/*
-Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-The Software shall be used for Good, not Evil.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-/*
- JSLINT is a global function. It takes two parameters.
-
- var myResult = JSLINT(source, option);
-
- The first parameter is either a string or an array of strings. If it is a
- string, it will be split on '\n' or '\r'. If it is an array of strings, it
- is assumed that each string represents one line. The source can be a
- JavaScript text, or HTML text, or a Konfabulator text.
-
- The second parameter is an optional object of options which control the
- operation of JSLINT. Most of the options are booleans: They are all are
- optional and have a default value of false.
-
- If it checks out, JSLINT returns true. Otherwise, it returns false.
-
- If false, you can inspect JSLINT.errors to find out the problems.
- JSLINT.errors is an array of objects containing these members:
-
- {
- line : The line (relative to 0) at which the lint was found
- character : The character (relative to 0) at which the lint was found
- reason : The problem
- evidence : The text line in which the problem occurred
- raw : The raw message before the details were inserted
- a : The first detail
- b : The second detail
- c : The third detail
- d : The fourth detail
- }
-
- If a fatal error was found, a null will be the last element of the
- JSLINT.errors array.
-
- You can request a Function Report, which shows all of the functions
- and the parameters and vars that they use. This can be used to find
- implied global variables and other problems. The report is in HTML and
- can be inserted in an HTML <body>.
-
- var myReport = JSLINT.report(limited);
-
- If limited is true, then the report will be limited to only errors.
-
- You can request a data structure which contains JSLint's results.
-
- var myData = JSLINT.data();
-
- It returns a structure with this form:
-
- {
- errors: [
- {
- line: NUMBER,
- character: NUMBER,
- reason: STRING,
- evidence: STRING
- }
- ],
- functions: [
- name: STRING,
- line: NUMBER,
- last: NUMBER,
- param: [
- STRING
- ],
- closure: [
- STRING
- ],
- var: [
- STRING
- ],
- exception: [
- STRING
- ],
- outer: [
- STRING
- ],
- unused: [
- STRING
- ],
- global: [
- STRING
- ],
- label: [
- STRING
- ]
- ],
- globals: [
- STRING
- ],
- member: {
- STRING: NUMBER
- },
- unuseds: [
- {
- name: STRING,
- line: NUMBER
- }
- ],
- implieds: [
- {
- name: STRING,
- line: NUMBER
- }
- ],
- urls: [
- STRING
- ],
- json: BOOLEAN
- }
-
- Empty arrays will not be included.
-
-*/
-
-/*jslint
- evil: true, nomen: false, onevar: false, regexp: false, strict: true
-*/
-
-/*members "\b", "\t", "\n", "\f", "\r", "!=", "!==", "\"", "%",
- "(begin)", "(breakage)", "(context)", "(error)", "(global)",
- "(identifier)", "(last)", "(line)", "(loopage)", "(name)", "(onevar)",
- "(params)", "(scope)", "(verb)", "*", "+", "++", "-", "--", "\/",
- "<", "<=", "==", "===", ">", ">=", ADSAFE, ActiveXObject,
- Array, Boolean, COM, CScript, Canvas, CustomAnimation, Date, Debug, E,
- Enumerator, Error, EvalError, FadeAnimation, Flash, FormField, Frame,
- Function, HotKey, Image, JSON, LN10, LN2, LOG10E, LOG2E, MAX_VALUE,
- MIN_VALUE, Math, MenuItem, MoveAnimation, NEGATIVE_INFINITY, Number,
- Object, Option, PI, POSITIVE_INFINITY, Point, RangeError, Rectangle,
- ReferenceError, RegExp, ResizeAnimation, RotateAnimation, SQRT1_2,
- SQRT2, ScrollBar, String, Style, SyntaxError, System, Text, TextArea,
- Timer, TypeError, URIError, URL, VBArray, WScript, Web, Window, XMLDOM,
- XMLHttpRequest, "\\", a, abbr, acronym, addEventListener, address,
- adsafe, alert, aliceblue, animator, antiquewhite, appleScript, applet,
- apply, approved, aqua, aquamarine, area, arguments, arity, article,
- aside, audio, autocomplete, azure, b, background,
- "background-attachment", "background-color", "background-image",
- "background-position", "background-repeat", base, bdo, beep, beige, big,
- bisque, bitwise, black, blanchedalmond, block, blockquote, blue,
- blueviolet, blur, body, border, "border-bottom", "border-bottom-color",
- "border-bottom-style", "border-bottom-width", "border-collapse",
- "border-color", "border-left", "border-left-color", "border-left-style",
- "border-left-width", "border-right", "border-right-color",
- "border-right-style", "border-right-width", "border-spacing",
- "border-style", "border-top", "border-top-color", "border-top-style",
- "border-top-width", "border-width", bottom, br, brown, browser,
- burlywood, button, bytesToUIString, c, cadetblue, call, callee, caller,
- canvas, cap, caption, "caption-side", cases, center, charAt, charCodeAt,
- character, chartreuse, chocolate, chooseColor, chooseFile, chooseFolder,
- cite, clear, clearInterval, clearTimeout, clip, close, closeWidget,
- closed, closure, cm, code, col, colgroup, color, command, comment,
- condition, confirm, console, constructor, content, convertPathToHFS,
- convertPathToPlatform, coral, cornflowerblue, cornsilk,
- "counter-increment", "counter-reset", create, crimson, css, cursor,
- cyan, d, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen,
- darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred,
- darksalmon, darkseagreen, darkslateblue, darkslategray, darkturquoise,
- darkviolet, data, datalist, dd, debug, decodeURI, decodeURIComponent,
- deeppink, deepskyblue, defaultStatus, defineClass, del, deserialize,
- details, devel, dfn, dialog, dimension, dimgray, dir, direction,
- display, div, dl, document, dodgerblue, dt, edition, else, em, embed,
- empty, "empty-cells", encodeURI, encodeURIComponent, entityify, eqeqeq,
- errors, es5, escape, eval, event, evidence, evil, ex, exception, exec, exps,
- fieldset, figure, filesystem, firebrick, first, float, floor,
- floralwhite, focus, focusWidget, font, "font-face", "font-family",
- "font-size", "font-size-adjust", "font-stretch", "font-style",
- "font-variant", "font-weight", footer, forestgreen, forin, form,
- fragment, frame, frames, frameset, from, fromCharCode, fuchsia, fud,
- funct, function, functions, g, gainsboro, gc, getComputedStyle,
- ghostwhite, global, globals, gold, goldenrod, gray, green, greenyellow,
- h1, h2, h3, h4, h5, h6, hasOwnProperty, head, header, height, help,
- hgroup, history, honeydew, hotpink, hr, 'hta:application', html,
- i, iTunes, id, identifier,
- iframe, img, immed, implieds, in, include, indent, indexOf, indianred,
- indigo, init, input, ins, isAlpha, isApplicationRunning, isDigit,
- isFinite, isNaN, ivory, join, jslint, json, kbd, keygen, khaki,
- konfabulatorVersion, label, labelled, lang, last, lavender,
- lavenderblush, lawngreen, laxbreak, lbp, led, left, legend,
- lemonchiffon, length, "letter-spacing", li, lib, lightblue, lightcoral,
- lightcyan, lightgoldenrodyellow, lightgreen, lightpink, lightsalmon,
- lightseagreen, lightskyblue, lightslategray, lightsteelblue,
- lightyellow, lime, limegreen, line, "line-height", linen, link,
- "list-style", "list-style-image", "list-style-position",
- "list-style-type", load, loadClass, location, log, m, magenta, map,
- margin, "margin-bottom", "margin-left", "margin-right", "margin-top",
- mark, "marker-offset", maroon, match, "max-height", "max-width", maxerr,
- maxlen, md5, media, mediumaquamarine, mediumblue, mediumorchid,
- mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen,
- mediumturquoise, mediumvioletred, member, menu, message, meta, meter,
- midnightblue, "min-height", "min-width", mintcream, mistyrose, mm,
- moccasin, moveBy, moveTo, name, nav, navajowhite, navigator, navy, new,
- newcap, noframes, nomen, noscript, nud, object, ol, oldlace, olive,
- olivedrab, on, onbeforeunload, onblur, onerror, onevar, onfocus, onload,
- onresize, onunload, opacity, open, openURL, opener, opera, optgroup,
- option, orange, orangered, orchid, outer, outline, "outline-color",
- "outline-style", "outline-width", output, overflow, "overflow-x",
- "overflow-y", p, padding, "padding-bottom", "padding-left",
- "padding-right", "padding-top", page, "page-break-after",
- "page-break-before", palegoldenrod, palegreen, paleturquoise,
- palevioletred, papayawhip, param, parent, parseFloat, parseInt,
- passfail, pc, peachpuff, peru, pink, play, plum, plusplus, pop,
- popupMenu, position, powderblue, pre, predef, preferenceGroups,
- preferences, print, progress, prompt, prototype, pt, purple, push, px,
- q, quit, quotes, random, range, raw, reach, readFile, readUrl, reason,
- red, regexp, reloadWidget, removeEventListener, replace, report,
- reserved, resizeBy, resizeTo, resolvePath, resumeUpdates, rhino, right,
- rosybrown, royalblue, rp, rt, ruby, runCommand, runCommandInBg,
- saddlebrown, safe, salmon, samp, sandybrown, saveAs, savePreferences,
- screen, script, scroll, scrollBy, scrollTo, seagreen, seal, search,
- seashell, section, select, serialize, setInterval, setTimeout, shift,
- showWidgetPreferences, sienna, silver, skyblue, slateblue, slategray,
- sleep, slice, small, snow, sort, source, span, spawn, speak, split,
- springgreen, src, stack, status, steelblue, strict, strong, style,
- styleproperty, sub, substr, sup, supplant, suppressUpdates, sync,
- system, table, "table-layout", tan, tbody, td, teal, tellWidget, test,
- "text-align", "text-decoration", "text-indent", "text-shadow",
- "text-transform", textarea, tfoot, th, thead, thistle, time, title,
- toLowerCase, toString, toUpperCase, toint32, token, tomato, top, tr, tt,
- turquoise, type, u, ul, undef, unescape, "unicode-bidi", unused,
- unwatch, updateNow, urls, value, valueOf, var, version,
- "vertical-align", video, violet, visibility, watch, wheat, white,
- "white-space", whitesmoke, widget, width, windows, "word-spacing",
- "word-wrap", yahooCheckLogin, yahooLogin, yahooLogout, yellow,
- yellowgreen, "z-index"
-*/
-
-// We build the application inside a function so that we produce only a single
-// global variable. The function will be invoked, its return value is the JSLINT
-// application itself.
-
-"use strict";
-
-var JSLINT = (function () {
- var adsafe_id, // The widget's ADsafe id.
- adsafe_may, // The widget may load approved scripts.
- adsafe_went, // ADSAFE.go has been called.
- anonname, // The guessed name for anonymous functions.
- approved, // ADsafe approved urls.
-
- atrule = {
- media : true,
- 'font-face': true,
- page : true
- },
-
-// These are operators that should not be used with the ! operator.
-
- bang = {
- '<': true,
- '<=': true,
- '==': true,
- '===': true,
- '!==': true,
- '!=': true,
- '>': true,
- '>=': true,
- '+': true,
- '-': true,
- '*': true,
- '/': true,
- '%': true
- },
-
-// These are members that should not be permitted in the safe subset.
-
- banned = { // the member names that ADsafe prohibits.
- 'arguments' : true,
- callee : true,
- caller : true,
- constructor : true,
- 'eval' : true,
- prototype : true,
- stack : true,
- unwatch : true,
- valueOf : true,
- watch : true
- },
-
-
-// These are the JSLint boolean options.
-
- boolOptions = {
- adsafe : true, // if ADsafe should be enforced
- bitwise : true, // if bitwise operators should not be allowed
- browser : true, // if the standard browser globals should be predefined
- cap : true, // if upper case HTML should be allowed
- css : true, // if CSS workarounds should be tolerated
- debug : true, // if debugger statements should be allowed
- devel : true, // if logging should be allowed (console, alert, etc.)
- eqeqeq : true, // if === should be required
- es5 : true, // if ES5 syntax should be allowed
- evil : true, // if eval should be allowed
- forin : true, // if for in statements must filter
- fragment : true, // if HTML fragments should be allowed
- immed : true, // if immediate invocations must be wrapped in parens
- laxbreak : true, // if line breaks should not be checked
- newcap : true, // if constructor names must be capitalized
- nomen : true, // if names should be checked
- on : true, // if HTML event handlers should be allowed
- onevar : true, // if only one var statement per function should be allowed
- passfail : true, // if the scan should stop on first error
- plusplus : true, // if increment/decrement should not be allowed
- regexp : true, // if the . should not be allowed in regexp literals
- rhino : true, // if the Rhino environment globals should be predefined
- undef : true, // if variables should be declared before used
- safe : true, // if use of some browser features should be restricted
- windows : true, // if MS Windows-specigic globals should be predefined
- strict : true, // require the "use strict"; pragma
- sub : true, // if all forms of subscript notation are tolerated
- white : true, // if strict whitespace rules apply
- widget : true // if the Yahoo Widgets globals should be predefined
- },
-
-// browser contains a set of global names which are commonly provided by a
-// web browser environment.
-
- browser = {
- addEventListener: false,
- blur : false,
- clearInterval : false,
- clearTimeout : false,
- close : false,
- closed : false,
- defaultStatus : false,
- document : false,
- event : false,
- focus : false,
- frames : false,
- getComputedStyle: false,
- history : false,
- Image : false,
- length : false,
- location : false,
- moveBy : false,
- moveTo : false,
- name : false,
- navigator : false,
- onbeforeunload : true,
- onblur : true,
- onerror : true,
- onfocus : true,
- onload : true,
- onresize : true,
- onunload : true,
- open : false,
- opener : false,
- Option : false,
- parent : false,
- print : false,
- removeEventListener: false,
- resizeBy : false,
- resizeTo : false,
- screen : false,
- scroll : false,
- scrollBy : false,
- scrollTo : false,
- setInterval : false,
- setTimeout : false,
- status : false,
- top : false,
- XMLHttpRequest : false
- },
-
- cssAttributeData,
- cssAny,
-
- cssColorData = {
- "aliceblue" : true,
- "antiquewhite" : true,
- "aqua" : true,
- "aquamarine" : true,
- "azure" : true,
- "beige" : true,
- "bisque" : true,
- "black" : true,
- "blanchedalmond" : true,
- "blue" : true,
- "blueviolet" : true,
- "brown" : true,
- "burlywood" : true,
- "cadetblue" : true,
- "chartreuse" : true,
- "chocolate" : true,
- "coral" : true,
- "cornflowerblue" : true,
- "cornsilk" : true,
- "crimson" : true,
- "cyan" : true,
- "darkblue" : true,
- "darkcyan" : true,
- "darkgoldenrod" : true,
- "darkgray" : true,
- "darkgreen" : true,
- "darkkhaki" : true,
- "darkmagenta" : true,
- "darkolivegreen" : true,
- "darkorange" : true,
- "darkorchid" : true,
- "darkred" : true,
- "darksalmon" : true,
- "darkseagreen" : true,
- "darkslateblue" : true,
- "darkslategray" : true,
- "darkturquoise" : true,
- "darkviolet" : true,
- "deeppink" : true,
- "deepskyblue" : true,
- "dimgray" : true,
- "dodgerblue" : true,
- "firebrick" : true,
- "floralwhite" : true,
- "forestgreen" : true,
- "fuchsia" : true,
- "gainsboro" : true,
- "ghostwhite" : true,
- "gold" : true,
- "goldenrod" : true,
- "gray" : true,
- "green" : true,
- "greenyellow" : true,
- "honeydew" : true,
- "hotpink" : true,
- "indianred" : true,
- "indigo" : true,
- "ivory" : true,
- "khaki" : true,
- "lavender" : true,
- "lavenderblush" : true,
- "lawngreen" : true,
- "lemonchiffon" : true,
- "lightblue" : true,
- "lightcoral" : true,
- "lightcyan" : true,
- "lightgoldenrodyellow" : true,
- "lightgreen" : true,
- "lightpink" : true,
- "lightsalmon" : true,
- "lightseagreen" : true,
- "lightskyblue" : true,
- "lightslategray" : true,
- "lightsteelblue" : true,
- "lightyellow" : true,
- "lime" : true,
- "limegreen" : true,
- "linen" : true,
- "magenta" : true,
- "maroon" : true,
- "mediumaquamarine" : true,
- "mediumblue" : true,
- "mediumorchid" : true,
- "mediumpurple" : true,
- "mediumseagreen" : true,
- "mediumslateblue" : true,
- "mediumspringgreen" : true,
- "mediumturquoise" : true,
- "mediumvioletred" : true,
- "midnightblue" : true,
- "mintcream" : true,
- "mistyrose" : true,
- "moccasin" : true,
- "navajowhite" : true,
- "navy" : true,
- "oldlace" : true,
- "olive" : true,
- "olivedrab" : true,
- "orange" : true,
- "orangered" : true,
- "orchid" : true,
- "palegoldenrod" : true,
- "palegreen" : true,
- "paleturquoise" : true,
- "palevioletred" : true,
- "papayawhip" : true,
- "peachpuff" : true,
- "peru" : true,
- "pink" : true,
- "plum" : true,
- "powderblue" : true,
- "purple" : true,
- "red" : true,
- "rosybrown" : true,
- "royalblue" : true,
- "saddlebrown" : true,
- "salmon" : true,
- "sandybrown" : true,
- "seagreen" : true,
- "seashell" : true,
- "sienna" : true,
- "silver" : true,
- "skyblue" : true,
- "slateblue" : true,
- "slategray" : true,
- "snow" : true,
- "springgreen" : true,
- "steelblue" : true,
- "tan" : true,
- "teal" : true,
- "thistle" : true,
- "tomato" : true,
- "turquoise" : true,
- "violet" : true,
- "wheat" : true,
- "white" : true,
- "whitesmoke" : true,
- "yellow" : true,
- "yellowgreen" : true
- },
-
- cssBorderStyle,
- cssBreak,
-
- cssLengthData = {
- '%': true,
- 'cm': true,
- 'em': true,
- 'ex': true,
- 'in': true,
- 'mm': true,
- 'pc': true,
- 'pt': true,
- 'px': true
- },
-
- cssOverflow,
-
- devel = {
- alert : false,
- confirm : false,
- console : false,
- Debug : false,
- opera : false,
- prompt : false
- },
-
- escapes = {
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '"' : '\\"',
- '/' : '\\/',
- '\\': '\\\\'
- },
-
- funct, // The current function
-
- functionicity = [
- 'closure', 'exception', 'global', 'label',
- 'outer', 'unused', 'var'
- ],
-
- functions, // All of the functions
-
- global, // The global scope
- htmltag = {
- a: {},
- abbr: {},
- acronym: {},
- address: {},
- applet: {},
- area: {empty: true, parent: ' map '},
- article: {},
- aside: {},
- audio: {},
- b: {},
- base: {empty: true, parent: ' head '},
- bdo: {},
- big: {},
- blockquote: {},
- body: {parent: ' html noframes '},
- br: {empty: true},
- button: {},
- canvas: {parent: ' body p div th td '},
- caption: {parent: ' table '},
- center: {},
- cite: {},
- code: {},
- col: {empty: true, parent: ' table colgroup '},
- colgroup: {parent: ' table '},
- command: {parent: ' menu '},
- datalist: {},
- dd: {parent: ' dl '},
- del: {},
- details: {},
- dialog: {},
- dfn: {},
- dir: {},
- div: {},
- dl: {},
- dt: {parent: ' dl '},
- em: {},
- embed: {},
- fieldset: {},
- figure: {},
- font: {},
- footer: {},
- form: {},
- frame: {empty: true, parent: ' frameset '},
- frameset: {parent: ' html frameset '},
- h1: {},
- h2: {},
- h3: {},
- h4: {},
- h5: {},
- h6: {},
- head: {parent: ' html '},
- header: {},
- hgroup: {},
- hr: {empty: true},
- 'hta:application':
- {empty: true, parent: ' head '},
- html: {parent: '*'},
- i: {},
- iframe: {},
- img: {empty: true},
- input: {empty: true},
- ins: {},
- kbd: {},
- keygen: {},
- label: {},
- legend: {parent: ' details fieldset figure '},
- li: {parent: ' dir menu ol ul '},
- link: {empty: true, parent: ' head '},
- map: {},
- mark: {},
- menu: {},
- meta: {empty: true, parent: ' head noframes noscript '},
- meter: {},
- nav: {},
- noframes: {parent: ' html body '},
- noscript: {},
- object: {},
- ol: {},
- optgroup: {parent: ' select '},
- option: {parent: ' optgroup select '},
- output: {},
- p: {},
- param: {parent: ' applet object '},
- pre: {},
- progress: {},
- q: {},
- rp: {},
- rt: {},
- ruby: {},
- s: {},
- samp: {},
- script: {empty: true, parent: ' body div frame head iframe p pre span '},
- section: {},
- select: {},
- small: {},
- span: {},
- source: {},
- strong: {},
- style: {parent: ' head ', empty: true},
- sub: {},
- sup: {},
- table: {},
- tbody: {parent: ' table '},
- td: {parent: ' tr '},
- textarea: {},
- tfoot: {parent: ' table '},
- th: {parent: ' tr '},
- thead: {parent: ' table '},
- time: {},
- title: {parent: ' head '},
- tr: {parent: ' table tbody thead tfoot '},
- tt: {},
- u: {},
- ul: {},
- 'var': {},
- video: {}
- },
-
- ids, // HTML ids
- implied, // Implied globals
- inblock,
- indent,
- jsonmode,
- lines,
- lookahead,
- member,
- membersOnly,
- nexttoken,
- noreach,
- option,
- predefined, // Global variables defined by option
- prereg,
- prevtoken,
-
- rhino = {
- defineClass : false,
- deserialize : false,
- gc : false,
- help : false,
- load : false,
- loadClass : false,
- print : false,
- quit : false,
- readFile : false,
- readUrl : false,
- runCommand : false,
- seal : false,
- serialize : false,
- spawn : false,
- sync : false,
- toint32 : false,
- version : false
- },
-
- scope, // The current scope
-
- windows = {
- ActiveXObject: false,
- CScript : false,
- Debug : false,
- Enumerator : false,
- System : false,
- VBArray : false,
- WScript : false
- },
-
- src,
- stack,
-
-// standard contains the global names that are provided by the
-// ECMAScript standard.
-
- standard = {
- 'void' : false,
- Array : false,
- Boolean : false,
- Date : false,
- decodeURI : false,
- decodeURIComponent : false,
- encodeURI : false,
- encodeURIComponent : false,
- Error : false,
- 'eval' : false,
- EvalError : false,
- Function : false,
- hasOwnProperty : false,
- isFinite : false,
- isNaN : false,
- JSON : false,
- Math : false,
- Number : false,
- Object : false,
- parseInt : false,
- parseFloat : false,
- RangeError : false,
- ReferenceError : false,
- RegExp : false,
- String : false,
- SyntaxError : false,
- TypeError : false,
- URIError : false
- },
-
- standard_member = {
- E : true,
- LN2 : true,
- LN10 : true,
- LOG2E : true,
- LOG10E : true,
- PI : true,
- SQRT1_2 : true,
- SQRT2 : true,
- MAX_VALUE : true,
- MIN_VALUE : true,
- NEGATIVE_INFINITY : true,
- POSITIVE_INFINITY : true
- },
-
- strict_mode,
- syntax = {},
- tab,
- token,
- urls,
- warnings,
-
-// widget contains the global names which are provided to a Yahoo
-// (fna Konfabulator) widget.
-
- widget = {
- alert : true,
- animator : true,
- appleScript : true,
- beep : true,
- bytesToUIString : true,
- Canvas : true,
- chooseColor : true,
- chooseFile : true,
- chooseFolder : true,
- closeWidget : true,
- COM : true,
- convertPathToHFS : true,
- convertPathToPlatform : true,
- CustomAnimation : true,
- escape : true,
- FadeAnimation : true,
- filesystem : true,
- Flash : true,
- focusWidget : true,
- form : true,
- FormField : true,
- Frame : true,
- HotKey : true,
- Image : true,
- include : true,
- isApplicationRunning : true,
- iTunes : true,
- konfabulatorVersion : true,
- log : true,
- md5 : true,
- MenuItem : true,
- MoveAnimation : true,
- openURL : true,
- play : true,
- Point : true,
- popupMenu : true,
- preferenceGroups : true,
- preferences : true,
- print : true,
- prompt : true,
- random : true,
- Rectangle : true,
- reloadWidget : true,
- ResizeAnimation : true,
- resolvePath : true,
- resumeUpdates : true,
- RotateAnimation : true,
- runCommand : true,
- runCommandInBg : true,
- saveAs : true,
- savePreferences : true,
- screen : true,
- ScrollBar : true,
- showWidgetPreferences : true,
- sleep : true,
- speak : true,
- Style : true,
- suppressUpdates : true,
- system : true,
- tellWidget : true,
- Text : true,
- TextArea : true,
- Timer : true,
- unescape : true,
- updateNow : true,
- URL : true,
- Web : true,
- widget : true,
- Window : true,
- XMLDOM : true,
- XMLHttpRequest : true,
- yahooCheckLogin : true,
- yahooLogin : true,
- yahooLogout : true
- },
-
-// xmode is used to adapt to the exceptions in html parsing.
-// It can have these states:
-// false .js script file
-// html
-// outer
-// script
-// style
-// scriptstring
-// styleproperty
-
- xmode,
- xquote,
-
-// unsafe comment or string
- ax = /@cc|<\/?|script|\]*s\]|<\s*!|</i,
-// unsafe characters that are silently deleted by one or more browsers
-// Whitelist Replacement Char, 0xfffd
- cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\ufffc\ufffe-\uffff]/,
-// token
- tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jslint|members?|global)?|=|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/,
-// html token
- hx = /^\s*(['"=>\/&#]|<(?:\/|\!(?:--)?)?|[a-zA-Z][a-zA-Z0-9_\-:]*|[0-9]+|--)/,
-// characters in strings that need escapement
- nx = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
- nxg = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
-// outer html token
- ox = /[>&]|<[\/!]?|--/,
-// star slash
- lx = /\*\/|\/\*/,
-// identifier
- ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/,
-// javascript url
- jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i,
-// url badness
- ux = /&|\+|\u00AD|\.\.|\/\*|%[^;]|base64|url|expression|data|mailto/i,
-// style
- sx = /^\s*([{:#%.=,>+\[\]@()"';]|\*=?|\$=|\|=|\^=|~=|[a-zA-Z_][a-zA-Z0-9_\-]*|[0-9]+|<\/|\/\*)/,
- ssx = /^\s*(\.?\d+(?:\.\d+)?|[@#!"'};:\-%.=,+\[\]()*_]|[a-zA-Z][a-zA-Z0-9._\-]*|\/\*?|<\/)/,
-// attributes characters
- //qx = /[^a-zA-Z0-9+\-_\/ ]/,
- qx = /[^a-zA-Z0-9+\-_\/ .#]/, // We want dots in names, period; and hashes for templating
-// query characters for ids
- //dx = /[\[\]\/\\"'*<>.&:(){}+=#]/,
- // allow . and /
- dx = /[\[\]\\"'*<>&:(){}+=#]/,
-
- rx = {
- outer: hx,
- html: hx,
- style: sx,
- styleproperty: ssx
- };
-
- function F() {}
-
- if (typeof Object.create !== 'function') {
- Object.create = function (o) {
- F.prototype = o;
- return new F();
- };
- }
-
-
- function is_own(object, name) {
- return Object.prototype.hasOwnProperty.call(object, name);
- }
-
-
- function combine(t, o) {
- var n;
- for (n in o) {
- if (is_own(o, n)) {
- t[n] = o[n];
- }
- }
- }
-
- String.prototype.entityify = function () {
- return this.
- replace(/&/g, '&').
- replace(/</g, '<').
- replace(/>/g, '>');
- };
-
- String.prototype.isAlpha = function () {
- return (this >= 'a' && this <= 'z\uffff') ||
- (this >= 'A' && this <= 'Z\uffff');
- };
-
-
- String.prototype.isDigit = function () {
- return (this >= '0' && this <= '9');
- };
-
-
- String.prototype.supplant = function (o) {
- return this.replace(/\{([^{}]*)\}/g, function (a, b) {
- var r = o[b];
- return typeof r === 'string' || typeof r === 'number' ? r : a;
- });
- };
-
- String.prototype.name = function () {
-
-// If the string looks like an identifier, then we can return it as is.
-// If the string contains no control characters, no quote characters, and no
-// backslash characters, then we can simply slap some quotes around it.
-// Otherwise we must also replace the offending characters with safe
-// sequences.
-
- if (ix.test(this)) {
- return this;
- }
- if (nx.test(this)) {
- return '"' + this.replace(nxg, function (a) {
- var c = escapes[a];
- if (c) {
- return c;
- }
- return '\\u' + ('0000' + a.charCodeAt().toString(16)).slice(-4);
- }) + '"';
- }
- return '"' + this + '"';
- };
-
-
- function assume() {
- if (!option.safe) {
- if (option.rhino) {
- combine(predefined, rhino);
- }
- if (option.devel) {
- combine(predefined, devel);
- }
- if (option.browser) {
- combine(predefined, browser);
- }
- if (option.windows) {
- combine(predefined, windows);
- }
- if (option.widget) {
- combine(predefined, widget);
- }
- }
- }
-
-
-// Produce an error warning.
-
- function quit(m, l, ch) {
- throw {
- name: 'JSLintError',
- line: l,
- character: ch,
- message: m + " (" + Math.floor((l / lines.length) * 100) +
- "% scanned)."
- };
- }
-
- function warning(m, t, a, b, c, d) {
- var ch, l, w;
- t = t || nexttoken;
- if (t.id === '(end)') { // `~
- t = token;
- }
- l = t.line || 0;
- ch = t.from || 0;
- w = {
- id: '(error)',
- raw: m,
- evidence: lines[l - 1] || '',
- line: l,
- character: ch,
- a: a,
- b: b,
- c: c,
- d: d
- };
- w.reason = m.supplant(w);
- JSLINT.errors.push(w);
- if (option.passfail) {
- quit('Stopping. ', l, ch);
- }
- warnings += 1;
- if (warnings >= option.maxerr) {
- quit("Too many errors.", l, ch);
- }
- return w;
- }
-
- function warningAt(m, l, ch, a, b, c, d) {
- return warning(m, {
- line: l,
- from: ch
- }, a, b, c, d);
- }
-
- function error(m, t, a, b, c, d) {
- var w = warning(m, t, a, b, c, d);
- quit("Stopping, unable to continue.", w.line, w.character);
- }
-
- function errorAt(m, l, ch, a, b, c, d) {
- return error(m, {
- line: l,
- from: ch
- }, a, b, c, d);
- }
-
-
-
-// lexical analysis
-
- var lex = (function lex() {
- var character, from, line, s;
-
-// Private lex methods
-
- function nextLine() {
- var at;
- if (line >= lines.length) {
- return false;
- }
- character = 1;
- s = lines[line];
- line += 1;
- at = s.search(/ \t/);
- if (at >= 0) {
- warningAt("Mixed spaces and tabs.", line, at + 1);
- }
- s = s.replace(/\t/g, tab);
- at = s.search(cx);
- if (at >= 0) {
- warningAt("Unsafe character.", line, at);
- }
- if (option.maxlen && option.maxlen < s.length) {
- warningAt("Line too long.", line, s.length);
- }
- return true;
- }
-
-// Produce a token object. The token inherits from a syntax symbol.
-
- function it(type, value) {
- var i, t;
- if (type === '(color)') {
- t = {type: type};
- } else if (type === '(punctuator)' ||
- (type === '(identifier)' && is_own(syntax, value))) {
- t = syntax[value] || syntax['(error)'];
- } else {
- t = syntax[type];
- }
- t = Object.create(t);
- if (type === '(string)' || type === '(range)') {
- if (jx.test(value)) {
- warningAt("Script URL.", line, from);
- }
- }
- if (type === '(identifier)') {
- t.identifier = true;
- if (value === '__iterator__' || value === '__proto__') {
- errorAt("Reserved name '{a}'.",
- line, from, value);
- } else if (option.nomen &&
- (value.charAt(0) === '_' ||
- value.charAt(value.length - 1) === '_')) {
- warningAt("Unexpected {a} in '{b}'.", line, from,
- "dangling '_'", value);
- }
- }
- t.value = value;
- t.line = line;
- t.character = character;
- t.from = from;
- i = t.id;
- if (i !== '(endline)') {
- prereg = i &&
- (('(,=:[!&|?{};'.indexOf(i.charAt(i.length - 1)) >= 0) ||
- i === 'return');
- }
- return t;
- }
-
-// Public lex methods
-
- return {
- init: function (source) {
- if (typeof source === 'string') {
- lines = source.
- replace(/\r\n/g, '\n').
- replace(/\r/g, '\n').
- split('\n');
- } else {
- lines = source;
- }
- line = 0;
- nextLine();
- from = 1;
- },
-
- range: function (begin, end) {
- var c, value = '';
- from = character;
- if (s.charAt(0) !== begin) {
- errorAt("Expected '{a}' and instead saw '{b}'.",
- line, character, begin, s.charAt(0));
- }
- for (;;) {
- s = s.slice(1);
- character += 1;
- c = s.charAt(0);
- switch (c) {
- case '':
- errorAt("Missing '{a}'.", line, character, c);
- break;
- case end:
- s = s.slice(1);
- character += 1;
- return it('(range)', value);
- case xquote:
- case '\\':
- warningAt("Unexpected '{a}'.", line, character, c);
- }
- value += c;
- }
-
- },
-
-// skip all content up to marker
-
- skip_till: function (end) {
- for (;;) {
- i = s.indexOf(end);
- if (i >= 0) {
- break;
- }
- if (!nextLine()) {
- errorAt("Unclosed {a} block.", line, character, end);
- }
- }
- character += i;
- s = s.substr(i);
- },
-
-// token -- this is called by advance to get the next token.
-
- token: function () {
- var b, c, captures, d, depth, high, i, l, low, q, t;
-
- function match(x) {
- var r = x.exec(s), r1;
- if (r) {
- l = r[0].length;
- r1 = r[1];
- c = r1.charAt(0);
- s = s.substr(l);
- from = character + l - r1.length;
- character += l;
- return r1;
- }
- }
-
- function string(x) {
- var c, j, r = '';
-
- if (jsonmode && x !== '"') {
- warningAt("Strings must use doublequote.",
- line, character);
- }
-
- if (xquote === x || (xmode === 'scriptstring' && !xquote)) {
- return it('(punctuator)', x);
- }
-
- function esc(n) {
- var i = parseInt(s.substr(j + 1, n), 16);
- j += n;
- if (i >= 32 && i <= 126 &&
- i !== 34 && i !== 92 && i !== 39) {
- warningAt("Unnecessary escapement.", line, character);
- }
- character += n;
- c = String.fromCharCode(i);
- }
- j = 0;
- for (;;) {
- while (j >= s.length) {
- j = 0;
- if (xmode !== 'html' || !nextLine()) {
- errorAt("Unclosed string.", line, from);
- }
- }
- c = s.charAt(j);
- if (c === x) {
- character += 1;
- s = s.substr(j + 1);
- return it('(string)', r, x);
- }
- if (c < ' ') {
- if (c === '\n' || c === '\r') {
- break;
- }
- warningAt("Control character in string: {a}.",
- line, character + j, s.slice(0, j));
- } else if (c === xquote) {
- warningAt("Bad HTML string", line, character + j);
- } else if (c === '<') {
- if (option.safe && xmode === 'html') {
- warningAt("ADsafe string violation.",
- line, character + j);
- } else if (s.charAt(j + 1) === '/' && (xmode || option.safe) && s.substr(j + 2, 6) === 'script') {
- warningAt("Expected '<\\/' and instead saw '</'.", line, character);
- } else if (s.charAt(j + 1) === '!' && (xmode || option.safe)) {
- warningAt("Unexpected '<!' in a string.", line, character);
- }
- } else if (c === '\\') {
- if (xmode === 'html') {
- if (option.safe) {
- warningAt("ADsafe string violation.",
- line, character + j);
- }
- } else if (xmode === 'styleproperty') {
- j += 1;
- character += 1;
- c = s.charAt(j);
- if (c !== x) {
- warningAt("Escapement in style string.",
- line, character + j);
- }
- } else {
- j += 1;
- character += 1;
- c = s.charAt(j);
- switch (c) {
- case xquote:
- warningAt("Bad HTML string", line,
- character + j);
- break;
- case '\\':
- case '\'':
- case '"':
- case '/':
- break;
- case 'b':
- c = '\b';
- break;
- case 'f':
- c = '\f';
- break;
- case 'n':
- c = '\n';
- break;
- case 'r':
- c = '\r';
- break;
- case 't':
- c = '\t';
- break;
- case 'u':
- esc(4);
- break;
- case 'v':
- c = '\v';
- break;
- case 'x':
- if (jsonmode) {
- warningAt("Avoid \\x-.", line, character);
- }
- esc(2);
- break;
- default:
- warningAt("Bad escapement.", line, character);
- }
- }
- }
- r += c;
- character += 1;
- j += 1;
- }
- }
-
- for (;;) {
- if (!s) {
- return it(nextLine() ? '(endline)' : '(end)', '');
- }
- while (xmode === 'outer') {
- i = s.search(ox);
- if (i === 0) {
- break;
- } else if (i > 0) {
- character += 1;
- s = s.slice(i);
- break;
- } else {
- if (!nextLine()) {
- return it('(end)', '');
- }
- }
- }
-// t = match(rx[xmode] || tx);
-// if (!t) {
-// if (xmode === 'html') {
-// return it('(error)', s.charAt(0));
-// } else {
-// t = '';
-// c = '';
-// while (s && s < '!') {
-// s = s.substr(1);
-// }
-// if (s) {
-// errorAt("Unexpected '{a}'.",
-// line, character, s.substr(0, 1));
-// }
-// }
- t = match(rx[xmode] || tx);
- if (!t) {
- t = '';
- c = '';
- while (s && s < '!') {
- s = s.substr(1);
- }
- if (s) {
- if (xmode === 'html') {
- return it('(error)', s.charAt(0));
- } else {
- errorAt("Unexpected '{a}'.",
- line, character, s.substr(0, 1));
- }
- }
- } else {
-
- // identifier
-
- if (c.isAlpha() || c === '_' || c === '$') {
- return it('(identifier)', t);
- }
-
- // number
-
- if (c.isDigit() || (c === '.' && t.substr(1, 1).isDigit())) {
- if (c === '.') {
- t = '0' + t;
- c = '0';
- }
-
- if (xmode !== 'style' && !isFinite(Number(t))) {
- warningAt("Bad number '{a}'.",
- line, character, t);
- }
- if (xmode !== 'style' &&
- xmode !== 'styleproperty' &&
- s.substr(0, 1).isAlpha()) {
- warningAt("Missing space after '{a}'.",
- line, character, t);
- }
- if (c === '0') {
- d = t.substr(1, 1);
- if (d.isDigit()) {
- if (token.id !== '.' && xmode !== 'styleproperty') {
- warningAt("Don't use extra leading zeros '{a}'.",
- line, character, t);
- }
- } else if (jsonmode && (d === 'x' || d === 'X')) {
- warningAt("Avoid 0x-. '{a}'.",
- line, character, t);
- }
- }
- if (t.substr(t.length - 1) === '.') {
- warningAt(
- "A trailing decimal point can be confused with a dot '{a}'.",
- line, character, t);
- }
- return it('(number)', t);
- }
- switch (t) {
-
- // string
-
- case '"':
- case "'":
- return string(t);
-
- // // comment
-
- case '//':
- if (src || (xmode && xmode !== 'script')) {
- warningAt("Unexpected comment.", line, character);
- } else if (xmode === 'script' && /<\s*\//i.test(s)) {
- warningAt("Unexpected <\/ in comment.", line, character);
- } else if ((option.safe || xmode === 'script') && ax.test(s)) {
- warningAt("Dangerous comment.", line, character);
- }
- s = '';
- token.comment = true;
- break;
-
- // /* comment
-
- case '/*':
- if (src || (xmode && xmode !== 'script' && xmode !== 'style' && xmode !== 'styleproperty')) {
- warningAt("Unexpected comment.", line, character);
- }
- if (option.safe && ax.test(s)) {
- warningAt("ADsafe comment violation.", line, character);
- }
- for (;;) {
- i = s.search(lx);
- if (i >= 0) {
- break;
- }
- if (!nextLine()) {
- errorAt("Unclosed comment.", line, character);
- } else {
- if (option.safe && ax.test(s)) {
- warningAt("ADsafe comment violation.",
- line, character);
- }
- }
- }
- character += i + 2;
- if (s.substr(i, 1) === '/') {
- errorAt("Nested comment.", line, character);
- }
- s = s.substr(i + 2);
- token.comment = true;
- break;
-
- // /*members /*jslint /*global
-
- case '/*members':
- case '/*member':
- case '/*jslint':
- case '/*global':
- case '*/':
- return {
- value: t,
- type: 'special',
- line: line,
- character: character,
- from: from
- };
-
- case '':
- break;
- // /
- case '/':
- if (token.id === '/=') {
- errorAt(
-"A regular expression literal can be confused with '/='.", line, from);
- }
- if (prereg) {
- depth = 0;
- captures = 0;
- l = 0;
- for (;;) {
- b = true;
- c = s.charAt(l);
- l += 1;
- switch (c) {
- case '':
- errorAt("Unclosed regular expression.",
- line, from);
- return;
- case '/':
- if (depth > 0) {
- warningAt("Unescaped '{a}'.",
- line, from + l, '/');
- }
- c = s.substr(0, l - 1);
- q = {
- g: true,
- i: true,
- m: true
- };
- while (q[s.charAt(l)] === true) {
- q[s.charAt(l)] = false;
- l += 1;
- }
- character += l;
- s = s.substr(l);
- q = s.charAt(0);
- if (q === '/' || q === '*') {
- errorAt("Confusing regular expression.",
- line, from);
- }
- return it('(regexp)', c);
- case '\\':
- c = s.charAt(l);
- if (c < ' ') {
- warningAt(
-"Unexpected control character in regular expression.", line, from + l);
- } else if (c === '<') {
- warningAt(
-"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
- }
- l += 1;
- break;
- case '(':
- depth += 1;
- b = false;
- if (s.charAt(l) === '?') {
- l += 1;
- switch (s.charAt(l)) {
- case ':':
- case '=':
- case '!':
- l += 1;
- break;
- default:
- warningAt(
-"Expected '{a}' and instead saw '{b}'.", line, from + l, ':', s.charAt(l));
- }
- } else {
- captures += 1;
- }
- break;
- case '|':
- b = false;
- break;
- case ')':
- if (depth === 0) {
- warningAt("Unescaped '{a}'.",
- line, from + l, ')');
- } else {
- depth -= 1;
- }
- break;
- case ' ':
- q = 1;
- while (s.charAt(l) === ' ') {
- l += 1;
- q += 1;
- }
- if (q > 1) {
- warningAt(
-"Spaces are hard to count. Use {{a}}.", line, from + l, q);
- }
- break;
- case '[':
- c = s.charAt(l);
- if (c === '^') {
- l += 1;
- if (option.regexp) {
- warningAt("Insecure '{a}'.",
- line, from + l, c);
- }
- }
- q = false;
- if (c === ']') {
- warningAt("Empty class.", line,
- from + l - 1);
- q = true;
- }
-klass: do {
- c = s.charAt(l);
- l += 1;
- switch (c) {
- case '[':
- case '^':
- warningAt("Unescaped '{a}'.",
- line, from + l, c);
- q = true;
- break;
- case '-':
- if (q) {
- q = false;
- } else {
- warningAt("Unescaped '{a}'.",
- line, from + l, '-');
- q = true;
- }
- break;
- case ']':
- if (!q) {
- warningAt("Unescaped '{a}'.",
- line, from + l - 1, '-');
- }
- break klass;
- case '\\':
- c = s.charAt(l);
- if (c < ' ') {
- warningAt(
-"Unexpected control character in regular expression.", line, from + l);
- } else if (c === '<') {
- warningAt(
-"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
- }
- l += 1;
- q = true;
- break;
- case '/':
- warningAt("Unescaped '{a}'.",
- line, from + l - 1, '/');
- q = true;
- break;
- case '<':
- if (xmode === 'script') {
- c = s.charAt(l);
- if (c === '!' || c === '/') {
- warningAt(
-"HTML confusion in regular expression '<{a}'.", line, from + l, c);
- }
- }
- q = true;
- break;
- default:
- q = true;
- }
- } while (c);
- break;
- case '.':
- if (option.regexp) {
- warningAt("Insecure '{a}'.", line,
- from + l, c);
- }
- break;
- case ']':
- case '?':
- case '{':
- case '}':
- case '+':
- case '*':
- warningAt("Unescaped '{a}'.", line,
- from + l, c);
- break;
- case '<':
- if (xmode === 'script') {
- c = s.charAt(l);
- if (c === '!' || c === '/') {
- warningAt(
-"HTML confusion in regular expression '<{a}'.", line, from + l, c);
- }
- }
- }
- if (b) {
- switch (s.charAt(l)) {
- case '?':
- case '+':
- case '*':
- l += 1;
- if (s.charAt(l) === '?') {
- l += 1;
- }
- break;
- case '{':
- l += 1;
- c = s.charAt(l);
- if (c < '0' || c > '9') {
- warningAt(
-"Expected a number and instead saw '{a}'.", line, from + l, c);
- }
- l += 1;
- low = +c;
- for (;;) {
- c = s.charAt(l);
- if (c < '0' || c > '9') {
- break;
- }
- l += 1;
- low = +c + (low * 10);
- }
- high = low;
- if (c === ',') {
- l += 1;
- high = Infinity;
- c = s.charAt(l);
- if (c >= '0' && c <= '9') {
- l += 1;
- high = +c;
- for (;;) {
- c = s.charAt(l);
- if (c < '0' || c > '9') {
- break;
- }
- l += 1;
- high = +c + (high * 10);
- }
- }
- }
- if (s.charAt(l) !== '}') {
- warningAt(
-"Expected '{a}' and instead saw '{b}'.", line, from + l, '}', c);
- } else {
- l += 1;
- }
- if (s.charAt(l) === '?') {
- l += 1;
- }
- if (low > high) {
- warningAt(
-"'{a}' should not be greater than '{b}'.", line, from + l, low, high);
- }
- }
- }
- }
- c = s.substr(0, l - 1);
- character += l;
- s = s.substr(l);
- return it('(regexp)', c);
- }
- return it('(punctuator)', t);
-
- // punctuator
-
- case '<!--':
- l = line;
- c = character;
- for (;;) {
- i = s.indexOf('--');
- if (i >= 0) {
- break;
- }
- i = s.indexOf('<!-');
- if (i >= 0) {
- errorAt("Nested HTML comment.",
- line, character + i);
- }
- if (!nextLine()) {
- errorAt("Unclosed HTML comment.", l, c);
- }
- }
- l = s.indexOf('<!-');
- if (l >= 0 && l < i) {
- errorAt("Nested HTML comment.",
- line, character + l);
- }
- character += i;
- if (s[i + 2] !== '>') {
- errorAt("Expected -->.", line, character);
- }
- character += 3;
- s = s.slice(i + 3);
- break;
- case '#':
- if (xmode === 'html' || xmode === 'styleproperty') {
- for (;;) {
- c = s.charAt(0);
- if ((c < '0' || c > '9') &&
- (c < 'a' || c > 'f') &&
- (c < 'A' || c > 'F')) {
- break;
- }
- character += 1;
- s = s.substr(1);
- t += c;
- }
- if (t.length !== 4 && t.length !== 7) {
- warningAt("Bad hex color '{a}'.", line,
- from + l, t);
- }
- return it('(color)', t);
- }
- return it('(punctuator)', t);
- default:
- if (xmode === 'outer' && c === '&') {
- character += 1;
- s = s.substr(1);
- for (;;) {
- c = s.charAt(0);
- character += 1;
- s = s.substr(1);
- if (c === ';') {
- break;
- }
- if (!((c >= '0' && c <= '9') ||
- (c >= 'a' && c <= 'z') ||
- c === '#')) {
- errorAt("Bad entity", line, from + l,
- character);
- }
- }
- break;
- }
- return it('(punctuator)', t);
- }
- }
- }
- }
- };
- }());
-
-
- function addlabel(t, type) {
-
- if (option.safe && funct['(global)'] &&
- typeof predefined[t] !== 'boolean') {
- warning('ADsafe global: ' + t + '.', token);
- } else if (t === 'hasOwnProperty') {
- warning("'hasOwnProperty' is a really bad name.");
- }
-
-// Define t in the current function in the current scope.
-
- if (is_own(funct, t) && !funct['(global)']) {
- warning(funct[t] === true ?
- "'{a}' was used before it was defined." :
- "'{a}' is already defined.",
- nexttoken, t);
- }
- funct[t] = type;
- if (funct['(global)']) {
- global[t] = funct;
- if (is_own(implied, t)) {
- warning("'{a}' was used before it was defined.", nexttoken, t);
- delete implied[t];
- }
- } else {
- scope[t] = funct;
- }
- }
-
-
- function doOption() {
- var b, obj, filter, o = nexttoken.value, t, v;
- switch (o) {
- case '*/':
- error("Unbegun comment.");
- break;
- case '/*members':
- case '/*member':
- o = '/*members';
- if (!membersOnly) {
- membersOnly = {};
- }
- obj = membersOnly;
- break;
- case '/*jslint':
- if (option.safe) {
- warning("ADsafe restriction.");
- }
- obj = option;
- filter = boolOptions;
- break;
- case '/*global':
- if (option.safe) {
- warning("ADsafe restriction.");
- }
- obj = predefined;
- break;
- default:
- }
- t = lex.token();
-loop: for (;;) {
- for (;;) {
- if (t.type === 'special' && t.value === '*/') {
- break loop;
- }
- if (t.id !== '(endline)' && t.id !== ',') {
- break;
- }
- t = lex.token();
- }
- if (t.type !== '(string)' && t.type !== '(identifier)' &&
- o !== '/*members') {
- error("Bad option.", t);
- }
- v = lex.token();
- if (v.id === ':') {
- v = lex.token();
- if (obj === membersOnly) {
- error("Expected '{a}' and instead saw '{b}'.",
- t, '*/', ':');
- }
- if (t.value === 'indent' && o === '/*jslint') {
- b = +v.value;
- if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.white = true;
- obj.indent = b;
- } else if (t.value === 'maxerr' && o === '/*jslint') {
- b = +v.value;
- if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.maxerr = b;
- } else if (t.value === 'maxlen' && o === '/*jslint') {
- b = +v.value;
- if (typeof b !== 'number' || !isFinite(b) || b <= 0 ||
- Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.",
- v, v.value);
- }
- obj.maxlen = b;
- } else if (v.value === 'true') {
- obj[t.value] = true;
- } else if (v.value === 'false') {
- obj[t.value] = false;
- } else {
- error("Bad option value.", v);
- }
- t = lex.token();
- } else {
- if (o === '/*jslint') {
- error("Missing option value.", t);
- }
- obj[t.value] = false;
- t = v;
- }
- }
- if (filter) {
- assume();
- }
- }
-
-
-// We need a peek function. If it has an argument, it peeks that much farther
-// ahead. It is used to distinguish
-// for ( var i in ...
-// from
-// for ( var i = ...
-
- function peek(p) {
- var i = p || 0, j = 0, t;
-
- while (j <= i) {
- t = lookahead[j];
- if (!t) {
- t = lookahead[j] = lex.token();
- }
- j += 1;
- }
- return t;
- }
-
-
-
-// Produce the next token. It looks for programming errors.
-
- function advance(id, t) {
- switch (token.id) {
- case '(number)':
- if (nexttoken.id === '.') {
- warning(
-"A dot following a number can be confused with a decimal point.", token);
- }
- break;
- case '-':
- if (nexttoken.id === '-' || nexttoken.id === '--') {
- warning("Confusing minusses.");
- }
- break;
- case '+':
- if (nexttoken.id === '+' || nexttoken.id === '++') {
- warning("Confusing plusses.");
- }
- break;
- }
- if (token.type === '(string)' || token.identifier) {
- anonname = token.value;
- }
-
- if (id && nexttoken.id !== id) {
- if (t) {
- if (nexttoken.id === '(end)') {
- warning("Unmatched '{a}'.", t, t.id);
- } else {
- warning(
-"Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
- nexttoken, id, t.id, t.line, nexttoken.value);
- }
- } else if (nexttoken.type !== '(identifier)' ||
- nexttoken.value !== id) {
- warning("Expected '{a}' and instead saw '{b}'.",
- nexttoken, id, nexttoken.value);
- }
- }
- prevtoken = token;
- token = nexttoken;
- for (;;) {
- nexttoken = lookahead.shift() || lex.token();
- if (nexttoken.id === '(end)' || nexttoken.id === '(error)') {
- return;
- }
- if (nexttoken.type === 'special') {
- doOption();
- } else {
- if (nexttoken.id !== '(endline)') {
- break;
- }
- }
- }
- }
-
-
-// This is the heart of JSLINT, the Pratt parser. In addition to parsing, it
-// is looking for ad hoc lint patterns. We add to Pratt's model .fud, which is
-// like nud except that it is only used on the first token of a statement.
-// Having .fud makes it much easier to define JavaScript. I retained Pratt's
-// nomenclature.
-
-// .nud Null denotation
-// .fud First null denotation
-// .led Left denotation
-// lbp Left binding power
-// rbp Right binding power
-
-// They are key to the parsing method called Top Down Operator Precedence.
-
- function parse(rbp, initial) {
- var left;
- if (nexttoken.id === '(end)') {
- error("Unexpected early end of program.", token);
- }
- advance();
- if (option.safe && typeof predefined[token.value] === 'boolean' &&
- (nexttoken.id !== '(' && nexttoken.id !== '.')) {
- warning('ADsafe violation.', token);
- }
- if (initial) {
- anonname = 'anonymous';
- funct['(verb)'] = token.value;
- }
- if (initial === true && token.fud) {
- left = token.fud();
- } else {
- if (token.nud) {
- left = token.nud();
- } else {
- if (nexttoken.type === '(number)' && token.id === '.') {
- warning(
-"A leading decimal point can be confused with a dot: '.{a}'.",
- token, nexttoken.value);
- advance();
- return token;
- } else {
- error("Expected an identifier and instead saw '{a}'.",
- token, token.id);
- }
- }
- while (rbp < nexttoken.lbp) {
- advance();
- if (token.led) {
- left = token.led(left);
- } else {
- error("Expected an operator and instead saw '{a}'.",
- token, token.id);
- }
- }
- }
- return left;
- }
-
-
-// Functions for conformance of style.
-
- function adjacent(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (option.white || xmode === 'styleproperty' || xmode === 'style') {
- if (left.character !== right.from && left.line === right.line) {
- warning("Unexpected space after '{a}'.", right, left.value);
- }
- }
- }
-
- function nospace(left, right) {
- left = left || token;
- right = right || nexttoken;
- if (option.white && !left.comment) {
- if (left.line === right.line) {
- adjacent(left, right);
- }
- }
- }
-
-
- function nonadjacent(left, right) {
- if (option.white) {
- left = left || token;
- right = right || nexttoken;
- if (left.line === right.line && left.character === right.from) {
- warning("Missing space after '{a}'.",
-
<TRUNCATED>
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa222434/AlluraTesting/jslint/js.jar
----------------------------------------------------------------------
diff --git a/AlluraTesting/jslint/js.jar b/AlluraTesting/jslint/js.jar
deleted file mode 100644
index 2369f99..0000000
Binary files a/AlluraTesting/jslint/js.jar and /dev/null differ