Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (96319 => 96320)
--- trunk/Source/WebCore/CMakeLists.txt 2011-09-29 11:39:11 UTC (rev 96319)
+++ trunk/Source/WebCore/CMakeLists.txt 2011-09-29 11:49:53 UTC (rev 96320)
@@ -2204,6 +2204,13 @@
# All Web Inspector generated files are created with this one call to CodeGeneratorInspector.pm
ADD_CUSTOM_COMMAND(
+ OUTPUT ${DERIVED_SOURCES_WEBCORE_DIR}/Inspector.json.validated
+ MAIN_DEPENDENCY inspector/Inspector.json
+ DEPENDS ${WEBCORE_DIR}/inspector/validate-protocol-compatibility ${WEBCORE_DIR}/inspector/Inspector.json
+ COMMAND ${PYTHON_EXECUTABLE} ${WEBCORE_DIR}/inspector/validate-protocol-compatibility -o ${DERIVED_SOURCES_WEBCORE_DIR}/Inspector.json.validated ${WEBCORE_DIR}/inspector/Inspector.json
+ VERBATIM)
+
+ADD_CUSTOM_COMMAND(
OUTPUT ${DERIVED_SOURCES_WEBCORE_DIR}/Inspector.idl
MAIN_DEPENDENCY inspector/Inspector.json
DEPENDS ${WEBCORE_DIR}/inspector/generate-inspector-idl ${WEBCORE_DIR}/inspector/Inspector.json
Modified: trunk/Source/WebCore/ChangeLog (96319 => 96320)
--- trunk/Source/WebCore/ChangeLog 2011-09-29 11:39:11 UTC (rev 96319)
+++ trunk/Source/WebCore/ChangeLog 2011-09-29 11:49:53 UTC (rev 96320)
@@ -1,3 +1,24 @@
+2011-09-28 Pavel Feldman <[email protected]>
+
+ Web Inspector: make inspector protocol validation a part of the build process.
+ https://bugs.webkit.org/show_bug.cgi?id=68999
+
+ Since we'd like to commit to inspector protocol backwards compatibility, violating it
+ should be a build failure.
+
+ Reviewed by Yury Semikhatsky.
+
+ * CMakeLists.txt:
+ * CodeGenerators.pri:
+ * DerivedSources.make:
+ * GNUmakefile.am:
+ * WebCore.gyp/WebCore.gyp:
+ * inspector/Inspector.draft-01.json:
+ * inspector/Inspector.json:
+ * inspector/generate-inspector-idl:
+ * inspector/generate-protocol-externs:
+ * inspector/validate-protocol-compatibility:
+
2011-09-27 Pavel Feldman <[email protected]>
Web Inspector: Scripts panel without folders causes errors when creating content scripts section.
Modified: trunk/Source/WebCore/CodeGenerators.pri (96319 => 96320)
--- trunk/Source/WebCore/CodeGenerators.pri 2011-09-29 11:39:11 UTC (rev 96319)
+++ trunk/Source/WebCore/CodeGenerators.pri 2011-09-29 11:49:53 UTC (rev 96320)
@@ -668,6 +668,14 @@
addExtraCompiler(idl)
# GENERATOR 2: inspector idl compiler
+inspectorValidate.output = $${WC_GENERATED_SOURCES_DIR}/Inspector.json.validated
+inspectorValidate.input = INSPECTOR_JSON
+inspectorValidate.wkScript = $$PWD/inspector/validate-protocol-compatibility
+inspectorValidate.commands = python $$inspectorValidate.wkScript -o $${WC_GENERATED_SOURCES_DIR}/Inspector.json.validated $$PWD/inspector/Inspector.json
+inspectorValidate.depends = $$PWD/inspector/validate-protocol-compatibility
+inspectorValidate.wkAddOutputToSources = false
+addExtraCompiler(inspectorValidate)
+
inspectorJSON.output = $${WC_GENERATED_SOURCES_DIR}/Inspector.idl
inspectorJSON.input = INSPECTOR_JSON
inspectorJSON.wkScript = $$PWD/inspector/generate-inspector-idl
Modified: trunk/Source/WebCore/DerivedSources.make (96319 => 96320)
--- trunk/Source/WebCore/DerivedSources.make 2011-09-29 11:39:11 UTC (rev 96319)
+++ trunk/Source/WebCore/DerivedSources.make 2011-09-29 11:49:53 UTC (rev 96320)
@@ -888,6 +888,9 @@
# Inspector interfaces generator
+Inspector.json.validated : Inspector.json inspector/validate-protocol-compatibility
+ python $(WebCore)/inspector/validate-protocol-compatibility -o Inspector.json.validated $(WebCore)/inspector/Inspector.json
+
Inspector.idl : Inspector.json inspector/generate-inspector-idl
python $(WebCore)/inspector/generate-inspector-idl -o Inspector.idl $(WebCore)/inspector/Inspector.json
Modified: trunk/Source/WebCore/GNUmakefile.am (96319 => 96320)
--- trunk/Source/WebCore/GNUmakefile.am 2011-09-29 11:39:11 UTC (rev 96319)
+++ trunk/Source/WebCore/GNUmakefile.am 2011-09-29 11:49:53 UTC (rev 96320)
@@ -687,6 +687,9 @@
$(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --attrs $(WebCore)/xml/xmlattrs.in --outputDir "$(GENSOURCES_WEBCORE)"
# All Web Inspector generated files are created with this one call to CodeGeneratorInspector.pm
+DerivedSources/WebCore/Inspector.json.validated : $(WebCore)/inspector/Inspector.json $(WebCore)/inspector/validate-protocol-compatibility
+ $(PYTHON) $(WebCore)/inspector/validate-protocol-compatibility -o $(GENSOURCES_WEBCORE)/Inspector.json.validated $(WebCore)/inspector/Inspector.json
+
DerivedSources/WebCore/Inspector.idl : $(WebCore)/inspector/Inspector.json $(WebCore)/inspector/generate-inspector-idl
$(PYTHON) $(WebCore)/inspector/generate-inspector-idl -o $(GENSOURCES_WEBCORE)/Inspector.idl $(WebCore)/inspector/Inspector.json
Modified: trunk/Source/WebCore/WebCore.gyp/WebCore.gyp (96319 => 96320)
--- trunk/Source/WebCore/WebCore.gyp/WebCore.gyp 2011-09-29 11:39:11 UTC (rev 96319)
+++ trunk/Source/WebCore/WebCore.gyp/WebCore.gyp 2011-09-29 11:49:53 UTC (rev 96320)
@@ -338,6 +338,28 @@
'target_name': 'inspector_idl',
'type': 'none',
'actions': [
+ {
+ 'action_name': 'validateInspectorProtocol',
+ 'inputs': [
+ '../inspector/validate-protocol-compatibility',
+ '../inspector/Inspector.json',
+ ],
+ 'outputs': [
+ '<(SHARED_INTERMEDIATE_DIR)/webcore/Inspector.json.validated',
+ ],
+ 'variables': {
+ 'generator_include_dirs': [
+ ],
+ },
+ 'action': [
+ 'python',
+ '../inspector/validate-protocol-compatibility',
+ '-o',
+ '<@(_outputs)',
+ '<@(_inputs)'
+ ],
+ 'message': 'Validate inspector protocol for backwards compatibility',
+ },
{
'action_name': 'generateInspectorProtocolIDL',
'inputs': [
Modified: trunk/Source/WebCore/inspector/Inspector.draft-01.json (96319 => 96320)
--- trunk/Source/WebCore/inspector/Inspector.draft-01.json 2011-09-29 11:39:11 UTC (rev 96319)
+++ trunk/Source/WebCore/inspector/Inspector.draft-01.json 2011-09-29 11:49:53 UTC (rev 96320)
@@ -1,6 +1,9 @@
-[
- {
+{
+ "version": "draft-01",
+ "compatible": [],
+ "domains" : [{
"domain": "Inspector",
+ "hidden": true,
"types": [],
"commands": [
],
@@ -1245,6 +1248,7 @@
},
{
"domain": "CSS",
+ "hidden": true,
"description": "This domain exposes CSS read/write operations. All CSS objects, like stylesheets, rules, and styles, have an associated <code>id</code> used in subsequent operations on the related object. Each object type has a specific <code>id</code> structure, and those are not interchangeable between objects of different kinds. CSS objects can be loaded using the <code>get*ForNode()</code> calls (which accept a DOM node id). Alternatively, a client can discover all the existing stylesheets with the <code>getAllStyleSheets()</code> method and subsequently load the required stylesheet contents using the <code>getStyleSheet[Text]()</code> methods.",
"types": [
{
@@ -1961,6 +1965,7 @@
},
{
"domain": "Worker",
+ "hidden": true,
"types": [],
"commands": [
{
@@ -2019,5 +2024,5 @@
]
}
]
- }
-]
+ }]
+}
Modified: trunk/Source/WebCore/inspector/Inspector.json (96319 => 96320)
--- trunk/Source/WebCore/inspector/Inspector.json 2011-09-29 11:39:11 UTC (rev 96319)
+++ trunk/Source/WebCore/inspector/Inspector.json 2011-09-29 11:49:53 UTC (rev 96320)
@@ -1,6 +1,9 @@
-[
- {
+{
+ "version": "tip-of-tree",
+ "compatible": ["draft-01"],
+ "domains": [{
"domain": "Inspector",
+ "hidden": true,
"types": [],
"commands": [
],
@@ -1211,7 +1214,7 @@
"name": "attributeRemoved",
"parameters": [
{ "name": "nodeId", "$ref": "NodeId", "description": "Id of the node that has changed." },
- { "name": "name", "type": "string", "description": "Local attribute name." }
+ { "name": "name", "type": "string", "description": "A ttribute name." }
],
"description": "Fired when <code>Element</code>'s attribute is removed."
},
@@ -1268,6 +1271,7 @@
},
{
"domain": "CSS",
+ "hidden": true,
"description": "This domain exposes CSS read/write operations. All CSS objects, like stylesheets, rules, and styles, have an associated <code>id</code> used in subsequent operations on the related object. Each object type has a specific <code>id</code> structure, and those are not interchangeable between objects of different kinds. CSS objects can be loaded using the <code>get*ForNode()</code> calls (which accept a DOM node id). Alternatively, a client can discover all the existing stylesheets with the <code>getAllStyleSheets()</code> method and subsequently load the required stylesheet contents using the <code>getStyleSheet[Text]()</code> methods.",
"types": [
{
@@ -1984,6 +1988,7 @@
},
{
"domain": "Worker",
+ "hidden": true,
"types": [],
"commands": [
{
@@ -2042,5 +2047,5 @@
]
}
]
- }
-]
+ }]
+}
Modified: trunk/Source/WebCore/inspector/generate-inspector-idl (96319 => 96320)
--- trunk/Source/WebCore/inspector/generate-inspector-idl 2011-09-29 11:39:11 UTC (rev 96319)
+++ trunk/Source/WebCore/inspector/generate-inspector-idl 2011-09-29 11:49:53 UTC (rev 96320)
@@ -42,7 +42,7 @@
json_string = input_file.read()
json_string = json_string.replace(": true", ": True")
json_string = json_string.replace(": false", ": false")
-json_api = eval(json_string)
+json_api = eval(json_string)["domains"]
output_file = open(output_path, "w")
output_file.write("""/*
Modified: trunk/Source/WebCore/inspector/generate-protocol-externs (96319 => 96320)
--- trunk/Source/WebCore/inspector/generate-protocol-externs 2011-09-29 11:39:11 UTC (rev 96319)
+++ trunk/Source/WebCore/inspector/generate-protocol-externs 2011-09-29 11:49:53 UTC (rev 96320)
@@ -42,7 +42,7 @@
json_string = input_file.read()
json_string = json_string.replace(": true", ": True")
json_string = json_string.replace(": false", ": false")
-json_api = eval(json_string)
+json_api = eval(json_string)["domains"]
output_file = open(output_path, "w")
Modified: trunk/Source/WebCore/inspector/validate-protocol-compatibility (96319 => 96320)
--- trunk/Source/WebCore/inspector/validate-protocol-compatibility 2011-09-29 11:39:11 UTC (rev 96319)
+++ trunk/Source/WebCore/inspector/validate-protocol-compatibility 2011-09-29 11:49:53 UTC (rev 96320)
@@ -296,24 +296,41 @@
"Network.requestWillBeSent: required parameter is missing: documentURL" ]
for i in range(len(errors)):
if errors[i] != golden_errors[i]:
- print "Self-test failed"
return False
return True
def main():
if not self_test():
- return
+ sys.stderr.write("Self-test failed")
+ return 1
- if len(sys.argv) < 3:
- print "Usage: %s Inspector.draft-01.json Inspector.json" % sys.argv[0]
- return
+ if len(sys.argv) < 4 or sys.argv[1] != "-o":
+ sys.stderr.write("Usage: %s -o OUTPUT_FILE INPUT_FILE\n" % sys.argv[0])
+ return 1
- schema_1 = load_json(sys.argv[1])
- schema_2 = load_json(sys.argv[2])
+ output_path = sys.argv[2]
+ output_file = open(output_path, "w")
- errors = compare_schemas(schema_1, schema_2)
- for error in errors:
- print error
+ input_path = sys.argv[3]
+ dir_name = os.path.dirname(input_path)
+ schema = load_json(input_path)
+ sys.stdout.write("Validating schema: %s\n" % schema["version"])
+ compatible = schema["compatible"]
+ errors_found = False
+ for version in compatible:
+ schema = load_json(input_path) # reload since modified while comparing
+ version_file_name = os.path.normpath(dir_name + "/Inspector." + version + ".json")
+ version_schema = load_json(version_file_name)
+ errors = compare_schemas(version_schema["domains"], schema["domains"])
+ if len(errors) > 0:
+ errors_found = True
+ sys.stderr.write(" compatibility with %s: FAILED\n" % version)
+ for error in errors:
+ sys.stderr.write( " %s\n" % error)
+ else:
+ sys.stderr.write(" compatibility with %s: SUCCESS\n" % version)
+ if errors_found:
+ return 1
if __name__ == '__main__':
sys.exit(main())