Skip to content

Commit 661a196

Browse files
committed
[js] Updates for proxy handling
1. proxy_test.js needs to run against Firefox 57+ now that we send w3c capabilities (e46eb57) 2. Chrome expects the noProxy config value to be a string while w3c accepts an array of strings 3. Handle a weird edge case for Firefox where noProxy matches just the hostname and not hostname + port
1 parent 8133499 commit 661a196

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

javascript/node/selenium-webdriver/chrome.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,16 @@ class Driver extends webdriver.WebDriver {
766766
opt_config instanceof Options ? opt_config.toCapabilities() :
767767
(opt_config || Capabilities.chrome());
768768

769+
// W3C spec requires noProxy value to be an array of strings, but Chrome
770+
// expects a single host as a string.
771+
let proxy = caps.get(Capability.PROXY);
772+
if (proxy && Array.isArray(proxy.noProxy)) {
773+
proxy.noProxy = proxy.noProxy[0];
774+
if (!proxy.noProxy) {
775+
proxy.noProxy = undefined;
776+
}
777+
}
778+
769779
return /** @type {!Driver} */(super.createSession(executor, caps));
770780
}
771781

javascript/node/selenium-webdriver/test/proxy_test.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ test.suite(function(env) {
104104
// clearing the network.proxy.no_proxies_on preference.
105105
.setFirefoxOptions(
106106
new firefox.Options()
107+
.setBinary(firefox.Channel.AURORA)
107108
.setPreference('network.proxy.no_proxies_on', ''))
108109
.setProxy(proxy)
109110
.build();
@@ -124,15 +125,10 @@ test.suite(function(env) {
124125
'This is the proxy landing page');
125126
});
126127

127-
// geckodriver does not support the bypass option, this must be configured
128-
// through profile preferences.
129-
test.ignore(env.browsers(
130-
Browser.FIREFOX,
131-
'legacy-' + Browser.FIREFOX)).
132128
it('can bypass proxy for specific hosts', async function() {
133129
await createDriver(proxy.manual({
134130
http: proxyServer.host(),
135-
bypass: helloServer.host()
131+
bypass: [helloServer.host()]
136132
}));
137133

138134
await driver.get(helloServer.url());
@@ -141,7 +137,9 @@ test.suite(function(env) {
141137
await driver.findElement({tagName: 'h3'}).getText(),
142138
'Hello, world!');
143139

144-
await driver.get(goodbyeServer.url());
140+
// For firefox the no proxy settings appear to match on hostname only.
141+
let url = goodbyeServer.url().replace(/127\.0\.0\.1/, 'localhost');
142+
await driver.get(url);
145143
assert.equal(await driver.getTitle(), 'Proxy page');
146144
assert.equal(
147145
await driver.findElement({tagName: 'h3'}).getText(),

0 commit comments

Comments
 (0)