You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[JSContext evaluteScript:] calls JSEvaluteScript with startingLineNumber 0, later interpreted as a oneBasedInt
https://bugs.webkit.org/show_bug.cgi?id=127648
Reviewed by Geoffrey Garen.
The actual bug being fixed here is that the line number for
scripts evaluated via the JSC APIs is now sane. However,
there is no good infrastructure in place right now to test that.
* API/tests/testapi.c:
(main):
* API/tests/testapi.mm:
(testObjectiveCAPI):
Add tests for exception line numbers and handling of bad
startingLineNumbers in public APIs. These tests were already
passing, I just add them to make sure they are not regressed
in the future.
* API/JSBase.cpp:
(JSEvaluateScript):
(JSCheckScriptSyntax):
* API/JSBase.h:
* API/JSObjectRef.cpp:
(JSObjectMakeFunction):
* API/JSObjectRef.h:
* API/JSScriptRef.cpp:
* API/JSScriptRefPrivate.h:
* API/JSStringRef.h:
- Clarify documentation that startingLineNumber is 1 based and clamped.
- Add clamping in the implementation to put sane values into JSC::SourceProvider.
* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::InspectorDebuggerAgent::didParseSource):
Remove the FIXME now that the SourceProvider is giving us expected values.
Canonical link: https://commits.webkit.org/145762@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162918 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Copy file name to clipboardExpand all lines: Source/JavaScriptCore/API/JSBase.h
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@
20
20
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
21
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
22
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
24
*/
25
25
26
26
#ifndef JSBase_h
@@ -102,7 +102,7 @@ extern "C" {
102
102
@param script A JSString containing the script to evaluate.
103
103
@param thisObject The object to use as "this," or NULL to use the global object as "this."
104
104
@param sourceURL A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions.
105
-
@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions.
105
+
@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. The value is one-based, so the first line is line 1 and invalid values are clamped to 1.
106
106
@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
107
107
@result The JSValue that results from evaluating script, or NULL if an exception is thrown.
@param script A JSString containing the script to check for syntax errors.
116
116
@param sourceURL A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions.
117
-
@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions.
117
+
@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. The value is one-based, so the first line is line 1 and invalid values are clamped to 1.
118
118
@param exception A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception.
119
119
@result true if the script is syntactically correct, otherwise false.
120
120
*/
121
121
JS_EXPORTboolJSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception);
122
122
123
123
/*!
124
124
@function JSGarbageCollect
125
-
@abstract Performs a JavaScript garbage collection.
125
+
@abstract Performs a JavaScript garbage collection.
126
126
@param ctx The execution context to use.
127
-
@discussion JavaScript values that are on the machine stack, in a register,
128
-
protected by JSValueProtect, set as the global object of an execution context,
127
+
@discussion JavaScript values that are on the machine stack, in a register,
128
+
protected by JSValueProtect, set as the global object of an execution context,
129
129
or reachable from any such value will not be collected.
130
130
131
-
During JavaScript execution, you are not required to call this function; the
131
+
During JavaScript execution, you are not required to call this function; the
132
132
JavaScript engine will garbage collect as needed. JavaScript values created
133
133
within a context group are automatically destroyed when the last reference
@param parameterNames A JSString array containing the names of the function's parameters. Pass NULL if parameterCount is 0.
486
486
@param body A JSString containing the script to use as the function's body.
487
487
@param sourceURL A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions.
488
-
@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions.
488
+
@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. The value is one-based, so the first line is line 1 and invalid values are clamped to 1.
489
489
@param exception A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception.
490
490
@result A JSObject that is a function, or NULL if either body or parameterNames contains a syntax error. The object's prototype will be the default function prototype.
491
491
@discussion Use this method when you want to execute a script repeatedly, to avoid the cost of re-parsing the script before each execution.
Copy file name to clipboardExpand all lines: Source/JavaScriptCore/API/JSScriptRefPrivate.h
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ extern "C" {
42
42
@abstract Creates a script reference from an ascii string, without copying or taking ownership of the string
43
43
@param contextGroup The context group the script is to be used in.
44
44
@param url The source url to be reported in errors and exceptions.
45
-
@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions.
45
+
@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. The value is one-based, so the first line is line 1 and invalid values are clamped to 1.
46
46
@param source The source string. This is required to be pure ASCII and to never be deallocated.
47
47
@param length The length of the source string.
48
48
@param errorMessage A pointer to a JSStringRef in which to store the parse error message if the source is not valid. Pass NULL if you do not care to store an error message.
@abstract Creates a script reference from a string
59
59
@param contextGroup The context group the script is to be used in.
60
60
@param url The source url to be reported in errors and exceptions.
61
-
@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions.
61
+
@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. The value is one-based, so the first line is line 1 and invalid values are clamped to 1.
62
62
@param source The source string.
63
63
@param errorMessage A pointer to a JSStringRef in which to store the parse error message if the source is not valid. Pass NULL if you do not care to store an error message.
64
64
@param errorLine A pointer to an int in which to store the line number of a parser error. Pass NULL if you do not care to store an error line.
0 commit comments