Commit cfaa5579 authored by apavlov@chromium.org's avatar apavlov@chromium.org

DevTools: [ClosureCompiler] Fix injected script errors on a newer compiler

R=aandrey@chromium.org, yurys@chromium.org, aandrey

Review URL: https://codereview.chromium.org/332173004

git-svn-id: svn://svn.chromium.org/blink/trunk@176317 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 65535a33
...@@ -28,6 +28,12 @@ ...@@ -28,6 +28,12 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/**
* FIXME: ES5 strict mode check is suppressed due to multiple uses of arguments.callee.
* @fileoverview
* @suppress {es5Strict}
*/
/** /**
* @param {InjectedScriptHostClass} InjectedScriptHost * @param {InjectedScriptHostClass} InjectedScriptHost
* @param {Window} inspectedWindow * @param {Window} inspectedWindow
...@@ -3955,16 +3961,17 @@ WebGLCallFormatter.prototype = { ...@@ -3955,16 +3961,17 @@ WebGLCallFormatter.prototype = {
// Sort to get rid of ambiguity. // Sort to get rid of ambiguity.
for (var value in this._enumValueToNames) { for (var value in this._enumValueToNames) {
var names = this._enumValueToNames[value]; var numericValue = Number(value);
var names = this._enumValueToNames[numericValue];
if (names.length > 1) { if (names.length > 1) {
// Choose one enum name if possible. For example: // Choose one enum name if possible. For example:
// [BLEND_EQUATION, BLEND_EQUATION_RGB] => BLEND_EQUATION // [BLEND_EQUATION, BLEND_EQUATION_RGB] => BLEND_EQUATION
// [COLOR_ATTACHMENT0, COLOR_ATTACHMENT0_WEBGL] => COLOR_ATTACHMENT0 // [COLOR_ATTACHMENT0, COLOR_ATTACHMENT0_WEBGL] => COLOR_ATTACHMENT0
var common = commonSubstring(names); var common = commonSubstring(names);
if (common) if (common)
this._enumValueToNames[value] = [common]; this._enumValueToNames[numericValue] = [common];
else else
this._enumValueToNames[value] = names.sort(); this._enumValueToNames[numericValue] = names.sort();
} }
} }
}, },
......
...@@ -92,7 +92,7 @@ type_checked_jsdoc_tags_or = "|".join(type_checked_jsdoc_tags_list) ...@@ -92,7 +92,7 @@ type_checked_jsdoc_tags_or = "|".join(type_checked_jsdoc_tags_list)
# Basic regex for invalid JsDoc types: an object type name ([A-Z][A-Za-z0-9.]+[A-Za-z0-9]) not preceded by '!', '?', ':' (this, new), or '.' (object property). # Basic regex for invalid JsDoc types: an object type name ([A-Z][A-Za-z0-9.]+[A-Za-z0-9]) not preceded by '!', '?', ':' (this, new), or '.' (object property).
invalid_type_regex = re.compile(r"@(?:" + type_checked_jsdoc_tags_or + r")\s*\{.*(?<![!?:.A-Za-z0-9])([A-Z][A-Za-z0-9.]+[A-Za-z0-9])[^/]*\}") invalid_type_regex = re.compile(r"@(?:" + type_checked_jsdoc_tags_or + r")\s*\{.*(?<![!?:.A-Za-z0-9])([A-Z][A-Za-z0-9.]+[A-Za-z0-9])[^/]*\}")
invalid_type_designator_regex = re.compile(r"@(?:" + type_checked_jsdoc_tags_or + r")\s*.*([?!])=?\}") invalid_type_designator_regex = re.compile(r"@(?:" + type_checked_jsdoc_tags_or + r")\s*.*(?<![{: ])([?!])=?\}")
importscript_regex = re.compile(r"importScript\(\s*[\"']") importscript_regex = re.compile(r"importScript\(\s*[\"']")
error_warning_regex = re.compile(r"(?:WARNING|ERROR)") error_warning_regex = re.compile(r"(?:WARNING|ERROR)")
...@@ -189,9 +189,6 @@ jsdocValidatorProc = verify_jsdoc_extra() ...@@ -189,9 +189,6 @@ jsdocValidatorProc = verify_jsdoc_extra()
modules_dir = tempfile.mkdtemp() modules_dir = tempfile.mkdtemp()
common_closure_args = " --summary_detail_level 3 --compilation_level SIMPLE_OPTIMIZATIONS --warning_level VERBOSE --language_in ECMASCRIPT5 --accept_const_keyword --module_output_path_prefix %s/" % modules_dir common_closure_args = " --summary_detail_level 3 --compilation_level SIMPLE_OPTIMIZATIONS --warning_level VERBOSE --language_in ECMASCRIPT5 --accept_const_keyword --module_output_path_prefix %s/" % modules_dir
compiler_args_file = tempfile.NamedTemporaryFile(mode='wt', delete=False)
closure_runner_command = "%s -jar %s --compiler-args-file %s" % (java_exec, closure_runner_jar, compiler_args_file.name)
spawned_compiler_command = "%s -jar %s %s \\\n" % (java_exec, closure_compiler_jar, common_closure_args) spawned_compiler_command = "%s -jar %s %s \\\n" % (java_exec, closure_compiler_jar, common_closure_args)
modules_by_name = {} modules_by_name = {}
...@@ -267,6 +264,9 @@ def dump_module(name, recursively, processed_modules): ...@@ -267,6 +264,9 @@ def dump_module(name, recursively, processed_modules):
print "Compiling frontend..." print "Compiling frontend..."
compiler_args_file = tempfile.NamedTemporaryFile(mode='wt', delete=False)
closure_runner_command = "%s -jar %s --compiler-args-file %s" % (java_exec, closure_runner_jar, compiler_args_file.name)
for module in modules: for module in modules:
closure_args = common_closure_args closure_args = common_closure_args
closure_args += " --externs " + global_externs_file closure_args += " --externs " + global_externs_file
...@@ -279,9 +279,8 @@ modular_compiler_proc = subprocess.Popen(closure_runner_command, stdout=subproce ...@@ -279,9 +279,8 @@ modular_compiler_proc = subprocess.Popen(closure_runner_command, stdout=subproce
def unclosure_injected_script(sourceFileName, outFileName): def unclosure_injected_script(sourceFileName, outFileName):
sourceFile = open(sourceFileName, "r") with open(sourceFileName, "r") as sourceFile:
source = sourceFile.read() source = sourceFile.read()
sourceFile.close()
def replace_function(matchobj): def replace_function(matchobj):
return re.sub(r"@param", "param", matchobj.group(1) or "") + "\n//" + matchobj.group(2) return re.sub(r"@param", "param", matchobj.group(1) or "") + "\n//" + matchobj.group(2)
...@@ -292,9 +291,11 @@ def unclosure_injected_script(sourceFileName, outFileName): ...@@ -292,9 +291,11 @@ def unclosure_injected_script(sourceFileName, outFileName):
# Comment out its return statement # Comment out its return statement
source = re.sub(r"\n(\s*return\s+[^;]+;\s*\n\}\)\s*)$", "\n/*\\1*/", source) source = re.sub(r"\n(\s*return\s+[^;]+;\s*\n\}\)\s*)$", "\n/*\\1*/", source)
outFileName = open(outFileName, "w") # Replace the "var Object" override with a "self.Object" one
outFileName.write(source) source = re.sub(r"\nvar Object =", "\nself.Object =", source, count=1)
outFileName.close()
with open(outFileName, "w") as outFileName:
outFileName.write(source)
injectedScriptSourceTmpFile = path.join(inspector_path, "InjectedScriptSourceTmp.js") injectedScriptSourceTmpFile = path.join(inspector_path, "InjectedScriptSourceTmp.js")
injectedScriptCanvasModuleSourceTmpFile = path.join(inspector_path, "InjectedScriptCanvasModuleSourceTmp.js") injectedScriptCanvasModuleSourceTmpFile = path.join(inspector_path, "InjectedScriptCanvasModuleSourceTmp.js")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment