示例#1
0
    def testNestedHtmlFile(self):
        self.assertContentsPreserved(
            """<script></script><script></script><script>
    // sometimes functions might be evil and do something like this, but we
    // should still use the original values when returning the filtered array
</script>
""", comment_scrubber.HtmlCommentExtractor())
示例#2
0
 def _MakeHtmlScrubbers(self):
     html_scrubbers = []
     html_scrubbers.append(
         comment_scrubber.CommentScrubber(
             comment_scrubber.HtmlCommentExtractor(),
             self._CommentScrubbers()))
     line_scrubbers = self._PolyglotLineOrientedScrubbers()
     for js_directory_rename in self.js_directory_renames:
         line_scrubbers.append(js_directory_rename)
     html_scrubbers.append(line_scrubber.LineScrubber(line_scrubbers))
     html_scrubbers.extend(self._PolyglotFileScrubbers())
     return html_scrubbers
示例#3
0
 def testHtmlCommentWithoutDelimiters(self):
     extractor = comment_scrubber.HtmlCommentExtractor()
     self.assertEqual('foo',
                      extractor.CommentWithoutDelimiters('<!--foo-->'))
     self.assertEqual('foo>',
                      extractor.CommentWithoutDelimiters('<!--foo>-->'))
     self.assertEqual(' foo',
                      extractor.CommentWithoutDelimiters('<!-- foo-->'))
     self.assertEqual('foo', extractor.CommentWithoutDelimiters('/*foo*/'))
     self.assertEqual('foo', extractor.CommentWithoutDelimiters('//foo'))
     self.assertRaises(base.Error, extractor.CommentWithoutDelimiters,
                       '<!-- whoops */')
示例#4
0
 def testHtmlCommentExtraction(self):
     TestCommentExtractor(self, comment_scrubber.HtmlCommentExtractor(),
                          os.path.join(TEST_DATA_DIR, 'test_file.html.txt'),
                          os.path.join(TEST_DATA_DIR, 'html_comments.txt'))
示例#5
0
 def testStripLineDirectiveHtml(self):
     scrubber = comment_scrubber.CommentScrubber(
         comment_scrubber.HtmlCommentExtractor())
     self.assertContents(
         scrubber, ['a = ""', 'c = a'],
         ['a = ""', 'b = a  <!-- MOE:strip_line -->', 'c = a'])
示例#6
0
 def testExcludeHtmlDelimiters(self):
     self.CheckReplace(comment_scrubber.HtmlCommentExtractor(), [
         ('<!-- MOE:end_strip_and_replace foo -->', 'foo'),
         ('<!--MOE:end_strip_and_replace foo-->', 'foo'),
         ('<!--MOE:end_strip_and_replace foo\nbar-->', 'foo\nbar'),
     ])