Title: [205008] trunk
Revision
205008
Author
[email protected]
Date
2016-08-26 01:04:02 -0700 (Fri, 26 Aug 2016)

Log Message

Make custom constructors consistent with generated bindings code
https://bugs.webkit.org/show_bug.cgi?id=159550

Reviewed by Youenn Fablet.

Add assertion to check DOMConstructorObject* passed in ExecState is not null.
Rename throwConstructorDocumentUnavailableError to throwConstructorScriptExecutionContextUnavailableError since
ScriptExecutionContext is not necessarily a Document.
Modify error message in case of argument error to be consistent with generated binding code: replace calls to
throwVMError with calls to throwConstructorScriptExecutionContextUnavailableError and throwArgumentTypeError.

No new test required. Modify tests and tests expectations to align with new error messages.

Source/WebCore:

* bindings/js/JSAudioContextCustom.cpp:
(WebCore::constructJSAudioContext):
* bindings/js/JSBlobCustom.cpp:
(WebCore::constructJSBlob):
* bindings/js/JSDOMBinding.cpp:
(WebCore::throwConstructorScriptExecutionContextUnavailableError):
* bindings/js/JSDOMBinding.h:
* bindings/js/JSDOMConstructor.h:
(WebCore::JSBuiltinConstructor<JSClass>::callConstructor):
* bindings/js/JSDOMFormDataCustom.cpp:
(WebCore::constructJSDOMFormData):
* bindings/js/JSDataCueCustom.cpp:
(WebCore::constructJSDataCue):
* bindings/js/JSFileCustom.cpp:
(WebCore::constructJSFile):
* bindings/js/JSHTMLElementCustom.cpp:
(WebCore::constructJSHTMLElement):
* bindings/js/JSMediaSessionCustom.cpp:
(WebCore::constructJSMediaSession):
* bindings/js/JSMutationObserverCustom.cpp:
(WebCore::constructJSMutationObserver):
* bindings/js/JSReadableStreamPrivateConstructors.cpp:
(WebCore::constructJSReadableStreamDefaultReader):
* bindings/js/JSWorkerCustom.cpp:
(WebCore::constructJSWorker):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateCallbackImplementation):
(NativeToJSValue):
(GenerateHashTableValueArray):
(GenerateConstructorDefinition):
* bindings/scripts/test/JS/JSTestEventConstructor.cpp:
(WebCore::JSTestEventConstructorConstructor::construct):
* bindings/scripts/test/JS/JSTestInterface.cpp:
(WebCore::JSTestInterfaceConstructor::construct):
* bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
(WebCore::JSTestNamedConstructorNamedConstructor::construct):
* bindings/scripts/test/JS/JSTestNode.cpp:
(WebCore::JSTestNodeConstructor::construct):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::JSTestObjConstructor::construct):
* bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
(WebCore::constructJSTestOverloadedConstructors1):
(WebCore::constructJSTestOverloadedConstructors2):
(WebCore::constructJSTestOverloadedConstructors3):
(WebCore::constructJSTestOverloadedConstructors4):
(WebCore::constructJSTestOverloadedConstructors5):
* bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp:
(WebCore::constructJSTestOverloadedConstructorsWithSequence1):
(WebCore::constructJSTestOverloadedConstructorsWithSequence2):
* bindings/scripts/test/JS/JSTestTypedefs.cpp:
(WebCore::JSTestTypedefsConstructor::construct):

LayoutTests:

* fast/dom/MutationObserver/mutation-observer-constructor-expected.txt:
* fast/files/file-constructor-expected.txt:
* fast/files/file-constructor.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (205007 => 205008)


--- trunk/LayoutTests/ChangeLog	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/LayoutTests/ChangeLog	2016-08-26 08:04:02 UTC (rev 205008)
@@ -1,3 +1,22 @@
+2016-08-26  Nael Ouedraogo  <[email protected]>
+
+        Make custom constructors consistent with generated bindings code
+        https://bugs.webkit.org/show_bug.cgi?id=159550
+
+        Reviewed by Youenn Fablet.
+
+        Add assertion to check DOMConstructorObject* passed in ExecState is not null.
+        Rename throwConstructorDocumentUnavailableError to throwConstructorScriptExecutionContextUnavailableError since
+        ScriptExecutionContext is not necessarily a Document.
+        Modify error message in case of argument error to be consistent with generated binding code: replace calls to
+        throwVMError with calls to throwConstructorScriptExecutionContextUnavailableError and throwArgumentTypeError.
+
+        No new test required. Modify tests and tests expectations to align with new error messages.
+
+        * fast/dom/MutationObserver/mutation-observer-constructor-expected.txt:
+        * fast/files/file-constructor-expected.txt:
+        * fast/files/file-constructor.html:
+
 2016-08-25  Jiewen Tan  <[email protected]>
 
         Unreviewed, rebase iOS simulator WK1 imported/w3c tests

Modified: trunk/LayoutTests/fast/dom/MutationObserver/mutation-observer-constructor-expected.txt (205007 => 205008)


--- trunk/LayoutTests/fast/dom/MutationObserver/mutation-observer-constructor-expected.txt	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/LayoutTests/fast/dom/MutationObserver/mutation-observer-constructor-expected.txt	2016-08-26 08:04:02 UTC (rev 205008)
@@ -8,10 +8,10 @@
 PASS typeof WebKitMutationObserver.prototype.disconnect is "function"
 PASS typeof observer.observe is "function"
 PASS typeof observer.disconnect is "function"
-PASS new MutationObserver({ handleEvent: function() {} }) threw exception TypeError: Callback argument must be a function.
-PASS new MutationObserver({}) threw exception TypeError: Callback argument must be a function.
-PASS new MutationObserver(42) threw exception TypeError: Callback argument must be a function.
-PASS new MutationObserver("foo") threw exception TypeError: Callback argument must be a function.
+PASS new MutationObserver({ handleEvent: function() {} }) threw exception TypeError: Argument 1 ('callback') to the MutationObserver constructor must be an instance of MutationCallback.
+PASS new MutationObserver({}) threw exception TypeError: Argument 1 ('callback') to the MutationObserver constructor must be an instance of MutationCallback.
+PASS new MutationObserver(42) threw exception TypeError: Argument 1 ('callback') to the MutationObserver constructor must be an instance of MutationCallback.
+PASS new MutationObserver("foo") threw exception TypeError: Argument 1 ('callback') to the MutationObserver constructor must be an instance of MutationCallback.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/files/file-constructor-expected.txt (205007 => 205008)


--- trunk/LayoutTests/fast/files/file-constructor-expected.txt	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/LayoutTests/fast/files/file-constructor-expected.txt	2016-08-26 08:04:02 UTC (rev 205008)
@@ -10,8 +10,8 @@
 PASS (new File(['hello'], 'world.html', {type:'text/html', endings:'native'})) instanceof window.File is true
 PASS (new File(['hello'], 'world.html', {type:'text/html', endings:'transparent'})) instanceof window.File is true
 PASS (new File([], 'world.html')) instanceof window.File is true
-PASS (new File()) threw exception TypeError: First argument to File constructor must be a valid sequence, was undefined or null.
-PASS (new File([])) threw exception TypeError: Second argument to File constructor must be a valid string, was undefined.
+PASS (new File()) threw exception TypeError: Argument 1 ('fileBits') to the File constructor must be an instance of sequence.
+PASS (new File([])) threw exception TypeError: Argument 2 ('filename') to the File constructor must be an instance of DOMString.
 PASS (new File([], null)) instanceof window.File is true
 PASS (new File([], 1)) instanceof window.File is true
 PASS (new File([], '')) instanceof window.File is true
@@ -18,7 +18,7 @@
 PASS (new File([], document)) instanceof window.File is true
 PASS new File('hello', 'world.html') threw exception TypeError: Value is not a sequence.
 PASS new File(0, 'world.html') threw exception TypeError: Value is not a sequence.
-PASS new File(null, 'world.html') threw exception TypeError: First argument to File constructor must be a valid sequence, was undefined or null.
+PASS new File(null, 'world.html') threw exception TypeError: Argument 1 ('fileBits') to the File constructor must be an instance of sequence.
 PASS (new File([], 'world.html')) instanceof window.File is true
 PASS (new File(['stringPrimitive'], 'world.html')) instanceof window.File is true
 PASS (new File([String('stringObject')], 'world.html')) instanceof window.File is true
@@ -49,10 +49,10 @@
 PASS (new File([], 'world.html', {lastModified: 555, type:'goodbyeî'})).lastModified is not 555
 PASS (new File([], 'world.html', null)) instanceof window.File is true
 PASS (new File([], 'world.html', undefined)) instanceof window.File is true
-PASS (new File([], 'world.html', 123)) instanceof window.File threw exception TypeError: Third argument of the constructor is not of type Object.
-PASS (new File([], 'world.html', 123.4)) instanceof window.File threw exception TypeError: Third argument of the constructor is not of type Object.
-PASS (new File([], 'world.html', true)) instanceof window.File threw exception TypeError: Third argument of the constructor is not of type Object.
-PASS (new File([], 'world.html', 'abc')) instanceof window.File threw exception TypeError: Third argument of the constructor is not of type Object.
+PASS (new File([], 'world.html', 123)) instanceof window.File threw exception TypeError: Argument 3 ('options') to the File constructor must be an instance of FilePropertyBag.
+PASS (new File([], 'world.html', 123.4)) instanceof window.File threw exception TypeError: Argument 3 ('options') to the File constructor must be an instance of FilePropertyBag.
+PASS (new File([], 'world.html', true)) instanceof window.File threw exception TypeError: Argument 3 ('options') to the File constructor must be an instance of FilePropertyBag.
+PASS (new File([], 'world.html', 'abc')) instanceof window.File threw exception TypeError: Argument 3 ('options') to the File constructor must be an instance of FilePropertyBag.
 PASS (new File([], 'world.html', [])) instanceof window.File is true
 PASS (new File([], 'world.html', /abc/)) instanceof window.File is true
 PASS (new File([], 'world.html', function () {})) instanceof window.File is true

Modified: trunk/LayoutTests/fast/files/file-constructor.html (205007 => 205008)


--- trunk/LayoutTests/fast/files/file-constructor.html	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/LayoutTests/fast/files/file-constructor.html	2016-08-26 08:04:02 UTC (rev 205008)
@@ -16,8 +16,8 @@
 shouldBeTrue("(new File([], 'world.html')) instanceof window.File")
 
 // Verify that the file name argument is required.
-shouldThrow("(new File())", '"TypeError: First argument to File constructor must be a valid sequence, was undefined or null"');
-shouldThrow("(new File([]))", '"TypeError: Second argument to File constructor must be a valid string, was undefined"');
+shouldThrow("(new File())", "'TypeError: Argument 1 (\\'fileBits\\') to the File constructor must be an instance of sequence'");
+shouldThrow("(new File([]))", "'TypeError: Argument 2 (\\'filename\\') to the File constructor must be an instance of DOMString'");
 
 // Test valid file names.
 shouldBeTrue("(new File([], null)) instanceof window.File");
@@ -28,7 +28,7 @@
 // Test invalid file parts.
 shouldThrow("new File('hello', 'world.html')", '"TypeError: Value is not a sequence"');
 shouldThrow("new File(0, 'world.html')", '"TypeError: Value is not a sequence"');
-shouldThrow("new File(null, 'world.html')", '"TypeError: First argument to File constructor must be a valid sequence, was undefined or null"');
+shouldThrow("new File(null, 'world.html')", "'TypeError: Argument 1 (\\'fileBits\\') to the File constructor must be an instance of sequence'");
 
 // Test valid file parts.
 shouldBeTrue("(new File([], 'world.html')) instanceof window.File");
@@ -73,16 +73,16 @@
 shouldBe("(new File([], 'world.html', {type:'hello\u00EE'})).type", "''");
 
 // FilePropertyBag  substeps: Type with non-ascii characters should prevent lastModified from being extracted.
-shouldBe("(new File([], 'world.html', {lastModified: 555, type:'goodbye'})).lastModified", "555"); 
-shouldNotBe("(new File([], 'world.html', {lastModified: 555, type:'goodbye\u00EE'})).lastModified", "555"); 
+shouldBe("(new File([], 'world.html', {lastModified: 555, type:'goodbye'})).lastModified", "555");
+shouldNotBe("(new File([], 'world.html', {lastModified: 555, type:'goodbye\u00EE'})).lastModified", "555");
 
 // Test various non-object literals being used as property bags.
 shouldBeTrue("(new File([], 'world.html', null)) instanceof window.File");
 shouldBeTrue("(new File([], 'world.html', undefined)) instanceof window.File");
-shouldThrow("(new File([], 'world.html', 123)) instanceof window.File", "'TypeError: Third argument of the constructor is not of type Object'");
-shouldThrow("(new File([], 'world.html', 123.4)) instanceof window.File", "'TypeError: Third argument of the constructor is not of type Object'");
-shouldThrow("(new File([], 'world.html', true)) instanceof window.File", "'TypeError: Third argument of the constructor is not of type Object'");
-shouldThrow("(new File([], 'world.html', 'abc')) instanceof window.File", "'TypeError: Third argument of the constructor is not of type Object'");
+shouldThrow("(new File([], 'world.html', 123)) instanceof window.File", "'TypeError: Argument 3 (\\'options\\') to the File constructor must be an instance of FilePropertyBag'");
+shouldThrow("(new File([], 'world.html', 123.4)) instanceof window.File", "'TypeError: Argument 3 (\\'options\\') to the File constructor must be an instance of FilePropertyBag'");
+shouldThrow("(new File([], 'world.html', true)) instanceof window.File", "'TypeError: Argument 3 (\\'options\\') to the File constructor must be an instance of FilePropertyBag'");
+shouldThrow("(new File([], 'world.html', 'abc')) instanceof window.File", "'TypeError: Argument 3 (\\'options\\') to the File constructor must be an instance of FilePropertyBag'");
 shouldBeTrue("(new File([], 'world.html', [])) instanceof window.File");
 shouldBeTrue("(new File([], 'world.html', /abc/)) instanceof window.File");
 shouldBeTrue("(new File([], 'world.html', function () {})) instanceof window.File");

Modified: trunk/Source/WebCore/ChangeLog (205007 => 205008)


--- trunk/Source/WebCore/ChangeLog	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/ChangeLog	2016-08-26 08:04:02 UTC (rev 205008)
@@ -1,3 +1,70 @@
+2016-08-26  Nael Ouedraogo  <[email protected]>
+
+        Make custom constructors consistent with generated bindings code
+        https://bugs.webkit.org/show_bug.cgi?id=159550
+
+        Reviewed by Youenn Fablet.
+
+        Add assertion to check DOMConstructorObject* passed in ExecState is not null.
+        Rename throwConstructorDocumentUnavailableError to throwConstructorScriptExecutionContextUnavailableError since
+        ScriptExecutionContext is not necessarily a Document.
+        Modify error message in case of argument error to be consistent with generated binding code: replace calls to
+        throwVMError with calls to throwConstructorScriptExecutionContextUnavailableError and throwArgumentTypeError.
+
+        No new test required. Modify tests and tests expectations to align with new error messages.
+
+        * bindings/js/JSAudioContextCustom.cpp:
+        (WebCore::constructJSAudioContext):
+        * bindings/js/JSBlobCustom.cpp:
+        (WebCore::constructJSBlob):
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::throwConstructorScriptExecutionContextUnavailableError):
+        * bindings/js/JSDOMBinding.h:
+        * bindings/js/JSDOMConstructor.h:
+        (WebCore::JSBuiltinConstructor<JSClass>::callConstructor):
+        * bindings/js/JSDOMFormDataCustom.cpp:
+        (WebCore::constructJSDOMFormData):
+        * bindings/js/JSDataCueCustom.cpp:
+        (WebCore::constructJSDataCue):
+        * bindings/js/JSFileCustom.cpp:
+        (WebCore::constructJSFile):
+        * bindings/js/JSHTMLElementCustom.cpp:
+        (WebCore::constructJSHTMLElement):
+        * bindings/js/JSMediaSessionCustom.cpp:
+        (WebCore::constructJSMediaSession):
+        * bindings/js/JSMutationObserverCustom.cpp:
+        (WebCore::constructJSMutationObserver):
+        * bindings/js/JSReadableStreamPrivateConstructors.cpp:
+        (WebCore::constructJSReadableStreamDefaultReader):
+        * bindings/js/JSWorkerCustom.cpp:
+        (WebCore::constructJSWorker):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateCallbackImplementation):
+        (NativeToJSValue):
+        (GenerateHashTableValueArray):
+        (GenerateConstructorDefinition):
+        * bindings/scripts/test/JS/JSTestEventConstructor.cpp:
+        (WebCore::JSTestEventConstructorConstructor::construct):
+        * bindings/scripts/test/JS/JSTestInterface.cpp:
+        (WebCore::JSTestInterfaceConstructor::construct):
+        * bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
+        (WebCore::JSTestNamedConstructorNamedConstructor::construct):
+        * bindings/scripts/test/JS/JSTestNode.cpp:
+        (WebCore::JSTestNodeConstructor::construct):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::JSTestObjConstructor::construct):
+        * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
+        (WebCore::constructJSTestOverloadedConstructors1):
+        (WebCore::constructJSTestOverloadedConstructors2):
+        (WebCore::constructJSTestOverloadedConstructors3):
+        (WebCore::constructJSTestOverloadedConstructors4):
+        (WebCore::constructJSTestOverloadedConstructors5):
+        * bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp:
+        (WebCore::constructJSTestOverloadedConstructorsWithSequence1):
+        (WebCore::constructJSTestOverloadedConstructorsWithSequence2):
+        * bindings/scripts/test/JS/JSTestTypedefs.cpp:
+        (WebCore::JSTestTypedefsConstructor::construct):
+
 2016-08-25  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed. Fix GTK+ build after r204986 and r204996.

Modified: trunk/Source/WebCore/bindings/js/JSAudioContextCustom.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/js/JSAudioContextCustom.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/js/JSAudioContextCustom.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -47,16 +47,13 @@
 EncodedJSValue JSC_HOST_CALL constructJSAudioContext(ExecState& exec)
 {
     DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec.callee());
-    if (!jsConstructor)
-        return throwVMError(&exec, createReferenceError(&exec, "AudioContext constructor callee is unavailable"));
+    ASSERT(jsConstructor);
 
     ScriptExecutionContext* scriptExecutionContext = jsConstructor->scriptExecutionContext();
     if (!scriptExecutionContext)
-        return throwVMError(&exec, createReferenceError(&exec, "AudioContext constructor script execution context is unavailable"));
+        return throwConstructorScriptExecutionContextUnavailableError(exec, "AudioContext");
+    ASSERT(scriptExecutionContext->isDocument());
 
-    if (!is<Document>(*scriptExecutionContext))
-        return throwVMError(&exec, createReferenceError(&exec, "AudioContext constructor called in a script execution context which is not a document"));
-
     Document& document = downcast<Document>(*scriptExecutionContext);
 
     RefPtr<AudioContext> audioContext;
@@ -69,7 +66,7 @@
             setDOMException(&exec, ec);
             return JSValue::encode(JSValue());
         }
-        if (!audioContext.get())
+        if (!audioContext)
             return throwVMError(&exec, createSyntaxError(&exec, "audio resources unavailable for AudioContext construction"));
     } else {
 #if ENABLE(LEGACY_WEB_AUDIO)
@@ -103,11 +100,9 @@
 #else
         return throwVMError(&exec, createSyntaxError(&exec, "Illegal AudioContext constructor"));
 #endif
+        if (!audioContext)
+            return throwVMError(&exec, createReferenceError(&exec, "Error creating AudioContext"));
     }
-
-    if (!audioContext)
-        return throwVMError(&exec, createReferenceError(&exec, "Error creating AudioContext"));
-
     return JSValue::encode(CREATE_DOM_WRAPPER(jsConstructor->globalObject(), AudioContext, audioContext.releaseNonNull()));
 }
 

Modified: trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/js/JSBlobCustom.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -37,6 +37,7 @@
 #include "JSDOMBinding.h"
 #include "JSDictionary.h"
 #include "JSFile.h"
+#include "ScriptExecutionContext.h"
 #include "WebKitBlobBuilder.h"
 #include <runtime/Error.h>
 #include <runtime/JSArray.h>
@@ -63,9 +64,11 @@
 EncodedJSValue JSC_HOST_CALL constructJSBlob(ExecState& exec)
 {
     DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec.callee());
+    ASSERT(jsConstructor);
+
     ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();
     if (!context)
-        return throwVMError(&exec, createReferenceError(&exec, "Blob constructor associated document is unavailable"));
+        return throwConstructorScriptExecutionContextUnavailableError(exec, "Blob");
 
     if (!exec.argumentCount()) {
         return JSValue::encode(CREATE_DOM_WRAPPER(jsConstructor->globalObject(), Blob, Blob::create()));

Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -878,10 +878,9 @@
     throwTypeError(state, makeString("The ", interfaceName, '.', attributeName, " attribute must be an instance of ", expectedType));
 }
 
-JSC::EncodedJSValue throwConstructorDocumentUnavailableError(JSC::ExecState& state, const char* interfaceName)
+JSC::EncodedJSValue throwConstructorScriptExecutionContextUnavailableError(JSC::ExecState& state, const char* interfaceName)
 {
-    // FIXME: This is confusing exception wording. Can we reword to be clearer and more specific?
-    return throwVMError(&state, createReferenceError(&state, makeString(interfaceName, " constructor associated document is unavailable")));
+    return throwVMError(&state, createReferenceError(&state, makeString(interfaceName, " constructor associated execution context is unavailable")));
 }
 
 void throwSequenceTypeError(JSC::ExecState& state)

Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (205007 => 205008)


--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h	2016-08-26 08:04:02 UTC (rev 205008)
@@ -124,10 +124,11 @@
 WEBCORE_EXPORT JSC::EncodedJSValue throwArgumentMustBeEnumError(JSC::ExecState&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName, const char* expectedValues);
 JSC::EncodedJSValue throwArgumentMustBeFunctionError(JSC::ExecState&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName);
 WEBCORE_EXPORT JSC::EncodedJSValue throwArgumentTypeError(JSC::ExecState&, unsigned argumentIndex, const char* argumentName, const char* functionInterfaceName, const char* functionName, const char* expectedType);
-JSC::EncodedJSValue throwConstructorDocumentUnavailableError(JSC::ExecState&, const char* interfaceName);
+JSC::EncodedJSValue throwConstructorScriptExecutionContextUnavailableError(JSC::ExecState&, const char* interfaceName);
 
 String makeGetterTypeErrorMessage(const char* interfaceName, const char* attributeName);
 String makeThisTypeErrorMessage(const char* interfaceName, const char* attributeName);
+
 WEBCORE_EXPORT JSC::EncodedJSValue throwGetterTypeError(JSC::ExecState&, const char* interfaceName, const char* attributeName);
 WEBCORE_EXPORT JSC::EncodedJSValue throwThisTypeError(JSC::ExecState&, const char* interfaceName, const char* functionName);
 

Modified: trunk/Source/WebCore/bindings/js/JSDOMConstructor.h (205007 => 205008)


--- trunk/Source/WebCore/bindings/js/JSDOMConstructor.h	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/js/JSDOMConstructor.h	2016-08-26 08:04:02 UTC (rev 205008)
@@ -227,7 +227,7 @@
 template<typename JSClass> inline JSC::EncodedJSValue JSBuiltinConstructor<JSClass>::callConstructor(JSC::ExecState& state, JSC::JSObject* object)
 {
     if (!object)
-        return throwConstructorDocumentUnavailableError(state, info()->className);
+        return throwConstructorScriptExecutionContextUnavailableError(state, info()->className);
     return callConstructor(state, *object);
 }
 

Modified: trunk/Source/WebCore/bindings/js/JSDOMFormDataCustom.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/js/JSDOMFormDataCustom.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/js/JSDOMFormDataCustom.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -49,7 +49,7 @@
 EncodedJSValue JSC_HOST_CALL constructJSDOMFormData(ExecState& exec)
 {
     DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec.callee());
-
+    ASSERT(jsConstructor);
     HTMLFormElement* form = toHTMLFormElementOrNull(exec.argument(0));
     auto domFormData = DOMFormData::create(form);
     return JSValue::encode(toJSNewlyCreated(&exec, jsConstructor->globalObject(), WTFMove(domFormData)));

Modified: trunk/Source/WebCore/bindings/js/JSDataCueCustom.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/js/JSDataCueCustom.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/js/JSDataCueCustom.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -20,7 +20,7 @@
  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include "config.h"
@@ -50,6 +50,7 @@
 EncodedJSValue JSC_HOST_CALL constructJSDataCue(ExecState& exec)
 {
     DOMConstructorObject* castedThis = jsCast<DOMConstructorObject*>(exec.callee());
+    ASSERT(castedThis);
     if (exec.argumentCount() < 3)
         return throwVMError(&exec, createNotEnoughArgumentsError(&exec));
 
@@ -63,13 +64,13 @@
 
     ScriptExecutionContext* context = castedThis->scriptExecutionContext();
     if (!context)
-        return throwConstructorDocumentUnavailableError(exec, "DataCue");
+        return throwConstructorScriptExecutionContextUnavailableError(exec, "DataCue");
 
     String type;
 #if ENABLE(DATACUE_VALUE)
     if (exec.argumentCount() > 3) {
         if (!exec.uncheckedArgument(3).isString())
-            return throwVMTypeError(&exec, ASCIILiteral("Second argument of the constructor is not of type String"));
+            return throwArgumentTypeError(exec, 3, "type", "DataCue", nullptr, "DOMString");
         type = exec.uncheckedArgument(3).getString(&exec);
     }
 #endif

Modified: trunk/Source/WebCore/bindings/js/JSFileCustom.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/js/JSFileCustom.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/js/JSFileCustom.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -28,6 +28,7 @@
 
 #include "JSDOMBinding.h"
 #include "JSDictionary.h"
+#include "ScriptExecutionContext.h"
 #include "WebKitBlobBuilder.h"
 #include <runtime/Error.h>
 #include <runtime/JSArray.h>
@@ -43,13 +44,16 @@
 EncodedJSValue JSC_HOST_CALL constructJSFile(ExecState& exec)
 {
     auto* constructor = jsCast<DOMConstructorObject*>(exec.callee());
+    ASSERT(constructor);
+
     ScriptExecutionContext* context = constructor->scriptExecutionContext();
     if (!context)
-        return throwVMError(&exec, createReferenceError(&exec, "File constructor associated document is unavailable"));
+        return throwConstructorScriptExecutionContextUnavailableError(exec, "File");
+    ASSERT(context->isDocument());
 
     JSValue arg = exec.argument(0);
     if (arg.isUndefinedOrNull())
-        return throwVMTypeError(&exec, ASCIILiteral("First argument to File constructor must be a valid sequence, was undefined or null"));
+        return throwArgumentTypeError(exec, 0, "fileBits", "File", nullptr, "sequence");
 
     unsigned blobPartsLength = 0;
     JSObject* blobParts = toJSSequence(exec, arg, blobPartsLength);
@@ -59,7 +63,7 @@
 
     arg = exec.argument(1);
     if (arg.isUndefined())
-        return throwVMTypeError(&exec, ASCIILiteral("Second argument to File constructor must be a valid string, was undefined"));
+        return throwArgumentTypeError(exec, 1, "filename", "File", nullptr, "DOMString");
 
     String filename = arg.toWTFString(&exec).replace('/', ':');
     if (exec.hadException())
@@ -72,7 +76,7 @@
     if (!arg.isUndefinedOrNull()) {
         JSObject* filePropertyBagObject = arg.getObject();
         if (!filePropertyBagObject)
-            return throwVMTypeError(&exec, ASCIILiteral("Third argument of the constructor is not of type Object"));
+            return throwArgumentTypeError(exec, 2, "options", "File", nullptr, "FilePropertyBag");
 
         // Create the dictionary wrapper from the initializer object.
         JSDictionary dictionary(&exec, filePropertyBagObject);

Modified: trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -32,6 +32,7 @@
 #include "HTMLFormElement.h"
 #include "JSCustomElementInterface.h"
 #include "JSNodeCustom.h"
+#include "ScriptExecutionContext.h"
 #include <runtime/InternalFunction.h>
 #include <runtime/JSWithScope.h>
 
@@ -43,10 +44,13 @@
 EncodedJSValue JSC_HOST_CALL constructJSHTMLElement(ExecState& exec)
 {
     auto* jsConstructor = jsCast<DOMConstructorObject*>(exec.callee());
+    ASSERT(jsConstructor);
 
     auto* context = jsConstructor->scriptExecutionContext();
-    if (!is<Document>(context))
-        return throwConstructorDocumentUnavailableError(exec, "HTMLElement");
+    if (!context)
+        return throwConstructorScriptExecutionContextUnavailableError(exec, "HTMLElement");
+    ASSERT(context->isDocument());
+
     auto& document = downcast<Document>(*context);
 
     auto* window = document.domWindow();

Modified: trunk/Source/WebCore/bindings/js/JSMediaSessionCustom.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/js/JSMediaSessionCustom.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/js/JSMediaSessionCustom.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -42,10 +42,11 @@
 EncodedJSValue JSC_HOST_CALL constructJSMediaSession(ExecState& exec)
 {
     auto* castedThis = jsCast<DOMConstructorObject*>(exec.callee());
+    ASSERT(castedThis);
 
     auto* context = castedThis->scriptExecutionContext();
     if (!context)
-        return throwConstructorDocumentUnavailableError(exec, "MediaSession");
+        return throwConstructorScriptExecutionContextUnavailableError(exec, "MediaSession");
 
     String kind;
     if (exec.argumentCount() > 0) {

Modified: trunk/Source/WebCore/bindings/js/JSMutationObserverCustom.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/js/JSMutationObserverCustom.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/js/JSMutationObserverCustom.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -50,7 +50,7 @@
     JSObject* object = exec.uncheckedArgument(0).getObject();
     CallData callData;
     if (!object || object->methodTable()->getCallData(object, callData) == CallType::None)
-        return throwVMTypeError(&exec, ASCIILiteral("Callback argument must be a function"));
+        return throwArgumentTypeError(exec, 0, "callback", "MutationObserver", nullptr, "MutationCallback");
 
     DOMConstructorObject* jsConstructor = jsCast<DOMConstructorObject*>(exec.callee());
     auto callback = JSMutationCallback::create(object, jsConstructor->globalObject());

Modified: trunk/Source/WebCore/bindings/js/JSReadableStreamPrivateConstructors.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/js/JSReadableStreamPrivateConstructors.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/js/JSReadableStreamPrivateConstructors.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -43,7 +43,7 @@
 {
     JSReadableStream* stream = jsDynamicCast<JSReadableStream*>(exec.argument(0));
     if (!stream)
-        return throwVMTypeError(&exec, ASCIILiteral("ReadableStreamDefaultReader constructor parameter is not a ReadableStream"));
+        return throwArgumentTypeError(exec, 0, "stream", "ReadableStreamReader", nullptr, "ReadableStream");
 
     JSValue jsFunction = stream->get(&exec, Identifier::fromString(&exec, "getReader"));
 

Modified: trunk/Source/WebCore/bindings/js/JSWorkerCustom.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/js/JSWorkerCustom.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/js/JSWorkerCustom.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -67,7 +67,7 @@
         return JSValue::encode(JSValue());
     }
 
-    return JSValue::encode(asObject(toJSNewlyCreated(&exec, jsConstructor->globalObject(), WTFMove(worker))));
+    return JSValue::encode(toJSNewlyCreated(&exec, jsConstructor->globalObject(), WTFMove(worker)));
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (205007 => 205008)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-08-26 08:04:02 UTC (rev 205008)
@@ -4303,7 +4303,7 @@
                 # https://heycam.github.io/webidl/#es-callback-function
                 $invokeMethod = "JSCallbackData::CallbackType::Function";
                 $propertyToLookup = "Identifier()";
-                push(@implContent, "    UNUSED_PARAM(state);\n");    
+                push(@implContent, "    UNUSED_PARAM(state);\n");
             } elsif ($numFunctions > 1) {
                 # The callback interface has more than one operation so we should not call the user object as a function.
                 # instead, we should look for a property with the same name as the operation on the user object.
@@ -4777,7 +4777,7 @@
         if ($codeGenerator->IsRefPtrType($innerType)) {
             AddToImplIncludes("JS${innerType}.h", $conditional);
         }
-        
+
         return "jsArray(state, $globalObject, $value)" if $codeGenerator->IsSequenceType($type);
         return "jsFrozenArray(state, $globalObject, $value)" if $codeGenerator->IsFrozenArrayType($type);
     }
@@ -4879,7 +4879,7 @@
             my $conditionalString = $codeGenerator->GenerateConditionalStringFromAttributeValue($conditional);
             push(@implContent, "#if ${conditionalString}\n");
         }
-        
+
         if ("@$specials[$i]" =~ m/Function/) {
             $firstTargetType = "static_cast<NativeFunction>";
         } elsif ("@$specials[$i]" =~ m/Builtin/) {
@@ -5220,14 +5220,15 @@
 template<> EncodedJSValue JSC_HOST_CALL ${constructorClassName}::construct(ExecState* state)
 {
     auto* jsConstructor = jsCast<${constructorClassName}*>(state->callee());
+    ASSERT(jsConstructor);
 
     if (!jsConstructor->scriptExecutionContext())
-        return throwVMError(state, createReferenceError(state, "Constructor associated execution context is unavailable"));
+        return throwConstructorScriptExecutionContextUnavailableError(*state, \"${visibleInterfaceName}\");
 
     if (UNLIKELY(state->argumentCount() < 1))
         return throwVMError(state, createNotEnoughArgumentsError(state));
 
-    AtomicString eventType = state->argument(0).toString(state)->toAtomicString(state);
+    AtomicString eventType = state->uncheckedArgument(0).toString(state)->toAtomicString(state);
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
 
@@ -5248,7 +5249,7 @@
     }
 
     Ref<${interfaceName}> event = ${interfaceName}::createForBindings(eventType, eventInit);
-    return JSValue::encode(toJS(state, jsConstructor->globalObject(), event));
+    return JSValue::encode(CREATE_DOM_WRAPPER(jsConstructor->globalObject(), ${interfaceName}, WTFMove(event)));
 }
 
 bool fill${interfaceName}Init(${interfaceName}Init& eventInit, JSDictionary& dictionary)
@@ -5303,6 +5304,7 @@
 
             push(@$outputArray, "{\n");
             push(@$outputArray, "    auto* castedThis = jsCast<${constructorClassName}*>(state->callee());\n");
+            push(@$outputArray, "    ASSERT(castedThis);\n");
 
             my @constructorArgList;
 
@@ -5330,7 +5332,7 @@
                 push(@constructorArgList, "*context");
                 push(@$outputArray, "    ScriptExecutionContext* context = castedThis->scriptExecutionContext();\n");
                 push(@$outputArray, "    if (UNLIKELY(!context))\n");
-                push(@$outputArray, "        return throwConstructorDocumentUnavailableError(*state, \"${visibleInterfaceName}\");\n");
+                push(@$outputArray, "        return throwConstructorScriptExecutionContextUnavailableError(*state, \"${visibleInterfaceName}\");\n");
             }
             if ($codeGenerator->ExtendedAttributeContains($interface->extendedAttributes->{"ConstructorCallWith"}, "Document")) {
                 $implIncludes{"Document.h"} = 1;
@@ -5337,7 +5339,7 @@
                 push(@constructorArgList, "document");
                 push(@$outputArray, "    ScriptExecutionContext* context = castedThis->scriptExecutionContext();\n");
                 push(@$outputArray, "    if (UNLIKELY(!context))\n");
-                push(@$outputArray, "        return throwConstructorDocumentUnavailableError(*state, \"${visibleInterfaceName}\");\n");
+                push(@$outputArray, "        return throwConstructorScriptExecutionContextUnavailableError(*state, \"${visibleInterfaceName}\");\n");
                 push(@$outputArray, "    ASSERT(context->isDocument());\n");
                 push(@$outputArray, "    auto& document = downcast<Document>(*context);\n");
             }
@@ -5380,7 +5382,7 @@
                  push(@$outputArray, "        return JSValue::encode(jsUndefined());\n");
             }
 
-            push(@$outputArray, "    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));\n");
+            push(@$outputArray, "    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));\n");
             push(@$outputArray, "}\n\n");
         }
     }

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -74,14 +74,15 @@
 template<> EncodedJSValue JSC_HOST_CALL JSTestEventConstructorConstructor::construct(ExecState* state)
 {
     auto* jsConstructor = jsCast<JSTestEventConstructorConstructor*>(state->callee());
+    ASSERT(jsConstructor);
 
     if (!jsConstructor->scriptExecutionContext())
-        return throwVMError(state, createReferenceError(state, "Constructor associated execution context is unavailable"));
+        return throwConstructorScriptExecutionContextUnavailableError(*state, "TestEventConstructor");
 
     if (UNLIKELY(state->argumentCount() < 1))
         return throwVMError(state, createNotEnoughArgumentsError(state));
 
-    AtomicString eventType = state->argument(0).toString(state)->toAtomicString(state);
+    AtomicString eventType = state->uncheckedArgument(0).toString(state)->toAtomicString(state);
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
 
@@ -102,7 +103,7 @@
     }
 
     Ref<TestEventConstructor> event = TestEventConstructor::createForBindings(eventType, eventInit);
-    return JSValue::encode(toJS(state, jsConstructor->globalObject(), event));
+    return JSValue::encode(CREATE_DOM_WRAPPER(jsConstructor->globalObject(), TestEventConstructor, WTFMove(event)));
 }
 
 bool fillTestEventConstructorInit(TestEventConstructorInit& eventInit, JSDictionary& dictionary)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -223,6 +223,7 @@
 template<> EncodedJSValue JSC_HOST_CALL JSTestInterfaceConstructor::construct(ExecState* state)
 {
     auto* castedThis = jsCast<JSTestInterfaceConstructor*>(state->callee());
+    ASSERT(castedThis);
     if (UNLIKELY(state->argumentCount() < 1))
         return throwVMError(state, createNotEnoughArgumentsError(state));
     ExceptionCode ec = 0;
@@ -234,13 +235,13 @@
         return JSValue::encode(jsUndefined());
     ScriptExecutionContext* context = castedThis->scriptExecutionContext();
     if (UNLIKELY(!context))
-        return throwConstructorDocumentUnavailableError(*state, "TestInterface");
+        return throwConstructorScriptExecutionContextUnavailableError(*state, "TestInterface");
     auto object = TestInterface::create(*context, WTFMove(str1), WTFMove(str2), ec);
     if (UNLIKELY(ec)) {
         setDOMException(state, ec);
         return JSValue::encode(JSValue());
     }
-    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
+    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
 }
 
 template<> JSValue JSTestInterfaceConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -83,6 +83,7 @@
 template<> EncodedJSValue JSC_HOST_CALL JSTestNamedConstructorNamedConstructor::construct(ExecState* state)
 {
     auto* castedThis = jsCast<JSTestNamedConstructorNamedConstructor*>(state->callee());
+    ASSERT(castedThis);
     if (UNLIKELY(state->argumentCount() < 1))
         return throwVMError(state, createNotEnoughArgumentsError(state));
     ExceptionCode ec = 0;
@@ -100,7 +101,7 @@
         setDOMException(state, ec);
         return JSValue::encode(JSValue());
     }
-    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
+    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
 }
 
 template<> JSValue JSTestNamedConstructorNamedConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -80,8 +80,9 @@
 template<> EncodedJSValue JSC_HOST_CALL JSTestNodeConstructor::construct(ExecState* state)
 {
     auto* castedThis = jsCast<JSTestNodeConstructor*>(state->callee());
+    ASSERT(castedThis);
     auto object = TestNode::create();
-    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
+    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
 }
 
 template<> JSValue JSTestNodeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -1099,6 +1099,7 @@
 template<> EncodedJSValue JSC_HOST_CALL JSTestObjConstructor::construct(ExecState* state)
 {
     auto* castedThis = jsCast<JSTestObjConstructor*>(state->callee());
+    ASSERT(castedThis);
     if (UNLIKELY(state->argumentCount() < 2))
         return throwVMError(state, createNotEnoughArgumentsError(state));
     if (UNLIKELY(!state->argument(0).isObject()))
@@ -1109,11 +1110,11 @@
     auto testCallbackFunction = JSTestCallbackFunction::create(asObject(state->uncheckedArgument(1)), castedThis->globalObject());
     ScriptExecutionContext* context = castedThis->scriptExecutionContext();
     if (UNLIKELY(!context))
-        return throwConstructorDocumentUnavailableError(*state, "TestObject");
+        return throwConstructorScriptExecutionContextUnavailableError(*state, "TestObject");
     ASSERT(context->isDocument());
     auto& document = downcast<Document>(*context);
     auto object = TestObj::create(document, *testCallback, *testCallbackFunction);
-    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
+    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
 }
 
 template<> JSValue JSTestObjConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -68,6 +68,7 @@
 static inline EncodedJSValue constructJSTestOverloadedConstructors1(ExecState* state)
 {
     auto* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(state->callee());
+    ASSERT(castedThis);
     if (UNLIKELY(state->argumentCount() < 1))
         return throwVMError(state, createNotEnoughArgumentsError(state));
     auto arrayBuffer = toArrayBuffer(state->argument(0));
@@ -76,12 +77,13 @@
     if (UNLIKELY(!arrayBuffer))
         return throwArgumentTypeError(*state, 0, "arrayBuffer", "TestOverloadedConstructors", nullptr, "ArrayBuffer");
     auto object = TestOverloadedConstructors::create(*arrayBuffer);
-    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
+    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
 }
 
 static inline EncodedJSValue constructJSTestOverloadedConstructors2(ExecState* state)
 {
     auto* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(state->callee());
+    ASSERT(castedThis);
     if (UNLIKELY(state->argumentCount() < 1))
         return throwVMError(state, createNotEnoughArgumentsError(state));
     auto arrayBufferView = toArrayBufferView(state->argument(0));
@@ -90,12 +92,13 @@
     if (UNLIKELY(!arrayBufferView))
         return throwArgumentTypeError(*state, 0, "arrayBufferView", "TestOverloadedConstructors", nullptr, "ArrayBufferView");
     auto object = TestOverloadedConstructors::create(*arrayBufferView);
-    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
+    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
 }
 
 static inline EncodedJSValue constructJSTestOverloadedConstructors3(ExecState* state)
 {
     auto* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(state->callee());
+    ASSERT(castedThis);
     if (UNLIKELY(state->argumentCount() < 1))
         return throwVMError(state, createNotEnoughArgumentsError(state));
     auto blob = JSBlob::toWrapped(state->argument(0));
@@ -102,12 +105,13 @@
     if (UNLIKELY(!blob))
         return throwArgumentTypeError(*state, 0, "blob", "TestOverloadedConstructors", nullptr, "Blob");
     auto object = TestOverloadedConstructors::create(*blob);
-    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
+    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
 }
 
 static inline EncodedJSValue constructJSTestOverloadedConstructors4(ExecState* state)
 {
     auto* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(state->callee());
+    ASSERT(castedThis);
     if (UNLIKELY(state->argumentCount() < 1))
         return throwVMError(state, createNotEnoughArgumentsError(state));
     auto string = state->argument(0).toWTFString(state);
@@ -114,17 +118,18 @@
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
     auto object = TestOverloadedConstructors::create(WTFMove(string));
-    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
+    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
 }
 
 static inline EncodedJSValue constructJSTestOverloadedConstructors5(ExecState* state)
 {
     auto* castedThis = jsCast<JSTestOverloadedConstructorsConstructor*>(state->callee());
+    ASSERT(castedThis);
     Vector<int32_t> longArgs = toNativeArguments<int32_t>(*state, 0);
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
     auto object = TestOverloadedConstructors::create(WTFMove(longArgs));
-    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
+    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
 }
 
 template<> EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsConstructor::construct(ExecState* state)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructorsWithSequence.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -67,16 +67,18 @@
 static inline EncodedJSValue constructJSTestOverloadedConstructorsWithSequence1(ExecState* state)
 {
     auto* castedThis = jsCast<JSTestOverloadedConstructorsWithSequenceConstructor*>(state->callee());
+    ASSERT(castedThis);
     auto sequenceOfStrings = state->argument(0).isUndefined() ? Vector<String>() : toNativeArray<String>(*state, state->uncheckedArgument(0));
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
     auto object = TestOverloadedConstructorsWithSequence::create(WTFMove(sequenceOfStrings));
-    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
+    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
 }
 
 static inline EncodedJSValue constructJSTestOverloadedConstructorsWithSequence2(ExecState* state)
 {
     auto* castedThis = jsCast<JSTestOverloadedConstructorsWithSequenceConstructor*>(state->callee());
+    ASSERT(castedThis);
     if (UNLIKELY(state->argumentCount() < 1))
         return throwVMError(state, createNotEnoughArgumentsError(state));
     auto string = state->argument(0).toWTFString(state);
@@ -83,7 +85,7 @@
     if (UNLIKELY(state->hadException()))
         return JSValue::encode(jsUndefined());
     auto object = TestOverloadedConstructorsWithSequence::create(WTFMove(string));
-    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
+    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
 }
 
 template<> EncodedJSValue JSC_HOST_CALL JSTestOverloadedConstructorsWithSequenceConstructor::construct(ExecState* state)

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp (205007 => 205008)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp	2016-08-26 07:36:01 UTC (rev 205007)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp	2016-08-26 08:04:02 UTC (rev 205008)
@@ -125,6 +125,7 @@
 template<> EncodedJSValue JSC_HOST_CALL JSTestTypedefsConstructor::construct(ExecState* state)
 {
     auto* castedThis = jsCast<JSTestTypedefsConstructor*>(state->callee());
+    ASSERT(castedThis);
     if (UNLIKELY(state->argumentCount() < 2))
         return throwVMError(state, createNotEnoughArgumentsError(state));
     auto hello = state->argument(0).toWTFString(state);
@@ -134,7 +135,7 @@
         return throwArgumentMustBeFunctionError(*state, 1, "testCallback", "TestTypedefs", nullptr);
     auto testCallback = JSTestCallback::create(asObject(state->uncheckedArgument(1)), castedThis->globalObject());
     auto object = TestTypedefs::create(WTFMove(hello), *testCallback);
-    return JSValue::encode(asObject(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))));
+    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
 }
 
 template<> JSValue JSTestTypedefsConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to