Changeset 207711 in webkit


Ignore:
Timestamp:
Oct 22, 2016 3:19:21 AM (7 years ago)
Author:
nael.ouedraogo@crf.canon.fr
Message:

Bindings error message for missing required dictionary member should be more explicit
https://bugs.webkit.org/show_bug.cgi?id=163665

Reviewed by Darin Adler.

Source/WebCore:

Add throwRequiredMemberTypeError function to throw a TypeError exception with an error
message indicating the missing required member.

No new test required, rebase existing tests.

  • bindings/js/JSDOMBinding.cpp:

(WebCore::throwRequiredMemberTypeError):

  • bindings/js/JSDOMBinding.h:
  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateDictionaryImplementationContent):

  • bindings/scripts/test/JS/JSTestObj.cpp:

(WebCore::convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>):

LayoutTests:

Update existing tests.

  • fast/mediastream/MediaStreamTrackEvent-constructor-expected.txt:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r207710 r207711  
     12016-10-22  Nael Ouedraogo  <nael.ouedraogo@crf.canon.fr>
     2
     3        Bindings error message for missing required dictionary member should be more explicit
     4        https://bugs.webkit.org/show_bug.cgi?id=163665
     5
     6        Reviewed by Darin Adler.
     7
     8        Update existing tests.
     9
     10        * fast/mediastream/MediaStreamTrackEvent-constructor-expected.txt:
     11
    1122016-10-22  Ryosuke Niwa  <rniwa@webkit.org>
    213
  • trunk/LayoutTests/fast/mediastream/MediaStreamTrackEvent-constructor-expected.txt

    r207588 r207711  
    1313
    1414*** Bubbles and cancelable true, track is missing ***
    15 PASS new MediaStreamTrackEvent('MediaStreamTrackEvent', { bubbles: true, cancelable: true }) threw exception TypeError: Type error.
     15PASS new MediaStreamTrackEvent('MediaStreamTrackEvent', { bubbles: true, cancelable: true }) threw exception TypeError: Member MediaStreamTrackEventInit.track is required and must be an instance of MediaStreamTrack.
    1616
    1717*** Bubbles and cancelable true, invalid track ***
  • trunk/Source/WebCore/ChangeLog

    r207710 r207711  
     12016-10-22  Nael Ouedraogo  <nael.ouedraogo@crf.canon.fr>
     2
     3        Bindings error message for missing required dictionary member should be more explicit
     4        https://bugs.webkit.org/show_bug.cgi?id=163665
     5
     6        Reviewed by Darin Adler.
     7
     8        Add throwRequiredMemberTypeError function to throw a TypeError exception with an error
     9        message indicating the missing required member.
     10
     11        No new test required, rebase existing tests.
     12
     13        * bindings/js/JSDOMBinding.cpp:
     14        (WebCore::throwRequiredMemberTypeError):
     15        * bindings/js/JSDOMBinding.h:
     16        * bindings/scripts/CodeGeneratorJS.pm:
     17        (GenerateDictionaryImplementationContent):
     18        * bindings/scripts/test/JS/JSTestObj.cpp:
     19        (WebCore::convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>):
     20
    1212016-10-22  Ryosuke Niwa  <rniwa@webkit.org>
    222
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp

    r207192 r207711  
    933933}
    934934
     935JSC::EncodedJSValue throwRequiredMemberTypeError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* memberName, const char* dictionaryName, const char* expectedType)
     936{
     937    StringBuilder builder;
     938    builder.appendLiteral("Member ");
     939    builder.append(dictionaryName);
     940    builder.append('.');
     941    builder.append(memberName);
     942    builder.appendLiteral(" is required and must be an instance of ");
     943    builder.append(expectedType);
     944    return throwVMTypeError(&state, scope, builder.toString());
     945}
     946
    935947JSC::EncodedJSValue throwConstructorScriptExecutionContextUnavailableError(JSC::ExecState& state, JSC::ThrowScope& scope, const char* interfaceName)
    936948{
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.h

    r207575 r207711  
    128128JSC::EncodedJSValue throwArgumentMustBeFunctionError(JSC::ExecState&, JSC::ThrowScope&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName);
    129129WEBCORE_EXPORT JSC::EncodedJSValue throwArgumentTypeError(JSC::ExecState&, JSC::ThrowScope&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName, const char* expectedType);
     130WEBCORE_EXPORT JSC::EncodedJSValue throwRequiredMemberTypeError(JSC::ExecState&, JSC::ThrowScope&, const char* memberName, const char* dictionaryName, const char* expectedType);
    130131JSC::EncodedJSValue throwConstructorScriptExecutionContextUnavailableError(JSC::ExecState&, JSC::ThrowScope&, const char* interfaceName);
    131132
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r207705 r207711  
    11621162                # 5.5. Otherwise, if value is undefined and the dictionary member is a required dictionary member, then throw a TypeError.
    11631163                $result .= "    } else {\n";
    1164                 $result .= "        throwTypeError(&state, throwScope);\n";
     1164                $result .= "        throwRequiredMemberTypeError(state, throwScope, \"".$member->name."\", \"$name\", \"".$idlType->name."\");\n";
    11651165                $result .= "        return { };\n";
    11661166                $result .= "    }\n";
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r207705 r207711  
    714714        RETURN_IF_EXCEPTION(throwScope, { });
    715715    } else {
    716         throwTypeError(&state, throwScope);
     716        throwRequiredMemberTypeError(state, throwScope, "nonNullableNode", "TestDictionaryThatShouldNotTolerateNull", "Node");
    717717        return { };
    718718    }
     
    722722        RETURN_IF_EXCEPTION(throwScope, { });
    723723    } else {
    724         throwTypeError(&state, throwScope);
     724        throwRequiredMemberTypeError(state, throwScope, "requiredDictionaryMember", "TestDictionaryThatShouldNotTolerateNull", "TestDictionary");
    725725        return { };
    726726    }
     
    730730        RETURN_IF_EXCEPTION(throwScope, { });
    731731    } else {
    732         throwTypeError(&state, throwScope);
     732        throwRequiredMemberTypeError(state, throwScope, "requiredEnumerationValue", "TestDictionaryThatShouldNotTolerateNull", "TestEnumType");
    733733        return { };
    734734    }
Note: See TracChangeset for help on using the changeset viewer.