[GLIB] Handle strings containing null characters
https://bugs.webkit.org/show_bug.cgi?id=184450
Reviewed by Michael Catanzaro.
Source/JavaScriptCore:
We should be able to evaluate scripts containing null characters and to handle strings that contains them
too. In JavaScript strings are not null-terminated, they can contain null characters. This patch adds a length
parameter to jsc_context_valuate() to pass the script length (or -1 if it's null terminated), and new functions
jsc_value_new_string_from_bytes() and jsc_value_to_string_as_bytes() using GBytes to store strings that might
contain null characters.
(OpaqueJSString::create): Add a create constructor that takes the String.
(OpaqueJSString::OpaqueJSString): Add a constructor that takes the String.
(jsc_context_evaluate): Add length parameter.
(jsc_context_evaluate_with_source_uri): Ditto.
- API/glib/JSCContext.h:
- API/glib/JSCValue.cpp:
(jsc_value_new_string_from_bytes):
(jsc_value_to_string):
(jsc_value_to_string_as_bytes):
(jsc_value_object_is_instance_of): Pass length to evaluate.
- API/glib/JSCValue.h:
- API/glib/docs/jsc-glib-4.0-sections.txt:
Tools:
Add test case for strings with null characters and update all calls to evaluate to pass the script length.
- TestWebKitAPI/PlatformGTK.cmake:
- TestWebKitAPI/PlatformWPE.cmake:
- TestWebKitAPI/Tests/JavaScriptCore/glib/TestJSC.cpp:
(testJSCBasic):
(testJSCFunction):
(testJSCObject):
(testJSCClass):
(testJSCPrototypes):
(testJSCExceptions):
(testJSCPromises):
(testJSCGarbageCollector):
(testJSCWeakValue):
(testsJSCVirtualMachine):
(testsJSCAutocleanups):
- TestWebKitAPI/Tests/JavaScriptCore/glib/script.js: Added.
- TestWebKitAPI/Tests/WebKitGLib/DOMElementTest.cpp:
(DOMElementTest::testAutoFill):
- TestWebKitAPI/Tests/WebKitGLib/EditorTest.cpp:
(WebKitWebEditorTest::testSelectionChanged):
- TestWebKitAPI/Tests/WebKitGLib/FrameTest.cpp:
(WebKitFrameTest::testJavaScriptValues):
- TestWebKitAPI/Tests/WebKitGLib/WebExtensionTest.cpp:
(consoleMessageSentCallback):
(methodCallCallback):