Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: tools/telemetry/third_party/webpagereplay/script_injector_test.py

Issue 1647513002: Delete tools/telemetry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/third_party/webpagereplay/script_injector_test.py
diff --git a/tools/telemetry/third_party/webpagereplay/script_injector_test.py b/tools/telemetry/third_party/webpagereplay/script_injector_test.py
deleted file mode 100755
index cf77a4082ae2de0581b1e8dcdaa0cdcfc6563fbb..0000000000000000000000000000000000000000
--- a/tools/telemetry/third_party/webpagereplay/script_injector_test.py
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2013 Google Inc. All Rights Reserved.
-#
-# 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.
-
-import script_injector
-import unittest
-
-
-LONG_COMMENT = '<!--%s-->' % ('comment,' * 200)
-SCRIPT_TO_INJECT = 'var flag = 0;'
-EXPECTED_SCRIPT = '<script>%s</script>' % SCRIPT_TO_INJECT
-TEXT_HTML = 'text/html'
-TEXT_CSS = 'text/css'
-APPLICATION = 'application/javascript'
-
-TEMPLATE_HEAD = '<!doctype html><html><head>%s</head><body></body></html>'
-TEMPLATE_HTML = '<!doctype html><html>%s<body></body></html>'
-TEMPLATE_DOCTYPE = '<!doctype html>%s<body></body>'
-TEMPLATE_RAW = '%s<body></body>'
-TEMPLATE_COMMENT = '%s<!doctype html>%s<html>%s<head>%s</head></html>'
-
-
-class ScriptInjectorTest(unittest.TestCase):
-
- def test_unsupported_content_type(self):
- source = 'abc'
- # CSS.
- new_source, already_injected = script_injector.InjectScript(
- source, TEXT_CSS, SCRIPT_TO_INJECT)
- self.assertEqual(new_source, source)
- self.assertFalse(already_injected)
- # Javascript.
- new_source, already_injected = script_injector.InjectScript(
- source, APPLICATION, SCRIPT_TO_INJECT)
- self.assertEqual(new_source, source)
- self.assertFalse(already_injected)
-
- def test_empty_content_as_already_injected(self):
- source, already_injected = script_injector.InjectScript(
- '', TEXT_HTML, SCRIPT_TO_INJECT)
- self.assertEqual(source, '')
- self.assertTrue(already_injected)
-
- def test_already_injected(self):
- source, already_injected = script_injector.InjectScript(
- TEMPLATE_HEAD % EXPECTED_SCRIPT, TEXT_HTML, SCRIPT_TO_INJECT)
- self.assertEqual(source, TEMPLATE_HEAD % EXPECTED_SCRIPT)
- self.assertTrue(already_injected)
-
- def _assert_successful_injection(self, template):
- source, already_injected = script_injector.InjectScript(
- template % '', TEXT_HTML, SCRIPT_TO_INJECT)
- self.assertEqual(source, template % EXPECTED_SCRIPT)
- self.assertFalse(already_injected)
-
- def test_normal(self):
- self._assert_successful_injection(TEMPLATE_HEAD)
-
- def test_no_head_tag(self):
- self._assert_successful_injection(TEMPLATE_HTML)
-
- def test_no_head_and_html_tag(self):
- self._assert_successful_injection(TEMPLATE_DOCTYPE)
-
- def test_no_head_html_and_doctype_tag(self):
- self._assert_successful_injection(TEMPLATE_RAW)
-
- def _assert_successful_injection_with_comment(self, before_doctype,
- after_doctype, after_html):
- source, already_injected = script_injector.InjectScript(
- TEMPLATE_COMMENT % (before_doctype, after_doctype, after_html, ''),
- TEXT_HTML, SCRIPT_TO_INJECT)
- expected_source = TEMPLATE_COMMENT % (before_doctype, after_doctype,
- after_html, EXPECTED_SCRIPT)
- self.assertEqual(source, expected_source)
- self.assertFalse(already_injected)
-
- def test_comment_before_doctype(self):
- self._assert_successful_injection_with_comment(LONG_COMMENT, '', '')
-
- def test_comment_after_doctype(self):
- self._assert_successful_injection_with_comment('', LONG_COMMENT, '')
-
- def test_comment_after_html(self):
- self._assert_successful_injection_with_comment('', '', LONG_COMMENT)
-
- def test_all_comments(self):
- self._assert_successful_injection_with_comment(
- LONG_COMMENT, LONG_COMMENT, LONG_COMMENT)
-
-
-if __name__ == '__main__':
- unittest.main()

Powered by Google App Engine
This is Rietveld 408576698