<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[159969] trunk/Tools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/159969">159969</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2013-12-02 14:53:15 -0800 (Mon, 02 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add JavaScript style checker and teach checker.py about .js files
https://bugs.webkit.org/show_bug.cgi?id=125049

Patch by Brian J. Burg &lt;burg@cs.washington.edu&gt; on 2013-12-02
Reviewed by Joseph Pecoraro.

Add a JavaScript file type, extension, and checker (JSChecker).
Use TextChecker for JavaScript tests, libraries, website resources,
etc. and use JSChecker for files within WebInspectorUI/UserInterface.

Amended tests for TextChecker to reflect the rule above.

* Scripts/webkitpy/style/checker.py:
(_all_categories): Add categories defined by JSChecker.
(FileType): Add file type for JS and re-number the enum.
(CheckerDispatcher._file_type): Detect .js files as JavaScript.
(CheckerDispatcher._create_checker):
Create a JSChecker or TextChecker depending on the file's path.

* Scripts/webkitpy/style/checker_unittest.py:
(CheckerDispatcherDispatchTest.assert_checker_js): Added.
(CheckerDispatcherDispatchTest.test_js_paths): Added.
(CheckerDispatcherDispatchTest.test_text_paths): Add new test paths
that end in .js but should be checked with TextChecker.
* Scripts/webkitpy/style/checkers/js.py: Added.
(JSChecker):
(JSChecker.__init__):
(JSChecker.check):
* Scripts/webkitpy/style/checkers/js_unittest.py: Added.
(JSTestCase):
(JSTestCase.assertNoError):
(JSTestCase.assertNoError.error_for_test):
(JSTestCase.assertError):
(JSTestCase.assertError.error_for_test):
(JSTestCase.test_no_error):
(JSTestCase.test_error):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptswebkitpystylecheckerpy">trunk/Tools/Scripts/webkitpy/style/checker.py</a></li>
<li><a href="#trunkToolsScriptswebkitpystylechecker_unittestpy">trunk/Tools/Scripts/webkitpy/style/checker_unittest.py</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsScriptswebkitpystylecheckersjspy">trunk/Tools/Scripts/webkitpy/style/checkers/js.py</a></li>
<li><a href="#trunkToolsScriptswebkitpystylecheckersjs_unittestpy">trunk/Tools/Scripts/webkitpy/style/checkers/js_unittest.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (159968 => 159969)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2013-12-02 22:48:54 UTC (rev 159968)
+++ trunk/Tools/ChangeLog        2013-12-02 22:53:15 UTC (rev 159969)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2013-12-02  Brian J. Burg  &lt;burg@cs.washington.edu&gt;
+
+        Add JavaScript style checker and teach checker.py about .js files
+        https://bugs.webkit.org/show_bug.cgi?id=125049
+
+        Reviewed by Joseph Pecoraro.
+
+        Add a JavaScript file type, extension, and checker (JSChecker).
+        Use TextChecker for JavaScript tests, libraries, website resources,
+        etc. and use JSChecker for files within WebInspectorUI/UserInterface.
+
+        Amended tests for TextChecker to reflect the rule above.
+
+        * Scripts/webkitpy/style/checker.py:
+        (_all_categories): Add categories defined by JSChecker.
+        (FileType): Add file type for JS and re-number the enum.
+        (CheckerDispatcher._file_type): Detect .js files as JavaScript.
+        (CheckerDispatcher._create_checker):
+        Create a JSChecker or TextChecker depending on the file's path.
+
+        * Scripts/webkitpy/style/checker_unittest.py:
+        (CheckerDispatcherDispatchTest.assert_checker_js): Added.
+        (CheckerDispatcherDispatchTest.test_js_paths): Added.
+        (CheckerDispatcherDispatchTest.test_text_paths): Add new test paths
+        that end in .js but should be checked with TextChecker.
+        * Scripts/webkitpy/style/checkers/js.py: Added.
+        (JSChecker):
+        (JSChecker.__init__):
+        (JSChecker.check):
+        * Scripts/webkitpy/style/checkers/js_unittest.py: Added.
+        (JSTestCase):
+        (JSTestCase.assertNoError):
+        (JSTestCase.assertNoError.error_for_test):
+        (JSTestCase.assertError):
+        (JSTestCase.assertError.error_for_test):
+        (JSTestCase.test_no_error):
+        (JSTestCase.test_error):
+
</ins><span class="cx"> 2013-12-02  Mark Hahnenberg  &lt;mhahnenberg@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         run-jsc-stress-tests always copies the VM
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpystylecheckerpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/style/checker.py (159968 => 159969)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/style/checker.py        2013-12-02 22:48:54 UTC (rev 159968)
+++ trunk/Tools/Scripts/webkitpy/style/checker.py        2013-12-02 22:53:15 UTC (rev 159969)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> from checkers.changelog import ChangeLogChecker
</span><span class="cx"> from checkers.cpp import CppChecker
</span><span class="cx"> from checkers.cmake import CMakeChecker
</span><ins>+from checkers.js import JSChecker
</ins><span class="cx"> from checkers.jsonchecker import JSONChecker
</span><span class="cx"> from checkers.png import PNGChecker
</span><span class="cx"> from checkers.python import PythonChecker
</span><span class="lines">@@ -263,6 +264,8 @@
</span><span class="cx">     'h',
</span><span class="cx">     ]
</span><span class="cx"> 
</span><ins>+_JS_FILE_EXTENSION = 'js'
+
</ins><span class="cx"> _JSON_FILE_EXTENSION = 'json'
</span><span class="cx"> 
</span><span class="cx"> _PYTHON_FILE_EXTENSION = 'py'
</span><span class="lines">@@ -279,7 +282,6 @@
</span><span class="cx">     'html',
</span><span class="cx">     'idl',
</span><span class="cx">     'in',
</span><del>-    'js',
</del><span class="cx">     'mm',
</span><span class="cx">     'php',
</span><span class="cx">     'pl',
</span><span class="lines">@@ -350,6 +352,7 @@
</span><span class="cx">     &quot;&quot;&quot;Return the set of all categories used by check-webkit-style.&quot;&quot;&quot;
</span><span class="cx">     # Take the union across all checkers.
</span><span class="cx">     categories = CommonCategories.union(CppChecker.categories)
</span><ins>+    categories = categories.union(JSChecker.categories)
</ins><span class="cx">     categories = categories.union(JSONChecker.categories)
</span><span class="cx">     categories = categories.union(TestExpectationsChecker.categories)
</span><span class="cx">     categories = categories.union(ChangeLogChecker.categories)
</span><span class="lines">@@ -494,16 +497,16 @@
</span><span class="cx">     # Alphabetize remaining types
</span><span class="cx">     CHANGELOG = 1
</span><span class="cx">     CPP = 2
</span><del>-    JSON = 3
-    PNG = 4
-    PYTHON = 5
-    TEXT = 6
-    WATCHLIST = 7
-    XML = 8
-    XCODEPROJ = 9
-    CMAKE = 10
</del><ins>+    JS = 3
+    JSON = 4
+    PNG = 5
+    PYTHON = 6
+    TEXT = 7
+    WATCHLIST = 8
+    XML = 9
+    XCODEPROJ = 10
+    CMAKE = 11
</ins><span class="cx"> 
</span><del>-
</del><span class="cx"> class CheckerDispatcher(object):
</span><span class="cx"> 
</span><span class="cx">     &quot;&quot;&quot;Supports determining whether and how to check style, based on path.&quot;&quot;&quot;
</span><span class="lines">@@ -566,6 +569,8 @@
</span><span class="cx">             # reading from stdin, cpp_style tests should not rely on
</span><span class="cx">             # the extension.
</span><span class="cx">             return FileType.CPP
</span><ins>+        elif file_extension == _JS_FILE_EXTENSION:
+            return FileType.JS
</ins><span class="cx">         elif file_extension == _JSON_FILE_EXTENSION:
</span><span class="cx">             return FileType.JSON
</span><span class="cx">         elif file_extension == _PYTHON_FILE_EXTENSION:
</span><span class="lines">@@ -602,6 +607,12 @@
</span><span class="cx">             file_extension = self._file_extension(file_path)
</span><span class="cx">             checker = CppChecker(file_path, file_extension,
</span><span class="cx">                                  handle_style_error, min_confidence)
</span><ins>+        elif file_type == FileType.JS:
+            # Do not attempt to check non-Inspector or 3rd-party JavaScript files as JS.
+            if os.path.join('WebInspectorUI', 'UserInterface') in file_path and (not 'External' in file_path):
+                checker = JSChecker(file_path, handle_style_error)
+            else:
+                checker = TextChecker(file_path, handle_style_error)
</ins><span class="cx">         elif file_type == FileType.JSON:
</span><span class="cx">             checker = JSONChecker(file_path, handle_style_error)
</span><span class="cx">         elif file_type == FileType.PYTHON:
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpystylechecker_unittestpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/style/checker_unittest.py (159968 => 159969)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/style/checker_unittest.py        2013-12-02 22:48:54 UTC (rev 159968)
+++ trunk/Tools/Scripts/webkitpy/style/checker_unittest.py        2013-12-02 22:53:15 UTC (rev 159969)
</span><span class="lines">@@ -52,6 +52,7 @@
</span><span class="cx"> from checker import StyleProcessorConfiguration
</span><span class="cx"> from checkers.changelog import ChangeLogChecker
</span><span class="cx"> from checkers.cpp import CppChecker
</span><ins>+from checkers.js import JSChecker
</ins><span class="cx"> from checkers.jsonchecker import JSONChecker
</span><span class="cx"> from checkers.python import PythonChecker
</span><span class="cx"> from checkers.text import TextChecker
</span><span class="lines">@@ -393,6 +394,10 @@
</span><span class="cx">         &quot;&quot;&quot;Assert that the dispatched checker is a CppChecker.&quot;&quot;&quot;
</span><span class="cx">         self.assert_checker(file_path, CppChecker)
</span><span class="cx"> 
</span><ins>+    def assert_checker_js(self, file_path):
+        &quot;&quot;&quot;Assert that the dispatched checker is a JSChecker.&quot;&quot;&quot;
+        self.assert_checker(file_path, JSChecker)
+
</ins><span class="cx">     def assert_checker_json(self, file_path):
</span><span class="cx">         &quot;&quot;&quot;Assert that the dispatched checker is a JSONChecker.&quot;&quot;&quot;
</span><span class="cx">         self.assert_checker(file_path, JSONChecker)
</span><span class="lines">@@ -459,6 +464,24 @@
</span><span class="cx">         self.assertEqual(checker.file_extension, file_extension)
</span><span class="cx">         self.assertEqual(checker.file_path, file_path)
</span><span class="cx"> 
</span><ins>+    def test_js_paths(self):
+        &quot;&quot;&quot;Test paths that should be checked as JavaScript.&quot;&quot;&quot;
+        paths = [
+           &quot;Source/WebInspectorUI/UserInterface/dummy.js&quot;,
+        ]
+
+        for path in paths:
+            self.assert_checker_js(path)
+
+        # Check checker attributes on a typical input.
+        file_base = &quot;foo&quot;
+        file_extension = &quot;css&quot;
+        file_path = file_base + &quot;.&quot; + file_extension
+        self.assert_checker_text(file_path)
+        checker = self.dispatch(file_path)
+        self.assertEqual(checker.handle_style_error,
+                          self.mock_handle_style_error)
+
</ins><span class="cx">     def test_json_paths(self):
</span><span class="cx">         &quot;&quot;&quot;Test paths that should be checked as JSON.&quot;&quot;&quot;
</span><span class="cx">         paths = [
</span><span class="lines">@@ -512,7 +535,6 @@
</span><span class="cx">            &quot;foo.html&quot;,
</span><span class="cx">            &quot;foo.idl&quot;,
</span><span class="cx">            &quot;foo.in&quot;,
</span><del>-           &quot;foo.js&quot;,
</del><span class="cx">            &quot;foo.mm&quot;,
</span><span class="cx">            &quot;foo.php&quot;,
</span><span class="cx">            &quot;foo.pl&quot;,
</span><span class="lines">@@ -525,7 +547,9 @@
</span><span class="cx">            &quot;foo.wm&quot;,
</span><span class="cx">            &quot;foo.xhtml&quot;,
</span><span class="cx">            &quot;foo.y&quot;,
</span><del>-           os.path.join(&quot;Source&quot;, &quot;WebCore&quot;, &quot;inspector&quot;, &quot;front-end&quot;, &quot;inspector.js&quot;),
</del><ins>+           &quot;Source/WebInspectorUI/External/codemirror.js&quot;,
+           &quot;LayoutTests/fast/foo.js&quot;,
+           &quot;Websites/webkit.org/foo.js&quot;,
</ins><span class="cx">            os.path.join(&quot;Tools&quot;, &quot;Scripts&quot;, &quot;check-webkit-style&quot;),
</span><span class="cx">         ]
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpystylecheckersjspy"></a>
<div class="addfile"><h4>Added: trunk/Tools/Scripts/webkitpy/style/checkers/js.py (0 => 159969)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/style/checkers/js.py                                (rev 0)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/js.py        2013-12-02 22:53:15 UTC (rev 159969)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+# Copyright (C) 2013 University of Washington. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+&quot;&quot;&quot;Supports checking WebKit style in JavaScript files&quot;&quot;&quot;
+
+from common import TabChecker
+
+
+class JSChecker(object):
+    &quot;&quot;&quot;Processes JavaScript lines for checking style.&quot;&quot;&quot;
+
+    # FIXME: plug in a JavaScript parser to find syntax errors.
+    categories = set(('js/syntax',))
+
+    def __init__(self, file_path, handle_style_error):
+        self._handle_style_error = handle_style_error
+        self._tab_checker = TabChecker(file_path, handle_style_error)
+
+    def check(self, lines):
+        self._tab_checker.check(lines)
</ins></span></pre></div>
<a id="trunkToolsScriptswebkitpystylecheckersjs_unittestpy"></a>
<div class="addfile"><h4>Added: trunk/Tools/Scripts/webkitpy/style/checkers/js_unittest.py (0 => 159969)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/style/checkers/js_unittest.py                                (rev 0)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/js_unittest.py        2013-12-02 22:53:15 UTC (rev 159969)
</span><span class="lines">@@ -0,0 +1,73 @@
</span><ins>+# Copyright (C) 2009 Google Inc. All rights reserved.
+# Copyright (C) 2013 University of Washington. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#     * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+&quot;&quot;&quot;Unit test for js.py.&quot;&quot;&quot;
+
+import unittest2 as unittest
+
+from js import JSChecker
+
+
+class JSTestCase(unittest.TestCase):
+    &quot;&quot;&quot;TestCase for js.py&quot;&quot;&quot;
+
+    def assertNoError(self, lines):
+        &quot;&quot;&quot;Asserts that the specified lines has no errors.&quot;&quot;&quot;
+        self.had_error = False
+
+        def error_for_test(line_number, category, confidence, message):
+            &quot;&quot;&quot;Records if an error occurs.&quot;&quot;&quot;
+            self.had_error = True
+
+        checker = JSChecker('', error_for_test)
+        checker.check(lines)
+        self.assertFalse(self.had_error, '%s should not have any errors.' % lines)
+
+    def assertError(self, lines, expected_line_number):
+        &quot;&quot;&quot;Asserts that the specified lines has an error.&quot;&quot;&quot;
+        self.had_error = False
+
+        def error_for_test(line_number, category, confidence, message):
+            &quot;&quot;&quot;Checks if the expected error occurs.&quot;&quot;&quot;
+            self.assertEqual(expected_line_number, line_number)
+            self.assertEqual('whitespace/tab', category)
+            self.had_error = True
+
+        checker = JSChecker('', error_for_test)
+        checker.check(lines)
+        self.assertTrue(self.had_error, '%s should have an error [whitespace/tab].' % lines)
+
+    def test_no_error(self):
+        &quot;&quot;&quot;Tests for no error cases.&quot;&quot;&quot;
+        self.assertNoError([''])
+        self.assertNoError(['abc def', 'ggg'])
+
+    def test_error(self):
+        &quot;&quot;&quot;Tests for error cases.&quot;&quot;&quot;
+        self.assertError(['\tvar foo = window;\n'], 1)
</ins></span></pre>
</div>
</div>

</body>
</html>