[Webkit-unassigned] [Bug 173757] [WPE] Use JSC API to send script messages from web extension in tests

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Jun 23 04:06:45 PDT 2017


https://bugs.webkit.org/show_bug.cgi?id=173757

--- Comment #3 from Carlos Garcia Campos <cgarcia at igalia.com> ---
(In reply to Zan Dobersek from comment #2)
> Comment on attachment 313694 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=313694&action=review
> 
> > Tools/TestWebKitAPI/Tests/WebKitGLib/WebExtensionTest.cpp:266
> > +    GUniquePtr<char> escapedMessageString(static_cast<char*>(g_malloc(strlen(messageString.get()) * 2 + 1)));
> > +    char* src = messageString.get();
> > +    char* dest = escapedMessageString.get();
> > +    while (*src) {
> > +        if (*src == '"') {
> > +            *dest++ = '\\';
> > +            *dest++ = '"';
> > +        } else
> > +            *dest++ = *src;
> > +        src++;
> > +    }
> > +    *dest = '\0';
> 
> Would it be possible to use something like g_strescape() here? And use
> g_strcompress() on the receiving end, if necessary or possible?

The problem is not the receiving end, but JSC. If we pass something like

"Foo"bar"Baz" 

the script fails to run, so it never gets to the other end. We don't receive anything escaped in the other end. Also we would need to add ifdefs in the UI process side too. I started using g_strescape(), but the problem is that it escapes all non ascii characters, making the test fail, because one of the error messages uses utf8. So, since what we only need is escaping " because we are passing "%s" to JSC, I thought it was simple enough to do it here.

> Apart from that, src++ should be ++src.

Ok, just curiosity, does it make any difference in this case?

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20170623/893e0937/attachment.html>


More information about the webkit-unassigned mailing list