Changeset 199219 in webkit


Ignore:
Timestamp:
Apr 8, 2016 12:13:28 AM (8 years ago)
Author:
BJ Burg
Message:

Web Inspector: protocol generator should emit an error when 'type' is used instead of '$ref'
https://bugs.webkit.org/show_bug.cgi?id=156275
<rdar://problem/25569331>

Reviewed by Darin Adler.

  • inspector/protocol/Heap.json: Fix a mistake that's now caught by the protocol generator.
  • inspector/scripts/codegen/models.py:

(TypeReference.init): Check here if type_kind is on a whitelist of primitive types.
(TypeReference.referenced_name): Update comment.

Add a new test specifically for the case when the type would otherwise be resolved. Rebaseline.

  • inspector/scripts/tests/expected/fail-on-type-reference-as-primitive-type.json-error: Added.
  • inspector/scripts/tests/expected/fail-on-unknown-type-reference-in-type-declaration.json-error:
  • inspector/scripts/tests/fail-on-type-reference-as-primitive-type.json: Added.
Location:
trunk/Source/JavaScriptCore
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r199214 r199219  
     12016-04-08  Brian Burg  <bburg@apple.com>
     2
     3        Web Inspector: protocol generator should emit an error when 'type' is used instead of '$ref'
     4        https://bugs.webkit.org/show_bug.cgi?id=156275
     5        <rdar://problem/25569331>
     6
     7        Reviewed by Darin Adler.
     8
     9        * inspector/protocol/Heap.json: Fix a mistake that's now caught by the protocol generator.
     10
     11        * inspector/scripts/codegen/models.py:
     12        (TypeReference.__init__): Check here if type_kind is on a whitelist of primitive types.
     13        (TypeReference.referenced_name): Update comment.
     14
     15        Add a new test specifically for the case when the type would otherwise be resolved. Rebaseline.
     16
     17        * inspector/scripts/tests/expected/fail-on-type-reference-as-primitive-type.json-error: Added.
     18        * inspector/scripts/tests/expected/fail-on-unknown-type-reference-in-type-declaration.json-error:
     19        * inspector/scripts/tests/fail-on-type-reference-as-primitive-type.json: Added.
     20
    1212016-04-07  Joseph Pecoraro  <pecoraro@apple.com>
    222
  • trunk/Source/JavaScriptCore/inspector/protocol/Heap.json

    r197926 r199219  
    7777            "description": "Information about the garbage collection.",
    7878            "parameters": [
    79                 { "name": "collection", "type": "GarbageCollection" }
     79                { "name": "collection", "$ref": "GarbageCollection" }
    8080            ]
    8181        },
  • trunk/Source/JavaScriptCore/inspector/scripts/codegen/models.py

    r198752 r199219  
    120120            raise ParseException("Type reference cannot have both 'type' and '$ref' keys.")
    121121
     122        all_primitive_types = ["integer", "number", "string", "boolean", "enum", "object", "array", "any"]
     123        if type_kind is not None and type_kind not in all_primitive_types:
     124            raise ParseException("Type reference '%s' is not a primitive type. Allowed values: %s" % (type_kind, ', '.join(all_primitive_types)))
     125
    122126        if type_kind == "array" and array_items is None:
    123127            raise ParseException("Type reference with type 'array' must have key 'items' to define array element type.")
     
    130134            return self.referenced_type_name
    131135        else:
    132             return self.type_kind  # integer, string, number, boolean, enum, object, array
     136            return self.type_kind  # one of all_primitive_types
    133137
    134138
  • trunk/Source/JavaScriptCore/inspector/scripts/tests/expected/fail-on-unknown-type-reference-in-type-declaration.json-error

    r172655 r199219  
    1 ERROR: Lookup failed for type reference: dragon (referenced from domain: Runtime)
     1ERROR: Type reference 'dragon' is not a primitive type. Allowed values: integer, number, string, boolean, enum, object, array, any
Note: See TracChangeset for help on using the changeset viewer.