Webview should only allow resources loading from the extension that embedded it.
[chromium-blink-merge.git] / chrome / common / extensions / PRESUBMIT_test.py
blob7ac79b06820b397d1594a0b572319182c8c9a796
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 import os
7 import unittest
9 import PRESUBMIT
11 EXTENSIONS_PATH = os.path.join('chrome', 'common', 'extensions')
12 DOCS_PATH = os.path.join(EXTENSIONS_PATH, 'docs')
13 SERVER2_PATH = os.path.join(DOCS_PATH, 'server2')
14 PUBLIC_PATH = os.path.join(DOCS_PATH, 'templates', 'public')
15 PRIVATE_PATH = os.path.join(DOCS_PATH, 'templates', 'private')
16 INTROS_PATH = os.path.join(DOCS_PATH, 'templates', 'intros')
17 ARTICLES_PATH = os.path.join(DOCS_PATH, 'templates', 'articles')
19 class PRESUBMITTest(unittest.TestCase):
20 def testCreateIntegrationTestArgs(self):
21 input_files = [
22 os.path.join(EXTENSIONS_PATH, 'test.cc'),
23 os.path.join(EXTENSIONS_PATH, 'test2.cc'),
24 os.path.join('test', 'test.py')
26 expected_files = []
27 self.assertEqual(expected_files,
28 PRESUBMIT._CreateIntegrationTestArgs(input_files))
29 expected_files.append(os.path.join('apps', 'fileSystem.html'))
30 input_files.append(os.path.join(EXTENSIONS_PATH, 'api', 'file_system.idl'))
31 self.assertEqual(expected_files,
32 PRESUBMIT._CreateIntegrationTestArgs(input_files))
33 expected_files.append(os.path.join('extensions', 'alarms.html'))
34 expected_files.append(os.path.join('apps', 'alarms.html'))
35 input_files.append(os.path.join(EXTENSIONS_PATH, 'api', 'alarms.json'))
36 self.assertEqual(expected_files,
37 PRESUBMIT._CreateIntegrationTestArgs(input_files))
38 expected_files.append('extensions/devtools_network.html')
39 input_files.append(os.path.join(EXTENSIONS_PATH,
40 'api',
41 'devtools',
42 'network.json'))
43 self.assertEqual(expected_files,
44 PRESUBMIT._CreateIntegrationTestArgs(input_files))
45 expected_files.append(os.path.join('extensions', 'docs.html'))
46 expected_files.append(os.path.join('apps', 'docs.html'))
47 input_files.append(os.path.join(PUBLIC_PATH, 'extensions', 'docs.html'))
48 self.assertEqual(expected_files,
49 PRESUBMIT._CreateIntegrationTestArgs(input_files))
50 expected_files.append(os.path.join('extensions', 'bookmarks.html'))
51 input_files.append(os.path.join(INTROS_PATH, 'bookmarks.html'))
52 self.assertEqual(expected_files,
53 PRESUBMIT._CreateIntegrationTestArgs(input_files))
54 expected_files.append(os.path.join('extensions', 'i18n.html'))
55 expected_files.append(os.path.join('apps', 'i18n.html'))
56 input_files.append(os.path.join(INTROS_PATH, 'i18n.html'))
57 self.assertEqual(expected_files,
58 PRESUBMIT._CreateIntegrationTestArgs(input_files))
59 expected_files.append(os.path.join('apps', 'about_apps.html'))
60 input_files.append(os.path.join(ARTICLES_PATH, 'about_apps.html'))
61 self.assertEqual(expected_files,
62 PRESUBMIT._CreateIntegrationTestArgs(input_files))
63 input_files.append(os.path.join(PRIVATE_PATH, 'type.html'))
64 self.assertEqual([ '-a' ],
65 PRESUBMIT._CreateIntegrationTestArgs(input_files))
66 input_files.pop()
67 input_files.append(os.path.join(SERVER2_PATH, 'test.txt'))
68 self.assertEqual(expected_files,
69 PRESUBMIT._CreateIntegrationTestArgs(input_files))
70 input_files.append(os.path.join(SERVER2_PATH, 'handler.py'))
71 self.assertEqual([ '-a' ],
72 PRESUBMIT._CreateIntegrationTestArgs(input_files))
74 if __name__ == '__main__':
75 unittest.main()