Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: chrome/test/data/extensions/api_test/proxy/events/invalid_proxy.js

Issue 16268017: GTTF: convert some tests in chrome to use EmbeddedTestServer patch nr 1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // proxy api test 5 // proxy api test
6 // browser_tests.exe --gtest_filter=ProxySettingsApiTest.ProxyEventsInvalidProxy 6 // browser_tests.exe --gtest_filter=ProxySettingsApiTest.ProxyEventsInvalidProxy
7 7
8 var expected_error = { 8 var expected_error = {
9 error: "net::ERR_PROXY_CONNECTION_FAILED", 9 error: "net::ERR_PROXY_CONNECTION_FAILED",
10 details: "", 10 details: "",
11 fatal: true 11 fatal: true
12 }; 12 };
13 var empty_json_url = ""; 13 var empty_json_url = "";
14 14
15 function test() { 15 function test() {
16 // Install error handler and get the test server config. 16 // Install error handler and get the test server config.
17 chrome.proxy.onProxyError.addListener(function (error) { 17 chrome.proxy.onProxyError.addListener(function (error) {
18 chrome.test.assertEq(expected_error, error); 18 chrome.test.assertEq(expected_error, error);
19 chrome.test.notifyPass(); 19 chrome.test.notifyPass();
20 }); 20 });
21 chrome.test.getConfig(readConfigAndSetProxy); 21 chrome.test.getConfig(readConfigAndSetProxy);
22 } 22 }
23 23
24 function readConfigAndSetProxy(test_config) { 24 function readConfigAndSetProxy(test_config) {
25 // Construct the URL used for XHRs and set the proxy settings. 25 // Construct the URL used for XHRs and set the proxy settings.
26 empty_json_url = "http://127.0.0.1:" + 26 empty_json_url = "http://127.0.0.1:" +
27 test_config.testServer.port + 27 test_config.testServer.port +
28 "/files/extensions/api_test/proxy/events/empty.json"; 28 "/extensions/api_test/proxy/events/empty.json";
29 29
30 // Set an invalid proxy and fire of a XHR. This should trigger proxy errors. 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 31 // There may be any number of proxy errors, as systems like safe browsing
32 // might start network traffic as well. 32 // might start network traffic as well.
33 var rules = { 33 var rules = {
34 singleProxy: { host: "does.not.exist" } 34 singleProxy: { host: "does.not.exist" }
35 }; 35 };
36 var config = { rules: rules, mode: "fixed_servers" }; 36 var config = { rules: rules, mode: "fixed_servers" };
37 chrome.proxy.settings.set({'value': config}, sendFailingXHR); 37 chrome.proxy.settings.set({'value': config}, sendFailingXHR);
38 } 38 }
39 39
40 function sendFailingXHR() { 40 function sendFailingXHR() {
41 var req = new XMLHttpRequest(); 41 var req = new XMLHttpRequest();
42 req.open("GET", empty_json_url, true); 42 req.open("GET", empty_json_url, true);
43 req.onload = function () { 43 req.onload = function () {
44 chrome.test.notifyFail("proxy settings should not work"); 44 chrome.test.notifyFail("proxy settings should not work");
45 } 45 }
46 req.onerror = testDone; 46 req.onerror = testDone;
47 req.send(null); 47 req.send(null);
48 } 48 }
49 49
50 function testDone() { 50 function testDone() {
51 // Do nothing. The test success/failure is decided in the event handler. 51 // Do nothing. The test success/failure is decided in the event handler.
52 } 52 }
53 53
54 test(); 54 test();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698