Bug 180408 - WebDriver: implement proxy support
Summary: WebDriver: implement proxy support
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebDriver (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-12-05 02:54 PST by Carlos Garcia Campos
Modified: 2019-11-11 16:57 PST (History)
13 users (show)

See Also:


Attachments
Patch (25.22 KB, patch)
2019-11-08 01:06 PST, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Patch (27.51 KB, patch)
2019-11-11 02:36 PST, Carlos Garcia Campos
clopez: review+
clopez: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2017-12-05 02:54:29 PST
https://w3c.github.io/webdriver/webdriver-spec.html#proxy
Comment 1 BJ Burg 2018-01-30 09:14:17 PST
safaridriver work tracked by <rdar://problem/36854985>. For safaridriver, we'd need WKWebView support for proxy settings that hook into the NSURLSession. I suppose other network stacks have similar settings to propagate.
Comment 2 Carlos Garcia Campos 2019-11-08 01:06:37 PST
Created attachment 383117 [details]
Patch
Comment 3 EWS Watchlist 2019-11-08 01:07:36 PST
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 4 Carlos Alberto Lopez Perez 2019-11-08 05:06:28 PST
Comment on attachment 383117 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=383117&action=review

> Source/WebDriver/WebDriverService.cpp:367
> +    if (proxy.type == "pac") {
> +        String autoconfigURL;
> +        if (!proxyObject.getString("proxyAutoconfigUrl"_s, autoconfigURL))
> +            return WTF::nullopt;
> +
> +        proxy.autoconfigURL = autoconfigURL;
> +        return proxy;
> +    }

This type of proxy doesn't seem to be handled.
Maybe returning an error is more according to the spec than silently accepting it and ignoring it?

> Source/WebDriver/WebDriverService.cpp:415
> +        if (proxyObject.getValue("socksProxy", value)) {
> +            String socksProxy;
> +            if (!value->asString(socksProxy))
> +                return WTF::nullopt;
> +
> +            proxy.socksURL = URL({ }, makeString("socks://", socksProxy));
> +            if (!proxy.socksURL->isValid())
> +                return WTF::nullopt;
> +
> +            RefPtr<JSON::Value> socksVersionValue;
> +            if (!proxyObject.getValue("socksVersion", socksVersionValue))
> +                return WTF::nullopt;
> +
> +            auto socksVersion = unsignedValue(*socksVersionValue);
> +            if (!socksVersion || socksVersion.value() > 255)
> +                return WTF::nullopt;
> +            proxy.socksVersion = socksVersion.value();
> +        }

socksVersionValue seems to be ignored when constructing socksURL.
It is true that webkit_network_proxy_settings_add_proxy_for_scheme() works with the three types of sock proxies if not a specific version is specified, but I think its better to be specific here is the user/application has requested a specific type of proxy.

This is my suggestion:
* proxy.socksURL should start with:
  - if socksVersionValue is invalid/missing or anything other than 4 or 5 -> socks:// 
  - if socksVersionValue is 4 and socksURL is an IP Adresss -> socks4:// 
  - if socksVersionValue is 4 and socksURL is a domain name -> socks4a:// 
  - if socksVersionValue is 5 -> socks5://
Comment 5 Carlos Garcia Campos 2019-11-08 06:06:04 PST
Comment on attachment 383117 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=383117&action=review

>> Source/WebDriver/WebDriverService.cpp:367
>> +    }
> 
> This type of proxy doesn't seem to be handled.
> Maybe returning an error is more according to the spec than silently accepting it and ignoring it?

Yes, I thought about it, I'll add a way to ask platform is a particular proxy types is supported.

>> Source/WebDriver/WebDriverService.cpp:415
>> +        }
> 
> socksVersionValue seems to be ignored when constructing socksURL.
> It is true that webkit_network_proxy_settings_add_proxy_for_scheme() works with the three types of sock proxies if not a specific version is specified, but I think its better to be specific here is the user/application has requested a specific type of proxy.
> 
> This is my suggestion:
> * proxy.socksURL should start with:
>   - if socksVersionValue is invalid/missing or anything other than 4 or 5 -> socks:// 
>   - if socksVersionValue is 4 and socksURL is an IP Adresss -> socks4:// 
>   - if socksVersionValue is 4 and socksURL is a domain name -> socks4a:// 
>   - if socksVersionValue is 5 -> socks5://

I had no idea how to specify the socks version, I'll do what you suggest here.
Comment 6 Carlos Garcia Campos 2019-11-11 02:36:59 PST
Created attachment 383257 [details]
Patch
Comment 7 Carlos Alberto Lopez Perez 2019-11-11 05:28:12 PST
Comment on attachment 383257 [details]
Patch

r=me. Thanks!
But before landing check build on wincairo EWS: It broke because platformSupportProxyType() is not defined there.
Comment 8 Carlos Garcia Campos 2019-11-11 07:13:56 PST
I forgot there's wincairo implementation of WebDriver
Comment 9 Carlos Garcia Campos 2019-11-11 07:16:23 PST
Committed r252323: <https://trac.webkit.org/changeset/252323>
Comment 10 Radar WebKit Bug Importer 2019-11-11 16:57:47 PST
<rdar://problem/57099330>