1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 // browser_tests.exe --gtest_filter=ProxySettingsApiTest.ProxyEventsInvalidProxy
9 error: "net::ERR_PROXY_CONNECTION_FAILED",
13 var empty_json_url = "";
16 // Install error handler and get the test server config.
17 chrome.proxy.onProxyError.addListener(function (error) {
18 chrome.test.assertEq(expected_error, error);
19 chrome.test.notifyPass();
21 chrome.test.getConfig(readConfigAndSetProxy);
24 function readConfigAndSetProxy(test_config) {
25 // Construct the URL used for XHRs and set the proxy settings.
26 empty_json_url = "http://127.0.0.1:" +
27 test_config.testServer.port +
28 "/extensions/api_test/proxy/events/empty.json";
30 // Set an invalid proxy and fire of a XHR. This should trigger proxy errors.
31 // There may be any number of proxy errors, as systems like safe browsing
32 // might start network traffic as well.
34 singleProxy: { host: "does.not.exist" }
36 var config = { rules: rules, mode: "fixed_servers" };
37 chrome.proxy.settings.set({'value': config}, sendFailingXHR);
40 function sendFailingXHR() {
41 var req = new XMLHttpRequest();
42 req.open("GET", empty_json_url, true);
43 req.onload = function () {
44 chrome.test.notifyFail("proxy settings should not work");
46 req.onerror = testDone;
51 // Do nothing. The test success/failure is decided in the event handler.