Changeset 181889 in webkit
- Timestamp:
- Mar 24, 2015, 12:30:05 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 11 added
- 40 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function-expected.txt (modified) (1 diff)
-
LayoutTests/fast/dom/call-a-constructor-as-a-function-expected.txt (modified) (1 diff)
-
LayoutTests/fast/regex/dom/cross-frame-callable-expected.txt (modified) (1 diff)
-
LayoutTests/fast/selectors/closest-general-expected.txt (modified) (1 diff)
-
LayoutTests/http/tests/security/xss-DENIED-window-index-assign-expected.txt (modified) (1 diff)
-
LayoutTests/js/dom/exception-thrown-from-new-expected.txt (modified) (1 diff)
-
LayoutTests/js/exception-for-nonobject-expected.txt (modified) (1 diff)
-
LayoutTests/js/exception-function-apply-expected.txt (added)
-
LayoutTests/js/exception-function-apply.html (added)
-
LayoutTests/js/exception-in-expected.txt (added)
-
LayoutTests/js/exception-in.html (added)
-
LayoutTests/js/exception-instanceof-expected.txt (added)
-
LayoutTests/js/exception-instanceof.html (added)
-
LayoutTests/js/instance-of-immediates-expected.txt (modified) (1 diff)
-
LayoutTests/js/script-tests/exception-function-apply.js (added)
-
LayoutTests/js/script-tests/exception-in.js (added)
-
LayoutTests/js/script-tests/exception-instanceof.js (added)
-
LayoutTests/js/typedarray-constructors-expected.txt (modified) (1 diff)
-
LayoutTests/platform/mac-wk2/plugins/npruntime/object-from-destroyed-plugin-expected.txt (modified) (1 diff)
-
LayoutTests/platform/mac-wk2/plugins/npruntime/object-from-destroyed-plugin-in-subframe-expected.txt (modified) (1 diff)
-
LayoutTests/platform/mac/css3/selectors3/xhtml/css3-modsel-15c-expected.txt (modified) (1 diff)
-
LayoutTests/platform/mac/css3/selectors3/xml/css3-modsel-15c-expected.txt (modified) (1 diff)
-
LayoutTests/plugins/npruntime/object-from-destroyed-plugin-expected.txt (modified) (1 diff)
-
LayoutTests/plugins/npruntime/object-from-destroyed-plugin-in-subframe-expected.txt (modified) (1 diff)
-
LayoutTests/plugins/npruntime/plugin-scriptable-object-invoke-default-expected.txt (modified) (1 diff)
-
LayoutTests/sputnik/Conformance/12_Statement/12.1_Block/S12.1_A4_T1-expected.txt (modified) (1 diff)
-
LayoutTests/sputnik/Conformance/13_Function_Definition/S13_A17_T2-expected.txt (modified) (1 diff)
-
LayoutTests/sputnik/Conformance/15_Native_Objects/15.1_The_Global_Object/S15.1_A2_T1-expected.txt (modified) (1 diff)
-
LayoutTests/sputnik/Conformance/15_Native_Objects/15.2_Object/15.2.4/S15.2.4_A3-expected.txt (modified) (1 diff)
-
LayoutTests/svg/dom/svgpath-out-of-bounds-getPathSeg-expected.txt (modified) (1 diff)
-
Source/JavaScriptCore/CMakeLists.txt (modified) (1 diff)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj (modified) (2 diffs)
-
Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters (modified) (2 diffs)
-
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (modified) (7 diffs)
-
Source/JavaScriptCore/interpreter/Interpreter.cpp (modified) (1 diff)
-
Source/JavaScriptCore/jit/JITOperations.cpp (modified) (4 diffs)
-
Source/JavaScriptCore/llint/LLIntSlowPaths.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/CommonSlowPaths.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/ErrorInstance.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/ErrorInstance.h (modified) (3 diffs)
-
Source/JavaScriptCore/runtime/ExceptionHelpers.cpp (modified) (4 diffs)
-
Source/JavaScriptCore/runtime/ExceptionHelpers.h (modified) (3 diffs)
-
Source/JavaScriptCore/runtime/JSObject.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/RuntimeType.cpp (added)
-
Source/JavaScriptCore/runtime/RuntimeType.h (added)
-
Source/JavaScriptCore/runtime/TypeProfilerLog.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/TypeSet.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/TypeSet.h (modified) (3 diffs)
-
Source/JavaScriptCore/runtime/VM.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r181888 r181889 1 2015-03-24 Saam Barati <saambarati1@gmail.com> 2 3 Improve error messages in JSC 4 https://bugs.webkit.org/show_bug.cgi?id=141869 5 6 Reviewed by Geoffrey Garen. 7 8 * fast/dom/NodeList/nodelist-item-call-as-function-expected.txt: 9 * fast/dom/call-a-constructor-as-a-function-expected.txt: 10 * fast/regex/dom/cross-frame-callable-expected.txt: 11 * fast/selectors/closest-general-expected.txt: 12 * http/tests/security/xss-DENIED-window-index-assign-expected.txt: 13 * js/dom/exception-thrown-from-new-expected.txt: 14 * js/exception-for-nonobject-expected.txt: 15 * js/exception-function-apply-expected.txt: Added. 16 * js/exception-function-apply.html: Added. 17 * js/exception-in-expected.txt: Added. 18 * js/exception-in.html: Added. 19 * js/exception-instanceof-expected.txt: Added. 20 * js/exception-instanceof.html: Added. 21 * js/instance-of-immediates-expected.txt: 22 * js/script-tests/exception-function-apply.js: Added. 23 * js/script-tests/exception-in.js: Added. 24 * js/script-tests/exception-instanceof.js: Added. 25 * js/typedarray-constructors-expected.txt: 26 * platform/mac-wk2/plugins/npruntime/object-from-destroyed-plugin-expected.txt: 27 * platform/mac-wk2/plugins/npruntime/object-from-destroyed-plugin-in-subframe-expected.txt: 28 * platform/mac/css3/selectors3/xhtml/css3-modsel-15c-expected.txt: 29 * platform/mac/css3/selectors3/xml/css3-modsel-15c-expected.txt: 30 * plugins/npruntime/object-from-destroyed-plugin-expected.txt: 31 * plugins/npruntime/object-from-destroyed-plugin-in-subframe-expected.txt: 32 * plugins/npruntime/plugin-scriptable-object-invoke-default-expected.txt: 33 * sputnik/Conformance/12_Statement/12.1_Block/S12.1_A4_T1-expected.txt: 34 * sputnik/Conformance/13_Function_Definition/S13_A17_T2-expected.txt: 35 * sputnik/Conformance/15_Native_Objects/15.1_The_Global_Object/S15.1_A2_T1-expected.txt: 36 * sputnik/Conformance/15_Native_Objects/15.2_Object/15.2.4/S15.2.4_A3-expected.txt: 37 * svg/dom/svgpath-out-of-bounds-getPathSeg-expected.txt: 38 1 39 2015-03-23 Yoav Weiss <yoav@yoav.ws> 2 40 -
trunk/LayoutTests/fast/dom/NodeList/nodelist-item-call-as-function-expected.txt
r152871 r181889 4 4 5 5 6 PASS nodeList(0) threw exception TypeError: NodeList is not a function (evaluating 'nodeList(0)').6 PASS nodeList(0) threw exception TypeError: nodeList is not a function. (In 'nodeList(0)', 'nodeList' is an instance of NodeList). 7 7 PASS successfullyParsed is true 8 8 -
trunk/LayoutTests/fast/dom/call-a-constructor-as-a-function-expected.txt
r178310 r181889 5 5 6 6 SKIP AudioContext is not implemented. 7 PASS FormData() threw exception TypeError: FormData Constructor is not a function (evaluating 'FormData()').8 PASS EventSource() threw exception TypeError: EventSource Constructor is not a function (evaluating 'EventSource()').9 PASS FileReader() threw exception TypeError: FileReader Constructor is not a function (evaluating 'FileReader()').10 PASS Audio() threw exception TypeError: Audio Constructor is not a function (evaluating 'Audio()').11 PASS Image() threw exception TypeError: Image Constructor is not a function (evaluating 'Image()').12 PASS Option() threw exception TypeError: Option Constructor is not a function (evaluating 'Option()').13 PASS MessageChannel() threw exception TypeError: MessageChannel Constructor is not a function (evaluating 'MessageChannel()').14 PASS WebKitCSSMatrix() threw exception TypeError: WebKitCSSMatrix Constructor is not a function (evaluating 'WebKitCSSMatrix()').15 PASS WebKitPoint() threw exception TypeError: WebKitPoint Constructor is not a function (evaluating 'WebKitPoint()').16 PASS WebSocket() threw exception TypeError: WebSocket Constructor is not a function (evaluating 'WebSocket()').17 PASS Worker() threw exception TypeError: Worker Constructor is not a function (evaluating 'Worker()').18 PASS XMLHttpRequest() threw exception TypeError: XMLHttpRequest Constructor is not a function (evaluating 'XMLHttpRequest()').19 PASS XSLTProcessor() threw exception TypeError: XSLTProcessor Constructor is not a function (evaluating 'XSLTProcessor()').7 PASS FormData() threw exception TypeError: FormData is not a function. (In 'FormData()', 'FormData' is an instance of FormDataConstructor). 8 PASS EventSource() threw exception TypeError: EventSource is not a function. (In 'EventSource()', 'EventSource' is an instance of EventSourceConstructor). 9 PASS FileReader() threw exception TypeError: FileReader is not a function. (In 'FileReader()', 'FileReader' is an instance of FileReaderConstructor). 10 PASS Audio() threw exception TypeError: Audio is not a function. (In 'Audio()', 'Audio' is an instance of AudioConstructor). 11 PASS Image() threw exception TypeError: Image is not a function. (In 'Image()', 'Image' is an instance of ImageConstructor). 12 PASS Option() threw exception TypeError: Option is not a function. (In 'Option()', 'Option' is an instance of OptionConstructor). 13 PASS MessageChannel() threw exception TypeError: MessageChannel is not a function. (In 'MessageChannel()', 'MessageChannel' is an instance of MessageChannelConstructor). 14 PASS WebKitCSSMatrix() threw exception TypeError: WebKitCSSMatrix is not a function. (In 'WebKitCSSMatrix()', 'WebKitCSSMatrix' is an instance of WebKitCSSMatrixConstructor). 15 PASS WebKitPoint() threw exception TypeError: WebKitPoint is not a function. (In 'WebKitPoint()', 'WebKitPoint' is an instance of WebKitPointConstructor). 16 PASS WebSocket() threw exception TypeError: WebSocket is not a function. (In 'WebSocket()', 'WebSocket' is an instance of WebSocketConstructor). 17 PASS Worker() threw exception TypeError: Worker is not a function. (In 'Worker()', 'Worker' is an instance of WorkerConstructor). 18 PASS XMLHttpRequest() threw exception TypeError: XMLHttpRequest is not a function. (In 'XMLHttpRequest()', 'XMLHttpRequest' is an instance of XMLHttpRequestConstructor). 19 PASS XSLTProcessor() threw exception TypeError: XSLTProcessor is not a function. (In 'XSLTProcessor()', 'XSLTProcessor' is an instance of XSLTProcessorConstructor). 20 20 PASS successfullyParsed is true 21 21 -
trunk/LayoutTests/fast/regex/dom/cross-frame-callable-expected.txt
r156066 r181889 1 PASS re('a') threw exception TypeError: RegExp is not a function (evaluating 're('a')').1 PASS re('a') threw exception TypeError: re is not a function. (In 're('a')', 're' is an instance of RegExp). 2 2 PASS re.exec('a') is ['a'] 3 3 PASS successfullyParsed is true -
trunk/LayoutTests/fast/selectors/closest-general-expected.txt
r174324 r181889 44 44 PASS sour.closest("a") is a 45 45 PASS document.closest is undefined 46 PASS document.closest() threw exception TypeError: undefined is not a function (evaluating 'document.closest()').46 PASS document.closest() threw exception TypeError: document.closest is not a function. (In 'document.closest()', 'document.closest' is undefined). 47 47 PASS theTarget.closest() threw exception TypeError: Not enough arguments. 48 48 PASS theTarget.closest("") threw exception Error: SyntaxError: DOM Exception 12. -
trunk/LayoutTests/http/tests/security/xss-DENIED-window-index-assign-expected.txt
r153526 r181889 1 1 ALERT: undefined 2 CONSOLE MESSAGE: line 1: TypeError: undefined is not a function (evaluating 'parent[0].f()')2 CONSOLE MESSAGE: line 1: TypeError: parent[0].f is not a function. (In 'parent[0].f()', 'parent[0].f' is undefined) 3 3 4 4 This test passes if the access is forbidden. -
trunk/LayoutTests/js/dom/exception-thrown-from-new-expected.txt
r156066 r181889 2 2 3 3 FAIL: e1 should be 'TypeError: 'undefined' is not a constructor (evaluating 'new f')' but instead is 'TypeError: undefined is not a constructor (evaluating 'new f')'. 4 FAIL: e2 should be 'TypeError: 'undefined' is not a function (evaluating 'g()')' but instead is 'TypeError: undefined is not a function (evaluating 'g()')'.4 FAIL: e2 should be 'TypeError: 'undefined' is not a function (evaluating 'g()')' but instead is 'TypeError: g is not a function. (In 'g()', 'g' is undefined)'. 5 5 -
trunk/LayoutTests/js/exception-for-nonobject-expected.txt
r152871 r181889 5 5 6 6 PASS new {}.undefined threw exception TypeError: undefined is not a constructor (evaluating 'new {}.undefined'). 7 PASS 1 instanceof {}.undefined threw exception TypeError: undefined is not a valid argument for 'instanceof'(evaluating '1 instanceof {}.undefined').7 PASS 1 instanceof {}.undefined threw exception TypeError: {}.undefined is not a function. (evaluating '1 instanceof {}.undefined'). 8 8 PASS successfullyParsed is true 9 9 -
trunk/LayoutTests/js/instance-of-immediates-expected.txt
r152871 r181889 4 4 5 5 6 PASS (1 instanceof 1) threw exception TypeError: 1 is not a valid argument for 'instanceof'(evaluating '1 instanceof 1').7 PASS ({} instanceof 1) threw exception TypeError: 1 is not a valid argument for 'instanceof'(evaluating '{} instanceof 1').8 PASS (obj instanceof 1) threw exception TypeError: 1 is not a valid argument for 'instanceof'(evaluating 'obj instanceof 1').9 PASS (1 instanceof {}) threw exception TypeError: Object is not a valid argument for 'instanceof'(evaluating '1 instanceof {}').10 PASS ({} instanceof {}) threw exception TypeError: Object is not a valid argument for 'instanceof'(evaluating '{} instanceof {}').11 PASS (obj instanceof {}) threw exception TypeError: Object is not a valid argument for 'instanceof'(evaluating 'obj instanceof {}').6 PASS (1 instanceof 1) threw exception TypeError: 1 is not a function. (evaluating '1 instanceof 1'). 7 PASS ({} instanceof 1) threw exception TypeError: 1 is not a function. (evaluating '{} instanceof 1'). 8 PASS (obj instanceof 1) threw exception TypeError: 1 is not a function. (evaluating 'obj instanceof 1'). 9 PASS (1 instanceof {}) threw exception TypeError: {} is not a function. (evaluating '1 instanceof {}'). 10 PASS ({} instanceof {}) threw exception TypeError: {} is not a function. (evaluating '{} instanceof {}'). 11 PASS (obj instanceof {}) threw exception TypeError: {} is not a function. (evaluating 'obj instanceof {}'). 12 12 PASS (1 instanceof Constructor) is false 13 13 PASS ({} instanceof Constructor) is false -
trunk/LayoutTests/js/typedarray-constructors-expected.txt
r161789 r181889 4 4 5 5 6 PASS Int8Array() threw exception TypeError: Function is not a function (evaluating 'Int8Array()').6 PASS Int8Array() threw exception TypeError: Int8Array is not a function. (In 'Int8Array()', 'Int8Array' is an instance of Function). 7 7 PASS new Int8Array() did not throw exception. 8 PASS Int16Array() threw exception TypeError: Function is not a function (evaluating 'Int16Array()').8 PASS Int16Array() threw exception TypeError: Int16Array is not a function. (In 'Int16Array()', 'Int16Array' is an instance of Function). 9 9 PASS new Int16Array() did not throw exception. 10 PASS Int32Array() threw exception TypeError: Function is not a function (evaluating 'Int32Array()').10 PASS Int32Array() threw exception TypeError: Int32Array is not a function. (In 'Int32Array()', 'Int32Array' is an instance of Function). 11 11 PASS new Int32Array() did not throw exception. 12 PASS Uint8Array() threw exception TypeError: Function is not a function (evaluating 'Uint8Array()').12 PASS Uint8Array() threw exception TypeError: Uint8Array is not a function. (In 'Uint8Array()', 'Uint8Array' is an instance of Function). 13 13 PASS new Uint8Array() did not throw exception. 14 PASS Uint16Array() threw exception TypeError: Function is not a function (evaluating 'Uint16Array()').14 PASS Uint16Array() threw exception TypeError: Uint16Array is not a function. (In 'Uint16Array()', 'Uint16Array' is an instance of Function). 15 15 PASS new Uint16Array() did not throw exception. 16 PASS Uint32Array() threw exception TypeError: Function is not a function (evaluating 'Uint32Array()').16 PASS Uint32Array() threw exception TypeError: Uint32Array is not a function. (In 'Uint32Array()', 'Uint32Array' is an instance of Function). 17 17 PASS new Uint32Array() did not throw exception. 18 PASS Uint8ClampedArray() threw exception TypeError: Function is not a function (evaluating 'Uint8ClampedArray()').18 PASS Uint8ClampedArray() threw exception TypeError: Uint8ClampedArray is not a function. (In 'Uint8ClampedArray()', 'Uint8ClampedArray' is an instance of Function). 19 19 PASS new Uint8ClampedArray() did not throw exception. 20 PASS Float32Array() threw exception TypeError: F unction is not a function (evaluating 'Float32Array()').20 PASS Float32Array() threw exception TypeError: Float32Array is not a function. (In 'Float32Array()', 'Float32Array' is an instance of Function). 21 21 PASS new Float32Array() did not throw exception. 22 PASS Float64Array() threw exception TypeError: F unction is not a function (evaluating 'Float64Array()').22 PASS Float64Array() threw exception TypeError: Float64Array is not a function. (In 'Float64Array()', 'Float64Array' is an instance of Function). 23 23 PASS new Float64Array() did not throw exception. 24 PASS DataView(new ArrayBuffer()) threw exception TypeError: Function is not a function (evaluating 'DataView(new ArrayBuffer())').24 PASS DataView(new ArrayBuffer()) threw exception TypeError: DataView is not a function. (In 'DataView(new ArrayBuffer())', 'DataView' is an instance of Function). 25 25 PASS new DataView(new ArrayBuffer()) did not throw exception. 26 26 PASS successfullyParsed is true -
trunk/LayoutTests/platform/mac-wk2/plugins/npruntime/object-from-destroyed-plugin-expected.txt
r152871 r181889 6 6 PASS testObject.gettingProperty threw exception ReferenceError: Trying to access object from destroyed plug-in.. 7 7 PASS testObject.settingProperty = 10 threw exception ReferenceError: Trying to access object from destroyed plug-in.. 8 PASS testObject() threw exception TypeError: NPObject is not a function (evaluating 'testObject()').8 PASS testObject() threw exception TypeError: testObject is not a function. (In 'testObject()', 'testObject' is an instance of NPObject). 9 9 PASS new testObject(); threw exception TypeError: NPObject is not a constructor (evaluating 'new testObject()'). 10 10 -
trunk/LayoutTests/platform/mac-wk2/plugins/npruntime/object-from-destroyed-plugin-in-subframe-expected.txt
r152871 r181889 6 6 PASS testObject.gettingProperty threw exception ReferenceError: Trying to access object from destroyed plug-in.. 7 7 PASS testObject.settingProperty = 10 threw exception ReferenceError: Trying to access object from destroyed plug-in.. 8 PASS testObject() threw exception TypeError: NPObject is not a function (evaluating 'testObject()').8 PASS testObject() threw exception TypeError: testObject is not a function. (In 'testObject()', 'testObject' is an instance of NPObject). 9 9 PASS new testObject(); threw exception TypeError: NPObject is not a constructor (evaluating 'new testObject()'). 10 10 -
trunk/LayoutTests/platform/mac/css3/selectors3/xhtml/css3-modsel-15c-expected.txt
r177774 r181889 1 CONSOLE MESSAGE: line 27: TypeError: undefined is not a function (evaluating 'document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'div')[0].setIdAttribute('title', true)')1 CONSOLE MESSAGE: line 27: TypeError: document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'div')[0].setIdAttribute is not a function. (In 'document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'div')[0].setIdAttribute('title', true)', 'document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'div')[0].setIdAttribute' is undefined) 2 2 layer at (0,0) size 800x600 3 3 RenderView at (0,0) size 800x600 -
trunk/LayoutTests/platform/mac/css3/selectors3/xml/css3-modsel-15c-expected.txt
r177774 r181889 1 CONSOLE MESSAGE: line 9: TypeError: undefined is not a function (evaluating 'document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'div')[0].setIdAttribute('title', true)')1 CONSOLE MESSAGE: line 9: TypeError: document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'div')[0].setIdAttribute is not a function. (In 'document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'div')[0].setIdAttribute('title', true)', 'document.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'div')[0].setIdAttribute' is undefined) 2 2 layer at (0,0) size 800x600 3 3 RenderView at (0,0) size 800x600 -
trunk/LayoutTests/plugins/npruntime/object-from-destroyed-plugin-expected.txt
r152871 r181889 6 6 PASS testObject.gettingProperty threw exception ReferenceError: Trying to access object from destroyed plug-in.. 7 7 PASS testObject.settingProperty = 10 threw exception ReferenceError: Trying to access object from destroyed plug-in.. 8 PASS testObject() threw exception TypeError: ProxyRuntimeObject is not a function (evaluating 'testObject()').8 PASS testObject() threw exception TypeError: testObject is not a function. (In 'testObject()', 'testObject' is an instance of ProxyRuntimeObject). 9 9 PASS new testObject(); threw exception TypeError: ProxyRuntimeObject is not a constructor (evaluating 'new testObject()'). 10 10 -
trunk/LayoutTests/plugins/npruntime/object-from-destroyed-plugin-in-subframe-expected.txt
r152871 r181889 6 6 PASS testObject.gettingProperty threw exception ReferenceError: Trying to access object from destroyed plug-in.. 7 7 PASS testObject.settingProperty = 10 threw exception ReferenceError: Trying to access object from destroyed plug-in.. 8 PASS testObject() threw exception TypeError: ProxyRuntimeObject is not a function (evaluating 'testObject()').8 PASS testObject() threw exception TypeError: testObject is not a function. (In 'testObject()', 'testObject' is an instance of ProxyRuntimeObject). 9 9 PASS new testObject(); threw exception TypeError: ProxyRuntimeObject is not a constructor (evaluating 'new testObject()'). 10 10 -
trunk/LayoutTests/plugins/npruntime/plugin-scriptable-object-invoke-default-expected.txt
r152871 r181889 8 8 PASS pluginWithInvokeDefault() is 1 9 9 PASS typeof(pluginWithoutInvokeDefault) is 'object' 10 PASS pluginWithoutInvokeDefault() threw exception TypeError: HTMLEmbedElement is not a function (evaluating 'pluginWithoutInvokeDefault()').10 PASS pluginWithoutInvokeDefault() threw exception TypeError: pluginWithoutInvokeDefault is not a function. (In 'pluginWithoutInvokeDefault()', 'pluginWithoutInvokeDefault' is an instance of HTMLEmbedElement). 11 11 -
trunk/LayoutTests/sputnik/Conformance/12_Statement/12.1_Block/S12.1_A4_T1-expected.txt
r181121 r181889 1 1 S12.1_A4_T1 2 2 3 PASS TypeError: Object is not a function (evaluating '{__func}()')3 PASS TypeError: {__func} is not a function. (In '{__func}()', '{__func}' is an instance of Object) 4 4 5 5 TEST COMPLETE -
trunk/LayoutTests/sputnik/Conformance/13_Function_Definition/S13_A17_T2-expected.txt
r152871 r181889 1 1 S13_A17_T2 2 2 3 TypeError: undefined is not a function (evaluating '__func()')3 TypeError: __func is not a function. (In '__func()', '__func' is undefined) 4 4 PASS 5 5 -
trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.1_The_Global_Object/S15.1_A2_T1-expected.txt
r152871 r181889 1 1 S15.1_A2_T1 2 2 3 PASS TypeError: Window is not a function (evaluating 'this()')3 PASS TypeError: this is not a function. (In 'this()', 'this' is an instance of Window) 4 4 5 5 TEST COMPLETE -
trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.2_Object/15.2.4/S15.2.4_A3-expected.txt
r152871 r181889 1 1 S15.2.4_A3 2 2 3 TypeError: Object is not a function (evaluating 'Object.prototype()')3 TypeError: Object.prototype is not a function. (In 'Object.prototype()', 'Object.prototype' is an instance of Object) 4 4 PASS 5 5 -
trunk/LayoutTests/svg/dom/svgpath-out-of-bounds-getPathSeg-expected.txt
r152871 r181889 6 6 PASS path.pathSegList.initialize(); threw exception TypeError: Not enough arguments. 7 7 PASS path.getPathSegAtLength(0) is 0 8 PASS path.insertItemBefore(null, 0) threw exception TypeError: undefined is not a function (evaluating 'path.insertItemBefore(null, 0)').9 PASS path.replaceItem(null, 0) threw exception TypeError: undefined is not a function (evaluating 'path.replaceItem(null, 0)').10 PASS path.appendItem(null) threw exception TypeError: undefined is not a function (evaluating 'path.appendItem(null)').8 PASS path.insertItemBefore(null, 0) threw exception TypeError: path.insertItemBefore is not a function. (In 'path.insertItemBefore(null, 0)', 'path.insertItemBefore' is undefined). 9 PASS path.replaceItem(null, 0) threw exception TypeError: path.replaceItem is not a function. (In 'path.replaceItem(null, 0)', 'path.replaceItem' is undefined). 10 PASS path.appendItem(null) threw exception TypeError: path.appendItem is not a function. (In 'path.appendItem(null)', 'path.appendItem' is undefined). 11 11 List correctly initialised. 12 12 PASS path.getPathSegAtLength(0) is 0 13 PASS path.insertItemBefore(null, 0) threw exception TypeError: undefined is not a function (evaluating 'path.insertItemBefore(null, 0)').14 PASS path.replaceItem(null, 0) threw exception TypeError: undefined is not a function (evaluating 'path.replaceItem(null, 0)').15 PASS path.appendItem(null) threw exception TypeError: undefined is not a function (evaluating 'path.appendItem(null)').13 PASS path.insertItemBefore(null, 0) threw exception TypeError: path.insertItemBefore is not a function. (In 'path.insertItemBefore(null, 0)', 'path.insertItemBefore' is undefined). 14 PASS path.replaceItem(null, 0) threw exception TypeError: path.replaceItem is not a function. (In 'path.replaceItem(null, 0)', 'path.replaceItem' is undefined). 15 PASS path.appendItem(null) threw exception TypeError: path.appendItem is not a function. (In 'path.appendItem(null)', 'path.appendItem' is undefined). 16 16 PASS successfullyParsed is true 17 17 -
trunk/Source/JavaScriptCore/CMakeLists.txt
r181601 r181889 536 536 runtime/RegExpObject.cpp 537 537 runtime/RegExpPrototype.cpp 538 runtime/RuntimeType.cpp 538 539 runtime/SamplingCounter.cpp 539 540 runtime/SetConstructor.cpp -
trunk/Source/JavaScriptCore/ChangeLog
r181887 r181889 1 2015-03-24 Saam Barati <saambarati1@gmail.com> 2 3 Improve error messages in JSC 4 https://bugs.webkit.org/show_bug.cgi?id=141869 5 6 Reviewed by Geoffrey Garen. 7 8 JavaScriptCore has some unintuitive error messages associated 9 with certain common errors. This patch changes some specific 10 error messages to be more understandable and also creates a 11 mechanism that will allow for easy modification of error messages 12 in the future. The specific errors we change are not a function 13 errors and invalid parameter errors. 14 15 * CMakeLists.txt: 16 * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: 17 * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: 18 * JavaScriptCore.xcodeproj/project.pbxproj: 19 * interpreter/Interpreter.cpp: 20 (JSC::sizeOfVarargs): 21 * jit/JITOperations.cpp: 22 op_throw_static_error always has a JSString as its argument. 23 There is no need to dance around this, and we should assert 24 that this always holds. This JSString represents the error 25 message we want to display to the user, so there is no need 26 to pass it into errorDescriptionForValue which will now place 27 quotes around the string. 28 29 * llint/LLIntSlowPaths.cpp: 30 (JSC::LLInt::LLINT_SLOW_PATH_DECL): 31 * runtime/CommonSlowPaths.h: 32 (JSC::CommonSlowPaths::opIn): 33 * runtime/ErrorInstance.cpp: 34 (JSC::ErrorInstance::ErrorInstance): 35 * runtime/ErrorInstance.h: 36 (JSC::ErrorInstance::hasSourceAppender): 37 (JSC::ErrorInstance::sourceAppender): 38 (JSC::ErrorInstance::setSourceAppender): 39 (JSC::ErrorInstance::clearSourceAppender): 40 (JSC::ErrorInstance::setRuntimeTypeForCause): 41 (JSC::ErrorInstance::runtimeTypeForCause): 42 (JSC::ErrorInstance::clearRuntimeTypeForCause): 43 (JSC::ErrorInstance::appendSourceToMessage): Deleted. 44 (JSC::ErrorInstance::setAppendSourceToMessage): Deleted. 45 (JSC::ErrorInstance::clearAppendSourceToMessage): Deleted. 46 * runtime/ExceptionHelpers.cpp: 47 (JSC::errorDescriptionForValue): 48 (JSC::defaultApproximateSourceError): 49 (JSC::defaultSourceAppender): 50 (JSC::functionCallBase): 51 (JSC::notAFunctionSourceAppender): 52 (JSC::invalidParameterInSourceAppender): 53 (JSC::invalidParameterInstanceofSourceAppender): 54 (JSC::createError): 55 (JSC::createInvalidFunctionApplyParameterError): 56 (JSC::createInvalidInParameterError): 57 (JSC::createInvalidInstanceofParameterError): 58 (JSC::createNotAConstructorError): 59 (JSC::createNotAFunctionError): 60 (JSC::createNotAnObjectError): 61 (JSC::createInvalidParameterError): Deleted. 62 * runtime/ExceptionHelpers.h: 63 * runtime/JSObject.cpp: 64 (JSC::JSObject::hasInstance): 65 * runtime/RuntimeType.cpp: Added. 66 (JSC::runtimeTypeForValue): 67 (JSC::runtimeTypeAsString): 68 * runtime/RuntimeType.h: Added. 69 * runtime/TypeProfilerLog.cpp: 70 (JSC::TypeProfilerLog::processLogEntries): 71 * runtime/TypeSet.cpp: 72 (JSC::TypeSet::getRuntimeTypeForValue): Deleted. 73 * runtime/TypeSet.h: 74 * runtime/VM.cpp: 75 (JSC::appendSourceToError): 76 (JSC::VM::throwException): 77 1 78 2015-03-23 Filip Pizlo <fpizlo@apple.com> 2 79 -
trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
r181841 r181889 803 803 <ClCompile Include="..\runtime\RegExpObject.cpp" /> 804 804 <ClCompile Include="..\runtime\RegExpPrototype.cpp" /> 805 <ClCompile Include="..\runtime\RuntimeType.cpp" /> 805 806 <ClCompile Include="..\runtime\SamplingCounter.cpp" /> 806 807 <ClCompile Include="..\runtime\SetConstructor.cpp" /> … … 1615 1616 <ClInclude Include="..\runtime\Reject.h" /> 1616 1617 <ClInclude Include="..\runtime\RuntimeFlags.h" /> 1618 <ClInclude Include="..\runtime\RuntimeType.h" /> 1617 1619 <ClInclude Include="..\runtime\SamplingCounter.h" /> 1618 1620 <ClInclude Include="..\runtime\SetConstructor.h" /> -
trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
r181628 r181889 802 802 <Filter>runtime</Filter> 803 803 </ClCompile> 804 <ClCompile Include="..\runtime\RuntimeType.cpp"> 805 <Filter>runtime</Filter> 806 </ClCompile> 804 807 <ClCompile Include="..\runtime\SamplingCounter.cpp"> 805 808 <Filter>runtime</Filter> … … 2869 2872 </ClInclude> 2870 2873 <ClInclude Include="..\runtime\RuntimeFlags.h"> 2874 <Filter>runtime</Filter> 2875 </ClInclude> 2876 <ClInclude Include="..\runtime\RuntimeType.h"> 2871 2877 <Filter>runtime</Filter> 2872 2878 </ClInclude> -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r181841 r181889 911 911 52678F8F1A031009006A306D /* BasicBlockLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 52678F8D1A031009006A306D /* BasicBlockLocation.h */; settings = {ATTRIBUTES = (Private, ); }; }; 912 912 52678F911A04177C006A306D /* ControlFlowProfiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 52678F901A04177C006A306D /* ControlFlowProfiler.h */; settings = {ATTRIBUTES = (Private, ); }; }; 913 527773DE1AAF83AC00BDE7E8 /* RuntimeType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 527773DD1AAF83AC00BDE7E8 /* RuntimeType.cpp */; }; 913 914 52B310FB1974AE610080857C /* FunctionHasExecutedCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 52B310FA1974AE610080857C /* FunctionHasExecutedCache.h */; settings = {ATTRIBUTES = (Private, ); }; }; 914 915 52B310FD1974AE870080857C /* FunctionHasExecutedCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52B310FC1974AE870080857C /* FunctionHasExecutedCache.cpp */; }; … … 916 917 52B311011975B4670080857C /* TypeLocationCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 52B311001975B4670080857C /* TypeLocationCache.h */; settings = {ATTRIBUTES = (Private, ); }; }; 917 918 52B717B51A0597E1007AF4F3 /* ControlFlowProfiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52B717B41A0597E1007AF4F3 /* ControlFlowProfiler.cpp */; }; 919 52C0611F1AA51E1C00B4ADBA /* RuntimeType.h in Headers */ = {isa = PBXBuildFile; fileRef = 52C0611D1AA51E1B00B4ADBA /* RuntimeType.h */; settings = {ATTRIBUTES = (Private, ); }; }; 918 920 52C952B719A289850069B386 /* TypeProfiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 52C952B619A289850069B386 /* TypeProfiler.h */; settings = {ATTRIBUTES = (Private, ); }; }; 919 921 52C952B919A28A1C0069B386 /* TypeProfiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52C952B819A28A1C0069B386 /* TypeProfiler.cpp */; }; … … 2568 2570 52678F8D1A031009006A306D /* BasicBlockLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BasicBlockLocation.h; sourceTree = "<group>"; }; 2569 2571 52678F901A04177C006A306D /* ControlFlowProfiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ControlFlowProfiler.h; sourceTree = "<group>"; }; 2572 527773DD1AAF83AC00BDE7E8 /* RuntimeType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RuntimeType.cpp; sourceTree = "<group>"; }; 2570 2573 52B310FA1974AE610080857C /* FunctionHasExecutedCache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FunctionHasExecutedCache.h; sourceTree = "<group>"; }; 2571 2574 52B310FC1974AE870080857C /* FunctionHasExecutedCache.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FunctionHasExecutedCache.cpp; sourceTree = "<group>"; }; … … 2573 2576 52B311001975B4670080857C /* TypeLocationCache.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TypeLocationCache.h; sourceTree = "<group>"; }; 2574 2577 52B717B41A0597E1007AF4F3 /* ControlFlowProfiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ControlFlowProfiler.cpp; sourceTree = "<group>"; }; 2578 52C0611D1AA51E1B00B4ADBA /* RuntimeType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuntimeType.h; sourceTree = "<group>"; }; 2575 2579 52C952B619A289850069B386 /* TypeProfiler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TypeProfiler.h; sourceTree = "<group>"; }; 2576 2580 52C952B819A28A1C0069B386 /* TypeProfiler.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TypeProfiler.cpp; sourceTree = "<group>"; }; … … 4565 4569 0FB7F39115ED8E3800F167B2 /* Reject.h */, 4566 4570 70B0A9D01A9B66200001306A /* RuntimeFlags.h */, 4571 527773DD1AAF83AC00BDE7E8 /* RuntimeType.cpp */, 4572 52C0611D1AA51E1B00B4ADBA /* RuntimeType.h */, 4567 4573 0F7700911402FF280078EB39 /* SamplingCounter.cpp */, 4568 4574 0F77008E1402FDD60078EB39 /* SamplingCounter.h */, … … 5460 5466 A1A009C11831A26E00CF8711 /* ARM64Assembler.h in Headers */, 5461 5467 86D3B2C410156BDE002865E7 /* ARMAssembler.h in Headers */, 5468 52C0611F1AA51E1C00B4ADBA /* RuntimeType.h in Headers */, 5462 5469 C442CB251A6CDB8C005D3D7C /* JSInputs.json in Headers */, 5463 5470 52678F911A04177C006A306D /* ControlFlowProfiler.h in Headers */, … … 7097 7104 0F13E04E16164A1F00DC8DE7 /* IndexingType.cpp in Sources */, 7098 7105 0FCEFACA1805E75500472CE4 /* InitializeLLVM.cpp in Sources */, 7106 527773DE1AAF83AC00BDE7E8 /* RuntimeType.cpp in Sources */, 7099 7107 A513E5B7185B8BD3007E95AD /* InjectedScript.cpp in Sources */, 7100 7108 0FBF158C19B7A53100695DD0 /* DFGBlockSet.cpp in Sources */, -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r180595 r181889 143 143 length = 0; 144 144 else if (!arguments.isObject()) { 145 callFrame->vm().throwException(callFrame, createInvalid ParameterError(callFrame, "Function.prototype.apply",arguments));145 callFrame->vm().throwException(callFrame, createInvalidFunctionApplyParameterError(callFrame, arguments)); 146 146 return 0; 147 147 } else if (asObject(arguments)->classInfo() == Arguments::info()) -
trunk/Source/JavaScriptCore/jit/JITOperations.cpp
r181814 r181889 201 201 202 202 if (!base->isObject()) { 203 vm->throwException(exec, createInvalid ParameterError(exec, "in", base));203 vm->throwException(exec, createInvalidInParameterError(exec, base)); 204 204 return JSValue::encode(jsUndefined()); 205 205 } … … 227 227 228 228 if (!base->isObject()) { 229 vm->throwException(exec, createInvalid ParameterError(exec, "in", base));229 vm->throwException(exec, createInvalidInParameterError(exec, base)); 230 230 return JSValue::encode(jsUndefined()); 231 231 } … … 967 967 VM& vm = exec->vm(); 968 968 NativeCallFrameTracer tracer(&vm, exec); 969 970 String message = errorDescriptionForValue(exec, JSValue::decode(encodedValue))->value(exec); 969 JSValue errorMessageValue = JSValue::decode(encodedValue); 970 RELEASE_ASSERT(errorMessageValue.isString()); 971 String errorMessage = asString(errorMessageValue)->value(exec); 971 972 if (referenceErrorFlag) 972 vm.throwException(exec, createReferenceError(exec, message));973 vm.throwException(exec, createReferenceError(exec, errorMessage)); 973 974 else 974 vm.throwException(exec, createTypeError(exec, message));975 vm.throwException(exec, createTypeError(exec, errorMessage)); 975 976 } 976 977 … … 1349 1350 } 1350 1351 1351 vm.throwException(exec, createInvalid ParameterError(exec, "instanceof", baseVal));1352 vm.throwException(exec, createInvalidInstanceofParameterError(exec, baseVal)); 1352 1353 return JSValue::encode(JSValue()); 1353 1354 } -
trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
r181814 r181889 559 559 } 560 560 } 561 LLINT_THROW(createInvalid ParameterError(exec, "instanceof", baseVal));561 LLINT_THROW(createInvalidInstanceofParameterError(exec, baseVal)); 562 562 } 563 563 … … 1306 1306 { 1307 1307 LLINT_BEGIN(); 1308 JSValue errorMessageValue = LLINT_OP_C(1).jsValue(); 1309 RELEASE_ASSERT(errorMessageValue.isString()); 1310 String errorMessage = asString(errorMessageValue)->value(exec); 1308 1311 if (pc[2].u.operand) 1309 LLINT_THROW(createReferenceError(exec, error DescriptionForValue(exec, LLINT_OP_C(1).jsValue())->value(exec)));1312 LLINT_THROW(createReferenceError(exec, errorMessage)); 1310 1313 else 1311 LLINT_THROW(createTypeError(exec, error DescriptionForValue(exec, LLINT_OP_C(1).jsValue())->value(exec)));1314 LLINT_THROW(createTypeError(exec, errorMessage)); 1312 1315 } 1313 1316 -
trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.h
r181814 r181889 73 73 { 74 74 if (!baseVal.isObject()) { 75 exec->vm().throwException(exec, createInvalid ParameterError(exec, "in", baseVal));75 exec->vm().throwException(exec, createInvalidInParameterError(exec, baseVal)); 76 76 return false; 77 77 } -
trunk/Source/JavaScriptCore/runtime/ErrorInstance.cpp
r171824 r181889 33 33 ErrorInstance::ErrorInstance(VM& vm, Structure* structure) 34 34 : JSNonFinalObject(vm, structure) 35 , m_appendSourceToMessage(false)36 35 { 37 36 } -
trunk/Source/JavaScriptCore/runtime/ErrorInstance.h
r173269 r181889 23 23 24 24 #include "Interpreter.h" 25 #include " JSObject.h"25 #include "RuntimeType.h" 26 26 #include "SourceProvider.h" 27 27 … … 51 51 } 52 52 53 bool appendSourceToMessage() { return m_appendSourceToMessage; } 54 void setAppendSourceToMessage() { m_appendSourceToMessage = true; } 55 void clearAppendSourceToMessage() { m_appendSourceToMessage = false; } 53 enum SourceTextWhereErrorOccurred { FoundExactSource, FoundApproximateSource }; 54 typedef String (*SourceAppender) (const String& originalMessage, const String& sourceText, RuntimeType, SourceTextWhereErrorOccurred); 55 56 bool hasSourceAppender() const { return !!m_sourceAppender; } 57 SourceAppender sourceAppender() const { return m_sourceAppender; } 58 void setSourceAppender(SourceAppender appender) { m_sourceAppender = appender; } 59 void clearSourceAppender() { m_sourceAppender = nullptr; } 60 void setRuntimeTypeForCause(RuntimeType type) { m_runtimeTypeForCause = type; } 61 RuntimeType runtimeTypeForCause() const { return m_runtimeTypeForCause; } 62 void clearRuntimeTypeForCause() { m_runtimeTypeForCause = TypeNothing; } 56 63 57 64 protected: … … 60 67 void finishCreation(VM&, const String&, Vector<StackFrame> = Vector<StackFrame>()); 61 68 62 bool m_appendSourceToMessage; 69 SourceAppender m_sourceAppender { nullptr }; 70 RuntimeType m_runtimeTypeForCause { TypeNothing }; 63 71 }; 64 72 -
trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp
r179429 r181889 33 33 #include "CallFrame.h" 34 34 #include "ErrorHandlingScope.h" 35 #include "ErrorInstance.h"36 35 #include "JSGlobalObjectFunctions.h" 37 #include "JSObject.h"38 36 #include "JSNotAnObject.h" 39 37 #include "Interpreter.h" 40 38 #include "Nodes.h" 41 39 #include "JSCInlines.h" 40 #include "RuntimeType.h" 41 #include <wtf/text/StringBuilder.h> 42 #include <wtf/text/StringView.h> 42 43 43 44 namespace JSC { … … 107 108 return vm.smallStrings.falseString(); 108 109 if (v.isString()) 109 return js Cast<JSString*>(v.asCell());110 return jsString(&vm, makeString('"', asString(v)->value(exec), '"')); 110 111 if (v.isObject()) { 111 112 CallData callData; … … 113 114 if (object->methodTable()->getCallData(object, callData) != CallTypeNone) 114 115 return vm.smallStrings.functionString(); 115 return jsString(exec, object->methodTable()->className(object));116 return jsString(exec, JSObject::calculatedClassName(object)); 116 117 } 117 118 … … 121 122 } 122 123 123 JSObject* createError(ExecState* exec, ErrorFactory errorFactory, JSValue value, const String& message) 124 static String defaultApproximateSourceError(const String& originalMessage, const String& sourceText) 125 { 126 return makeString(originalMessage, " (near '...", sourceText, "...')"); 127 } 128 129 static String defaultSourceAppender(const String& originalMessage, const String& sourceText, RuntimeType, ErrorInstance::SourceTextWhereErrorOccurred occurrence) 130 { 131 if (occurrence == ErrorInstance::FoundApproximateSource) 132 return defaultApproximateSourceError(originalMessage, sourceText); 133 134 ASSERT(occurrence == ErrorInstance::FoundExactSource); 135 return makeString(originalMessage, " (evaluating '", sourceText, "')"); 136 } 137 138 static String functionCallBase(const String& sourceText) 139 { 140 // This function retrieves the 'foo.bar' substring from 'foo.bar(baz)'. 141 unsigned idx = sourceText.length() - 1; 142 if (sourceText[idx] != ')') { 143 // For function calls that have many new lines in between their open parenthesis 144 // and their closing parenthesis, the text range passed into the message appender 145 // will not inlcude the text in between these parentheses, it will just be the desired 146 // text that precedes the parentheses. 147 return sourceText; 148 } 149 150 unsigned parenStack = 1; 151 bool isInMultiLineComment = false; 152 idx -= 1; 153 // Note that we're scanning text right to left instead of the more common left to right, 154 // so syntax detection is backwards. 155 while (parenStack > 0) { 156 UChar curChar = sourceText[idx]; 157 if (isInMultiLineComment) { 158 if (curChar == '*' && sourceText[idx - 1] == '/') { 159 isInMultiLineComment = false; 160 idx -= 1; 161 } 162 } else if (curChar == '(') 163 parenStack -= 1; 164 else if (curChar == ')') 165 parenStack += 1; 166 else if (curChar == '/' && sourceText[idx - 1] == '*') { 167 isInMultiLineComment = true; 168 idx -= 1; 169 } 170 171 idx -= 1; 172 } 173 174 return sourceText.left(idx + 1); 175 } 176 177 static String notAFunctionSourceAppender(const String& originalMessage, const String& sourceText, RuntimeType type, ErrorInstance::SourceTextWhereErrorOccurred occurrence) 178 { 179 ASSERT(type != TypeFunction); 180 181 if (occurrence == ErrorInstance::FoundApproximateSource) 182 return defaultApproximateSourceError(originalMessage, sourceText); 183 184 ASSERT(occurrence == ErrorInstance::FoundExactSource); 185 auto notAFunctionIndex = originalMessage.reverseFind("is not a function"); 186 RELEASE_ASSERT(notAFunctionIndex != notFound); 187 StringView displayValue; 188 if (originalMessage.is8Bit()) 189 displayValue = StringView(originalMessage.characters8(), notAFunctionIndex - 1); 190 else 191 displayValue = StringView(originalMessage.characters16(), notAFunctionIndex - 1); 192 193 String base = functionCallBase(sourceText); 194 StringBuilder builder; 195 builder.append(base); 196 builder.appendLiteral(" is not a function. (In '"); 197 builder.append(sourceText); 198 builder.appendLiteral("', '"); 199 builder.append(base); 200 builder.appendLiteral("' is "); 201 if (type == TypeObject) 202 builder.appendLiteral("an instance of "); 203 builder.append(displayValue); 204 builder.appendLiteral(")"); 205 206 return builder.toString(); 207 } 208 209 static String invalidParameterInSourceAppender(const String& originalMessage, const String& sourceText, RuntimeType, ErrorInstance::SourceTextWhereErrorOccurred occurrence) 210 { 211 ASSERT(type != TypeObject); 212 213 if (occurrence == ErrorInstance::FoundApproximateSource) 214 return defaultApproximateSourceError(originalMessage, sourceText); 215 216 ASSERT(occurrence == ErrorInstance::FoundExactSource); 217 auto inIndex = sourceText.reverseFind("in"); 218 RELEASE_ASSERT(inIndex != notFound); 219 if (sourceText.find("in") != inIndex) 220 return makeString(originalMessage, " (evaluating '", sourceText, "')"); 221 222 static const unsigned inLength = 2; 223 String rightHandSide = sourceText.substring(inIndex + inLength).simplifyWhiteSpace(); 224 return makeString(rightHandSide, " is not an Object. (evaluating '", sourceText, "')"); 225 } 226 227 static String invalidParameterInstanceofSourceAppender(const String& originalMessage, const String& sourceText, RuntimeType, ErrorInstance::SourceTextWhereErrorOccurred occurrence) 228 { 229 if (occurrence == ErrorInstance::FoundApproximateSource) 230 return defaultApproximateSourceError(originalMessage, sourceText); 231 232 ASSERT(occurrence == ErrorInstance::FoundExactSource); 233 auto instanceofIndex = sourceText.reverseFind("instanceof"); 234 RELEASE_ASSERT(instanceofIndex != notFound); 235 if (sourceText.find("instanceof") != instanceofIndex) 236 return makeString(originalMessage, " (evaluating '", sourceText, "')"); 237 238 static const unsigned instanceofLength = 10; 239 String rightHandSide = sourceText.substring(instanceofIndex + instanceofLength).simplifyWhiteSpace(); 240 return makeString(rightHandSide, " is not a function. (evaluating '", sourceText, "')"); 241 } 242 243 JSObject* createError(ExecState* exec, ErrorFactory errorFactory, JSValue value, const String& message, ErrorInstance::SourceAppender appender) 124 244 { 125 245 String errorMessage = makeString(errorDescriptionForValue(exec, value)->value(exec), ' ', message); 126 246 JSObject* exception = errorFactory(exec, errorMessage); 127 247 ASSERT(exception->isErrorInstance()); 128 static_cast<ErrorInstance*>(exception)->setAppendSourceToMessage(); 248 static_cast<ErrorInstance*>(exception)->setSourceAppender(appender); 249 static_cast<ErrorInstance*>(exception)->setRuntimeTypeForCause(runtimeTypeForValue(value)); 129 250 return exception; 130 251 } 131 252 132 JSObject* createInvalidParameterError(ExecState* exec, const char* op, JSValue value) 133 { 134 return createError(exec, createTypeError, value, makeString("is not a valid argument for '", op, '\'')); 253 JSObject* createInvalidFunctionApplyParameterError(ExecState* exec, JSValue value) 254 { 255 JSObject* exception = createTypeError(exec, makeString("second argument to Function.prototype.apply must be an Array-like object")); 256 ASSERT(exception->isErrorInstance()); 257 static_cast<ErrorInstance*>(exception)->setSourceAppender(defaultSourceAppender); 258 static_cast<ErrorInstance*>(exception)->setRuntimeTypeForCause(runtimeTypeForValue(value)); 259 return exception; 260 } 261 262 JSObject* createInvalidInParameterError(ExecState* exec, JSValue value) 263 { 264 return createError(exec, createTypeError, value, makeString("is not an Object."), invalidParameterInSourceAppender); 265 } 266 267 JSObject* createInvalidInstanceofParameterError(ExecState* exec, JSValue value) 268 { 269 return createError(exec, createTypeError, value, makeString("is not a function."), invalidParameterInstanceofSourceAppender); 135 270 } 136 271 137 272 JSObject* createNotAConstructorError(ExecState* exec, JSValue value) 138 273 { 139 return createError(exec, createTypeError, value, ASCIILiteral("is not a constructor") );274 return createError(exec, createTypeError, value, ASCIILiteral("is not a constructor"), defaultSourceAppender); 140 275 } 141 276 142 277 JSObject* createNotAFunctionError(ExecState* exec, JSValue value) 143 278 { 144 return createError(exec, createTypeError, value, ASCIILiteral("is not a function") );279 return createError(exec, createTypeError, value, ASCIILiteral("is not a function"), notAFunctionSourceAppender); 145 280 } 146 281 147 282 JSObject* createNotAnObjectError(ExecState* exec, JSValue value) 148 283 { 149 return createError(exec, createTypeError, value, ASCIILiteral("is not an object") );284 return createError(exec, createTypeError, value, ASCIILiteral("is not an object"), defaultSourceAppender); 150 285 } 151 286 -
trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.h
r171391 r181889 30 30 #define ExceptionHelpers_h 31 31 32 #include "ErrorInstance.h" 32 33 #include "JSObject.h" 33 34 … … 39 40 bool isTerminatedExecutionException(JSObject*); 40 41 JS_EXPORT_PRIVATE bool isTerminatedExecutionException(JSValue); 41 JS_EXPORT_PRIVATE JSObject* createError(ExecState*, ErrorFactory, JSValue, const String& );42 JS_EXPORT_PRIVATE JSObject* createError(ExecState*, ErrorFactory, JSValue, const String&, ErrorInstance::SourceAppender); 42 43 JS_EXPORT_PRIVATE JSObject* createStackOverflowError(ExecState*); 43 44 JSObject* createStackOverflowError(JSGlobalObject*); … … 45 46 JSObject* createUndefinedVariableError(ExecState*, const Identifier&); 46 47 JSObject* createNotAnObjectError(ExecState*, JSValue); 47 JSObject* createInvalidParameterError(ExecState*, const char* op, JSValue); 48 JSObject* createInvalidFunctionApplyParameterError(ExecState*, JSValue); 49 JSObject* createInvalidInParameterError(ExecState*, JSValue); 50 JSObject* createInvalidInstanceofParameterError(ExecState*, JSValue); 48 51 JSObject* createNotAConstructorError(ExecState*, JSValue); 49 52 JSObject* createNotAFunctionError(ExecState*, JSValue); -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r180460 r181889 1472 1472 if (info.implementsHasInstance()) 1473 1473 return methodTable(vm)->customHasInstance(this, exec, value); 1474 vm.throwException(exec, createInvalid ParameterError(exec, "instanceof", this));1474 vm.throwException(exec, createInvalidInstanceofParameterError(exec, this)); 1475 1475 return false; 1476 1476 } -
trunk/Source/JavaScriptCore/runtime/TypeProfilerLog.cpp
r174789 r181889 76 76 } 77 77 78 RuntimeType type = TypeSet::getRuntimeTypeForValue(value);78 RuntimeType type = runtimeTypeForValue(value); 79 79 TypeLocation* location = entry->location; 80 80 location->m_lastSeenType = type; -
trunk/Source/JavaScriptCore/runtime/TypeSet.cpp
r179621 r181889 43 43 } 44 44 45 RuntimeType TypeSet::getRuntimeTypeForValue(JSValue v)46 {47 RuntimeType ret;48 if (v.isFunction())49 ret = TypeFunction;50 else if (v.isUndefined())51 ret = TypeUndefined;52 else if (v.isNull())53 ret = TypeNull;54 else if (v.isBoolean())55 ret = TypeBoolean;56 else if (v.isMachineInt())57 ret = TypeMachineInt;58 else if (v.isNumber())59 ret = TypeNumber;60 else if (v.isString())61 ret = TypeString;62 else if (v.isObject())63 ret = TypeObject;64 else65 ret = TypeNothing;66 67 return ret;68 }69 70 45 void TypeSet::addTypeInformation(RuntimeType type, PassRefPtr<StructureShape> prpNewShape, Structure* structure) 71 46 { -
trunk/Source/JavaScriptCore/runtime/TypeSet.h
r179621 r181889 27 27 #define TypeSet_h 28 28 29 #include "RuntimeType.h" 29 30 #include "StructureSet.h" 30 31 #include <wtf/HashSet.h> … … 46 47 47 48 namespace JSC { 48 49 class JSValue;50 51 enum RuntimeType : uint8_t {52 TypeNothing = 0x0,53 TypeFunction = 0x1,54 TypeUndefined = 0x2,55 TypeNull = 0x4,56 TypeBoolean = 0x8,57 TypeMachineInt = 0x10,58 TypeNumber = 0x20,59 TypeString = 0x40,60 TypeObject = 0x8061 };62 49 63 50 class StructureShape : public RefCounted<StructureShape> { … … 99 86 TypeSet(); 100 87 void addTypeInformation(RuntimeType, PassRefPtr<StructureShape>, Structure*); 101 static RuntimeType getRuntimeTypeForValue(JSValue);102 88 void invalidateCache(); 103 89 String dumpTypes() const; -
trunk/Source/JavaScriptCore/runtime/VM.cpp
r181887 r181889 76 76 #include "RegExpCache.h" 77 77 #include "RegExpObject.h" 78 #include "RuntimeType.h" 78 79 #include "SimpleTypedArrayController.h" 79 80 #include "SourceProviderCache.h" … … 541 542 static void appendSourceToError(CallFrame* callFrame, ErrorInstance* exception, unsigned bytecodeOffset) 542 543 { 543 exception->clearAppendSourceToMessage(); 544 ErrorInstance::SourceAppender appender = exception->sourceAppender(); 545 exception->clearSourceAppender(); 546 RuntimeType type = exception->runtimeTypeForCause(); 547 exception->clearRuntimeTypeForCause(); 544 548 545 549 if (!callFrame->codeBlock()->hasExpressionInfo()) … … 570 574 571 575 if (expressionStart < expressionStop) 572 message = makeString(message, " (evaluating '", codeBlock->source()->getRange(expressionStart, expressionStop), "')");576 message = appender(message, codeBlock->source()->getRange(expressionStart, expressionStop), type, ErrorInstance::FoundExactSource); 573 577 else { 574 578 // No range information, so give a few characters of context. … … 587 591 while (stop > expressionStart && isStrWhiteSpace((*data)[stop - 1])) 588 592 stop--; 589 message = makeString(message, " (near '...", codeBlock->source()->getRange(start, stop), "...')");593 message = appender(message, codeBlock->source()->getRange(start, stop), type, ErrorInstance::FoundApproximateSource); 590 594 } 591 595 … … 663 667 exception->putDirect(*this, Identifier(this, "sourceURL"), jsString(this, stackFrame.sourceURL), ReadOnly | DontDelete); 664 668 } 665 if (exception->isErrorInstance() && static_cast<ErrorInstance*>(exception)-> appendSourceToMessage()) {669 if (exception->isErrorInstance() && static_cast<ErrorInstance*>(exception)->hasSourceAppender()) { 666 670 FindFirstCallerFrameWithCodeblockFunctor functor(exec); 667 671 topCallFrame->iterate(functor);
Note:
See TracChangeset
for help on using the changeset viewer.