Skip to content
Permalink
Browse files
Web Inspector: protocol generator should not allow non-boolean values…
… for "optional" key

https://bugs.webkit.org/show_bug.cgi?id=148679

Reviewed by Joseph Pecoraro.

In Python, the 'bool' type inherits from 'int'. In the runtime, True and False are
just numbers to Python. So, the existing check for boolean literals was not quite right.

* inspector/scripts/codegen/models.py: Use isinstance instead.
(TypeMember.__init__):
(Parameter.__init__):
* inspector/scripts/tests/expected/fail-on-number-typed-optional-parameter-flag.json-error: Added.
* inspector/scripts/tests/expected/fail-on-number-typed-optional-type-member.json-error: Added.
* inspector/scripts/tests/fail-on-number-typed-optional-parameter-flag.json: Added.
* inspector/scripts/tests/fail-on-number-typed-optional-type-member.json: Added.


Canonical link: https://commits.webkit.org/166800@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189222 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
burg committed Sep 1, 2015
1 parent 21f03a8 commit 2137ada32bad6419c772f6452983a26b1f394b78
Showing 6 changed files with 56 additions and 2 deletions.
@@ -1,3 +1,21 @@
2015-09-01 Brian Burg <bburg@apple.com>

Web Inspector: protocol generator should not allow non-boolean values for "optional" key
https://bugs.webkit.org/show_bug.cgi?id=148679

Reviewed by Joseph Pecoraro.

In Python, the 'bool' type inherits from 'int'. In the runtime, True and False are
just numbers to Python. So, the existing check for boolean literals was not quite right.

* inspector/scripts/codegen/models.py: Use isinstance instead.
(TypeMember.__init__):
(Parameter.__init__):
* inspector/scripts/tests/expected/fail-on-number-typed-optional-parameter-flag.json-error: Added.
* inspector/scripts/tests/expected/fail-on-number-typed-optional-type-member.json-error: Added.
* inspector/scripts/tests/fail-on-number-typed-optional-parameter-flag.json: Added.
* inspector/scripts/tests/fail-on-number-typed-optional-type-member.json: Added.

2015-09-01 Filip Pizlo <fpizlo@apple.com>

DFG AI assertions about not having to do type checks at the point of a Known use kind are unsound
@@ -538,7 +538,7 @@ def __init__(self, member_name, type_ref, is_optional, description):
self.is_optional = is_optional
self.description = description

if self.is_optional not in [True, False]:
if not isinstance(self.is_optional, bool):
raise ParseException("The 'optional' flag for a type member must be a boolean literal.")

def resolve_type_references(self, protocol, domain):
@@ -553,7 +553,7 @@ def __init__(self, parameter_name, type_ref, is_optional, description):
self.is_optional = is_optional
self.description = description

if self.is_optional not in [True, False]:
if not isinstance(self.is_optional, bool):
raise ParseException("The 'optional' flag for a parameter must be a boolean literal.")

def resolve_type_references(self, protocol, domain):
@@ -0,0 +1 @@
ERROR: The 'optional' flag for a parameter must be a boolean literal.
@@ -0,0 +1 @@
ERROR: The 'optional' flag for a type member must be a boolean literal.
@@ -0,0 +1,18 @@
{
"domain": "Database",
"types": [
{
"id": "DatabaseId",
"type": "string",
"description": "Unique identifier of Database object."
}
],
"events": [
{
"name": "didExecuteOptionalParameters",
"parameters": [
{ "name": "columnNames", "type": "string", "optional": 0 }
]
}
]
}
@@ -0,0 +1,16 @@
[
{
"domain": "Database",
"types": [
{
"id": "Error",
"type": "object",
"description": "Database error.",
"properties": [
{ "name": "message", "type": "string", "description": "Error message." },
{ "name": "code", "type": "integer", "description": "Error code.", "optional": 0 }
]
}
]
}
]

0 comments on commit 2137ada

Please sign in to comment.