Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / third_party / tvcm / tvcm / js_utils.py
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 def EscapeJSIfNeeded(js):
6   return js.replace("</script>", "<\/script>")
7
8 def ValidateUsesStrictMode(module_name, stripped_text):
9   """Check that the first non-empty line is 'use strict';.
10
11   Args:
12     stripped_text: Javascript source code with comments stripped out.
13
14   Raises:
15     DepsException: This file doesn't use strict mode.
16   """
17   lines = stripped_text.split('\n')
18   for line in lines:
19     line = line.strip()
20     if len(line.strip()) == 0:
21       continue
22     if """'use strict';""" in line.strip():
23       break
24     raise module.DepsException('%s must use strict mode' % module_name)
25